Mercurial > hg > octave-nkf
comparison src/variables.cc @ 2300:9484969866d2
[project @ 1996-06-24 07:13:26 by jwe]
author | jwe |
---|---|
date | Mon, 24 Jun 1996 07:15:11 +0000 |
parents | 46839fa1fcf3 |
children | c2c1482c34c8 |
comparison
equal
deleted
inserted
replaced
2299:f296bbc757a1 | 2300:9484969866d2 |
---|---|
409 // Eat whitespace and comments from FFILE, returning the text of the | 409 // Eat whitespace and comments from FFILE, returning the text of the |
410 // comments read if it doesn't look like a copyright notice. If | 410 // comments read if it doesn't look like a copyright notice. If |
411 // IN_PARTS, consider each block of comments separately; otherwise, | 411 // IN_PARTS, consider each block of comments separately; otherwise, |
412 // grab them all at once. | 412 // grab them all at once. |
413 | 413 |
414 // XXX FIXME XXX -- grab_help_text() in lex.l duplicates some of this | |
415 // code! | |
416 | |
414 static string | 417 static string |
415 gobble_leading_white_space (FILE *ffile, int in_parts) | 418 gobble_leading_white_space (FILE *ffile, int in_parts) |
416 { | 419 { |
417 string help_txt; | 420 string help_txt; |
418 | 421 |
419 int first_comments_seen = 0; | 422 bool first_comments_seen = false; |
420 int have_help_text = 0; | 423 bool begin_comment = false; |
421 int in_comment = 0; | 424 bool have_help_text = false; |
425 bool in_comment = false; | |
422 int c; | 426 int c; |
423 | 427 |
424 while ((c = getc (ffile)) != EOF) | 428 while ((c = getc (ffile)) != EOF) |
425 { | 429 { |
426 current_input_column++; | 430 current_input_column++; |
431 | |
432 if (begin_comment) | |
433 { | |
434 if (c == '%' || c == '#') | |
435 continue; | |
436 else | |
437 begin_comment = false; | |
438 } | |
427 | 439 |
428 if (in_comment) | 440 if (in_comment) |
429 { | 441 { |
430 if (! have_help_text) | 442 if (! have_help_text) |
431 { | 443 { |
432 first_comments_seen = 1; | 444 first_comments_seen = true; |
433 help_txt += (char) c; | 445 help_txt += (char) c; |
434 } | 446 } |
435 | 447 |
436 if (c == '\n') | 448 if (c == '\n') |
437 { | 449 { |
438 input_line_number++; | 450 input_line_number++; |
439 current_input_column = 0; | 451 current_input_column = 0; |
440 in_comment = 0; | 452 in_comment = false; |
441 | 453 |
442 if (in_parts) | 454 if (in_parts) |
443 { | 455 { |
444 if ((c = getc (ffile)) != EOF) | 456 if ((c = getc (ffile)) != EOF) |
445 { | 457 { |
458 switch (c) | 470 switch (c) |
459 { | 471 { |
460 case ' ': | 472 case ' ': |
461 case '\t': | 473 case '\t': |
462 if (first_comments_seen) | 474 if (first_comments_seen) |
463 have_help_text = 1; | 475 have_help_text = true; |
464 break; | 476 break; |
465 | 477 |
466 case '\n': | 478 case '\n': |
467 if (first_comments_seen) | 479 if (first_comments_seen) |
468 have_help_text = 1; | 480 have_help_text = true; |
469 input_line_number++; | 481 input_line_number++; |
470 current_input_column = 0; | 482 current_input_column = 0; |
471 continue; | 483 continue; |
472 | 484 |
473 case '%': | 485 case '%': |
474 case '#': | 486 case '#': |
475 in_comment = 1; | 487 begin_comment = true; |
488 in_comment = true; | |
476 break; | 489 break; |
477 | 490 |
478 default: | 491 default: |
479 current_input_column--; | 492 current_input_column--; |
480 ungetc (c, ffile); | 493 ungetc (c, ffile); |