Showing the changes to ctangle.c (1 of 16 files). Show all
Unified · Split
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | #include <stdio.h> | 7 | #include <stdio.h> |
| 8 | 8 | ||
| 9 | /*:6*//*62:*/ | 9 | /*:6*//*62:*/ |
| 10 | #line 874 "ctangle.w" | 10 | #line 875 "ctangle.w" |
| 11 | 11 | ||
| 12 | #include <ctype.h> | 12 | #include <ctype.h> |
| 13 | #include <stdlib.h> | 13 | #include <stdlib.h> |
| @@ -15,7 +15,7 @@ · 1 unmodified line | |||
| 15 | /*:62*/ | 15 | /*:62*/ |
| 16 | #line 62 "ctangle.w" | 16 | #line 62 "ctangle.w" |
| 17 | 17 | ||
| 18 | #define banner "This is CTANGLE (Version 3.2)\n" \ | 18 | #define banner "This is CTANGLE (Version 3.3)\n" \ |
| 19 | 19 | ||
| 20 | #define max_bytes 90000 \ | 20 | #define max_bytes 90000 \ |
| 21 | 21 | ||
| @@ -47,15 +47,15 @@ · 25 unmodified lines | |||
| 47 | #define period_ast 026 | 47 | #define period_ast 026 |
| 48 | #define minus_gt_ast 027 \ | 48 | #define minus_gt_ast 027 \ |
| 49 | 49 | ||
| 50 | #define xisalpha(c)(isalpha(c)&&((eight_bits)c<0200)) | 50 | #define xisalpha(c) (isalpha(c) &&((eight_bits) c<0200) ) |
| 51 | #define xisdigit(c)(isdigit(c)&&((eight_bits)c<0200)) | 51 | #define xisdigit(c) (isdigit(c) &&((eight_bits) c<0200) ) |
| 52 | #define xisspace(c)(isspace(c)&&((eight_bits)c<0200)) | 52 | #define xisspace(c) (isspace(c) &&((eight_bits) c<0200) ) |
| 53 | #define xislower(c)(islower(c)&&((eight_bits)c<0200)) | 53 | #define xislower(c) (islower(c) &&((eight_bits) c<0200) ) |
| 54 | #define xisupper(c)(isupper(c)&&((eight_bits)c<0200)) | 54 | #define xisupper(c) (isupper(c) &&((eight_bits) c<0200) ) |
| 55 | #define xisxdigit(c)(isxdigit(c)&&((eight_bits)c<0200)) \ | 55 | #define xisxdigit(c) (isxdigit(c) &&((eight_bits) c<0200) ) \ |
| 56 | 56 | ||
| 57 | #define length(c)(c+1)->byte_start-(c)->byte_start | 57 | #define length(c) (c+1) ->byte_start-(c) ->byte_start |
| 58 | #define print_id(c)term_write((c)->byte_start,length((c))) | 58 | #define print_id(c) term_write((c) ->byte_start,length((c) ) ) |
| 59 | #define llink link | 59 | #define llink link |
| 60 | #define rlink dummy.Rlink | 60 | #define rlink dummy.Rlink |
| 61 | #define root name_dir->rlink \ | 61 | #define root name_dir->rlink \ |
| @@ -66,9 +66,9 @@ · 4 unmodified lines | |||
| 66 | #define harmless_message 1 | 66 | #define harmless_message 1 |
| 67 | #define error_message 2 | 67 | #define error_message 2 |
| 68 | #define fatal_message 3 | 68 | #define fatal_message 3 |
| 69 | #define mark_harmless {if(history==spotless)history= harmless_message;} | 69 | #define mark_harmless {if(history==spotless) history= harmless_message;} |
| 70 | #define mark_error history= error_message | 70 | #define mark_error history= error_message |
| 71 | #define confusion(s)fatal("! This can't happen: ",s) \ | 71 | #define confusion(s) fatal("! This can't happen: ",s) \ |
| 72 | 72 | ||
| 73 | #define max_file_name_length 60 | 73 | #define max_file_name_length 60 |
| 74 | #define cur_file file[include_depth] | 74 | #define cur_file file[include_depth] |
| @@ -80,12 +80,12 @@ · 5 unmodified lines | |||
| 80 | #define show_progress flags['p'] | 80 | #define show_progress flags['p'] |
| 81 | #define show_happiness flags['h'] \ | 81 | #define show_happiness flags['h'] \ |
| 82 | 82 | ||
| 83 | #define update_terminal fflush(stdout) | 83 | #define update_terminal fflush(stdout) |
| 84 | #define new_line putchar('\n') | 84 | #define new_line putchar('\n') |
| 85 | #define putxchar putchar | 85 | #define putxchar putchar |
| 86 | #define term_write(a,b)fflush(stdout),fwrite(a,sizeof(char),b,stdout) | 86 | #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) |
| 87 | #define C_printf(c,a)fprintf(C_file,c,a) | 87 | #define C_printf(c,a) fprintf(C_file,c,a) |
| 88 | #define C_putc(c)putc(c,C_file) \ | 88 | #define C_putc(c) putc(c,C_file) \ |
| 89 | 89 | ||
| 90 | #define equiv equiv_or_xref \ | 90 | #define equiv equiv_or_xref \ |
| 91 | 91 | ||
| @@ -93,7 +93,7 @@ · 1 unmodified line | |||
| 93 | 93 | ||
| 94 | #define string 02 | 94 | #define string 02 |
| 95 | #define join 0177 | 95 | #define join 0177 |
| 96 | #define output_defs_flag (2*024000-1) \ | 96 | #define output_defs_flag (2*024000-1) \ |
| 97 | 97 | ||
| 98 | #define cur_end cur_state.end_field | 98 | #define cur_end cur_state.end_field |
| 99 | #define cur_byte cur_state.byte_field | 99 | #define cur_byte cur_state.byte_field |
| @@ -125,14 +125,14 @@ · 25 unmodified lines | |||
| 125 | 125 | ||
| 126 | #define constant 03 \ | 126 | #define constant 03 \ |
| 127 | 127 | ||
| 128 | #define isxalpha(c)((c)=='_') | 128 | #define isxalpha(c) ((c) =='_') |
| 129 | #define ishigh(c)((unsigned char)(c)>0177) \ | 129 | #define ishigh(c) ((unsigned char) (c) >0177) \ |
| 130 | \ | 130 | \ |
| 131 | 131 | ||
| 132 | #define compress(c)if(loc++<=limit)return(c) \ | 132 | #define compress(c) if(loc++<=limit) return(c) \ |
| 133 | 133 | ||
| 134 | #define macro 0 | 134 | #define macro 0 |
| 135 | #define app_repl(c){if(tok_ptr==tok_mem_end)overflow("token");*tok_ptr++= c;} \ | 135 | #define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \ |
| 136 | 136 | ||
| 137 | 137 | ||
| 138 | #line 63 "ctangle.w" | 138 | #line 63 "ctangle.w" |
| @@ -345,15 +345,16 @@ boolean comment_continues= 0; · 206 unmodified lines | |||
| 345 | #line 871 "ctangle.w" | 345 | #line 871 "ctangle.w" |
| 346 | 346 | ||
| 347 | name_pointer cur_section_name; | 347 | name_pointer cur_section_name; |
| 348 | int no_where; | ||
| 348 | 349 | ||
| 349 | /*:61*//*75:*/ | 350 | /*:61*//*75:*/ |
| 350 | #line 1181 "ctangle.w" | 351 | #line 1185 "ctangle.w" |
| 351 | 352 | ||
| 352 | text_pointer cur_text; | 353 | text_pointer cur_text; |
| 353 | eight_bits next_control; | 354 | eight_bits next_control; |
| 354 | 355 | ||
| 355 | /*:75*//*82:*/ | 356 | /*:75*//*82:*/ |
| 356 | #line 1328 "ctangle.w" | 357 | #line 1335 "ctangle.w" |
| 357 | 358 | ||
| 358 | extern sixteen_bits section_count; | 359 | extern sixteen_bits section_count; |
| 359 | 360 | ||
| @@ -382,15 +383,15 @@ void output_defs(); · 22 unmodified lines | |||
| 382 | /*:46*//*48:*/ | 383 | /*:46*//*48:*/ |
| 383 | #line 642 "ctangle.w" | 384 | #line 642 "ctangle.w" |
| 384 | 385 | ||
| 385 | void out_char(); | 386 | static void out_char(); |
| 386 | 387 | ||
| 387 | /*:48*//*90:*/ | 388 | /*:48*//*90:*/ |
| 388 | #line 1434 "ctangle.w" | 389 | #line 1442 "ctangle.w" |
| 389 | 390 | ||
| 390 | void phase_one(); | 391 | void phase_one(); |
| 391 | 392 | ||
| 392 | /*:90*//*92:*/ | 393 | /*:90*//*92:*/ |
| 393 | #line 1452 "ctangle.w" | 394 | #line 1460 "ctangle.w" |
| 394 | 395 | ||
| 395 | void skip_limbo(); | 396 | void skip_limbo(); |
| 396 | 397 | ||
| @@ -457,7 +458,7 @@ ccode['\'']= ord; · 60 unmodified lines | |||
| 457 | } | 458 | } |
| 458 | 459 | ||
| 459 | /*:57*//*71:*/ | 460 | /*:57*//*71:*/ |
| 460 | #line 1105 "ctangle.w" | 461 | #line 1106 "ctangle.w" |
| 461 | section_text[0]= ' '; | 462 | section_text[0]= ' '; |
| 462 | 463 | ||
| 463 | /*:71*/ | 464 | /*:71*/ |
| @@ -717,7 +718,7 @@ pop_level(0); · 253 unmodified lines | |||
| 717 | /*:47*//*49:*/ | 718 | /*:47*//*49:*/ |
| 718 | #line 645 "ctangle.w" | 719 | #line 645 "ctangle.w" |
| 719 | 720 | ||
| 720 | void | 721 | static void |
| 721 | out_char(cur_char) | 722 | out_char(cur_char) |
| 722 | eight_bits cur_char; | 723 | eight_bits cur_char; |
| 723 | { | 724 | { |
| @@ -861,7 +862,7 @@ else loc++; · 137 unmodified lines | |||
| 861 | } | 862 | } |
| 862 | 863 | ||
| 863 | /*:60*//*63:*/ | 864 | /*:60*//*63:*/ |
| 864 | #line 885 "ctangle.w" | 865 | #line 886 "ctangle.w" |
| 865 | 866 | ||
| 866 | eight_bits | 867 | eight_bits |
| 867 | get_next() | 868 | get_next() |
| @@ -872,10 +873,10 @@ while(1){ · 4 unmodified lines | |||
| 872 | if(loc>limit){ | 873 | if(loc>limit){ |
| 873 | if(preprocessing&&*(limit-1)!='\\')preprocessing= 0; | 874 | if(preprocessing&&*(limit-1)!='\\')preprocessing= 0; |
| 874 | if(get_line()==0)return(new_section); | 875 | if(get_line()==0)return(new_section); |
| 875 | else if(print_where){ | 876 | else if(print_where&&!no_where){ |
| 876 | print_where= 0; | 877 | print_where= 0; |
| 877 | /*77:*/ | 878 | /*77:*/ |
| 878 | #line 1208 "ctangle.w" | 879 | #line 1215 "ctangle.w" |
| 879 | 880 | ||
| 880 | store_two_bytes(0150000); | 881 | store_two_bytes(0150000); |
| 881 | if(changing)id_first= change_file_name; | 882 | if(changing)id_first= change_file_name; |
| @@ -883,11 +884,11 @@ else id_first= cur_file_name; · 1 unmodified line | |||
| 883 | id_loc= id_first+strlen(id_first); | 884 | id_loc= id_first+strlen(id_first); |
| 884 | if(changing)store_two_bytes((sixteen_bits)change_line); | 885 | if(changing)store_two_bytes((sixteen_bits)change_line); |
| 885 | else store_two_bytes((sixteen_bits)cur_line); | 886 | else store_two_bytes((sixteen_bits)cur_line); |
| 886 | {int a= id_lookup(id_first,id_loc)-name_dir;app_repl((a/0400)+0200); | 887 | {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200); |
| 887 | app_repl(a%0400);} | 888 | app_repl(a%0400);} |
| 888 | 889 | ||
| 889 | /*:77*/ | 890 | /*:77*/ |
| 890 | #line 897 "ctangle.w" | 891 | #line 898 "ctangle.w" |
| 891 | ; | 892 | ; |
| 892 | } | 893 | } |
| 893 | else return('\n'); | 894 | else return('\n'); |
| @@ -901,7 +902,7 @@ else continue; · 7 unmodified lines | |||
| 901 | } | 902 | } |
| 902 | loc++; | 903 | loc++; |
| 903 | if(xisdigit(c)||c=='\\'||c=='.')/*66:*/ | 904 | if(xisdigit(c)||c=='\\'||c=='.')/*66:*/ |
| 904 | #line 963 "ctangle.w" | 905 | #line 964 "ctangle.w" |
| 905 | { | 906 | { |
| 906 | id_first= loc-1; | 907 | id_first= loc-1; |
| 907 | if(*id_first=='.'&&!xisdigit(*loc))goto mistake; | 908 | if(*id_first=='.'&&!xisdigit(*loc))goto mistake; |
| @@ -929,11 +930,11 @@ return(constant); · 21 unmodified lines | |||
| 929 | } | 930 | } |
| 930 | 931 | ||
| 931 | /*:66*/ | 932 | /*:66*/ |
| 932 | #line 909 "ctangle.w" | 933 | #line 910 "ctangle.w" |
| 933 | 934 | ||
| 934 | else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"'))) | 935 | else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"'))) |
| 935 | /*67:*/ | 936 | /*67:*/ |
| 936 | #line 994 "ctangle.w" | 937 | #line 995 "ctangle.w" |
| 937 | { | 938 | { |
| 938 | char delim= c; | 939 | char delim= c; |
| 939 | id_first= section_text+1; | 940 | id_first= section_text+1; |
| @@ -976,11 +977,11 @@ return(string); · 36 unmodified lines | |||
| 976 | } | 977 | } |
| 977 | 978 | ||
| 978 | /*:67*/ | 979 | /*:67*/ |
| 979 | #line 911 "ctangle.w" | 980 | #line 912 "ctangle.w" |
| 980 | 981 | ||
| 981 | else if(isalpha(c)||isxalpha(c)||ishigh(c)) | 982 | else if(isalpha(c)||isxalpha(c)||ishigh(c)) |
| 982 | /*65:*/ | 983 | /*65:*/ |
| 983 | #line 957 "ctangle.w" | 984 | #line 958 "ctangle.w" |
| 984 | { | 985 | { |
| 985 | id_first= --loc; | 986 | id_first= --loc; |
| 986 | while(isalpha(*++loc)||isdigit(*loc)||isxalpha(*loc)||ishigh(*loc)); | 987 | while(isalpha(*++loc)||isdigit(*loc)||isxalpha(*loc)||ishigh(*loc)); |
| @@ -988,10 +989,10 @@ id_loc= loc;return(identifier); · 1 unmodified line | |||
| 988 | } | 989 | } |
| 989 | 990 | ||
| 990 | /*:65*/ | 991 | /*:65*/ |
| 991 | #line 913 "ctangle.w" | 992 | #line 914 "ctangle.w" |
| 992 | 993 | ||
| 993 | else if(c=='@')/*68:*/ | 994 | else if(c=='@')/*68:*/ |
| 994 | #line 1038 "ctangle.w" | 995 | #line 1039 "ctangle.w" |
| 995 | { | 996 | { |
| 996 | c= ccode[(eight_bits)*loc++]; | 997 | c= ccode[(eight_bits)*loc++]; |
| 997 | switch(c){ | 998 | switch(c){ |
| @@ -1008,11 +1009,11 @@ continue; · 10 unmodified lines | |||
| 1008 | case section_name: | 1009 | case section_name: |
| 1009 | cur_section_name_char= *(loc-1); | 1010 | cur_section_name_char= *(loc-1); |
| 1010 | /*70:*/ | 1011 | /*70:*/ |
| 1011 | #line 1087 "ctangle.w" | 1012 | #line 1088 "ctangle.w" |
| 1012 | { | 1013 | { |
| 1013 | char*k; | 1014 | char*k; |
| 1014 | /*72:*/ | 1015 | /*72:*/ |
| 1015 | #line 1107 "ctangle.w" | 1016 | #line 1108 "ctangle.w" |
| 1016 | 1017 | ||
| 1017 | k= section_text; | 1018 | k= section_text; |
| 1018 | while(1){ | 1019 | while(1){ |
| @@ -1023,7 +1024,7 @@ loc= buffer+1;break; · 4 unmodified lines | |||
| 1023 | } | 1024 | } |
| 1024 | c= *loc; | 1025 | c= *loc; |
| 1025 | /*73:*/ | 1026 | /*73:*/ |
| 1026 | #line 1131 "ctangle.w" | 1027 | #line 1132 "ctangle.w" |
| 1027 | 1028 | ||
| 1028 | if(c=='@'){ | 1029 | if(c=='@'){ |
| 1029 | c= *(loc+1); | 1030 | c= *(loc+1); |
| @@ -1042,7 +1043,7 @@ err_print("! Nesting of section names not allowed");break; · 12 unmodified lines | |||
| 1042 | } | 1043 | } |
| 1043 | 1044 | ||
| 1044 | /*:73*/ | 1045 | /*:73*/ |
| 1045 | #line 1116 "ctangle.w" | 1046 | #line 1117 "ctangle.w" |
| 1046 | ; | 1047 | ; |
| 1047 | loc++;if(k<section_text_end)k++; | 1048 | loc++;if(k<section_text_end)k++; |
| 1048 | if(xisspace(c)){ | 1049 | if(xisspace(c)){ |
| @@ -1059,7 +1060,7 @@ printf("...");mark_harmless; · 10 unmodified lines | |||
| 1059 | if(*k==' '&&k>section_text)k--; | 1060 | if(*k==' '&&k>section_text)k--; |
| 1060 | 1061 | ||
| 1061 | /*:72*/ | 1062 | /*:72*/ |
| 1062 | #line 1089 "ctangle.w" | 1063 | #line 1090 "ctangle.w" |
| 1063 | ; | 1064 | ; |
| 1064 | if(k-section_text>3&&strncmp(k-2,"...",3)==0) | 1065 | if(k-section_text>3&&strncmp(k-2,"...",3)==0) |
| 1065 | cur_section_name= section_lookup(section_text+1,k-3,1); | 1066 | cur_section_name= section_lookup(section_text+1,k-3,1); |
| @@ -1082,16 +1083,16 @@ overflow("output files"); · 16 unmodified lines | |||
| 1082 | } | 1083 | } |
| 1083 | 1084 | ||
| 1084 | /*:40*/ | 1085 | /*:40*/ |
| 1085 | #line 1095 "ctangle.w" | 1086 | #line 1096 "ctangle.w" |
| 1086 | ; | 1087 | ; |
| 1087 | return(section_name); | 1088 | return(section_name); |
| 1088 | } | 1089 | } |
| 1089 | 1090 | ||
| 1090 | /*:70*/ | 1091 | /*:70*/ |
| 1091 | #line 1053 "ctangle.w" | 1092 | #line 1054 "ctangle.w" |
| 1092 | ; | 1093 | ; |
| 1093 | case string:/*74:*/ | 1094 | case string:/*74:*/ |
| 1094 | #line 1153 "ctangle.w" | 1095 | #line 1154 "ctangle.w" |
| 1095 | { | 1096 | { |
| 1096 | id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; | 1097 | id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; |
| 1097 | while(*loc!='@'||*(loc+1)!='>')loc++; | 1098 | while(*loc!='@'||*(loc+1)!='>')loc++; |
| @@ -1102,10 +1103,10 @@ return(string); · 4 unmodified lines | |||
| 1102 | } | 1103 | } |
| 1103 | 1104 | ||
| 1104 | /*:74*/ | 1105 | /*:74*/ |
| 1105 | #line 1054 "ctangle.w" | 1106 | #line 1055 "ctangle.w" |
| 1106 | ; | 1107 | ; |
| 1107 | case ord:/*69:*/ | 1108 | case ord:/*69:*/ |
| 1108 | #line 1066 "ctangle.w" | 1109 | #line 1067 "ctangle.w" |
| 1109 | 1110 | ||
| 1110 | id_first= loc; | 1111 | id_first= loc; |
| 1111 | if(*loc=='\\'){ | 1112 | if(*loc=='\\'){ |
| @@ -1128,14 +1129,14 @@ loc++; · 16 unmodified lines | |||
| 1128 | return(ord); | 1129 | return(ord); |
| 1129 | 1130 | ||
| 1130 | /*:69*/ | 1131 | /*:69*/ |
| 1131 | #line 1055 "ctangle.w" | 1132 | #line 1056 "ctangle.w" |
| 1132 | ; | 1133 | ; |
| 1133 | default:return(c); | 1134 | default:return(c); |
| 1134 | } | 1135 | } |
| 1135 | } | 1136 | } |
| 1136 | 1137 | ||
| 1137 | /*:68*/ | 1138 | /*:68*/ |
| 1138 | #line 914 "ctangle.w" | 1139 | #line 915 "ctangle.w" |
| 1139 | 1140 | ||
| 1140 | else if(xisspace(c)){ | 1141 | else if(xisspace(c)){ |
| 1141 | if(!preprocessing||loc>limit)continue; | 1142 | if(!preprocessing||loc>limit)continue; |
| @@ -1144,7 +1145,7 @@ else return(' '); · 2 unmodified lines | |||
| 1144 | } | 1145 | } |
| 1145 | else if(c=='#'&&loc==buffer+1)preprocessing= 1; | 1146 | else if(c=='#'&&loc==buffer+1)preprocessing= 1; |
| 1146 | mistake:/*64:*/ | 1147 | mistake:/*64:*/ |
| 1147 | #line 935 "ctangle.w" | 1148 | #line 936 "ctangle.w" |
| 1148 | 1149 | ||
| 1149 | switch(c){ | 1150 | switch(c){ |
| 1150 | case'+':if(*loc=='+')compress(plus_plus);break; | 1151 | case'+':if(*loc=='+')compress(plus_plus);break; |
| @@ -1168,14 +1169,14 @@ case'!':if(*loc=='=')compress(not_eq);break; · 17 unmodified lines | |||
| 1168 | } | 1169 | } |
| 1169 | 1170 | ||
| 1170 | /*:64*/ | 1171 | /*:64*/ |
| 1171 | #line 921 "ctangle.w" | 1172 | #line 922 "ctangle.w" |
| 1172 | 1173 | ||
| 1173 | return(c); | 1174 | return(c); |
| 1174 | } | 1175 | } |
| 1175 | } | 1176 | } |
| 1176 | 1177 | ||
| 1177 | /*:63*//*76:*/ | 1178 | /*:63*//*76:*/ |
| 1178 | #line 1185 "ctangle.w" | 1179 | #line 1189 "ctangle.w" |
| 1179 | 1180 | ||
| 1180 | void | 1181 | void |
| 1181 | scan_repl(t) | 1182 | scan_repl(t) |
| @@ -1183,7 +1184,7 @@ eight_bits t; · 1 unmodified line | |||
| 1183 | { | 1184 | { |
| 1184 | sixteen_bits a; | 1185 | sixteen_bits a; |
| 1185 | if(t==section_name){/*77:*/ | 1186 | if(t==section_name){/*77:*/ |
| 1186 | #line 1208 "ctangle.w" | 1187 | #line 1215 "ctangle.w" |
| 1187 | 1188 | ||
| 1188 | store_two_bytes(0150000); | 1189 | store_two_bytes(0150000); |
| 1189 | if(changing)id_first= change_file_name; | 1190 | if(changing)id_first= change_file_name; |
| @@ -1191,23 +1192,23 @@ else id_first= cur_file_name; · 1 unmodified line | |||
| 1191 | id_loc= id_first+strlen(id_first); | 1192 | id_loc= id_first+strlen(id_first); |
| 1192 | if(changing)store_two_bytes((sixteen_bits)change_line); | 1193 | if(changing)store_two_bytes((sixteen_bits)change_line); |
| 1193 | else store_two_bytes((sixteen_bits)cur_line); | 1194 | else store_two_bytes((sixteen_bits)cur_line); |
| 1194 | {int a= id_lookup(id_first,id_loc)-name_dir;app_repl((a/0400)+0200); | 1195 | {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200); |
| 1195 | app_repl(a%0400);} | 1196 | app_repl(a%0400);} |
| 1196 | 1197 | ||
| 1197 | /*:77*/ | 1198 | /*:77*/ |
| 1198 | #line 1191 "ctangle.w" | 1199 | #line 1195 "ctangle.w" |
| 1199 | ;} | 1200 | ;} |
| 1200 | while(1)switch(a= get_next()){ | 1201 | while(1)switch(a= get_next()){ |
| 1201 | /*78:*/ | 1202 | /*78:*/ |
| 1202 | #line 1218 "ctangle.w" | 1203 | #line 1225 "ctangle.w" |
| 1203 | 1204 | ||
| 1204 | case identifier:a= id_lookup(id_first,id_loc)-name_dir; | 1205 | case identifier:a= id_lookup(id_first,id_loc,0)-name_dir; |
| 1205 | app_repl((a/0400)+0200); | 1206 | app_repl((a/0400)+0200); |
| 1206 | app_repl(a%0400);break; | 1207 | app_repl(a%0400);break; |
| 1207 | case section_name:if(t!=section_name)goto done; | 1208 | case section_name:if(t!=section_name)goto done; |
| 1208 | else{ | 1209 | else{ |
| 1209 | /*79:*/ | 1210 | /*79:*/ |
| 1210 | #line 1246 "ctangle.w" | 1211 | #line 1253 "ctangle.w" |
| 1211 | { | 1212 | { |
| 1212 | char*try_loc= loc; | 1213 | char*try_loc= loc; |
| 1213 | while(*try_loc==' '&&try_loc<limit)try_loc++; | 1214 | while(*try_loc==' '&&try_loc<limit)try_loc++; |
| @@ -1220,13 +1221,13 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section"); · 6 unmodified lines | |||
| 1220 | } | 1221 | } |
| 1221 | 1222 | ||
| 1222 | /*:79*/ | 1223 | /*:79*/ |
| 1223 | #line 1224 "ctangle.w" | 1224 | #line 1231 "ctangle.w" |
| 1224 | ; | 1225 | ; |
| 1225 | a= cur_section_name-name_dir; | 1226 | a= cur_section_name-name_dir; |
| 1226 | app_repl((a/0400)+0250); | 1227 | app_repl((a/0400)+0250); |
| 1227 | app_repl(a%0400); | 1228 | app_repl(a%0400); |
| 1228 | /*77:*/ | 1229 | /*77:*/ |
| 1229 | #line 1208 "ctangle.w" | 1230 | #line 1215 "ctangle.w" |
| 1230 | 1231 | ||
| 1231 | store_two_bytes(0150000); | 1232 | store_two_bytes(0150000); |
| 1232 | if(changing)id_first= change_file_name; | 1233 | if(changing)id_first= change_file_name; |
| @@ -1234,11 +1235,11 @@ else id_first= cur_file_name; · 1 unmodified line | |||
| 1234 | id_loc= id_first+strlen(id_first); | 1235 | id_loc= id_first+strlen(id_first); |
| 1235 | if(changing)store_two_bytes((sixteen_bits)change_line); | 1236 | if(changing)store_two_bytes((sixteen_bits)change_line); |
| 1236 | else store_two_bytes((sixteen_bits)cur_line); | 1237 | else store_two_bytes((sixteen_bits)cur_line); |
| 1237 | {int a= id_lookup(id_first,id_loc)-name_dir;app_repl((a/0400)+0200); | 1238 | {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200); |
| 1238 | app_repl(a%0400);} | 1239 | app_repl(a%0400);} |
| 1239 | 1240 | ||
| 1240 | /*:77*/ | 1241 | /*:77*/ |
| 1241 | #line 1228 "ctangle.w" | 1242 | #line 1235 "ctangle.w" |
| 1242 | ;break; | 1243 | ;break; |
| 1243 | } | 1244 | } |
| 1244 | case output_defs_code: | 1245 | case output_defs_code: |
| @@ -1246,7 +1247,7 @@ a= output_defs_flag; · 1 unmodified line | |||
| 1246 | app_repl((a/0400)+0200); | 1247 | app_repl((a/0400)+0200); |
| 1247 | app_repl(a%0400); | 1248 | app_repl(a%0400); |
| 1248 | /*77:*/ | 1249 | /*77:*/ |
| 1249 | #line 1208 "ctangle.w" | 1250 | #line 1215 "ctangle.w" |
| 1250 | 1251 | ||
| 1251 | store_two_bytes(0150000); | 1252 | store_two_bytes(0150000); |
| 1252 | if(changing)id_first= change_file_name; | 1253 | if(changing)id_first= change_file_name; |
| @@ -1254,15 +1255,15 @@ else id_first= cur_file_name; · 1 unmodified line | |||
| 1254 | id_loc= id_first+strlen(id_first); | 1255 | id_loc= id_first+strlen(id_first); |
| 1255 | if(changing)store_two_bytes((sixteen_bits)change_line); | 1256 | if(changing)store_two_bytes((sixteen_bits)change_line); |
| 1256 | else store_two_bytes((sixteen_bits)cur_line); | 1257 | else store_two_bytes((sixteen_bits)cur_line); |
| 1257 | {int a= id_lookup(id_first,id_loc)-name_dir;app_repl((a/0400)+0200); | 1258 | {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200); |
| 1258 | app_repl(a%0400);} | 1259 | app_repl(a%0400);} |
| 1259 | 1260 | ||
| 1260 | /*:77*/ | 1261 | /*:77*/ |
| 1261 | #line 1234 "ctangle.w" | 1262 | #line 1241 "ctangle.w" |
| 1262 | ;break; | 1263 | ;break; |
| 1263 | case constant:case string: | 1264 | case constant:case string: |
| 1264 | /*80:*/ | 1265 | /*80:*/ |
| 1265 | #line 1257 "ctangle.w" | 1266 | #line 1264 "ctangle.w" |
| 1266 | 1267 | ||
| 1267 | app_repl(a); | 1268 | app_repl(a); |
| 1268 | while(id_first<id_loc){ | 1269 | while(id_first<id_loc){ |
| @@ -1276,11 +1277,11 @@ app_repl(*id_first++); · 7 unmodified lines | |||
| 1276 | app_repl(a);break; | 1277 | app_repl(a);break; |
| 1277 | 1278 | ||
| 1278 | /*:80*/ | 1279 | /*:80*/ |
| 1279 | #line 1236 "ctangle.w" | 1280 | #line 1243 "ctangle.w" |
| 1280 | ; | 1281 | ; |
| 1281 | case ord: | 1282 | case ord: |
| 1282 | /*81:*/ | 1283 | /*81:*/ |
| 1283 | #line 1273 "ctangle.w" | 1284 | #line 1280 "ctangle.w" |
| 1284 | { | 1285 | { |
| 1285 | int c= (eight_bits)*id_first; | 1286 | int c= (eight_bits)*id_first; |
| 1286 | if(c=='\\'){ | 1287 | if(c=='\\'){ |
| @@ -1331,7 +1332,7 @@ app_repl(constant); · 44 unmodified lines | |||
| 1331 | break; | 1332 | break; |
| 1332 | 1333 | ||
| 1333 | /*:81*/ | 1334 | /*:81*/ |
| 1334 | #line 1238 "ctangle.w" | 1335 | #line 1245 "ctangle.w" |
| 1335 | ; | 1336 | ; |
| 1336 | case definition:case format_code:case begin_C:if(t!=section_name)goto done; | 1337 | case definition:case format_code:case begin_C:if(t!=section_name)goto done; |
| 1337 | else{ | 1338 | else{ |
| @@ -1341,8 +1342,11 @@ err_print("! @d, @f and @c are ignored in C text");continue; · 3 unmodified lines | |||
| 1341 | case new_section:goto done; | 1342 | case new_section:goto done; |
| 1342 | 1343 | ||
| 1343 | /*:78*/ | 1344 | /*:78*/ |
| 1344 | #line 1196 "ctangle.w" | 1345 | #line 1200 "ctangle.w" |
| 1345 | 1346 | ||
| 1347 | case')':app_repl(a); | ||
| 1348 | if(t==macro)app_repl(' '); | ||
| 1349 | break; | ||
| 1346 | default:app_repl(a); | 1350 | default:app_repl(a); |
| 1347 | } | 1351 | } |
| 1348 | done:next_control= (eight_bits)a; | 1352 | done:next_control= (eight_bits)a; |
| @@ -1351,7 +1355,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr; · 2 unmodified lines | |||
| 1351 | } | 1355 | } |
| 1352 | 1356 | ||
| 1353 | /*:76*//*83:*/ | 1357 | /*:76*//*83:*/ |
| 1354 | #line 1335 "ctangle.w" | 1358 | #line 1342 "ctangle.w" |
| 1355 | 1359 | ||
| 1356 | void | 1360 | void |
| 1357 | scan_section() | 1361 | scan_section() |
| @@ -1359,14 +1363,14 @@ scan_section() · 1 unmodified line | |||
| 1359 | name_pointer p; | 1363 | name_pointer p; |
| 1360 | text_pointer q; | 1364 | text_pointer q; |
| 1361 | sixteen_bits a; | 1365 | sixteen_bits a; |
| 1362 | section_count++; | 1366 | section_count++;no_where= 1; |
| 1363 | if(*(loc-1)=='*'&&show_progress){ | 1367 | if(*(loc-1)=='*'&&show_progress){ |
| 1364 | printf("*%d",section_count);update_terminal; | 1368 | printf("*%d",section_count);update_terminal; |
| 1365 | } | 1369 | } |
| 1366 | next_control= 0; | 1370 | next_control= 0; |
| 1367 | while(1){ | 1371 | while(1){ |
| 1368 | /*84:*/ | 1372 | /*84:*/ |
| 1369 | #line 1373 "ctangle.w" | 1373 | #line 1381 "ctangle.w" |
| 1370 | 1374 | ||
| 1371 | while(next_control<definition) | 1375 | while(next_control<definition) |
| 1372 | 1376 | ||
| @@ -1375,11 +1379,11 @@ loc-= 2;next_control= get_next(); · 2 unmodified lines | |||
| 1375 | } | 1379 | } |
| 1376 | 1380 | ||
| 1377 | /*:84*/ | 1381 | /*:84*/ |
| 1378 | #line 1349 "ctangle.w" | 1382 | #line 1356 "ctangle.w" |
| 1379 | ; | 1383 | ; |
| 1380 | if(next_control==definition){ | 1384 | if(next_control==definition){ |
| 1381 | /*85:*/ | 1385 | /*85:*/ |
| 1382 | #line 1380 "ctangle.w" | 1386 | #line 1388 "ctangle.w" |
| 1383 | { | 1387 | { |
| 1384 | while((next_control= get_next())=='\n'); | 1388 | while((next_control= get_next())=='\n'); |
| 1385 | if(next_control!=identifier){ | 1389 | if(next_control!=identifier){ |
| @@ -1387,18 +1391,18 @@ err_print("! Definition flushed, must start with identifier"); · 1 unmodified line | |||
| 1387 | 1391 | ||
| 1388 | continue; | 1392 | continue; |
| 1389 | } | 1393 | } |
| 1390 | app_repl(((a= id_lookup(id_first,id_loc)-name_dir)/0400)+0200); | 1394 | app_repl(((a= id_lookup(id_first,id_loc,0)-name_dir)/0400)+0200); |
| 1391 | 1395 | ||
| 1392 | app_repl(a%0400); | 1396 | app_repl(a%0400); |
| 1393 | if(*loc!='('){ | 1397 | if(*loc!='('){ |
| 1394 | app_repl(string);app_repl(' ');app_repl(string); | 1398 | app_repl(string);app_repl(' ');app_repl(string); |
| 1395 | } | 1399 | } |
| 1396 | print_where= 0;scan_repl(macro); | 1400 | scan_repl(macro); |
| 1397 | cur_text->text_link= 0; | 1401 | cur_text->text_link= 0; |
| 1398 | } | 1402 | } |
| 1399 | 1403 | ||
| 1400 | /*:85*/ | 1404 | /*:85*/ |
| 1401 | #line 1351 "ctangle.w" | 1405 | #line 1358 "ctangle.w" |
| 1402 | 1406 | ||
| 1403 | continue; | 1407 | continue; |
| 1404 | } | 1408 | } |
| @@ -1408,34 +1412,35 @@ p= name_dir;break; · 3 unmodified lines | |||
| 1408 | if(next_control==section_name){ | 1412 | if(next_control==section_name){ |
| 1409 | p= cur_section_name; | 1413 | p= cur_section_name; |
| 1410 | /*86:*/ | 1414 | /*86:*/ |
| 1411 | #line 1405 "ctangle.w" | 1415 | #line 1413 "ctangle.w" |
| 1412 | 1416 | ||
| 1413 | while((next_control= get_next())=='+'); | 1417 | while((next_control= get_next())=='+'); |
| 1414 | if(next_control!='='&&next_control!=eq_eq) | 1418 | if(next_control!='='&&next_control!=eq_eq) |
| 1415 | continue; | 1419 | continue; |
| 1416 | 1420 | ||
| 1417 | /*:86*/ | 1421 | /*:86*/ |
| 1418 | #line 1359 "ctangle.w" | 1422 | #line 1366 "ctangle.w" |
| 1419 | ; | 1423 | ; |
| 1420 | break; | 1424 | break; |
| 1421 | } | 1425 | } |
| 1422 | return; | 1426 | return; |
| 1423 | } | 1427 | } |
| 1428 | no_where= print_where= 0; | ||
| 1424 | /*87:*/ | 1429 | /*87:*/ |
| 1425 | #line 1410 "ctangle.w" | 1430 | #line 1418 "ctangle.w" |
| 1426 | 1431 | ||
| 1427 | /*88:*/ | 1432 | /*88:*/ |
| 1428 | #line 1415 "ctangle.w" | 1433 | #line 1423 "ctangle.w" |
| 1429 | 1434 | ||
| 1430 | store_two_bytes((sixteen_bits)(0150000+section_count)); | 1435 | store_two_bytes((sixteen_bits)(0150000+section_count)); |
| 1431 | 1436 | ||
| 1432 | 1437 | ||
| 1433 | /*:88*/ | 1438 | /*:88*/ |
| 1434 | #line 1411 "ctangle.w" | 1439 | #line 1419 "ctangle.w" |
| 1435 | ; | 1440 | ; |
| 1436 | scan_repl(section_name); | 1441 | scan_repl(section_name); |
| 1437 | /*89:*/ | 1442 | /*89:*/ |
| 1438 | #line 1419 "ctangle.w" | 1443 | #line 1427 "ctangle.w" |
| 1439 | 1444 | ||
| 1440 | if(p==name_dir||p==0){ | 1445 | if(p==name_dir||p==0){ |
| 1441 | (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text; | 1446 | (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text; |
| @@ -1452,16 +1457,16 @@ cur_text->text_link= section_flag; · 10 unmodified lines | |||
| 1452 | 1457 | ||
| 1453 | 1458 | ||
| 1454 | /*:89*/ | 1459 | /*:89*/ |
| 1455 | #line 1413 "ctangle.w" | 1460 | #line 1421 "ctangle.w" |
| 1456 | ; | 1461 | ; |
| 1457 | 1462 | ||
| 1458 | /*:87*/ | 1463 | /*:87*/ |
| 1459 | #line 1364 "ctangle.w" | 1464 | #line 1372 "ctangle.w" |
| 1460 | ; | 1465 | ; |
| 1461 | } | 1466 | } |
| 1462 | 1467 | ||
| 1463 | /*:83*//*91:*/ | 1468 | /*:83*//*91:*/ |
| 1464 | #line 1437 "ctangle.w" | 1469 | #line 1445 "ctangle.w" |
| 1465 | 1470 | ||
| 1466 | void | 1471 | void |
| 1467 | phase_one(){ | 1472 | phase_one(){ |
| @@ -1475,7 +1480,7 @@ phase= 2; · 7 unmodified lines | |||
| 1475 | } | 1480 | } |
| 1476 | 1481 | ||
| 1477 | /*:91*//*93:*/ | 1482 | /*:91*//*93:*/ |
| 1478 | #line 1455 "ctangle.w" | 1483 | #line 1463 "ctangle.w" |
| 1479 | 1484 | ||
| 1480 | void | 1485 | void |
| 1481 | skip_limbo() | 1486 | skip_limbo() |
| @@ -1490,7 +1495,7 @@ c= *loc++; · 8 unmodified lines | |||
| 1490 | if(ccode[(eight_bits)c]==new_section)break; | 1495 | if(ccode[(eight_bits)c]==new_section)break; |
| 1491 | switch(ccode[(eight_bits)c]){ | 1496 | switch(ccode[(eight_bits)c]){ |
| 1492 | case translit_code:/*94:*/ | 1497 | case translit_code:/*94:*/ |
| 1493 | #line 1484 "ctangle.w" | 1498 | #line 1492 "ctangle.w" |
| 1494 | 1499 | ||
| 1495 | while(xisspace(*loc)&&loc<limit)loc++; | 1500 | while(xisspace(*loc)&&loc<limit)loc++; |
| 1496 | loc+= 3; | 1501 | loc+= 3; |
| @@ -1515,7 +1520,7 @@ translit[i-0200][loc-beg]= '\0'; · 18 unmodified lines | |||
| 1515 | } | 1520 | } |
| 1516 | 1521 | ||
| 1517 | /*:94*/ | 1522 | /*:94*/ |
| 1518 | #line 1468 "ctangle.w" | 1523 | #line 1476 "ctangle.w" |
| 1519 | ;break; | 1524 | ;break; |
| 1520 | case format_code:case'@':break; | 1525 | case format_code:case'@':break; |
| 1521 | case control_text:if(c=='q'||c=='Q'){ | 1526 | case control_text:if(c=='q'||c=='Q'){ |
| @@ -1533,7 +1538,7 @@ default:err_print("! Double @ should be used in limbo"); · 11 unmodified lines | |||
| 1533 | } | 1538 | } |
| 1534 | 1539 | ||
| 1535 | /*:93*//*95:*/ | 1540 | /*:93*//*95:*/ |
| 1536 | #line 1510 "ctangle.w" | 1541 | #line 1518 "ctangle.w" |
| 1537 | 1542 | ||
| 1538 | void | 1543 | void |
| 1539 | print_stats(){ | 1544 | print_stats(){ |