#define EXTERN extern
-#include "texd.h"
+#include "yandytex.h"
#define USEOUREALLOC
#define USEMEMSET
#define REALLOC realloc
#endif
-int wantcopyrght = 1;
-
-char *compiletime = __TIME__;
-char *compiledate = __DATE__;
-char *www = "http://www.tug.org/yandy";
-char *copyright = "\nCopyright (C) 1993--2000 Y&Y, Inc.\n"
- "Copyright (C) 2007 TeX Users Group.\n"
- "Copyright (C) 2014 Clerk Ma.\n\n"
- "This program is free software; you can redistribute it and/or modify\n"
- "it under the terms of the GNU General Public License as published by\n"
- "the Free Software Foundation; either version 2 of the License, or\n"
- "(at your option) any later version.\n\n ";
-char *yandyversion = "2.3.0";
-char *application = "Y&Y TeX";
-char *tex_version = "This is TeX, Version 3.14159265";
+#if defined (__ANDROID__)
+ #define malloc_usable_size dlmalloc_usable_size
+#elif defined (__APPLE__)
+ #define malloc_usable_size malloc_size
+#endif
+
+#if defined (__clang__)
+const char * compiler = "Clang/LLVM";
+#elif defined (__GNUC__) || defined(__GNUG__)
+const char * compiler = "GCC";
+#elif defined (_MSC_VER)
+const char * compiler = "MSVC";
+#endif
+
+#if defined (_WIN64)
+const char * dist = "Win64";
+#elif defined (_WIN32)
+const char * dist = "Win32";
+#elif defined (__ANDROID__)
+const char * dist = "Android";
+#elif defined (__APPLE__)
+const char * dist = "Darwin";
+#elif defined (__gnu_linux__)
+const char * dist = "Linux";
+#else
+const char * dist = "Unknown";
+#endif
+
+const char * compiletime = __TIME__;
+const char * compiledate = __DATE__;
+const char * yandyversion = "2.3.0";
+const char * application = "Y&Y TeX";
+const char * banner = "This is TeX, Version 3.14159265";
+
+void print_banner (void)
+{
+ char dist_ver[256];
+ memset(dist_ver, 0, sizeof(dist_ver));
+ sprintf(dist_ver, "%s (%s %s/%s)", banner, application, yandyversion, dist);
+ prints(dist_ver);
+}
clock_t start_time, main_time, finish_time;
char * fmt_directory = "";
char * pdf_directory = "";
-char * texpath = "";
+char log_line[256];
-char log_line[MAXLINE]; // used also in tex9.c
-
-int mem_spec_flag = 0; /* non-zero if `-m=...' was used */
-int format_spec = 0; /* non-zero if a format specified on command line */
-int closed_already = 0; /* make sure we don't try this more than once */
-boolean reorder_arg_flag = true; /* put command line flags/arguments first */
+boolean mem_spec_flag = false;
+boolean format_spec = false;
+boolean reorder_arg_flag = true; /* put command line flags/arguments first */
/* Mapping from Windows ANSI to DOS code page 850 96/Jan/20 */
-/* Used in tex0.c with wintodos[c-128] */
unsigned char wintodos[128] =
{
138, 130, 136, 137, 141, 161, 140, 139,
208, 164, 149, 162, 147, 228, 148, 246,
155, 151, 163, 150, 129, 236, 231, 152
-};
+};
void show_usage (void)
{
printf("\n"
- " Useage: yanytex [OPTION]... [+format_file] [tex_file]\n\n"
- " --help -?\n"
- " show this usage summary\n"
- " --initex -i\n"
- " start up as iniTeX (create format file)\n"
- " --verbose -v\n"
- " be verbose (show implementation version number)\n"
- " -n do not allow `non ASCII' characters in input files (complain instead)\n"
- " --showhex -w\n"
- " do not show `non ASCII' characters in hexadecimal (show as is)\n"
- " -d do not allow DOS style file names - i.e. do not convert \\ to /\n"
- " -r do not allow Mac style termination - i.e. do not convert \\r to \\n\n"
- " --patterns -p\n"
- " allow use of \\patterns after loading format (iniTeX only)\n"
- " --knuthify -K\n"
- " disable all extensions to basic TeX\n"
- " --main-memory -m\n"
- " initial main memory size in kilo words (iniTeX only)\n"
- " --hyph-size -e\n"
- " hyphenation exception dictionary size (iniTeX only)\n"
- " --trie-size -h\n"
- " hyphenation pattern trie size (iniTeX only)\n"
- " --xchr-file -x\n"
- " use `non ASCII' character mapping (xchr[]) defined in file\n"
- " --key-file -k\n"
- " use `key replacement' defined in file\n"
- " --dvi-dir -o\n"
- " write DVI file in specified directory (default current directory)\n"
- " --log-dir -l\n"
- " write LOG file in specified directory (default current directory)\n"
- " --aux-dir -a\n"
- " write AUX file in specified directory (default current directory)\n");
-
-#ifndef _WINDOWS
- uexit(EXIT_FAILURE); // has this been setup yet ???
-#endif
+ "Useage: yandytex [OPTION]... [+format_file] [tex_file]\n\n"
+ "--help -? show this usage summary\n"
+ "--initex -i start up as initex (create format file)\n"
+ "--verbose -v be verbose (show implementation version number)\n"
+ "--ascii -n do not allow `non ASCII' characters in input files\n"
+ " (complain instead)\n"
+ "--showhex -w do not show `non ASCII' characters in hexadecimal\n"
+ " (show as is)\n"
+ "--nodos -d do not allow DOS style file names - i.e. do not convert\n"
+ " \\ to /\n"
+ "--nomac -r do not allow Mac style termination - i.e. do not convert\n"
+ " \\r to \\n\n"
+ "--patterns -p allow use of \\patterns after loading format (initex only)\n"
+ "--knuthify -K disable all extensions to basic TeX\n"
+ "--main-mem -m initial main memory size in kilo words (initex only)\n"
+ "--hyph-size -e hyphenation exception dictionary size (initex only)\n"
+ "--trie-size -h hyphenation pattern trie size (initex only)\n"
+ "--xchr-file -x use `non ASCII' character mapping (xchr[]) defined in file\n"
+ "--key-file -k use `key replacement' defined in file\n"
+ "--dvi-dir -o write DVI file in specified directory (default '.')\n"
+ "--log-dir -l write LOG file in specified directory (default '.')\n"
+ "--aux-dir -a write AUX file in specified directory (default '.')\n");
+ uexit(EXIT_FAILURE);
}
-/* -z do not discard control-Z at end of input file (treat as character)\n\ */
-
-/* \t-d\tallow DOS style file names - i.e. convert \\ to / \n\ */
-/* \t\t(applies to file name and format file name, if present)\n\ */
-/* \t-r\tallow Mac style line termination - i.e. convert \\r to \\n \n\ */
-
// Sep 27 1990 => 1990 Sep 27
-// 012456789 0123456789
+// 0123456789 0123456789
void scivilize (char * date)
{
int k;
char pyear[6];
- strcpy (pyear, date + 7);
+ strcpy(pyear, date + 7);
for (k = 5; k >= 0; k--)
date[k + 5] = date[k];
date[4] = ' ';
if (date[9] == ' ')
- date[9] = '0'; /* replace space by '0' */
+ date[9] = '0';
}
// Thu Sep 27 06:26:35 1990 => 1990 Sep 27 06:26:35
int k;
char pyear[6];
- strcpy (pyear, date + 20);
+ strcpy(pyear, date + 20);
for (k = 18; k >= 0; k--)
- date[k+1] = date[k];
+ date[k + 1] = date[k];
date[20] = '\0';
date[4] = ' ';
}
-// now writes result into given buffer
-void stamp_it (char *s)
+void stamp_it (char * s)
{
char date[11 + 1];
strcpy(date, compiledate);
scivilize(date);
- sprintf(s, "%s %s ", application, yandyversion);
- s += strlen(s);
- sprintf(s, "(compiled time: %s %s)", date, compiletime);
+ sprintf(s, "%s %s (compiled time: %s %s with %s)",
+ application, yandyversion, date, compiletime, compiler);
s += strlen(s);
}
-void stampcopy (char *s)
-{
- if (wantcopyrght)
- {
- sprintf(s, "%s %s", copyright, www);
- }
-}
-
#define MAXCHRS 256
#define NOTDEF 127
{
char buffer[file_name_size];
int k, from, to, count = 0;
- char *s;
+ char * s;
memset(xchr, NOTDEF, MAXCHRS);
memset(xord, NOTDEF, MAXCHRS);
if (from >= 0 && from < MAXCHRS && to >= 0 && to < MAXCHRS)
{
- if (xchr[from] == (unsigned char) NOTDEF)
- {
+ if (xchr[from] == NOTDEF)
xchr[from] = (unsigned char) to;
- }
else
- {
- sprintf(log_line, "NOTE: %s collision: %d => %d, %d\n", "xchr", from, xchr[from], to);
- show_line(log_line, 0);
- }
+ printf("NOTE: %s collision: %d => %d, %d\n", "xchr", from, xchr[from], to);
if (xord[to] == NOTDEF)
- {
xord[to] = (unsigned char) from;
- }
else
- {
- sprintf(log_line, "NOTE: %s collision: %d => %d, %d\n", "xord", to, xord[to], from);
- show_line(log_line, 0);
- }
+ printf("NOTE: %s collision: %d => %d, %d\n", "xord", to, xord[to], from);
count++;
}
if (trace_flag)
{
- sprintf(log_line, "Read %d xchr[] pairs:\n", count);
- show_line(log_line, 0);
+ printf("Read %d xchr[] pairs:\n", count);
for (k = 0; k < MAXCHRS; k++)
{
if (xchr[k] != NOTDEF)
- {
- sprintf(log_line, "%d => %d\n", k, xchr[k]);
- show_line(log_line, 0);
- }
+ printf("%d => %d\n", k, xchr[k]);
}
}
}
-char *replacement[MAXCHRS]; /* pointers to replacement strings */
+char * replacement[MAXCHRS]; /* pointers to replacement strings */
void read_repl_sub (FILE * repl_input)
{
char buffer[file_name_size];
char charname[128];
int charnum[10];
- char *s, *t;
+ char * s, * t;
- memset(replacement, 0, MAXCHRS * sizeof(replacement[ 0]));
-
+ memset(replacement, 0, MAXCHRS * sizeof(replacement[0]));
while (fgets(buffer, file_name_size, repl_input) != NULL)
{
if (*buffer == '%' || *buffer == ';' || *buffer == '\n')
continue;
- if ((m = sscanf(buffer, "%d%n %s", &chrs, &n, &charname)) == 0)
+ if ((m = sscanf(buffer, "%d%n %s", &chrs, &n, (char *)&charname)) == 0)
continue;
else if (m == 2)
{
if (chrs >= 0 && chrs < MAXCHRS)
replacement[chrs] = xstrdup(charname);
}
- else {
- sprintf(log_line, "ERROR: don't understand %s", buffer);
- show_line(log_line, 1);
- }
+ else
+ printf("ERROR: don't understand %s", buffer);
}
if (trace_flag)
{
- puts("Key replacement table\n");
+ puts("Key replacement table");
for (k = 0; k < MAXCHRS; k++)
{
if (replacement[k] != NULL)
- {
- sprintf(log_line, "%d\t%s\n", k, replacement[k]);
- show_line(log_line, 0);
- }
+ printf("%d\t%s\n", k, replacement[k]);
}
}
}
/* the flag is 0 for -x=... and the flag is 1 for -k=... */
int read_xchr_file (char *filename, int flag, char *argv[])
{
- FILE *pinput;
+ FILE *xchr_input;
char infile[file_name_size];
char *s;
return -1;
if (trace_flag)
- {
- sprintf(log_line, "Reading xchr/repl %s\n", filename);
- show_line(log_line, 0);
- }
+ printf("Reading xchr/repl %s\n", filename);
-/* first try using file as specified */
+ /* first try using file as specified */
strcpy(infile, filename);
if (trace_flag)
- {
- sprintf(log_line, "Trying %s\n", infile);
- show_line(log_line, 0);
- }
+ printf("Trying %s\n", infile);
- pinput = fopen (infile, "r");
+ xchr_input = fopen (infile, "r");
- if (pinput == NULL)
+ if (xchr_input == NULL)
{
if (strrchr(infile, '.') == NULL)
{
strcat(infile, ".key");
if (trace_flag)
- {
- sprintf(log_line, "Trying %s\n", infile);
- show_line(log_line, 0);
- }
+ printf("Trying %s\n", infile);
- pinput = fopen (infile, "r");
+ xchr_input = fopen(infile, "r");
}
}
- if (pinput == NULL)
+ if (xchr_input == NULL)
{
strcpy(infile, argv[0]); /* try TeX program path */
- if ((s = strrchr (infile, '\\')) != NULL) *(s+1) = '\0';
- else if ((s = strrchr (infile, '/')) != NULL) *(s+1) = '\0';
- else if ((s = strrchr (infile, ':')) != NULL) *(s+1) = '\0';
+ if ((s = strrchr (infile, '\\')) != NULL)
+ *(s+1) = '\0';
+ else if ((s = strrchr (infile, '/')) != NULL)
+ *(s+1) = '\0';
+ else if ((s = strrchr (infile, ':')) != NULL)
+ *(s+1) = '\0';
strcat (infile, filename);
if (trace_flag)
- {
- sprintf(log_line, "Trying %s\n", infile);
- show_line(log_line, 0);
- }
+ printf("Trying %s\n", infile);
- pinput = fopen (infile, "r");
+ xchr_input = fopen (infile, "r");
- if (pinput == NULL)
+ if (xchr_input == NULL)
{
if (strchr(infile, '.') == NULL)
{
strcat(infile, ".key");
if (trace_flag)
- {
- sprintf(log_line, "Trying %s\n", infile);
- show_line(log_line, 0);
- }
+ printf("Trying %s\n", infile);
- pinput = fopen (infile, "r");
+ xchr_input = fopen (infile, "r");
}
}
}
- if (pinput == NULL) /* 97/July/31 */
+ if (xchr_input == NULL)
{
- strcpy (infile, argv[0]); /* try TeX program path */
+ strcpy(infile, argv[0]); /* try TeX program path */
- if ((s = strrchr (infile, '\\')) != NULL) *(s+1) = '\0';
- else if ((s = strrchr (infile, '/')) != NULL) *(s+1) = '\0';
- else if ((s = strrchr (infile, ':')) != NULL) *(s+1) = '\0';
+ if ((s = strrchr (infile, '\\')) != NULL)
+ *(s + 1) = '\0';
+ else if ((s = strrchr (infile, '/')) != NULL)
+ *(s + 1) = '\0';
+ else if ((s = strrchr (infile, ':')) != NULL)
+ *(s + 1) = '\0';
- strcat (infile, "keyboard\\");
- strcat (infile, filename);
+ strcat(infile, "keyboard\\");
+ strcat(infile, filename);
if (trace_flag)
- {
- sprintf(log_line, "Trying %s\n", infile);
- show_line(log_line, 0);
- }
+ printf("Trying %s\n", infile);
- pinput = fopen (infile, "r");
+ xchr_input = fopen (infile, "r");
- if (pinput == NULL)
+ if (xchr_input == NULL)
{
if (strchr(infile, '.') == NULL)
{
strcat(infile, ".key");
if (trace_flag)
- {
- sprintf(log_line, "Trying %s\n", infile);
- show_line(log_line, 0);
- }
+ printf("Trying %s\n", infile);
- pinput = fopen (infile, "r");
+ xchr_input = fopen (infile, "r");
}
}
}
-/* Note: can't look in TeX source file dir, since that is not known yet */
- if (pinput == NULL)
+
+ /* Note: can't look in TeX source file dir, since that is not known yet */
+ if (xchr_input == NULL)
{
- sprintf(log_line, "ERROR: Sorry, cannot find %s file %s",
+ printf("ERROR: Sorry, cannot find %s file %s",
flag ? " xchr[]" : "key mapping", filename);
- show_line(log_line, 1);
perrormod (filename);
- return 0; // failed
+ return 0;
}
if (flag == 0)
- read_xchr_sub (pinput);
+ read_xchr_sub(xchr_input);
else
- read_repl_sub (pinput);
+ read_repl_sub(xchr_input);
+
+ (void) fclose(xchr_input);
- (void) fclose (pinput);
return 1;
}
/* need to also allocate `buffercopy' here and free at end */
/* need to call `readreplace' in appropriate place */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
#define MAXSPLITS 3
/* ad hoc default minimum growth in memory realloc is 62% */
/* also tries _expand first, which can avoid address growth ... */
#ifdef USEOUREALLOC
-void *ourrealloc (void *old, size_t new_size)
+void * ourrealloc (void * old, size_t new_size)
{
void * mnew;
size_t old_size, overlap;
- /* round up to nearest multiple of four bytes */
+ /* round up to nearest multiple of four bytes */
/* avoid unlikely alignment */
if ((new_size % 4) != 0)
new_size = ((new_size / 4) + 1) * 4;
if (mnew != NULL)
{
if (trace_flag)
- {
- sprintf(log_line, "EXPANDED! %p (%d) == %p (%d)\n",
+ printf("EXPANDED! %p (%ld) == %p (%ld)\n",
mnew, new_size, old, old_size);
- show_line(log_line, 0);
- }
return mnew;
}
- /* do this if you want to call the real realloc next - */
+ /* do this if you want to call the real realloc next - */
mnew = realloc (old, new_size);
if (mnew != NULL)
}
#endif
-void memory_error (char *s, int n)
+void memory_error (const char * s, int n)
{
if (log_opened)
{
show_maximums(log_file);
}
- sprintf(log_line, "\n! Unable to allocate %d bytes for %s\n", n, s);
- show_line(log_line, 1);
+ printf("\n! Unable to allocate %d bytes for %s\n", n, s);
show_maximums(stderr);
}
-void trace_memory (char *s, int n)
+void trace_memory (const char * s, int n)
{
printf("Allocating %d bytes for %s\n", n, s);
}
-void update_statistics (int address, int size, int old_size)
+void update_statistics (long address, int size, int old_size)
{
if (address + size > max_address)
max_address = address + size;
void probe_memory (void)
{
- char *s = (char *) malloc(4); /* get current top address */
+ char * s = (char *) malloc(sizeof(void *));
free(s);
- update_statistics ((int) s, 0, 0); /* show where we are */
+ update_statistics ((long) s, 0, 0);
}
void probe_show (void)
size_t roundup (size_t n)
{
- if ((n % 4) == 0)
+ if ((n % sizeof(void *)) == 0)
return n;
else
- return ((n / 4) + 1) * 4;
+ return ((n / sizeof(void *)) + 1) * sizeof(void *);
}
#ifdef ALLOCATETRIES
}
if (trace_flag)
- {
- sprintf(log_line, "Addresses trie_trl %p trie_tro %p trie_trc %p\n", trie_trl, trie_tro, trie_trc);
- show_line(log_line, 0);
- }
+ printf("Addresses trie_trl %p trie_tro %p trie_trc %p\n", trie_trl, trie_tro, trie_trc);
- update_statistics((int) trie_trl, nl, 0);
- update_statistics((int) trie_tro, no, 0);
- update_statistics((int) trie_trc, nc, 0);
+ update_statistics((long) trie_trl, nl, 0);
+ update_statistics((long) trie_tro, no, 0);
+ update_statistics((long) trie_trc, nc, 0);
trie_size = trie_max;
#endif
#ifdef ALLOCATEHYPHEN
-boolean prime(int); /* test function later in this file */
-
int current_prime = 0; /* remember in case reallocated later */
/* we don't return an address here, since TWO memory regions allocated */
if (!prime(hyphen_prime))
{
- sprintf(log_line, "ERROR: non-prime hyphen exception number (%d)\n", hyphen_prime);
- show_line(log_line, 1);
+ printf("ERROR: non-prime hyphen exception number (%d)\n", hyphen_prime);
return -1;
}
/* need not/cannot preserve old contents when hyphen prime is changed */
/* if (hyph_list != NULL) free(hyph_list); */
/* if (hyph_word != NULL) free(hyph_word); */
-/* important + 1 since str_number hyph_word[hyphen_prime + 1] in original etc. */
nw = (hyphen_prime + 1) * sizeof(str_number);
nl = (hyphen_prime + 1) * sizeof(halfword);
n = nw + nl;
}
if (trace_flag)
- {
- sprintf(log_line, "Addresses hyph_word %p hyph_list %p\n", hyph_word, hyph_list);
- show_line(log_line, 0);
- }
+ printf("Addresses hyph_word %p hyph_list %p\n", hyph_word, hyph_list);
/* cannot preserve old contents when hyphen prime is changed */
#ifdef USEMEMSET
if (current_prime != 0)
{
- update_statistics((int) hyph_word, nw, (current_prime + 1) * sizeof(str_number));
- update_statistics((int) hyph_list, nl, (current_prime + 1) * sizeof(halfword));
+ update_statistics((long) hyph_word, nw, (current_prime + 1) * sizeof(str_number));
+ update_statistics((long) hyph_list, nl, (current_prime + 1) * sizeof(halfword));
}
else
{
- update_statistics((int) hyph_word, nw, 0);
- update_statistics((int) hyph_list, nl, 0);
+ update_statistics((long) hyph_word, nw, 0);
+ update_statistics((long) hyph_list, nl, 0);
}
current_prime = hyphen_prime;
#ifdef ALLOCATEMAIN
/* initial main memory alloc - mem_top */
-memory_word *allocate_main_memory (int size)
+memory_word * allocate_main_memory (int size)
{
int n;
mem_max = mem_top;
mem_start = 0; /* bottom of memory allocated by system */
mem_min = 0; /* bottom of area made available to TeX */
- n = (mem_max - mem_start + 1) * sizeof (memory_word); /* 256k * 8 = 2000 k */
+ n = (mem_max - mem_start + 1) * sizeof (memory_word);
if (trace_flag)
trace_memory("main memory", n);
if (main_memory == NULL)
{
memory_error("initial main memory", n);
-// exit (1);
return NULL;
}
if (trace_flag)
- {
- sprintf(log_line, "Address main memory == %p\n", main_memory);
- show_line(log_line, 0);
- }
+ printf("Address main memory == %p\n", main_memory);
mem = main_memory;
mem = main_memory - mem_start;
if (trace_flag)
- {
- sprintf(log_line, "Offset address main memory == %p\n", mem);
- show_line(log_line, 0);
- }
+ printf("Offset address main memory == %p\n", mem);
- update_statistics((int) main_memory, n, (current_mem_size + 1) * sizeof (memory_word));
+ update_statistics((long) main_memory, n, (current_mem_size + 1) * sizeof (memory_word));
/* current_mem_size = (mem_max - mem_start + 1); */
current_mem_size = mem_max - mem_start; /* total number of words - 1 */
memory_word * new_memory = NULL;
if (trace_flag)
- {
- sprintf(log_line, "WARNING: Entering realloc_main lo %d hi %d\n", lo_size, hi_size);
- show_line(log_line, 0);
- }
+ printf("WARNING: Entering realloc_main lo %d hi %d\n", lo_size, hi_size);
if (is_initex)
{
- puts("ERROR: Cannot extent main memory in iniTeX\n");
+ puts("ERROR: Cannot extent main memory in initex");
if (!knuth_flag)
puts("Please use `-m=...' on command line");
}
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "main memory", main_memory);
- show_line(log_line, 0);
- }
+ printf("Old Address %s == %p\n", "main memory", main_memory);
/* if we REALLY run up to limit ! */
if (current_mem_size + 1 == max_mem_size)
{
memory_error("main memory", (max_mem_size + 1) * sizeof(memory_word));
-
return NULL;
}
}
if (trace_flag)
- {
- sprintf(log_line, "New Address %s == %p\n", "main memory", new_memory);
- show_line(log_line, 0);
- }
+ printf("New Address %s == %p\n", "main memory", new_memory);
if (lo_size > 0)
{
/* shift everything upward to make space for new low area */
if (trace_flag)
- {
- sprintf(log_line, "memmove %p %p %d \n", new_memory + lo_size,
+ printf("memmove %p %p %ld \n", new_memory + lo_size,
new_memory, (current_mem_size + 1) * sizeof(memory_word));
- show_line(log_line, 0);
- }
memmove (new_memory + lo_size, new_memory,
(current_mem_size + 1) * sizeof(memory_word));
if (hi_size > 0)
mem_max = mem_max + hi_size; /* update upper limit */
- update_statistics ((int) main_memory, n,
+ update_statistics ((long) main_memory, n,
(current_mem_size + 1) * sizeof (memory_word));
current_mem_size = new_size;
if (current_mem_size != mem_max - mem_start)
- {
puts("ERROR: Impossible Memory Error");
- }
if (mem_start != 0)
mem = main_memory - mem_start;
#ifdef ALLOCATEFONT
int current_font_mem_size = 0;
-/* fmemoryword can be either halfword or memory_word */
memory_word * realloc_font_info (int size)
{
memory_word * new_font_info = NULL;
int n = 0;
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "font_info", font_info);
- show_line(log_line, 0);
- }
-/* during initial allocation, font_info == NULL - realloc acts like malloc */
-/* during initial allocation current_font_mem_size == 0 */
+ printf("Old Address %s == %p\n", "font_info", font_info);
+
+ /* during initial allocation, font_info == NULL - realloc acts like malloc */
+ /* during initial allocation current_font_mem_size == 0 */
if (current_font_mem_size == font_mem_size) /* if we REALLY run up to limit */
{
-/* memory_error("font", (font_mem_size + 1) * sizeof(memory_word)); */
+ /* memory_error("font", (font_mem_size + 1) * sizeof(memory_word)); */
return font_info; /* pass it back to TeX 99/Fabe/4 */
}
-/* try and prevent excessive frequent reallocations */
-/* while avoiding over allocation by too much */
-/* min_size = current_font_mem_size / 2; */
+ /* try and prevent excessive frequent reallocations */
+ /* while avoiding over allocation by too much */
+ /* min_size = current_font_mem_size / 2; */
min_size = current_font_mem_size / 100 * percent_grow;
if (size < min_size)
font_info = new_font_info;
if (trace_flag)
- {
- sprintf(log_line, "New Address %s == %p\n", "font_info", font_info);
- show_line(log_line, 0);
- }
+ printf("New Address %s == %p\n", "font_info", font_info);
- update_statistics ((int) font_info, n, current_font_mem_size * sizeof(memory_word));
+ update_statistics ((long) font_info, n, current_font_mem_size * sizeof(memory_word));
current_font_mem_size = new_size;
if (trace_flag)
int k, min_size;
int new_size = 0;
int n = 0;
- packed_ASCII_code *newstrpool = NULL;
+ packed_ASCII_code * new_str_pool = NULL;
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "string pool", str_pool);
- show_line(log_line, 0);
- }
+ printf("Old Address %s == %p\n", "string pool", str_pool);
if (current_pool_size == pool_size)
{
if (trace_flag)
trace_memory("str_pool", n);
- newstrpool = (packed_ASCII_code *) REALLOC (str_pool, n); /* 95/Sep/24 */
+ new_str_pool = (packed_ASCII_code *) REALLOC (str_pool, n); /* 95/Sep/24 */
- if (newstrpool != NULL)
+ if (new_str_pool != NULL)
break; /* did we get it ? */
if (current_pool_size == 0)
size = size / 2; /* else can retry smaller */
}
- if (newstrpool == NULL)
+ if (new_str_pool == NULL)
{
memory_error("string pool", n);
return str_pool; /* try and continue !!! */
}
- str_pool = newstrpool;
- update_statistics ((int) str_pool, n, current_pool_size);
+ str_pool = new_str_pool;
+ update_statistics ((long) str_pool, n, current_pool_size);
current_pool_size = new_size;
if (trace_flag)
- {
- sprintf(log_line, "New Address %s == %p\n", "string pool", str_pool);
- show_line(log_line, 0);
- }
+ printf("New Address %s == %p\n", "string pool", str_pool);
if (trace_flag)
probe_show();
#ifdef ALLOCATESTRING
int current_max_strings = 0;
-pool_pointer *realloc_str_start (int size)
+pool_pointer * realloc_str_start (int size)
{
int k, min_size;
int n = 0;
pool_pointer * new_str_start = NULL;
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "string start", str_start);
- show_line(log_line, 0);
- }
+ printf("Old Address %s == %p\n", "string start", str_start);
if (current_max_strings == max_strings)
{
}
str_start = new_str_start;
- update_statistics((int) str_start, n, current_max_strings * sizeof (pool_pointer));
+ update_statistics((long) str_start, n, current_max_strings * sizeof (pool_pointer));
current_max_strings = new_size;
if (trace_flag)
- {
- sprintf(log_line, "New Address %s == %p\n", "string start", str_start);
- show_line(log_line, 0);
- }
+ printf("New Address %s == %p\n", "string start", str_start);
if (trace_flag)
probe_show();
{
int n, nl, no, nc, nr, nh, nt;
- nh = nr = nl = (size + 1) * sizeof(trie_pointer);
- no = (size + 1) * sizeof(trie_op_code);
- nc = (size + 1) * sizeof(packed_ASCII_code);
-/* nt = (size + 1) * sizeof(boolean); */
- nt = (size + 1) * sizeof(char);
+ nh = (size + 1) * sizeof(trie_pointer);
+ nr = (size + 1) * sizeof(trie_pointer);
+ nl = (size + 1) * sizeof(trie_pointer);
+ no = (size + 1) * sizeof(trie_op_code);
+ nc = (size + 1) * sizeof(packed_ASCII_code);
+ nt = (size + 1) * sizeof(char);
n = nl + no + nc + nr + nh + nt;
-/* n = (size + 1) * (sizeof(packed_ASCII_code) + sizeof(trie_op_code) +
- 3 * sizeof(trie_pointer) + sizeof (char)); */
+
if (trace_flag)
- trace_memory ("iniTeX hyphen trie", n);
+ trace_memory ("initex hyphen trie", n);
trie_l = (trie_pointer *) malloc (roundup(nl));
trie_o = (trie_op_code *) malloc (roundup(no));
if (trie_c == NULL || trie_o == NULL || trie_l == NULL || trie_r == NULL ||
trie_hash == NULL || trie_taken == NULL)
{
- memory_error("iniTeX hyphen trie", n);
-// exit (1); /* serious error */
+ memory_error("initex hyphen trie", n);
return -1;
}
if (trace_flag)
{
- sprintf(log_line, "Addresses trie_l %p trie_o %p trie_c %p\n", trie_l, trie_o, trie_c);
- show_line(log_line, 0);
- sprintf(log_line, "Addresses trie_r %p trie_hash %p trie_taken %p\n",
- trie_r, trie_hash, trie_taken);
- show_line(log_line, 0);
+ printf("Addresses: trie_l %p trie_o %p trie_c %p\n", trie_l, trie_o, trie_c);
+ printf("Addresses: trie_r %p trie_hash %p trie_taken %p\n", trie_r, trie_hash, trie_taken);
}
- update_statistics ((int) trie_l, nl, 0);
- update_statistics ((int) trie_o, no, 0);
- update_statistics ((int) trie_c, nc, 0);
- update_statistics ((int) trie_r, nr, 0);
- update_statistics ((int) trie_hash, nh, 0);
- update_statistics ((int) trie_taken, nt, 0);
-/* trie_size = size; */ /* ??? */
+ update_statistics ((long) trie_l, nl, 0);
+ update_statistics ((long) trie_o, no, 0);
+ update_statistics ((long) trie_c, nc, 0);
+ update_statistics ((long) trie_r, nr, 0);
+ update_statistics ((long) trie_hash, nh, 0);
+ update_statistics ((long) trie_taken, nt, 0);
+
if (trace_flag)
probe_show();
#ifdef ALLOCATESAVESTACK
int current_save_size = 0;
-memory_word *realloc_save_stack (int size)
+memory_word * realloc_save_stack (int size)
{
int k, min_size;
int n = 0, new_size = 0;
memory_word * new_save_stack = NULL;
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "save stack", save_stack);
- show_line(log_line, 0);
- }
+ printf("Old Address %s == %p\n", "save stack", save_stack);
- if (current_save_size == save_size) /* arbitrary limit */
+ if (current_save_size == save_size)
{
-/* memory_error ("save stack", (save_size + 1) * sizeof(memory_word)); */
-/* exit (1); */
- return save_stack; /* let TeX handle the error */
+ return save_stack; /* let TeX handle the error */
}
min_size = current_save_size / 100 * percent_grow;
if (new_size > save_size)
new_size = save_size;
- n = (new_size + 1) * sizeof (memory_word); /* save_stack[save_size + 1] */
+ n = (new_size + 1) * sizeof (memory_word);
if (trace_flag)
trace_memory("save_stack", n);
if (new_save_stack == NULL)
{
- memory_error("save stack", n);
+ memory_error("save_stack", n);
return save_stack; /* try and continue !!! */
}
save_stack = new_save_stack;
- update_statistics ((int) save_stack, n, current_save_size);
+ update_statistics ((long) save_stack, n, current_save_size);
current_save_size = new_size;
if (trace_flag)
{
- sprintf(log_line, "Current %s %d\n", "save_size", current_save_size);
- show_line(log_line, 0);
- sprintf(log_line, "New Address %s == %p\n", "save stack", save_stack);
- show_line(log_line, 0);
+ printf("Current %s %d\n", "save_size", current_save_size);
+ printf("New Address %s == %p\n", "save stack", save_stack);
}
if (trace_flag)
#ifdef ALLOCATEINPUTSTACK
int current_stack_size = 0; /* input stack size */
-in_state_record *realloc_input_stack (int size)
+in_state_record * realloc_input_stack (int size)
{
int k, min_size;
int n = 0, new_size = 0;
in_state_record * new_input_stack = NULL;
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "input stack", input_stack);
- show_line(log_line, 0);
- }
+ printf("Old Address %s == %p\n", "input stack", input_stack);
- if (current_stack_size == stack_size) /* arbitrary limit */
+ if (current_stack_size == stack_size)
{
-/* memory_error ("input stack", (stack_size + 1) * sizeof(in_state_record)); */
-/* exit (1); */
return input_stack;
}
if (new_size > stack_size)
new_size = stack_size;
- n = (new_size + 1) * sizeof (in_state_record); /* input_stack[stack_size + 1] */
+ n = (new_size + 1) * sizeof(in_state_record);
if (trace_flag)
trace_memory("input_stack", n);
}
input_stack = new_input_stack;
- update_statistics ((int) input_stack, n, current_stack_size);
+ update_statistics ((long) input_stack, n, current_stack_size);
current_stack_size = new_size;
if (trace_flag)
{
- sprintf(log_line, "Current %s %d\n", "stack_size", current_stack_size);
- show_line(log_line, 0);
- sprintf(log_line, "New Address %s == %p\n", "input stack", input_stack);
- show_line(log_line, 0);
+ printf("Current %s %d\n", "stack_size", current_stack_size);
+ printf("New Address %s == %p\n", "input stack", input_stack);
}
if (trace_flag)
- probe_show(); /* 94/Mar/25 */
+ probe_show();
return input_stack;
}
#ifdef ALLOCATENESTSTACK
int current_nest_size = 0; /* current nest size */
-list_state_record *realloc_nest_stack (int size)
+list_state_record * realloc_nest_stack (int size)
{
int k, min_size;
int n = 0, new_size = 0;
list_state_record * new_nest = NULL;
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "nest stack", nest);
- show_line(log_line, 0);
- }
+ printf("Old Address %s == %p\n", "nest stack", nest);
- if (current_nest_size == nest_size) /* arbitrary limit */
+ if (current_nest_size == nest_size)
{
-/* memory_error ("nest stack", (nest_size + 1) * sizeof(list_state_record)); */
-/* exit (1); */
- return nest; /* let TeX handle the error */
+ return nest;
}
min_size = current_nest_size / 100 * percent_grow;
if (new_size > nest_size)
new_size = nest_size;
- n = (new_size + 1) * sizeof (list_state_record); /* nest[nest_size + 1] */
+ n = (new_size + 1) * sizeof (list_state_record);
if (trace_flag)
trace_memory("nest stack", n);
}
nest = new_nest;
- update_statistics ((int) nest, n, current_nest_size);
+ update_statistics ((long) nest, n, current_nest_size);
current_nest_size = new_size;
if (trace_flag)
{
- sprintf(log_line, "Current %s %d\n", "nest_size", current_nest_size);
- show_line(log_line, 0);
- sprintf(log_line, "New Address %s == %p\n", "nest stack", nest);
- show_line(log_line, 0);
+ printf("Current %s %d\n", "nest_size", current_nest_size);
+ printf("New Address %s == %p\n", "nest stack", nest);
}
if (trace_flag)
halfword * new_param = NULL;
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "param stack", param_stack);
- show_line(log_line, 0);
- }
+ printf("Old Address %s == %p\n", "param stack", param_stack);
- if (current_param_size == param_size) /* arbitrary limit */
+ if (current_param_size == param_size)
{
-/* memory_error ("param stack", (param_size + 1) * sizeof(halfword)); */
-/* exit (1); */
- return param_stack; /* let TeX handle the error */
+ return param_stack;
}
min_size = current_param_size / 100 * percent_grow;
if (new_size > param_size)
new_size = param_size;
- n = (new_size + 1) * sizeof (halfword); /* param_stack[param_size + 1] */
+ n = (new_size + 1) * sizeof(pointer);
if (trace_flag)
trace_memory("param stack", n);
- new_param = (halfword *) REALLOC (param_stack, n);
+ new_param = (pointer *) REALLOC (param_stack, n);
if (new_param != NULL)
break; /* did we get it ? */
if (current_param_size == 0)
break; /* initial allocation must work */
- size = size / 2; /* else can retry smaller */
+ size = size / 2; /* else can retry smaller */
}
if (new_param == NULL)
}
param_stack = new_param;
- update_statistics ((int) param_stack, n, current_param_size);
+ update_statistics((long) param_stack, n, current_param_size);
current_param_size = new_size;
if (trace_flag)
{
- sprintf(log_line, "Current %s %d\n", "param_size", current_param_size);
- show_line(log_line, 0);
- sprintf(log_line, "New Address %s == %p\n", "param stack", param_stack);
- show_line(log_line, 0);
+ printf("Current %s %d\n", "param_size", current_param_size);
+ printf("New Address %s == %p\n", "param stack", param_stack);
}
if (trace_flag)
- probe_show(); /* 94/Mar/25 */
+ probe_show();
return param_stack;
}
ASCII_code * new_buffer = NULL;
if (trace_flag)
- {
- sprintf(log_line, "Old Address %s == %p\n", "buffer", buffer);
- show_line(log_line, 0);
- }
+ printf("Old Address %s == %p\n", "buffer", buffer);
if (current_buf_size == buf_size)
{
-/* memory_error ("buffer", buf_size); */
-/* exit (1); */
- return buffer; /* pass it back to TeX 99/Fabe/4 */
+ return buffer;
}
min_size = current_buf_size / 100 * percent_grow;
}
buffer = new_buffer;
- update_statistics ((int) buffer, n, current_buf_size);
+ update_statistics ((long) buffer, n, current_buf_size);
#ifdef USEMEMSET
memset(buffer + current_buf_size, 0, new_size - current_buf_size);
#else
- for (k = current_buf_size; k < new_size; k++) buffer[k]= 0;
+ for (k = current_buf_size; k < new_size; k++)
+ buffer[k] = 0;
#endif
current_buf_size = new_size;
if (trace_flag)
{
- sprintf(log_line, "Current %s %d\n", "buffer", current_buf_size);
- show_line(log_line, 0);
- sprintf(log_line, "New Address %s == %p\n", "buffer", buffer);
- show_line(log_line, 0);
+ printf("Current %s %d\n", "buffer", current_buf_size);
+ printf("New Address %s == %p\n", "buffer", buffer);
}
if (trace_flag)
#ifdef ALLOCATEINPUTSTACK
input_stack = NULL;
current_stack_size = 0;
- input_stack = realloc_input_stack (initial_stack_size); /* + 1 */
+ input_stack = realloc_input_stack(initial_stack_size);
#endif
#ifdef ALLOCATENESTSTACK
nest = NULL;
current_nest_size = 0;
- nest = realloc_nest_stack (initial_nest_size); /* + 1 */
+ nest = realloc_nest_stack(initial_nest_size);
#endif
#ifdef ALLOCATEPARAMSTACK
param_stack = NULL;
current_param_size = 0;
- param_stack = realloc_param_stack (initial_param_size); /* + 1 */
+ param_stack = realloc_param_stack(initial_param_size);
#endif
#ifdef ALLOCATESAVESTACK
if (is_initex)
{
if (trace_flag)
- puts("ini TeX pool and string allocation\n");
+ puts("ini TeX pool and string allocation");
- str_pool = realloc_str_pool(initial_pool_size);
+ str_pool = realloc_str_pool(initial_pool_size);
str_start = realloc_str_start(initial_max_strings);
}
#endif
#ifdef ALLOCATEFONT
font_info = NULL;
current_font_mem_size = 0;
-/* if not iniTeX, then do initial allocation on fmt file read in itex.c */
-/* if ini-TeX we need to do it here - no format file read later */
+/* if not iniTeX, then do initial allocation on fmt file read in itex.c */
+/* if ini-TeX we need to do it here - no format file read later */
if (is_initex)
- font_info = realloc_font_info (initial_font_mem_size);
+ font_info = realloc_font_info(initial_font_mem_size);
#endif
#ifdef ALLOCATEMAIN
mem_min = mem_bot; /* just to avoid complaints in texbody */
mem_top = mem_initex;
mem_max = mem_top;
-/* allocate main memory here if this is iniTeX */
-/* otherwise wait for format undumping in itex.c ... */
+/* allocate main memory here if this is iniTeX */
+/* otherwise wait for format undumping in itex.c ... */
if (is_initex)
{
-/* avoid this if format specified on command line ??? */
-/* allocate_main_memory(mem_initex); */ /* made variable ! */
- mem = allocate_main_memory(mem_initex); /* made variable ! */
+ /* avoid this if format specified on command line ??? */
+ mem = allocate_main_memory(mem_initex); /* made variable ! */
+
if (mem == NULL)
-// exit (1);
- return -1; /* serious error */
+ return -1;
}
#endif
#ifdef ALLOCATEHYPHEN
hyph_word = NULL;
hyph_list = NULL;
-/* this will be overridden later by what is in format file */
+/* this will be overridden later by what is in format file */
hyphen_prime = default_hyphen_prime;
-/* non ini-TeX use assumes format will be read and that specifies size */
+/* non ini-TeX use assumes format will be read and that specifies size */
if (is_initex)
{
if (new_hyphen_prime)
}
#endif
-/* now for memory for the part of the hyphenation stuff that always needed */
-/* if iniTeX, need to allocate pre-determined fixed amount - trie_size */
-/* if iniTeX not selected, allocate only enough later - undump in itex.c ! */
+/* now for memory for the part of the hyphenation stuff that always needed */
+/* if iniTeX, need to allocate pre-determined fixed amount - trie_size */
+/* if iniTeX not selected, allocate only enough later - undump in itex.c ! */
#ifdef ALLOCATETRIES
if (is_initex)
{
}
#endif
-/* now for memory for hyphenation stuff needed only when running iniTeX */
+/* now for memory for hyphenation stuff needed only when running iniTeX */
#ifdef ALLOCATEINI
if (is_initex)
{
}
else
{
- trie_l = trie_r = trie_o = trie_hash = NULL; /* (trie_size + 1) * integer */
- trie_c = NULL; /* (trie_size + 1) * char */
- trie_taken = NULL; /* (trie_size + 1) * boolean */
+ trie_l = NULL;
+ trie_r = NULL;
+ trie_o = NULL;
+ trie_hash = NULL;
+ trie_c = NULL;
+ trie_taken = NULL;
}
#endif
if (trace_flag)
{
- sprintf(log_line, "Heap total: %u bytes --- max address %u\n",
+ printf("Heap total: %u bytes --- max address %u\n",
heap_total, max_address);
- show_line(log_line, 0);
- }
-
- if (trace_flag)
- {
- printf("Main Memory: variable node %lld (%lld - %ld);\n"
- " one word %ld (%ld - %ld)\n",
+ printf("Main Memory: variable node %lld (%lld - %d);\n"
+ " one word %d (%d - %d)\n",
lo_mem_max - mem_min, mem_min, lo_mem_max,
mem_end - hi_mem_min, hi_mem_min, mem_end);
- }
-
- if (trace_flag)
puts("Freeing memory again");
+ }
-/* only free memory if safe ... additional check */
+/* only free memory if safe ... additional check */
#ifdef ALLOCATEINI
if (is_initex)
{
free(trie_l);
trie_taken = NULL;
- trie_hash = trie_l = trie_r = NULL;
+ trie_hash = NULL;
+ trie_l = NULL;
+ trie_r = NULL;
trie_c = NULL;
trie_o = NULL;
}
#ifdef ALLOCATETRIES
if (trie_trc != NULL)
- free (trie_trc);
+ free(trie_trc);
if (trie_tro != NULL)
- free (trie_tro);
+ free(trie_tro);
if (trie_trl != NULL)
- free (trie_trl);
+ free(trie_trl);
trie_trc = NULL;
- trie_tro = trie_trl = NULL;
+ trie_tro = NULL;
+ trie_trl = NULL;
#endif
#ifdef ALLOCATEHYPHEN
if (source_direct != NULL)
free(source_direct);
- format_file = source_direct = NULL;
+ format_file = NULL;
+ source_direct = NULL;
if (dvi_file_name != NULL)
free(dvi_file_name);
if (pdf_file_name != NULL)
free(pdf_file_name);
- pdf_file_name = log_file_name = dvi_file_name = NULL;
+ pdf_file_name = NULL;
+ log_file_name = NULL;
+ dvi_file_name = NULL;
return 0;
}
int quitflag = 0;
boolean show_use = false;
-boolean floating = false;
void complainarg (int c, char *s)
{
- sprintf(log_line, "ERROR: Do not understand `%c' argument value `%s'\n", c, s);
- show_line(log_line, 1);
- show_use = 1;
+ printf("ERROR: Do not understand `%c' argument value `%s'\n", c, s);
+ show_use = true;
}
/* following is list of allowed command line flags and args */
if (trace_flag)
{
show_line(takeargs, 0);
- show_char('\n');
+ wterm_cr();
}
n = 1;
}
}
-int test_align (int address, int size, char *str)
+int test_align (long address, int size, const char *str)
{
int n;
- if (size > 4)
- n = address % 4;
+ if (size > sizeof(void *))
+ n = address % sizeof(void *);
else
n = address % size;
if (n != 0)
- {
- sprintf(log_line, "OFFSET %d (ELEMENT %d) in %s\n", n, size, str);
- show_line(log_line, 0);
- }
+ printf("OFFSET %d (ELEMENT %d) in %s\n", n, size, str);
return n;
}
{
(void) flag;
- if (test_align ((int) &mem_top, 4, "FIXED ALIGNMENT"))
+ if (test_align ((long) &mem_top, 4, "FIXED ALIGNMENT"))
{
- puts("PLEASE RECOMPILE ME!\n");
+ puts("PLEASE RECOMPILE ME!");
}
#ifdef CHECKALIGNMENT
if (!flag)
return;
- test_align ((int) &mem_top, 4, "mem_top");
- test_align ((int) &mem_max, 4, "mem_max");
- test_align ((int) &mem_min, 4, "mem_min");
- test_align ((int) &bad, 4, "bad");
- test_align ((int) &trie_size, 4, "trie_size");
- test_align ((int) &xord, sizeof(xord[0]), "xord"); /* no op */
- test_align ((int) &xchr, sizeof(xchr[0]), "xchr"); /* no op */
- test_align ((int) &name_length, 4, "name_length");
- test_align ((int) &first, 4, "first");
- test_align ((int) &last, 4, "last");
- test_align ((int) &max_buf_stack, 4, "max_buf_stack");
- test_align ((int) &pool_ptr, 4, "pool_ptr");
- test_align ((int) &str_ptr, 4, "str_ptr");
- test_align ((int) &init_pool_ptr, 4, "init_pool_ptr");
- test_align ((int) &init_str_ptr, 4, "init_str_ptr");
- test_align ((int) &log_file, 4, "log_file");
- test_align ((int) &tally, 4, "tally");
- test_align ((int) &term_offset, 4, "term_offset");
- test_align ((int) &file_offset, 4, "file_offset");
- test_align ((int) &trick_count, 4, "trick_count");
- test_align ((int) &first_count, 4, "first_count");
- test_align ((int) &deletions_allowed, 4, "deletions_allowed");
- test_align ((int) &set_box_allowed, 4, "set_box_allowed");
- test_align ((int) &help_line, sizeof(help_line[0]), "help_line");
- test_align ((int) &use_err_help, 4, "use_err_help");
- test_align ((int) &interrupt, 4, "interrupt");
- test_align ((int) &OK_to_interrupt, 4, "OK_to_interrupt");
- test_align ((int) &arith_error, 4, "arith_error");
- test_align ((int) &tex_remainder, 4, "tex_remainder");
- test_align ((int) &temp_ptr, 4, "temp_ptr");
- test_align ((int) &lo_mem_max, 4, "lo_mem_max");
- test_align ((int) &hi_mem_min, 4, "hi_mem_min");
- test_align ((int) &var_used, 4, "var_used");
- test_align ((int) &dyn_used, 4, "dyn_used");
- test_align ((int) &avail, 4, "avail");
- test_align ((int) &mem_end, 4, "mem_end");
- test_align ((int) &mem_start, 4, "mem_start");
- test_align ((int) &rover, 4, "rover");
- test_align ((int) &font_in_short_display, 4, "font_in_short_display");
- test_align ((int) &depth_threshold, 4, "depth_threshold");
- test_align ((int) &breadth_max, 4, "breadth_max");
- test_align ((int) &nest, sizeof(nest[0]), "nest");
-/* test_align ((int) &xeq_level, sizeof(xeq_level[0]), "xeq_level"); */
- test_align ((int) &zzzad, sizeof(zzzad[0]), "zzzad");
-/* test_align ((int) &hash, sizeof(hash[0]), "hash"); */
- test_align ((int) &zzzae, sizeof(zzzae[0]), "zzzae");
-
- test_align ((int) &save_stack, sizeof(save_stack[0]), "save_stack");
- test_align ((int) &input_stack, sizeof(input_stack[0]), "input_stack");
- test_align ((int) &input_file, sizeof(input_file[0]), "input_file");
- test_align ((int) &line_stack, sizeof(line_stack[0]), "line_stack");
- test_align ((int) ¶m_stack, sizeof(param_stack[0]), "param_stack");
- test_align ((int) &cur_mark, sizeof(cur_mark[0]), "cur_mark");
- test_align ((int) &pstack, sizeof(pstack[0]), "pstack");
- test_align ((int) &read_file, sizeof(read_file[0]), "read_file");
-
- test_align ((int) &font_check, sizeof(font_check[0]), "font_check");
- test_align ((int) &font_size, sizeof(font_size[0]), "font_size");
- test_align ((int) &font_dsize, sizeof(font_dsize[0]), "font_dsize");
- test_align ((int) &font_params, sizeof(font_params[0]), "font_params");
- test_align ((int) &font_name, sizeof(font_name[0]), "font_name");
- test_align ((int) &font_area, sizeof(font_area[0]), "font_area");
- test_align ((int) &font_bc, sizeof(font_bc[0]), "font_bc");
- test_align ((int) &font_ec, sizeof(font_ec[0]), "font_ec");
- test_align ((int) &font_glue, sizeof(font_glue[0]), "font_glue");
- test_align ((int) &font_used, sizeof(font_used[0]), "font_used");
- test_align ((int) &hyphen_char, sizeof(hyphen_char[0]), "hyphen_char");
- test_align ((int) &skew_char, sizeof(skew_char[0]), "skew_char");
- test_align ((int) &bchar_label, sizeof(bchar_label[0]), "bchar_label");
- test_align ((int) &font_bchar, sizeof(font_bchar[0]), "font_bchar");
- test_align ((int) &font_false_bchar, sizeof(font_false_bchar[0]), "font_false_bchar");
- test_align ((int) &char_base, sizeof(char_base[0]), "char_base");
- test_align ((int) &width_base, sizeof(width_base[0]), "width_base");
- test_align ((int) &height_base, sizeof(height_base[0]), "height_base");
- test_align ((int) &depth_base, sizeof(depth_base[0]), "depth_base");
- test_align ((int) &italic_base, sizeof(italic_base[0]), "italic_base");
- test_align ((int) &lig_kern_base, sizeof(lig_kern_base[0]), "lig_kern_base");
- test_align ((int) &kern_base, sizeof(kern_base[0]), "kern_base");
- test_align ((int) &exten_base, sizeof(exten_base[0]), "exten_base");
- test_align ((int) ¶m_base, sizeof(param_base[0]), "param_base");
-
-#ifdef ALLOCATEDVIBUF
- test_align ((int) &zdvibuf, sizeof(zdvibuf[0]), "zdvibuf"); /* no op */
-#endif
-
- test_align ((int) &total_stretch, sizeof(total_stretch[0]), "total_stretch");
- test_align ((int) &total_shrink, sizeof(total_shrink[0]), "total_shrink");
- test_align ((int) &active_width, sizeof(active_width[0]), "active_width");
- test_align ((int) &cur_active_width, sizeof(cur_active_width[0]), "cur_active_width");
- test_align ((int) &background, sizeof(background[0]), "background");
- test_align ((int) &break_width, sizeof(break_width[0]), "break_width");
- test_align ((int) &minimal_demerits, sizeof(minimal_demerits[0]), "minimal_demerits");
- test_align ((int) &best_place, sizeof(best_place[0]), "best_place");
- test_align ((int) &best_pl_line, sizeof(best_pl_line[0]), "best_pl_line");
- test_align ((int) &hc, sizeof(hc[0]), "hc");
- test_align ((int) &hu, sizeof(hu[0]), "hu");
- test_align ((int) &hyf, sizeof(hyf[0]), "hyf");
-/* test_align ((int) &x, sizeof(x[0]), "x"); */
-
- test_align ((int) &hyf_distance, sizeof(hyf_distance[0]), "hyf_distance");
- test_align ((int) &hyf_num, sizeof(hyf_num[0]), "hyf_num");
- test_align ((int) &hyf_next, sizeof(hyf_next[0]), "hyf_next");
- test_align ((int) &op_start, sizeof(op_start[0]), "op_start");
-
-/* test_align ((int) &trie_op_hash, sizeof(trie_op_hash[0]), "trie_op_hash"); */
- test_align ((int) &zzzaf, sizeof(zzzaf[0]), "zzzaf");
- test_align ((int) &trie_used, sizeof(trie_used[0]), "trie_used");
-/* test_align ((int) &trie_op_lang, sizeof(trie_op_lang[0]), "trie_op_lang");*/
- test_align ((int) &trie_op_val, sizeof(trie_op_val[0]), "trie_op_val");
-
- test_align ((int) &trie_min, sizeof(trie_min[0]), "trie_min");
- test_align ((int) &page_so_far, sizeof(page_so_far[0]), "page_so_far");
- test_align ((int) &write_file, sizeof(write_file[0]), "write_file");
- test_align ((int) &write_open, sizeof(write_open[0]), "write_open");
+ test_align ((long) &mem_top, 4, "mem_top");
+ test_align ((long) &mem_max, 4, "mem_max");
+ test_align ((long) &mem_min, 4, "mem_min");
+ test_align ((long) &bad, 4, "bad");
+ test_align ((long) &trie_size, 4, "trie_size");
+ test_align ((long) &xord, sizeof(xord[0]), "xord");
+ test_align ((long) &xchr, sizeof(xchr[0]), "xchr");
+ test_align ((long) &name_length, 4, "name_length");
+ test_align ((long) &first, 4, "first");
+ test_align ((long) &last, 4, "last");
+ test_align ((long) &max_buf_stack, 4, "max_buf_stack");
+ test_align ((long) &pool_ptr, 4, "pool_ptr");
+ test_align ((long) &str_ptr, 4, "str_ptr");
+ test_align ((long) &init_pool_ptr, 4, "init_pool_ptr");
+ test_align ((long) &init_str_ptr, 4, "init_str_ptr");
+ test_align ((long) &log_file, 4, "log_file");
+ test_align ((long) &tally, 4, "tally");
+ test_align ((long) &term_offset, 4, "term_offset");
+ test_align ((long) &file_offset, 4, "file_offset");
+ test_align ((long) &trick_count, 4, "trick_count");
+ test_align ((long) &first_count, 4, "first_count");
+ test_align ((long) &deletions_allowed, 4, "deletions_allowed");
+ test_align ((long) &set_box_allowed, 4, "set_box_allowed");
+ test_align ((long) &help_line, sizeof(help_line[0]), "help_line");
+ test_align ((long) &use_err_help, 4, "use_err_help");
+ test_align ((long) &interrupt, 4, "interrupt");
+ test_align ((long) &OK_to_interrupt, 4, "OK_to_interrupt");
+ test_align ((long) &arith_error, 4, "arith_error");
+ test_align ((long) &tex_remainder, 4, "tex_remainder");
+ test_align ((long) &temp_ptr, 4, "temp_ptr");
+ test_align ((long) &lo_mem_max, 4, "lo_mem_max");
+ test_align ((long) &hi_mem_min, 4, "hi_mem_min");
+ test_align ((long) &var_used, 4, "var_used");
+ test_align ((long) &dyn_used, 4, "dyn_used");
+ test_align ((long) &avail, 4, "avail");
+ test_align ((long) &mem_end, 4, "mem_end");
+ test_align ((long) &mem_start, 4, "mem_start");
+ test_align ((long) &rover, 4, "rover");
+ test_align ((long) &font_in_short_display, 4, "font_in_short_display");
+ test_align ((long) &depth_threshold, 4, "depth_threshold");
+ test_align ((long) &breadth_max, 4, "breadth_max");
+ test_align ((long) &nest, sizeof(nest[0]), "nest");
+ // test_align ((long) &xeq_level, sizeof(xeq_level[0]), "xeq_level");
+ test_align ((long) &zzzad, sizeof(zzzad[0]), "zzzad");
+ // test_align ((long) &hash, sizeof(hash[0]), "hash");
+ test_align ((long) &zzzae, sizeof(zzzae[0]), "zzzae");
+ test_align ((long) &save_stack, sizeof(save_stack[0]), "save_stack");
+ test_align ((long) &input_stack, sizeof(input_stack[0]), "input_stack");
+ test_align ((long) &input_file, sizeof(input_file[0]), "input_file");
+ test_align ((long) &line_stack, sizeof(line_stack[0]), "line_stack");
+ test_align ((long) ¶m_stack, sizeof(param_stack[0]), "param_stack");
+ test_align ((long) &cur_mark, sizeof(cur_mark[0]), "cur_mark");
+ test_align ((long) &pstack, sizeof(pstack[0]), "pstack");
+ test_align ((long) &read_file, sizeof(read_file[0]), "read_file");
+ test_align ((long) &font_check, sizeof(font_check[0]), "font_check");
+ test_align ((long) &font_size, sizeof(font_size[0]), "font_size");
+ test_align ((long) &font_dsize, sizeof(font_dsize[0]), "font_dsize");
+ test_align ((long) &font_params, sizeof(font_params[0]), "font_params");
+ test_align ((long) &font_name, sizeof(font_name[0]), "font_name");
+ test_align ((long) &font_area, sizeof(font_area[0]), "font_area");
+ test_align ((long) &font_bc, sizeof(font_bc[0]), "font_bc");
+ test_align ((long) &font_ec, sizeof(font_ec[0]), "font_ec");
+ test_align ((long) &font_glue, sizeof(font_glue[0]), "font_glue");
+ test_align ((long) &font_used, sizeof(font_used[0]), "font_used");
+ test_align ((long) &hyphen_char, sizeof(hyphen_char[0]), "hyphen_char");
+ test_align ((long) &skew_char, sizeof(skew_char[0]), "skew_char");
+ test_align ((long) &bchar_label, sizeof(bchar_label[0]), "bchar_label");
+ test_align ((long) &font_bchar, sizeof(font_bchar[0]), "font_bchar");
+ test_align ((long) &font_false_bchar, sizeof(font_false_bchar[0]), "font_false_bchar");
+ test_align ((long) &char_base, sizeof(char_base[0]), "char_base");
+ test_align ((long) &width_base, sizeof(width_base[0]), "width_base");
+ test_align ((long) &height_base, sizeof(height_base[0]), "height_base");
+ test_align ((long) &depth_base, sizeof(depth_base[0]), "depth_base");
+ test_align ((long) &italic_base, sizeof(italic_base[0]), "italic_base");
+ test_align ((long) &lig_kern_base, sizeof(lig_kern_base[0]), "lig_kern_base");
+ test_align ((long) &kern_base, sizeof(kern_base[0]), "kern_base");
+ test_align ((long) &exten_base, sizeof(exten_base[0]), "exten_base");
+ test_align ((long) ¶m_base, sizeof(param_base[0]), "param_base");
+ test_align ((long) &total_stretch, sizeof(total_stretch[0]), "total_stretch");
+ test_align ((long) &total_shrink, sizeof(total_shrink[0]), "total_shrink");
+ test_align ((long) &active_width, sizeof(active_width[0]), "active_width");
+ test_align ((long) &cur_active_width, sizeof(cur_active_width[0]), "cur_active_width");
+ test_align ((long) &background, sizeof(background[0]), "background");
+ test_align ((long) &break_width, sizeof(break_width[0]), "break_width");
+ test_align ((long) &minimal_demerits, sizeof(minimal_demerits[0]), "minimal_demerits");
+ test_align ((long) &best_place, sizeof(best_place[0]), "best_place");
+ test_align ((long) &best_pl_line, sizeof(best_pl_line[0]), "best_pl_line");
+ test_align ((long) &hc, sizeof(hc[0]), "hc");
+ test_align ((long) &hu, sizeof(hu[0]), "hu");
+ test_align ((long) &hyf, sizeof(hyf[0]), "hyf");
+ // test_align ((long) &x, sizeof(x[0]), "x");
+ test_align ((long) &hyf_distance, sizeof(hyf_distance[0]), "hyf_distance");
+ test_align ((long) &hyf_num, sizeof(hyf_num[0]), "hyf_num");
+ test_align ((long) &hyf_next, sizeof(hyf_next[0]), "hyf_next");
+ test_align ((long) &op_start, sizeof(op_start[0]), "op_start");
+ // test_align ((long) &trie_op_hash, sizeof(trie_op_hash[0]), "trie_op_hash");
+ test_align ((long) &trie_used, sizeof(trie_used[0]), "trie_used");
+/* test_align ((long) &trie_op_lang, sizeof(trie_op_lang[0]), "trie_op_lang");*/
+ test_align ((long) &trie_op_val, sizeof(trie_op_val[0]), "trie_op_val");
+ test_align ((long) &trie_min, sizeof(trie_min[0]), "trie_min");
+ test_align ((long) &page_so_far, sizeof(page_so_far[0]), "page_so_far");
+ test_align ((long) &write_file, sizeof(write_file[0]), "write_file");
+ test_align ((long) &write_open, sizeof(write_open[0]), "write_open");
#endif
}
{
(void) flag;
- if (test_align((int) eqtb, sizeof(eqtb[0]), "ALLOCATED ALIGNMENT"))
- puts("PLEASE RECOMPILE ME!\n");
+ if (test_align((long) eqtb, sizeof(eqtb[0]), "ALLOCATED ALIGNMENT"))
+ puts("PLEASE RECOMPILE ME!");
#ifdef CHECKALIGNMENT
if (!flag)
return;
#ifndef ALLOCZEQTB
- test_align ((int) zeqtb, sizeof(zeqtb[0]), "zeqtb");
+ test_align ((long) eqtb, sizeof(eqtb[0]), "eqtb");
#endif
-#ifndef ALLOCATEDVIBUF
- test_align ((int) &zdvibuf, sizeof(zdvibuf[0]), "zdvibuf"); /* no op */
-#endif
-
- test_align ((int) str_pool, sizeof(str_pool[0]), "str_pool"); /* no op */
- test_align ((int) str_start, sizeof(str_start[0]), "str_start");
- test_align ((int) zmem, sizeof(zmem[0]), "main memory");
- test_align ((int) font_info, sizeof(font_info[0]), "font memory");
- test_align ((int) trie_trl, sizeof(trie_trl[0]), "trie_trl");
- test_align ((int) trie_tro, sizeof(trie_tro[0]), "trie_tro");
- test_align ((int) trie_trc, sizeof(trie_trc[0]), "trie_trc");
- test_align ((int) hyph_word, sizeof(hyph_word[0]), "hyph_word");
- test_align ((int) hyph_list, sizeof(hyph_list[0]), "hyph_list");
-/* test_align ((int) trie_c, sizeof(trie_c[0]), "trie_c"); *//* no op */
- test_align ((int) trie_o, sizeof(trie_o[0]), "trie_o");
- test_align ((int) trie_l, sizeof(trie_l[0]), "trie_l");
- test_align ((int) trie_r, sizeof(trie_r[0]), "trie_r");
- test_align ((int) trie_hash, sizeof(trie_hash[0]), "trie_hash");
- test_align ((int) trie_taken, sizeof(trie_taken[0]), "trie_taken");
+ test_align ((long) str_pool, sizeof(str_pool[0]), "str_pool"); /* no op */
+ test_align ((long) str_start, sizeof(str_start[0]), "str_start");
+ test_align ((long) mem, sizeof(mem[0]), "main memory");
+ test_align ((long) font_info, sizeof(font_info[0]), "font memory");
+ test_align ((long) trie_trl, sizeof(trie_trl[0]), "trie_trl");
+ test_align ((long) trie_tro, sizeof(trie_tro[0]), "trie_tro");
+ test_align ((long) trie_trc, sizeof(trie_trc[0]), "trie_trc");
+ test_align ((long) hyph_word, sizeof(hyph_word[0]), "hyph_word");
+ test_align ((long) hyph_list, sizeof(hyph_list[0]), "hyph_list");
+/* test_align ((long) trie_c, sizeof(trie_c[0]), "trie_c"); *//* no op */
+ test_align ((long) trie_o, sizeof(trie_o[0]), "trie_o");
+ test_align ((long) trie_l, sizeof(trie_l[0]), "trie_l");
+ test_align ((long) trie_r, sizeof(trie_r[0]), "trie_r");
+ test_align ((long) trie_hash, sizeof(trie_hash[0]), "trie_hash");
+ test_align ((long) trie_taken, sizeof(trie_taken[0]), "trie_taken");
#endif
}
-boolean backwardflag = false; /* don't cripple all advanced features */
boolean shorten_file_name = false; /* don't shorten file names to 8+3 for DOS */
-boolean usesourcedirectory = true; /* use source file directory as local when WorkingDirectory is set */
/* cache to prevent allocating twice in a row */
-char *lastname = NULL, *lastvalue = NULL;
+char * lastname = NULL;
+char * lastvalue = NULL;
/* returns allocated string -- these strings are not freed again */
/* is it safe to do that now ? 98/Jan/31 */
-char * grabenv (char * varname)
+char * grabenv (const char * varname)
{
- char *s;
+ char * s;
if (varname == NULL)
return NULL;
if (lastname != NULL && strcasecmp(lastname, varname) == 0)
{
if (trace_flag)
- {
- sprintf(log_line, "Cache hit: %s=%s\n", lastname, lastvalue);
- show_line(log_line, 0);
- }
+ printf("Cache hit: %s=%s\n", lastname, lastvalue);
return xstrdup(lastvalue);
}
return NULL;
}
-void flush_trailing_slash (char *directory)
+void flush_trailing_slash (char * directory)
{
- char *s;
+ char * s;
if (strcmp(directory, "") != 0)
{
default_rule = 26214; /* revert to default rule thickness */
pseudo_tilde = false;
pseudo_space = false;
- show_texinput_flag = false;
truncate_long_lines = false;
allow_quoted_names = false;
show_cs_names = false;
- font_dimen_zero = false;
ignore_frozen = false;
suppress_f_ligs = false;
full_file_name_flag = false;
char * xchr_file = NULL;
char * repl_file = NULL;
-char * short_options = "m:e:h:0:H:g:P:o:l:a:wvpiKLZMdp2t?u";
+const char * short_options = "m:e:h:0:H:g:P:o:l:a:r:kwvpiKLZMd2t?u";
static struct option long_options[] =
{
- {"main-memory", 1, 0, 'm'},
- {"hyph-size", 1, 0, 'e'},
- {"trie-size", 1, 0, 'h'},
- {"backend", 1, 0, '0'},
- {"tab-step", 1, 0, 'H'},
- {"percent-grow", 1, 0, 'g'},
- {"default-rule", 1, 0, 'P'},
- {"dvi-dir", 1, 0, 'o'},
- {"log-dir", 1, 0, 'l'},
- {"aux-dir", 1, 0, 'a'},
- {"showhex", 0, 0, 'w'},
- {"verbose", 0, 0, 'v'},
- {"patterns", 0, 0, 'p'},
- {"initex", 0, 0, 'i'},
- {"knuthify", 0, 0, 'K'},
- {"cstyle", 0, 0, 'L'},
- {"showtfm", 0, 0, 'Z'},
- {"showmissing", 0, 0, 'M'},
- {"deslash", 0, 0, 'd'},
- {"patterns", 0, 0, 'p'},
- {"suppressflig", 0, 0, '2'},
- {"trace", 0, 0, 't'},
- {"help", 0, 0, '?'},
- {"usage", 0, 0, 'u'},
+ {"main-memory", required_argument, NULL, 'm'},
+ {"hyph-size", required_argument, NULL, 'e'},
+ {"trie-size", required_argument, NULL, 'h'},
+ {"backend", required_argument, NULL, '0'},
+ {"tab-step", required_argument, NULL, 'H'},
+ {"percent-grow", required_argument, NULL, 'g'},
+ {"default-rule", required_argument, NULL, 'P'},
+ {"dvi-dir", required_argument, NULL, 'o'},
+ {"log-dir", required_argument, NULL, 'l'},
+ {"aux-dir", required_argument, NULL, 'a'},
+ {"key-file", required_argument, NULL, 'k'},
+ {"jobname", required_argument, NULL, 'r'},
+ {"showhex", no_argument, NULL, 'w'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"patterns", no_argument, NULL, 'p'},
+ {"initex", no_argument, NULL, 'i'},
+ {"knuthify", no_argument, NULL, 'K'},
+ {"cstyle", no_argument, NULL, 'L'},
+ {"showtfm", no_argument, NULL, 'Z'},
+ {"showmissing", no_argument, NULL, 'M'},
+ {"deslash", no_argument, NULL, 'd'},
+ {"suppressflig", no_argument, NULL, '2'},
+ {"trace", no_argument, NULL, 't'},
+ {"help", no_argument, NULL, '?'},
+ {"usage", no_argument, NULL, 'u'},
{NULL, 0, 0, 0}
};
-int analyze_flag (int c, char *optarg)
+int analyze_flag (int c, char * optarg)
{
switch (c)
{
+ case 'r':
+ c_job_name = optarg;
+ break;
case 'v':
verbose_flag = true;
break;
is_initex = true;
break;
case 'Q':
- interaction = batch_mode; /* quiet mode */
+ interaction = batch_mode;
break;
case 'R':
- interaction = nonstop_mode; /* run mode */
+ interaction = nonstop_mode;
break;
case 'S':
- interaction = scroll_mode; /* scroll mode */
+ interaction = scroll_mode;
break;
case 'T':
- interaction = error_stop_mode; /* tex mode */
+ interaction = error_stop_mode;
break;
case 'K':
- backwardflag = true;
- knuthify(); /* revert to `standard' Knuth TeX */
+ knuthify();
break;
case 'L':
- c_style_flag = true; /* C style error msg 94/Mar/21 */
+ c_style_flag = true;
break;
case 'Z':
- show_tfm_flag = true; /* show TFM in log file 94/Jun/21 */
+ show_tfm_flag = true;
break;
case 'M':
- show_missing = false; /* do not show missing 94/June/10 */
+ show_missing = false;
break;
case 'd':
- deslash = false; /* flipped 93/Nov/18 */
- /* pseudo_tilde = 0; */ /* new 95/Sep/26 */
+ deslash = false;
break;
case 'p':
- allow_patterns = true; /* 93/Nov/26 */
- /* reset_exceptions = true; */ /* 93/Dec/23 */
+ allow_patterns = true;
break;
-/* case 'w': show_in_hex = false; */ /* 94/Jan/26 */
case 'w':
- show_in_hex = true; /* flipped 00/Jun/18 */
+ show_in_hex = true;
break;
case 'j':
- show_in_dos = true; /* 96/Jan/26 */
+ show_in_dos = true;
break;
case 'n':
restrict_to_ascii = true; /* 0 - 127 1994/Jan/21 */
break;
- case '7':
- usesourcedirectory = false; /* use working dir 98/Sep/29 */
- break;
case 'f':
- show_fonts_used = false; /* 97/Dec/24 */
+ show_fonts_used = false;
break;
case '8':
- shorten_file_name = true; /* 95/Feb/20 */
+ shorten_file_name = true;
break;
case '9':
- show_cs_names = true; /* 98/Mar/31 */
+ show_cs_names = true;
break;
case '4':
- ignore_frozen = true; /* 98/Oct/5 */
- break;
- case '5':
- font_dimen_zero = false; /* 98/Oct/5 */
- break;
- case 'F':
- show_texinput_flag = false; /* 98/Jan/28 */
+ ignore_frozen = true;
break;
-/* case 'X': truncate_long_lines = false; */ /* 98/Feb/2 */
- /* break; */
case 'J':
show_line_break_stats = false; /* 96/Feb/8 */
break;
break;
/* The following are really obscure and should not be advertized */
case 's':
- show_current = false; /* tex8 93/Dec/14 */
+ show_current = false;
break;
case 'N':
- show_numeric = false; /* 93/Dec/21 */
+ show_numeric = false;
break;
case 'A':
- civilize_flag = false; /* 93/Dec/16 */
+ civilize_flag = false;
break;
case 'B':
- open_trace_flag = true; /* openinou 1994/Jan/8 */
+ open_trace_flag = true;
break;
case 'Y':
reorder_arg_flag = false; /* local */
if (mem_initex == 0)
complainarg(c, optarg);
- mem_spec_flag = 1;
+ mem_spec_flag = true;
break;
#ifdef VARIABLETRIESIZE
case 'h':
if (optarg == 0)
+ {
+ //trie_size = atoi(kpse_var_value("trie_size"));
trie_size = default_trie_size;
+ }
else
trie_size = atoi(optarg);
if (tab_step == 0)
complainarg(c, optarg);
break;
+
case 'x':
if (optarg == 0)
xchr_file = xstrdup("xchr.map");
if (xchr_file == NULL || *xchr_file == '\0')
complainarg(c, optarg);
break;
+
case 'k':
if (optarg == 0)
repl_file = xstrdup("repl.key");
if (repl_file == NULL || *repl_file == '\0')
complainarg(c, optarg);
break;
+
case 'P':
if (optarg == 0)
default_rule = 26214;
if (default_rule == 0)
complainarg(c, optarg);
break;
+
case 'E':
if (optarg != 0)
putenv(optarg);
else
complainarg(c, optarg);
break;
+
case 'o':
if (optarg == 0)
dvi_directory = "";
complainarg(c, optarg);
break;
- case '0':
- {
- char * format_spec = NULL;
- if (optarg != 0)
- format_spec = xstrdup(optarg);
-
- if (!strcmp(format_spec, "pdf"))
- shipout_flag = out_pdf_flag;
- else if (!strcmp(format_spec, "dvi"))
- shipout_flag = out_dvi_flag;
- else if (!strcmp(format_spec, "xdv"))
- shipout_flag = out_xdv_flag;
- else
- {
- sprintf(log_line, "ERROR: Do not understand shipout flag `%s'\n", format_spec);
- show_line(log_line, 1);
- }
- }
- break;
case 'l':
if (optarg == 0)
log_directory = "";
else
optargnew = optarg;
- analyze_flag (c, optargnew);
+ analyze_flag(c, optargnew);
}
if (show_use || quitflag == 3)
stamp_it(log_line);
strcat(log_line, "\n");
show_line(log_line, 0);
- //stampcopy(log_line);
- //strcat(log_line, "\n");
- //show_line(log_line, 0);
if (show_use)
show_usage();
if (read_xchr_file(repl_file, 1, av))
{
if (trace_flag)
- puts("KEY REPLACE ON\n");
+ puts("KEY REPLACE ON");
key_replace = true;
}
if (read_xchr_file(xchr_file, 0, av))
{
if (trace_flag)
- puts("NON ASCII ON\n");
+ puts("NON ASCII ON");
non_ascii = true;
}
deslash = true;
pseudo_tilde = 254; /* default '~' replace 95/Sep/26 filledbox DOS 850 */
pseudo_space = 255; /* default ' ' replace 97/June/5 nbspace DOS 850 */
- default_rule = 26214; /* default rule variable 95/Oct/9 */
+ default_rule = 26214;
show_current = true;
civilize_flag = true;
show_numeric = true;
show_missing = true;
- c_style_flag = false; /* use c-style error output */
- show_fmt_flag = true; /* show format file in log */
+ c_style_flag = false;
+ show_fmt_flag = true;
show_tfm_flag = false; /* don't show metric file in log */
shorten_file_name = false; /* don't shorten file names to 8+3 */
- show_texinput_flag = true; /* show TEXINPUTS and TEXFONTS */
truncate_long_lines = true; /* truncate long lines */
tab_step = 0; /* do not replace tabs with spaces */
show_line_break_stats = true; /* show line break statistics 96/Feb/8 */
show_fonts_used = true; /* show fonts used in LOG file 97/Dec/24 */
allow_quoted_names = true; /* allow quoted names with spaces 98/Mar/15 */
show_cs_names = false;
- knuth_flag = false; /* allow extensions to TeX */
+ knuth_flag = false;
full_file_name_flag = true; /* new default 2000 June 18 */
errout = stdout; /* as opposed to stderr say --- used ??? */
new_hyphen_prime = 0;
#ifdef VARIABLETRIESIZE
-/* trie_size = default_trie_size; */
+ // trie_size = default_trie_size;
trie_size = 0;
#endif
mem_extra_high = 0;
mem_extra_low = 0;
mem_initex = 0;
-
- format_name = "plain";
-
- encoding_name = "";
+ format_name = "plain";
if (read_command_line(ac, av) < 0)
return -1;
#if defined(ALLOCATEHIGH) || defined(ALLOCATELOW)
if (mem_extra_high != 0 || mem_extra_low != 0)
{
- puts("ERROR: Cannot extend main memory in iniTeX\n");
- mem_extra_high = 0; mem_extra_low = 0;
+ puts("ERROR: Cannot extend main memory in initex");
+ mem_extra_high = 0;
+ mem_extra_low = 0;
}
#endif
}
{
if (mem_initex != 0)
{
- puts("ERROR: Can only set initial main memory size in iniTeX\n");
+ puts("ERROR: Can only set initial main memory size in initex");
mem_initex = 0;
}
if (trie_size != 0)
{
- puts("ERROR: Need only set hyphenation trie size in iniTeX\n");
+ puts("ERROR: Need only set hyphenation trie size in initex");
/* trie_size = 0; */
}
}
if (trie_size == 0)
trie_size = default_trie_size;
+
/* Just in case user mistakenly specified words instead of kilo words */
if (mem_extra_high > 10000L * 1024L)
mem_extra_high = mem_extra_high / 1024;
if (mem_initex > 2048L * 1024L) /* extend main memory by 16 mega byte! */
{
- puts("WARNING: There may be no benefit to asking for so much memory\n");
+ puts("WARNING: There may be no benefit to asking for so much memory");
/* mem_initex = 2048 * 1024; */
}
if (new_hyphen_prime > 0)
{
if (! is_initex)
- puts("ERROR: Can only set hyphen prime in iniTeX\n");
+ puts("ERROR: Can only set hyphen prime in initex");
else
{
if (new_hyphen_prime % 2 == 0)
new_hyphen_prime = new_hyphen_prime + 2;
if (trace_flag)
- {
- sprintf(log_line, "Using %d as hyphen prime\n", new_hyphen_prime);
- show_line(log_line, 0);
- }
+ printf("Using %d as hyphen prime\n", new_hyphen_prime);
}
}
percent_grow = 10; /* lower limit - 10% */
}
-/**********************************************************************/
-
-void perrormod (char *s)
+void perrormod (const char * s)
{
- sprintf(log_line, "`%s': %s\n", s, strerror(errno));
- show_line(log_line, 1);
+ printf("`%s': %s\n", s, strerror(errno));
}
-/*************************************************************************/
-
/* convert tilde to pseudo_tilde to hide it from TeX --- 95/Sep/26 */
/* convert space to pseudo_space to hide it from TeX --- 97/Jun/5 */
/* called only if pseudo_tilde != 0 or pseudo_space != 0 */
#ifdef DEBUGTWIDDLE
if (trace_flag)
- {
- sprintf(log_line, "Hidetwiddle %s", tname);
- show_line(log_line, 0);
- }
+ printf("Hidetwiddle %s", tname);
#endif
while (*s != '\0')
#ifdef DEBUGTWIDDLE
if (trace_flag)
- {
- sprintf(log_line, "=> %s\n", tname);
- show_line(log_line, 0);
- }
+ printf("=> %s\n", tname);
#endif
}
if (*s == '\\' || *s == '/')
*s = '\0';
- texpath = xstrdup(buffer);
-
if (strcmp(dvi_directory, "") != 0)
flush_trailing_slash(dvi_directory);
if (deslash)
{
- unixify (texpath);
-
if (strcmp(dvi_directory, "") != 0)
unixify(dvi_directory);
unixify(pdf_directory);
}
- format_spec = 0;
+ format_spec = false;
if (optind < ac && optind > 0)
{
if (deslash)
{
- if (trace_flag || debug_flag)
- {
- sprintf(log_line, "deslash: k %d argv[k] %s (argc %d)\n",
- optind, av[optind], ac);
- show_line(log_line, 0);
- }
+ if (trace_flag)
+ printf("deslash: k %d argv[k] %s (argc %d)\n", optind, av[optind], ac);
unixify(av[optind]);
}
if (pseudo_tilde != 0 || pseudo_space != 0)
- hidetwiddle (av[optind]);
+ hidetwiddle(av[optind]);
if (*av[optind] == '&' || *av[optind] == '+')
{
- format_spec = 1;
+ format_spec = true;
format_name = xstrdup(av[optind] + 1);
if (optind + 1 < ac)
{
if (deslash)
{
- if (trace_flag || debug_flag)
- {
- sprintf(log_line, "deslash: k %d argv[k] %s (argc %d)\n",
- optind + 1, av[optind + 1], ac);
- show_line(log_line, 0);
- }
+ if (trace_flag)
+ printf("deslash: k %d argv[k] %s (argc %d)\n", optind + 1, av[optind + 1], ac);
unixify(av[optind + 1]);
}
if (pseudo_tilde != 0 || pseudo_space != 0)
- hidetwiddle (av[optind + 1]);
+ hidetwiddle(av[optind + 1]);
}
}
}
}
-/* note: those optarg == 0 test don't really work ... */
-/* note: optarg starts at = in case of x=... */
-
-int main_init (int ac, char **av)
+int main_init (int ac, char ** av)
{
- kpse_set_program_name(av[0], NULL);
+ kpse_set_program_name(av[0], "dvipdfmx");
xputenv("engine", "yandytex");
if (sizeof(memory_word) != sizeof(halfword) * 2)
- printf("ERROR: Bad word size %d!\n", sizeof(memory_word));
+ printf("ERROR: Bad word size %ld!\n", sizeof(memory_word));
start_time = clock();
main_time = start_time;
#ifdef ALLOCATEBUFFER
buffer = NULL;
current_buf_size = 0;
- buffer = realloc_buffer (initial_buf_size);
+ buffer = realloc_buffer(initial_buf_size);
#endif
hyph_list = NULL;
log_opened = false; /* so can tell whether opened */
interaction = -1; /* default state => 3 */
missing_characters = 0; /* none yet! */
- font_dimen_zero = true; /* \fontdimen0 for checksum 98/Oct/5 */
ignore_frozen = false; /* default is not to ignore 98/Oct/5 */
suppress_f_ligs = false; /* default is not to ignore f-ligs */
underfull_hbox = 0;
overfull_vbox = 0;
underfull_vbox = 0;
- closed_already = 0;
if (trace_flag)
- puts("Entering init (local.c)");
+ puts("Entering main_init() (local.c).");
probe_memory();
ini_max_address = max_address;
initial_memory();
deslash_all(ac, av);
- no_interrupts = 0;
if (format_spec && mem_spec_flag)
- puts("WARNING: Cannot change initial main memory size when format specified");
+ puts("WARNING: Cannot change initial main_memory size when format specified");
if (allocate_memory() != 0)
return -1;
check_alloc_align(trace_flag);
if (trace_flag)
- puts("Leaving init (local.c)");
+ puts("Leaving main_init() (local.c).");
return 0;
}
flag = 1;
if (missing_characters)
- {
- sprintf(log_line, "! There %s %d missing character%s --- see log file\n",
- (missing_characters == 1) ? "was" : "were", missing_characters,
+ printf("! There %s %d missing character%s --- see log file\n",
+ (missing_characters == 1) ? "was" : "were", missing_characters,
(missing_characters == 1) ? "" : "s");
- show_line(log_line, 0);
- }
if (free_memory() != 0)
flag++;
return flag;
}
// printf control sequences' name
-void print_cs_name (FILE *output, int h)
+void print_cs_name (FILE * output, int h)
{
int c, textof, n;
memmove(log_line + c + n, "\n", 2);
if (output == stderr)
- {
show_line(log_line, 1);
- }
+ else if (output == stdout)
+ show_line(log_line, 0);
else
- {
- if (output == stdout)
- show_line(log_line, 0);
- else
- fprintf(output, "%s", log_line);
- }
-
+ fprintf(output, "%s", log_line);
}
// prototype
int compare_strn (int, int, int, int);
if (pass == 1 && csused[h])
continue;
- if (hash[h].rh != 0)
+ if (text(h) != 0)
{
if (pass == 0)
csused[h] = 1;
ccount, (pass == 1) ? "new" : "");
if (output == stderr)
- {
show_line(log_line, 1);
- }
+ else if (output == stdout)
+ show_line(log_line, 0);
else
- {
- if (output == stdout)
- show_line(log_line, 0);
- else
- fprintf(output, "%s", log_line);
- }
+ fprintf(output, "%s", log_line);
if (ccount > 0)
{
sprintf(log_line, "\n");
if (output == stderr)
- {
show_line(log_line, 1);
- }
+ else if (output == stdout)
+ show_line(log_line, 0);
else
- {
- if (output == stdout)
- show_line(log_line, 0);
- else
- fprintf(output, "%s", log_line);
- }
+ fprintf(output, "%s", log_line);
free((void *)cnumtable);
}
return 0; /* strings match */
}
/* compare two font names and their at sizes in qsort */
-int compare_fnt (const void *fp1, const void *fp2)
+int compare_fnt (const void * fp1, const void * fp2)
{
int f1, f2, l1, l2, k1, k2, s;
return s;
}
/* decode checksum information */
-unsigned long checkdefault = 0x59265920; /* default signature */
+const unsigned long checkdefault = 0x59265920;
int decode_fourty (unsigned long checksum, char *codingvector)
{
int c;
codingvector[5-k] = (char) c;
}
+
codingvector[6] = '\0';
}
return (pt);
}
-void dvi_font_show(internal_font_number f, int suppressname)
+void dvi_font_show (internal_font_number f, int suppressname)
{
int a, l, k, n;
unsigned long checksum;
{
if (m > 0)
{
- if (compare_fnt_name(fnumtable[m-1], fnumtable[m]) == 0)
+ if (compare_fnt_name(fnumtable[m - 1], fnumtable[m]) == 0)
repeatflag = 1;
else
repeatflag = 0;