# HG changeset patch # User Mychaela Falconia # Date 1615089529 0 # Node ID fc1635333d813ccbf8152d6efd079ad6f89d3dee # Parent bca0f86d9efeb4d4ad65a3927c7d0f3f5fd93b77 allow comments in hex data files diff -r bca0f86d9efe -r fc1635333d81 libutil/hexread.c --- a/libutil/hexread.c Sun Mar 07 03:41:06 2021 +0000 +++ b/libutil/hexread.c Sun Mar 07 03:58:49 2021 +0000 @@ -24,12 +24,18 @@ perror(filename); return(-1); } - for (count = 0; ; count++) { + for (count = 0; ; ) { do c = getc(inf); while (isspace(c)); if (c < 0) break; + if (c == '#') { + do + c = getc(inf); + while (c >= 0 && c != '\n'); + continue; + } if (!isxdigit(c)) { inv_input: fprintf(stderr, "%s: invalid hex file input\n", filename); @@ -45,8 +51,8 @@ fclose(inf); return(-1); } - databuf[count] = (decode_hex_digit(c) << 4) | - decode_hex_digit(c2); + databuf[count++] = (decode_hex_digit(c) << 4) | + decode_hex_digit(c2); } fclose(inf); if (!count) {