Procházet zdrojové kódy

properly chomp lines

Wichert Akkerman před 26 roky
rodič
revize
690c13620d
2 změnil soubory, kde provedl 7 přidání a 1 odebrání
  1. 4 0
      ChangeLog
  2. 3 1
      lib/myopt.c

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+Thu Nov 23 19:13:21 CET 2000 Wichert Akkerman <wakkerma@debian.org>
+
+  * lib/myopt.c: properly chomp read lines
+
 Thu Nov 23 17:52:44 CET 2000 Wichert Akkerman <wakkerma@debian.org>
 Thu Nov 23 17:52:44 CET 2000 Wichert Akkerman <wakkerma@debian.org>
 
 
   * lib/fields.c, lib/dump.c: fix two memory leaks
   * lib/fields.c, lib/dump.c: fix two memory leaks

+ 3 - 1
lib/myopt.c

@@ -41,9 +41,11 @@ void myfileopt(const char* fn, const struct cmdinfo* cmdinfos) {
   while (fgets(linebuf, sizeof(linebuf), file)) {
   while (fgets(linebuf, sizeof(linebuf), file)) {
     char* opt;
     char* opt;
     const struct cmdinfo *cip;
     const struct cmdinfo *cip;
+    int l;
 
 
     if ((linebuf[0]=='#') || (linebuf[0]=='\n') || (linebuf[0]==0)) continue;
     if ((linebuf[0]=='#') || (linebuf[0]=='\n') || (linebuf[0]==0)) continue;
-    linebuf[strlen(linebuf)-1]=0;
+    l=strlen(linebuf);
+    if (linebuf[l-1]=='\n') linebuf[l-1]=0;
     for (opt=linebuf;isalnum(*opt)||*opt=='-';opt++) ;
     for (opt=linebuf;isalnum(*opt)||*opt=='-';opt++) ;
     if (*opt==0)
     if (*opt==0)
       opt=NULL;
       opt=NULL;