MCPcopy Create free account
hub / github.com/IBM/Project_CodeNet / get

Function get

tools/tokenizer/ntokenize.c:263–299  ·  view source on GitHub ↗

Phase 1. Forms logical lines by resolving escaped newlines (line continuations). */

Source from the content-addressed store, hash-verified

261 Forms logical lines by resolving escaped newlines (line continuations).
262*/
263int get(void)
264{
265 int cc;
266 restart:
267 // Read a fresh char:
268 cc = normalize_newline(); // cc != '\r'
269 if (cc == EOF) return EOF;
270 char_count++;
271 if (utf8_start(cc)) utf8_count++;
272
273 if (cc == '\n') { // a normalized end-of-line (\r|\r?\n)
274 linenr++;
275 column = 0;
276 return cc; // \n here signals a logical end-of-line
277 }
278
279 // Deal with \ line continuations!
280 if (cc == '\\') {
281 // Must look ahead (never maintained across get calls!):
282 int nc = normalize_newline();
283 if (nc == '\n') { // 1 logical line: discard \\n combo:
284 char_count++; // counts the newline
285 utf8_count++;
286 linenr++; // on next physical line
287 column = 0;
288
289 // Still need to get a character.
290 // Could again start a line continuation!
291 goto restart;
292 }
293 // Mind nc not \n. ungetc(EOF) is Okay.
294 ungetc(nc, stdin);
295 // cc == '\\' a regular backslash
296 }
297 column++;
298 return cc;
299}
300
301/* Phase 2.
302 Removes line and block comments and condenses white-space up to a newline.

Callers 2

filterFunction · 0.70
buffer_fillFunction · 0.70

Calls 1

normalize_newlineFunction · 0.70

Tested by

no test coverage detected