History

even faster

bellard committed 24 years ago

Commit 5d7f7bb1 parent 711075f1 file · +29 −19Browse files

Unified · Split

tcc.c+29−19
@@ -613,23 +613,32 @@ void sym_pop(SymStack *st, Sym *b) · 612 unmodified lines
613 st->top = b;613 st->top = b;
614}614}
615 615
616/* no need to put that inline */
617int handle_eof(void)
618{
619 if (include_stack_ptr == include_stack)
620 return -1;
621 /* pop include stack */
622 fclose(file);
623 free(filename);
624 include_stack_ptr--;
625 file = include_stack_ptr->file;
626 filename = include_stack_ptr->filename;
627 line_num = include_stack_ptr->line_num;
628 return 0;
629}
630
616/* read next char from current input file */631/* read next char from current input file */
617void inp(void)632static inline void inp(void)
618{633{
619 redo:634 redo:
620 /* faster than fgetc */635 /* faster than fgetc */
621 ch1 = getc_unlocked(file);636 ch1 = getc_unlocked(file);
622 if (ch1 == -1) {637 if (ch1 == -1) {
623 if (include_stack_ptr == include_stack)638 if (handle_eof() < 0)
624 return;639 return;
625 /* pop include stack */640 else
626 fclose(file);641 goto redo;
627 free(filename);
628 include_stack_ptr--;
629 file = include_stack_ptr->file;
630 filename = include_stack_ptr->filename;
631 line_num = include_stack_ptr->line_num;
632 goto redo;
633 }642 }
634 if (ch1 == '\n')643 if (ch1 == '\n')
635 line_num++;644 line_num++;
@@ -637,9 +646,9 @@ void inp(void) · 1 unmodified line
637}646}
638 647
639/* input with '\\n' handling */648/* input with '\\n' handling */
640void minp()649static inline void minp(void)
641{650{
642 redo:651 redo:
643 ch = ch1;652 ch = ch1;
644 inp();653 inp();
645 if (ch == '\\' && ch1 == '\n') {654 if (ch == '\\' && ch1 == '\n') {
@@ -649,8 +658,9 @@ void minp() · 3 unmodified lines
649 //printf("ch=%c 0x%x\n", ch, ch);658 //printf("ch=%c 0x%x\n", ch, ch);
650}659}
651 660
661
652/* same as minp, but also skip comments */662/* same as minp, but also skip comments */
653void cinp()663void cinp(void)
654{664{
655 int c;665 int c;
656 666
@@ -669,11 +679,11 @@ void cinp() · 12 unmodified lines
669 while (ch1 != -1) {679 while (ch1 != -1) {
670 c = ch1;680 c = ch1;
671 inp();681 inp();
672 if (c == '*' && ch1 == '/') {682 if (c == '*' && ch1 == '/') {
673 inp();683 inp();
674 ch = ' '; /* return space */684 ch = ' '; /* return space */
675 break;685 break;
676 }686 }
677 }687 }
678 } else {688 } else {
679 ch = '/';689 ch = '/';
@@ -683,7 +693,7 @@ void cinp() · 3 unmodified lines
683 }693 }
684}694}
685 695
686void skip_spaces()696void skip_spaces(void)
687{697{
688 while (ch == ' ' || ch == '\t')698 while (ch == ' ' || ch == '\t')
689 cinp();699 cinp();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t