MCPcopy Create free account
hub / github.com/NetHack/NetHack / get_next_line

Function get_next_line

win/share/tiletext.c:99–125  ·  view source on GitHub ↗

read next line; repeat until it's a non-comment; populates 'inbuf[]'; the buffer might already have data (first line after colormap) */

Source from the content-addressed store, hash-verified

97/* read next line; repeat until it's a non-comment; populates 'inbuf[]';
98 the buffer might already have data (first line after colormap) */
99static int
100get_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
127static void
128read_text_colormap(FILE *txtfile)

Callers 2

read_text_colormapFunction · 0.85
read_txttileFunction · 0.85

Calls 2

fgetcFunction · 0.85
fgetsFunction · 0.85

Tested by

no test coverage detected