OSDN Git Service

code clean.
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Thu, 19 Jun 2014 21:10:46 +0000 (05:10 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Thu, 19 Jun 2014 21:10:46 +0000 (05:10 +0800)
src/texsourc/local.c
src/texsourc/tex0.c
src/texsourc/tex1.c
src/texsourc/tex2.c
src/texsourc/yandytex.c

index b1e2cbd..b63f575 100644 (file)
@@ -604,8 +604,7 @@ void memory_error (char *s, int n)
 
 void trace_memory (char *s, int n)
 {
-  sprintf(log_line, "Allocating %d bytes for %s\n", n, s);
-  show_line(log_line, 0);
+  printf("Allocating %d bytes for %s\n", n, s);
 }
 
 void update_statistics (int address, int size, int old_size)
@@ -618,9 +617,7 @@ void update_statistics (int address, int size, int old_size)
 
 void probe_memory (void)
 {
-  char *s;
-
-  s = (char *) malloc(4); /* get current top address */
+  char *s = (char *) malloc(4); /* get current top address */
   free(s);
   update_statistics ((int) s, 0, 0); /* show where we are */
 }
@@ -640,14 +637,7 @@ size_t roundup (size_t n)
 }
 
 #ifdef ALLOCATETRIES
-/* using allocating hyphenation trie slows things down maybe 1%              */
-/* but saves typically (270k - 55k) = 215k of memory                         */
-/* NOTE: it's safe to allocate based on the trie_max read from fmt file      */
-/* since hyphenation trie cannot be extended (after iniTeX)                  */
-/* for iniTeX, however, we need to allocate the full trie_size ahead of time */
-/*                                                                           */
-/* NOTE: we don't ever reallocate these                                      */
-/* returns -1 if it fails                                                    */
+/* returns -1 if it fails */
 
 int allocate_tries (int trie_max)
 {
@@ -743,13 +733,15 @@ int realloc_hyphen (int hyphen_prime)
 #ifdef USEMEMSET
   memset(hyph_word, 0, (hyphen_prime + 1) * sizeof (hyph_word[0]));
 #else
-  for (k = 0; k <= hyphen_prime; k++) hyph_word[k]= 0;
+  for (k = 0; k <= hyphen_prime; k++)
+    hyph_word[k]= 0;
 #endif
 
 #ifdef USEMEMSET
   memset(hyph_list, 0, (hyphen_prime + 1) * sizeof (hyph_list[0]));
 #else
-  for (k = 0; k <= hyphen_prime; k++) hyph_list[k]= 0;
+  for (k = 0; k <= hyphen_prime; k++)
+    hyph_list[k]= 0;
 #endif
 
   hyph_count = 0;
@@ -791,7 +783,7 @@ memory_word *allocate_main_memory (int size)
   if (main_memory != NULL)
   {
     if (trace_flag)
-      puts("Reallocating initial memory allocation\n");
+      puts("Reallocating initial memory allocation");
   }
 
   mem_top = mem_bot + size;
@@ -864,8 +856,8 @@ memory_word * realloc_main (int lo_size, int hi_size)
   {
     puts("ERROR: Cannot extent main memory in iniTeX\n");
 
-    if (! knuth_flag)
-      puts("Please use `-m=...' on command line\n");
+    if (!knuth_flag)
+      puts("Please use `-m=...' on command line");
 
     return NULL;
   }
@@ -920,8 +912,10 @@ memory_word * realloc_main (int lo_size, int hi_size)
 
     if (new_size >= max_mem_size) /* bump against limit - ha ha ha */
     {
-      while (new_size >= max_mem_size) {
-        lo_size = lo_size / 2; hi_size = hi_size / 2;
+      while (new_size >= max_mem_size)
+      {
+        lo_size = lo_size / 2;
+        hi_size = hi_size / 2;
         new_size = current_mem_size + lo_size + hi_size;
       }
     }
@@ -963,10 +957,12 @@ memory_word * realloc_main (int lo_size, int hi_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));
 /*  could reduce words moved by (mem_max - mem_end) */
   }
+
   main_memory = new_memory;       /* remember for free later */
 
   if (lo_size > 0)
@@ -981,7 +977,7 @@ memory_word * realloc_main (int lo_size, int hi_size)
 
   if (current_mem_size != mem_max - mem_start)
   {
-    puts("ERROR: Impossible Memory Error\n");
+    puts("ERROR: Impossible Memory Error");
   }
 
   if (mem_start != 0)
@@ -997,8 +993,6 @@ memory_word * realloc_main (int lo_size, int hi_size)
 #endif
 
 #ifdef ALLOCATEFONT
-/* font_mem_size = 10000L ==> font_info array 100k * 8 = 800 kilobytes */
-
 int current_font_mem_size = 0;
 
 /* fmemoryword can be either halfword or memory_word */
