w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

errors.c
Go to the documentation of this file.
1 /*
2 
3 errors.w
4 
5 Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
6 
7 This file is part of LuaTeX.
8 
9 LuaTeX is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2 of the License, or (at your
12 option) any later version.
13 
14 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 License for more details.
18 
19 You should have received a copy of the GNU General Public License along
20 with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #include "ptexlib.h"
25 #define edit_var "TEXEDIT"
26 
27 /*tex
28 
29 When something anomalous is detected, \TeX\ typically does something like this:
30 $$\vbox{\halign{#\hfil\cr |print_err("Something anomalous has been
31 detected");|\cr |help3("This is the first line of my offer to help.")|\cr |("This
32 is the second line. I'm trying to")|\cr |("explain the best way for you to
33 proceed.");|\cr |error;|\cr}}$$ A two-line help message would be given using
34 |help2|, etc.; these informal helps should use simple vocabulary that complements
35 the words used in the official error message that was printed. (Outside the
36 U.S.A., the help messages should preferably be translated into the local
37 vernacular. Each line of help is at most 60 characters long, in the present
38 implementation, so that |max_print_line| will not be exceeded.)
39 
40 The |print_err| procedure supplies a `\.!' before the official message, and makes
41 sure that the terminal is awake if a stop is going to occur. The |error|
42 procedure supplies a `\..' after the official message, then it shows the location
43 of the error; and if |interaction=error_stop_mode|, it also enters into a dialog
44 with the user, during which time the help message may be printed. @^system
45 dependencies@>
46 
47 */
48 
49 /*tex The current level of interaction: */
50 
52 
53 /*tex Set from the command line: */
54 
56 
57 char *last_error = NULL;
62 
63 int err_old_setting = 0 ;
64 int in_error = 0 ;
65 
67 {
69  int sel = selector;
70  int saved_new_line_char;
71  int saved_new_string_line;
73  saved_new_line_char = new_line_char_par;
74  saved_new_string_line = new_string_line;
75  new_line_char_par = 10;
76  new_string_line = 10;
77  show_context();
79  str = make_string();
81  flush_str(str);
82  selector = sel;
83  new_line_char_par = saved_new_line_char;
84  new_string_line = saved_new_string_line;
85  return;
86 }
87 
88 void flush_err(void)
89 {
90  str_number s_error;
91  char *s = NULL;
92  int callback_id ;
93  if (in_error) {
95  str_room(1);
96  s_error = make_string();
97  s = makecstring(s_error);
98  flush_str(s_error);
101  }
102  xfree(last_error);
103  last_error = (string) xmalloc((unsigned) (strlen(s) + 1));
106  if (callback_id > 0) {
107  run_callback(callback_id, "->");
108  } else {
109  tprint(s);
110  }
111  in_error = 0 ;
112  }
113 }
114 
115 void print_err(const char *s)
116 {
118  if (interaction == error_stop_mode) {
120  }
121  if (callback_id > 0) {
124  in_error = 1 ;
125  }
126  if (filelineerrorstylep) {
127  print_file_line();
128  } else {
129  tprint_nl("! ");
130  }
131  tprint(s);
132  if (callback_id <= 0) {
133  xfree(last_error);
134  last_error = (string) xmalloc((unsigned) (strlen(s) + 1));
136  }
137 }
138 
139 /*tex
140 
141 \TeX\ is careful not to call |error| when the print |selector| setting might be
142 unusual. The only possible values of |selector| at the time of error messages are
143 
144 |no_print| (when |interaction=batch_mode| and |log_file| not yet open);
145 
146 |term_only| (when |interaction>batch_mode| and |log_file| not yet open);
147 
148 |log_only| (when |interaction=batch_mode| and |log_file| is open);
149 
150 |term_and_log| (when |interaction>batch_mode| and |log_file| is open).
151 
152 */
153 
154 void fixup_selector(boolean logopened)
155 {
156  if (interaction == batch_mode)
157  selector = no_print;
158  else
160  if (logopened)
161  selector = selector + 2;
162 }
163 
164 /*tex
165 
166 A global variable |deletions_allowed| is set |false| if the |get_next| routine is
167 active when |error| is called; this ensures that |get_next| and related routines
168 like |get_token| will never be called recursively. A similar interlock is
169 provided by |set_box_allowed|. @^recursion@>
170 
171 The global variable |history| records the worst level of error that has been
172 detected. It has four possible values: |spotless|, |warning_issued|,
173 |error_message_issued|, and |fatal_error_stop|.
174 
175 Another global variable, |error_count|, is increased by one when an |error|
176 occurs without an interactive dialog, and it is reset to zero at the end of every
177 paragraph. If |error_count| reaches 100, \TeX\ decides that there is no point in
178 continuing further.
179 
180 */
181 
182 /*tex Is it safe for |error| to call |get_token|? */
183 
185 
186 /*tex Is it safe to do a \.{\\setbox} assignment? */
187 
189 /*tex Has the source input been clean so far? */
190 
192 
193 /*tex The number of scrolled errors since the last paragraph ended. */
194 
196 
197 /*tex Should \TeX\ pause for instructions? */
198 
200 
201 /*tex Should interrupts be observed? */
202 
204 
205 /*tex
206 
207 The value of |history| is initially |fatal_error_stop|, but it will be changed to
208 |spotless| if \TeX\ survives the initialization process.
209 
210 */
211 
213 {
216  else
218  deletions_allowed = true;
219  set_box_allowed = true;
220  OK_to_interrupt = true;
221 }
222 
223 /*tex
224 
225 It is possible for |error| to be called recursively if some error arises when
226 |get_token| is being used to delete a token, and/or if some fatal error occurs
227 while \TeX\ is trying to fix a non-fatal one. But such recursion @^recursion@> is
228 never more than two levels deep.
229 
230 Individual lines of help are recorded in the array |help_line|.
231 
232 */
233 
234 const char *help_line[7];
235 
236 /*tex
237  Should the |err_help| list be shown?
238 */
239 
240 boolean use_err_help;
241 
242 /*tex
243 
244 The |jump_out| procedure just cuts across all active procedure levels and exits
245 the program. It is used when there is no recovery from a particular error. The
246 exit code can be overloaded.
247 
248 */
249 
251 
252 __attribute__ ((noreturn))
254 {
255  update_terminal();
256  ready_already = 0;
257  lua_close(Luas);
258  if ((history != spotless) && (history != warning_issued))
259  uexit(1);
260  else
262 }
263 
264 __attribute__ ((noreturn))
266 {
268  do_final_end();
269 }
270 
271 /*tex
272 
273 Here is the function that calls the editor, if one is defined. This is loosely
274 based on a similar function in kpathsea, but the calling convention is quite
275 different.
276 
277 */
278 
280 
281 #if defined(WIN32)
282 
283 static int Isspace (char c)
284 {
285  return (c == ' ' || c == '\t');
286 }
287 
288 #endif /* WIN32 */
289 
290 __attribute__ ((noreturn))
291 static void luatex_calledit (int baseptr, int linenumber)
292 {
293  char *temp, *command;
294  char *fullcmd = NULL; /* avoid compiler warning */
295  char c;
296  int sdone, ddone, i;
297  char *filename = makecstring(input_stack[base_ptr].name_field);
298  int fnlength = strlen(filename);
299 #ifdef WIN32
300  char *fp, *ffp, *env, editorname[256], buffer[256];
301  int cnt = 0;
302  int dontchange = 0;
303 #endif
304  sdone = ddone = 0;
305  /*tex
306  Close any open input files, since we're going to kill the job.
307  */
309  /*tex
310  Replace the default with the value of the appropriate environment
311  variable or config file value, if it's set.
312  */
313  temp = kpse_var_value (edit_var);
314  if (temp != NULL)
315  edit_value = temp;
316  /*tex
317  Construct the command string. The `11' is the maximum length an
318  integer might be.
319  */
320  command = xmalloc (strlen (edit_value) + fnlength + 11);
321  /*tex
322  So we can construct it as we go.
323  */
324  temp = command;
325 #ifdef WIN32
326  fp = editorname;
327  if ((isalpha(*edit_value) && *(edit_value + 1) == ':' && IS_DIR_SEP (*(edit_value + 2)))
328  || (*edit_value == '"' && isalpha(*(edit_value + 1))
329  && *(edit_value + 2) == ':' && IS_DIR_SEP (*(edit_value + 3)))) {
330  dontchange = 1;
331  }
332 #endif
333  while ((c = *edit_value++) != 0) {
334  if (c == '%') {
335  switch (c = *edit_value++) {
336  case 'd':
337  if (ddone)
338  FATAL1 ("call_edit: `%%d' appears twice in editor command: `%s'", edit_value);
339  sprintf (temp, "%ld", (long int)linenumber);
340  while (*temp != '\0')
341  temp++;
342  ddone = 1;
343  break;
344  case 's':
345  if (sdone)
346  FATAL1 ("call_edit: `%%s' appears twice in editor command: `%s'", edit_value);
347  for (i =0; i < fnlength; i++)
348  *temp++ = filename[i];
349  sdone = 1;
350  break;
351  case '\0':
352  *temp++ = '%';
353  /*tex
354  Back up to the null to force termination.
355  */
356  edit_value--;
357  break;
358  default:
359  *temp++ = '%';
360  *temp++ = c;
361  break;
362  }
363  } else {
364 #ifdef WIN32
365  if (dontchange) {
366  *temp++ = c;
367  } else if(Isspace(c) && cnt == 0) {
368  cnt++;
369  temp = command;
370  *temp++ = c;
371  *fp = '\0';
372  } else if(!Isspace(c) && cnt == 0) {
373  *fp++ = c;
374  } else {
375  *temp++ = c;
376  }
377 #else
378  *temp++ = c;
379 #endif
380  }
381  }
382  *temp = 0;
383 #ifdef WIN32
384  if (dontchange == 0) {
385  if(editorname[0] == '.' || editorname[0] == '/' || editorname[0] == '\\') {
386  fprintf(stderr, "%s is not allowed to execute.\n", editorname);
387  do_final_end();
388  }
389  env = (char *)getenv("PATH");
390  if(SearchPath(env, editorname, ".exe", 256, buffer, &ffp)==0) {
391  if(SearchPath(env, editorname, ".bat", 256, buffer, &ffp)==0) {
392  fprintf(stderr, "I cannot find %s in the PATH.\n", editorname);
393  do_final_end();
394  }
395  }
396  fullcmd = (char *)xmalloc(strlen(buffer)+strlen(command)+5);
397  strcpy(fullcmd, "\"");
398  strcat(fullcmd, buffer);
399  strcat(fullcmd, "\"");
400  strcat(fullcmd, command);
401  }
402 #else
403  fullcmd = command;
404 #endif
405  /*tex Execute the command. */
406  if (system (fullcmd) != 0) {
407  fprintf (stderr, "! Trouble executing `%s'.\n", command);
408  }
409  /*tex Quit, since we found an error. */
410  do_final_end ();
411 }
412 
413 /*tex
414 
415  This completes the job of error reporting.
416 
417 */
418 
419 void error(void)
420 {
421  /*tex What the user types :*/
422  ASCII_code c;
423  int callback_id;
424  /*tex Used to save global variables when deleting tokens: */
425  int s1, s2, s3, s4;
426  int i;
427  flush_err();
431  if (callback_id > 0) {
433  run_callback(callback_id, "->");
434  } else {
435  print_char('.');
436  show_context();
437  }
438  if (haltonerrorp) {
440  jump_out();
441  }
442  if (interaction == error_stop_mode) {
443  /*tex Get user's advice and |return|. */
444  while (1) {
445  CONTINUE:
446  /*tex
447  Original reports:
448 
449  https://tex.stackexchange.com/questions/551313/
450  https://tug.org/pipermail/tex-live/2020-June/045876.html
451 
452  This will probably be fixed by DEK in the 2021 tuneup in a different
453  way (so we'll have to remove or alter this change), but the interaction
454  sequence in the reports above causes a segmentation fault in web2c -
455  writing to the closed \write15 stream because we wrongly decrement
456  selector from 16 to 15 in term_input, due to the lack of this check in
457  recursive error() call.
458  */
460  return;
462  prompt_input("? ");
463  if (last == first)
464  return;
465  c = buffer[first];
466  if (c >= 'a')
467  c = c + 'A' - 'a';
468  /*tex
469  Interpret code |c| and |return| if done. It is desirable to
470  provide an `\.E' option here that gives the user an easy way
471  to return from \TeX\ to the system editor, with the offending
472  line ready to be edited. But such an extension requires some
473  system wizardry, so the present implementation simply types
474  out the name of the file that should be edited and the
475  relevant line number.
476  */
477  switch (c) {
478  case '0':
479  case '1':
480  case '2':
481  case '3':
482  case '4':
483  case '5':
484  case '6':
485  case '7':
486  case '8':
487  case '9':
488  if (deletions_allowed) {
489  /*tex
490  Delete |c-"0"| tokens and |goto continue|. We allow
491  deletion of up to 99 tokens at a time.
492  */
493  s1 = cur_tok;
494  s2 = cur_cmd;
495  s3 = cur_chr;
496  s4 = align_state;
497  align_state = 1000000;
498  OK_to_interrupt = false;
499  if ((last > first + 1) && (buffer[first + 1] >= '0')
500  && (buffer[first + 1] <= '9'))
501  c = c * 10 + buffer[first + 1] - '0' * 11;
502  else
503  c = c - '0';
504  while (c > 0) {
505  /*tex One-level recursive call of |error| is possible. */
506  get_token();
507  decr(c);
508  }
509  cur_tok = s1;
510  cur_cmd = s2;
511  cur_chr = s3;
512  align_state = s4;
513  OK_to_interrupt = true;
514  help2(
515  "I have just deleted some text, as you asked.",
516  "You can now delete more, or insert, or whatever."
517  );
518  show_context();
519  goto CONTINUE;
520  }
521  break;
522  case 'E':
523  if (base_ptr > 0) {
524  int callback_id = callback_defined(call_edit_callback);
525  if (callback_id>0) {
526  (void)run_callback(callback_id, "Sd->", makecstring(input_stack[base_ptr].name_field), line);
527  /*tex This should not be reached. */
528  jump_out();
529  } else {
530  tprint_nl("You want to edit file ");
531  print(input_stack[base_ptr].name_field);
532  tprint(" at line ");
533  print_int(line);
535  if (kpse_init) {
537  } else {
538  /*tex This should not be reached. */
539  tprint_nl("There is no valid callback defined.");
540  jump_out();
541  }
542  }
543  }
544  break;
545  case 'H':
546  /*tex Print the help information and |goto continue| */
547  if (use_err_help) {
548  give_err_help();
549  } else {
550  if (help_line[0] == NULL) {
551  help2(
552  "Sorry, I don't know how to help in this situation.",
553  "Maybe you should try asking a human?"
554  );
555  }
556  i = 0;
557  while (help_line[i] != NULL)
558  tprint_nl(help_line[i++]);
559  help4(
560  "Sorry, I already gave what help I could...",
561  "Maybe you should try asking a human?",
562  "An error might have occurred before I noticed any problems.",
563  "``If all else fails, read the instructions.''"
564  );
565  goto CONTINUE;
566  }
567  break;
568  case 'I':
569  /*tex
570 
571  Introduce new material from the terminal and |return|. When
572  the following code is executed, |buffer[(first+1)..(last-1)]|
573  may contain the material inserted by the user; otherwise
574  another prompt will be given. In order to understand this
575  part of the program fully, you need to be familiar with
576  \TeX's input stacks.
577 
578  We enter a new syntactic level for terminal input:
579 
580  */
582  /*tex
583  Now |state=mid_line|, so an initial blank space will count as
584  a blank.
585  */
586  if (last > first + 1) {
587  iloc = first + 1;
588  buffer[first] = ' ';
589  } else {
590  prompt_input("insert>");
591  iloc = first;
592  }
593  first = last;
594  /*tex No |end_line_char| ends this line. */
595  ilimit = last - 1;
596  return;
597  break;
598  case 'Q':
599  case 'R':
600  case 'S':
601  /*tex
602 
603  Change the interaction level and |return|. Here the author of
604  \TeX\ apologizes for making use of the numerical relation
605  between |"Q"|, |"R"|, |"S"|, and the desired interaction
606  settings |batch_mode|, |nonstop_mode|, |scroll_mode|.
607 
608  */
609  error_count = 0;
610  interaction = batch_mode + c - 'Q';
611  tprint("OK, entering ");
612  switch (c) {
613  case 'Q':
614  tprint_esc("batchmode");
615  decr(selector);
616  break;
617  case 'R':
618  tprint_esc("nonstopmode");
619  break;
620  case 'S':
621  tprint_esc("scrollmode");
622  break;
623  }
624  tprint("...");
625  print_ln();
626  update_terminal();
627  return;
628  break;
629  case 'X':
631  jump_out();
632  break;
633  default:
634  break;
635  }
636  if (!use_err_help) {
637  /* Print the menu of available options */
638  tprint("Type <return> to proceed, S to scroll future error messages,");
639  tprint_nl("R to run without stopping, Q to run quietly,");
640  tprint_nl("I to insert something, ");
641  if (base_ptr > 0)
642  tprint("E to edit your file,");
643  if (deletions_allowed)
644  tprint_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
645  tprint_nl("H for help, X to quit.");
646  }
647  use_err_help = false;
648  }
649 
650  }
651  incr(error_count);
652  if (error_count == 100) {
653  tprint_nl("(That makes 100 errors; please try again.)");
655  jump_out();
656  }
657  /*tex Put help message on the transcript file. */
658  if (interaction > batch_mode) {
659  /*tex Avoid terminal output: */
660  decr(selector);
661  }
662  if (use_err_help) {
663  print_ln();
664  give_err_help();
665  } else {
666  int i1 = 0;
667  while (help_line[i1] != NULL)
668  tprint_nl(help_line[i1++]);
669  }
670  print_ln();
671  if (interaction > batch_mode) {
672  /*tex Re-enable terminal output: */
673  incr(selector);
674  }
675  print_ln();
676 }
677 
678 /*tex
679 
680 A dozen or so error messages end with a parenthesized integer, so we save a teeny
681 bit of program space by declaring the following procedure:
682 
683 */
684 
685 void int_error(int n)
686 {
687  tprint(" (");
688  print_int(n);
689  print_char(')');
690  error();
691 }
692 
693 /*tex
694 
695 In anomalous cases, the print selector might be in an unknown state; the
696 following subroutine is called to fix things just enough to keep running a bit
697 longer.
698 
699 */
700 
702 {
703  if (log_opened_global)
705  else
707  if (job_name == 0)
708  open_log_file();
709  if (interaction == batch_mode)
710  decr(selector);
711 }
712 
713 /*tex
714 
715 The following procedure prints \TeX's last words before dying.
716 
717 */
718 
719 void succumb(void)
720 {
721  if (interaction == error_stop_mode) {
722  /*tex No more interaction: */
724  }
725  if (log_opened_global) {
726  error();
727  }
729  /*tex Irrecoverable error: */
730  jump_out();
731 }
732 
733 /*tex
734 
735 This prints |s|, and that's it.
736 
737 */
738 
739 void fatal_error(const char *s)
740 {
742  print_err("Emergency stop");
743  help1(s);
744  succumb();
745 }
746 
747 /*tex
748 
749 Here is the most dreaded error message. We stop due to finiteness.
750 
751 */
752 
753 void overflow(const char *s, unsigned int n)
754 {
756  print_err("TeX capacity exceeded, sorry [");
757  tprint(s);
758  print_char('=');
759  print_int((int) n);
760  print_char(']');
761  if (varmem == NULL) {
762  print_err("Sorry, I ran out of memory.");
763  print_ln();
765  }
766  help2(
767  "If you really absolutely need more capacity,",
768  "you can ask a wizard to enlarge me."
769  );
770  succumb();
771 }
772 
773 /*tex
774 
775 The program might sometime run completely amok, at which point there is no choice
776 but to stop. If no previous error has been detected, that's bad news; a message
777 is printed that is really intended for the \TeX\ maintenance person instead of
778 the user (unless the user has been particularly diabolical). The index entries
779 for `this can't happen' may help to pinpoint the problem. @^dry rot@>
780 
781 */
782 
783 void confusion(const char *s)
784 { /* consistency check violated; |s| tells where */
787  print_err("This can't happen (");
788  tprint(s);
789  print_char(')');
790  help1(
791  "I'm broken. Please show this to someone who can fix"
792  );
793  } else {
794  print_err("I can't go on meeting you like this");
795  help2(
796  "One of your faux pas seems to have wounded me deeply...",
797  "in fact, I'm barely conscious. Please fix it and try again."
798  );
799  }
800  succumb();
801 }
802 
803 /*tex
804 
805 Users occasionally want to interrupt \TeX\ while it's running. If the runtime
806 system allows this, one can implement a routine that sets the global variable
807 |interrupt| to some nonzero value when such an interrupt is signalled. Otherwise
808 there is probably at least a way to make |interrupt| nonzero using the debugger.
809 @^system dependencies@> @^debugging@>
810 
811 */
812 
813 void check_interrupt(void)
814 {
815  if (interrupt != 0)
817 }
818 
819 /*tex
820 
821 When an interrupt has been detected, the program goes into its highest
822 interaction level and lets the user have nearly the full flexibility of the
823 |error| routine. \TeX\ checks for interrupts only at times when it is safe to do
824 this.
825 
826 */
827 
829 {
830  if (OK_to_interrupt) {
832  if ((selector == log_only) || (selector == no_print))
833  incr(selector);
834  print_err("Interruption");
835  help3(
836  "You rang?",
837  "Try to insert some instructions for me (e.g.,`I\\showlists'),",
838  "unless you just want to quit by typing `X'."
839  );
840  deletions_allowed = false;
841  error();
842  deletions_allowed = true;
843  interrupt = 0;
844  }
845 }
846 
847 void tex_error(const char *msg, const char **hlp)
848 {
849  print_err(msg);
850  if (hlp != NULL) {
851  int i;
852  for (i = 0; (hlp[i] != NULL && i <= 5); i++) {
853  help_line[i] = hlp[i];
854  }
855  help_line[i] = NULL;
856  } else {
857  help_line[0] = NULL;
858  }
859  error();
860 }
861 
862 /*tex
863 
864 The |back_error| routine is used when we want to replace an offending token just
865 before issuing an error message. This routine, like |back_input|, requires that
866 |cur_tok| has been set. We disable interrupts during the call of |back_input| so
867 that the help message won't be lost.
868 
869 */
870 
871 void back_error(void)
872 {
873  OK_to_interrupt = false;
874  back_input();
875  OK_to_interrupt = true;
876  error();
877 }
878 
879 /*tex
880 
881  Back up one inserted token and call |error|.
882 */
883 
884 void ins_error(void)
885 {
886  OK_to_interrupt = false;
887  back_input();
889  OK_to_interrupt = true;
890  error();
891 }
892 
893 /*tex
894 
895 When \TeX\ wants to typeset a character that doesn't exist, the character node is
896 not created; thus the output routine can assume that characters exist when it
897 sees them. The following procedure prints a warning message unless the user has
898 suppressed it.
899 If |tracing_lost_chars_par| (i.e. \.{\\tracinglostchar}) is greater than 2,
900 it's considered as an error.
901 
902 */
903 
905 {
906  /*tex saved value of |tracing_online| */
907  int old_setting;
908  /* index to current digit; we assume that $0\L n<16^{22}$ */
909  int k;
910  if (tracing_lost_chars_par > 0) {
912  if (tracing_lost_chars_par > 1)
913  tracing_online_par = 1;
915  tprint_nl("Missing character: There is no ");
916  print(c);
917  tprint(" (U+");
918  k = 0;
919  if (c < 16)
920  print_char('0');
921  if (c < 256)
922  print_char('0');
923  if (c < 4096)
924  print_char('0');
925  do {
926  dig[k] = c % 16;
927  c = c / 16;
928  incr(k);
929  } while (c != 0);
931  tprint(") in font ");
933  print_char('!');
934  end_diagnostic(false);
936  }
937  if (tracing_lost_chars_par > 2) {
938  error();
939  }
940 }
941 
942 void wrapup_backend(void) {
944  if (output_mode_used == OMODE_NONE) {
945  print_err(" ==> Fatal error occurred, no FMT file produced!");
946  } else {
948  }
949 }
950 
951 void normal_error(const char *t, const char *p)
952 {
954  if (interaction == error_stop_mode) {
956  }
957  if (filelineerrorstylep) {
958  print_file_line();
959  } else {
960  tprint_nl("! ");
961  }
962  tprint("error: ");
963  if (cur_file_name) {
964  tprint(" (file ");
966  tprint(")");
967  }
968  if (t != NULL) {
969  tprint(" (");
970  tprint(t);
971  tprint(")");
972  }
973  tprint(": ");
974  if (p != NULL)
975  tprint(p);
977  wrapup_backend();
979 }
980 
981 void normal_warning(const char *t, const char *p)
982 {
983  int report_id ;
984  if (strcmp(t,"lua") == 0) {
985  int saved_new_line_char;
986  saved_new_line_char = new_line_char_par;
987  new_line_char_par = 10;
989  if (report_id == 0) {
990  if (p != NULL)
991  tprint(p);
992  help2(
993  "The lua interpreter ran into a problem, so the",
994  "remainder of this lua chunk will be ignored."
995  );
996  } else {
997  (void) run_callback(report_id, "->");
998  }
999  error();
1000  new_line_char_par = saved_new_line_char;
1001  } else {
1003  if (report_id > 0) {
1004  /*tex Free the last ones, */
1011  run_callback(report_id, "->");
1012  } else {
1013  print_ln();
1014  tprint("warning ");
1015  if (cur_file_name) {
1016  tprint(" (file ");
1018  tprint(")");
1019  }
1020  if (t != NULL) {
1021  tprint(" (");
1022  tprint(t);
1023  tprint(")");
1024  }
1025  tprint(": ");
1026  if (p != NULL)
1027  tprint(p);
1028  print_ln();
1029  }
1030  if (history == spotless)
1032  }
1033 }
1034 
1036 
1037 __attribute__ ((format(printf, 2,3)))
1038 void formatted_error(const char *t, const char *fmt, ...)
1039 {
1040  va_list args;
1041  va_start(args, fmt);
1044  va_end(args);
1045 }
1046 
1047 __attribute__ ((format(printf, 2,3)))
1049 {
1050  va_list args;
1051  va_start(args, fmt);
1054  va_end(args);
1055 }
void give_err_help(void)
Definition: aptex-src.c:36017
void close_files_and_terminate(void)
Definition: aptex-src.c:36094
void get_token(void)
Definition: aptex-src.c:14331
static void prompt_input(const char *s)
void print_int(integer n)
Definition: aptex-src.c:7042
void back_input(void)
Definition: aptex-src.c:14086
void print_char(ASCII_code s)
Definition: aptex-src.c:6782
void show_context(void)
Definition: aptex-src.c:13728
void begin_file_reading(void)
Definition: aptex-src.c:14130
void clear_for_error_prompt(void)
Definition: aptex-src.c:14177
void open_log_file(void)
Definition: aptex-src.c:19506
@ error_message_issued
Definition: aptex-macros.h:95
@ fatal_error_stop
Definition: aptex-macros.h:96
@ warning_issued
Definition: aptex-macros.h:94
#define help2(...)
Definition: aptex-macros.h:101
#define help1(...)
Definition: aptex-macros.h:100
#define help4(...)
Definition: aptex-macros.h:103
@ batch_mode
Definition: aptex-macros.h:85
@ error_stop_mode
Definition: aptex-macros.h:88
@ scroll_mode
Definition: aptex-macros.h:87
#define help3(...)
Definition: aptex-macros.h:102
@ term_only
Definition: aptex-macros.h:75
@ no_print
Definition: aptex-macros.h:74
@ log_only
Definition: aptex-macros.h:76
@ new_string
Definition: aptex-macros.h:79
@ term_and_log
Definition: aptex-macros.h:77
static void print_the_digs(eight_bits k)
Definition: aptex-src.c:7028
void end_diagnostic(boolean blank_line)
Definition: aptex-src.c:11249
void begin_diagnostic(void)
Definition: aptex-src.c:11235
static uint32_t dig[23+1]
Definition: aptex.h:306
integer str_number
Definition: aptex.h:196
static halfword cur_chr
Definition: aptex.h:407
uint8_t ASCII_code
Definition: aptex.h:109
integer internal_font_number
Definition: aptex.h:269
static integer align_state
Definition: aptex.h:433
static int cur_cmd
Definition: aptex.h:406
static in_state_record * input_stack
Definition: aptex.h:411
static int old_setting
Definition: aptex.h:381
static uint32_t selector
Definition: aptex.h:305
static integer ready_already
Definition: aptex.h:720
static halfword cur_tok
Definition: aptex.h:409
static integer base_ptr
Definition: aptex.h:435
backend_function * backend_out_control
Definition: backend.c:11
@ backend_control_finish_file
Definition: backend.h:22
#define static
#define n
Definition: t4ht.c:1290
int linenumber
Definition: devnag.c:401
int command
Definition: t4ht.c:934
#define xfree(p)
Definition: ptexmac.h:85
#define PRINTF_BUF_SIZE
Definition: ptexmac.h:35
int strcmp()
Definition: coll.cpp:143
int printf()
char * strcpy()
char * temp
Definition: dvidvi.c:137
#define IS_DIR_SEP
Definition: dvidvi.c:106
void flush_str(void)
Definition: dvispc.c:1768
#define tracing_online_par
Definition: equivalents.h:745
#define tracing_lost_chars_par
Definition: equivalents.h:748
#define new_line_char_par
Definition: equivalents.h:661
static char print_buf[1024]
Definition: errors.c:1035
void print_err(const char *s)
Definition: errors.c:115
int interrupt
Definition: errors.c:199
void normal_error(const char *t, const char *p)
Definition: errors.c:951
char * last_warning_tag
Definition: errors.c:59
int interactionoption
Definition: errors.c:55
char * last_error_context
Definition: errors.c:61
static void luatex_calledit(int baseptr, int linenumber)
Definition: errors.c:291
void formatted_error(const char *t, const char *fmt,...)
Definition: errors.c:1038
static const_string edit_value
Definition: errors.c:279
void normal_warning(const char *t, const char *p)
Definition: errors.c:981
boolean use_err_help
Definition: errors.c:240
const char * help_line[7]
Definition: errors.c:234
void normalize_selector(void)
Definition: errors.c:701
void error(void)
Definition: errors.c:419
void succumb(void)
Definition: errors.c:719
char * last_lua_error
Definition: errors.c:58
void char_warning(internal_font_number f, int c)
Definition: errors.c:904
void confusion(const char *s)
Definition: errors.c:783
void fatal_error(const char *s)
Definition: errors.c:739
void back_error(void)
Definition: errors.c:871
int defaultexitcode
Definition: errors.c:250
char * last_error
Definition: errors.c:57
#define edit_var
Definition: errors.c:25
int interaction
Definition: errors.c:51
void do_final_end(void)
Definition: errors.c:253
void ins_error(void)
Definition: errors.c:884
void flush_err(void)
Definition: errors.c:88
int err_old_setting
Definition: errors.c:63
int history
Definition: errors.c:191
void jump_out(void)
Definition: errors.c:265
boolean set_box_allowed
Definition: errors.c:188
int in_error
Definition: errors.c:64
void pause_for_instructions(void)
Definition: errors.c:828
void tex_error(const char *msg, const char **hlp)
Definition: errors.c:847
void initialize_errors(void)
Definition: errors.c:212
void fixup_selector(boolean logopened)
Definition: errors.c:154
int error_count
Definition: errors.c:195
void overflow(const char *s, unsigned int n)
Definition: errors.c:753
boolean deletions_allowed
Definition: errors.c:184
boolean OK_to_interrupt
Definition: errors.c:203
char * last_warning_str
Definition: errors.c:60
void int_error(int n)
Definition: errors.c:685
void formatted_warning(const char *t, const char *fmt,...)
Definition: errors.c:1048
void wrapup_backend(void)
Definition: errors.c:942
void set_last_error_context(void)
Definition: errors.c:66
void check_interrupt(void)
Definition: errors.c:813
@ unspecified_mode
Definition: errors.h:34
static void
Definition: fpif.c:118
mpz_t * f
Definition: gen-fib.c:34
#define s
Definition: afcover.h:80
#define c(n)
Definition: gpos-common.c:150
#define iloc
Definition: inputstack.h:48
#define ilimit
Definition: inputstack.h:52
@ inserted
Definition: inputstack.h:296
#define EXIT_FAILURE
Definition: cdjpeg.h:169
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
#define const
Definition: ftzconf.h:91
void exit()
char * getenv()
#define xmalloc(size)
Definition: writet1.c:33
#define FATAL1(str, e1)
Definition: lib.h:63
const char * const_string
Definition: simpletypes.h:59
#define system(p)
Definition: win32lib.h:269
#define fprintf
Definition: mendex.h:64
#define EDITOR
Definition: acconfig.h:37
#define decr(x)
Definition: cpascal.h:91
#define incr(x)
Definition: cpascal.h:92
#define update_terminal
Definition: ctangleboot.c:88
#define cur_file_name
Definition: ctangleboot.c:60
#define string
Definition: ctangleboot.c:111
#define spotless
Definition: ctangleboot.c:72
uint8_t eight_bits
Definition: ctangleboot.c:165
#define __attribute__(A)
Definition: synctex.c:338
#define print_ln(v)
Definition: tie.c:37
char args[100]
Definition: fixwrites.c:7
#define vsnprintf
Definition: snprintf.c:40
#define sprintf
Definition: snprintf.c:44
int run_callback(int i, const char *values,...)
Definition: lcallbacklib.c:259
token_type
Definition: scripting.h:54
int kpse_init
Definition: luainit.c:189
@ OMODE_NONE
Definition: luatex-api.h:25
int output_mode_used
Definition: pdfgen.c:37
@ show_lua_error_hook_callback
@ show_warning_message_callback
@ show_error_message_callback
@ call_edit_callback
@ show_error_hook_callback
#define callback_defined(a)
int haltonerrorp
Definition: mainbody.c:295
int filelineerrorstylep
Definition: mainbody.c:291
static lua_State * Luas[1]
Definition: mfluac.c:37
int k
Definition: otp-parser.c:70
#define Isspace(c)
Definition: p2clib.c:20
static int format
Definition: pbmclean.c:15
#define print(s)
Definition: pbmtoln03.c:48
char * filename[256]
Definition: pbmtopk.c:46
PDF static_pdf
Definition: pdfgen.c:33
void ensure_output_state(PDF pdf, output_state s)
Definition: pdfgen.c:1029
@ ST_OMODE_FIX
Definition: pdftypes.h:122
#define fp
static int cnt
Definition: pkout.c:166
#define uexit
Definition: pmakempx.c:110
static int32_t last
Definition: ppagelist.c:29
static int32_t first
Definition: ppagelist.c:29
void print_file_line(void)
Definition: printing.c:1249
void tprint(const char *sss)
Definition: printing.c:415
void tprint_esc(const char *s)
Definition: printing.c:624
void tprint_nl(const char *s)
Definition: printing.c:521
int new_string_line
Definition: printing.c:30
#define print_font_name(A)
Definition: printing.h:84
char line[1024]
Definition: process_score.c:29
#define isalpha(ch)
Definition: utype.h:82
void lua_close(lua_State *L)
Definition: lstate.c:341
static void make_string(char **ppstr, int n)
Definition: scanid.c:232
#define str(s)
Definition: sh6.c:399
char * makecstring(int s)
Definition: stringpool.c:284
#define str_room(wsize)
Definition: stringpool.h:90
Definition: usprintf.c:39
Definition: utils.c:300
Definition: sh.h:1689
Definition: bdf.c:133
Definition: texview.c:48
Definition: dvips.h:235
s1
Definition: t4ht.c:1059
static char job_name[255]
Definition: t4ht.c:484
char * s2
Definition: t4ht.c:1062
*job_name strlen((char *) job_name) - 4)
char fmt[256]
Definition: tex4ht.c:3925
boolean log_opened_global
Definition: texfileio.c:862
#define wake_up_terminal()
Definition: texfileio.h:86
memory_word *volatile varmem
Definition: texnodes.c:38
#define s4
Definition: tokst.h:125
#define s3
Definition: tokst.h:105
#define va_start(pvar)
Definition: varargs.h:30
#define va_end(pvar)
Definition: varargs.h:38
char * va_list
Definition: varargs.h:22