home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume28 / unproto / patch01 next >
Encoding:
Text File  |  1992-02-23  |  26.5 KB  |  911 lines

  1. Newsgroups: comp.sources.misc
  2. From: wietse@wzv.win.tue.nl (Wietse Venema)
  3. Subject:  v28i069:  unproto - ANSI C with traditional UNIX C compiler, Patch01
  4. Message-ID: <1992Feb24.034828.14131@sparky.imd.sterling.com>
  5. X-Md4-Signature: fe20b2b822b503a511192d1a2661cf82
  6. Date: Mon, 24 Feb 1992 03:48:28 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: wietse@wzv.win.tue.nl (Wietse Venema)
  10. Posting-number: Volume 28, Issue 69
  11. Archive-name: unproto/patch01
  12. Environment: UNIX, PCC
  13. Patch-To: unproto: Volume 27, Issue 85-86
  14.  
  15. This is a patch to the unproto release that appeared a month ago in
  16. this news group (volume 27, issues 85 and 86). It fixes an omission
  17. that was found by Byron Rakitzis when he let the unprototyper loose 
  18. on his re-implementation of the plan 9 rc shell.
  19.  
  20. Changes with respect to the previous release: declarations/definitions
  21. of functions returning pointer to function are now rewritten to old
  22. style; besides a sample stdarg.h, the package now also provides sample
  23. versions of the stddef.h and stdlib.h include files; more hints are
  24. given on how to integrate the unprototyper with the native C compiler;
  25. "asm" has been added to the list of reserved words.
  26.  
  27. A fully patched version of the unproto source can be obtained from
  28. ftp.win.tue.nl, file /pub/unix/unproto4.shar.Z
  29.  
  30.     Wietse Venema
  31.     wietse@wzv.win.tue.nl
  32.     Mathematics and Computing Science
  33.     Eindhoven University of Technology
  34.     The Netherlands
  35.  
  36. Prereq: 1.3
  37. *** ./example.c.old    Wed Jan 15 21:53:27 1992
  38. --- ./example.c    Sat Feb 15 17:17:06 1992
  39. ***************
  40. *** 1,5 ****
  41.    /*
  42. !   * @(#) example.c 1.3 92/01/15 21:53:26
  43.     * 
  44.     * Examples of things that can be done with the unproto package
  45.     */
  46. --- 1,5 ----
  47.    /*
  48. !   * @(#) example.c 1.4 92/02/15 17:17:05
  49.     * 
  50.     * Examples of things that can be done with the unproto package
  51.     */
  52. ***************
  53. *** 187,189 ****
  54. --- 187,216 ----
  55.   
  56.   int (*(*test18[bar])(charstar))(charstar) = \
  57.       (int (*(*[bar])(charstar))(charstar)) 0;
  58. + /* Function returning pointer to function */
  59. + int (*(*test19(long))(int))(double);
  60. + /* GCC accepts the following stuff, K&R C does not... */
  61. + void test20(int test21(double)) {}
  62. + void test22(struct { int foo; } test23(short)) {}
  63. + /* Do not blindly rewrite (*name(stuff))(otherstuff) */
  64. + void    test23()
  65. + {
  66. +     int     (*test24(int)) (int),
  67. +             y = (*test24(2)) (3),
  68. +             z = ((*test24(2)) (3));
  69. + }
  70. + /* Function returning pointer to function */
  71. + int (*(*test25(long foo))(int bar))(double baz){ /* body */ }
  72. + int (*(*test26(foo))())()
  73. + long foo;
  74. + { /* body */ }
  75. Prereq: 1.4
  76. *** ./unproto.c.old    Wed Jan 15 21:52:59 1992
  77. --- ./unproto.c    Sat Feb 15 17:17:12 1992
  78. ***************
  79. *** 7,12 ****
  80. --- 7,14 ----
  81.   /*    unproto
  82.   /* SYNOPSIS
  83.   /*    /somewhere/cpp ...
  84. + /*
  85. + /*    cc cflags -E file.c | unproto >file.i; cc cflags -c file.i
  86.   /* DESCRIPTION
  87.   /*    This document describes a filter that sits in between the UNIX
  88.   /*    C preprocessor and the next UNIX C compiler stage, on the fly rewriting
  89. ***************
  90. *** 123,134 ****
  91.   /*    Department of Mathematics and Computer Science
  92.   /*    Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  93.   /* LAST MODIFICATION
  94. ! /*    92/01/15 21:52:56
  95.   /* VERSION/RELEASE
  96. ! /*    1.4
  97.   /*--*/
  98.   
  99. ! static char unproto_sccsid[] = "@(#) unproto.c 1.4 92/01/15 21:52:56";
  100.   
  101.   /* C library */
  102.   
  103. --- 125,136 ----
  104.   /*    Department of Mathematics and Computer Science
  105.   /*    Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  106.   /* LAST MODIFICATION
  107. ! /*    92/02/15 17:17:09
  108.   /* VERSION/RELEASE
  109. ! /*    1.5
  110.   /*--*/
  111.   
  112. ! static char unproto_sccsid[] = "@(#) unproto.c 1.5 92/02/15 17:17:09";
  113.   
  114.   /* C library */
  115.   
  116. ***************
  117. *** 331,339 ****
  118.   
  119.   #endif
  120.   
  121. ! /* header_flush - rewrite new-style function header to old style */
  122.   
  123. ! static void header_flush(t)
  124.   register struct token *t;
  125.   {
  126.       register struct token *s;
  127. --- 333,341 ----
  128.   
  129.   #endif
  130.   
  131. ! /* show_arg_names - display function argument names */
  132.   
  133. ! static void show_arg_names(t)
  134.   register struct token *t;
  135.   {
  136.       register struct token *s;
  137. ***************
  138. *** 355,362 ****
  139.           }
  140.       }
  141.       }
  142. !     put_nl();                    /* make output look nicer */
  143.   
  144.       /* Do argument types, but suppress void and trailing ... */
  145.   
  146.       if (!LAST_ARG_AND_EQUAL(t->head, VOID_ARG)) {
  147. --- 357,371 ----
  148.           }
  149.       }
  150.       }
  151. ! }
  152.   
  153. + /* show_arg_types - display function argument types */
  154. + static void show_arg_types(t)
  155. + register struct token *t;
  156. + {
  157. +     register struct token *s;
  158.       /* Do argument types, but suppress void and trailing ... */
  159.   
  160.       if (!LAST_ARG_AND_EQUAL(t->head, VOID_ARG)) {
  161. ***************
  162. *** 370,378 ****
  163.           }
  164.       }
  165.       }
  166. -     tok_free(t);
  167.   }
  168.   
  169.   /* show_arg_name - extract argument name from argument type info */
  170.   
  171.   static void show_arg_name(s)
  172. --- 379,468 ----
  173.           }
  174.       }
  175.       }
  176.   }
  177.   
  178. + /* header_flush - rewrite new-style function heading to old style */
  179. + static void header_flush(t)
  180. + register struct token *t;
  181. + {
  182. +     show_arg_names(t);                /* show argument names */
  183. +     put_nl();                    /* make output look nicer */
  184. +     show_arg_types(t);                /* show argument types */
  185. +     tok_free(t);                /* discard token */
  186. + }
  187. + /* fpf_header_names - define func returning ptr to func, no argument types */
  188. + static void fpf_header_names(list)
  189. + struct token *list;
  190. + {
  191. +     register struct token *s;
  192. +     register struct token *p;
  193. +     /*
  194. +      * Recurse until we find the argument list. Account for the rare case
  195. +      * that list is a comma-separated list (which should be a syntax error).
  196. +      * Display old-style fuction argument names.
  197. +      */
  198. +     for (s = list->head; s; s = s->next) {
  199. +     tok_show_ch(s);                /* '(' or ',' or ')' */
  200. +     for (p = s->head; p; p = p->next) {
  201. +         if (p->tokno == TOK_LIST) {
  202. +         if (IS_FUNC_PTR_TYPE(p)) {    /* recurse */
  203. +             fpf_header_names(p);
  204. +             show_empty_list(p = p->next);
  205. +         } else {            /* display argument names */
  206. +             show_arg_names(p);
  207. +         }
  208. +         } else {                /* pass through other stuff */
  209. +         tok_show(p);
  210. +         }
  211. +     }
  212. +     }
  213. + }
  214. + /* fpf_header_types - define func returning ptr to func, argument types only */
  215. + static void fpf_header_types(list)
  216. + struct token *list;
  217. + {
  218. +     register struct token *s;
  219. +     register struct token *p;
  220. +     /*
  221. +      * Recurse until we find the argument list. Account for the rare case
  222. +      * that list is a comma-separated list (which should be a syntax error).
  223. +      * Display old-style function argument types.
  224. +      */
  225. +     for (s = list->head; s; s = s->next) {
  226. +     for (p = s->head; p; p = p->next) {
  227. +         if (p->tokno == TOK_LIST) {
  228. +         if (IS_FUNC_PTR_TYPE(p)) {    /* recurse */
  229. +             fpf_header_types(p);
  230. +             p = p->next;
  231. +         } else {            /* display argument types */
  232. +             show_arg_types(p);
  233. +         }
  234. +         }
  235. +     }
  236. +     }
  237. + }
  238. + /* fpf_header - define function returning pointer to function */
  239. + static void fpf_header(l1, l2)
  240. + struct token *l1;
  241. + struct token *l2;
  242. + {
  243. +     fpf_header_names(l1);            /* strip argument types */
  244. +     show_empty_list(l2);            /* strip prototype */
  245. +     put_nl();                    /* nicer output */
  246. +     fpf_header_types(l1);            /* show argument types */
  247. + }
  248.   /* show_arg_name - extract argument name from argument type info */
  249.   
  250.   static void show_arg_name(s)
  251. ***************
  252. *** 413,423 ****
  253. --- 503,528 ----
  254.   {
  255.       register struct token *p;
  256.   
  257. +     /*
  258. +      * Rewrite (*stuff)(args) to (*stuff)(). Rewrite word(args) to word(),
  259. +      * but only if the word was preceded by a word, '*' or '}'. Leave
  260. +      * anything else alone.
  261. +      */
  262.       for (p = s->head; p; p = p->next) {
  263.       if (IS_FUNC_PTR_TYPE(p)) {
  264.           p = show_func_ptr_type(p, p->next);    /* function pointer type */
  265.       } else {
  266. +         register struct token *q;
  267. +         register struct token *r;
  268.           tok_show(p);            /* other */
  269. +         if ((p->tokno == TOK_WORD || p->tokno == '*' || p->tokno == '}')
  270. +         && (q = p->next) && q->tokno == TOK_WORD
  271. +         && (r = q->next) && r->tokno == TOK_LIST) {
  272. +         tok_show(q);            /* show name */
  273. +         show_empty_list(p = r);        /* strip args */
  274. +         }
  275.       }
  276.       }
  277.   }
  278. ***************
  279. *** 676,687 ****
  280.       }
  281.   }
  282.   
  283. ! /* func_ptr_dcl_flush - rewrite function pointer declaration */
  284.   
  285.   static struct token *func_ptr_dcl_flush(list)
  286.   register struct token *list;
  287.   {
  288.       register struct token *t;
  289.   
  290.       /*
  291.        * Ignore blanks and newlines because we are too lazy to maintain more
  292. --- 781,793 ----
  293.       }
  294.   }
  295.   
  296. ! /* func_ptr_dcl_flush - rewrite function pointer stuff */
  297.   
  298.   static struct token *func_ptr_dcl_flush(list)
  299.   register struct token *list;
  300.   {
  301.       register struct token *t;
  302. +     register struct token *t2;
  303.   
  304.       /*
  305.        * Ignore blanks and newlines because we are too lazy to maintain more
  306. ***************
  307. *** 696,705 ****
  308.           tok_free(t);
  309.           break;
  310.       case TOK_LIST:
  311. !         /* Function pointer type: (list1) (list2) -> (list1) () */
  312. !         (void) show_func_ptr_type(list, t);    /* may be recursive */
  313.           tok_free(list);
  314.           tok_free(t);
  315.           return (0);
  316.       default:                /* not a declaration */
  317.           tok_unget(t);
  318. --- 802,827 ----
  319.           tok_free(t);
  320.           break;
  321.       case TOK_LIST:
  322. !         /* Function pointer or function returning pointer to function. */
  323. !         while ((t2 = tok_class())        /* skip blanks etc. */
  324. !            &&(t2->tokno == TOK_WSPACE || t2->tokno == '\n'))
  325. !         tok_free(t2);
  326. !         switch (t2 ? t2->tokno : 0) {
  327. !         case '{':                /* function heading (new) */
  328. !         fpf_header(list, t);
  329. !         break;
  330. !         case TOK_WORD:            /* function heading (old) */
  331. !         tok_show(list);
  332. !         tok_show(t);
  333. !         break;
  334. !         default:                /* func pointer type */
  335. !         (void) show_func_ptr_type(list, t);
  336. !         break;
  337. !         }
  338.           tok_free(list);
  339.           tok_free(t);
  340. +         if (t2)
  341. +         tok_unget(t2);
  342.           return (0);
  343.       default:                /* not a declaration */
  344.           tok_unget(t);
  345. Prereq: 1.4
  346. *** ./README.old    Wed Jan 15 21:52:56 1992
  347. --- ./README    Sat Feb 15 17:17:02 1992
  348. ***************
  349. *** 1,4 ****
  350. ! @(#) README 1.4 92/01/15 21:52:54
  351.   
  352.   unproto - Compile ANSI C with traditional UNIX C compiler
  353.   
  354. --- 1,4 ----
  355. ! @(#) README 1.5 92/02/15 17:17:00
  356.   
  357.   unproto - Compile ANSI C with traditional UNIX C compiler
  358.   
  359. ***************
  360. *** 7,14 ****
  361.   
  362.   This is a filter that sits in between the UNIX C preprocessor and the
  363.   next UNIX C compiler stage, on the fly transforming ANSI C syntax to
  364. ! old C syntax.  It runs at roughly the same speed as /lib/cpp, so it 
  365. ! has negligible impact on compilation time.
  366.   
  367.   Typically, the program is invoked by the native UNIX C compiler as an
  368.   alternate preprocessor. The unprototyper in turn invokes the native C
  369. --- 7,15 ----
  370.   
  371.   This is a filter that sits in between the UNIX C preprocessor and the
  372.   next UNIX C compiler stage, on the fly transforming ANSI C syntax to
  373. ! old C syntax.  Line number information is preserved so that compiler
  374. ! diagnostics still make sense.  It runs at roughly the same speed as
  375. ! /lib/cpp, so it has negligible impact on compilation time.
  376.   
  377.   Typically, the program is invoked by the native UNIX C compiler as an
  378.   alternate preprocessor. The unprototyper in turn invokes the native C
  379. ***************
  380. *** 20,30 ****
  381.   Unlike some other unprototypers, this one is fully recursive and does
  382.   not depend on source file layout (see the example.c file).
  383.   
  384. ! New and improved functionality provided by the present version: string
  385. ! concatenation, conversion of \a and \x escape sequences to their octal
  386. ! equivalents, translation of __TIME__ and __DATE__, optional mapping of
  387. ! `void *' to `char *', optional mapping of plain `void' to `int', faster
  388. ! execution, and better conservation of program layout.
  389.   
  390.   The unprototyper provides hooks for compilers that require special
  391.   tricks for variadic functions (fortunately, many don't). <stdarg.h>
  392. --- 21,31 ----
  393.   Unlike some other unprototypers, this one is fully recursive and does
  394.   not depend on source file layout (see the example.c file).
  395.   
  396. ! Besides the rewriting of argument lists, the program does the following
  397. ! transformations:  string concatenation, conversion of \a and \x escape
  398. ! sequences to their octal equivalents, translation of the __TIME__ and
  399. ! __DATE__ macros, optional mapping of `void *' to `char *', and optional
  400. ! mapping of plain `void' to `int'. 
  401.   
  402.   The unprototyper provides hooks for compilers that require special
  403.   tricks for variadic functions (fortunately, many don't). <stdarg.h>
  404. ***************
  405. *** 43,67 ****
  406.   Problems fixed with this release:
  407.   ---------------------------------
  408.   
  409. ! Some multi-line statements could end up on a single output line, so
  410. ! that compiler diagnostics with respect to those statements could point
  411. ! to the wrong source-file position (other compiler diagnostics would not
  412. ! have this problem).  The token input/output routines were completely
  413. ! rewritten to eliminate these inconsistencies.
  414.   
  415. - Backslashes within comments were not given special treatment.  Since
  416. - the C preprocessor by default removes all comments this would almost
  417. - never have caused a problem.
  418. - A backslash in front of any token except newline was not given special
  419. - treatment. I have never seen any C code where this would have caused a
  420. - problem.
  421. - The program now returns a non-zero status if it detected any problems.
  422. - A couple of simple heuristics have been added so that the program may
  423. - now even be useful for the conversion of unpreprocessed source.
  424.   Operation:
  425.   ----------
  426.   
  427. --- 44,52 ----
  428.   Problems fixed with this release:
  429.   ---------------------------------
  430.   
  431. ! Prototypes and definitions of functions returning pointer to function
  432. ! were not rewritten to old style.
  433.   
  434.   Operation:
  435.   ----------
  436.   
  437. ***************
  438. *** 78,83 ****
  439. --- 63,78 ----
  440.   
  441.   Your C compiler manual page should provide the necessary information.
  442.   
  443. + A more portable, but less efficient, approach relies on the observation
  444. + that almost every UNIX C compiler supports the -E (write preprocessor
  445. + output to stdout) and -P options (preprocess file.c into file.i). Just
  446. + add the following lines to your Makefiles:
  447. +     .c.o:
  448. +         $(CC) $(CFLAGS) -E $*.c | unproto >$*.i # simulate -P option
  449. +         $(CC) $(CFLAGS) -c $*.i
  450. +         rm -f $*.i
  451.   On some systems the lint(1) command is just a shell script, and writing
  452.   a version that uses the unprototyper should not be too hard. With SunOS
  453.   4.x, /usr/bin/lint is not a shell script, but it does accept the same
  454. ***************
  455. *** 92,114 ****
  456.   
  457.   Check the contents of the `stdarg.h' file provided with this package.
  458.   This file serves a dual purpose: (1) on systems that do not provide a
  459. ! stdarg.h file, it should be included by C source files that implement
  460.   ANSI-style variadic functions; (2) it is also used to configure the
  461.   unprototyper so that it emits the proper magic when it sees `...'.
  462.   
  463.   The `stdarg.h' file has support for sparc, mips, and for compilers that
  464. ! pass arguments via the stack (old-style UNIX compilers for 80*86, mc68k
  465. ! and vax). It gives general hints for other compilers.
  466.   
  467.   The `varargs.c' file provided with this package can be used to verify
  468.   that the `stdarg.h' file has been set up correctly.
  469.   
  470. ! For maximal flexibility, the `cpp.sh' shell script can be used to set
  471. ! up the pipe between the native C preprocessor and the unprototyper
  472. ! command.  The script assumes that the unprototyper binary is called
  473. ! `unproto'.  See the Makefile and the `cpp.sh' script for details and
  474. ! for a description of possible problems with this approach.
  475.   
  476.   The overhead and problems of shell-script interpretation can be avoided
  477.   by letting the unprototyper itself pipe its standard input through the
  478.   C preprocessor.  For this mode of operation, the unprototyper binary
  479. --- 87,118 ----
  480.   
  481.   Check the contents of the `stdarg.h' file provided with this package.
  482.   This file serves a dual purpose: (1) on systems that do not provide a
  483. ! stdarg.h file, it should be included by C source files that implements
  484.   ANSI-style variadic functions; (2) it is also used to configure the
  485.   unprototyper so that it emits the proper magic when it sees `...'.
  486.   
  487.   The `stdarg.h' file has support for sparc, mips, and for compilers that
  488. ! pass arguments via the stack (typical for 80*86, mc68k and vax). It
  489. ! gives general hints for other compilers.
  490.   
  491. + The other sample header files (stddef.h and stdlib.h) are not required
  492. + to build the unprototyper.
  493.   The `varargs.c' file provided with this package can be used to verify
  494.   that the `stdarg.h' file has been set up correctly.
  495.   
  496. ! If your C compiler has no hooks for an alternate preprocessor (the
  497. ! unprototyper will be used as: `cc cflags -E file.c | unproto >file.i'),
  498. ! build the `unproto' executable without the `PIPE_THROUGH_CPP' feature.
  499. ! Details are given in the Makefile.
  500.   
  501. + Otherwise, the `cpp.sh' shell script can be used to set up the pipe
  502. + between the native C preprocessor and the unprototyper command.  The
  503. + script assumes that the unprototyper binary is called `unproto', and
  504. + that it was compiled without the `PIPE_THROUGH_CPP' feature.  See the
  505. + Makefile and the `cpp.sh' script for details and for a description of
  506. + possible problems with this approach.
  507.   The overhead and problems of shell-script interpretation can be avoided
  508.   by letting the unprototyper itself pipe its standard input through the
  509.   C preprocessor.  For this mode of operation, the unprototyper binary
  510. ***************
  511. *** 122,128 ****
  512.   
  513.   Install the `unproto.1' manual page in a suitable place. If your system
  514.   does not provide a `stdarg.h' file, find a suitable place for the one
  515. ! provided with the unprototyper and install it there.
  516.   
  517.   If you use the `cpp' shell script to pipe the preprocessor output
  518.   through the unprototyper program, install the `unproto' binary in a
  519. --- 126,142 ----
  520.   
  521.   Install the `unproto.1' manual page in a suitable place. If your system
  522.   does not provide a `stdarg.h' file, find a suitable place for the one
  523. ! provided with the unprototyper and install it there. The same goes for
  524. ! the sample stddef.h and stdlib.h files; make sure that the definitions
  525. ! in there apply to your environment. Most or all of the latter files are
  526. ! already part of Ultrix 4.x and SunOS 4.1.1.
  527. ! The ANSI float.h and limits.h files can be generated with the config
  528. ! program by Steve Pemberton (comp.sources.misc volume 10, issue 62,
  529. ! available from ftp.uu.net as comp.sources.misc/volume10/config42.Z).
  530. ! If you run the unprototyper with "cc -E" just install the `unproto'
  531. ! binary; the `cpp' shell script will not be needed.
  532.   
  533.   If you use the `cpp' shell script to pipe the preprocessor output
  534.   through the unprototyper program, install the `unproto' binary in a
  535. *** ./stdlib.h.old    Sat Feb 15 17:23:12 1992
  536. --- ./stdlib.h    Sat Feb 15 17:25:45 1992
  537. ***************
  538. *** 0 ****
  539. --- 1,53 ----
  540. + /* @(#) stdlib.h 1.1 92/02/15 17:25:45 */
  541. + #ifndef _stdlib_h_
  542. + #define _stdlib_h_
  543. + /* NULL is also defined in <stdio.h> */
  544. + #ifndef NULL
  545. + #define NULL    0
  546. + #endif
  547. + /*
  548. +  * Some functions in this file will be missing from the typical pre-ANSI
  549. +  * UNIX library. Some pre-ANSI UNIX library functions have return types
  550. +  * that differ from what ANSI requires.
  551. +  */
  552. + extern double atof();
  553. + extern int atoi();
  554. + extern long atol();
  555. + extern double strtod();
  556. + extern long strtol();
  557. + extern unsigned long strtoul();
  558. + extern int rand();
  559. + extern void srand();
  560. + extern char *calloc();
  561. + extern char *malloc();
  562. + extern char *realloc();
  563. + extern void free();
  564. + extern void abort();
  565. + extern void exit();
  566. + extern int atextit();
  567. + extern int system();
  568. + extern char *getenv();
  569. + extern char *bsearch();
  570. + extern void qsort();
  571. + extern int abs();
  572. + extern long labs();
  573. + typedef struct {
  574. +     int     quot;
  575. +     int     rem;
  576. + } div_t;
  577. + typedef struct {
  578. +     long    quot;
  579. +     long    rem;
  580. + } ldiv_t;
  581. + extern div_t div();
  582. + extern ldiv_t ldiv();
  583. + #endif /* _stdlib_h_ */
  584. Prereq: 1.4
  585. *** ./Makefile.old    Wed Jan 15 21:53:22 1992
  586. --- ./Makefile    Sat Feb 15 17:17:04 1992
  587. ***************
  588. *** 1,19 ****
  589. ! # @(#) Makefile 1.4 92/01/15 21:53:20
  590.   
  591.   ## BEGIN CONFIGURATION STUFF
  592.   
  593. ! # For maximal flexibility, the "/lib/cpp | unproto" pipeline can be
  594. ! # packaged as an executable shell script (see the provided "cpp.sh" script)
  595. ! # that should be installed as "/whatever/cpp". This script should then be
  596. ! # specified to the C compiler as a non-default preprocessor.
  597.   #
  598.   # PROG    = unproto
  599.   # PIPE    =
  600.   
  601. ! # For maximal performance, the overhead of shell script interpretation can
  602. ! # be eliminated by having the unprototyper program itself open the pipe
  603. ! # to the preprocessor.  In that case, define the PIPE_THROUGH_CPP macro
  604. ! # as the path name of the default C preprocessor (usually "/lib/cpp"),
  605.   # install the unprototyper as "/whatever/cpp" and specify that to the C
  606.   # compiler as a non-default preprocessor.
  607.   #
  608. --- 1,24 ----
  609. ! # @(#) Makefile 1.5 92/02/15 17:17:03
  610.   
  611.   ## BEGIN CONFIGURATION STUFF
  612.   
  613. ! # In the unlikely case that your compiler has no hooks for alternate
  614. ! # compiler passes, use a "cc cflags -E file.c | unproto >file.i"
  615. ! # pipeline, then "cc cflags -c file.i" to compile the resulting
  616. ! # intermediate file.
  617. ! # 
  618. ! # Otherwise, the "/lib/cpp | unproto" pipeline can be packaged as an
  619. ! # executable shell script (see the provided "cpp.sh" script) that should
  620. ! # be installed as "/whatever/cpp". This script should then be specified
  621. ! # to the C compiler as a non-default preprocessor.
  622.   #
  623.   # PROG    = unproto
  624.   # PIPE    =
  625.   
  626. ! # The overhead and problems of shell script interpretation can be
  627. ! # eliminated by having the unprototyper program itself open the pipe to
  628. ! # the preprocessor.  In that case, define the PIPE_THROUGH_CPP macro as
  629. ! # the path name of the default C preprocessor (usually "/lib/cpp"),
  630.   # install the unprototyper as "/whatever/cpp" and specify that to the C
  631.   # compiler as a non-default preprocessor.
  632.   #
  633. ***************
  634. *** 70,76 ****
  635.       hash.c strsave.c
  636.   HFILES    = error.h token.h vstring.h symbol.h
  637.   SCRIPTS    = cpp.sh
  638. ! SAMPLES    = stdarg.h varargs.c example.c example.out
  639.   SOURCES    = README $(CFILES) $(HFILES) Makefile $(SCRIPTS) $(SAMPLES)
  640.   FILES    = $(SOURCES) unproto.1
  641.   OBJECTS    = tok_io.o tok_class.o tok_pool.o unproto.o vstring.o symbol.o error.o \
  642. --- 75,81 ----
  643.       hash.c strsave.c
  644.   HFILES    = error.h token.h vstring.h symbol.h
  645.   SCRIPTS    = cpp.sh
  646. ! SAMPLES    = stdarg.h stddef.h stdlib.h varargs.c example.c example.out
  647.   SOURCES    = README $(CFILES) $(HFILES) Makefile $(SCRIPTS) $(SAMPLES)
  648.   FILES    = $(SOURCES) unproto.1
  649.   OBJECTS    = tok_io.o tok_class.o tok_pool.o unproto.o vstring.o symbol.o error.o \
  650. ***************
  651. *** 81,87 ****
  652.   #CFLAGS    = -g $(PIPE) $(SKIP) $(BELL) $(MAP) $(ALIAS) -DDEBUG
  653.   
  654.   $(PROG): $(OBJECTS)
  655. !     cc $(CFLAGS) -o $@ $(OBJECTS) $(MALLOC)
  656.   
  657.   # For linting, enable all bells and whistles.
  658.   
  659. --- 86,92 ----
  660.   #CFLAGS    = -g $(PIPE) $(SKIP) $(BELL) $(MAP) $(ALIAS) -DDEBUG
  661.   
  662.   $(PROG): $(OBJECTS)
  663. !     $(CC) $(CFLAGS) -o $@ $(OBJECTS) $(MALLOC)
  664.   
  665.   # For linting, enable all bells and whistles.
  666.   
  667. *** ./example.out.old    Wed Jan 15 22:04:24 1992
  668. --- ./example.out    Sat Feb 15 17:17:09 1992
  669. ***************
  670. *** 48,58 ****
  671.   # 38 "example.c"
  672.   int (*(*bar)())();
  673.   {/*1*/
  674. !     int     (*baz)() = (int (*)()) 0,
  675.           y = (y * (*baz)(y)),
  676. !         *(*z)() = (int *(*)()) 0;
  677.   
  678. !     struct {/*2*/ int (*foo)(); }/*2*/ *(*s)() = 
  679.       (struct { int (*foo)(); } *(*)()) 0;
  680.   
  681.       /* end dcls */{/*2*/
  682. --- 48,58 ----
  683.   # 38 "example.c"
  684.   int (*(*bar)())();
  685.   {/*1*/
  686. !     int     (*baz)()= (int (*)()) 0,
  687.           y = (y * (*baz)(y)),
  688. !         *(*z)()= (int *(*)()) 0;
  689.   
  690. !     struct {/*2*/ int (*foo)(); }/*2*/ *(*s)()= 
  691.       (struct { int (*foo)(); } *(*)()) 0;
  692.   
  693.       /* end dcls */{/*2*/
  694. ***************
  695. *** 122,128 ****
  696.       struct {/*2*/
  697.       int (*f)(), o;
  698.       }/*2*/ bar;
  699. ! }/*1*/ (*baz2)() = (struct { struct { int (*f)(), o; } bar; } (*)()) 0;
  700.   
  701.   
  702.   
  703. --- 122,128 ----
  704.       struct {/*2*/
  705.       int (*f)(), o;
  706.       }/*2*/ bar;
  707. ! }/*1*/ (*baz2)()= (struct { struct { int (*f)(), o; } bar; } (*)()) 0;
  708.   
  709.   
  710.   
  711. ***************
  712. *** 218,222 ****
  713.   # 186 "example.c"
  714.   {/*1*/}/*1*/
  715.   
  716. ! int (*(*test18[bar])())() =     (int (*(*[bar])())()) 0;
  717.   
  718. --- 218,261 ----
  719.   # 186 "example.c"
  720.   {/*1*/}/*1*/
  721.   
  722. ! int (*(*test18[bar])())()=     (int (*(*[bar])())()) 0;
  723.   
  724. + int (*(*test19())())();
  725. + void test20(test21)
  726. + # 197 "example.c"
  727. + int test21();
  728. + # 197 "example.c"
  729. + {/*1*/}/*1*/
  730. + void test22(test23)
  731. + # 199 "example.c"
  732. + struct { int foo; } test23();
  733. + # 199 "example.c"
  734. + {/*1*/}/*1*/
  735. + void    test23()
  736. + {/*1*/
  737. +     int     (*test24())(),
  738. +             y = (*test24(2)) (3),
  739. +             z = ((*test24(2))(3));
  740. + }/*1*/
  741. + int (*(*test25(foo))())()
  742. + # 212 "example.c"
  743. + long foo;
  744. + # 212 "example.c"
  745. + {/*1*/  }/*1*/
  746. + int (*(*test26(foo))())()
  747. + long foo;
  748. + {/*1*/  }/*1*/
  749. Prereq: 1.4
  750. *** ./unproto.1.old    Wed Jan 15 21:53:22 1992
  751. --- ./unproto.1    Sat Feb 15 17:17:20 1992
  752. ***************
  753. *** 13,18 ****
  754. --- 13,20 ----
  755.   .na
  756.   .nf
  757.   /somewhere/cpp ...
  758. + cc cflags -E file.c | unproto >file.i; cc cflags -c file.i
  759.   .SH DESCRIPTION
  760.   .ad
  761.   .fi
  762. ***************
  763. *** 143,150 ****
  764.   .SH LAST MODIFICATION
  765.   .na
  766.   .nf
  767. ! 92/01/15 21:52:56
  768.   .SH VERSION/RELEASE
  769.   .na
  770.   .nf
  771. ! 1.4
  772. --- 145,152 ----
  773.   .SH LAST MODIFICATION
  774.   .na
  775.   .nf
  776. ! 92/02/15 17:17:09
  777.   .SH VERSION/RELEASE
  778.   .na
  779.   .nf
  780. ! 1.5
  781. *** ./stddef.h.old    Sat Feb 15 17:23:12 1992
  782. --- ./stddef.h    Sat Feb 15 17:25:47 1992
  783. ***************
  784. *** 0 ****
  785. --- 1,23 ----
  786. + /* @(#) stddef.h 1.1 92/02/15 17:25:46 */
  787. + #ifndef _stddef_h_
  788. + #define _stddef_h_
  789. + /* NULL is also defined in <stdio.h> */
  790. + #ifndef NULL
  791. + #define NULL 0
  792. + #endif
  793. + /* Structure member offset - some compilers barf on this. */
  794. + #define offsetof(type, member) ((size_t) &((type *)0)->member)
  795. + /* Some of the following types may already be defined in <sys/types.h>. */
  796. + /* #include <sys/types.h> */
  797. + /* typedef long ptrdiff_t;        /* type of pointer difference */
  798. + /* typedef unsigned short wchar_t;    /* wide character type */
  799. + /* typedef unsigned size_t;        /* type of sizeof */
  800. + #endif /* _stddef_h_ */
  801. Prereq: 1.3
  802. *** symbol.c.old    Wed Jan 15 21:53:09 1992
  803. --- symbol.c    Sat Feb 15 18:59:58 1992
  804. ***************
  805. *** 33,44 ****
  806.   /*    Department of Mathematics and Computer Science
  807.   /*    Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  808.   /* LAST MODIFICATION
  809. ! /*    92/01/15 21:53:08
  810.   /* VERSION/RELEASE
  811. ! /*    1.3
  812.   /*--*/
  813.   
  814. ! static char symbol_sccsid[] = "@(#) symbol.c 1.3 92/01/15 21:53:08";
  815.   
  816.   /* C library */
  817.   
  818. --- 33,44 ----
  819.   /*    Department of Mathematics and Computer Science
  820.   /*    Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  821.   /* LAST MODIFICATION
  822. ! /*    92/02/15 18:59:56
  823.   /* VERSION/RELEASE
  824. ! /*    1.4
  825.   /*--*/
  826.   
  827. ! static char symbol_sccsid[] = "@(#) symbol.c 1.4 92/02/15 18:59:56";
  828.   
  829.   /* C library */
  830.   
  831. ***************
  832. *** 128,133 ****
  833. --- 128,134 ----
  834.   #if defined(MAP_VOID_STAR) || defined(MAP_VOID)
  835.       "void", TOK_VOID,
  836.   #endif
  837. +     "asm", TOK_OTHER,
  838.       0,
  839.   };
  840.   
  841.  
  842. exit 0 # Just in case...
  843.