home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume22 / p2cpatches / part01 next >
Text File  |  1990-06-07  |  30KB  |  878 lines

  1. Subject:  v22i034:  Update kit for p2c Pascal to C translator, Part01/02
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 8d150bd0 6d105e5d ee3f12e0 032ba92d
  5.  
  6. Submitted-by: David Gillespie <daveg@csvax.caltech.edu>
  7. Posting-number: Volume 22, Issue 34
  8. Archive-name: p2cpatches/part01
  9.  
  10. The following patches convert p2c version 1.14 into p2c version 1.15.  To
  11. apply them automatically with Patch v2.0, first cd into your p2c
  12. distribution directory (with subdirectories src, examples, etc.), then
  13. execute "patch -p0 <p2c.patch", where "p2c.patch" is name of this file,
  14. then "cd src" and execute "make install".
  15.  
  16. These patches do not cover the example files, nor reproducible files such
  17. as "p2c.hdrs" and "p2c.cat".  Those files will be rebuilt by "make
  18. install".
  19.  
  20. Enjoy!
  21.                             -- Dave
  22.  
  23. Dave Gillespie
  24. 256-80 Caltech, Pasadena CA 91125
  25. daveg@csvax.caltech.edu, ...!cit-vax!daveg
  26.  
  27.  
  28.  
  29. *** README    Thu Mar 22 14:27:56 1990
  30. --- ../dist/README    Fri Apr 13 20:59:32 1990
  31. ***************
  32. *** 1,5 ****
  33.   
  34. ! This directory contains "p2c" version 1.14, a Pascal to C translator.
  35.   
  36.   "p2c"  Copyright 1989  Dave Gillespie
  37.                          256-80 Caltech
  38. --- 1,5 ----
  39.   
  40. ! This directory contains "p2c" version 1.15, a Pascal to C translator.
  41.   
  42.   "p2c"  Copyright 1989  Dave Gillespie
  43.                          256-80 Caltech
  44. Files Makefile and ../dist/Makefile are identical
  45. Files src/COPYING and ../dist/src/COPYING are identical
  46. diff -c -N -r -s src/HISTORY ../dist/src/HISTORY
  47. *** src/HISTORY    Thu Mar 22 14:27:23 1990
  48. --- ../dist/src/HISTORY    Fri Apr 13 20:58:54 1990
  49. ***************
  50. *** 4,9 ****
  51. --- 4,44 ----
  52.   ------- -- ------- --  ---
  53.   
  54.   
  55. + Version 1.15:
  56. +  * Taught the line breaker to handle logical/relational operators specially.
  57. +  * Improved code generation for large set constructors.
  58. +  * Changed makeexpr_assign to handle EK_LITCAST's on the lefthand side.
  59. +  * Changed makeexpr_addr to handle casts.
  60. +  * Changed FieldMacros so that the substituted base expr retains its type.
  61. +  * Bug fix in p2c.h: Rewrote P_getbits_US and other small-packed-array macros.
  62. +    Symptom: On many architectures, these macros didn't work at all!
  63. +    NOTE: These now pack small arrays in the opposite direction (LSB first).
  64. +  * Bug fix in funcs.c:handleread_text: changed strread of string to use %255s.
  65. +    Symptom: Previous translation of %255c did not append a null character.
  66. +  * Bug fix in p2clib.c:strrtrim: Added test for empty string input.
  67. +    Symptom: Incorrect behavior on strrtrim("").
  68. +  * Bug fix in p2clib.c:P_addsetr: Changed to signed comparison of v1 and v2.
  69. +    Symptom: Adding [0..-1] to a set failed.
  70. +  * Bug fix in p2clib.c:P_expset: Don't write to d[1] if set is empty.
  71. +    Symptom: Sets allocated to store 0 elements didn't work properly.
  72. +  * Added to sys.p2crc/trans.h the following configuration parameters:
  73. +     LogBreakPenalty         Like OpBreakPenalty, but for && and ||.
  74. +     LogBreakExtraPenalty    Like OpBreakExtraPenalty, but for && and ||.
  75. +     RelBreakPenalty         Like OpBreakPenalty, but for <, ==, etc.
  76. +     RelBreakExtraPenalty    Like OpBreakExtraPenalty, but for <, ==, etc.
  77.   Version 1.14:
  78.   
  79.    * Added partial support for Oregon Software Pascal's delete(f) procedure.
  80. ***************
  81. *** 41,47 ****
  82.   
  83.    * Added some extra parentheses to the P_clrbits macros. (!)
  84.   
  85. !  * Added to sys.p2crc/trans.h the following configuration parameter:
  86.   
  87.       CharFileText    Treat "file of char" as identical to "text".
  88.       UseStrncmp        Use strncmp, not memcmp, to compare packed arrays of char.
  89. --- 76,82 ----
  90.   
  91.    * Added some extra parentheses to the P_clrbits macros. (!)
  92.   
  93. !  * Added to sys.p2crc/trans.h the following configuration parameters:
  94.   
  95.       CharFileText    Treat "file of char" as identical to "text".
  96.       UseStrncmp        Use strncmp, not memcmp, to compare packed arrays of char.
  97. Files src/Makefile and ../dist/src/Makefile are identical
  98. Files src/NOTES and ../dist/src/NOTES are identical
  99. Files src/README and ../dist/src/README are identical
  100. Files src/citmods.c and ../dist/src/citmods.c are identical
  101. Files src/comment.c and ../dist/src/comment.c are identical
  102. diff -c -N -r -s src/decl.c ../dist/src/decl.c
  103. *** src/decl.c    Thu Mar 22 14:27:32 1990
  104. --- ../dist/src/decl.c    Fri Apr 13 20:59:09 1990
  105. ***************
  106. *** 2835,2841 ****
  107.       head = NULL;
  108.       for (mp = firstmp; mp; mp = mp->cnext) {
  109.       if (mp->kind == MK_FIELD) {
  110. !         if (mp->val.i == 8 || mp->val.i == 16) {
  111.           if (!head)
  112.               head = mp;
  113.           } else {
  114. --- 2835,2844 ----
  115.       head = NULL;
  116.       for (mp = firstmp; mp; mp = mp->cnext) {
  117.       if (mp->kind == MK_FIELD) {
  118. !         if ((mp->val.i == 8 &&
  119. !          (mp->type == tp_uint ||
  120. !           hassignedchar || signedchars == 1)) ||
  121. !         mp->val.i == 16) {
  122.           if (!head)
  123.               head = mp;
  124.           } else {
  125. Files src/dir.c and ../dist/src/dir.c are identical
  126. diff -c -N -r -s src/expr.c ../dist/src/expr.c
  127. *** src/expr.c    Thu Mar 22 14:27:33 1990
  128. --- ../dist/src/expr.c    Fri Apr 13 20:59:11 1990
  129. ***************
  130. *** 3505,3510 ****
  131. --- 3505,3527 ----
  132.           FREE(a);
  133.           ex->val.type = type;
  134.           return ex;
  135. +     } else if (a->kind == EK_CAST) {
  136. +     return makeexpr_cast(makeexpr_addr(a->args[0]), type);
  137. +     } else if (a->kind == EK_ACTCAST) {
  138. +     return makeexpr_actcast(makeexpr_addr(a->args[0]), type);
  139. +     } else if (a->kind == EK_LITCAST) {
  140. +     if (a->args[0]->kind == EK_NAME) {
  141. +         if (my_strchr(a->args[0]->val.s, '(') ||
  142. +         my_strchr(a->args[0]->val.s, '['))
  143. +         note("Constructing pointer type by adding '*' may be incorrect [322]");
  144. +         return makeexpr_bin(EK_LITCAST, tp_integer,
  145. +                 makeexpr_name(format_s("%s*",
  146. +                                a->args[0]->val.s),
  147. +                           tp_integer),
  148. +                 makeexpr_addr(a->args[1]));
  149. +     } else
  150. +         return makeexpr_bin(EK_LITCAST, tp_integer, makeexpr_type(type),
  151. +                 makeexpr_addr(a->args[1]));
  152.       } else {
  153.           switch (a->val.type->kind) {
  154.           
  155. ***************
  156. *** 4088,4094 ****
  157. --- 4105,4120 ----
  158.   }
  159.   
  160.   
  161. + Meaning *totempvar(ex)
  162. + Expr *ex;
  163. + {
  164. +     while (structuredfunc(ex))
  165. +     ex = ex->args[0];
  166. +     return istempvar(ex);
  167. + }
  168.   
  169.   Meaning *isretvar(ex)
  170.   Expr *ex;
  171.   {
  172. ***************
  173. *** 4416,4432 ****
  174.           return a;
  175.       }
  176.       }
  177. !     while (a->kind == EK_CAST || a->kind == EK_ACTCAST) {
  178. !     if (ansiC < 2 ||     /* in GNU C, a cast is an lvalue */
  179. !         isarithkind(a->args[0]->kind) ||
  180. !         (a->val.type->kind == TK_POINTER &&
  181. !          a->args[0]->val.type->kind == TK_POINTER)) {
  182.           if (a->kind == EK_CAST)
  183.           b = makeexpr_cast(b, a->args[0]->val.type);
  184.           else
  185.           b = makeexpr_actcast(b, a->args[0]->val.type);
  186. !             a = grabarg(a, 0);
  187. !         } else
  188.           break;
  189.       }
  190.       if (a->kind == EK_NEG)
  191. --- 4442,4462 ----
  192.           return a;
  193.       }
  194.       }
  195. !     while (a->kind == EK_CAST || a->kind == EK_ACTCAST ||
  196. !        a->kind == EK_LITCAST) {
  197. !     if (a->kind == EK_LITCAST) {
  198. !         b = makeexpr_cast(b, a->args[1]->val.type);
  199. !         a = grabarg(a, 1);
  200. !     } else if (ansiC < 2 ||    /* in GNU C, a cast is an lvalue */
  201. !            isarithkind(a->args[0]->kind) ||
  202. !            (a->val.type->kind == TK_POINTER &&
  203. !             a->args[0]->val.type->kind == TK_POINTER)) {
  204.           if (a->kind == EK_CAST)
  205.           b = makeexpr_cast(b, a->args[0]->val.type);
  206.           else
  207.           b = makeexpr_actcast(b, a->args[0]->val.type);
  208. !         a = grabarg(a, 0);
  209. !     } else
  210.           break;
  211.       }
  212.       if (a->kind == EK_NEG)
  213. ***************
  214. *** 4928,4934 ****
  215.       if (mp->constdefn) {
  216.           nex = makeexpr(EK_MACARG, 0);
  217.           nex->val.type = tp_integer;
  218. !         ex3 = replaceexprexpr(copyexpr(mp->constdefn), nex, ex);
  219.           freeexpr(ex);
  220.           freeexpr(nex);
  221.           ex = gentle_cast(ex3, mp->val.type);
  222. --- 4958,4964 ----
  223.       if (mp->constdefn) {
  224.           nex = makeexpr(EK_MACARG, 0);
  225.           nex->val.type = tp_integer;
  226. !         ex3 = replaceexprexpr(copyexpr(mp->constdefn), nex, ex, 0);
  227.           freeexpr(ex);
  228.           freeexpr(nex);
  229.           ex = gentle_cast(ex3, mp->val.type);
  230. diff -c -N -r -s src/funcs.c ../dist/src/funcs.c
  231. *** src/funcs.c    Thu Mar 22 14:27:36 1990
  232. --- ../dist/src/funcs.c    Fri Apr 13 20:59:13 1990
  233. ***************
  234. *** 3239,3245 ****
  235.                       break;
  236.   
  237.                   case TK_STRING:     /* strread only */
  238. !                     ex = makeexpr_string(format_d("%%%dc", strmax(fex)));
  239.                       break;
  240.   
  241.                   case TK_ARRAY:      /* strread only */
  242. --- 3239,3245 ----
  243.                       break;
  244.   
  245.                   case TK_STRING:     /* strread only */
  246. !                     ex = makeexpr_string(format_d("%%%lds", strmax(fex)));
  247.                       break;
  248.   
  249.                   case TK_ARRAY:      /* strread only */
  250. Files src/hpmods.c and ../dist/src/hpmods.c are identical
  251. Files src/lex.c and ../dist/src/lex.c are identical
  252. Files src/loc.p2clib.c and ../dist/src/loc.p2clib.c are identical
  253. Files src/loc.p2crc and ../dist/src/loc.p2crc are identical
  254. Files src/makeproto.c and ../dist/src/makeproto.c are identical
  255. diff -c -N -r -s src/out.c ../dist/src/out.c
  256. *** src/out.c    Thu Mar 22 14:27:28 1990
  257. --- ../dist/src/out.c    Fri Apr 13 20:59:05 1990
  258. ***************
  259. *** 534,539 ****
  260. --- 534,540 ----
  261.   
  262.   
  263.   
  264.   /* The following routine explores the tree of all possible line breaks,
  265.      pruning according to the fact that "badness" and "extra" are
  266.      increasing functions.  The object is to find the set of breaks and
  267. ***************
  268. *** 802,807 ****
  269. --- 803,823 ----
  270.               penalty += parenbreakpenalty + parenbreakextrapenalty*i;
  271.           else if (outbuf[pos-2] == ',')
  272.               penalty += commabreakpenalty + commabreakextrapenalty*i;
  273. +         else if (((outbuf[pos] == '&' || outbuf[pos] == '|') &&
  274. +               outbuf[pos+1] == outbuf[pos]) ||
  275. +              ((outbuf[pos-3] == '&' || outbuf[pos-3] == '|') &&
  276. +               outbuf[pos-3] == outbuf[pos-2]))
  277. +             penalty += logbreakpenalty + logbreakextrapenalty*i;
  278. +         else if (((outbuf[pos] == '<' || outbuf[pos] == '>') &&
  279. +               outbuf[pos+1] != outbuf[pos]) ||
  280. +              ((outbuf[pos] == '=' || outbuf[pos] == '!') &&
  281. +               outbuf[pos+1] == '=') ||
  282. +              ((outbuf[pos-2] == '<' || outbuf[pos-2] == '>') &&
  283. +               outbuf[pos-3] != outbuf[pos-2]) ||
  284. +              ((outbuf[pos-3] == '<' || outbuf[pos-3] == '>' ||
  285. +                outbuf[pos-3] == '=' || outbuf[pos-3] == '!') &&
  286. +               outbuf[pos-2] == '='))
  287. +             penalty += relbreakpenalty + relbreakextrapenalty*i;
  288.           else if (outbuf[pos-2] == '=')
  289.               penalty += assignbreakpenalty + assignbreakextrapenalty*i;
  290.           else if (outbuf[pos] == '?') {
  291. diff -c -N -r -s src/p2c.h ../dist/src/p2c.h
  292. *** src/p2c.h    Thu Mar 22 14:27:39 1990
  293. --- ../dist/src/p2c.h    Fri Apr 13 20:59:19 1990
  294. ***************
  295. *** 4,10 ****
  296.   
  297.   /* Header file for code generated by "p2c", the Pascal-to-C translator */
  298.   
  299. ! /* "p2c"  Copyright (C) 1989 Dave Gillespie, version 1.14.
  300.    * This file may be copied, modified, etc. in any way.  It is not restricted
  301.    * by the licence agreement accompanying p2c itself.
  302.    */
  303. --- 4,10 ----
  304.   
  305.   /* Header file for code generated by "p2c", the Pascal-to-C translator */
  306.   
  307. ! /* "p2c"  Copyright (C) 1989 Dave Gillespie, version 1.15.
  308.    * This file may be copied, modified, etc. in any way.  It is not restricted
  309.    * by the licence agreement accompanying p2c itself.
  310.    */
  311. ***************
  312. *** 250,255 ****
  313. --- 250,256 ----
  314.   extern Void     P_readpaoc  PP( (FILE *, Char *, int) );
  315.   extern Void     P_readlnpaoc PP( (FILE *, Char *, int) );
  316.   extern long     P_maxpos    PP( (FILE *) );
  317. + extern Char    *P_trimname  PP( (Char *, int) );
  318.   extern long    *P_setunion  PP( (long *, long *, long *) );
  319.   extern long    *P_setint    PP( (long *, long *, long *) );
  320.   extern long    *P_setdiff   PP( (long *, long *, long *) );
  321. ***************
  322. *** 351,361 ****
  323.                      (((~(i))&((1<<(L)-(n))-1)) << (n))) )
  324.   
  325.   /* small packed arrays */
  326. ! #define P_getbits_US(v,i,n)     ((int)((v) >> (~(i) << (n)) & (1<<(1<<(n)))-1))
  327. ! #define P_getbits_SS(v,i,n)     ((int)((long)(v) << (32 - (((~(i))+1) << (n))) >> (32-(1<<(n)))))
  328. ! #define P_putbits_US(v,i,x,n)   ((v) |= (x) << (~(i) << (n)))
  329. ! #define P_putbits_SS(v,i,x,n)   ((v) |= ((x) & (1<<(1<<(n)))-1) << (~(i) << (n)))
  330. ! #define P_clrbits_S(v,i,n)      ((v) &= ~( ((1<<(1<<(n)))-1) << (~(i) << (n)) ))
  331.   
  332.   #define P_max(a,b)   ((a) > (b) ? (a) : (b))
  333.   #define P_min(a,b)   ((a) < (b) ? (a) : (b))
  334. --- 352,362 ----
  335.                      (((~(i))&((1<<(L)-(n))-1)) << (n))) )
  336.   
  337.   /* small packed arrays */
  338. ! #define P_getbits_US(v,i,n)     ((int)((v) >> ((i)<<(n)) & (1<<(1<<(n)))-1))
  339. ! #define P_getbits_SS(v,i,n)     ((int)((long)(v) << (SETBITS - (((i)+1) << (n))) >> (SETBITS-(1<<(n)))))
  340. ! #define P_putbits_US(v,i,x,n)   ((v) |= (x) << ((i) << (n)))
  341. ! #define P_putbits_SS(v,i,x,n)   ((v) |= ((x) & (1<<(1<<(n)))-1) << ((i)<<(n)))
  342. ! #define P_clrbits_S(v,i,n)      ((v) &= ~( ((1<<(1<<(n)))-1) << ((i)<<(n)) ))
  343.   
  344.   #define P_max(a,b)   ((a) > (b) ? (a) : (b))
  345.   #define P_min(a,b)   ((a) < (b) ? (a) : (b))
  346. diff -c -N -r -s src/p2c.man ../dist/src/p2c.man
  347. *** src/p2c.man    Thu Mar 22 14:27:24 1990
  348. --- ../dist/src/p2c.man    Fri Apr 13 20:58:58 1990
  349. ***************
  350. *** 1,7 ****
  351.   .\" p2c  Copyright 1989 Dave Gillespie
  352.   .TH P2C 1 "local"
  353.   .SH NAME
  354. ! p2c \- Pascal to C translator, version 1.14
  355.   .SH SYNOPSIS
  356.   .B p2c
  357.   [ options ] [ file [ module ] ]
  358. --- 1,7 ----
  359.   .\" p2c  Copyright 1989 Dave Gillespie
  360.   .TH P2C 1 "local"
  361.   .SH NAME
  362. ! p2c \- Pascal to C translator, version 1.15
  363.   .SH SYNOPSIS
  364.   .B p2c
  365.   [ options ] [ file [ module ] ]
  366. diff -c -N -r -s src/p2clib.c ../dist/src/p2clib.c
  367. *** src/p2clib.c    Thu Mar 22 14:27:38 1990
  368. --- ../dist/src/p2clib.c    Fri Apr 13 20:59:15 1990
  369. ***************
  370. *** 236,241 ****
  371. --- 236,243 ----
  372.   {
  373.       register char *s2 = s;
  374.   
  375. +     if (!*s)
  376. +     return s;
  377.       while (*++s2) ;
  378.       while (s2 > s && Isspace(*--s2))
  379.           *s2 = 0;
  380. ***************
  381. *** 474,485 ****
  382.   
  383.   /* Use packed array of char for a file name. */
  384.   
  385. ! char *P_trimname(fn, len)
  386. ! register char *fn;
  387.   register int len;
  388.   {
  389. !     static char fnbuf[256];
  390. !     register char *cp = fnbuf;
  391.       
  392.       while (--len >= 0 && *fn && !isspace(*fn))
  393.       *cp++ = *fn++;
  394. --- 476,487 ----
  395.   
  396.   /* Use packed array of char for a file name. */
  397.   
  398. ! Char *P_trimname(fn, len)
  399. ! register Char *fn;
  400.   register int len;
  401.   {
  402. !     static Char fnbuf[256];
  403. !     register Char *cp = fnbuf;
  404.       
  405.       while (--len >= 0 && *fn && !isspace(*fn))
  406.       *cp++ = *fn++;
  407. ***************
  408. *** 620,626 ****
  409.   {
  410.       register long *sbase = s;
  411.       register int b1, b2, size;
  412. !     if (v1 > v2)
  413.       return sbase;
  414.       b1 = v1 % SETBITS;
  415.       v1 /= SETBITS;
  416. --- 622,628 ----
  417.   {
  418.       register long *sbase = s;
  419.       register int b1, b2, size;
  420. !     if ((int)v1 > (int)v2)
  421.       return sbase;
  422.       b1 = v1 % SETBITS;
  423.       v1 /= SETBITS;
  424. ***************
  425. *** 709,719 ****
  426.   
  427.   long *P_expset(d, s)                /* d := s */
  428.   register long *d;
  429. ! long s;
  430.   {
  431. !     if ((d[1] = s))
  432. !         *d = 1;
  433. !     else
  434.           *d = 0;
  435.       return d;
  436.   }
  437. --- 711,722 ----
  438.   
  439.   long *P_expset(d, s)                /* d := s */
  440.   register long *d;
  441. ! register long s;
  442.   {
  443. !     if (s) {
  444. !     d[1] = s;
  445. !     *d = 1;
  446. !     } else
  447.           *d = 0;
  448.       return d;
  449.   }
  450. diff -c -N -r -s src/parse.c ../dist/src/parse.c
  451. *** src/parse.c    Thu Mar 22 14:27:30 1990
  452. --- ../dist/src/parse.c    Fri Apr 13 20:59:08 1990
  453. ***************
  454. *** 1742,1755 ****
  455.   
  456.   /* Replace all occurrences of one expression with another expression */
  457.   
  458. ! Expr *replaceexprexpr(ex, oldex, newex)
  459.   Expr *ex, *oldex, *newex;
  460.   {
  461.       int i;
  462.       Type *type;
  463.   
  464.       for (i = 0; i < ex->nargs; i++)
  465. !         ex->args[i] = replaceexprexpr(ex->args[i], oldex, newex);
  466.       if (exprsame(ex, oldex, 2)) {
  467.           if (ex->val.type->kind == TK_POINTER &&
  468.               ex->val.type->basetype == oldex->val.type) {
  469. --- 1742,1756 ----
  470.   
  471.   /* Replace all occurrences of one expression with another expression */
  472.   
  473. ! Expr *replaceexprexpr(ex, oldex, newex, keeptype)
  474.   Expr *ex, *oldex, *newex;
  475. + int keeptype;
  476.   {
  477.       int i;
  478.       Type *type;
  479.   
  480.       for (i = 0; i < ex->nargs; i++)
  481. !         ex->args[i] = replaceexprexpr(ex->args[i], oldex, newex, keeptype);
  482.       if (exprsame(ex, oldex, 2)) {
  483.           if (ex->val.type->kind == TK_POINTER &&
  484.               ex->val.type->basetype == oldex->val.type) {
  485. ***************
  486. *** 1763,1769 ****
  487.           type = ex->val.type;
  488.               freeexpr(ex);
  489.               ex = copyexpr(newex);
  490. !         ex->val.type = type;
  491.           return ex;
  492.           }
  493.       }
  494. --- 1764,1771 ----
  495.           type = ex->val.type;
  496.               freeexpr(ex);
  497.               ex = copyexpr(newex);
  498. !         if (keeptype)
  499. !         ex->val.type = type;
  500.           return ex;
  501.           }
  502.       }
  503. ***************
  504. *** 1779,1789 ****
  505.           replaceexpr(sp->stm1, oldex, newex);
  506.           replaceexpr(sp->stm2, oldex, newex);
  507.           if (sp->exp1)
  508. !             sp->exp1 = replaceexprexpr(sp->exp1, oldex, newex);
  509.           if (sp->exp2)
  510. !             sp->exp2 = replaceexprexpr(sp->exp2, oldex, newex);
  511.           if (sp->exp3)
  512. !             sp->exp3 = replaceexprexpr(sp->exp3, oldex, newex);
  513.           sp = sp->next;
  514.       }
  515.   }
  516. --- 1781,1791 ----
  517.           replaceexpr(sp->stm1, oldex, newex);
  518.           replaceexpr(sp->stm2, oldex, newex);
  519.           if (sp->exp1)
  520. !             sp->exp1 = replaceexprexpr(sp->exp1, oldex, newex, 1);
  521.           if (sp->exp2)
  522. !             sp->exp2 = replaceexprexpr(sp->exp2, oldex, newex, 1);
  523.           if (sp->exp3)
  524. !             sp->exp3 = replaceexprexpr(sp->exp3, oldex, newex, 1);
  525.           sp = sp->next;
  526.       }
  527.   }
  528. ***************
  529. *** 1814,1820 ****
  530.            exproccurs(sp->next->exp1->args[1], sp->exp1->args[0]) == 1) {
  531.           sp->next->exp1->args[1] = replaceexprexpr(sp->next->exp1->args[1],
  532.                                                     sp->exp1->args[0],
  533. !                                                   sp->exp1->args[1]);
  534.           if (mp && mp->istemporary)
  535.               canceltempvar(mp);
  536.           return sp->next;
  537. --- 1816,1822 ----
  538.            exproccurs(sp->next->exp1->args[1], sp->exp1->args[0]) == 1) {
  539.           sp->next->exp1->args[1] = replaceexprexpr(sp->next->exp1->args[1],
  540.                                                     sp->exp1->args[0],
  541. !                                                   sp->exp1->args[1], 1);
  542.           if (mp && mp->istemporary)
  543.               canceltempvar(mp);
  544.           return sp->next;
  545. ***************
  546. *** 1992,1998 ****
  547.           case EK_NE:                 /* (a<>b) -> c2 */
  548.               if ((c1->kind == EK_NE) == not1) {
  549.                   if (c1->args[0]->kind == EK_VAR) {
  550. !                     ex = replaceexprexpr(copyexpr(c2), c1->args[0], c1->args[1]);
  551.                       i = expr_is_bool(ex, !not2);
  552.                       freeexpr(ex);
  553.                       if (i)
  554. --- 1994,2000 ----
  555.           case EK_NE:                 /* (a<>b) -> c2 */
  556.               if ((c1->kind == EK_NE) == not1) {
  557.                   if (c1->args[0]->kind == EK_VAR) {
  558. !                     ex = replaceexprexpr(copyexpr(c2), c1->args[0], c1->args[1], 1);
  559.                       i = expr_is_bool(ex, !not2);
  560.                       freeexpr(ex);
  561.                       if (i)
  562. ***************
  563. *** 1999,2005 ****
  564.                           return 1;
  565.                   }
  566.                   if (c1->args[1]->kind == EK_VAR) {
  567. !                     ex = replaceexprexpr(copyexpr(c2), c1->args[1], c1->args[0]);
  568.                       i = expr_is_bool(ex, !not2);
  569.                       freeexpr(ex);
  570.                       if (i)
  571. --- 2001,2007 ----
  572.                           return 1;
  573.                   }
  574.                   if (c1->args[1]->kind == EK_VAR) {
  575. !                     ex = replaceexprexpr(copyexpr(c2), c1->args[1], c1->args[0], 1);
  576.                       i = expr_is_bool(ex, !not2);
  577.                       freeexpr(ex);
  578.                       if (i)
  579. diff -c -N -r -s src/pexpr.c ../dist/src/pexpr.c
  580. *** src/pexpr.c    Thu Mar 22 14:27:34 1990
  581. --- ../dist/src/pexpr.c    Fri Apr 13 20:59:12 1990
  582. ***************
  583. *** 343,349 ****
  584.       mp = makestmttempvar(ex->val.type, name_SET);
  585.           ex2 = makeexpr(EK_MACARG, 0);
  586.           ex2->val.type = ex->val.type;
  587. !     ex = replaceexprexpr(ex, ex2, makeexpr_var(mp));
  588.           freeexpr(ex2);
  589.       } else if (mp->kind == MK_CONST &&
  590.                  (mp == mp_false ||
  591. --- 343,349 ----
  592.       mp = makestmttempvar(ex->val.type, name_SET);
  593.           ex2 = makeexpr(EK_MACARG, 0);
  594.           ex2->val.type = ex->val.type;
  595. !     ex = replaceexprexpr(ex, ex2, makeexpr_var(mp), 0);
  596.           freeexpr(ex2);
  597.       } else if (mp->kind == MK_CONST &&
  598.                  (mp == mp_false ||
  599. ***************
  600. *** 2158,2173 ****
  601.   Expr *ex;
  602.   int env;
  603.   {
  604. !     Expr *ex2, *ex3, **ep;
  605.       Type *type, *type2;
  606. -     Meaning *mp;
  607.       char *cp;
  608.       char sbuf[5];
  609. !     int i;
  610.       Value val;
  611.   
  612.       if (!ex)
  613.           return NULL;
  614.       switch (ex->kind) {
  615.   
  616.           case EK_BICALL:
  617. --- 2158,2173 ----
  618.   Expr *ex;
  619.   int env;
  620.   {
  621. !     Expr *ex2, *ex3;
  622.       Type *type, *type2;
  623.       char *cp;
  624.       char sbuf[5];
  625. !     int i, j;
  626.       Value val;
  627.   
  628.       if (!ex)
  629.           return NULL;
  630. +     if (debug>4) {fprintf(outf, "fixexpr("); dumpexpr(ex); fprintf(outf, ")\n");}
  631.       switch (ex->kind) {
  632.   
  633.           case EK_BICALL:
  634. ***************
  635. *** 2208,2213 ****
  636. --- 2208,2267 ----
  637.                   ex = makeexpr_cond(ex->args[0], ex->args[2], ex2);
  638.               } else if (!strcmp(cp, "assert")) {
  639.                   ex->args[0] = fixexpr(ex->args[0], ENV_BOOL);
  640. +         } else if ((!strcmp(cp, setaddname) ||
  641. +             !strcmp(cp, setaddrangename)) &&
  642. +                (ex2 = ex->args[0])->kind == EK_BICALL &&
  643. +                (!strcmp(ex2->val.s, setaddname) ||
  644. +             !strcmp(ex2->val.s, setaddrangename))) {
  645. +         while (ex2->kind == EK_BICALL &&
  646. +                (!strcmp(ex2->val.s, setaddname) ||
  647. +             !strcmp(ex2->val.s, setaddrangename) ||
  648. +             !strcmp(ex2->val.s, setexpandname)))
  649. +             ex2 = ex2->args[0];
  650. +         if (nosideeffects(ex2, 1)) {
  651. +             ex = makeexpr_comma(ex->args[0], ex);
  652. +             ex->args[1]->args[0] = ex2;
  653. +             ex = fixexpr(ex, env);
  654. +         } else
  655. +             for (i = 0; i < ex->nargs; i++)
  656. +             ex->args[i] = fixexpr(ex->args[i], ENV_EXPR);
  657. +         } else if (!strcmp(cp, setunionname) &&
  658. +                (ex3 = singlevar(ex->args[0])) != NULL &&
  659. +                ((i=1, exprsame(ex->args[0], ex->args[i], 0)) ||
  660. +             (i=2, exprsame(ex->args[0], ex->args[i], 0))) &&
  661. +                !exproccurs(ex3, ex->args[3-i]) &&
  662. +                ex->args[3-i]->kind == EK_BICALL &&
  663. +                (!strcmp(ex->args[3-i]->val.s, setaddname) ||
  664. +             !strcmp(ex->args[3-i]->val.s, setaddrangename) ||
  665. +             (!strcmp(ex->args[3-i]->val.s, setexpandname) &&
  666. +              checkconst(ex->args[3-i]->args[1], 0))) &&
  667. +                totempvar(ex->args[3-i])) {
  668. +         if (!strcmp(ex->args[3-i]->val.s, setexpandname)) {
  669. +             ex = grabarg(ex, 0);
  670. +         } else {
  671. +             ex = makeexpr_comma(ex, ex->args[3-i]);
  672. +             ex->args[0]->args[3-i] = ex->args[1]->args[0];
  673. +             ex->args[1]->args[0] = copyexpr(ex->args[0]->args[0]);
  674. +         }
  675. +         ex = fixexpr(ex, env);
  676. +         } else if (!strcmp(cp, setdiffname) && *setremname &&
  677. +                (ex3 = singlevar(ex->args[0])) != NULL &&
  678. +                exprsame(ex->args[0], ex->args[1], 0) &&
  679. +                !exproccurs(ex3, ex->args[2]) &&
  680. +                ex->args[2]->kind == EK_BICALL &&
  681. +                (!strcmp(ex->args[2]->val.s, setaddname) ||
  682. +             (!strcmp(ex->args[2]->val.s, setexpandname) &&
  683. +              checkconst(ex->args[2]->args[1], 0))) &&
  684. +                totempvar(ex->args[2])) {
  685. +         if (!strcmp(ex->args[2]->val.s, setexpandname)) {
  686. +             ex = grabarg(ex, 0);
  687. +         } else {
  688. +             ex = makeexpr_comma(ex, ex->args[2]);
  689. +             ex->args[0]->args[2] = ex->args[1]->args[0];
  690. +             ex->args[1]->args[0] = copyexpr(ex->args[0]->args[0]);
  691. +             strchange(&ex->args[1]->val.s, setremname);
  692. +         }
  693. +         ex = fixexpr(ex, env);
  694.               } else {
  695.                   for (i = 0; i < ex->nargs; i++)
  696.                       ex->args[i] = fixexpr(ex->args[i], ENV_EXPR);
  697. ***************
  698. *** 2241,2246 ****
  699. --- 2295,2301 ----
  700.                           if (env != ENV_STMT)
  701.                               ex = makeexpr_comma(ex, copyexpr(ex->args[1]));
  702.                       }
  703. + #if 0
  704.           } else if (!strcmp(cp, setunionname) &&
  705.                  (ex3 = singlevar(ex->args[0])) != NULL &&
  706.                  ((i=1, exprsame(ex->args[0], ex->args[i], 0)) ||
  707. ***************
  708. *** 2289,2294 ****
  709. --- 2344,2350 ----
  710.                   ex = ex->args[2];
  711.               }
  712.               }
  713. + #endif
  714.                   } else if (!strcmp(cp, setexpandname) && env == ENV_STMT &&
  715.                              checkconst(ex->args[1], 0)) {
  716.                       ex = makeexpr_assign(makeexpr_hat(ex->args[0], 0),
  717. ***************
  718. *** 2423,2436 ****
  719.               break;
  720.   
  721.           case EK_COMMA:
  722. !             for (i = 0; i < ex->nargs-1; ) {
  723. !                 ex->args[i] = fixexpr(ex->args[i], ENV_STMT);
  724. !                 if (nosideeffects(ex->args[i], 1))
  725.                       delfreearg(&ex, i);
  726. !                 else
  727.                       i++;
  728.               }
  729. -             ex->args[ex->nargs-1] = fixexpr(ex->args[ex->nargs-1], env);
  730.               if (ex->nargs == 1)
  731.                   ex = grabarg(ex, 0);
  732.               break;
  733. --- 2479,2498 ----
  734.               break;
  735.   
  736.           case EK_COMMA:
  737. !             for (i = 0; i < ex->nargs; ) {
  738. !         j = (i < ex->nargs-1);
  739. !                 ex->args[i] = fixexpr(ex->args[i], j ? ENV_STMT : env);
  740. !                 if (nosideeffects(ex->args[i], 1) && j) {
  741.                       delfreearg(&ex, i);
  742. !                 } else if (ex->args[i]->kind == EK_COMMA) {
  743. !             ex2 = ex->args[i];
  744. !             ex->args[i++] = ex2->args[0];
  745. !             for (j = 1; j < ex2->nargs; j++)
  746. !             insertarg(&ex, i++, ex2->args[j]);
  747. !             FREE(ex2);
  748. !         } else
  749.                       i++;
  750.               }
  751.               if (ex->nargs == 1)
  752.                   ex = grabarg(ex, 0);
  753.               break;
  754. ***************
  755. *** 2470,2475 ****
  756. --- 2532,2538 ----
  757.                   ex->args[i] = fixexpr(ex->args[i], ENV_EXPR);
  758.               break;
  759.       }
  760. +     if (debug>4) {fprintf(outf, "fixexpr returns "); dumpexpr(ex); fprintf(outf, "\n");}
  761.       return fix_expression(ex, env);
  762.   }
  763.   
  764. Files src/string.pas and ../dist/src/string.pas are identical
  765. Files src/stuff.c and ../dist/src/stuff.c are identical
  766. diff -c -N -r -s src/sys.p2crc ../dist/src/sys.p2crc
  767. *** src/sys.p2crc    Thu Mar 22 14:27:26 1990
  768. --- ../dist/src/sys.p2crc    Fri Apr 13 20:59:02 1990
  769. ***************
  770. *** 1,4 ****
  771. ! # Standard configuration file for "p2c" 1.14, the Pascal to C translator
  772.   #  Copyright (C) 1989 David Gillespie.
  773.   #  Author's address: daveg@csvax.caltech.edu; 256-80 Caltech/Pasadena CA 91125.
  774.   
  775. --- 1,4 ----
  776. ! # Standard configuration file for "p2c" 1.15, the Pascal to C translator
  777.   #  Copyright (C) 1989 David Gillespie.
  778.   #  Author's address: daveg@csvax.caltech.edu; 256-80 Caltech/Pasadena CA 91125.
  779.   
  780. ***************
  781. *** 412,417 ****
  782. --- 412,429 ----
  783.   
  784.   OpBreakExtraPenalty             # Additional penalty multiplied by nesting
  785.                                   # level of the operator.  Default=20.
  786. + LogBreakPenalty            # Penalty for breaking at an && or || operator.
  787. +                 # Default=5.
  788. + LogBreakExtraPenalty        # Additional penalty multiplied by nesting
  789. +                 # level of the logical operator.  Default=1.
  790. + LogBreakPenalty            # Penalty for breaking at a relational
  791. +                 # operator.  Default=20.
  792. + LogBreakExtraPenalty        # Additional penalty multiplied by nesting
  793. +                 # level of the relational op.  Default=10.
  794.   
  795.   ExHyphenPenalty                 # Additional penalty for breaking a line just
  796.                                   # after a minus sign.  Default=10.  :-)
  797. Files src/system.imp and ../dist/src/system.imp are identical
  798. Files src/system.m2 and ../dist/src/system.m2 are identical
  799. Files src/trans.c and ../dist/src/trans.c are identical
  800. diff -c -N -r -s src/trans.h ../dist/src/trans.h
  801. *** src/trans.h    Thu Mar 22 14:27:40 1990
  802. --- ../dist/src/trans.h    Fri Apr 13 20:59:22 1990
  803. ***************
  804. *** 1,4 ****
  805. ! /* "p2c", a Pascal to C translator, version 1.14.
  806.      Copyright (C) 1989 David Gillespie.
  807.      Author's address: daveg@csvax.caltech.edu; 256-80 Caltech/Pasadena CA 91125.
  808.   
  809. --- 1,4 ----
  810. ! /* "p2c", a Pascal to C translator, version 1.15.
  811.      Copyright (C) 1989 David Gillespie.
  812.      Author's address: daveg@csvax.caltech.edu; 256-80 Caltech/Pasadena CA 91125.
  813.   
  814. ***************
  815. *** 134,140 ****
  816.   extern char *p2c_home;
  817.   #endif
  818.   
  819. ! #define P2C_VERSION  "1.14"
  820.   
  821.   
  822.   
  823. --- 134,140 ----
  824.   extern char *p2c_home;
  825.   #endif
  826.   
  827. ! #define P2C_VERSION  "1.15"
  828.   
  829.   
  830.   
  831. ***************
  832. *** 1064,1069 ****
  833. --- 1064,1071 ----
  834.   extern double assignbreakpenalty, assignbreakextrapenalty;
  835.   extern double specialargbreakpenalty;
  836.   extern double opbreakpenalty, opbreakextrapenalty, exhyphenpenalty;
  837. + extern double logbreakpenalty, logbreakextrapenalty;
  838. + extern double relbreakpenalty, relbreakextrapenalty;
  839.   extern double morebreakpenalty, morebreakextrapenalty;
  840.   extern double parenbreakpenalty, parenbreakextrapenalty;
  841.   extern double qmarkbreakpenalty, qmarkbreakextrapenalty;
  842. ***************
  843. *** 1253,1258 ****
  844. --- 1255,1264 ----
  845.       'R', 'V', "SPECIALARGBREAKPENALTY",(anyptr) &specialargbreakpenalty,   500,
  846.       'R', 'V', "OPBREAKPENALTY",        (anyptr) &opbreakpenalty,          2500,
  847.       'R', 'V', "OPBREAKEXTRAPENALTY",   (anyptr) &opbreakextrapenalty,     2000,
  848. +     'R', 'V', "LOGBREAKPENALTY",       (anyptr) &logbreakpenalty,          500,
  849. +     'R', 'V', "LOGBREAKEXTRAPENALTY",  (anyptr) &logbreakextrapenalty,     100,
  850. +     'R', 'V', "RELBREAKPENALTY",       (anyptr) &relbreakpenalty,         2000,
  851. +     'R', 'V', "RELBREAKEXTRAPENALTY",  (anyptr) &relbreakextrapenalty,    1000,
  852.       'R', 'V', "EXHYPHENPENALTY",       (anyptr) &exhyphenpenalty,         1000,
  853.       'R', 'V', "MOREBREAKPENALTY",      (anyptr) &morebreakpenalty,        -500,
  854.       'R', 'V', "MOREBREAKEXTRAPENALTY", (anyptr) &morebreakextrapenalty,   -300,
  855. Files src/turbo.imp and ../dist/src/turbo.imp are identical
  856.  
  857. exit 0 # Just in case...
  858.