OSDN Git Service

show_inter_val().
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Fri, 13 Jun 2014 23:32:24 +0000 (07:32 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Fri, 13 Jun 2014 23:32:24 +0000 (07:32 +0800)
type cast.
succmb().
fixed glue values: 65535->unity.
write_dvi: macro -> inline function.
removed abort_flag.

16 files changed:
src/texsourc/Makefile.gcc
src/texsourc/coerce.h
src/texsourc/itex.c
src/texsourc/local.c
src/texsourc/makefile
src/texsourc/openinou.c
src/texsourc/subroute.c
src/texsourc/tex0.c
src/texsourc/tex3.c
src/texsourc/tex4.c
src/texsourc/tex8.c
src/texsourc/tex9.c
src/texsourc/texd.h
src/texsourc/texmf.h
src/texsourc/yandy_inlines.c [new file with mode: 0644]
src/texsourc/yandy_macros.h

index 247e825..904d53d 100644 (file)
@@ -18,7 +18,7 @@ LDFLAGS = -lkpathsea -lhpdf -lpng -lz
 objects = yandytex.o itex.o openinou.o subroute.o local.o \
        tex0.o tex1.o tex2.o tex3.o tex4.o \
        tex5.o tex6.o tex7.o tex8.o tex9.o \
-       yandy_pool.o md5.o yandy_backend_pdf.o
+       yandy_pool.o md5.o yandy_inlines.o
 
 headers = yandytex.h texd.h coerce.h texmf.h texmfmem.h
 
@@ -76,8 +76,8 @@ yandy_pool.o: yandy_pool.c $(headers)
 md5.o: libmd5/md5.c $(headers)
        $(CC) -c $(CFLAGS) libmd5/md5.c
 
-yandy_backend_pdf.o: yandy_backend_pdf.c $(headers)
-       $(CC) -c $(CFLAGS) yandy_backend_pdf.c
+yandy_inlines.o: yandy_inlines.c $(headers)
+       $(CC) -c $(CFLAGS) yandy_inlines.c
 
 .PHONY: clean
 
index bff03cb..6c90e45 100644 (file)
@@ -16,7 +16,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301 USA.  */
 
-void print_err (const char * s);
 void initialize (void);
 void print_ln (void);
 void print_char_(ASCII_code);
index ce9471e..9f9efa1 100644 (file)
@@ -142,7 +142,7 @@ void initialize (void)
   mode = 1;
   head = contrib_head;
   tail = contrib_head;
-  cur_list.aux_field.cint = ignore_depth;
+  prev_depth = ignore_depth;
   mode_line = 0;
   prev_graf = 0;
   shown_mode = 0;
@@ -2174,7 +2174,7 @@ int main_program (void)
     printf("%s%s%ld\n", "Ouch---my internal constants have been clobbered!",
         "---case ", (long) bad);
 
-    goto lab9999;
+    goto final_end;
   }
 
   initialize();
@@ -2183,7 +2183,7 @@ int main_program (void)
   if (is_initex)
   {
     if (!get_strings_started())
-      goto lab9999;
+      goto final_end;
 
     init_prim();
     init_str_ptr = str_ptr;
@@ -2203,12 +2203,12 @@ lab1:
 
 #ifdef _WIN32
   #ifdef _WIN64
-    printf(log_line, " (%s %s/Windows 64bit)", application, yandyversion);
+    printf(" (%s %s/Win64)", application, yandyversion);
   #else
-    printf(log_line, " (%s %s/Windows 32bit)", application, yandyversion);
+    printf(" (%s %s/Win32)", application, yandyversion);
   #endif
 #else
-    printf(log_line, " (%s %s/Linux)", application, yandyversion);
+    printf(" (%s %s/Linux)", application, yandyversion);
 #endif
 
   if (format_ident > 0)
@@ -2256,21 +2256,20 @@ lab1:
       align_state = 1000000L;
 
       if (!init_terminal())
-        goto lab9999;
+        goto final_end;
 
       limit = last;
       first = last + 1;
     }
     
-    if ((format_ident == 0) ||
-        (buffer[loc] == '&') ||
-        (buffer[loc] == '+'))
+    if ((format_ident == 0) || (buffer[loc] == '&') ||
+      (buffer[loc] == '+'))
     {
       if (format_ident != 0)
         initialize();
 
       if (!open_fmt_file ())
-        goto lab9999;
+        goto final_end;
 
       if (!load_fmt_file ())
       {
@@ -2279,7 +2278,7 @@ lab1:
 #else
         w_close(fmt_file);
 #endif
-        goto lab9999;
+        goto final_end;
       }
 
 #ifdef COMPACTFORMAT
@@ -2288,8 +2287,7 @@ lab1:
       w_close(fmt_file);
 #endif
 
-      while ((loc < limit) &&
-          (buffer[loc] == ' '))
+      while ((loc < limit) && (buffer[loc] == ' '))
         incr(loc);
     }
 
@@ -2306,8 +2304,7 @@ lab1:
     else
       selector = term_only;
 
-    if ((loc < limit) &&
-      (cat_code(buffer[loc]) != escape))
+    if ((loc < limit) && (cat_code(buffer[loc]) != escape))
       start_input();
   }
 
@@ -2328,7 +2325,7 @@ lab1:
   final_cleanup();
   close_files_and_terminate();
 
-lab9999:
+final_end:
   {
     int code;
 
@@ -2365,7 +2362,7 @@ void add_variable_space(int size)
   if (mem_min < mem_start)      /* sanity test */
   {
     if (trace_flag)
-      puts("WARNING: mem_min < mem_start!\n");
+      puts("WARNING: mem_min < mem_start!");
 
     mem_min = mem_start;
   }
@@ -2384,15 +2381,13 @@ void add_variable_space(int size)
 }
 #endif
 
