OSDN Git Service

version 2.3.0-final.
[putex/putex.git] / src / texsourc / yandytex.c
index 9ad2641..9a0400a 100644 (file)
-/* Copyright 1992 Karl Berry
-   Copyright 2007 TeX Users Group
-   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
-
-#include "texd.h"
-
-#define dump_default_var    TEX_format_default
-#define dump_default        " plain.fmt"
-#define dump_ext_length     4
-#define dump_default_length format_default_length
-#define main_program        texbody
-#define edit_value          tex_edit_value
-
-extern char * replacement[];
-
-/* The main program, etc.  */
-
-/* What we were invoked as and with.  */
-static char *program_name = NULL;
-int    gargc;   /* number of args - set to zero after initialization */
-char **gargv;   /* char *gargv[] -- bkph ? */
-
-/* The entry point: set up for reading the command line, which will
-   happen in `t_open_in', then call the main body.  */
-
-int main_init(int, char **);     /* in local.c */
-
-int jump_used = 0;
-
-jmp_buf jumpbuffer;   // for non-local jumps
-
-int main (int ac, char *av[])
-{
-  int flag = 0, ret = 0;
-
-#ifndef INI
-  char custom_default[PATH_MAX];
-#endif
-
-#ifdef WIN32
-  _setmaxstdio(2048);
-#endif
-
-  gargc = ac;
-  gargv = av;
-
-  if (main_init(gargc, gargv))
-    return -1; // failure
-
-  dump_default_var = dump_default;
-  dump_default_length = strlen(dump_default_var + 1);
-
-  jump_used = 0;
-
-  ret = setjmp(jumpbuffer);
-
-  if (ret == 0)
-  {
-    flag = main_program();
-
-    if (trace_flag)
-    {
-      sprintf(log_line, "EXITING at %s %d %d %d\n", "MAIN", flag, ret, jump_used);
-      show_line(log_line, 0);
-    }
-  }
-  else
-  {
-    if (trace_flag)
-    {
-      sprintf(log_line, "EXITING at %s %d %d %d\n", "JUMPOUT", flag, ret, jump_used);
-      show_line(log_line, 0);
-    }
-  }
-
-  if (endit(flag) != 0)
-    flag = 1; /* do final clean up in local.c */
-
-  if (flag == 0)
-    return 0;
-
-#ifdef _WINDOWS
-  return flag;
-#else
-  else exit (flag);   // avoid circularity!
-#endif
-}
-
-/* texk/web2c/lib/texmfmp.c */
-void t_open_in (void)
-{
-  int i;
-
-  buffer[first] = 0;  /* In case there are no arguments.  */
-
-#ifdef MSDOS
-  if (gargc > optind && optind > 0)
-  {
-    for (i = optind; i < gargc; i++)
-#else
-  if (gargc > 1)
-  {
-    for (i = 1; i < gargc; i++)
-#endif
-    {
-      if (allow_quoted_names && strchr(gargv[i], ' ') != NULL)
-      {
-        (void) strcat ((char *) &buffer[first], "\"");
-        (void) strcat ((char *) &buffer[first], gargv[i]);
-        (void) strcat ((char *) &buffer[first], "\"");
-      }
-      else
-        (void) strcat ((char *) &buffer[first], gargv[i]);
-
-      (void) strcat ((char *) &buffer[first], " ");
-    }
-    
-    gargc = 0;
-  }
-
-  /* Find the end of the buffer.  */
-  for (last = first; buffer[last]; ++last)
-    ;
-
-  for (--last; last >= first && ISBLANK (buffer[last]) && buffer[last] != '\r'; --last)
-    ;
-
-  last++;
-
-/* One more time, this time converting to TeX's internal character
-   representation.  */ /* for command line input in this case */
-  if (non_ascii)
-  {
-    for (i = first; i < last; i++)
-      buffer[i] = xord[buffer[i]];
-  }
-}
-
-/* All our interrupt handler has to do is set TeX's or Metafont's global
-   variable `interrupt'; then they will do everything needed.  */
-
-static void catch_interrupt (int err)
-{
-  (void) signal (SIGINT, SIG_IGN);
-
-  if (interrupt++ >= 3)
-    exit(1);
-
-  (void) signal (SIGINT, catch_interrupt);
-}
-
-/* Besides getting the date and time here, we also set up the interrupt
-   handler, for no particularly good reason.  It's just that since the
-   `fix_date_and_time' routine is called early on (section 1337 in TeX,
-   ``Get the first line of input and prepare to start''), this is as
-   good a place as any.  */
-
-void get_date_and_time (integer *sys_minutes,
-                        integer *sys_day,
-                        integer *sys_month,
-                        integer *sys_year)
-{
-  time_t clock;
-  struct tm *tmptr;
-
-  (void) time (&clock);  /* - seconds since 1970 */ 
-
-  if (trace_flag)
-  {
-    sprintf(log_line, "The time is %u\n", clock);
-    show_line(log_line, 0);   
-  }
-
-  if (clock < 0)
-  {
-    show_line("Time not available!\n", 1);
-  }
-
-  tmptr = localtime (&clock);
-
-  if (tmptr == NULL)
-  {
-    sprintf(log_line, "Cannot convert time (%0ld)!\n", clock);
-    show_line(log_line, 1);
-    *sys_year    = 2038;
-    *sys_month   = 1;
-    *sys_day     = 18;
-    *sys_minutes = 22 * 60 + 14;
-  }
-  else
-  {
-    *sys_minutes = tmptr->tm_hour * 60 + tmptr->tm_min;
-    *sys_day     = tmptr->tm_mday;
-    *sys_month   = tmptr->tm_mon + 1;
-    *sys_year    = tmptr->tm_year + 1900;
-
-    if (trace_flag)
-    {
-      sprintf(log_line, "%d-%d-%d %d:%d\n",
-        tmptr->tm_year + 1900,
-        tmptr->tm_mon + 1,
-        tmptr->tm_mday,
-        tmptr->tm_hour,
-        tmptr->tm_min);
-      show_line(log_line, 0);
-    }
-  }
-
-  {
-#ifdef MSDOS
-    if (!no_interrupts)
-    {
-      if (signal(SIGINT, catch_interrupt) == SIG_ERR)
-      {
-        show_line(" CTRL-C handler not installed\n", 0);
-#ifndef _WINDOWS
-        uexit(1);  /* do we care when run as DLL ? */
-#endif
-      }
-    }
-#else
-    void (*old_handler)();
-
-    if ((old_handler = signal (SIGINT, catch_interrupt)) != SIG_DFL)
-      (void) signal (SIGINT, old_handler);
-#endif
-  }
-}
-
-/* I/O for TeX and Metafont.  */ /* give file name ? */
-
-void complain_line (FILE *output)
-{
-  show_line("\n", 0);
-
-#ifdef ALLOCATEBUFFER
-  sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", current_buf_size);
-#else
-  sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", buf_size);
-#endif
-
-  if (output == stderr)
-    show_line(log_line, 1);
-  else
-    if (output == stdout)
-      show_line(log_line, 0);
-    else
-      fputs(log_line, output); // never
-
-  show_line("  (File may have a line termination problem.)", 0);
-}
-
-void show_bad_line (FILE *output, int first, int last)
-{
-  int i, c, d, ch;
-  char *s = log_line;
-
-  for (i = first; i <= last; i++)
-  {
-    ch = buffer[i];
-
-    if ((show_in_hex && ch > 127))
-    {
-      c = ch >> 4;
-      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)
-      {
-/* 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;
-        }
-  }
-//  putc(' ', output);    /*  putc('\n', output); */
-  *s++ = ' ';
-  *s++ = '\0';
-  if (output == stderr)
-    show_line(log_line, 1);
-  else
-    if (output == stdout)
-      show_line(log_line, 0);
-    else
-      fputs(log_line, output);   // log_file
-}
-
-// split off for convenience and use in ConsoleInput
-bool 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 */
-  if (last >= max_buf_stack)
-    max_buf_stack = last; /* remember longest line */
-
-/* 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];
-
-    if (i == ' ' || i == '\t')
-      --last;
-/*    else if (trimeof && i == 26) --last;   */   /* 93/Nov/24 */
-    else
-      break;
-  }
-/*  if (trimeof != 0 && i == EOF && last == first)  
-      return false; */              /* EOF and line empty */
-// #else
-//   while (last > first
-//         && isblank (buffer[last - 1]) && buffer[last - 1] != '\r')
-//    --last;
-// #endif
-
-/* 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);
-        show_line(log_line, 1);
-        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;
-}
-
-/* Read a line of input into buffer as efficiently as possible (ha ha)
-   while still looking like Pascal.
-   We set `last' to `first' and return `false' if we get to eof.
-   Otherwise, we return `true' and set last = first +
-   length(line except trailing whitespace).  */
-/* texmfmp.c */
-
-bool input_line (FILE *f)
-{
-//  int ch, flag;         /* for restrict_to_ascii case 94/Jan/21 */
-  char *u;            /* 1994/July/3 for key_replace */
-  int i = '\0';
-
-/*  and here is the long way of doing this */
-  last = first;
-/*  following is new version with tab expansion and key replacement */
-/*  may want to expand out separately for speed 1994/July/3 */
-/*  different versions depending on return_flag / tabexpand / key_replace */
-/*  while (last < buf_size && (i = getc (f)) != EOF)  */
-#ifdef ALLOCATEBUFFER
-  for ( ; ; ) 
-#else
-  while (last < buf_size) 
-#endif
-  {
-    i = getc(f);
-
-    if (i < ' ')
-    {
-      if (i == EOF || i == '\n' || (i == '\r' && return_flag))
-        break;
-      else if (i == '\t' && tab_step != 0)
-      {
-        buffer[last++] = (ASCII_code) ' ';
-
-#ifdef ALLOCATEBUFFER
-        if (last >= current_buf_size)
-        {
-          buffer = realloc_buffer(increment_buf_size);  
-
-          if (last >= current_buf_size)
-            break;
-        }
-#endif
-
-#ifdef ALLOCATEBUFFER
-        while ((last - first) % tab_step != 0) 
-#else
-        while (last < buf_size && (last - first) % tab_step != 0)
-#endif
-        {
-
-          buffer[last++] = (ASCII_code) ' ';
-
-#ifdef ALLOCATEBUFFER
-          if (last >= current_buf_size)
-          {
-            buffer = realloc_buffer(increment_buf_size);
-
-            if (last >= current_buf_size)
-              break;
-          }
-#endif
-        }
-
-        continue;
-      }
-    }
-
-    if (key_replace && (u = replacement[i]) != NULL)
-    {
-#ifdef ALLOCATEBUFFER
-      while (*u != '\0') 
-#else
-      while (last < buf_size && *u != '\0')  
-#endif
-      {
-        buffer[last++] = (ASCII_code) *u++;
-#ifdef ALLOCATEBUFFER
-        if (last >= current_buf_size)
-        {
-          buffer = realloc_buffer(increment_buf_size);
-
-          if (last >= current_buf_size)
-            break;
-        }
-#endif
-      }
-    }
-    else       /* normal case */
-    {
-      buffer[last++] = (ASCII_code) i;
-
-#ifdef ALLOCATEBUFFER
-      if (last >= current_buf_size)
-      {
-        buffer = realloc_buffer(increment_buf_size);
-
-        if (last >= current_buf_size)
-          break;
-      }
-#endif
-    }
-  }
-
-  if (return_flag)    /* let return terminate line as well as newline */
-  {
-    if (i == '\r')      /* see whether return followed by newline */
-    {
-      i = getc (f);       /* in which case throw away the newline */
-
-      if (i != '\n')
-      {
-        ungetc (i, f);
-        i = '\r';
-      }
-/*      else  buffer[last-1] = (ASCII_code) i; */
-    }
-  }
-
-  //  Turn Ctrl-Z at end of file into newline 2000 June 22
-  if (i == EOF && trimeof && buffer[last - 1] == 26)
-  {
-    last--;
-  }
-
-  if (i == EOF && last == first)
-    return false;
-
-/*  Didn't get the whole line because buffer was too small?  */
-/*  This shouldn't happen anymore 99/Jan/23 */
-  if (i != EOF && i != '\n' && i != '\r')
-  {
-    complain_line(errout);
-
-    if (log_opened)
-      complain_line(log_file);
-
-    /* This may no longer be needed ... now that we grow it */
-    if (truncate_long_lines)
-    {
-      while (i != EOF && i != '\n' && i != '\r')
-      {
-        i = getc (f);     // discard rest of line
-      }
-
-      last--;       /* just in case */
-    }
-    else
-      uexit(1);      /* line too long */
-  }
-
-  return input_line_finish();
-}
-
-\f
-/* This string specifies what the `e' option does in response to an
-   error message.  */ 
-
-static char *edit_value = "c:\\yandy\\WinEdt\\WinEdt.exe [Open('%s');SelLine(%d,7)]";
-
-/* This procedure is due to sjc@s1-c.  TeX (or Metafont) calls it when
-   the user types `e' in response to an error, invoking a text editor on
-   the erroneous source file.  FNSTART is how far into STRINGPOOL the
-   actual filename starts; FNLENGTH is how long the filename is.
-   
-   See ../site.h for how to set the default, and how to override it.  */
-
-/* called from close_files_and_terminate in  tex9.c */
-
-void call_edit (ASCII_code *stringpool, pool_pointer fnstart, integer fnlength, integer linenumber)
-{
-  char *command, *s, *t, *u;
-  char c;
-  int sdone, ddone, ldone;
-  int i, n;
-  unsigned int commandlen;
-  ASCII_code *texfilename;
-  ASCII_code *log_file_name;
-  pool_pointer lgstart;
-  integer lglength;
-
-  if (log_opened)
-  {
-    lgstart = str_start[texmf_log_name];
-    lglength = length(texmf_log_name);
-    log_file_name = stringpool + lgstart;
-  }
-  else
-  {
-    lglength = 0;
-    log_file_name = (unsigned char *) "";
-  }
-
-  sdone = ddone = ldone = 0;
-  texfilename = stringpool + fnstart;
-
-  for (i = 1; i <= in_open; i++)
-    (void) fclose (input_file[i]);
-
-  n = fcloseall();
-
-  if (n > 0 && verbose_flag)
-  {
-    sprintf(log_line, "Closed %d streams\n", n);
-    show_line(log_line, 0);
-  }
-
-  s = kpse_var_value(edit_value);  
-
-  if (s != NULL)
-    edit_value = s;
-
-  commandlen = strlen (edit_value) + fnlength + lglength + 10 + 1 + 2;
-  command = (string) xmalloc (commandlen); 
-
-  s = command;
-
-  u = edit_value;
-
-  while ((c = *u++) != 0)
-  {
-    if (c == '%')
-    {
-      switch (c = *u++)
-      {
-        case 'd':
-          if (ddone)
-          {
-#ifdef _WIN32
-            sprintf(log_line, "! bad command syntax (%c).\n", 'd');
-            show_line(log_line, 1);
-#else
-            sprintf(log_line, "! `%%d' cannot appear twice in editor command.\n");
-            show_line(log_line, 1);
-#endif
-            uexit(1); 
-          }
-
-          (void) sprintf (s, "%d", linenumber);
-
-          while (*s != '\0')
-            s++;
-
-          ddone = 1;
-          break;
-
-        case 's':
-          if (sdone)
-          {
-#ifdef __WIN32
-            sprintf(log_line, "! bad command syntax (%c).\n", 's'); 
-            show_line(log_line, 1);
-#else
-            sprintf(log_line, "! `%%s' cannot appear twice in editor command.\n");
-            show_line(log_line, 1);
-#endif
-            uexit(1); 
-          }
-
-          t = (char *) texfilename;
-          n = fnlength;
-
-          if (non_ascii)
-            for (i = 0; i < n; i++)
-              *s++ = xchr [*t++];
-          else
-            for (i = 0; i < n; i++)
-              *s++ = (char) *t++;
-
-          sdone = 1;
-          break;
-
-        case 'l':
-          if (ldone)
-          {
-#ifdef __WIN32
-            sprintf(log_line, "! bad command syntax (%c).\n", 'l'); 
-            show_line(log_line, 1);
-#else
-            sprintf(log_line, "! `%%l' cannot appear twice in editor command.\n");
-            show_line(log_line, 1);
-#endif
-            uexit(1); 
-          }
-
-          t = (char *) log_file_name;
-          n = lglength;
-
-          if (non_ascii)
-            for (i = 0; i < n; i++)
-              *s++ = xchr [*t++];
-          else
-            for (i = 0; i < n; i++)
-              *s++ = (char) *t++;
-
-          ldone = 1;
-          break;
-
-        case '\0':
-          *s++ = '%'; 
-          u--;
-          break;
-
-        default:
-          *s++ = '%';
-          *s++ = c;
-          break;
-      }
-    }
-    else
-      *s++ = c;
-  }
-
-  *s = 0; /* terminate the command string */
-
-  if (strlen(command) + 1 >= commandlen)
-  {
-    sprintf(log_line, "Command too long (%d > %d)\n", strlen(command) + 1, commandlen);
-    show_line(log_line, 1);
-    uexit(1);
-  }
-
-  //flushall();
-  fflush(NULL);
-
-  if (system (command) != 0)
-  {
-    show_line("\n", 0);
-    sprintf(log_line, "! Error in call: %s\n", command);
-    show_line(log_line, 1);
-
-#ifdef __WIN32
-    if (errno != 0)
-      perrormod("! DOS says");
-#endif
-
-    sprintf(log_line, "  (TEXEDIT=%s)\n", edit_value);
-    show_line(log_line, 0);
-    show_line("  (Editor specified may be missing or path may be wrong)\n", 0);
-    show_line("  (or there may be missing -- or extraneous -- quotation signs)\n", 0);
-  }
-
-  uexit(1);
-}
-
-\f
-/* Read and write format (for TeX) or base (for Metafont) files.  In
-   tex.web, these files are architecture dependent; specifically,
-   BigEndian and LittleEndian architectures produce different files.
-   These routines always output BigEndian files.  This still does not
-   make the dump files architecture-independent, because it is possible
-   to make a format file that dumps a glue ratio, i.e., a floating-point
-   number.  Fortunately, none of the standard formats do that.  */
-
-#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP) /* this fn */
-
-/* We don't REALLY care what `endian' the machine is after all ! */
-/* But we do care about speed - so check exe file for following - bkph */
-
-// #ifdef MYDEBUG
-// char swapmarkerstring="ERROR: SWAPPING - NOT BigEndian AND NOT NoFmtBaseSwap";
-// #endif
-
-/* This macro is always invoked as a statement.  It assumes a variable
-   `temp'.  */
-   
-#define SWAP(x, y) temp = (x); (x) = (y); (y) = temp;
-
-
-/* Make the NITEMS items pointed at by P, each of size SIZE, be the
-   opposite-endianness of whatever they are now.  */
-
-static int swap_items (char *p, int nitems, int size)
-{
-  char temp;
-
-  /* Since `size' does not change, we can write a while loop for each
-     case, and avoid testing `size' for each time.  */
-  switch (size)
-  {
-    case 8:
-      while (nitems--)
-      {
-        SWAP (p[0], p[7]);
-        SWAP (p[1], p[6]);
-        SWAP (p[2], p[5]);
-        SWAP (p[3], p[4]);
-        p += size;
-      }
-      break;
-
-    case 4:
-      while (nitems--)
-      {
-        SWAP (p[0], p[3]);
-        SWAP (p[1], p[2]);
-        p += size;
-      }
-      break;
-
-    case 2:
-      while (nitems--)
-      {
-        SWAP (p[0], p[1]);
-        p += size;
-      }
-      break;
-
-    case 1:
-    /* Nothing to do.  */
-      break;
-
-    default:
-      show_line("\n", 0);
-      sprintf(log_line, "! I can't (un)dump a %d byte item.\n", size);
-      show_line(log_line, 1);
-      uexit(1);
-  }
-  return 0;
-}
-#endif /* not WORDS_BIGENDIAN and not NO_FMTBASE_SWAP */
-
-/* Hmm, this could benefit from some on the fly compression - bkph */
-/* and complementary decompression on input - bkph */
-
-/* Here we write NITEMS items, each item being ITEM_SIZE bytes long.
-   The pointer to the stuff to write is P, and we write to the file
-   OUT_FILE.  */
-
-int do_dump (char *p, int item_size, int nitems, FILE *out_file)
-{
-#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)
-  swap_items (p, nitems, item_size);
-#endif
-
-#ifdef COMPACTFORMAT
-  if (gzwrite(gz_fmt_file, p, (item_size * nitems)) != (item_size * nitems))
-#else
-  if ((int) fwrite (p, item_size, nitems, out_file) != nitems)
-#endif
-  {
-    show_line("\n", 0);
-    sprintf(log_line, "! Could not write %d %d-byte item%s.\n",
-               nitems, item_size, (nitems > 1) ? "s" : "");
-    show_line(log_line, 1);
-    uexit(1);
-  }
-
-/* Have to restore the old contents of memory, since some of it might get used again.  */
-#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)
-  swap_items (p, nitems, item_size);
-#endif
-
-  return 0;
-}
-
-/* Hmm, this could benefit from some on the fly decompression - bkph */
-
-/* Here is the dual of the writing routine.  */
-int do_undump (char *p, int item_size, int nitems, FILE *in_file)
-{
-#ifdef COMPACTFORMAT
-  if (gzread(gz_fmt_file, (void *) p, (unsigned int) (item_size * nitems)) <= 0)
-#else
-  if ((int) fread((void *) p, item_size, nitems, in_file) != nitems)
-#endif
-  {
-    show_line("\n", 0);
-    sprintf(log_line, "! Could not read %d %d-byte item%s.\n",
-               nitems, item_size, (nitems > 1) ? "s" : "");
-    show_line(log_line, 1);
-    uexit(1);
-  }
-
-#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)
-  swap_items (p, nitems, item_size);
-#endif
-  return 0;
-}
-
-\f
-#ifdef FUNNY_CORE_DUMP
-/* This procedure is due to chris@mimsy.umd.edu.  It makes a core dump
-   without any sort of error status (abort(2) does return an error status,
-   so we don't want to use that).  It is used only when making a preloaded
-   TeX from virtex, and is triggered by a magic file name requested as
-   input (see `open_input', above).  */
-
-void funny_core_dump (void)
-{
-  int pid, w;
-  union wait status;
-
-  switch (pid = vfork ())
-  {
-    case -1:    /* failed */
-      perrormod ("vfork");
-      exit (-1);      /* NOTREACHED */
-
-    case 0:             /* child */
-       (void) signal (SIGQUIT, SIG_DFL);
-       (void) kill (getpid (), SIGQUIT);
-       (void) write (2, "how did we get here?\n", 21);
-       exit (1);       /* NOTREACHED */
-
-    default:    /* parent */
-      while ((w = wait (&status)) != pid && w != -1)
-        ;
-      if (status.w_coredump)
-        exit (0);
-      (void) write (2, "attempt to dump core failed\n", 28);
-      exit (1);
-  }
-}
-#endif /* FUNNY_CORE_DUMP */
\ No newline at end of file
+/*\r
+   Copyright 1992 Karl Berry\r
+   Copyright 2007 TeX Users Group\r
+   Copyright 2014 Clerk Ma\r
+\r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful, but\r
+   WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+   General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
+   02110-1301 USA.\r
+*/\r
+\r
+#define EXTERN\r
+\r
+#include "yandytex.h"\r
+\r
+#define dump_ext_length 4\r
+#define edit_value      tex_edit_value\r
+\r
+extern char * replacement[];\r
+int    gargc;\r
+char **gargv;\r
+\r
+int jump_used = 0;\r
+\r
+jmp_buf jumpbuffer;\r
+\r
+int main (int ac, char *av[])\r
+{\r
+  int flag = 0, ret = 0;\r
+\r
+  gargc = ac;\r
+  gargv = av;\r
+\r
+  if (main_init(gargc, gargv))\r
+    return -1;\r
+\r
+  TEX_format_default = " plain.fmt";\r
+  format_default_length = strlen(TEX_format_default + 1);\r
+\r
+  jump_used = 0;\r
+\r
+  ret = setjmp(jumpbuffer);\r
+\r
+  if (ret == 0)\r
+  {\r
+    flag = main_program();\r
+\r
+    if (trace_flag)\r
+      printf("EXITING at %s: flag = %d, ret = %d, jump_used = %d\n", "main", flag, ret, jump_used);\r
+  }\r
+  else\r
+  {\r
+    if (trace_flag)\r
+      printf("EXITING at %s: flag = %d, ret = %d, jump_used =  %d\n", "jump_out", flag, ret, jump_used);\r
+  }\r
+\r
+  if (endit(flag) != 0)\r
+    flag = 1; /* do final clean up in local.c */\r
+\r
+  if (flag == 0)\r
+    return 0;\r
+  else\r
+    exit (flag);\r
+}\r
+\r
+/* texk/web2c/lib/texmfmp.c */\r
+void t_open_in (void)\r
+{\r
+  int i;\r
+\r
+  buffer[first] = 0;\r
+\r
+  if (gargc > optind && optind > 0)\r
+  {\r
+    for (i = optind; i < gargc; i++)\r
+    {\r
+      if (allow_quoted_names && strchr(gargv[i], ' ') != NULL)\r
+      {\r
+        (void) strcat ((char *) &buffer[first], "\"");\r
+        (void) strcat ((char *) &buffer[first], gargv[i]);\r
+        (void) strcat ((char *) &buffer[first], "\"");\r
+      }\r
+      else\r
+        (void) strcat ((char *) &buffer[first], gargv[i]);\r
+\r
+      (void) strcat ((char *) &buffer[first], " ");\r
+    }\r
+    \r
+    gargc = 0;\r
+  }\r
+\r
+  /* Find the end of the buffer.  */\r
+  for (last = first; buffer[last]; ++last)\r
+    do_nothing();\r
+\r
+  for (--last; last >= first && ISBLANK(buffer[last]) && buffer[last] != '\r'; --last)\r
+    do_nothing();\r
+\r
+  last++;\r
+\r
+  if (non_ascii)\r
+  {\r
+    for (i = first; i < last; i++)\r
+      buffer[i] = xord[buffer[i]];\r
+  }\r
+}\r
+\r
+static void catch_interrupt (int err)\r
+{\r
+  (void) err;\r
+  (void) signal(SIGINT, SIG_IGN);\r
+\r
+  if (interrupt++ >= 3)\r
+    exit(1);\r
+\r
+  (void) signal(SIGINT, catch_interrupt);\r
+}\r
+\r
+void fix_date_and_time (void)\r
+{\r
+  time_t clock;\r
+  struct tm *tmptr;\r
+\r
+  (void) time(&clock);\r
+\r
+  if (trace_flag)\r
+    printf("The time is %lld\n", (long long)clock);\r
+\r
+  if (clock < 0)\r
+    puts("Time not available!");\r
+\r
+  tmptr = localtime (&clock);\r
+\r
+  if (tmptr == NULL)\r
+  {\r
+    printf("Cannot convert time (%0lld)!\n", (long long)clock);\r
+    year     = 2038;\r
+    month    = 1;\r
+    day      = 18;\r
+    tex_time = 22 * 60 + 14;\r
+  }\r
+  else\r
+  {\r
+    tex_time = tmptr->tm_hour * 60 + tmptr->tm_min;\r
+    day      = tmptr->tm_mday;\r
+    month    = tmptr->tm_mon + 1;\r
+    year     = tmptr->tm_year + 1900;\r
+\r
+    if (trace_flag)\r
+      printf("%d-%d-%d %d:%d\n",\r
+        tmptr->tm_year + 1900,\r
+        tmptr->tm_mon + 1,\r
+        tmptr->tm_mday,\r
+        tmptr->tm_hour,\r
+        tmptr->tm_min);\r
+  }\r
+\r
+  {\r
+#ifdef _WIN32\r
+    if (signal(SIGINT, catch_interrupt) == SIG_ERR)\r
+    {\r
+      puts(" CTRL-C handler not installed");\r
+      uexit(EXIT_FAILURE);\r
+    }\r
+#else\r
+    void (*old_handler)();\r
+\r
+    old_handler = signal(SIGINT, catch_interrupt);\r
+\r
+    if (old_handler != SIG_DFL)\r
+      (void) signal(SIGINT, old_handler);\r
+#endif\r
+  }\r
+}\r
+\r
+/* I/O for TeX and Metafont. */\r
+void complain_line (FILE * output)\r
+{\r
+  show_line("\n", 0);\r
+\r
+#ifdef ALLOCATEBUFFER\r
+  sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", current_buf_size);\r
+#else\r
+  sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", buf_size);\r
+#endif\r
+\r
+  fputs(log_line, output);\r
+  puts("  (File may have a line termination problem.)");\r
+}\r
+\r
+void show_bad_line (FILE * output, int first, int last)\r
+{\r
+  int i, c, d, ch;\r
+  char *s = log_line;\r
+\r
+  for (i = first; i <= last; i++)\r
+  {\r
+    ch = buffer[i];\r
+\r
+    if (show_in_hex && (ch > 127))\r
+    {\r
+      c = ch >> 4;\r
+      d = ch & 15;\r
+\r
+      if (c > 9)\r
+        c = c + 'a' - 10;\r
+      else\r
+        c = c + '0';\r
+\r
+      if (d > 9)\r
+        d = d + 'a' - 10;\r
+      else\r
+        d = d + '0';\r
+\r
+      *s++ = '^';\r
+      *s++ = '^';\r
+\r
+      *s++ = (char) c;\r
+      *s++ = (char) d;\r
+    }\r
+    else if (ch < 32)\r
+    {\r
+      *s++ = '^';\r
+      *s++ = '^';\r
+      *s++ = (char) (ch + 64);\r
+    }\r
+    else if (ch == 127)\r
+    {\r
+      *s++ = '^';\r
+      *s++ = '^';\r
+      *s++ = (char) (ch - 64);\r
+    }\r
+    else\r
+    {\r
+      *s++ = (char) ch;\r
+    }\r
+  }\r
+\r
+  *s++ = ' ';\r
+  *s++ = '\0';\r
+\r
+  fputs(log_line, output);   // log_file\r
+}\r
+\r
+boolean input_line_finish (void)\r
+{\r
+  int i = '\0';\r
+  int ch, flag;\r
+\r
+  buffer[last] = ' ';\r
+\r
+  if (last >= max_buf_stack)\r
+    max_buf_stack = last;\r
+\r
+  while (last > first)\r
+  {\r
+    i = buffer[last - 1];\r
+\r
+    if (i == ' ' || i == '\t')\r
+      --last;\r
+    else\r
+      break;\r
+  }\r
+\r
+  if (restrict_to_ascii)\r
+  {\r
+    flag = 0;\r
+\r
+    for (i = first; i <= last; i++)\r
+    {\r
+      ch = buffer[i];\r
+\r
+      if (ch > 126 ||  (ch < ' ' && ch != '\t' && ch != '\f' && ch != '\r' && ch != '\n'))\r
+      {\r
+        sprintf(log_line, "\n! non ASCII char (%d) in line: ", ch);\r
+        show_line(log_line, 1);\r
+\r
+        if (log_opened)\r
+          fprintf(log_file, "\n! non ASCII char (%d) in line: ", ch);\r
+\r
+        flag = 1;\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (flag)\r
+    {\r
+      show_bad_line(errout, first, last);\r
+\r
+      if (log_opened)\r
+        show_bad_line(log_file, first, last);\r
+    }\r
+  }\r
+\r
+  if (non_ascii)\r
+  {\r
+    for (i = first; i <= last; i++)\r
+      buffer[i] = xord[buffer[i]];\r
+  }\r
+\r
+  return true;\r
+}\r
+/* sec 0031 */\r
+boolean input_line (FILE * f)\r
+{\r
+  char * u;        /* 1994/July/3 for key_replace */\r
+  int i = '\0';\r
+\r
+  last = first;\r
+/*  following is new version with tab expansion and key replacement */\r
+/*  may want to expand out separately for speed 1994/July/3 */\r
+/*  different versions depending on return_flag / tabexpand / key_replace */\r
+/*  while (last < buf_size && (i = getc (f)) != EOF)  */\r
+#ifdef ALLOCATEBUFFER\r
+  for ( ; ; ) \r
+#else\r
+  while (last < buf_size) \r
+#endif\r
+  {\r
+    i = getc(f);\r
+\r
+    if (i < ' ')\r
+    {\r
+      if (i == EOF || i == '\n' || (i == '\r' && return_flag))\r
+        break;\r
+      else if (i == '\t' && tab_step != 0)\r
+      {\r
+        buffer[last++] = (ASCII_code) ' ';\r
+\r
+#ifdef ALLOCATEBUFFER\r
+        if (last >= current_buf_size)\r
+        {\r
+          buffer = realloc_buffer(increment_buf_size);  \r
+\r
+          if (last >= current_buf_size)\r
+            break;\r
+        }\r
+#endif\r
+\r
+#ifdef ALLOCATEBUFFER\r
+        while ((last - first) % tab_step != 0) \r
+#else\r
+        while (last < buf_size && (last - first) % tab_step != 0)\r
+#endif\r
+        {\r
+\r
+          buffer[last++] = (ASCII_code) ' ';\r
+\r
+#ifdef ALLOCATEBUFFER\r
+          if (last >= current_buf_size)\r
+          {\r
+            buffer = realloc_buffer(increment_buf_size);\r
+\r
+            if (last >= current_buf_size)\r
+              break;\r
+          }\r
+#endif\r
+        }\r
+\r
+        continue;\r
+      }\r
+    }\r
+\r
+    if (key_replace && (u = replacement[i]) != NULL)\r
+    {\r
+#ifdef ALLOCATEBUFFER\r
+      while (*u != '\0') \r
+#else\r
+      while (last < buf_size && *u != '\0')  \r
+#endif\r
+      {\r
+        buffer[last++] = (ASCII_code) *u++;\r
+\r
+#ifdef ALLOCATEBUFFER\r
+        if (last >= current_buf_size)\r
+        {\r
+          buffer = realloc_buffer(increment_buf_size);\r
+\r
+          if (last >= current_buf_size)\r
+            break;\r
+        }\r
+#endif\r
+      }\r
+    }\r
+    else       /* normal case */\r
+    {\r
+      buffer[last++] = (ASCII_code) i;\r
+\r
+#ifdef ALLOCATEBUFFER\r
+      if (last >= current_buf_size)\r
+      {\r
+        buffer = realloc_buffer(increment_buf_size);\r
+\r
+        if (last >= current_buf_size)\r
+          break;\r
+      }\r
+#endif\r
+    }\r
+  }\r
+\r
+  if (return_flag)  /* let return terminate line as well as newline */\r
+  {\r
+    if (i == '\r')  /* see whether return followed by newline */\r
+    {\r
+      i = getc(f);  /* in which case throw away the newline */\r
+\r
+      if (i != '\n')\r
+      {\r
+        ungetc(i, f);\r
+        i = '\r';\r
+      }\r
+/*      else  buffer[last-1] = (ASCII_code) i; */\r
+    }\r
+  }\r
+\r
+  //  Turn Ctrl-Z at end of file into newline 2000 June 22\r
+  if (i == EOF && trimeof && buffer[last - 1] == 26)\r
+  {\r
+    last--;\r
+  }\r
+\r
+  if (i == EOF && last == first)\r
+    return false;\r
+\r
+/*  Didn't get the whole line because buffer was too small?  */\r
+/*  This shouldn't happen anymore 99/Jan/23 */\r
+  if (i != EOF && i != '\n' && i != '\r')\r
+  {\r
+    complain_line(errout);\r
+\r
+    if (log_opened)\r
+      complain_line(log_file);\r
+\r
+    /* This may no longer be needed ... now that we grow it */\r
+    if (truncate_long_lines)\r
+    {\r
+      while (i != EOF && i != '\n' && i != '\r')\r
+      {\r
+        i = getc (f);     // discard rest of line\r
+      }\r
+\r
+      last--;       /* just in case */\r
+    }\r
+    else\r
+      uexit(EXIT_FAILURE);      /* line too long */\r
+  }\r
+\r
+  return input_line_finish();\r
+}\r
+\r
+static char * edit_value = "c:\\yandy\\WinEdt\\WinEdt.exe [Open('%s');SelLine(%d,7)]";\r
+\r
+#ifdef WIN32\r
+static inline int Isspace (char c)\r
+{\r
+  return (c == ' ' || c == '\t');\r
+}\r
+#endif\r
+\r
+void call_edit (ASCII_code * filename, pool_pointer fnstart, integer fnlength, integer linenumber)\r
+{\r
+  char *temp, *command, *fullcmd;\r
+  char c;\r
+  int sdone, ddone, i;\r
+\r
+#ifdef WIN32\r
+  char *fp, *ffp, *env, editorname[256], buffer[256];\r
+  int cnt = 0;\r
+  int dontchange = 0;\r
+#endif\r
+\r
+  sdone = ddone = 0;\r
+  filename += fnstart;\r
+\r
+  /* Close any open input files, since we're going to kill the job. */\r
+  for (i = 1; i <= in_open; i++)\r
+#ifdef XeTeX\r
+    xfclose(input_file[i]->f, "inputfile");\r
+#else\r
+    xfclose(input_file[i], "inputfile");\r
+#endif\r
+\r
+  /* Replace the default with the value of the appropriate environment\r
+     variable or config file value, if it's set.  */\r
+  temp = kpse_var_value("TEXEDIT");\r
+\r
+  if (temp != NULL)\r
+    edit_value = temp;\r
+\r
+  /* Construct the command string.  The `11' is the maximum length an\r
+     integer might be.  */\r
+  command = (char *) xmalloc (strlen (edit_value) + fnlength + 11);\r
+\r
+  /* So we can construct it as we go.  */\r
+  temp = command;\r
+\r
+#ifdef WIN32\r
+  fp = editorname;\r
+  if ((isalpha(*edit_value) && *(edit_value + 1) == ':'\r
+        && IS_DIR_SEP (*(edit_value + 2)))\r
+      || (*edit_value == '"' && isalpha(*(edit_value + 1))\r
+        && *(edit_value + 2) == ':'\r
+        && IS_DIR_SEP (*(edit_value + 3)))\r
+     )\r
+    dontchange = 1;\r
+#endif\r
+\r
+  while ((c = *edit_value++) != 0)\r
+  {\r
+    if (c == '%')\r
+    {\r
+      switch (c = *edit_value++)\r
+      {\r
+        case 'd':\r
+          if (ddone)\r
+            FATAL ("call_edit: `%%d' appears twice in editor command");\r
+          sprintf (temp, "%ld", (long int)linenumber);\r
+          while (*temp != '\0')\r
+            temp++;\r
+          ddone = 1;\r
+          break;\r
+        \r
+        case 's':\r
+          if (sdone)\r
+            FATAL ("call_edit: `%%s' appears twice in editor command");\r
+          for (i = 0; i < fnlength; i++)\r
+            *temp++ = xchr[(filename[i])];\r
+          sdone = 1;\r
+          break;\r
+        \r
+        case '\0':\r
+          *temp++ = '%';\r
+          /* Back up to the null to force termination.  */\r
+          edit_value--;\r
+          break;\r
+        \r
+        default:\r
+          *temp++ = '%';\r
+          *temp++ = c;\r
+          break;\r
+      }\r
+    }\r
+    else\r
+    {\r
+#ifdef WIN32\r
+      if (dontchange)\r
+        *temp++ = c;\r
+      else \r
+      { \r
+        if(Isspace(c) && cnt == 0)\r
+        {\r
+          cnt++;\r
+          temp = command;\r
+          *temp++ = c;\r
+          *fp = '\0';\r
+        }\r
+        else if(!Isspace(c) && cnt == 0)\r
+        {\r
+          *fp++ = c;\r
+        }\r
+        else\r
+        {\r
+          *temp++ = c;\r
+        }\r
+      }\r
+#else\r
+      *temp++ = c;\r
+#endif\r
+    }\r
+  }\r
+\r
+  *temp = 0;\r
+\r
+#ifdef WIN32\r
+  if (dontchange == 0) {\r
+    if(editorname[0] == '.' ||\r
+       editorname[0] == '/' ||\r
+       editorname[0] == '\\') {\r
+      fprintf(stderr, "%s is not allowed to execute.\n", editorname);\r
+      uexit(1);\r
+    }\r
+    env = (char *)getenv("PATH");\r
+    if(SearchPath(env, editorname, ".exe", 256, buffer, &ffp)==0) {\r
+      if(SearchPath(env, editorname, ".bat", 256, buffer, &ffp)==0) {\r
+        fprintf(stderr, "I cannot find %s in the PATH.\n", editorname);\r
+        uexit(1);\r
+      }\r
+    }\r
+    fullcmd = (char *)xmalloc(strlen(buffer)+strlen(command)+5);\r
+    strcpy(fullcmd, "\"");\r
+    strcat(fullcmd, buffer);\r
+    strcat(fullcmd, "\"");\r
+    strcat(fullcmd, command);\r
+  } else\r
+#endif\r
+  fullcmd = command;\r
+\r
+  /* Execute the command.  */\r
+  if (system (fullcmd) != 0)\r
+    fprintf(stderr, "! Trouble executing `%s'.\n", command);\r
+\r
+  /* Quit, since we found an error.  */\r
+  uexit(1);\r
+}\r
+\r
+\r
+#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)\r
+   \r
+#define SWAP(x, y) temp = (x); (x) = (y); (y) = temp;\r
+\r
+\r
+/* Make the NITEMS items pointed at by P, each of size SIZE, be the\r
+   opposite-endianness of whatever they are now.  */\r
+\r
+static int swap_items (char *p, int nitems, int size)\r
+{\r
+  char temp;\r
+\r
+  /* Since `size' does not change, we can write a while loop for each\r
+     case, and avoid testing `size' for each time.  */\r
+  switch (size)\r
+  {\r
+    case 8:\r
+      while (nitems--)\r
+      {\r
+        SWAP (p[0], p[7]);\r
+        SWAP (p[1], p[6]);\r
+        SWAP (p[2], p[5]);\r
+        SWAP (p[3], p[4]);\r
+        p += size;\r
+      }\r
+      break;\r
+\r
+    case 4:\r
+      while (nitems--)\r
+      {\r
+        SWAP (p[0], p[3]);\r
+        SWAP (p[1], p[2]);\r
+        p += size;\r
+      }\r
+      break;\r
+\r
+    case 2:\r
+      while (nitems--)\r
+      {\r
+        SWAP (p[0], p[1]);\r
+        p += size;\r
+      }\r
+      break;\r
+\r
+    case 1:\r
+    /* Nothing to do.  */\r
+      break;\r
+\r
+    default:\r
+      show_line("\n", 0);\r
+      sprintf(log_line, "! I can't (un)dump a %d byte item.\n", size);\r
+      show_line(log_line, 1);\r
+      uexit(EXIT_FAILURE);\r
+  }\r
+  return 0;\r
+}\r
+#endif /* not WORDS_BIGENDIAN and not NO_FMTBASE_SWAP */\r
+\r
+#ifdef COMPACTFORMAT\r
+int do_dump (char *p, int item_size, int nitems, gzFile out_file)\r
+#else\r
+int do_dump (char *p, int item_size, int nitems, FILE *out_file)\r
+#endif\r
+{\r
+#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)\r
+  swap_items (p, nitems, item_size);\r
+#endif\r
+\r
+#ifdef COMPACTFORMAT\r
+  if (gzwrite(out_file, p, (item_size * nitems)) != (item_size * nitems))\r
+#else\r
+  if ((int) fwrite(p, item_size, nitems, out_file) != nitems)\r
+#endif\r
+  {\r
+    printf("\n! Could not write %d %d-byte item%s.\n",\r
+               nitems, item_size, (nitems > 1) ? "s" : "");\r
+    uexit(EXIT_FAILURE);\r
+  }\r
+\r
+/* Have to restore the old contents of memory, since some of it might get used again.  */\r
+#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)\r
+  swap_items (p, nitems, item_size);\r
+#endif\r
+\r
+  return 0;\r
+}\r
+\r
+#ifdef COMPACTFORMAT\r
+int do_undump (char *p, int item_size, int nitems, gzFile in_file)\r
+#else\r
+int do_undump (char *p, int item_size, int nitems, FILE *in_file)\r
+#endif\r
+{\r
+#ifdef COMPACTFORMAT\r
+  if (gzread(in_file, (void *) p, (unsigned int) (item_size * nitems)) <= 0)\r
+#else\r
+  if ((int) fread((void *) p, item_size, nitems, in_file) != nitems)\r
+#endif\r
+  {\r
+    printf("\n! Could not read %d %d-byte item%s.\n",\r
+               nitems, item_size, (nitems > 1) ? "s" : "");\r
+    uexit(EXIT_FAILURE);\r
+  }\r
+\r
+#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)\r
+  swap_items (p, nitems, item_size);\r
+#endif\r
+\r
+  return 0;\r
+}
\ No newline at end of file