Date: Sun, 15 Jul 2007 00:51:24 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 123511 for review Message-ID: <200707150051.l6F0pOrl084910@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123511 Change 123511 by gcooper@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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707150051.l6F0pOrl084910>