1 /* luatex.c: Hand-coded routines for TeX or Metafont in C. Originally
2 written by Tim Morgan, drawing from other Unix ports of TeX. This is
3 a collection of miscellany, everything that's easier (or only
6 This file is public domain. */
8 /* This file is used to create texextra.c etc., with this line
9 changed to include texd.h or mfd.h. The ?d.h file is what
10 #defines TeX or MF, which avoids the need for a special
13 /* We |#define DLLPROC| in order to build LuaTeX and LuajitTeX as DLL
16 #define DLLPROC dllluajittexmain
18 #define DLLPROC dllluatexmain
23 #include "lua/luatex-api.h"
25 #include "luatex_svnversion.h"
31 int luatex_version
= 98; /* \.{\\luatexversion} */
32 int luatex_revision
= '3'; /* \.{\\luatexrevision} */
33 int luatex_date_info
= 2016081300; /* the compile date is now hardwired */
34 const char *luatex_version_string
= "0.98.3";
35 const char *engine_name
= my_name
; /* the name of this engine */
37 #include <kpathsea/c-ctype.h>
38 #include <kpathsea/line.h>
39 #include <kpathsea/readable.h>
40 #include <kpathsea/variable.h>
41 #include <kpathsea/absolute.h>
43 #include <kpathsea/concatn.h>
50 #include <time.h> /* For `struct tm'. */
51 #if defined (HAVE_SYS_TIME_H)
52 # include <sys/time.h>
53 #elif defined (HAVE_SYS_TIMEB_H)
54 # include <sys/timeb.h>
61 #include <signal.h> /* Catch interrupts. */
64 /* {tex,mf}d.h defines TeX, MF, INI, and other such symbols.
65 Unfortunately there's no way to get the banner into this code, so
66 just repeat the text. */
67 #define edit_var "TEXEDIT"
71 If shellenabledp == 0, all shell escapes are forbidden.
72 If (shellenabledp == 1 && restrictedshell == 0), any command
73 is allowed for a shell escape.
74 If (shellenabledp == 1 && restrictedshell == 1), only commands
75 given in the configuration file as
76 shell_escape_commands = kpsewhich,ebb,extractbb,mpost,metafun,...
77 (no spaces between commands) in texmf.cnf are allowed for a shell
78 escape in a restricted form: command name and arguments should be
79 separated by a white space. The first word should be a command
80 name. The quotation character for an argument with spaces,
81 including a pathname, should be ". ' should not be used.
83 Internally, all arguments are quoted by ' (Unix) or " (Windows)
84 before calling the system() function in order to forbid execution
85 of any embedded command.
87 If the --shell-escape option is given, we set
88 shellenabledp = 1 and restrictedshell = 0, i.e., any command is allowed.
89 If the --shell-restricted option is given, we set
90 shellenabledp = 1 and restrictedshell = 1, i.e., only given cmds allowed.
91 If the --no-shell-escape option is given, we set
92 shellenabledp = -1 (and restrictedshell is irrelevant).
93 If none of these option are given, there are three cases:
98 it becomes shellenabledp = 1 and restrictedshell = 0,
99 that is, any command is allowed.
100 (2) In the case where
102 it becomes shellenabledp = 1 and restrictedshell = 1,
103 that is, restricted shell escape is allowed.
104 (3) In all other cases, shellenabledp = 0, that is, shell
105 escape is forbidden. The value of restrictedshell is
106 irrelevant if shellenabledp == 0.
111 /* cmdlist is a list of allowed commands which are given like this:
112 shell_escape_commands = kpsewhich,ebb,extractbb,mpost,metafun
115 static char **cmdlist
= NULL
;
117 void mk_shellcmdlist(char *v
)
126 /* analyze the variable shell_escape_commands = foo,bar,...
127 spaces before and after (,) are not allowed. */
129 while ((r
= strchr(q
, ',')) != 0) {
135 cmdlist
= (char **) xmalloc(n
* sizeof (char *));
138 while ((r
= strchr(q
, ',')) != 0) {
148 /* Called from maininit. Not static because also called from
149 luatexdir/lua/luainit.c. */
152 In order to avoid all kind of time code in the backend code we use a function.
153 The start time can be overloaded in several ways:
155 (1) By setting the environmment variable SOURCE_DATE_EPOCH. This will influence
156 the tex parameters, random seed, pdf timestamp and pdf id that is derived
157 from the time. This variable is consulted when the kpse library is enabled
158 which is analogue to other properties.
160 (2) By setting the texconfig.start_time variable (as with other variables
161 we use the internal name there). This has the same effect as (1) and is
162 provided for when kpse is not used to set these variables or when an overloaded
163 is wanted. This is analogue to other properties.
165 When an utc time is needed one can provide the flag --utc. This property is
166 independent of this time hackery. This flag has a corresponding texconfig
169 To some extend a cleaner solution would be to have a flag that disables all
170 variable data in one go (like filenames and so) but we just follow the method
171 implemented in pdftex where primitives are used tod disable it.
175 static int start_time
= -1;
177 int get_start_time(void) {
178 if (start_time
< 0) {
179 start_time
= time((time_t *) NULL
);
185 This one is called as part of the kpse initialization which only happens
186 when this library is enabled.
188 #if defined(_MSC_VER)
189 #define strtoull _strtoui64
192 void init_start_time(void) {
193 if (start_time
< 0) {
194 unsigned long long epoch
;
197 We don't really care how kpse sets up this variable but we prefer to
198 just use its abstract interface.
200 /* char *source_date_epoch = getenv("SOURCE_DATE_EPOCH"); */
201 char *source_date_epoch
= kpse_var_value("SOURCE_DATE_EPOCH");
202 if (source_date_epoch
&& source_date_epoch
!= '\0' ) {
204 epoch
= strtoull(source_date_epoch
, &endptr
, 10);
205 if (epoch
< 0 || *endptr
!= '\0' || errno
!= 0) {
208 #if defined(_MSC_VER)
209 /* We avoid to crash if users test a large value which is not
210 * supported by Visual Studio 2010:
211 * a later time than 3001/01/01 20:59:59.
213 if (epoch
> 32535291599ULL)
214 epoch
= 32535291599ULL;
222 This one is used to fetch a value from texconfig which can also be used to
223 set properties. This might come in handy when one has other ways to get date
224 info in the pdf file.
227 void set_start_time(int s
) {
233 void init_shell_escape(void)
235 if (shellenabledp
< 0) { /* --no-shell-escape on cmd line */
239 if (shellenabledp
== 0) { /* no shell options on cmd line, check cnf */
240 char *v1
= kpse_var_value("shell_escape");
242 if (*v1
== 't' || *v1
== 'y' || *v1
== '1') {
244 } else if (*v1
== 'p') {
252 /* If shell escapes are restricted, get allowed cmds from cnf. */
253 if (shellenabledp
&& restrictedshell
== 1) {
254 char *v2
= kpse_var_value("shell_escape_commands");
271 static int char_needs_quote(int c
)
273 /* special characters of cmd.exe */
275 return (c
== '&' || c
== '|' || c
== '%' || c
== '<' ||
276 c
== '>' || c
== ';' || c
== ',' || c
== '(' || c
== ')');
281 static int Isspace(char c
)
283 return (c
== ' ' || c
== '\t');
287 -1 : invalid quotation of an argument
288 0 : command is not allowed
289 2 : restricted shell escape, CMD is allowed.
291 We set *SAFECMD to a safely-quoted version of *CMD; this is what
292 should get executed. And we set CMDNAME to its first word; this is
293 what is checked against the shell_escape_commands list. */
295 int shell_cmd_is_allowed(const char *cmd
, char **safecmd
, char **cmdname
)
305 /* pre == 1 means that the previous character is a white space
306 pre == 0 means that the previous character is not a white space */
307 buf
= xmalloc(strlen(cmd
) + 1);
313 while (!Isspace(*d
) && *d
)
317 /* *cmdname is the first word of the command line. For example,
318 *cmdname == "kpsewhich" for
319 \write18{kpsewhich --progname=dvipdfm --format="other text files" config}
321 *cmdname
= xstrdup(c
);
324 /* Is *cmdname listed in a texmf.cnf vriable as
325 shell_escape_commands = foo,bar,... ? */
329 if (strcmp(*p
, *cmdname
) == 0) {
330 /* *cmdname is found in the list, so restricted shell escape
340 for (s
= cmd
; *s
; s
++) {
345 /* allocate enough memory (too much?) */
347 *safecmd
= xmalloc(2 * strlen(cmd
) + 3 + 2 * spaces
);
349 *safecmd
= xmalloc(strlen(cmd
) + 3 + 2 * spaces
);
352 /* make a safe command line *safecmd */
357 while (!Isspace(*s
) && *s
)
362 /* Quotation given by a user. " should always be used; we
363 transform it below. On Unix, if ' is used, simply immediately
364 return a quotation error. */
370 /* All arguments are quoted as 'foo' (Unix) or "foo" (Windows)
371 before calling system(). Therefore closing QUOTE is necessary
372 if the previous character is not a white space.
374 --format="other text files" becomes
375 '--format=''other text files' (Unix)
376 "--format"="other text files" (Windows) */
392 /* output the quotation mark for the quoted argument */
397 /* Illegal use of ', or closing quotation mark is missing */
398 if (*s
== '\'' || *s
== '\0')
402 if (char_needs_quote(*s
))
409 /* Closing quotation mark will be output afterwards, so
410 we do nothing here */
413 /* The character after the closing quotation mark
414 should be a white space or NULL */
415 if (!Isspace(*s
) && *s
)
418 /* Beginning of a usual argument */
419 } else if (pre
== 1 && !Isspace(*s
)) {
424 if (char_needs_quote(*s
))
429 /* Ending of a usual argument */
431 } else if (pre
== 0 && Isspace(*s
)) {
433 /* Closing quotation mark */
437 /* Copy a character from cmd to *safecmd. */
440 if (char_needs_quote(*s
))
447 /* End of the command line */
456 if (strlen (p
) > 2 && p
[1] == ':' && !IS_DIR_SEP (p
[2])) {
457 q
= xmalloc (strlen (p
) + 2);
465 } else if (!IS_DIR_SEP (p
[0]) && !(p
[1] == ':' && IS_DIR_SEP (p
[2]))) {
466 p
= kpse_var_value ("SELFAUTOLOC");
469 while (*r
&& !Isspace(*r
))
472 q
= concatn ("\"", p
, "/", *safecmd
, "\"", NULL
);
476 while (*r
&& Isspace(*r
))
479 q
= concatn ("\"", p
, "/", *safecmd
, "\" ", r
, NULL
);
481 q
= concatn ("\"", p
, "/", *safecmd
, "\"", NULL
);
498 /* What we were invoked as and with. */
502 /* The C version of what might wind up in |TEX_format_default|. */
505 /* The C version of the jobname, if given. */
506 const_string c_job_name
;
508 const char *luatex_banner
;
511 /* Invalid parameter handler */
512 static void myInvalidParameterHandler(const wchar_t * expression
,
513 const wchar_t * function
,
514 const wchar_t * file
,
519 printf(L"Invalid parameter detected in function %s."
520 L" File: %s Line: %d\n", function, file, line);
521 printf(L"Expression: %s\n", expression);
524 I return silently to avoid an exit with the error 0xc0000417
525 (invalid parameter) when we use non-embedded fonts in luatex-ja,
526 which works without any problem on Unix systems.
527 I hope it is not dangerous.
533 /* The entry point: set up for reading the command line, which will
534 happen in `topenin', then call the main body. */
538 DLLPROC (int ac
, string
*av
)
540 main (int ac
, string
*av
)
550 _set_invalid_parameter_handler(myInvalidParameterHandler
);
552 av
[0] = kpse_program_basename (av
[0]);
555 * We choose to crash for fatal errors
556 SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
558 setmode(fileno(stdin
), _O_BINARY
);
561 lua_initialize(ac
, av
);
566 if ((strlen(av
[ac
-1]) > 2) &&
567 isalpha(av
[ac
-1][0]) &&
568 (av
[ac
-1][1] == ':') &&
569 (av
[ac
-1][2] == '\\')) {
570 for (pp
=av
[ac
-1]+2; *pp
; pp
++) {
582 /* Call the real main program. */
589 /* This is supposed to ``open the terminal for input'', but what we
590 really do is copy command line arguments into TeX's or Metafont's
591 buffer, so they can handle them. If nothing is available, or we've
592 been called already (and hence, argc==0), we return with
600 buffer
[first
] = 0; /* In case there are no arguments. */
602 if (optind
< argc
) { /* We have command line arguments. */
604 for (i
= optind
; i
< argc
; i
++) {
605 char *ptr
= &(argv
[i
][0]);
606 /* Don't use strcat, since in Aleph the buffer elements aren't
609 buffer
[k
++] = (packed_ASCII_code
) * (ptr
++);
613 argc
= 0; /* Don't do this again. */
617 /* Find the end of the buffer. */
618 for (last
= first
; buffer
[last
]; ++last
);
620 /* Make `last' be one past the last non-blank character in `buffer'. */
621 /* ??? The test for '\r' should not be necessary. */
622 for (--last
; last
>= first
623 && ISBLANK(buffer
[last
]) && buffer
[last
] != '\r'; --last
);
626 /* One more time, this time converting to TeX's internal character
630 /* IPC for TeX. By Tom Rokicki for the NeXT; it makes TeX ship out the
631 DVI file in a pipe to TeXView so that the output can be displayed
632 incrementally. Shamim Mohamed adapted it for Web2c. */
633 #if defined (TeX) && defined (IPC)
637 #include <winsock2.h>
639 #include <sys/socket.h>
641 #ifndef O_NONBLOCK /* POSIX */
642 #ifdef O_NDELAY /* BSD */
643 #define O_NONBLOCK O_NDELAY
644 #elif defined(O_FNDELAY) /* NeXT */
645 #define O_NONBLOCK O_FNDELAY
647 what the fcntl
? cannot implement IPC without equivalent
for O_NONBLOCK
.
649 #endif /* no O_NONBLOCK */
653 # define IPC_AF AF_INET
654 # ifndef IPC_LOCAL_HOST
655 # define IPC_LOCAL_HOST "127.0.0.1"
656 # define FIXED_PORT (unsigned short)4242
659 # define IPC_AF AF_UNIX
660 # ifndef IPC_PIPE_NAME /* $HOME is prepended to this. */
661 # define IPC_PIPE_NAME "/.TeXview_Pipe"
664 #ifndef IPC_SERVER_CMD /* Command to run to start the server. */
666 # define IPC_SERVER_CMD "texview.exe"
668 # define IPC_SERVER_CMD "open `which TeXview`"
674 int namelength
; /* length of auxiliary data */
675 int eof
; /* new eof for dvi file */
676 #if 0 /* see usage of struct msg below */
677 char more_data
[0]; /* where the rest of the stuff goes */
681 static struct sockaddr
*ipc_addr
;
682 static int ipc_addr_len
;
687 if (ipc_addr_len
== 0) {
689 unsigned long remote_addr
= inet_addr(IPC_LOCAL_HOST
);
690 if (remote_addr
!= INADDR_NONE
) {
691 struct sockaddr_in
*ipc_sin_addr
= xmalloc (sizeof (struct sockaddr_in
));
692 ipc_sin_addr
->sin_family
= AF_INET
;
693 ipc_sin_addr
->sin_addr
.s_addr
= remote_addr
;
694 ipc_sin_addr
->sin_port
= htons (FIXED_PORT
);
695 ipc_addr
= ((struct sockaddr
*) ipc_sin_addr
);
696 ipc_addr_len
= sizeof(struct sockaddr_in
);
699 string s
= getenv ("HOME");
702 ipc_addr
= xmalloc (strlen (s
) + 40);
703 ipc_addr
->sa_family
= 0;
704 ipc_name
= ipc_addr
->sa_data
;
705 strcpy (ipc_name
, s
);
706 strcat (ipc_name
, IPC_PIPE_NAME
);
707 ipc_addr_len
= strlen (ipc_name
) + 3;
714 static int sock
= -1;
717 # define CLOSE_SOCKET(s) closesocket (s); WSACleanup ()
719 # define CLOSE_SOCKET(s) close (s)
729 ipc_open_out (void) {
731 struct WSAData wsaData
;
733 unsigned long mode
= 1;
736 fputs ("tex: Opening socket for IPC output ...\n", stderr
);
743 if ((nCode
= WSAStartup(MAKEWORD(1, 1), &wsaData
)) != 0) {
744 fprintf(stderr
,"WSAStartup() returned error code %d.\n", nCode
);
749 if (ipc_make_name () <= 0)
752 sock
= socket (IPC_AF
, SOCK_STREAM
, 0);
755 fprintf(stderr
, "tex: Socket handle is %d\n", sock
);
757 fprintf(stderr
, "tex: Socket is invalid.\n");
761 if (connect (sock
, ipc_addr
, ipc_addr_len
) != 0 ||
763 ioctlsocket (sock
, FIONBIO
, &mode
) < 0
765 fcntl (sock
, F_SETFL
, O_NONBLOCK
) < 0
771 fputs ("tex: IPC socket cannot be connected.\n", stderr
);
772 fputs ("tex: Socket is closed.\n", stderr
);
777 fputs ("tex: Successfully opened IPC socket.\n", stderr
);
786 fputs ("tex: Closing output socket ...\n", stderr
);
788 if (ipc_is_open ()) {
795 ipc_snd (int n
, int is_eof
, char *data
)
800 char more_data
[1024];
803 if (!ipc_is_open ()) {
808 fprintf(stderr
, "%d\t%d\n", ourmsg
.msg
.namelength
, ourmsg
.msg
.eof
);
809 fputs ("tex: Sending message to socket ...\n", stderr
);
811 ourmsg
.msg
.namelength
= n
;
812 ourmsg
.msg
.eof
= is_eof
;
814 strcpy (ourmsg
.more_data
, data
);
816 n
+= sizeof (struct msg
);
818 fprintf(stderr
, "%d\t%d\n", ourmsg
.msg
.namelength
, ourmsg
.msg
.eof
);
819 fputs ("tex: Writing to socket...\n", stderr
);
822 if (send (sock
, (char *)&ourmsg
, n
, 0) != n
) {
824 if (write (sock
, &ourmsg
, n
) != n
) {
829 fputs ("tex: IPC message sent.\n", stderr
);
833 /* This routine notifies the server if there is an eof, or the filename
834 if a new DVI file is starting. This is the routine called by TeX.
835 Aleph defines str_start(#) as str_start_ar[# - too_big_char], with
836 too_big_char = biggest_char + 1 = 65536 (omstr.ch). */
841 static boolean begun
= false;
846 string name
; /* Just the filename. */
847 string cwd
= xgetcwd ();
851 /* Have to pass whole filename to the other end, since it may have
852 been started up and running as a daemon, e.g., as with the NeXT
854 name
= static_pdf
->file_name
;
855 p
= concat3 (cwd
, DIR_SEP_STRING
, name
);
861 for (q
= p
; *q
; q
++) {
864 else if (IS_KANJI(q
))
872 ipc_snd (len
, is_eof
, p
);
877 #endif /* TeX && IPC */
879 /* Normalize quoting of filename -- that is, only quote if there is a space,
880 and always use the quote-name-quote style. */
881 string
normalize_quotes(const_string name
, const_string mesg
)
883 boolean quoted
= false;
884 boolean must_quote
= (strchr(name
, ' ') != NULL
);
885 /* Leave room for quotes and NUL. */
886 string ret
= (string
) xmalloc((unsigned) strlen(name
) + 3);
892 for (q
= name
; *q
; q
++) {
902 fprintf(stderr
, "! Unbalanced quotes in %s %s\n", mesg
, name
);
909 /* All our interrupt handler has to do is set TeX's or Metafont's global
910 variable `interrupt'; then they will do everything needed. */
912 /* Win32 doesn't set SIGINT ... */
913 static BOOL WINAPI
catch_interrupt(DWORD arg
)
917 case CTRL_BREAK_EVENT
:
921 /* No need to set interrupt as we are exiting anyway */
925 #else /* not WIN32 */
926 static RETSIGTYPE
catch_interrupt(int arg
)
931 (void) signal(SIGINT
, SIG_ACK
);
933 (void) signal(SIGINT
, catch_interrupt
);
934 # endif /* not OS2 */
936 #endif /* not WIN32 */
938 /* Besides getting the date and time here, we also set up the interrupt
939 handler, for no particularly good reason. It's just that since the
940 `fix_date_and_time' routine is called early on (section 1337 in TeX,
941 ``Get the first line of input and prepare to start''), this is as
942 good a place as any. */
944 void get_date_and_time(int *minutes
, int *day
, int *month
, int *year
)
946 time_t myclock
= get_start_time();
949 tmptr
= gmtime(&myclock
);
951 tmptr
= localtime(&myclock
);
954 *minutes
= tmptr
->tm_hour
* 60 + tmptr
->tm_min
;
955 *day
= tmptr
->tm_mday
;
956 *month
= tmptr
->tm_mon
+ 1;
957 *year
= tmptr
->tm_year
+ 1900;
961 /* Under SunOS 4.1.x, the default action after return from the
962 signal handler is to restart the I/O if nothing has been
963 transferred. The effect on TeX is that interrupts are ignored if
964 we are waiting for input. The following tells the system to
965 return EINTR from read() in this case. From ken@cs.toronto.edu. */
967 struct sigaction a
, oa
;
969 a
.sa_handler
= catch_interrupt
;
970 sigemptyset(&a
.sa_mask
);
971 sigaddset(&a
.sa_mask
, SIGINT
);
972 a
.sa_flags
= SA_INTERRUPT
;
973 sigaction(SIGINT
, &a
, &oa
);
974 if (oa
.sa_handler
!= SIG_DFL
)
975 sigaction(SIGINT
, &oa
, (struct sigaction
*) 0);
976 #else /* no SA_INTERRUPT */
978 SetConsoleCtrlHandler(catch_interrupt
, TRUE
);
979 # else /* not WIN32 */
980 RETSIGTYPE(*old_handler
) (int);
982 old_handler
= signal(SIGINT
, catch_interrupt
);
983 if (old_handler
!= SIG_DFL
)
984 signal(SIGINT
, old_handler
);
985 # endif /* not WIN32 */
986 #endif /* no SA_INTERRUPT */
991 Getting a high resolution time.
993 void get_seconds_and_micros(int *seconds
, int *micros
)
995 #if defined (HAVE_GETTIMEOFDAY)
997 gettimeofday(&tv
, NULL
);
998 *seconds
= (int)tv
.tv_sec
;
999 *micros
= (int)tv
.tv_usec
;
1000 #elif defined (HAVE_FTIME)
1004 *micros
= tb
.millitm
* 1000;
1006 time_t myclock
= time((time_t *) NULL
);
1007 *seconds
= (int) myclock
;
1013 Generating a better seed numbers
1015 int getrandomseed(void)
1017 #if defined (HAVE_GETTIMEOFDAY)
1019 gettimeofday(&tv
, NULL
);
1020 return (int)(tv
.tv_usec
+ 1000000 * tv
.tv_usec
);
1021 #elif defined (HAVE_FTIME)
1024 return (tb
.millitm
+ 1000 * tb
.time
);
1026 time_t myclock
= get_start_time((time_t *) NULL
);
1029 tmptr
= gmtime(&myclock
);
1031 tmptr
= localtime(&myclock
);
1033 return (tmptr
->tm_sec
+ 60 * (tmptr
->tm_min
+ 60 * tmptr
->tm_hour
));
1037 /* Read a line of input as efficiently as possible while still looking
1038 like Pascal. We set `last' to `first' and return `false' if we get
1039 to eof. Otherwise, we return `true' and set last = first +
1040 length(line except trailing whitespace). */
1042 boolean
input_line(FILE * f
)
1047 if (f
!= Poptr
&& fileno (f
) != fileno (stdin
)) {
1048 long position
= ftell (f
);
1050 if (position
== 0L) { /* Detect and skip Byte order marks. */
1053 if (k1
!= 0xff && k1
!= 0xfe && k1
!= 0xef)
1058 if (k2
!= 0xff && k2
!= 0xfe && k2
!= 0xbb)
1060 else if ((k1
== 0xff && k2
== 0xfe) || /* UTF-16(LE) */
1061 (k1
== 0xfe && k2
== 0xff)) /* UTF-16(BE) */
1066 if (k1
== 0xef && k2
== 0xbb && k3
== 0xbf) /* UTF-8 */
1075 /* Recognize either LF or CR as a line terminator. */
1077 while (last
< buf_size
&& (i
= getc(f
)) != EOF
&& i
!= '\n' && i
!= '\r')
1078 buffer
[last
++] = (packed_ASCII_code
) i
;
1080 if (i
== EOF
&& errno
!= EINTR
&& last
== first
)
1083 /* We didn't get the whole line because our buffer was too small. */
1084 if (i
!= EOF
&& i
!= '\n' && i
!= '\r') {
1085 fprintf(stderr
, "! Unable to read an entire line---bufsize=%u.\n",
1086 (unsigned) buf_size
);
1087 fputs("Please increase buf_size in texmf.cnf.\n", stderr
);
1092 if (last
>= max_buf_stack
)
1093 max_buf_stack
= last
;
1095 /* If next char is LF of a CRLF, read it. */
1097 while ((i
= getc(f
)) == EOF
&& errno
== EINTR
);
1102 /* Trim trailing whitespace. */
1103 while (last
> first
&& ISBLANK(buffer
[last
- 1]))
1106 /* Don't bother using xord if we don't need to. */
1114 /* Get the job name to be used, which may have been set from the
1116 str_number
getjobname(str_number name
)
1118 str_number ret
= name
;
1119 if (c_job_name
!= NULL
)
1120 ret
= maketexstring(c_job_name
);