home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / tex / texsrc1 / Src / lib / old-h / pascal < prev    next >
Encoding:
Text File  |  1992-12-12  |  3.7 KB  |  112 lines

  1. /* pascal.h: implement various bits of standard Pascal that we use.  */
  2.  
  3. #ifndef PASCAL_H
  4. #define PASCAL_H
  5.  
  6. /* Absolute value.  Without the casts to integer here, the Ultrix and
  7.    AIX compilers (at least) produce bad code (or maybe it's that I don't
  8.    understand all the casting rules in C) for tests on memory fields. 
  9.    Specifically, a test in diag_round (in Metafont) on a quarterword
  10.    comes out differently without the cast, thus causing the trap test to
  11.    fail.  (A path at line 86 is constructed slightly differently).  */
  12. #define    abs(x)((integer)(x)>=0?(integer)(x):(integer)-(x))
  13.  
  14. /* Other standard predefined routines.  */
  15. #define    chr(x)        (x)
  16. #define ord(x)        (x)
  17. #define    odd(x)        ((x) % 2)
  18. #define    round(x)    zround ((double) (x))
  19. #define trunc(x)    ((integer) (x))
  20.  
  21. /* File routines.  */
  22. #define    reset(f, n)    ((f) ? fclose (f) : 0), \
  23.              (f) = xfopen_pas ((char *) (n), "r")
  24. #define rewrite(f, n)    (f) = xfopen_pas ((char *) (n), "w")
  25. #define flush(f)    (void) fflush (f)
  26.  
  27. #define read(f, b)    ((b) = getc (f))
  28. #define    readln(f)    { register c; \
  29.                           while ((c = getc (f)) != '\n' && c != EOF); }
  30.  
  31. /* We hope this will be efficient than the `x = x - 1' that decr would
  32.    otherwise be translated to.  Likewise for incr.  */
  33. #define    decr(x)        --(x)
  34. #define    incr(x)        ++(x)
  35.  
  36. /* PatGen 2 uses this.  */
  37. #define    input2ints(a, b)  zinput2ints (&a, &b)
  38.  
  39. /* We need this routine only if TeX is being debugged.  */
  40. #define    input3ints(a, b, c)  zinput3ints (&a, &b, &c)
  41.  
  42. /* Pascal has no address-of operator, and we need pointers to integers
  43.    to set up the option table.  */
  44. #define addressofint(x)    ((int *) &(x))
  45.  
  46. /* Not all C libraries have fabs, so we'll roll our own.  */
  47. #define    fabs(x)        ((x) >= 0.0 ? (x) : -(x))
  48.  
  49. /* The fixwrites program outputs this.  */
  50. #define    Fputs(f, s)    (void) fputs (s, f)
  51.  
  52. /* Tangle removes underscores from names, but the `struct option'
  53.    structure has a field name with an underscore.  So we have to put it
  54.    back.  Ditto for the other names.  */
  55. #define getoptlongonly    getopt_long_only
  56. #define hasarg        has_arg
  57.  
  58. /* Same underscore problem.  */
  59. #define PATHMAX        PATH_MAX
  60.  
  61. /* We need a new type for the argument parsing, too.  */
  62. typedef struct option getoptstruct;
  63.  
  64. #define printreal(r, n, m)  fprintreal (stdout, r, n, m)
  65. #define    putbyte(x, f)    putc ((char) (x) & 255, f)
  66.  
  67. #define    toint(x)    ((integer) (x))
  68.  
  69. /* For throwing away input from the file F.  */
  70. #define vgetc(f)    (void) getc (f)
  71.  
  72. /* If we don't care that strcpy(3) returns A.  Likewise for strcat.  */
  73. #define vstrcpy(a, b)    (void) strcpy (a, b)
  74. #define vstrcat(a, b)    (void) strcat (a, b)
  75.  
  76. /* Write out elements START through END of BUF to the file F.  */
  77. #define writechunk(f, buf, start, end) \
  78.   (void) fwrite (&buf[start], sizeof (buf[start]), end - start + 1, f)
  79.  
  80. /* Like fseek(3), but cast the arguments and ignore the return value.  */
  81. #define checkedfseek(f, n, w)  (void) fseek(f, (long) n, (int) w)
  82.  
  83. /* For faking arrays.  */
  84. typedef unsigned char *pointertobyte;
  85. #define casttobytepointer(e) ((pointertobyte) e)
  86.  
  87. /* For some initializations of constant strings.  */
  88. typedef char *ccharpointer;
  89.  
  90. /* `real' is used for noncritical floating-point stuff.  */
  91. typedef double real;
  92.  
  93. /* C doesn't distinguish between text files and other files.  */
  94. typedef FILE *text, *file_ptr, *alphafile;
  95.  
  96. /* `aopenin' is used both for input files and pool files, so it
  97.    needs to know what path to use.  */
  98. #define aopenin(f, p)    open_input (&(f), p, FOPEN_R_MODE)
  99. #define aopenout(f)    open_output (&(f), FOPEN_W_MODE)
  100.  
  101. /* Closing files is even easier; we don't bother to check the return
  102.    status from fclose(3).  */
  103. #define aclose(f)    if (f) (void) fclose (f)
  104.  
  105. #ifdef BibTeX
  106. /* See bibtex.ch for why these are necessary.  */
  107. extern FILE *standardinput;
  108. extern FILE *standardoutput;
  109. #endif
  110.  
  111. #endif /* not PASCAL_H */
  112.