-/**************************************************************************/
-
 #ifdef INITEX
 /* split out to allow sharing of code from do_initex and newpattern */
 void reset_trie (void)
 {
   integer k;
 
-  for (k = - (integer) trie_op_size; k <= trie_op_size; k++)
+  for (k = -(integer)trie_op_size; k <= trie_op_size; k++)
     trie_op_hash[k] = 0;
 
   for (k = 0; k <= 255; k++)
@@ -2407,7 +2402,7 @@ void reset_trie (void)
   trie_not_ready = true;
 }
 /* borrowed code from initialize() */
-void reset_hyphen (void)
+void reset_hyphen(void)
 {
   hyph_pointer z;
 
@@ -2439,15 +2434,15 @@ void do_initex (void)
     k = k + glue_spec_size;
   }
 
-  stretch(fil_glue) = 65535L;
+  stretch(fil_glue) = unity;
   stretch_order(fil_glue) = fil;
-  stretch(fill_glue) = 65535L;
+  stretch(fill_glue) = unity;
   stretch_order(fill_glue) = fill;
-  stretch(ss_glue) = 65535L;
+  stretch(ss_glue) = unity;
   stretch_order(ss_glue) = fil;
-  shrink(ss_glue) = 65535L;
+  shrink(ss_glue) = unity;
   shrink_order(ss_glue) = fil;
-  stretch(fil_neg_glue) = -65536L;
+  stretch(fil_neg_glue) = -unity;
   stretch_order(fil_neg_glue) = fil;
   rover = lo_mem_stat_max + 1;
   link(rover) = empty_flag;
@@ -2472,7 +2467,7 @@ void do_initex (void)
   link(mem_top) = page_ins_head;
   type(page_head) = glue_node;
   subtype(page_head) = normal;
-  avail = 0;                   /* avail <- null p.164 */
+  avail = 0;
   mem_end = mem_top;
   hi_mem_min = hi_mem_stat_min;
   var_used = lo_mem_stat_max + 1 - mem_bot;
@@ -2871,7 +2866,7 @@ void first_fit_ (trie_pointer p)
       {
         overflow("pattern memory", trie_size);
 /*      not dynamic ---- but can be set -h=... from command line in ini-TeX */
-        return;     // abort_flag set
+        return;
       }
 
       do
@@ -3275,7 +3270,6 @@ void store_fmt_file (void)
     if (!knuth_flag)
       puts("  (Use -i on the command line)\n");
 
-    abort_flag++;
     return;
   }
 
index 880c567..f9d9ca3 100644 (file)
@@ -2250,7 +2250,7 @@ void check_alloc_align (int flag)
 {
   (void) flag;
 
-  if (test_align ((int) eqtb, sizeof(eqtb[0]), "ALLOCATED ALIGNMENT"))
+  if (test_align((int) eqtb, sizeof(eqtb[0]), "ALLOCATED ALIGNMENT"))
     puts("PLEASE RECOMPILE ME!\n");
 
 #ifdef CHECKALIGNMENT
@@ -2806,8 +2806,6 @@ int init_commands (int ac, char **av)
   knuth_flag            = false; /* allow extensions to TeX */
   full_file_name_flag   = true;  /* new default 2000 June 18 */
   errout                = stdout; /* as opposed to stderr say --- used ??? */
-  abort_flag            = 0;      // not yet hooked up ???
-  err_level             = 0;      // not yet hooked up ???
   new_hyphen_prime      = 0;
 
 #ifdef VARIABLETRIESIZE
@@ -3011,26 +3009,25 @@ void deslash_all (int ac, char **av)
 
   s = buffer + strlen(buffer) - 1;
 
-  if (*s == '\\' || *s == '/') *s = '\0';   /* flush trailing PATH_SEP */
+  if (*s == '\\' || *s == '/')
+    *s = '\0';
 
   texpath = xstrdup(buffer);
 
-/*  Hmm, we may be operating on DOS environment variables here !!! */
-
   if (strcmp(dvi_directory, "") != 0)
-    flush_trailing_slash (dvi_directory);
+    flush_trailing_slash(dvi_directory);
 
   if (strcmp(log_directory, "") != 0)
-    flush_trailing_slash (log_directory);
+    flush_trailing_slash(log_directory);
 
   if (strcmp(aux_directory, "") != 0)
-    flush_trailing_slash (aux_directory);
+    flush_trailing_slash(aux_directory);
 
   if (strcmp(fmt_directory, "") != 0)
-    flush_trailing_slash (fmt_directory);
+    flush_trailing_slash(fmt_directory);
 
   if (strcmp(pdf_directory, "") != 0)
-    flush_trailing_slash (pdf_directory);
+    flush_trailing_slash(pdf_directory);
 
   if (deslash)
   {
@@ -3053,10 +3050,7 @@ void deslash_all (int ac, char **av)
   }
 
   format_spec = 0;
-/*  NOTE: assuming that command line arguments are in writable memory ! */
-/*  if (trace_flag || debug_flag)
-    sprintf(log_line, "optind %d ac %d\n", optind, ac); */   /* debugging */ 
-/*  if (optind < ac) { */           /* bkph */
+
   if (optind < ac && optind > 0)
   {
     if (deslash)
@@ -3074,7 +3068,6 @@ void deslash_all (int ac, char **av)
     if (pseudo_tilde != 0 || pseudo_space != 0)
       hidetwiddle (av[optind]);
 
-    /* For Windows NT, lets allow + instead of & for format specification */
     if (*av[optind] == '&' || *av[optind] == '+')
     {
       format_spec = 1;
@@ -3110,10 +3103,7 @@ int main_init (int ac, char **av)
   xputenv("engine", "yandytex");
 
   if (sizeof(memory_word) != sizeof(halfword) * 2)
-  {
-    sprintf(log_line, "ERROR: Bad word size %d!\n", sizeof(memory_word));
-    show_line(log_line, 1);
-  }
+    printf("ERROR: Bad word size %d!\n", sizeof(memory_word));
 
   start_time = clock();
   main_time  = start_time;
@@ -3182,10 +3172,10 @@ int main_init (int ac, char **av)
   closed_already    = 0;
 
   if (trace_flag)
-    puts("Entering init (local.c)\n");
+    puts("Entering init (local.c)");
 
-  probe_memory(); /* show top address */
-  ini_max_address = max_address; /* initial max address */
+  probe_memory();
+  ini_max_address = max_address;
 
   if (trace_flag)
     show_maximums(stdout);
@@ -3200,11 +3190,10 @@ int main_init (int ac, char **av)
   if (allocate_memory() != 0)
     return -1;
 
-  /* following is more or less useless since most all things not yet alloc */
-  check_alloc_align(trace_flag);    /* sanity check 1994/Jan/8 */
+  check_alloc_align(trace_flag);
 
   if (trace_flag)
-    show_line("Leaving init (local.c)\n", 0);
+    puts("Leaving init (local.c)");
 
   return 0;
 }
@@ -3220,32 +3209,27 @@ void show_inter_val (clock_t inter_val)
     tenths = (inter_val * 10 + CLK_TCK / 2) / CLK_TCK; 
     seconds = tenths / 10; 
     tenths = tenths % 10;
-    sprintf(log_line, "%d.%d", seconds, tenths);
-    show_line(log_line, 0);
+    printf("%d.%d", seconds, tenths);
+  }
+  else if (inter_val >= CLK_TCK)
+  {
+    hundredth = (inter_val * 100 + CLK_TCK / 2) / CLK_TCK;
+    seconds = hundredth / 100;
+    hundredth = hundredth % 100;
+    printf("%d.%02d", seconds, hundredth);
+  }
+  else if (inter_val > 0)
+  {
+    thousands = (inter_val * 1000 + CLK_TCK / 2) / CLK_TCK;
+    seconds = thousands / 1000;
+    thousands = thousands % 1000;
+    printf("%d.%03d", seconds, thousands);
   }
   else
-    if (inter_val >= CLK_TCK)     /* 94/Feb/25 */
-    {
-      hundredth = (inter_val * 100 + CLK_TCK / 2) / CLK_TCK;
-      seconds = hundredth / 100;
-      hundredth = hundredth % 100;
-      sprintf(log_line, "%d.%02d", seconds, hundredth);
-      show_line(log_line, 0);
-    }
-    else
-      if (inter_val > 0)         /* 94/Oct/4 */
-      {
-        thousands = (inter_val * 1000 + CLK_TCK / 2) / CLK_TCK;
-        seconds = thousands / 1000;
-        thousands = thousands % 1000;
-        sprintf(log_line, "%d.%03d", seconds, thousands);
-        show_line(log_line, 0);
-      }
-      else
-        show_line("0", 0);
+    show_line("0", 0);
 }
 
