PERFORCE change 123511 for review
Garrett Cooper
gcooper at FreeBSD.org
Sun Jul 15 00:51:24 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=123511
Change 123511 by gcooper at optimus-revised_pkgtools on 2007/07/15 00:50:56
Much faster way to read a packing list. Inspired by Tim Kientzle (kientzle).
Affected files ...
.. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/plist.c#7 edit
Differences ...
==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/plist.c#7 (text+ko) ====
@@ -309,7 +309,7 @@
}
++cp, ++sp;
}
- printf("COMMAND STRING: %s\nCMD: %s\nCP: %s\nSP: %s\n", s, cmd, cp, sp);
+ printf("COMMAND STRING: %s\nCMD"/*: %s\nCP: %s\nSP: %s\n"*/, s/*, cmd, cp, sp*/);
if(!*(cmd+1))
return FAIL;
@@ -422,8 +422,6 @@
int cmd;
- unsigned int i = 0;
-
pkg->fmtver_maj = 1;
pkg->fmtver_mnr = 2;
pkg->origin = NULL;
@@ -434,18 +432,12 @@
/* Empty file -- don't attempt to process */
assert(contents_stat.st_size != 0);
- plines = (char*) malloc(contents_stat.st_size);
+ plines = (char*) malloc(contents_stat.st_size+1);
- for(i = 0; !feof(fp) && i < contents_stat.st_size; i++)
- *(plines+i) = fgetc(fp);
-
-// printf("+CONTENTS DUMP: %s\n", plines);
-
- /* Avoid strangely crafted files with zero-length, but non-zero size */
- assert(0 != i);
+ assert(contents_stat.st_size == read(fileno(fp), plines, contents_stat.st_size+1));
/* Just in case file doesn't have EOF */
- *(plines+i) = '\0';
+ *(plines+contents_stat.st_size) = '\0';
pline = strtok(plines, "\n");
More information about the p4-projects
mailing list