From owner-p4-projects@FreeBSD.ORG Tue Jun 2 03:34:52 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 276201065672; Tue, 2 Jun 2009 03:34:52 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE71D106564A for ; Tue, 2 Jun 2009 03:34:51 +0000 (UTC) (envelope-from dforsyth@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A1D588FC19 for ; Tue, 2 Jun 2009 03:34:51 +0000 (UTC) (envelope-from dforsyth@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n523YpKb020840 for ; Tue, 2 Jun 2009 03:34:51 GMT (envelope-from dforsyth@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n523Yp3x020838 for perforce@freebsd.org; Tue, 2 Jun 2009 03:34:51 GMT (envelope-from dforsyth@FreeBSD.org) Date: Tue, 2 Jun 2009 03:34:51 GMT Message-Id: <200906020334.n523Yp3x020838@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to dforsyth@FreeBSD.org using -f From: David Forsythe To: Perforce Change Reviews Cc: Subject: PERFORCE change 163332 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: Tue, 02 Jun 2009 03:34:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=163332 Change 163332 by dforsyth@squirrel on 2009/06/02 03:33:52 Finished read_file_to_text up. Need to move it. Affected files ... .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#4 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_info.c#4 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb.c#4 edit Differences ... ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#4 (text+ko) ==== @@ -43,6 +43,6 @@ struct pkg_info; -struct pkg_info *pkg_info_digest_info_from_text(const char *text); +struct pkg_info *pkg_info_parse_info_from_text(const char *text); #endif ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_info.c#4 (text+ko) ==== @@ -29,7 +29,7 @@ }; struct pkg_info * -pkg_info_digest_info_from_text(const char *text) +pkg_info_parse_info_from_text(const char *text) { struct pkg_info *pi; ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb.c#4 (text+ko) ==== @@ -7,6 +7,7 @@ #include #include #include +#include #include "pkg_util.h" #include "pkg_info.h" @@ -128,7 +129,7 @@ return (NULL); } - text = pkgdb_read_read_pkg_file_to_text(db, p, COMMENT_FILE); + text = pkgdb_read_file_to_text(db, p, COMMENT_FILE); pkg_set_comment(p, text); free(text); @@ -212,23 +213,30 @@ if (path == NULL) return (NULL); strcpy(path, dir); - strcat(path, '/'); + strcat(path, "/"); strcat(path, filename); s = stat(path, &sb); - if (s < 0 || !S_ISREG(st.st_mode)) { + if (s < 0 || !S_ISREG(sb.st_mode)) { free(path); return (NULL); } - fd = open(path, O_READONLY); - if (fd < 0) { - free(path); + fd = open(path, O_RDONLY); + free(path); + text = malloc(sb.st_size + 1); + if (fd < 0 || text == NULL) { + free(text); + return (NULL); + } + /* reuse s */ + s = read(fd, text, sb.st_size); + if (s < 0) { + free(text); return (NULL); } - + text[sb.st_size] = '\0'; - return (text); }