-int endit (int flag)
+int endit(int flag)
 {
   finish_time = clock();
 
@@ -3265,21 +3249,19 @@ int endit (int flag)
 
   if (verbose_flag)
   {
-    puts("Total ");
+    printf("Total ");
     show_inter_val(finish_time - start_time);
-    puts(" sec (");
+    printf(" sec (");
     show_inter_val(main_time - start_time);
-    puts(" format load + ");
+    printf(" format load + ");
     show_inter_val(finish_time - main_time);
-    puts(" processing) ");
+    printf(" processing) ");
 
     if (total_pages > 0)
     {
       show_inter_val((finish_time - main_time) / total_pages);
-      puts(" sec per page.");
+      printf(" sec per page.");
     }
-
-    puts("\n");
   }
 
   return flag;
@@ -3448,8 +3430,6 @@ void print_cs_names (FILE *output, int pass)
   }
 }
 
-/***************** font info listing moved from TEX9.C ******************/
-/* compare two strings in str_pool (not null terminated) */
 /* k1 and k2 are positions in string pool */
 /* l1 and l2 are lengths of strings */
 int compare_strn (int k1, int l1, int k2, int l2)
@@ -3565,7 +3545,6 @@ double sclpnt (long x)
   return (pt);
 }
 
-// Shows list of fonts in log file
 void dvi_font_show(internal_font_number f, int suppressname)
 {
   int a, l, k, n;
@@ -3627,7 +3606,7 @@ void show_font_info (void)
   if (fcount == 0)
     return;
 
-  fnumtable = (short *) malloc (fcount * sizeof(short));
+  fnumtable = (short *) malloc(fcount * sizeof(short));
 
   fprintf(log_file, "\nUsed %d font%s:\n", fcount, (fcount == 1) ? "" : "s");
 
@@ -3637,7 +3616,7 @@ void show_font_info (void)
     if (font_used[k])
       fnumtable[fcount++] = (short) k;
 
-  qsort ((void *)fnumtable, fcount, sizeof (short), &compare_fnt);
+  qsort ((void *)fnumtable, fcount, sizeof(short), &compare_fnt);
 
   repeatflag = 0;
 
index 6fd7538..b7d9a73 100644 (file)
@@ -9,20 +9,8 @@ CC = cl
 LINK = link
 RC = rc
 
-# -Gf saves about 7k bytes in EXE file
-
-# For production (-Bd show compiler passes)
-# ASSUMING WE WORK WITH MS COMPILER AND LINKER ONLY use -Gy and -Gf
-# CFLAGS=-c -DDOS -DMSDOS -DPHARLAP -DTeX -DMYDEBUG -Ilib -Ox -Gy -Gf -W3
-# CFLAGS=-c -DDOS -DMSDOS -DPHARLAP -DTeX -DMYDEBUG -Ilib -YX -Ox -Ge -Gy -Gf -W4
-# Release version
-# CFLAGS=/c /Ge /Gy /Gf /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG /Ilib /YX
 CFLAGS=/nologo /c /MT /GF /Gy /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG \
        /I"kpathsea" /I"zlib" /I"libmd5"
-# Debugging version
-# CFLAGS=/c /Ge /Gy /Gf /Od /Zi /W4 /DMSDOS /DTeX /DPHARLAP /Ilib /YX
-
-# NOTE: -Ox => -Ogityb1 -Gs
 
 # Link with MS LINK
 # LFLAGS=@yandytex.nt /MAP lib\libdos.lib
@@ -37,14 +25,14 @@ LFLAGS=/NOLOGO /MAP
 objs = yandytex.obj itex.obj openinou.obj subroute.obj local.obj \
        tex0.obj tex1.obj tex2.obj tex3.obj tex4.obj \
        tex5.obj tex6.obj tex7.obj tex8.obj tex9.obj \
-       yandy_pool.obj yandytex.res md5.obj
+       yandy_pool.obj yandytex.res md5.obj yandy_inlines.obj
 
 # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
 
 yandytex.exe: $(objs)
        $(LINK) $(LFLAGS) yandytex itex openinou subroute local \
        tex0 tex1 tex2 tex3 tex4 tex5 tex6 tex7 tex8 tex9 \
-       yandy_pool yandytex.res md5 \
+       yandy_pool yandytex.res md5 yandy_inlines\
        kpathsea\kpathsea.lib libpng\libpng.lib zlib\zlib.lib \
        dvipdfmx\libdvipdfmx.lib
        del ..\yandy\bin\yandytex.exe
@@ -109,6 +97,9 @@ tex9.obj: tex9.c \
 yandy_pool.obj: yandy_pool.c \
        texd.h texmf.h texmfmem.h coerce.h yandy_macros.h
 
+yandy_inlines.obj: yandy_inlines.c \
+       texd.h texmf.h texmfmem.h coerce.h yandy_macros.h
+
 .SUFFIXES:
 .SUFFIXES: .obj .c
 
index 8f04ed5..b796ebb 100644 (file)
 
 #include "texd.h"
 
+extern char * dvi_directory;
+extern char * log_directory;
+extern char * aux_directory;
+extern char * fmt_directory;
+extern char * pdf_directory;
+
 #define PATH_SEP        '/'
 #define PATH_SEP_STRING "/"
 
@@ -77,7 +83,6 @@ char * xconcat3 (char *buffer, char *s1, char *s2, char *s3)
 }
 #endif
 
