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

Function normalize_newline

tools/tokenizer/ntokenize.c:239–258  ·  view source on GitHub ↗

Deal with DOS (\r \n) and classic Mac OS (\r) line endings. Keeps track of physical coordinates and absolute location for each character. */

Source from the content-addressed store, hash-verified

237 Keeps track of physical coordinates and absolute location for each character.
238*/
239int normalize_newline(void)
240{
241 int cc = getchar();
242
243 if (cc == '\r') {
244 // Maybe \r \n (CR NL) combination?
245 int nc = getchar();
246 if (nc == '\n') {
247 char_count++; // counts the carriage return
248 utf8_count++;
249 // No use incrementing column.
250 return nc; // return \n; effectively skipping the \r
251 }
252 // Mind nc not \n. ungetc(EOF) is Okay.
253 ungetc(nc, stdin);
254 // cc == '\r'; consider a newline as well, so turn into \n:
255 cc = '\n';
256 }
257 return cc;
258}
259
260/* Phase 1.
261 Forms logical lines by resolving escaped newlines (line continuations).

Callers 1

getFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected