From: hadaq Date: Fri, 19 Nov 2010 19:30:16 +0000 (+0000) Subject: accept empty lines and #comments by wm X-Git-Tag: v6.0~174 X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=ce199d545bd9c50236a84ff6b5765890629a7264;p=trbnettools.git accept empty lines and #comments by wm --- diff --git a/libtrbnet/trbcmd.c b/libtrbnet/trbcmd.c index d81f260..1c27cad 100644 --- a/libtrbnet/trbcmd.c +++ b/libtrbnet/trbcmd.c @@ -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);