-// separated out 1996/Jan/20 to make easier to read
 // assumes path does not end in PATH_SEP
 void patch_in_path (unsigned char *buffer, unsigned char *name, unsigned char *path)
 {
@@ -197,9 +202,7 @@ boolean open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
     retwiddle(name_of_file + 1);
 
   if (shorten_file_name)
-  {
     check_short_name(name_of_file + 1);
-  }
   
   if (open_trace_flag)
   {
@@ -319,16 +322,6 @@ boolean open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
   return openable;
 }
 
-/* Call the external program PROGRAM, passing it `name_of_file'.  */
-/* This nonsense probably only works for Unix anyway. bkph */
-/* For one thing, MakeTeXTFM etc is more than 8 characters ! */
-
-extern char * dvi_directory;
-extern char * log_directory;
-extern char * aux_directory;
-extern char * fmt_directory;
-extern char * pdf_directory;
-
 /* At least check for I/O error (such as disk full) when closing */
 /* Would be better to check while writing - but this is better than nothing */
 /* This is used for both input and output files, but never mind ... */
@@ -376,19 +369,12 @@ boolean open_output (FILE **f, char *fopen_mode)
       prepend_path_if(name_of_file + 1, name_of_file + 1, ".pdf", (unsigned char *) pdf_directory))
   {
     if (open_trace_flag)
-    {
-      sprintf(log_line, "After prepend %s\n", name_of_file + 1);
-      show_line(log_line, 0);
-    }
+      printf("After prepend %s\n", name_of_file + 1);
   }
 
   if (open_trace_flag)
-  {
-    sprintf(log_line, " Open `%s' for output ", name_of_file + 1);
-    show_line(log_line, 0);
-  }
+    printf(" Open `%s' for output ", name_of_file + 1);
 
-/*  but we can assume this is opening here for *output* */
   *f = fopen((char *) name_of_file + 1, fopen_mode);
 
 /* Can't open as given.  Try the envvar.  */
@@ -421,9 +407,7 @@ boolean open_output (FILE **f, char *fopen_mode)
 
 #ifdef COMPACTFORMAT
   if (strstr((char *) name_of_file + 1, ".fmt") != NULL)
-  {
     gz_fmt_file = gzdopen(fileno(*f), "wb9");
-  }
 #endif
 
   if (strstr((char *) name_of_file + 1, ".dvi") != NULL)
@@ -475,5 +459,5 @@ boolean open_output (FILE **f, char *fopen_mode)
   if (*f)
     name_length = temp_length;
   
-  return *f != NULL;
+  return (*f != NULL);
 }
\ No newline at end of file
index fd76055..03aeab5 100644 (file)
@@ -98,11 +98,7 @@ char * unixify (char * t)
   }
 
   if (trace_flag)
-  {
     printf("Unixified name: %s\n", t);
-    //sprintf(log_line, "Unixified name: %s\n", t);
-    //show_line(log_line, 0);
-  }
 
   return t;
 }
index 64af5a1..61b05ca 100644 (file)
 
 #include "texd.h"
 
