]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
accept empty lines and #comments by wm
authorhadaq <hadaq>
Fri, 19 Nov 2010 19:30:16 +0000 (19:30 +0000)
committerhadaq <hadaq>
Fri, 19 Nov 2010 19:30:16 +0000 (19:30 +0000)
libtrbnet/trbcmd.c

index d81f260d16d48898a06e49f1e4ac4278222835a7..1c27cad37ac3273369431ce25a42e471c7cbbf3c 100644 (file)
@@ -25,7 +25,7 @@
                                          
 static int hexMode = HEXMODE;
 
-static const char trbcmd_version[] = "$Revision: 2.62 $";
+static const char trbcmd_version[] = "$Revision: 2.63 $";
 
 #define BACKLOG 10
 static uint16_t tcp_port = 55555;
@@ -631,12 +631,23 @@ int start(int argc, char **argv)
           abort();
 
         while (getline(&line, &len, file) != -1) {
+          char* c = NULL;
+          
           if (size >= dataSize) {
             dataSize += 64;
             data = (uint32_t *) realloc(data, sizeof(uint32_t) * dataSize);
             if (data == NULL)
               abort();
           }
+          
+          /* Remove newline and comments */
+          if ((c = strchr(line, '\n')) != NULL) {
+            *c = '\0';
+          }
+          if ((c = strchr(line, '#')) != NULL) {
+            *c = '\0';
+          }
+          if (strlen(line) == 0) continue; 
           data[size++] = strtoul(line, NULL, hexMode == 1 ? 16 : 0);
         }
         free(line);