From owner-p4-projects@FreeBSD.ORG Sun Jul 15 06:23:30 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4C0BD16A402; Sun, 15 Jul 2007 06:23:30 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0AE1416A400 for ; Sun, 15 Jul 2007 06:23:30 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id EE5B713C442 for ; Sun, 15 Jul 2007 06:23:29 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6F6NTdE026335 for ; Sun, 15 Jul 2007 06:23:29 GMT (envelope-from gcooper@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6F6NT6q026332 for perforce@freebsd.org; Sun, 15 Jul 2007 06:23:29 GMT (envelope-from gcooper@FreeBSD.org) Date: Sun, 15 Jul 2007 06:23:29 GMT Message-Id: <200707150623.l6F6NT6q026332@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gcooper@FreeBSD.org using -f From: Garrett Cooper To: Perforce Change Reviews Cc: Subject: PERFORCE change 123523 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2007 06:23:30 -0000 http://perforce.freebsd.org/chv.cgi?CH=123523 Change 123523 by gcooper@optimus-revised_pkgtools on 2007/07/15 06:23:14 lib/exec.c: Whitespace and make hardcoded integers into constants. lib/lib.h: -Add #include -Get rid of constants I defined for profiling and buffering. -Add function prototypes. lib/match.c: Minor logic change and move int len declaration to function header. Affected files ... .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/exec.c#2 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/lib.h#4 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/match.c#2 edit Differences ... ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/exec.c#2 (text+ko) ==== @@ -29,6 +29,9 @@ * builds and executes command. Returns exit code. */ +/* some slop for the sh -c */ +#define SH_SLOP 32 + int vsystem(const char *fmt, ...) { @@ -36,8 +39,8 @@ char *cmd; int ret, maxargs; - maxargs = sysconf(_SC_ARG_MAX); - maxargs -= 32; /* some slop for the sh -c */ + maxargs = sysconf(_SC_ARG_MAX) - SH_SLOP; + cmd = malloc(maxargs); if (!cmd) { warnx("vsystem can't alloc arg space"); @@ -61,18 +64,19 @@ char * vpipe(const char *fmt, ...) { - FILE *fp; - char *cmd, *rp; - int maxargs; - va_list args; + FILE *fp; + char *cmd, *rp; + int maxargs; + va_list args; rp = malloc(MAXPATHLEN); if (!rp) { warnx("vpipe can't alloc buffer space"); return NULL; } - maxargs = sysconf(_SC_ARG_MAX); - maxargs -= 32; /* some slop for the sh -c */ + + maxargs = sysconf(_SC_ARG_MAX) - SH_SLOP; + cmd = alloca(maxargs); if (!cmd) { warnx("vpipe can't alloc arg space"); ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/lib.h#4 (text+ko) ==== @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -105,17 +106,6 @@ #define PLIST_FMT_VER_MAJOR 1 #define PLIST_FMT_VER_MINOR 1 -#define BUFFER_TRY 1 -#define SIMPLE_PROF_TRY 1 - -#ifndef BUFFER_TRY -#define BUFFER_TRY 0 -#endif - -#ifndef SIMPLE_PROF_TRY -#define SIMPLE_PROF_TRY 0 -#endif - enum _plist_t { PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD, PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE, @@ -171,16 +161,12 @@ off_t min_free(const char *); //static char *find_playpen(char *, off_t); -#if SIMPLE_PROF_TRY - char *make_playpen_np(char *, off_t); void leave_playpen_np(void); char *find_playpen_np(char *, off_t); char* run_generic_playpen_prof(char *fn_name, ...); -#endif - /* String */ char *get_dash_string(char **); char *copy_string(const char *); @@ -202,7 +188,8 @@ Boolean isURL(const char *); char *fileGetURL(const char *, const char *, int); char *fileFindByPath(const char *, const char *); -char *fileGetContents(const char *); +char *fileGetContentsByFilename(const char *); +char *fileGetContentsByDescriptor(FILE *, const char *); void write_file(const char *, const char *); void copy_file(const char *, const char *, const char *); void move_file(const char *, const char *, const char *); @@ -211,9 +198,7 @@ int unpack(const char *, const char *); void format_cmd(char *, int, const char *, const char *, const char *); -#if SIMPLE_PROF_TRY int delete_hierarchy_np(const char *, Boolean, Boolean); -#endif /* Msg */ void upchuck(const char *); @@ -239,18 +224,17 @@ int delete_package(Boolean, Boolean, Package *); Boolean make_preserve_name(char *, int, const char *, const char *); -#if SIMPLE_PROF_TRY - int run_generic_plist_prof(char *fn_name, ...); void add_plist_np(Package *, plist_t, const char *); void add_plist_top_np(Package *, plist_t, const char *); void delete_plist_np(Package *pkg, Boolean all, plist_t type, const char *name); void write_plist_np(Package *, FILE *); -void read_plist_np(Package *, FILE *); +void read_plist_old_np(Package *, FILE *); int plist_cmd_np(const char *, char **); int delete_package_np(Boolean, Boolean, Package *); -#endif +void read_plist_np(Package *, FILE *); +int trim_end_whitespace(char *); /* For all */ int pkg_perform(char **); ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/match.c#2 (text+ko) ==== @@ -242,6 +242,7 @@ { char **installed; int i; + int len; static struct store *store = NULL; store = storecreate(store); @@ -278,17 +279,20 @@ } cmd = -1; + while (fgets(tmp, sizeof(tmp), fp)) { - int len = strlen(tmp); + + if( 0 == (len = strlen(tmp)) && *cp != CMD_CHAR ) + continue; while (len && isspace(tmp[len - 1])) tmp[--len] = '\0'; if (!len) continue; + cp = tmp; - if (tmp[0] != CMD_CHAR) - continue; - cmd = plist_cmd(tmp + 1, &cp); + + cmd = plist_cmd(tmp+1, &cp); if (cmd == PLIST_ORIGIN) { if (csh_match(origin, cp, FNM_PATHNAME) == 0) storeappend(store, installed[i]);