-INLINE void prompt_input(const char * s)
-{
-  print_string(s);
-  term_input();
-}
-INLINE void synch_h(void)
-{
-  if (cur_h != dvi_h)
-  {
-    movement(cur_h - dvi_h, right1);
-    dvi_h = cur_h;
-  }
-}
-INLINE void synch_v(void)
-{
-  if (cur_v != dvi_v)
-  {
-    movement(cur_v - dvi_v, down1);
-    dvi_v = cur_v;
-  }
-}
-INLINE void set_cur_lang(void)
-{
-  if (language <= 0)
-    cur_lang = 0;
-  else if (language > 255)
-    cur_lang = 0;
-  else
-    cur_lang = language;
-}
-INLINE void free_avail_(halfword p)
-{
-  link(p) = avail;
-  avail = p;
-#ifdef STAT
-  decr(dyn_used);
-#endif /* STAT */
-}
-INLINE void dvi_out_(ASCII_code op)
-{
-  dvi_buf[dvi_ptr] = op;
-  incr(dvi_ptr);
-
-  if (dvi_ptr == dvi_limit)
-    dvi_swap();
-}
-INLINE void succumb (void)
-{
-  if (interaction == error_stop_mode)
-    interaction = scroll_mode;
-
-  if (log_opened)
-  {
-    error();
-  }
-
-#ifdef DEBUG
-  if (interaction > 0)
-    debug_help();
-#endif
-
-  history = 3;
-  jump_out();
-}
-INLINE void flush_string (void)
-{
-  decr(str_ptr);
-  pool_ptr = str_start[str_ptr];
-}
-INLINE void append_char (ASCII_code c)
-{
-  str_pool[pool_ptr] = c;
-  incr(pool_ptr);
-}
-INLINE void append_lc_hex (ASCII_code c)
-{
-  if (c < 10)
-    append_char(c + '0');
-  else
-    append_char(c - 10 + 'a');
-}
-INLINE void print_err (const char * s)
-{
-  if (interaction == error_stop_mode);
-    print_nl("! ");
-  print_string(s);
-}
-INLINE void tex_help (unsigned int n, ...)
-{
-  int i;
-  va_list help_arg;
-
-  if (n > 6)
-    n = 6;
-
-  help_ptr = n;
-  va_start(help_arg, n);
-
-  for (i = n - 1; i > -1; --i)
-    help_line[i] = va_arg(help_arg, char *);
-
-  va_end(help_arg);
-}
-INLINE void str_room_ (int val)
-{
-#ifdef ALLOCATESTRING
-  if (pool_ptr + val > current_pool_size)
-    str_pool = realloc_str_pool(increment_pool_size);
-
-  if (pool_ptr + val > current_pool_size)
-  {
-    overflow("pool size", current_pool_size - init_pool_ptr);
-  }
-#else
-  if (pool_ptr + val > pool_size)
-  {
-    overflow("pool size", pool_size - init_pool_ptr);
-  }
-#endif
-}
-INLINE void tail_append_ (pointer val)
-{
-  link(tail) = val;
-  tail = link(tail);
-}
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 /* sec 0058 */
 void print_ln (void)
 {
@@ -155,12 +27,12 @@ void print_ln (void)
     case term_and_log:
       show_char('\n');
       term_offset = 0;
-      (void) putc ('\n', log_file);
+      (void) putc('\n', log_file);
       file_offset = 0;
       break;
 
     case log_only:
-      (void) putc ('\n',  log_file);
+      (void) putc('\n',  log_file);
       file_offset = 0;
       break;
 
@@ -175,7 +47,7 @@ void print_ln (void)
       break;
 
     default:
-      (void) putc ('\n', write_file[selector]);
+      (void) putc('\n', write_file[selector]);
       break;
   }
 }
@@ -183,13 +55,11 @@ void print_ln (void)
 void print_char_ (ASCII_code s)
 {
   if (s == new_line_char)
-  {
     if (selector < pseudo)
     {
       print_ln();
       return;
     }
-  }
 
   switch (selector)
   {
@@ -249,13 +119,13 @@ void print_char_ (ASCII_code s)
       
       if (pool_ptr < current_pool_size)
       {
-        str_pool[pool_ptr]= s;
+        str_pool[pool_ptr] = s;
         incr(pool_ptr);
       }
 #else
       if (pool_ptr < pool_size)
       {
-        str_pool[pool_ptr]= s;
+        str_pool[pool_ptr] = s;
         incr(pool_ptr);
       }
 #endif
@@ -299,14 +169,15 @@ void print_ (integer s)
           
           nl = new_line_char;
           new_line_char = -1;
-/* translate ansi to dos 850 */
+          
+          /* translate ansi to dos 850 */
           if (!show_in_hex && s < 256 && s >= 32)
           {
             if (show_in_dos && s > 127)
             {
               if (wintodos[s - 128] > 0)
               {
-                print_char (wintodos[s - 128]);
+                print_char(wintodos[s - 128]);
               }
               else
               {
@@ -2521,10 +2392,10 @@ void show_node_list_(integer p)
                 else
                   print_string("< -");
 
-                print_glue(20000 * 65536L, glue_order(p), "");
+                print_glue(20000 * unity, glue_order(p), "");
               }
               else
-                print_glue(round(65536L * g), glue_order(p), "");
+                print_glue(round(unity * g), glue_order(p), "");
             }
 
             if (shift_amount(p) != 0)
index acc4212..c0f929c 100644 (file)
@@ -440,7 +440,7 @@ lab88:
   if (cur_val >= 16384)     /* 2^14 */
     arith_error = true;
   else
-    cur_val = cur_val * 65536L + f;
+    cur_val = cur_val * unity + f;
 lab30:;
   {
     get_x_token();
@@ -1830,8 +1830,7 @@ void open_log_file (void)
       (void) fputs(log_line, log_file);
     }
     
-    (void) fputs(tex_version, log_file); 
-    (void) fprintf(log_file, " (%s %s)", application, yandyversion);
+    fprintf(log_file, "%s (%s %s)", tex_version, application, yandyversion);
 
     if (format_ident > 0)
       slow_print(format_ident);
@@ -2156,7 +2155,7 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire
     tfm_temp = getc(tfm_file);
     z =(z * 16) + (tfm_temp / 16);
 
-    if (z < 65536L)
+    if (z < unity)
       goto lab11; 
 
     while (lh > 2)
index 2b9425f..19b6e8f 100644 (file)
@@ -121,24 +121,23 @@ void dvi_swap (void)
 
   dvi_gone = dvi_gone + half_buf;
 }
-/* attempt at speeding up bkph - is compiler smart ? */
 /* sec 0600 */
 void dvi_four_(integer x)
 { 
   if (x >= 0)
-    dvi_out(x / 0100000000); // dvi_out((x >> 24));
+    dvi_out(x / 0100000000);
   else
   {
     x = x + 010000000000;
     x = x + 010000000000;
-    dvi_out((x / 0100000000) + 128); // dvi_out((x >> 24) + 128);
+    dvi_out((x / 0100000000) + 128);
   }
 
-  x = x % 0100000000; // x = x & 16777215L;
-  dvi_out(x / 0200000); // dvi_out((x >> 16));
-  x = x % 0200000; // x = x & 65535L;
-  dvi_out(x / 0400); // dvi_out((x >> 8));
-  dvi_out(x % 0400); // dvi_out(x & 255);
+  x = x % 0100000000;
+  dvi_out(x / 0200000);
+  x = x % 0200000;
+  dvi_out(x / 0400);
+  dvi_out(x % 0400);
 }
 /* sec 0601 */
 void dvi_pop_(integer l)
@@ -146,7 +145,7 @@ void dvi_pop_(integer l)
   if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0))
     decr(dvi_ptr);
   else
