summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src/myndbm.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2002-09-02 05:50:28 +0000
committerpeter <peter@FreeBSD.org>2002-09-02 05:50:28 +0000
commitcf46dfb750863d760d19b9858b0a336b158275da (patch)
tree8440832ece5130fad994f5f3489b01676ab1ca4a /contrib/cvs/src/myndbm.c
parent92c0df1bed708821e09e92931a5309cd3abd82fb (diff)
downloadFreeBSD-src-cf46dfb750863d760d19b9858b0a336b158275da.zip
FreeBSD-src-cf46dfb750863d760d19b9858b0a336b158275da.tar.gz
Import cvs-1.11.2 onto vendor branch
Obtained from: http://www.cvshome.org/
Diffstat (limited to 'contrib/cvs/src/myndbm.c')
-rw-r--r--contrib/cvs/src/myndbm.c23
1 files changed, 17 insertions, 6 deletions
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);
}
}
OpenPOWER on IntegriCloud