index 2e17801..90ad12f 100644 (file)
@@ -331,7 +331,8 @@ void print_cs_ (integer p)
       }
     else if (p < active_base)
       print_esc("IMPOSSIBLE.");
-    else print(p - active_base);
+    else
+      print(p - active_base);
   else if (p >= undefined_control_sequence)
     print_esc("IMPOSSIBLE.");
   else if ((text(p) >= str_ptr))
index f06baa3..4537472 100644 (file)
@@ -201,6 +201,7 @@ void flush_node_list_(pointer p)
               else
                 free_node(p, noad_size);
             }
+
             goto done;
           }
           break;
@@ -375,7 +376,7 @@ pointer copy_node_list_(pointer p)
     while (words > 0)
     {
       decr(words);
-      mem[r + words] = mem[p + words]; /* r may be used without having ... */
+      mem[r + words] = mem[p + words];
     }
 
     link(q) = r;
@@ -410,9 +411,7 @@ void print_mode_(integer m)
   else
   {
     if (m == 0)
-    {
       print_string("no");
-    }
     else
     {
       switch ((- (integer) m) / (max_command + 1))
@@ -508,9 +507,7 @@ void show_activities (void)
     }
 
     if (nest[p].ml_field < 0)
-    {
       print_string(" (\\output routine)");
-    }
 
     if (p == 0)
     {
@@ -519,9 +516,7 @@ void show_activities (void)
         print_nl("### current page:");
         
         if (output_active)
-        {
           print_string(" (held over for next output)");
-        }
 
         show_box(link(page_head));
 
@@ -2298,7 +2293,7 @@ halfword id_lookup_(integer j, integer l)
 #endif
       }
 
-      goto found; 
+      goto found;
     }
 
     p = next(p);
@@ -2385,7 +2380,7 @@ void eq_define_(halfword p, quarterword t, halfword e)
   else if (cur_level > level_one)
     eq_save(p, eq_level(p));
 
-  eq_level(p) = (quarterword) cur_level; /* because cur_level padded out */
+  eq_level(p) = (quarterword) cur_level;
   eq_type(p) = t;
   equiv(p) = e;
 }
@@ -2395,7 +2390,7 @@ void eq_word_define_(halfword p, integer w)
   if (xeq_level[p] != cur_level)
   {
     eq_save(p, xeq_level[p]);
-    xeq_level[p] = (quarterword) cur_level; /* because cur_level padded out */
+    xeq_level[p] = (quarterword) cur_level;
   }
 
   eqtb[p].cint = w;
