Ver código fonte

* lib/nfmalloc.c: in nfstrnsave, don't set the char after the end, but
set the end, to \0.
* lib/parse.c: Don't loose the last char of a field value, when EOF is
hit.

Adam Heath 25 anos atrás
pai
commit
082c6d9882
3 arquivos alterados com 10 adições e 4 exclusões
  1. 7 0
      ChangeLog
  2. 1 1
      lib/nfmalloc.c
  3. 2 3
      lib/parse.c

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+Sat Apr 28 15:22:25 CDT 2001 Adam Heath <doogie@debian.org>
+
+  * lib/nfmalloc.c: in nfstrnsave, don't set the char after the end, but
+    set the end, to \0.
+  * lib/parse.c: Don't loose the last char of a field value, when EOF is
+    hit.
+
 Sat Apr 28 14:31:27 CDT 2001 Adam Heath <doogie@debian.org>
 
   * scripts/dpkg-divert.pl, debian/changelog: Fix removing of diversions.

+ 1 - 1
lib/nfmalloc.c

@@ -60,7 +60,7 @@ char *nfstrnsave(const char *string, int l) {
   char *ret;
   OBSTACK_INIT;
   ret = obstack_copy (&db_obs, string, l + 1);
-  *(ret + l + 1) = 0;
+  *(ret + l) = 0;
   return ret;
 }
 

+ 2 - 3
lib/parse.c

@@ -123,7 +123,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
 
   lno= 1;
   pdone= 0;
-#define EOF_mmap(dataptr, endptr)	(dataptr >= endptr)
+#define EOF_mmap(dataptr, endptr)	(dataptr > endptr)
 #define getc_mmap(dataptr)		*dataptr++;
 #define ungetc_mmap(c, dataptr, data)	dataptr--;
 
@@ -172,7 +172,6 @@ int parsedb(const char *filename, enum parsedbflags flags,
       for (;;) {
         if (c == '\n' || c == MSDOS_EOF_CHAR) {
           lno++;
-	  if (EOF_mmap(dataptr, endptr)) break;
           c= getc_mmap(dataptr);
 /* Found double eol, or start of new field */
           if (EOF_mmap(dataptr, endptr) || c == '\n' || !isspace(c)) break;
@@ -185,7 +184,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
         }
         c= getc_mmap(dataptr);
       }
-      valuelen= dataptr - valuestart - 2;
+      valuelen= dataptr - valuestart - 1;
 /* trim ending space on value */
       while (valuelen && isspace(*(valuestart+valuelen-1)))
  valuelen--;