From ce199d545bd9c50236a84ff6b5765890629a7264 Mon Sep 17 00:00:00 2001 From: hadaq Date: Fri, 19 Nov 2010 19:30:16 +0000 Subject: [PATCH] accept empty lines and #comments by wm --- libtrbnet/trbcmd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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); -- 2.43.0