-    dvi_out(142);
+    dvi_out(pop);
 }
 /* sec 0602 */
 void dvi_font_def_(internal_font_number f)
@@ -599,7 +598,7 @@ void hlist_out (void)
   incr(cur_s);
 
   if (cur_s > 0)
-    dvi_out(141);
+    dvi_out(push);
 
   if (cur_s > max_push)
     max_push = cur_s;
@@ -903,7 +902,7 @@ void vlist_out (void)
   incr(cur_s);
 
   if (cur_s > 0)
-    dvi_out(141);
+    dvi_out(push);
 
   if (cur_s > max_push)
     max_push = cur_s;
@@ -1189,21 +1188,7 @@ void dvi_ship_out_(halfword p)
   dvi_v = 0;
   cur_h = h_offset;
   dvi_f = null_font;
-
-  if (output_file_name == 0)
-  {
-    if (job_name == 0)
-      open_log_file();
-
-    pack_job_name(".dvi");
-
-    while (!b_open_out(dvi_file))
-    {
-      prompt_file_name("file name for output", ".dvi");
-    }
-
-    output_file_name = b_make_name_string(dvi_file);
-  }
+  ensure_dvi_open();
 
   if (total_pages == 0)
   {
index eb8f2f7..466eca5 100644 (file)
@@ -768,7 +768,7 @@ void new_font_(small_number a)
       help2("I can only handle fonts at positive sizes that are",
         "less than 2048pt, so I've changed what you said to 10pt.");
       error();
-      s = 10 * 65536L;
+      s = 10 * unity;
     }
   }
   else if (scan_keyword("scaled"))
index 3b05ddc..2515c02 100644 (file)
@@ -102,12 +102,7 @@ lab40:
 
   return true;
 }
-/**************************************************************************/
-void print_char_string (unsigned char *s)
-{
-  while (*s > 0)
-    print_char(*s++);
-}
+
 void show_font_info (void); // now in local.c
 extern int closed_already;  // make sure we don't try this more than once
 /* sec 1333 */
@@ -137,34 +132,34 @@ void close_files_and_terminate (void)
       fprintf(log_file, "%c\n", ' ');
       fprintf(log_file, "\n");
       fprintf(log_file, "%s%s\n", "Here is how much of TeX's memory", " you used:");
-      fprintf(log_file, "%c%ld%s", ' ', str_ptr - init_str_ptr, " string");
+      fprintf(log_file, "%c%ld%s", ' ', (int)(str_ptr - init_str_ptr), " string");
 
       if (str_ptr != init_str_ptr + 1)
         putc('s',  log_file);
 
 #ifdef ALLOCATESTRING
       if (show_current)
-        fprintf(log_file, "%s%ld\n", " out of ", current_max_strings - init_str_ptr);
+        fprintf(log_file, "%s%ld\n", " out of ", (int)(current_max_strings - init_str_ptr));
       else
 #endif
-        fprintf(log_file, "%s%ld\n", " out of ", max_strings - init_str_ptr);
+        fprintf(log_file, "%s%ld\n", " out of ", (int)(max_strings - init_str_ptr));
 
 #ifdef ALLOCATESTRING
       if (show_current)
-        fprintf(log_file, "%c%ld%s%ld\n", ' ', pool_ptr - init_pool_ptr, " string characters out of ", current_pool_size - init_pool_ptr);
+        fprintf(log_file, "%c%ld%s%ld\n", ' ', (int)(pool_ptr - init_pool_ptr), " string characters out of ", current_pool_size - init_pool_ptr);
       else
 #endif
-        fprintf(log_file, "%c%ld%s%ld\n", ' ', pool_ptr - init_pool_ptr, " string characters out of ", pool_size - init_pool_ptr);
+        fprintf(log_file, "%c%ld%s%ld\n", ' ', (int)(pool_ptr - init_pool_ptr), " string characters out of ", pool_size - init_pool_ptr);
 
 #ifdef ALLOCATEMAIN
       if (show_current)
-        fprintf(log_file, "%c%ld%s%ld\n", ' ', (long)lo_mem_max - mem_min + mem_end - hi_mem_min + 2, " words of memory out of ", current_mem_size);
+        fprintf(log_file, "%c%ld%s%ld\n", ' ', (int)(lo_mem_max - mem_min + mem_end - hi_mem_min + 2), " words of memory out of ", current_mem_size);
       else
 #endif
-        fprintf(log_file, "%c%ld%s%ld\n", ' ', (long)lo_mem_max - mem_min + mem_end - hi_mem_min + 2, " words of memory out of ", mem_end + 1 - mem_min);
+        fprintf(log_file, "%c%ld%s%ld\n", ' ', (int)(lo_mem_max - mem_min + mem_end - hi_mem_min + 2), " words of memory out of ", mem_end + 1 - mem_min);
 
