OSDN Git Service

xphung on github said: "config2help currently doesn't work on OS X, it
authorRob Landley <rob@landley.net>
Mon, 1 Jan 2018 17:24:48 +0000 (11:24 -0600)
committerRob Landley <rob@landley.net>
Mon, 1 Jan 2018 17:24:48 +0000 (11:24 -0600)
terminates parsing of Config.in at first blank line. This is because
getdelim() in portability.c returns -1 whenever the line comprises only
a single linefeed character. Fixing this was a trivial change to two lines
(see below), and config2help now works on OS X but I haven't regression
tested this on any other commands which rely on getdelim()"

lib/portability.c

index 78e500b..38cf5cb 100644 (file)
@@ -61,9 +61,8 @@ ssize_t getdelim(char **linep, size_t *np, int delim, FILE *stream)
       line = *linep = new_line;
     }
 
-    line[i] = ch;
+    line[i++] = ch;
     if (ch == delim) break;
-    i += 1;
   }
 
   if (i > *np) {
@@ -74,7 +73,7 @@ ssize_t getdelim(char **linep, size_t *np, int delim, FILE *stream)
     *np = new_len;
     line = *linep = new_line;
   }
-  line[i + 1] = '\0';
+  line[i] = '\0';
 
   return i > 0 ? i : -1;
 }