Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. */
-#define EXTERN /* Instantiate data in `texd.h' or `mfd.h' here ! */
+#define EXTERN
#include "texd.h"
-/* Hand-coded routines for TeX or Metafont in C. This code was (mostly)
- written by Tim Morgan, drawing from other Unix ports of TeX. */
-/* Either `texd.h' or `mfd.h' will include `../common/texmf.h'. */
-
-/* Note: INITEX definition in makefile only affects included *.h files */
-
-/* Instantiate data in `texd.h' or `mfd.h' here. */
-
-#ifdef TeX
- #define dump_default_var TEX_format_default
- #define dump_default " plain.fmt"
- #define dump_format " %s.fmt"
- #define dump_ext_length 4
- #define dump_default_length format_default_length
- #define virgin_program "virtex"
- #define main_program texbody
- #define edit_value tex_edit_value
- #define edit_var "UFYFEJU" /* shrouded 93/Nov/20 */
-#endif
+#define dump_default_var TEX_format_default
+#define dump_default " plain.fmt"
+#define dump_ext_length 4
+#define dump_default_length format_default_length
+#define main_program texbody
+#define edit_value tex_edit_value
+#define edit_var "UFYFEJU" /* shrouded 93/Nov/20 */
extern char * replacement[]; /* pointers to replacement strings */
/* The entry point: set up for reading the command line, which will
happen in `t_open_in', then call the main body. */
-#ifdef MSDOS
- int main_init(int, char **); /* in local.c */
-#endif /* INIVIR */
+int main_init(int, char **); /* in local.c */
int jump_used = 0;
_setmaxstdio(2048);
#endif
- gargc = ac; /* make available globally */
- gargv = av; /* make available globally */
+ gargc = ac;
+ gargv = av;
-
- if (main_init(gargc, gargv)) /* in local.c */
- return -1; // failure
+ if (main_init(gargc, gargv))
+ return -1; // failure
dump_default_var = dump_default;
- dump_default_length = strlen (dump_default_var + 1); /* 93/Nov/20 */
+ dump_default_length = strlen(dump_default_var + 1);
jump_used = 0;
if (ret == 0)
{
- flag = main_program(); // texbody in itex.c
+ flag = main_program();
if (trace_flag)
{
#else
else exit (flag); // avoid circularity!
#endif
-} /* end of main */
+}
-/* This is supposed to ``open the terminal for input'', but what we
- really do is copy command line arguments into TeX's or Metafont's
- buffer, so they can handle them. If nothing is available, or we've
- been called already (and hence, gargc==0), we return with
- `last=first'. */
/* texk/web2c/lib/texmfmp.c */
void t_open_in (void)
{
buffer[first] = 0; /* In case there are no arguments. */
#ifdef MSDOS
-/* command line arguments? 94/Apr/10 */
if (gargc > optind && optind > 0)
{
- for (i = optind; i < gargc; i++) /* 94/Apr/10 */
+ for (i = optind; i < gargc; i++)
#else
-/* We do have command line arguments. */
- if (gargc > 1)
- {
- for (i = 1; i < gargc; i++)
+ if (gargc > 1)
+ {
+ for (i = 1; i < gargc; i++)
#endif
{
-/* the following won't happen if pseudo_space is set ... */
if (allow_quoted_names && strchr(gargv[i], ' ') != NULL)
{
(void) strcat ((char *) &buffer[first], "\"");
(void) strcat ((char *) &buffer[first], " ");
}
-
- gargc = 0; /* Don't do this again. */
+
+ gargc = 0;
}
/* Find the end of the buffer. */
for (last = first; buffer[last]; ++last) ;
- /* Make `last' be one past the last non-blank non-formfeed character
- in `buffer'. */
for (--last; last >= first
- && ISSPACE (buffer[last]) && buffer[last] != '\f'; --last);
+ && ISBLANK (buffer[last]) && buffer[last] != '\r'; --last)
+ ;
last++;
-/* do we want to check line for non-ASCII at this point ? */
-
- /* One more time, this time converting to TeX's internal character
- representation. */ /* for command line input in this case */
-/* #ifdef NONASCII */
+/* One more time, this time converting to TeX's internal character
+ representation. */ /* for command line input in this case */
if (non_ascii)
{
for (i = first; i < last; i++)
buffer[i] = xord[buffer[i]];
}
-/* #endif */
}
/* All our interrupt handler has to do is set TeX's or Metafont's global
if (output == stdout)
show_line(log_line, 0);
else
- fputs(log_line, output); // never
+ fputs(log_line, output); // never
show_line(" (File may have a line termination problem.)", 0);
}
#endif
{
i = getc (f);
+
if (i < ' ') /* isolate the more expensive tests */
{
if (i == EOF || i == '\n' || (i == '\r' && return_flag))
if (last >= current_buf_size)
{
buffer = realloc_buffer(increment_buf_size);
+
if (last >= current_buf_size)
break;
}
if (last >= current_buf_size)
{
buffer = realloc_buffer(increment_buf_size);
+
if (last >= current_buf_size)
break;
}
if (last >= current_buf_size)
{
buffer = realloc_buffer(increment_buf_size);
+
if (last >= current_buf_size)
break;
}
unsigned int commandlen;
ASCII_code *texfilename;
ASCII_code *log_file_name;
- pool_pointer lgstart; /* 1994/Jan/94 */
- integer lglength; /* 1994/Jan/94 */
+ pool_pointer lgstart;
+ integer lglength;
- if (log_opened) /* 1994/Aug/10 */
+ if (log_opened)
{
lgstart = str_start[texmf_log_name];
lglength = length(texmf_log_name);
log_file_name = stringpool + lgstart;
}
- else /* 1994/Aug/10 */
+ else
{
lglength = 0;
log_file_name = (unsigned char *) "";
}
sdone = ddone = ldone = 0;
-/* filename += fnstart; */
texfilename = stringpool + fnstart;
-/* Close any open input files, since we're going to kill the job. */
-/* and since the editor will need access to them... */
for (i = 1; i <= in_open; i++)
(void) fclose (input_file[i]);
- n = fcloseall(); /* paranoia 1994/Aug/10 */
+ n = fcloseall();
if (n > 0 && verbose_flag)
{
show_line(log_line, 0);
}
-/* Replace the default with the value of the appropriate environment
- variable, if it's set. */
-/* s = getenv (edit_var); */ /* 93/Nov/20 */
s = get_env_shroud (edit_var);
+
if (s != NULL)
- edit_value = s; /* OK, replace wired in default */
+ edit_value = s;
/* Construct the command string. */
/* The `11' is the maximum length a 32 bit integer might be, plus one for null. */
/* remove quotes around [...] string for WinEdt ? */
u = edit_value;
- while ((c = *u++) != 0) {
- if (c == '%') { /* handle special codes */
+
+ while ((c = *u++) != 0)
+ {
+ if (c == '%')
+ {
switch (c = *u++)
{
case 'd':
if (ddone)
{
-#ifdef MSDOS
+#ifdef _WIN32
sprintf(log_line, "! bad command syntax (%c).\n", 'd');
show_line(log_line, 1);
#else
#endif
uexit(1);
}
+
(void) sprintf (s, "%d", linenumber);
+
while (*s != '\0')
s++;
- ddone = 1; /* indicate already used %d */
+
+ ddone = 1;
break;
case 's':
if (sdone)
{
-#ifdef MSDOS
+#ifdef __WIN32
sprintf(log_line, "! bad command syntax (%c).\n", 's');
show_line(log_line, 1);
#else
#endif
uexit(1);
}
+
t = (char *) texfilename;
n = fnlength;
-/* following modified to allow non ASCII - bkph */ /* for file names */
if (non_ascii)
-/* for (i = 0; i < fnlength; i++) *s++ = xchr [filename[i]]; */
for (i = 0; i < n; i++)
*s++ = xchr [*t++];
else
-/* for (i = 0; i < fnlength; i++) *s++ = (char) filename[i]; */
for (i = 0; i < n; i++)
*s++ = (char) *t++;
- sdone = 1; /* indicate already used %s */
+
+ sdone = 1;
break;
- case 'l': /* 1994/Jan/28 */
+ case 'l':
if (ldone)
{
-#ifdef MSDOS
+#ifdef __WIN32
sprintf(log_line, "! bad command syntax (%c).\n", 'l');
show_line(log_line, 1);
#else
#endif
uexit(1);
}
+
t = (char *) log_file_name;
- n = lglength; /* 1994/Jan/28 */
+ n = lglength;
-/* following modified to allow non ASCII - bkph */ /* for file names */
if (non_ascii)
-/* for (i = 0; i < fnlength; i++) *s++ = xchr [filename[i]]; */
for (i = 0; i < n; i++)
*s++ = xchr [*t++];
else
-/* for (i = 0; i < fnlength; i++) *s++ = (char) filename[i]; */
for (i = 0; i < n; i++)
*s++ = (char) *t++;
- ldone = 1; /* indicate already used %l */
+
+ ldone = 1;
break;
- case '\0': /* '%' at end of line */
+ case '\0':
*s++ = '%';
- u--; /* Back up to the null to force termination. */
+ u--;
break;
- default: /* something other than 's', 'd', 'l' follows */
+ default:
*s++ = '%';
*s++ = c;
break;
}
}
- else *s++ = c; /* ordinary character pass it through */
+ else
+ *s++ = c;
}
- *s = 0; /* terminate the command string */
- if (strlen(command) + 1 >= commandlen) /* should not happen! */
+ *s = 0; /* terminate the command string */
+
+ if (strlen(command) + 1 >= commandlen)
{
sprintf(log_line, "Command too long (%d > %d)\n", strlen(command) + 1, commandlen);
show_line(log_line, 1);
uexit(1);
}
-/* You must explicitly flush (using fflush or _flushall) or close any stream before calling system. */
- _flushall();
-/* Try and execute the command. */
-/* There may be problem here with long names and spaces ??? */
-/* Use _exec or _spawn instead ??? */
+ //flushall();
+ fflush(NULL);
if (system (command) != 0)
{
-// fprintf (errout, "\n");
show_line("\n", 0);
-// fprintf (errout,
- sprintf(log_line, "! Error in call: %s\n", command); /* shroud ? */
+ sprintf(log_line, "! Error in call: %s\n", command);
show_line(log_line, 1);
-/* errno seems to be 0 typically, so perror says "no error" */
-#ifdef MSDOS
+
+#ifdef __WIN32
if (errno != 0)
- perrormod("! DOS says"); /* 94/Aug/10 - bkph */
+ perrormod("! DOS says");
#endif
+
sprintf(log_line, " (TEXEDIT=%s)\n", edit_value);
show_line(log_line, 0);
show_line(" (Editor specified may be missing or path may be wrong)\n", 0);
show_line(" (or there may be missing -- or extraneous -- quotation signs)\n", 0);
}
- uexit(1); /* Quit, since we found an error. */
+
+ uexit(1);
}
\f