home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / tex / texsrc1 / Src / lib / h / pascal < prev    next >
Encoding:
Text File  |  1993-05-01  |  3.7 KB  |  114 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. #ifndef fabs
  48. #define    fabs(x)        ((x) >= 0.0 ? (x) : -(x))
  49. #endif
  50.  
  51. /* The fixwrites program outputs this.  */
  52. #define    Fputs(f, s)    (void) fputs (s, f)
  53.  
  54. /* Tangle removes underscores from names, but the `struct option'
  55.    structure has a field name with an underscore.  So we have to put it
  56.    back.  Ditto for the other names.  */
  57. #define getoptlongonly    getopt_long_only
  58. #define hasarg        has_arg
  59.  
  60. /* Same underscore problem.  */
  61. #define PATHMAX        PATH_MAX
  62.  
  63. /* We need a new type for the argument parsing, too.  */
  64. typedef struct option getoptstruct;
  65.  
  66. #define printreal(r, n, m)  fprintreal (stdout, r, n, m)
  67. #define    putbyte(x, f)    putc ((char) (x) & 255, f)
  68.  
  69. #define    toint(x)    ((integer) (x))
  70.  
  71. /* For throwing away input from the file F.  */
  72. #define vgetc(f)    (void) getc (f)
  73.  
  74. /* If we don't care that strcpy(3) returns A.  Likewise for strcat.  */
  75. #define vstrcpy(a, b)    (void) strcpy (a, b)
  76. #define vstrcat(a, b)    (void) strcat (a, b)
  77.  
  78. /* Write out elements START through END of BUF to the file F.  */
  79. #define writechunk(f, buf, start, end) \
  80.   (void) fwrite (&buf[start], sizeof (buf[start]), end - start + 1, f)
  81.  
  82. /* Like fseek(3), but cast the arguments and ignore the return value.  */
  83. #define checkedfseek(f, n, w)  (void) fseek(f, (long) n, (int) w)
  84.  
  85. /* For faking arrays.  */
  86. typedef unsigned char *pointertobyte;
  87. #define casttobytepointer(e) ((pointertobyte) e)
  88.  
  89. /* For some initializations of constant strings.  */
  90. typedef char *ccharpointer;
  91.  
  92. /* `real' is used for noncritical floating-point stuff.  */
  93. typedef double real;
  94.  
  95. /* C doesn't distinguish between text files and other files.  */
  96. typedef FILE *text, *file_ptr, *alphafile;
  97.  
  98. /* `aopenin' is used both for input files and pool files, so it
  99.    needs to know what path to use.  */
  100. #define aopenin(f, p)    open_input (&(f), p, FOPEN_R_MODE)
  101. #define aopenout(f)    open_output (&(f), FOPEN_W_MODE)
  102.  
  103. /* Closing files is even easier; we don't bother to check the return
  104.    status from fclose(3).  */
  105. #define aclose(f)    if (f) (void) fclose (f)
  106.  
  107. #ifdef BibTeX
  108. /* See bibtex.ch for why these are necessary.  */
  109. extern FILE *standardinput;
  110. extern FILE *standardoutput;
  111. #endif
  112.  
  113. #endif /* not PASCAL_H */
  114.