PERFORCE change 123523 for review
Garrett Cooper
gcooper at FreeBSD.org
Sun Jul 15 06:23:30 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=123523
Change 123523 by gcooper at 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 <assert.h>
-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 <sys/file.h>
#include <sys/stat.h>
#include <sys/queue.h>
+#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <stdarg.h>
@@ -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]);
More information about the p4-projects
mailing list