-      fprintf(log_file, "%c%ld%s%ld\n", ' ', cs_count, " multiletter control sequences out of ", (hash_size + hash_extra));
-      fprintf(log_file, "%c%ld%s%ld%s", ' ', (long)fmem_ptr, " words of font info for ", (long)font_ptr - font_base, " font");
+      fprintf(log_file, "%c%ld%s%ld\n", ' ', (int)(cs_count), " multiletter control sequences out of ", (hash_size + hash_extra));
+      fprintf(log_file, "%c%ld%s%ld%s", ' ', (int)(fmem_ptr), " words of font info for ", (int)(font_ptr - font_base), " font");
 
       if (font_ptr != 1)
         putc('s',  log_file);
@@ -183,11 +178,11 @@ void close_files_and_terminate (void)
 
       fprintf(log_file, "%s%ld\n",  " out of ", hyphen_prime);
       fprintf(log_file, " ");
-      fprintf(log_file, "%ld%s", max_in_stack, "i,");
-      fprintf(log_file, "%ld%s", max_nest_stack, "n,");
-      fprintf(log_file, "%ld%s", max_param_stack, "p,");
-      fprintf(log_file, "%ld%s", max_buf_stack + 1, "b,");
-      fprintf(log_file, "%ld%s", max_save_stack + 6, "s");
+      fprintf(log_file, "%ld%s", (int)max_in_stack, "i,");
+      fprintf(log_file, "%ld%s", (int)max_nest_stack, "n,");
+      fprintf(log_file, "%ld%s", (int)max_param_stack, "p,");
+      fprintf(log_file, "%ld%s", (int)max_buf_stack + 1, "b,");
+      fprintf(log_file, "%ld%s", (int)max_save_stack + 6, "s");
       fprintf(log_file, " stack positions out of ");
 
 #ifdef ALLOCATESAVESTACK
@@ -231,7 +226,7 @@ void close_files_and_terminate (void)
         fprintf(log_file, " (i = in_stack, n = nest_stack, p = param_stack, b = buf_stack, s = save_stack)\n");
 
       if (!knuth_flag)
