diff options
author | peter <peter@FreeBSD.org> | 1997-05-15 22:46:24 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-05-15 22:46:24 +0000 |
commit | 4f40fe8334ad5f056e1d9105f23fe7ac859c39ba (patch) | |
tree | 3b2f0092fa216d9f61059ba94b7f10b5bacf9496 /contrib/cvs/src/parseinfo.c | |
parent | 8982e501c77217c860f79bba431f46a62b607a21 (diff) | |
download | FreeBSD-src-4f40fe8334ad5f056e1d9105f23fe7ac859c39ba.zip FreeBSD-src-4f40fe8334ad5f056e1d9105f23fe7ac859c39ba.tar.gz |
Import of cvs-1.9.9-970515 onto vendor branch.
Obtained from: cyclic.com
Diffstat (limited to 'contrib/cvs/src/parseinfo.c')
-rw-r--r-- | contrib/cvs/src/parseinfo.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/contrib/cvs/src/parseinfo.c b/contrib/cvs/src/parseinfo.c index c567ef8..1011965 100644 --- a/contrib/cvs/src/parseinfo.c +++ b/contrib/cvs/src/parseinfo.c @@ -7,6 +7,7 @@ */ #include "cvs.h" +#include "getline.h" /* * Parse the INFOFILE file for the specified REPOSITORY. Invoke CALLPROC for @@ -24,15 +25,16 @@ Parse_Info (infofile, repository, callproc, all) { int err = 0; FILE *fp_info; - char infopath[PATH_MAX]; - char line[MAXLINELEN]; + char *infopath; + char *line = NULL; + size_t line_allocated = 0; char *default_value = NULL; char *expanded_value= NULL; int callback_done, line_number; char *cp, *exp, *value, *srepos; const char *regex_err; - if (CVSroot == NULL) + if (CVSroot_original == NULL) { /* XXX - should be error maybe? */ error (0, 0, "CVSROOT variable not set"); @@ -40,10 +42,20 @@ Parse_Info (infofile, repository, callproc, all) } /* find the info file and open it */ - (void) sprintf (infopath, "%s/%s/%s", CVSroot, + infopath = xmalloc (strlen (CVSroot_directory) + + strlen (infofile) + + sizeof (CVSROOTADM) + + 10); + (void) sprintf (infopath, "%s/%s/%s", CVSroot_directory, CVSROOTADM, infofile); - if ((fp_info = fopen (infopath, "r")) == NULL) - return (0); /* no file -> nothing special done */ + fp_info = CVS_FOPEN (infopath, "r"); + if (fp_info == NULL) + { + /* If no file, don't do anything special. */ + if (!existence_error (errno)) + error (0, errno, "cannot open %s", infopath); + return 0; + } /* strip off the CVSROOT if repository was absolute */ srepos = Short_Repository (repository); @@ -54,7 +66,7 @@ Parse_Info (infofile, repository, callproc, all) /* search the info file for lines that match */ callback_done = line_number = 0; - while (fgets (line, sizeof (line), fp_info) != NULL) + while (getline (&line, &line_allocated, fp_info) >= 0) { line_number++; @@ -146,7 +158,10 @@ Parse_Info (infofile, repository, callproc, all) err += callproc (repository, expanded_value); callback_done = 1; } - (void) fclose (fp_info); + if (ferror (fp_info)) + error (0, errno, "cannot read %s", infopath); + if (fclose (fp_info) < 0) + error (0, errno, "cannot close %s", infopath); /* if we fell through and didn't callback at all, do the default */ if (callback_done == 0 && default_value != NULL) @@ -157,6 +172,9 @@ Parse_Info (infofile, repository, callproc, all) free (default_value); if (expanded_value != NULL) free (expanded_value); + free (infopath); + if (line != NULL) + free (line); return (err); } |