read next line; repeat until it's a non-comment; populates 'inbuf[]'; the buffer might already have data (first line after colormap) */
| 97 | /* read next line; repeat until it's a non-comment; populates 'inbuf[]'; |
| 98 | the buffer might already have data (first line after colormap) */ |
| 99 | static int |
| 100 | get_next_line(FILE *txtfile, boolean force) |
| 101 | { |
| 102 | int ch; |
| 103 | |
| 104 | for (;;) { |
| 105 | if (force || !inbuf[0]) { |
| 106 | /* skip leading whitespace */ |
| 107 | do { |
| 108 | ch = fgetc(txtfile); |
| 109 | } while (ch == ' '); |
| 110 | ungetc(ch, txtfile); |
| 111 | /* get rest of line */ |
| 112 | if (!fgets(inbuf, BUFSZ, txtfile)) |
| 113 | break; |
| 114 | force = TRUE; |
| 115 | /* ignore blank lines; |
| 116 | the old fscanf() processing did that, possibly by accident */ |
| 117 | if (!inbuf[0] || (inbuf[0] == '\n' && !inbuf[1])) |
| 118 | continue; |
| 119 | } |
| 120 | if (inbuf[0] != '#' || !strncmp(inbuf, "# tile ", 7)) |
| 121 | return 1; |
| 122 | } |
| 123 | inbuf[0] = '\0'; |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | static void |
| 128 | read_text_colormap(FILE *txtfile) |
no test coverage detected