index 4868490..b89eb10 100644 (file)
@@ -472,6 +472,7 @@ void end_token_list (void)
     else
     {
       delete_token_ref(start);
+
       if (index == macro)
         while (param_ptr > limit)
         {
@@ -588,8 +589,8 @@ void end_file_reading (void)
 /* sec 0330 */
 void clear_for_error_prompt (void) 
 {
-  while ((state != 0) && (cur_input.name_field == 0) && (input_ptr > 0) &&
-      (loc > limit))
+  while ((state != 0) && (cur_input.name_field == 0) &&
+    (input_ptr > 0) && (loc > limit))
     end_file_reading();
 
   print_ln();
@@ -956,7 +957,7 @@ done1:
           store_new_token(cur_tok);
         }
 
-        incr(m);          /* m may be used without having been ... */
+        incr(m);
 
         if (info(r) > end_match_token)
           goto continu;
@@ -968,7 +969,7 @@ found:
         {
           if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head))
           {
-            link(rbrace_ptr) = 0; /* rbrace_ptr may be used without ... */
+            link(rbrace_ptr) = 0;
             free_avail(p);
             p = link(temp_head);
             pstack[n] = link(p);
@@ -982,7 +983,7 @@ found:
           if (tracing_macros > 0)
           {
             begin_diagnostic();
-            //print_nl(match_chr); /* matchchar may be used without ... */
+            //print_nl(match_chr);
             print_nl(""); print(match_chr);
             print_int(n);
             print_string("<-");
@@ -1012,7 +1013,7 @@ found:
       if (max_param_stack > current_param_size)
         param_stack = realloc_param_stack(increment_param_size);
 
-      if (max_param_stack > current_param_size) /* check again after allocation */
+      if (max_param_stack > current_param_size)
       {
         overflow("parameter stack size", current_param_size);
         return;
@@ -1020,7 +1021,7 @@ found:
 #else
       if (max_param_stack > param_size)
       {
-        overflow("parameter stack size", param_size); /* parameter stack - not dynamic */
+        overflow("parameter stack size", param_size);
         return;
       }
 #endif
@@ -1437,7 +1438,7 @@ void scan_twenty_seven_bit_int (void)
 {
   scan_int();
 
-  if ((cur_val < 0) || (cur_val > 134217727L)) /* 2^27 - 1 */
+  if ((cur_val < 0) || (cur_val > 134217727L))
   {
     print_err("Bad delimiter code");
     help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
index e49e58b..f4913f7 100644 (file)
@@ -29,9 +29,6 @@ static char * program_name = NULL;
 int    gargc;   /* number of args - set to zero after initialization */
 char **gargv;
 
-/* The entry point: set up for reading the command line, which will
-   happen in `t_open_in', then call the main body.  */
-
 int jump_used = 0;
 
 jmp_buf jumpbuffer;
@@ -220,76 +217,61 @@ void show_bad_line (FILE *output, int first, int last)
   {
     ch = buffer[i];
 
-    if ((show_in_hex && ch > 127))
+    if (show_in_hex && (ch > 127))
     {
       c = ch >> 4;
-      d = ch & 15; 
+      d = ch & 15;
+
       if (c > 9)
         c = c + 'a' - 10;
       else
         c = c + '0';
+
       if (d > 9)
         d = d + 'a' - 10;
       else
         d = d + '0';
-/* putc('^', output); putc('^', output); */
+
       *s++ = '^';
       *s++ = '^';
-/* putc (c, output); putc (d, output); */
+
       *s++ = (char) c;
       *s++ = (char) d;
     }
+    else if (ch < 32)
+    {
+      *s++ = '^';
+      *s++ = '^';
+      *s++ = (char) (ch + 64);
+    }
+    else if (ch == 127)
+    {
+      *s++ = '^';
+      *s++ = '^';
+      *s++ = (char) (ch - 64);
+    }
     else
-      if (ch < 32)
-      {
-/* putc('^', output); putc('^', output); */
-        *s++ = '^';
-        *s++ = '^';
-/* putc (ch + 64, output); */
-        *s++ = (char) (ch + 64);
-      }
-      else
-        if (ch == 127)
-        {
-/* putc('^', output); putc('^', output); */
-          *s++ = '^';
-          *s++ = '^';
-/* putc (ch - 64, output); */
-          *s++ = (char) (ch - 64);
-        }
-        else
-        {
-/* putc(ch, output); */
-          *s++ = (char) ch;
-        }
+    {
+      *s++ = (char) ch;
+    }
   }
-//  putc(' ', output);    /*  putc('\n', output); */
+
   *s++ = ' ';
   *s++ = '\0';
 
   fputs(log_line, output);   // log_file
 }
 
-// split off for convenience and use in ConsoleInput
 boolean input_line_finish (void)
 {
   int i = '\0';
   int ch, flag;
-  
-/*  if last line in file does not end with \n - never happens ? */
-/*  if (i == EOF && buffer[last] != '\n') buffer[last++] = '\n'; */
 
-  buffer[last] = ' ';           /* space terminate */
+  buffer[last] = ' ';
 
   if (last >= max_buf_stack)
-    max_buf_stack = last; /* remember longest line */
+    max_buf_stack = last;
 
-/* Trim trailing whitespace.  */ 
-/* #define isblank(c) ((c) == ' ' || (c) == '\t') */
-/* What about \n ?  Can't get in here ?- bkph */
-/* What about control-Z that gets read in binary mode ? - bkph */
-// #ifdef MYDEBUG
-/*  while (last > first && buffer[last - 1] <= ' ')  --last; */
   while (last > first)
   {
     i = buffer[last - 1];
@@ -300,16 +282,14 @@ boolean input_line_finish (void)
       break;
   }
 
-/* following added to check source file integrity ASCII 32 - 127 */
-/* allow space, tab, new-page - also allow return, newline ? */
   if (restrict_to_ascii)
   {
     flag = 0;
+
     for (i = first; i <= last; i++)
     {
       ch = buffer[i];
-/*      if (ch > 127 || (ch < ' ' && ch != '\t' && ch != '\f')) */
-/*      1 -- 8, 11, 14 -- 31 are not good ASCII characters */
+
       if (ch > 126 ||  (ch < ' ' && ch != '\t' && ch != '\f' && ch != '\r' && ch != '\n'))
       {
         sprintf(log_line, "\n! non ASCII char (%d) in line: ", ch);
@@ -318,26 +298,26 @@ boolean input_line_finish (void)
         if (log_opened)
           fprintf(log_file, "\n! non ASCII char (%d) in line: ", ch);
 
-/*        buffer[i]= 127; */ /* not defined - invalid char */
         flag = 1;
         break;
       }
     }
+
     if (flag)
     {
       show_bad_line(errout, first, last);
+
       if (log_opened)
         show_bad_line(log_file, first, last);
     }
   }
-/* Don't bother using xord if we don't need to. */ /* for input line */
-/* #ifdef NONASCII */ /* has been turned into command line flag - bkph */
+
   if (non_ascii)
   {
     for (i = first; i <= last; i++)
       buffer[i] = xord[buffer[i]];
   }
-/* #endif */
+
   return true;
 }