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

Function buffer_fill

tools/tokenizer/ntokenize.c:386–436  ·  view source on GitHub ↗

Phase 3. Buffers up enough characters to encompass any possible token length. Assumes buffer contents is white-space followed by at least 1 token and contains 1 logical line. Tokens (but not comments) are assumed to fit on a logical line. */

Source from the content-addressed store, hash-verified

384 Tokens (but not comments) are assumed to fit on a logical line.
385*/
386int buffer_fill(void)
387{
388 int cc;
389 int ws;
390 int start_linenr = linenr;
391 buffered = 0;
392 while ((cc = filter(&ws)) != EOF && cc != '\n') {
393 if (ws) buffer_add(' ');
394 buffer_add(cc);
395 // special action for ": (cannot have this situation for ')
396 if (cc == '"') {
397 // Switch to unfiltered input till unescaped closing ":
398 if ((cc = get()) == '"') {
399 buffer_add(cc);
400 // An empty string literal.
401 continue;
402 }
403 if (cc == EOF || cc == '\n')
404 // unexpected EOF or newline in string
405 break;
406 buffer_add(cc);
407 int pc;
408 do {
409 pc = cc;
410 cc = get();
411 if (cc == EOF || cc == '\n')
412 // unexpected EOF or newline in string
413 goto break_outer;
414 buffer_add(cc);
415 } while (pc == '\\' || cc != '"');
416 // pc != '\\' && cc == '"'
417 }
418 }
419 break_outer:
420 // cc == EOF || cc == '\n'
421 // Note: line of only white-space will have nothing in buffer.
422
423 // Only deal with non-empty lines:
424 if (buffered) {
425 buffer_close();
426 // All white-space in buffer compressed to single ' '
427 // (except of course in string literal).
428
429 // Match tokens in buffer:
430 const char *p = buffer;
431 unsigned len;
432 while ((len = get_token(p, p-buffer)))
433 p += len;
434 }
435 return cc;
436}
437
438int main(int argc, char *argv[])
439{

Callers 1

mainFunction · 0.85

Calls 3

filterFunction · 0.85
get_tokenFunction · 0.85
getFunction · 0.70

Tested by

no test coverage detected