-        fprintf(log_file, " %d inputs open max out of %d\n", high_in_open, max_in_open);
+        fprintf(log_file, " %d inputs open max out of %ld\n", high_in_open, max_in_open);
 
       if (show_line_break_stats && first_pass_count > 0)
       {
@@ -292,7 +287,7 @@ void close_files_and_terminate (void)
         while (cur_s > -1)
         {
           if (cur_s > 0) 
-            dvi_out(142);
+            dvi_out(pop);
           else
           {
             dvi_out(eop);
@@ -369,7 +364,7 @@ void close_files_and_terminate (void)
           print_nl("Output written on ");
 
           if (full_file_name_flag && dvi_file_name != NULL)
-            print_char_string((unsigned char *) dvi_file_name);
+            print_string(dvi_file_name);
           else
             slow_print(output_file_name);
 
@@ -400,7 +395,7 @@ void close_files_and_terminate (void)
       print_nl("Transcript written on ");
 
       if (full_file_name_flag && log_file_name != NULL)
-        print_char_string((unsigned char *) log_file_name);
+        print_string(log_file_name);
       else
         slow_print(texmf_log_name);
 
index 8273804..5c193ee 100644 (file)
@@ -498,9 +498,7 @@ EXTERN integer hyphen_char[font_max + 1];
 EXTERN integer skew_char[font_max + 1];
 EXTERN font_index bchar_label[font_max + 1];
 EXTERN short font_bchar[font_max + 1];
-/* don't change above to int or format file will be incompatible */
 EXTERN short font_false_bchar[font_max + 1];
-/* don't change above to int or format file will be incompatible */
 EXTERN integer char_base[font_max + 1];
 EXTERN integer width_base[font_max + 1];
 EXTERN integer height_base[font_max + 1];
@@ -828,8 +826,6 @@ EXTERN FILE * errout;
 EXTERN int font_dimen_zero;
 EXTERN int ignore_frozen;
 EXTERN boolean suppress_f_ligs;
-EXTERN int abort_flag;
-EXTERN int err_level;
 EXTERN int jump_used;
 EXTERN jmp_buf jumpbuffer;
 extern int current_pool_size;
@@ -885,24 +881,27 @@ char *unixify (char *);
 #include "coerce.h"
 
 /* sec 79 */
-extern INLINE void prompt_input(const char *s);
-extern INLINE void synch_h(void);
-extern INLINE void synch_v(void);
-extern INLINE void set_cur_lang(void);
+extern inline void print_err (const char * s);
+extern inline void ensure_dvi_open(void);
+extern inline void write_dvi(size_t a, size_t b);
+extern inline void prompt_input(const char *s);
+extern inline void synch_h(void);
+extern inline void synch_v(void);
+extern inline void set_cur_lang(void);
 extern char * md5_file(FILE * in_file);
-extern INLINE void str_room_ (int val);
+extern inline void str_room_ (int val);
 #define str_room(a) str_room_((int) a)
-extern INLINE void tail_append_ (pointer val);
+extern inline void tail_append_ (pointer val);
 #define tail_append(a) tail_append_((pointer) a)
-extern INLINE void tex_help (unsigned int n, ...);
-extern INLINE void append_char(ASCII_code c);
-extern INLINE void append_lc_hex(ASCII_code c);
-extern INLINE void succumb(void);
-extern INLINE void dvi_out_ (ASCII_code op);
+extern inline void tex_help (unsigned int n, ...);
+extern inline void append_char(ASCII_code c);
+extern inline void append_lc_hex(ASCII_code c);
+extern inline void succumb(void);
+extern inline void dvi_out_ (ASCII_code op);
 #define dvi_out(op) dvi_out_((ASCII_code) (op))
-extern INLINE void free_avail_(halfword p);
+extern inline void free_avail_(halfword p);
 #define free_avail(p) free_avail_((halfword) (p))
-extern INLINE void flush_string (void);
+extern inline void flush_string (void);
 extern str_number load_pool_strings (integer spare_size);
 extern str_number make_string_pool (const char *s);
 #define help0()     tex_help(0)
index e8c5e1d..b6648ad 100644 (file)
@@ -31,8 +31,6 @@ enum
   out_dpx_flag = (1 << 3),
 };
 
-#define INLINE inline
-
 /* Read a line of input as quickly as possible.  */
 extern boolean input_line (FILE *);
 #define input_ln(stream, flag) input_line(stream)
@@ -56,11 +54,11 @@ extern void fix_date_and_time(void);
   #define dumpcore abort
 #endif
 
-#define write_dvi(a, b)                                           \
-  if ((size_t) fwrite ((char *) &dvi_buf[a], sizeof (dvi_buf[a]), \
-         (size_t) ((size_t)(b) - (size_t)(a) + 1), dvi_file)      \
-         != (size_t) ((size_t)(b) - (size_t)(a) + 1))             \
-     FATAL_PERROR ("\n! dvi file")
+//#define write_dvi(a, b)                                           \
+//  if ((size_t) fwrite ((char *) &dvi_buf[a], sizeof (dvi_buf[a]), \
+//         (size_t) ((size_t)(b) - (size_t)(a) + 1), dvi_file)      \
+//         != (size_t) ((size_t)(b) - (size_t)(a) + 1))             \
+//     FATAL_PERROR ("\n! dvi file")
 
 
 #ifdef COMPACTFORMAT
diff --git a/src/texsourc/yandy_inlines.c b/src/texsourc/yandy_inlines.c
new file mode 100644 (file)
index 0000000..3ce8f47
--- /dev/null
@@ -0,0 +1,167 @@
+/* Copyright 2014 Clerk Ma
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301 USA.  */
+
+#define EXTERN extern
+
+#include "texd.h"
+
+inline void ensure_dvi_open(void)
+{
+  if (output_file_name == 0)
+  {
+    if (job_name == 0)
+      open_log_file();
+
+    pack_job_name(".dvi");
+
+    while (!b_open_out(dvi_file))
+    {
+      prompt_file_name("file name for output", ".dvi");
+    }
+
+    output_file_name = b_make_name_string(dvi_file);
+  }
+}
+
+inline void write_dvi(size_t a, size_t b)
+{
+  if (fwrite((char *) &dvi_buf[a], sizeof(dvi_buf[a]),
+    ((b) - (a) + 1), dvi_file) != ((b) - (a) + 1))
+    FATAL_PERROR ("\n! dvi file");
+}
+inline void prompt_input(const char * s)
+{
+  print_string(s);
+  term_input();
+}
+inline void synch_h(void)
+{
+  if (cur_h != dvi_h)
+  {
+    movement(cur_h - dvi_h, right1);
+    dvi_h = cur_h;
+  }
+}
+inline void synch_v(void)
+{
+  if (cur_v != dvi_v)
+  {
+    movement(cur_v - dvi_v, down1);
+    dvi_v = cur_v;
+  }
+}
+inline void set_cur_lang(void)
+{
+  if (language <= 0)
+    cur_lang = 0;
+  else if (language > 255)
+    cur_lang = 0;
+  else
+    cur_lang = language;
+}
+inline void free_avail_(halfword p)
+{
+  link(p) = avail;
+  avail = p;
+#ifdef STAT
+  decr(dyn_used);
+#endif
+}
+inline void dvi_out_(ASCII_code op)
+{
+  dvi_buf[dvi_ptr] = op;
+  incr(dvi_ptr);
+
+  if (dvi_ptr == dvi_limit)
+    dvi_swap();
+}
+inline void succumb (void)
+{
+  if (interaction == error_stop_mode)
+    interaction = scroll_mode;
+
+  if (log_opened)
+  {
+    error();
+  }
+
+#ifdef DEBUG
+  if (interaction > 0)
+    debug_help();
+#endif
+
+  history = error_stop_mode;
+  jump_out();
+}
+inline void flush_string (void)
+{
+  decr(str_ptr);
+  pool_ptr = str_start[str_ptr];
+}
+inline void append_char (ASCII_code c)
+{
+  str_pool[pool_ptr] = c;
+  incr(pool_ptr);
+}
+inline void append_lc_hex (ASCII_code c)
+{
+  if (c < 10)
+    append_char(c + '0');
+  else
+    append_char(c - 10 + 'a');
+}
+inline void print_err (const char * s)
+{
+  if (interaction == error_stop_mode);
+    print_nl("! ");
+
+  print_string(s);
+}
+inline void tex_help (unsigned int n, ...)
+{
+  int i;
+  va_list help_arg;
+
+  if (n > 6)
+    n = 6;
+
+  help_ptr = n;
+  va_start(help_arg, n);
+
+  for (i = n - 1; i > -1; --i)
+    help_line[i] = va_arg(help_arg, char *);
+
+  va_end(help_arg);
+}
+inline void str_room_ (int val)
+{
+#ifdef ALLOCATESTRING
+  if (pool_ptr + val > current_pool_size)
+    str_pool = realloc_str_pool(increment_pool_size);
+
+  if (pool_ptr + val > current_pool_size)
+    overflow("pool size", current_pool_size - init_pool_ptr);
+#else
+  if (pool_ptr + val > pool_size)
+    overflow("pool size", pool_size - init_pool_ptr);
+#endif
+}
+inline void tail_append_ (pointer val)
+{
+  link(tail) = val;
+  tail = link(tail);
+}
\ No newline at end of file
index 04d61b1..6c46e8e 100644 (file)
@@ -61,6 +61,9 @@ do                            \
     pause_for_instructions(); \
 }                             \
 while (0)
+/* sec 0101 */
+#define unity 0200000
+#define two   0400000
 /* sec 0105 */
 #define nx_plux_y(...)   mult_and_add(..., 07777777777L)
 #define mult_integers(a) mult_and_add(a,0,017777777777L)
@@ -1013,8 +1016,8 @@ while (0)
 #define nop       138 // NULL
 #define bop       139 // c0[4] c1[4] ... c9[4] p[4]
 #define eop       140 // NULL
-//#define dvi_push 141
-//#define dvi_pop  142
+#define push      141
+#define pop       142
 #define right1    143 // b[1]
 #define right2    144 // b[2]
 #define right3    145 // b[3]