From cf46dfb750863d760d19b9858b0a336b158275da Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 2 Sep 2002 05:50:28 +0000 Subject: Import cvs-1.11.2 onto vendor branch Obtained from: http://www.cvshome.org/ --- contrib/cvs/src/myndbm.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'contrib/cvs/src/myndbm.c') diff --git a/contrib/cvs/src/myndbm.c b/contrib/cvs/src/myndbm.c index 7795f66..600b3aa 100644 --- a/contrib/cvs/src/myndbm.c +++ b/contrib/cvs/src/myndbm.c @@ -19,7 +19,7 @@ #ifdef MY_NDBM -static void mydbm_load_file PROTO ((FILE *, List *)); +static void mydbm_load_file PROTO ((FILE *, List *, char *)); /* Returns NULL on error in which case errno has been set to indicate the error. Can also call error() itself. */ @@ -44,7 +44,7 @@ mydbm_open (file, flags, mode) if (fp != NULL) { - mydbm_load_file (fp, db->dbm_list); + mydbm_load_file (fp, db->dbm_list, file); if (fclose (fp) < 0) error (0, errno, "cannot close %s", file); } @@ -195,9 +195,10 @@ mydbm_store (db, key, value, flags) } static void -mydbm_load_file (fp, list) +mydbm_load_file (fp, list, filename) FILE *fp; List *list; + char *filename; /* Used in error messages. */ { char *line = NULL; size_t line_size; @@ -206,14 +207,17 @@ mydbm_load_file (fp, list) char *cp, *vp; int cont; int line_length; + int line_num; value_allocated = 1; value = xmalloc (value_allocated); cont = 0; + line_num=0; while ((line_length = getstr (&line, &line_size, fp, '\012', 0, GETLINE_NO_LIMIT)) >= 0) { + line_num++; if (line_length > 0 && line[line_length - 1] == '\012') { /* Strip the newline. */ @@ -280,21 +284,28 @@ mydbm_load_file (fp, list) kp = vp; while (*vp && !isspace ((unsigned char) *vp)) vp++; - *vp++ = '\0'; /* NULL terminate the key */ + if (*vp) + *vp++ = '\0'; /* NULL terminate the key */ p->type = NDBMNODE; p->key = xstrdup (kp); while (*vp && isspace ((unsigned char) *vp)) vp++; /* skip whitespace to value */ if (*vp == '\0') { - error (0, 0, "warning: NULL value for key `%s'", p->key); + if (!really_quiet) + error (0, 0, + "warning: NULL value for key `%s' at line %d of `%s'", + p->key, line_num, filename); freenode (p); continue; } p->data = xstrdup (vp); if (addnode (list, p) == -1) { - error (0, 0, "duplicate key found for `%s'", p->key); + if (!really_quiet) + error (0, 0, + "duplicate key found for `%s' at line %d of `%s'", + p->key, line_num, filename); freenode (p); } } -- cgit v1.1