Skip to content

Commit f999b45

Browse files
authored
Merge pull request #635 from ralismark/diagnostics
Add diagnostics where errors/warnings are emitted
2 parents 1a200dd + 6110cfd commit f999b45

9 files changed

+482
-897
lines changed

tectonic/xetex-errors.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@ pre_error_message (void)
2626
if (interaction == BATCH_MODE)
2727
selector--;
2828

29-
if (file_line_error_style_p)
30-
print_file_line();
31-
else
32-
print_nl_cstr("! ");
29+
error_here_with_diagnostic("");
3330
}
3431

3532

3633
/*82: */
3734
static void
3835
post_error_message(int need_to_print_it)
3936
{
37+
capture_to_diagnostic(NULL);
38+
4039
if (interaction == ERROR_STOP_MODE)
4140
interaction = SCROLL_MODE;
4241

@@ -102,6 +101,8 @@ fatal_error(const char* s)
102101
pre_error_message();
103102
print_cstr("Emergency stop");
104103
print_nl_cstr(s);
104+
capture_to_diagnostic(NULL); // started in pre_error_message
105+
105106
close_files_and_terminate();
106107
tt_cleanup();
107108
ttstub_output_flush(rust_stdout);

tectonic/xetex-ini.c

+30-73
Original file line numberDiff line numberDiff line change
@@ -813,11 +813,8 @@ new_patterns(void)
813813
cur_chr = LC_CODE(cur_chr);
814814

815815
if (cur_chr == 0) {
816-
if (file_line_error_style_p)
817-
print_file_line();
818-
else
819-
print_nl_cstr("! ");
820-
print_cstr("Nonletter");
816+
error_here_with_diagnostic("Nonletter");
817+
capture_to_diagnostic(NULL);
821818
help_ptr = 1;
822819
help_line[0] = "(See Appendix H.)";
823820
error();
@@ -893,11 +890,8 @@ new_patterns(void)
893890
}
894891

895892
if (trie_o[q] != MIN_TRIE_OP) {
896-
if (file_line_error_style_p)
897-
print_file_line();
898-
else
899-
print_nl_cstr("! ");
900-
print_cstr("Duplicate pattern");
893+
error_here_with_diagnostic("Duplicate pattern");
894+
capture_to_diagnostic(NULL);
901895
help_ptr = 1;
902896
help_line[0] = "(See Appendix H.)";
903897
error();
@@ -915,12 +909,9 @@ new_patterns(void)
915909
break;
916910

917911
default:
918-
if (file_line_error_style_p)
919-
print_file_line();
920-
else
921-
print_nl_cstr("! ");
922-
print_cstr("Bad ");
912+
error_here_with_diagnostic("Bad ");
923913
print_esc_cstr("patterns");
914+
capture_to_diagnostic(NULL);
924915
help_ptr = 1;
925916
help_line[0] = "(See Appendix H.)";
926917
error();
@@ -990,12 +981,9 @@ new_patterns(void)
990981
trie_r[q] = 0; /*:1644*/
991982
}
992983
} else {
993-
if (file_line_error_style_p)
994-
print_file_line();
995-
else
996-
print_nl_cstr("! ");
997-
print_cstr("Too late for ");
984+
error_here_with_diagnostic("Too late for ");
998985
print_esc_cstr("patterns");
986+
capture_to_diagnostic(NULL);
999987
help_ptr = 1;
1000988
help_line[0] = "All patterns must be given before typesetting begins.";
1001989
error();
@@ -1198,11 +1186,8 @@ new_hyph_exceptions(void)
11981186
hc[0] = trie_tro[hyph_index + cur_chr];
11991187

12001188
if (hc[0] == 0) {
1201-
if (file_line_error_style_p)
1202-
print_file_line();
1203-
else
1204-
print_nl_cstr("! ");
1205-
print_cstr("Not a letter");
1189+
error_here_with_diagnostic("Not a letter");
1190+
capture_to_diagnostic(NULL);
12061191
help_ptr = 2;
12071192
help_line[1] = "Letters in \\hyphenation words must have \\lccode>0.";
12081193
help_line[0] = "Proceed; I'll ignore the character I just read.";
@@ -1300,13 +1285,10 @@ new_hyph_exceptions(void)
13001285
break;
13011286

13021287
default:
1303-
if (file_line_error_style_p)
1304-
print_file_line();
1305-
else
1306-
print_nl_cstr("! ");
1307-
print_cstr("Improper ");
1288+
error_here_with_diagnostic("Improper ");
13081289
print_esc_cstr("hyphenation");
13091290
print_cstr(" will be flushed");
1291+
capture_to_diagnostic(NULL);
13101292
help_ptr = 2;
13111293
help_line[1] = "Hyphenation exceptions must contain only letters";
13121294
help_line[0] = "and hyphens. But continue; I'll forgive and forget.";
@@ -1339,13 +1321,10 @@ prefixed_command(void)
13391321
} while (cur_cmd == SPACER || cur_cmd == RELAX);
13401322

13411323
if (cur_cmd <= MAX_NON_PREFIXED_COMMAND) { /*1247:*/
1342-
if (file_line_error_style_p)
1343-
print_file_line();
1344-
else
1345-
print_nl_cstr("! ");
1346-
print_cstr("You can't use a prefix with `");
1324+
error_here_with_diagnostic("You can't use a prefix with `");
13471325
print_cmd_chr(cur_cmd, cur_chr);
13481326
print_char('\'');
1327+
capture_to_diagnostic(NULL);
13491328
help_ptr = 1;
13501329
help_line[0] = "I'll pretend you didn't say \\long or \\outer or \\global or \\protected.";
13511330
back_error();
@@ -1365,21 +1344,18 @@ prefixed_command(void)
13651344
}
13661345

13671346
if (cur_cmd != DEF && (a % 4 != 0 || j != 0)) {
1368-
if (file_line_error_style_p)
1369-
print_file_line();
1370-
else
1371-
print_nl_cstr("! ");
1372-
print_cstr("You can't use `");
1347+
error_here_with_diagnostic("You can't use `");
13731348
print_esc_cstr("long");
13741349
print_cstr("' or `");
13751350
print_esc_cstr("outer");
1376-
help_ptr = 1;
1377-
help_line[0] = "I'll pretend you didn't say \\long or \\outer or \\protected here.";
13781351
print_cstr("' or `");
13791352
print_esc_cstr("protected");
13801353
print_cstr("' with `");
13811354
print_cmd_chr(cur_cmd, cur_chr);
13821355
print_char('\'');
1356+
capture_to_diagnostic(NULL);
1357+
help_ptr = 1;
1358+
help_line[0] = "I'll pretend you didn't say \\long or \\outer or \\protected here.";
13831359
error();
13841360
}
13851361

@@ -1614,11 +1590,8 @@ prefixed_command(void)
16141590
scan_int();
16151591
n = cur_val;
16161592
if (!scan_keyword("to")) {
1617-
if (file_line_error_style_p)
1618-
print_file_line();
1619-
else
1620-
print_nl_cstr("! ");
1621-
print_cstr("Missing `to' inserted");
1593+
error_here_with_diagnostic("Missing `to' inserted");
1594+
capture_to_diagnostic(NULL);
16221595
help_ptr = 2;
16231596
help_line[1] = "You should have said `\\read<number> to \\cs'.";
16241597
help_line[0] = "I'm going to look for the \\cs now.";
@@ -1890,17 +1863,14 @@ prefixed_command(void)
18901863
scan_int();
18911864

18921865
if ((cur_val < 0 && p < DEL_CODE_BASE) || cur_val > n) {
1893-
if (file_line_error_style_p)
1894-
print_file_line();
1895-
else
1896-
print_nl_cstr("! ");
1897-
print_cstr("Invalid code (");
1866+
error_here_with_diagnostic("Invalid code (");
18981867
print_int(cur_val);
18991868
if (p < DEL_CODE_BASE)
19001869
print_cstr("), should be in the range 0..");
19011870
else
19021871
print_cstr("), should be at most ");
19031872
print_int(n);
1873+
capture_to_diagnostic(NULL);
19041874
help_ptr = 1;
19051875
help_line[0] = "I'm going to use 0 instead of that illegal code value.";
19061876
error();
@@ -1967,12 +1937,9 @@ prefixed_command(void)
19671937
if (set_box_allowed) {
19681938
scan_box(n);
19691939
} else {
1970-
if (file_line_error_style_p)
1971-
print_file_line();
1972-
else
1973-
print_nl_cstr("! ");
1974-
print_cstr("Improper ");
1940+
error_here_with_diagnostic("Improper ");
19751941
print_esc_cstr("setbox");
1942+
capture_to_diagnostic(NULL);
19761943
help_ptr = 2;
19771944
help_line[1] = "Sorry, \\setbox is not allowed after \\halign in a display,";
19781945
help_line[0] = "or between \\accent and an accented character.";
@@ -2047,11 +2014,8 @@ prefixed_command(void)
20472014
goto done;
20482015
}
20492016

2050-
if (file_line_error_style_p)
2051-
print_file_line();
2052-
else
2053-
print_nl_cstr("! ");
2054-
print_cstr("Patterns can be loaded only by INITEX");
2017+
error_here_with_diagnostic("Patterns can be loaded only by INITEX");
2018+
capture_to_diagnostic(NULL);
20552019
help_ptr = 0;
20562020
error();
20572021

@@ -2139,12 +2103,8 @@ store_fmt_file(void)
21392103
rust_output_handle_t fmt_out;
21402104

21412105
if (save_ptr != 0) {
2142-
if (file_line_error_style_p)
2143-
print_file_line();
2144-
else
2145-
print_nl_cstr("! ");
2146-
2147-
print_cstr("You can't dump inside a group");
2106+
error_here_with_diagnostic("You can't dump inside a group");
2107+
capture_to_diagnostic(NULL);
21482108
help_ptr = 1;
21492109
help_line[0] = "`{...\\dump}' is a no-no.";
21502110

@@ -2405,11 +2365,8 @@ store_fmt_file(void)
24052365
if (font_area[k] == AAT_FONT_FLAG || font_area[k] == OTGR_FONT_FLAG || font_mapping[k] != NULL) {
24062366
print_file_name(font_name[k], EMPTY_STRING, EMPTY_STRING);
24072367

2408-
if (file_line_error_style_p)
2409-
print_file_line();
2410-
else
2411-
print_nl_cstr("! ");
2412-
print_cstr("Can't \\dump a format with native fonts or font-mappings");
2368+
error_here_with_diagnostic("Can't \\dump a format with native fonts or font-mappings");
2369+
capture_to_diagnostic(NULL);
24132370

24142371
help_ptr = 3;
24152372
help_line[2] = "You really, really don't want to do this.";

tectonic/xetex-linebreak.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -2377,13 +2377,8 @@ finite_shrink(int32_t p)
23772377
int32_t q;
23782378
if (no_shrink_error_yet) {
23792379
no_shrink_error_yet = false;
2380-
{
2381-
if (file_line_error_style_p)
2382-
print_file_line();
2383-
else
2384-
print_nl_cstr("! ");
2385-
print_cstr("Infinite glue shrinkage found in a paragraph");
2386-
}
2380+
error_here_with_diagnostic("Infinite glue shrinkage found in a paragraph");
2381+
capture_to_diagnostic(NULL);
23872382
{
23882383
help_ptr = 5;
23892384
help_line[4] = "The paragraph just ended includes some glue that has";

0 commit comments

Comments
 (0)