Annotation of researchv10no/cmd/gre/gre.bundle, revision 1.1

1.1     ! root        1: mkdir regress.d
        !             2: # To unbundle, sh this file
        !             3: echo main.c 1>&2
        !             4: sed 's/.//' >main.c <<'//GO.SYSIN DD main.c'
        !             5: -#define       MAIN    1
        !             6: -#include      <ctype.h>
        !             7: -#include      "re.h"
        !             8: -#include      "lre.h"
        !             9: -#include      "hdr.h"
        !            10: -
        !            11: -/* handle void* which didn't exist prior to ANSI C and C++ */
        !            12: -#if defined(__STDC__) || defined(c_plusplus) || defined(__cplusplus)
        !            13: -# define VOID void
        !            14: -#else
        !            15: -# define VOID char
        !            16: -#endif
        !            17: -
        !            18: -static enum { gre, grep, egrep, fgrep } whoami = gre;
        !            19: -static char fullopts[] = "e:f:1bcEFGhilLnsvx";
        !            20: -static char *opts = fullopts+4;                       /* start in after last : */
        !            21: -
        !            22: -static void
        !            23: -usage(void)
        !            24: -{
        !            25: -      EPR "usage: %s [ -%s ] [ -e pattern ] [ -f file ] [ pattern ] [ file ] ...\n", progname, opts);
        !            26: -      exit(2);
        !            27: -}
        !            28: -
        !            29: -#ifdef        PROFILING
        !            30: -short profb[50000];
        !            31: -#endif
        !            32: -
        !            33: -main(int argc, char **argv)
        !            34: -{
        !            35: -      register c;
        !            36: -      int errflg = 0;
        !            37: -      char *input = 0, *finput = 0;
        !            38: -      int k, sval;
        !            39: -      unsigned char map[256];
        !            40: -      int foundsome = 0;
        !            41: -      PROCFN procfn;
        !            42: -      RDFN rdfn;
        !            43: -      MATCHFN matchfn;
        !            44: -      VOID *pat;
        !            45: -
        !            46: -#ifdef        PROFILING
        !            47: -      { extern etext(); monitor((int (*)())2, etext, profb, ((int)etext) - 2+12+2400, 300); }
        !            48: -#endif
        !            49: -
        !            50: -/*re_debug=20;/**/
        !            51: -      /*
        !            52: -              determine if we are to be restricted to compatability mode
        !            53: -      */
        !            54: -      if(progname = strrchr(argv[0], '/'))
        !            55: -              progname++;
        !            56: -      else
        !            57: -              progname = argv[0];
        !            58: -#ifdef        PLAN9
        !            59: -      if(strcmp(progname, "ogrep") == 0)
        !            60: -#else
        !            61: -      if(strcmp(progname, "grep") == 0)
        !            62: -#endif
        !            63: -              whoami = grep;
        !            64: -      else if(strcmp(progname, "egrep") == 0)
        !            65: -              whoami = egrep;
        !            66: -      else if(strcmp(progname, "fgrep") == 0)
        !            67: -              whoami = fgrep;
        !            68: -      offsetunit = (whoami == gre)? 1 : 1024;         /* test before -[FGE] */
        !            69: -      /*
        !            70: -              read the options; decide legality after we know what we are doing.
        !            71: -              the options are split so we can maintain the usage line
        !            72: -              in one place. note the only option we have to be wary of
        !            73: -              is -f (not grep)
        !            74: -      */
        !            75: -      while((c = getopt(argc, argv, fullopts)) != -1)
        !            76: -              switch(c)
        !            77: -              {
        !            78: -              case '1':       oneflag = 1; break;
        !            79: -              case 'b':       bflag = 1; break;
        !            80: -              case 'c':       cflag = 1; break;
        !            81: -              case 'e':       if(input){
        !            82: -                                      EPR "%s: only one -e arg allowed\n", progname);
        !            83: -                                      errflg = 1;
        !            84: -                              }
        !            85: -                              input = optarg; break;
        !            86: -              case 'E':       whoami = egrep; break;
        !            87: -              case 'f':       if(input){
        !            88: -                                      EPR "%s: only one -f arg allowed\n", progname);
        !            89: -                                      errflg = 1;
        !            90: -                              }
        !            91: -                              finput = optarg; break;
        !            92: -              case 'F':       whoami = fgrep; break;
        !            93: -              case 'G':       whoami = grep; break;
        !            94: -              case 'h':       hflag = 1; break;
        !            95: -              case 'i':       iflag = 1; break;
        !            96: -              case 'l':       lflag = 1; break;
        !            97: -              case 'L':       Lflag = 1; break;
        !            98: -              case 'n':       nflag = 1; break;
        !            99: -              case 's':       sflag = 1; break;
        !           100: -              case 'v':       vflag = 1; break;
        !           101: -              case 'x':       xflag = 1; break;
        !           102: -              case '?':       errflg = 1; break;
        !           103: -              }
        !           104: -      if(errflg)
        !           105: -              usage();
        !           106: -      argv += optind;
        !           107: -      /*
        !           108: -              check for bad flag combinations
        !           109: -      */
        !           110: -      if(finput && (whoami == grep)){
        !           111: -              EPR "%s: cannot use -f with grep\n", progname);
        !           112: -              exit(2);
        !           113: -      }
        !           114: -      if(finput && input){
        !           115: -              EPR "%s: cannot use -f with -e\n", progname);
        !           116: -              exit(2);
        !           117: -      }
        !           118: -      if(!input && !finput){
        !           119: -              input = *argv++;
        !           120: -              if(input == 0)
        !           121: -                      usage();
        !           122: -      }
        !           123: -      /*
        !           124: -              character mapping ?
        !           125: -      */
        !           126: -      for(k = 0; k < 256; k++)
        !           127: -              map[k] = k;
        !           128: -      if(iflag)
        !           129: -              for(k = 'A'; k <= 'Z'; k++)
        !           130: -                      map[k] = tolower(k);
        !           131: -      /*
        !           132: -              in the interests of readability, fob off grep-type specific
        !           133: -              handling to separate functions. setting bmfn means using
        !           134: -              bmfind; similiarly cwfn means use cwfind
        !           135: -
        !           136: -      rules:
        !           137: -              lnum needs be maintained only if nflag.
        !           138: -              nbytes needs be maintained only if bflag.
        !           139: -              for -[s1lL], do a longjmp(env).
        !           140: -              for -c, increment nmatch.
        !           141: -      */
        !           142: -      switch(whoami)
        !           143: -      {
        !           144: -      case gre:       dogre(greparse, input, finput, map, &procfn, &pat, &rdfn, &matchfn); break;
        !           145: -      case grep:      dogre(grepparse, input, finput, map, &procfn, &pat, &rdfn, &matchfn); break;
        !           146: -      case fgrep:     dofgrep(input, finput, map, &procfn, &pat, &rdfn, &matchfn); break;
        !           147: -      case egrep:     dogre(egrepparse, input, finput, map, &procfn, &pat, &rdfn, &matchfn); break;
        !           148: -      }
        !           149: -      /*
        !           150: -              do generic flag handling
        !           151: -      */
        !           152: -      prname = !hflag && *argv && argv[1];
        !           153: -      /*
        !           154: -              do file arguments now! for uniformity, no args = '-'
        !           155: -      */
        !           156: -      if(!*argv)
        !           157: -              *--argv = "-";
        !           158: -      for(; curfile = *argv++; close(ifd)){
        !           159: -              if(strcmp(curfile, "-") == 0)
        !           160: -                      ifd = 0;
        !           161: -              else if((ifd = open(curfile, 0)) < 0){
        !           162: -                      EPR "%s: ", progname);
        !           163: -                      perror(curfile);
        !           164: -                      errflg = 2;
        !           165: -                      continue;
        !           166: -              }
        !           167: -              if(sflag && foundsome)
        !           168: -                      continue;       /* don't need to scan */
        !           169: -              lnum = nmatch = nbytes = 0;
        !           170: -              longlinewarned = 0;
        !           171: -              if((sval = setjmp(env)) == 0)
        !           172: -                      if((*procfn)(pat, rdfn, matchfn) < 0){
        !           173: -                              EPR "%s: ", progname);
        !           174: -                              perror(curfile);
        !           175: -                              errflg = 2;
        !           176: -                              continue;
        !           177: -                      }
        !           178: -              if((lflag && sval) || (Lflag && !sval))
        !           179: -                      PR "%s\n", curfile);
        !           180: -              if(cflag){
        !           181: -                      if(prname)
        !           182: -                              PR "%s:", curfile);
        !           183: -                      PR "%ld\n", nmatch);
        !           184: -              }
        !           185: -              if(nmatch)
        !           186: -                      foundsome = 1;
        !           187: -      }
        !           188: -      exit(errflg? errflg : (foundsome == 0));
        !           189: -      /*NOTREACHED*/
        !           190: -}
        !           191: -
        !           192: -void
        !           193: -re_error(char *s)
        !           194: -{
        !           195: -      EPR "%s: %s\n", progname, s);
        !           196: -      exit(2);
        !           197: -}
        !           198: //GO.SYSIN DD main.c
        !           199: echo dofgrep.c 1>&2
        !           200: sed 's/.//' >dofgrep.c <<'//GO.SYSIN DD dofgrep.c'
        !           201: -#include      <ctype.h>
        !           202: -#include      "re.h"
        !           203: -#include      "lre.h"
        !           204: -#include      "hdr.h"
        !           205: -
        !           206: -static int addwords(char*, re_cw*, unsigned char**, unsigned char**);
        !           207: -
        !           208: -void
        !           209: -dofgrep(char *input, char *finput, unsigned char *map, PROCFN *pprocfn, void **pat, RDFN *prdfn, MATCHFN *pmatchfn)
        !           210: -{
        !           211: -      unsigned char *lb, *le;
        !           212: -      int nwords, k;
        !           213: -      re_cw *cw;
        !           214: -
        !           215: -      *pat = (void *)(cw = re_cwinit(map));
        !           216: -      if(finput){
        !           217: -              nwords = addwords(finput, cw, &lb, &le);
        !           218: -      } else {
        !           219: -              register unsigned char *s, *e;
        !           220: -
        !           221: -              nwords = 0;
        !           222: -              s = (unsigned char *)input;
        !           223: -              while(*s){
        !           224: -                      char ch;
        !           225: -
        !           226: -                      for(e = s; *e && (*e != '\n'); e++)
        !           227: -                              ;
        !           228: -                      ch = *e;
        !           229: -                      if(xflag){
        !           230: -                              s[-1] = '\n';
        !           231: -                              *e = '\n';
        !           232: -                              re_cwadd(cw, (lb = s)-1, (le = e)+1);
        !           233: -                              *e = ch;
        !           234: -                      } else
        !           235: -                              re_cwadd(cw, lb = s, le = e);
        !           236: -                      s = *e? (e+1):e;
        !           237: -                      nwords++;
        !           238: -              }
        !           239: -              if(nwords == 1){
        !           240: -                      s = (unsigned char *)malloc(1 + (k = le-lb));
        !           241: -                      if (!s){
        !           242: -                              re_error("malloc failure");
        !           243: -                              cw->seenerror = 1;
        !           244: -                              return;
        !           245: -                      }
        !           246: -                      memmove((char *)s, (char *)lb, k);
        !           247: -                      lb = s;
        !           248: -                      le = s+k;
        !           249: -                      if(xflag)
        !           250: -                              *le++ = '\n';
        !           251: -              }
        !           252: -      }
        !           253: -      if(nwords == 1){
        !           254: -              *pat = (void *)re_bmcomp((char *)lb, (char *)le, map);
        !           255: -              *pprocfn = re_bmexec;
        !           256: -              *prdfn = greprd;
        !           257: -              *pmatchfn = xflag ? bmxmatch : grepmatch;
        !           258: -      } else {
        !           259: -              re_cwcomp(cw);
        !           260: -              *pprocfn = re_cwexec;
        !           261: -              *prdfn = xflag? cwxrd : greprd;
        !           262: -              *pmatchfn = xflag ? cwxmatch : grepmatch;
        !           263: -      }
        !           264: -      if(sflag || lflag || Lflag || oneflag){
        !           265: -              if(vflag == 0)
        !           266: -                      succfn = oneshot, failfn = count_m;
        !           267: -              else
        !           268: -                      succfn = count, failfn = oneshot;
        !           269: -      } else if(cflag){
        !           270: -              if(vflag == 0)
        !           271: -                      succfn = inc, failfn = null;
        !           272: -              else
        !           273: -                      succfn = null, failfn = inc_m;
        !           274: -      } else if(vflag){
        !           275: -              if(bflag||nflag)
        !           276: -                      succfn = count;
        !           277: -              else
        !           278: -                      succfn = null;
        !           279: -              failfn = pr_m;
        !           280: -      } else {
        !           281: -              succfn = pr;
        !           282: -              if(bflag||nflag)
        !           283: -                      failfn = count_m;
        !           284: -              else
        !           285: -                      failfn = null;
        !           286: -      }
        !           287: -}
        !           288: -
        !           289: -static
        !           290: -addwords(char *file, re_cw *pat, unsigned char **b, unsigned char **e)
        !           291: -{
        !           292: -      unsigned char rbuf[MAXLINE+2];
        !           293: -      unsigned char *buf = rbuf+1;
        !           294: -      int fd;
        !           295: -      int nwords = 0, eof, k;
        !           296: -      register unsigned char *nl, *nn, *end;
        !           297: -
        !           298: -      if((fd = open(file, 0)) < 0){
        !           299: -              perror(file);
        !           300: -              exit(2);
        !           301: -      }
        !           302: -      rbuf[0] = '\n';
        !           303: -      nl = end = buf+1;
        !           304: -      eof = 0;
        !           305: -      for(;;){
        !           306: -              if((nn = (unsigned char *)memchr((char *)nl, '\n', end-nl)) == 0){
        !           307: -                      if(nl == buf){
        !           308: -                              EPR "line too long in %s\n", file);
        !           309: -                              exit(2);
        !           310: -                      }
        !           311: -                      memmove((char *)buf, (char *)nl, end-nl);
        !           312: -                      end -= nl-buf;
        !           313: -                      nl = buf;
        !           314: -                      k = read(fd, (char *)end, &buf[MAXLINE]-end);
        !           315: -                      if(k > 0){
        !           316: -                              end += k;
        !           317: -                              continue;
        !           318: -                      } else if(k == 0){
        !           319: -                              if(nl == end)   /* clean read to end of file */
        !           320: -                                      break;
        !           321: -                              eof = 1;
        !           322: -                              *end++ = '\n';
        !           323: -                              continue;
        !           324: -                      } else {
        !           325: -                              perror(file);
        !           326: -                              exit(2);
        !           327: -                      }
        !           328: -              }
        !           329: -              if(xflag)
        !           330: -                      re_cwadd(pat, nl-1, nn+1);
        !           331: -              else
        !           332: -                      re_cwadd(pat, nl, nn);
        !           333: -              nl = nn+1;
        !           334: -              nwords++;
        !           335: -              if(eof)
        !           336: -                      break;
        !           337: -      }
        !           338: -      close(fd);
        !           339: -      if(nwords == 1){
        !           340: -              k = strlen((char *)buf)-1;
        !           341: -              *b = (unsigned char *)malloc(k+1);
        !           342: -              if (!*b){
        !           343: -                      re_error("malloc failed");
        !           344: -                      pat->seenerror = 1;
        !           345: -                      return 0;
        !           346: -              }
        !           347: -              memmove((char *)*b, (char *)buf, k);
        !           348: -              if(xflag)
        !           349: -                      (*b)[k++] = '\n';
        !           350: -              *e = *b + k;
        !           351: -      }
        !           352: -      return(nwords);
        !           353: -}
        !           354: //GO.SYSIN DD dofgrep.c
        !           355: echo dogre.c 1>&2
        !           356: sed 's/.//' >dogre.c <<'//GO.SYSIN DD dogre.c'
        !           357: -#include      <ctype.h>
        !           358: -#include      "re.h"
        !           359: -#include      "lre.h"
        !           360: -#include      "hdr.h"
        !           361: -
        !           362: -static void gresucc(char*, char*);    /* does reg exp match after bm */
        !           363: -static int reader(void*, RDFN, MATCHFN);/* plain analog of bmfind, cwfind */
        !           364: -static void readin(char*, char*, unsigned char**, unsigned char**);
        !           365: -
        !           366: -void
        !           367: -dogre(Parsetype parser, char *input, char *finput, unsigned char *map, PROCFN *pprocfn, void **pat, RDFN *prdfn, MATCHFN *pmatchfn)
        !           368: -{
        !           369: -      unsigned char *lb, *le;
        !           370: -
        !           371: -      readin(input, finput, &lb, &le);
        !           372: -      *pat = 0;
        !           373: -      globre = egprep(parser, lb, le, map, 1);
        !           374: -      *prdfn = greprd;
        !           375: -      *pmatchfn = grepmatch;
        !           376: -      if(sflag || lflag || Lflag || oneflag){
        !           377: -              if(vflag == 0)
        !           378: -                      succ2fn = oneshot, failfn = count_m;
        !           379: -              else
        !           380: -                      succ2fn = count, failfn = oneshot;
        !           381: -      } else if(cflag){
        !           382: -              if(vflag == 0)
        !           383: -                      succ2fn = inc, failfn = null;
        !           384: -              else
        !           385: -                      succ2fn = null, failfn = inc_m;
        !           386: -      } else if(vflag){
        !           387: -              if(bflag||nflag)
        !           388: -                      succ2fn = count;
        !           389: -              else
        !           390: -                      succ2fn = null;
        !           391: -              failfn = pr_m;
        !           392: -      } else {
        !           393: -              succ2fn = pr;
        !           394: -              if(bflag||nflag)
        !           395: -                      failfn = count_m;
        !           396: -              else
        !           397: -                      failfn = null;
        !           398: -      }
        !           399: -      if(re_lit(globre, &lb, &le)){
        !           400: -              *pat = (void *)re_bmcomp((char *)lb, (char *)le, map);
        !           401: -              *pprocfn = re_bmexec;
        !           402: -              succfn = gresucc;
        !           403: -      } else {
        !           404: -              if(*pat = (void *)re_recw(globre, map))
        !           405: -                      *pprocfn = re_cwexec;
        !           406: -              else
        !           407: -                      *pprocfn = reader;
        !           408: -              succfn = succ2fn;
        !           409: -      }
        !           410: -}
        !           411: -
        !           412: -static
        !           413: -reader(void *UNUSED, RDFN rdfn, MATCHFN matchfn)
        !           414: -{
        !           415: -      unsigned char *b, *e;
        !           416: -      unsigned char *nl;
        !           417: -      int k;
        !           418: -#pragma ref UNUSED
        !           419: -
        !           420: -      b = 0;
        !           421: -      while((k = (*rdfn)((char**)&b, (char**)&e)) > 0){
        !           422: -              while(nl = (unsigned char *)memchr((char *)b, '\n', e-b)){
        !           423: -                      if(eg_match(globre, b, nl, (unsigned char **)0, (unsigned char **)0)){
        !           424: -                              e = nl;
        !           425: -                              if((k = (*matchfn)((char**)&b, (char**)&e)) <= 0)
        !           426: -                                      return(k);
        !           427: -                      } else
        !           428: -                              b = nl+1;
        !           429: -              }
        !           430: -      }
        !           431: -      return(k);
        !           432: -}
        !           433: -
        !           434: -static void
        !           435: -readin(char *in, char *fin, unsigned char **beg, unsigned char **end)
        !           436: -{
        !           437: -      int size, n, fd, left;
        !           438: -      char *base, *p;
        !           439: -
        !           440: -      if(in){
        !           441: -              if(xflag){
        !           442: -                      size = 4+strlen(in)+1;
        !           443: -                      *beg = (unsigned char *)malloc(size);
        !           444: -                      if (!*beg){
        !           445: -                              EPR "%s: can't malloc %d bytes for -x\n", progname, size);
        !           446: -                              exit(2);
        !           447: -                      }
        !           448: -                      p = (char *)*beg;
        !           449: -                      *p++ = '^';
        !           450: -                      *p++ = '(';
        !           451: -                      memmove(p, in, n = strlen(in));
        !           452: -                      p += n;
        !           453: -                      *p++ = ')';
        !           454: -                      *p++ = '$';
        !           455: -                      *end = (unsigned char *)p;
        !           456: -              } else {
        !           457: -                      *beg = (unsigned char *)in;
        !           458: -                      *end = *beg + strlen(in);
        !           459: -              }
        !           460: -              return;
        !           461: -      }
        !           462: -      /* we know fin is nonzero */
        !           463: -      if((fd = open(fin, 0)) < 0){
        !           464: -              perror(fin);
        !           465: -              exit(2);
        !           466: -      }
        !           467: -      /*
        !           468: -              i object to calling stat; the following crap is not painful
        !           469: -              and at worst involves copying twice the number of bytes.
        !           470: -      */
        !           471: -      size = 128;
        !           472: -      if((base = malloc(size)) == 0){
        !           473: -              EPR "%s: can't malloc %d bytes for -f %s\n", progname, size, fin);
        !           474: -              exit(2);
        !           475: -      }
        !           476: -      left = size;
        !           477: -      p = base;
        !           478: -      if(xflag){
        !           479: -              *p++ = '^';
        !           480: -              left--;
        !           481: -      }
        !           482: -      for(; (n = read(fd, p, left)) > 0;){
        !           483: -              p += n;
        !           484: -              left -= n;
        !           485: -              if(left == 0){
        !           486: -                      size *= 2;
        !           487: -                      if((base = realloc(base, size+2)) == 0){
        !           488: -                              EPR "%s: can't malloc %d bytes for -f %s\n", progname, size, fin);
        !           489: -                              exit(2);
        !           490: -                      }
        !           491: -                      p = base+size/2;
        !           492: -                      left = size/2;
        !           493: -              }
        !           494: -      }
        !           495: -      if(n < 0){
        !           496: -              perror(fin);
        !           497: -              exit(2);
        !           498: -      }
        !           499: -      close(fd);
        !           500: -      if(xflag){
        !           501: -              *p++ = '$';
        !           502: -      }
        !           503: -      *beg = (unsigned char *)base;
        !           504: -      *end = (unsigned char *)p;
        !           505: -}
        !           506: -
        !           507: -static void
        !           508: -gresucc(char *b, char *e)
        !           509: -{
        !           510: -      if(eg_match(globre, (unsigned char*)b, (unsigned char*)(e-1), (unsigned char **)0, (unsigned char **)0))
        !           511: -              (*succ2fn)(b, e);
        !           512: -      else
        !           513: -              (*failfn)(b, e);
        !           514: -}
        !           515: //GO.SYSIN DD dogre.c
        !           516: echo fns.c 1>&2
        !           517: sed 's/.//' >fns.c <<'//GO.SYSIN DD fns.c'
        !           518: -#include      "re.h"
        !           519: -#include      "lre.h"
        !           520: -#include      "hdr.h"
        !           521: -
        !           522: -void
        !           523: -pr(char *b, char *e)
        !           524: -{
        !           525: -      nmatch++;
        !           526: -      if(prname)
        !           527: -              PR "%s:", curfile);
        !           528: -      if(bflag){
        !           529: -              PR "%ld:", nbytes/offsetunit);
        !           530: -              nbytes += (e-b) + noverflow;
        !           531: -              noverflow = 0;
        !           532: -      }
        !           533: -      if(nflag)
        !           534: -              PR "%ld:", ++lnum);
        !           535: -      WR(b, e-b);
        !           536: -}
        !           537: -
        !           538: -void
        !           539: -pr_m(char *b, char *e)
        !           540: -{
        !           541: -      register char *nl;
        !           542: -
        !           543: -      while(nl = (char*)memchr(b, '\n', e-b)){
        !           544: -              nmatch++;
        !           545: -              nl++;
        !           546: -              if(prname)
        !           547: -                      PR "%s:", curfile);
        !           548: -              if(bflag){
        !           549: -                      PR "%ld:", nbytes/offsetunit);
        !           550: -                      nbytes += (nl-b) + noverflow;
        !           551: -                      noverflow = 0;
        !           552: -              }
        !           553: -              if(nflag)
        !           554: -                      PR "%ld:", ++lnum);
        !           555: -              WR(b, nl-b);
        !           556: -              if((b = nl) >= e)
        !           557: -                      break;
        !           558: -      }
        !           559: -}
        !           560: -
        !           561: -/* ARGSUSED */
        !           562: -void
        !           563: -inc(char *UNUSED, char *UNUSED2)
        !           564: -{
        !           565: -#pragma ref UNUSED
        !           566: -#pragma ref UNUSED2
        !           567: -      nmatch++;
        !           568: -}
        !           569: -
        !           570: -void
        !           571: -inc_m(register char *b, register char *e)
        !           572: -{
        !           573: -      register char *nl;
        !           574: -
        !           575: -      while(nl = (char*)memchr(b, '\n', e-b)){
        !           576: -              nmatch++;
        !           577: -              if((b = nl+1) >= e)
        !           578: -                      break;
        !           579: -      }
        !           580: -}
        !           581: -
        !           582: -void
        !           583: -null(char *UNUSED, char *UNUSED2)
        !           584: -#pragma ref UNUSED
        !           585: -#pragma ref UNUSED2
        !           586: -{
        !           587: -}
        !           588: -
        !           589: -void
        !           590: -count(register char *b, register char *e)
        !           591: -{
        !           592: -      nbytes += (e-b) + noverflow;
        !           593: -      noverflow = 0;
        !           594: -      lnum++;
        !           595: -}
        !           596: -
        !           597: -void
        !           598: -count_m(register char *b, register char *e)
        !           599: -{
        !           600: -      register char *nl;
        !           601: -
        !           602: -      nbytes += (e-b) + noverflow;
        !           603: -      noverflow = 0;
        !           604: -      while(nl = (char*)memchr(b, '\n', e-b)){
        !           605: -              lnum++;
        !           606: -              if((b = nl+1) >= e)
        !           607: -                      break;
        !           608: -      }
        !           609: -}
        !           610: -
        !           611: -void
        !           612: -oneshot(char *b, char *e)
        !           613: -{
        !           614: -      register char *nl;
        !           615: -
        !           616: -      nmatch++;
        !           617: -      nl = (char*)memchr(b, '\n', e-b)+1;
        !           618: -      if(oneflag)
        !           619: -              pr(b, nl);
        !           620: -      longjmp(env, 1);
        !           621: -}
        !           622: //GO.SYSIN DD fns.c
        !           623: echo buffer.c 1>&2
        !           624: sed 's/.//' >buffer.c <<'//GO.SYSIN DD buffer.c'
        !           625: -#include      "re.h"
        !           626: -#include      "lre.h"
        !           627: -#include      "hdr.h"
        !           628: -
        !           629: -/*#define             DEBUG           /**/
        !           630: -
        !           631: -/* the following ifdef aids testing of the buffering code */
        !           632: -#ifndef       BUFSIZE
        !           633: -#define       BUFSIZE 50000
        !           634: -#endif
        !           635: -
        !           636: -#define       OVERFLOW        (BUFSIZE/10)
        !           637: -/*
        !           638: -      lines less than BUFSIZE are preserved. larger lines have at least
        !           639: -      BUFSIZE-OVERFLOW preserved
        !           640: -*/
        !           641: -
        !           642: -static char rbuf[BUFSIZE+1] = "\n";
        !           643: -static char *buf = rbuf+1;
        !           644: -static char *next, *proc;
        !           645: -/* invariants:
        !           646: -      valid text in buffer:   buf <= text < next
        !           647: -      text to be processed:   proc <= text < next
        !           648: -      buf, proc always point at beginning of lines
        !           649: -*/
        !           650: -
        !           651: -greprd(register char **b, register char **e)
        !           652: -{
        !           653: -      int n;
        !           654: -      int keepingsome;
        !           655: -      register char *p;
        !           656: -
        !           657: -      if(*b == 0)                     /* set up invariants */
        !           658: -              *b = *e = next = proc = buf;
        !           659: -      keepingsome = *b != *e;
        !           660: -again:        /* this is only used for overflowing input lines */
        !           661: -#ifdef        DEBUG
        !           662: -      fprint(2, "%d <> %d; keep=%d (%d'%.10s'..%d) proc=%d\n", next, &buf[BUFSIZE], keepingsome, *b, *b?*b:"", *e, proc);
        !           663: -#endif
        !           664: -      if(next < &buf[BUFSIZE]){
        !           665: -              /*
        !           666: -                      next is fine but *b may not be set
        !           667: -              */
        !           668: -              if(!keepingsome)
        !           669: -                      *b = proc;
        !           670: -      } else {
        !           671: -              /*
        !           672: -                      find a \n so we can shift the buffer
        !           673: -              */
        !           674: -              if(keepingsome){
        !           675: -                      for(p = *b-1; p >= buf; p--)
        !           676: -                              if(*p == '\n') break;
        !           677: -                      p++;
        !           678: -                      /* the best new buffer start is p */
        !           679: -                      if(p == buf){   /* progressing? */
        !           680: -      longline:
        !           681: -                              if(!longlinewarned){
        !           682: -                                      EPR "%s: %s: warning: ", progname, curfile);
        !           683: -                                      if(bflag)
        !           684: -                                              EPR "%ld: ", nbytes/offsetunit);
        !           685: -                                      if(nflag)
        !           686: -                                              EPR "%ld: ", lnum);
        !           687: -                                      EPR "line too long (> %d chars); text skipped\n", BUFSIZE);
        !           688: -                                      longlinewarned = 1;
        !           689: -                              }
        !           690: -                              next -= OVERFLOW;
        !           691: -                              noverflow += OVERFLOW;
        !           692: -                              goto again;
        !           693: -                      }
        !           694: -              } else {
        !           695: -                      /* not keeping any; we only have to look at unprocessed */
        !           696: -                      for(p = next-1; p >= proc; p--)
        !           697: -                              if(*p == '\n') break;
        !           698: -                      p++;
        !           699: -                      if(p == buf)
        !           700: -                              goto longline;
        !           701: -                      *b = p;
        !           702: -              }
        !           703: -              /* process any we haven't */
        !           704: -              if(proc < p){
        !           705: -                      (*failfn)(proc, p);
        !           706: -                      proc = p;
        !           707: -              }
        !           708: -              /* move it! */
        !           709: -              n = p-buf;
        !           710: -              memcpy(buf, p, next-p);
        !           711: -              proc -= n;
        !           712: -              next -= n;
        !           713: -              *b -= n;
        !           714: -      }
        !           715: -      /*
        !           716: -              *b points to start of returned (saved) text
        !           717: -              next points to first available text for reading
        !           718: -      */
        !           719: -      FLUSH;
        !           720: -      if((n = read(ifd, next, &buf[BUFSIZE] - next)) <= 0){
        !           721: -              if(proc < next){
        !           722: -                      (*failfn)(proc, next);
        !           723: -              }
        !           724: -              proc = next;
        !           725: -              return(n);
        !           726: -      }
        !           727: -      next += n;
        !           728: -      *e = next;
        !           729: -#ifdef        DEBUG
        !           730: -fprint(2, "greprd returns %d .. %d\n", *b, *e);
        !           731: -#endif
        !           732: -      return(1);
        !           733: -}
        !           734: -
        !           735: -grepmatch(register char **b, register char **e)
        !           736: -{
        !           737: -      char *s, *f;
        !           738: -      int eoffset, n, ret = 1;
        !           739: -#ifdef        DEBUG
        !           740: -fprint(2, "match! *b=%d@%d='%.100s' *e=%d@%d\n", **b, *b, *b, **e, *e);/**/
        !           741: -#endif
        !           742: -      for(s = *b; s >= proc; s--)
        !           743: -              if(*s == '\n')
        !           744: -                      break;
        !           745: -      if(s != *b)
        !           746: -              s++;
        !           747: -      if(proc < s){
        !           748: -              (*failfn)(proc, s);
        !           749: -              proc = s;
        !           750: -      }
        !           751: -      f = *e;
        !           752: -      for(;;){
        !           753: -              for(; f < next; f++)
        !           754: -                      if(*f == '\n')
        !           755: -                              goto done;
        !           756: -              eoffset = f-s;
        !           757: -              if((n = greprd(&s, &f)) <= 0){
        !           758: -                      ret = n;
        !           759: -                      goto done;
        !           760: -              }
        !           761: -              f = s+eoffset;
        !           762: -      }
        !           763: -done:
        !           764: -      f++;
        !           765: -      if(s > f)
        !           766: -              abort();
        !           767: -      (*succfn)(s, f);
        !           768: -      proc = *b = f;
        !           769: -      *e = next;
        !           770: -#ifdef        DEBUG
        !           771: -fprint(2, "match at '%.20s'; resuming at '%.20s'@%d\n", s, f, f);/**/
        !           772: -#endif
        !           773: -      return(ret);
        !           774: -}
        !           775: -
        !           776: -cwxrd(register char **b, register char **e)
        !           777: -{
        !           778: -      int n;
        !           779: -
        !           780: -      n = greprd(b, e);
        !           781: -      if(n > 0){
        !           782: -              (*b)--;
        !           783: -#ifdef        DEBUG
        !           784: -              fprint(2, "grepxrd returns %d .. %d\n", *b, *e);
        !           785: -#endif
        !           786: -      }
        !           787: -      return(n);
        !           788: -}
        !           789: -
        !           790: -cwxmatch(register char **b, register char **e)
        !           791: -{
        !           792: -      char *s, *f;
        !           793: -      int eoffset, n, ret = 1;
        !           794: -
        !           795: -#ifdef        DEBUG
        !           796: -fprint(2, "cwxmatch! *b=%d@%d='%.100s' *e=%d@%d\n", **b, *b, *b, **e, *e);/**/
        !           797: -#endif
        !           798: -      for(s = *b; s >= proc; s--)
        !           799: -              if(*s == '\n')
        !           800: -                      break;
        !           801: -      s++;
        !           802: -      if(proc < s){
        !           803: -/*
        !           804: -fprint(2, "cwxfail! *b=%d@%d='%.50s' *e=%d@%d\n", **b, *b, *b, **e, *e);
        !           805: -fprint(2, "s=%d, proc=%d, dbg.b=%d dbg.e=%d dbg.resume=%d\n", s, proc,dbg.b, dbg.e, dbg.resume);
        !           806: -*/
        !           807: -              (*failfn)(proc, s);
        !           808: -              proc = s;
        !           809: -      }
        !           810: -      f = *e - 1;
        !           811: -      for(;;){
        !           812: -              for(; f < next; f++)
        !           813: -                      if(*f == '\n')
        !           814: -                              goto done;
        !           815: -              eoffset = f-s;
        !           816: -              if((n = greprd(&s, &f)) <= 0){
        !           817: -                      ret = n;
        !           818: -                      goto done;
        !           819: -              }
        !           820: -              f = s+eoffset;
        !           821: -      }
        !           822: -done:
        !           823: -      f++;
        !           824: -      if(s > f)
        !           825: -              abort();
        !           826: -      (*succfn)(s, f);
        !           827: -      proc = *b = f;
        !           828: -      *e = next;
        !           829: -      (*b)--;
        !           830: -#ifdef        DEBUG
        !           831: -fprint(2, "cwxmatch at '%.20s'; resuming at '%.20s'@%d\n", s, f, f);/**/
        !           832: -#endif
        !           833: -      return(ret);
        !           834: -}
        !           835: -
        !           836: -bmxmatch(register char **b, register char **e)
        !           837: -{
        !           838: -      char *s, *f;
        !           839: -      int eoffset, n, ret = 1;
        !           840: -
        !           841: -#ifdef        DEBUG
        !           842: -fprint(2, "bmxmatch! *b=%d@%d='%.100s' *e=%d@%d\n", **b, *b, *b, **e, *e);/**/
        !           843: -#endif
        !           844: -      for(s = *b; s >= proc; s--)
        !           845: -              if(*s == '\n')
        !           846: -                      break;
        !           847: -      s++;
        !           848: -      if(proc < s){
        !           849: -              (*failfn)(proc, s);
        !           850: -              proc = s;
        !           851: -      }
        !           852: -      f = *e - 1;
        !           853: -      for(;;){
        !           854: -              for(; f < next; f++)
        !           855: -                      if(*f == '\n')
        !           856: -                              goto done;
        !           857: -              eoffset = f-s;
        !           858: -              if((n = greprd(&s, &f)) <= 0){
        !           859: -                      ret = n;
        !           860: -                      goto done;
        !           861: -              }
        !           862: -              f = s+eoffset;
        !           863: -      }
        !           864: -done:
        !           865: -      f++;
        !           866: -      if(s > f)
        !           867: -              abort();
        !           868: -      (*((*b == s)? succfn:failfn))(s, f);
        !           869: -      proc = *b = f;
        !           870: -      *e = next;
        !           871: -#ifdef        DEBUG
        !           872: -fprint(2, "bmxmatch at '%.20s'; resuming at '%.20s'\n", s, f);/**/
        !           873: -#endif
        !           874: -      return(ret);
        !           875: -}
        !           876: //GO.SYSIN DD buffer.c
        !           877: echo cw.c 1>&2
        !           878: sed 's/.//' >cw.c <<'//GO.SYSIN DD cw.c'
        !           879: -#include      "re.h"
        !           880: -#include      "lre.h"
        !           881: -#include      "hdr.h"
        !           882: -
        !           883: -typedef struct Link
        !           884: -{
        !           885: -      unsigned char l;
        !           886: -      struct Node *node;
        !           887: -      struct Link *next;
        !           888: -} Link;
        !           889: -static Link *froot;
        !           890: -
        !           891: -#define       NEW(N)  (froot?(t = froot, froot = froot->next, t->next = 0, t->node = N, t): newlink(c, 0, N))
        !           892: -#define       ADD(N)  if(qtail) qtail = qtail->next = NEW(N);\
        !           893: -                      else qtail = qhead = NEW(N)
        !           894: -#define       DEL()   { Link *tmp = qhead;if((qhead = qhead->next) == 0)\
        !           895: -                      qtail = 0; tmp->next = froot; froot = tmp;}
        !           896: -
        !           897: -typedef struct Node
        !           898: -{
        !           899: -      short out;
        !           900: -      short d;
        !           901: -      short shift1;
        !           902: -      short shift2;
        !           903: -      long id;
        !           904: -      struct Node **tab;
        !           905: -      Link *alts;
        !           906: -      struct Node *fail;
        !           907: -} Node;
        !           908: -
        !           909: -static Link *newlink(re_cw*, int, Node*);
        !           910: -static Node *newnode(re_cw*, int);
        !           911: -static void zeroroot(Node*, Node*);
        !           912: -static void shifttab(Node*);
        !           913: -static void shiftprop(re_cw*,Node*);
        !           914: -#ifdef        DEBUG
        !           915: -static void cwpr(register Node *n);
        !           916: -#endif
        !           917: -
        !           918: -re_cw *
        !           919: -re_cwinit(unsigned char *cmap)
        !           920: -{
        !           921: -      register i;
        !           922: -      register re_cw *c;
        !           923: -
        !           924: -      if((c = (re_cw *)egmalloc(sizeof *c, "malloc failed in re_cwinit")) == 0)
        !           925: -              return((re_cw *)0);
        !           926: -      c->nodeid = 0;
        !           927: -      c->maxdepth = 0;
        !           928: -      c->mindepth = 10000;
        !           929: -      c->seenerror = 0;
        !           930: -      c->root = newnode(c, 0);
        !           931: -      if(cmap)
        !           932: -              memmove((char *)c->map, (char *)cmap, sizeof c->map);
        !           933: -      else
        !           934: -              for(i = 0; i < sizeof c->map; i++)
        !           935: -                      c->map[i] = i;
        !           936: -      return(c);
        !           937: -}
        !           938: -
        !           939: -void
        !           940: -re_cwadd(register re_cw *c, register unsigned char *s, register unsigned char *e)
        !           941: -{
        !           942: -      register Node *p, *state;
        !           943: -      register Link *l;
        !           944: -      int depth;
        !           945: -
        !           946: -      for(state = c->root; s <= --e;){
        !           947: -              for(l = state->alts; l; l = l->next)
        !           948: -                      if(l->l == c->map[*e]) break;
        !           949: -              if(l == 0)
        !           950: -                      break;
        !           951: -              else
        !           952: -                      state = l->node;
        !           953: -      }
        !           954: -      if(s <= e){
        !           955: -              depth = state->d+1;
        !           956: -              l = newlink(c, *e--, p = newnode(c, depth++));
        !           957: -              if((l == 0) || (p == 0)){
        !           958: -                      c->seenerror = 1;
        !           959: -                      return;
        !           960: -              }
        !           961: -              l->next = state->alts;
        !           962: -              state->alts = l;
        !           963: -              state = p;
        !           964: -              while(s <= e){
        !           965: -                      state->alts = newlink(c, *e--, p = newnode(c, depth++));
        !           966: -                      if((state->alts == 0) || (p == 0)){
        !           967: -                              c->seenerror = 1;
        !           968: -                              return;
        !           969: -                      }
        !           970: -                      state = p;
        !           971: -              }
        !           972: -      }
        !           973: -      if(c->mindepth > state->d)
        !           974: -              c->mindepth = state->d;
        !           975: -      state->out = 1;
        !           976: -}
        !           977: -
        !           978: -#ifdef        DEBUG
        !           979: -static void
        !           980: -cwpr(register Node *n)
        !           981: -{
        !           982: -      register Link *l;
        !           983: -
        !           984: -      Fprint(1, "%d[%d,%d]: ", n->id, n->shift1, n->shift2);
        !           985: -      for(l = n->alts; l; l = l->next){
        !           986: -              Fprint(1, "edge from \"%d\" to \"%d\" label {\"%c\"};",
        !           987: -                      n->id, l->node->id, l->l);
        !           988: -              if(l->node->out) Fprint(1, " draw \"%d\" as Doublecircle;", l->node->id);
        !           989: -              if(l->node->fail)
        !           990: -                      Fprint(1, " edge from \"%d\" to \"%d\" dashed;", l->node->id, l->node->fail->id);
        !           991: -              Fprint(1, "\n");
        !           992: -              cwpr(l->node);
        !           993: -      }
        !           994: -}
        !           995: -#endif
        !           996: -
        !           997: -static void
        !           998: -fail(re_cw *c, Node *root)
        !           999: -{
        !          1000: -      Link *qhead = 0, *qtail = 0;
        !          1001: -      register Link *l, *ll;
        !          1002: -      register Link *t;
        !          1003: -      register Node *state, *r, *s;
        !          1004: -      int a;
        !          1005: -
        !          1006: -      for(l = root->alts; l; l = l->next){
        !          1007: -              ADD(l->node);
        !          1008: -              l->node->fail = root;
        !          1009: -      }
        !          1010: -      while(qhead){
        !          1011: -              r = qhead->node;
        !          1012: -              DEL();
        !          1013: -              for(l = r->alts; l; l = l->next){
        !          1014: -                      s = l->node;
        !          1015: -                      a = l->l;
        !          1016: -                      ADD(s);
        !          1017: -                      for(state = r->fail; state;){
        !          1018: -                              for(ll = state->alts; ll; ll = ll->next)
        !          1019: -                                      if(ll->l == a)
        !          1020: -                                              break;
        !          1021: -                              if(ll || (state == root)){
        !          1022: -                                      if(ll)
        !          1023: -                                              state = ll->node;
        !          1024: -                                      /*
        !          1025: -                                              do it here as only other exit is
        !          1026: -                                              state 0
        !          1027: -                                      */
        !          1028: -                                      if(state->out){
        !          1029: -                                              s->out = 1;
        !          1030: -                                      }
        !          1031: -                                      break;
        !          1032: -                              } else
        !          1033: -                                      state = state->fail;
        !          1034: -                      }
        !          1035: -                      s->fail = state;
        !          1036: -              }
        !          1037: -      }
        !          1038: -      zeroroot(root, root);
        !          1039: -}
        !          1040: -
        !          1041: -static void
        !          1042: -zeroroot(register Node *root, register Node *n)
        !          1043: -{
        !          1044: -      register Link *l;
        !          1045: -
        !          1046: -      if(n->fail == root)
        !          1047: -              n->fail = 0;
        !          1048: -      for(l = n->alts; l; l = l->next)
        !          1049: -              zeroroot(root, l->node);
        !          1050: -}
        !          1051: -
        !          1052: -static void
        !          1053: -shift(re_cw *c)
        !          1054: -{
        !          1055: -      Link *qhead = 0, *qtail = 0;
        !          1056: -      register Link *l;
        !          1057: -      register Link *t;
        !          1058: -      register Node *state, *r, *s;
        !          1059: -      int k;
        !          1060: -
        !          1061: -      for(k = 0; k < 256; k++)
        !          1062: -              c->step[k] = c->mindepth+1;
        !          1063: -      c->root->shift1 = 1;
        !          1064: -      c->root->shift2 = c->mindepth;
        !          1065: -      for(l = c->root->alts; l; l = l->next){
        !          1066: -/*            l->node->shift2 = c->root->shift2;/**/
        !          1067: -              ADD(l->node);
        !          1068: -              l->node->fail = 0;
        !          1069: -      }
        !          1070: -      while(qhead){
        !          1071: -              r = qhead->node;
        !          1072: -              DEL();
        !          1073: -              r->shift1 = c->mindepth;
        !          1074: -              r->shift2 = c->mindepth;
        !          1075: -              if(state = r->fail){
        !          1076: -                      do {
        !          1077: -                              k = r->d - state->d;
        !          1078: -                              if(k < state->shift1){
        !          1079: -                                      state->shift1 = k;
        !          1080: -                              }
        !          1081: -                              if(r->out && (k < state->shift2)){
        !          1082: -                                      state->shift2 = k;
        !          1083: -                              }
        !          1084: -                      } while(state = state->fail);
        !          1085: -              }
        !          1086: -              for(l = r->alts; l; l = l->next){
        !          1087: -                      s = l->node;
        !          1088: -                      ADD(s);
        !          1089: -              }
        !          1090: -      }
        !          1091: -      shiftprop(c, c->root);
        !          1092: -      shifttab(c->root);
        !          1093: -      c->step[0] = 1;
        !          1094: -}
        !          1095: -
        !          1096: -static void
        !          1097: -shifttab(register Node *n)
        !          1098: -{
        !          1099: -      register Link *l;
        !          1100: -      register Node **nn;
        !          1101: -
        !          1102: -      n->tab = nn = (Node **)calloc(256, sizeof(Node *));
        !          1103: -      for(l = n->alts; l; l = l->next)
        !          1104: -              nn[l->l] = l->node;
        !          1105: -}
        !          1106: -
        !          1107: -static void
        !          1108: -shiftprop(register re_cw *c, register Node *n)
        !          1109: -{
        !          1110: -      register Link *l;
        !          1111: -      register Node *nn;
        !          1112: -
        !          1113: -      for(l = n->alts; l; l = l->next){
        !          1114: -              if(c->step[l->l] > l->node->d)
        !          1115: -                      c->step[l->l] = l->node->d;
        !          1116: -              nn = l->node;
        !          1117: -              if(n->shift2 < nn->shift2)
        !          1118: -                      nn->shift2 = n->shift2;
        !          1119: -              shiftprop(c, nn);
        !          1120: -      }
        !          1121: -}
        !          1122: -
        !          1123: -void
        !          1124: -re_cwcomp(re_cw *c)
        !          1125: -{
        !          1126: -      if(c->seenerror)
        !          1127: -              return;
        !          1128: -      fail(c, c->root);
        !          1129: -      shift(c);
        !          1130: -#ifdef        DEBUG
        !          1131: -      cwpr(c->root);
        !          1132: -#endif
        !          1133: -}
        !          1134: -
        !          1135: -re_cwexec(void *re_c, RDFN rdfn, MATCHFN matchfn)
        !          1136: -{
        !          1137: -      re_cw *c = (re_cw*)re_c;
        !          1138: -      register Node *state;
        !          1139: -      register Link *l;
        !          1140: -      register unsigned char *sp;
        !          1141: -      register unsigned char *e, *s;
        !          1142: -      register Node *ostate;
        !          1143: -      register k;
        !          1144: -      unsigned char *rs, *re;
        !          1145: -      unsigned char fake[1];
        !          1146: -      unsigned char mappedsp;
        !          1147: -
        !          1148: -      if(c->seenerror)
        !          1149: -              return(-1);
        !          1150: -      fake[0] = 0;
        !          1151: -      state = c->root;
        !          1152: -      for(rs = 0; (k = (*rdfn)((char**)&rs,(char**) &re)) > 0;){
        !          1153: -doneline:
        !          1154: -              s = rs+c->mindepth-1;
        !          1155: -              e = re;
        !          1156: -              while(s < e){
        !          1157: -                      /* scan */
        !          1158: -                      for(sp = s; ostate = state;){
        !          1159: -                              if(state->tab){
        !          1160: -                                      if((state = state->tab[c->map[*sp]]) == 0)
        !          1161: -                                              goto nomatch;
        !          1162: -                              } else {
        !          1163: -                                      mappedsp = c->map[*sp];
        !          1164: -                                      for(l = state->alts; ; l = l->next){
        !          1165: -                                              if(l == 0)
        !          1166: -                                                      goto nomatch;
        !          1167: -                                              if(l->l == mappedsp){
        !          1168: -                                                      state = l->node;
        !          1169: -                                                      break;
        !          1170: -                                              }
        !          1171: -                                      }
        !          1172: -                              }
        !          1173: -#ifdef        DEBUG
        !          1174: -print("state %d -0x%x-> state %d (out=%d)\n", ostate->id, *sp&0xFF, state->id, state->out);
        !          1175: -#endif
        !          1176: -                              if(state->out){
        !          1177: -                                      unsigned char *bm = sp, *em = s+1;
        !          1178: -                                      if((k = (*matchfn)((char**)&bm, (char**)&em)) <= 0)
        !          1179: -                                              return(k);
        !          1180: -                                      rs = bm;
        !          1181: -                                      re = em;
        !          1182: -                                      state = c->root;
        !          1183: -                                      goto doneline;
        !          1184: -                              }
        !          1185: -                              if(--sp < rs){
        !          1186: -                                      sp = fake;
        !          1187: -                                      break;
        !          1188: -                              }
        !          1189: -                      }
        !          1190: -              nomatch:
        !          1191: -                      k = c->step[c->map[*sp]]-ostate->d-1;
        !          1192: -                      if(k < ostate->shift1)
        !          1193: -                              k = ostate->shift1;
        !          1194: -                      if(k > ostate->shift2)
        !          1195: -                              k = ostate->shift2;
        !          1196: -                      s += k;
        !          1197: -                      state = c->root;
        !          1198: -              }
        !          1199: -#ifdef        DEBUG
        !          1200: -print("end of s<e loop: s=%d e=%d, rs=%d, re=%d\n", s, e, rs, re);
        !          1201: -#endif
        !          1202: -              rs = re;        /* we have analysed evrything up to here */
        !          1203: -      }
        !          1204: -      return(k? -1:0);
        !          1205: -}
        !          1206: -
        !          1207: -static void
        !          1208: -freenode(Node *n)
        !          1209: -{
        !          1210: -      register Link *l, *ll;
        !          1211: -
        !          1212: -      if(n->tab)
        !          1213: -              free((char *)n->tab);
        !          1214: -      for(l = n->alts; l; l = ll){
        !          1215: -              ll = l->next;
        !          1216: -              freenode(l->node);
        !          1217: -      }
        !          1218: -      free((char *)n);
        !          1219: -}
        !          1220: -
        !          1221: -void
        !          1222: -re_cwfree(re_cw *cw)
        !          1223: -{
        !          1224: -      register Link *l;
        !          1225: -
        !          1226: -      while(froot){
        !          1227: -              l = froot->next;
        !          1228: -              free((char *)froot);
        !          1229: -              froot = l;
        !          1230: -      }
        !          1231: -      freenode(cw->root);
        !          1232: -      free((char *)cw);
        !          1233: -}
        !          1234: -
        !          1235: -static Node *
        !          1236: -newnode(re_cw *c, int d)
        !          1237: -{
        !          1238: -      static Node *next = 0, *lim = 0;
        !          1239: -      static incr = 1000;
        !          1240: -
        !          1241: -      if(next == lim){
        !          1242: -              next = (Node *)malloc(incr*sizeof(Node));
        !          1243: -              if(next == 0){
        !          1244: -                      re_error("node malloc fail");
        !          1245: -                      return 0;
        !          1246: -              }
        !          1247: -              lim = next+incr;
        !          1248: -      }
        !          1249: -      next->d = d;
        !          1250: -      if(d > c->maxdepth) c->maxdepth = d;
        !          1251: -      next->id = c->nodeid++;
        !          1252: -      next->alts = 0;
        !          1253: -      next->tab = 0;
        !          1254: -      next->out = 0;
        !          1255: -      return(next++);
        !          1256: -}
        !          1257: -
        !          1258: -static Link *
        !          1259: -newlink(re_cw *c, int l, Node *n)
        !          1260: -{
        !          1261: -      static Link *next = 0, *lim = 0;
        !          1262: -      static incr = 1000;
        !          1263: -
        !          1264: -      if(next == lim){
        !          1265: -              next = (Link *)malloc(incr*sizeof(Node));
        !          1266: -              if(next == 0){
        !          1267: -                      re_error("link malloc fail");
        !          1268: -                      return 0;
        !          1269: -              }
        !          1270: -              lim = next+incr;
        !          1271: -      }
        !          1272: -      next->l = c->map[l];
        !          1273: -      next->node = n;
        !          1274: -      next->next = 0;
        !          1275: -      return(next++);
        !          1276: -}
        !          1277: //GO.SYSIN DD cw.c
        !          1278: echo bm.c 1>&2
        !          1279: sed 's/.//' >bm.c <<'//GO.SYSIN DD bm.c'
        !          1280: -#include      "re.h"
        !          1281: -#include      "lre.h"
        !          1282: -#include      "hdr.h"
        !          1283: -
        !          1284: -/*
        !          1285: -      this next one is dirty but i can't think of a good way out now.
        !          1286: -      essentially, LARGE has to be a bit bigger than the biggest buffer
        !          1287: -      we are ever given by rdfn
        !          1288: -*/
        !          1289: -#define               LARGE   (100000000+2)
        !          1290: -
        !          1291: -static int bb(re_bm *, unsigned char*, unsigned char*);
        !          1292: -
        !          1293: -re_bm *
        !          1294: -re_bmcomp(char *ppb, char *ppe, unsigned char *map)
        !          1295: -{
        !          1296: -      register unsigned char *pb = (unsigned char *)ppb;
        !          1297: -      register unsigned char *pe = (unsigned char *)ppe;
        !          1298: -      register int j;
        !          1299: -      int delta[256];
        !          1300: -      register re_bm *b;
        !          1301: -
        !          1302: -      b = (re_bm *)malloc(sizeof *b);
        !          1303: -      if(b == 0){
        !          1304: -              re_error("b malloc fail");
        !          1305: -              return 0;
        !          1306: -      }
        !          1307: -      b->patlen = pe-pb;
        !          1308: -      memmove((char *)b->cmap, (char *)map, sizeof b->cmap);
        !          1309: -      b->bmpat = malloc(b->patlen);
        !          1310: -      if(b->bmpat == 0){
        !          1311: -              re_error("bmpat malloc fail");
        !          1312: -              free((char*)b);
        !          1313: -              return 0;
        !          1314: -      }
        !          1315: -      if (bb(b, pb, pe) == 0){
        !          1316: -              free((char*)b->bmpat);
        !          1317: -              free((char*)b);
        !          1318: -              return 0;
        !          1319: -      }
        !          1320: -      for(j = 0; pb+j < pe; j++)
        !          1321: -              b->bmpat[j] = b->cmap[pb[j]];
        !          1322: -      for(j = 0; j < 256; j++)
        !          1323: -              delta[j] = b->patlen;
        !          1324: -      for(pe--; pb < pe; pb++)
        !          1325: -              delta[b->cmap[*pb]] = pe-pb;
        !          1326: -      delta[b->cmap[*pb]] = LARGE;
        !          1327: -      for(j = 0; j < 256; j++)
        !          1328: -              b->delta0[j] = delta[b->cmap[j]];
        !          1329: -      return(b);
        !          1330: -}
        !          1331: -
        !          1332: -static int
        !          1333: -bb(register re_bm *b, register unsigned char *pb, register unsigned char *pe)
        !          1334: -{
        !          1335: -      int *f;
        !          1336: -      register m = pe-pb;
        !          1337: -      register i, k, j;
        !          1338: -
        !          1339: -      f = (int *)malloc(sizeof(int)*(m+1));
        !          1340: -      if(f == 0){
        !          1341: -              re_error("delta2 f malloc");
        !          1342: -              return 0;
        !          1343: -      }
        !          1344: -      pb--;
        !          1345: -      b->delta2 = (int *)malloc(sizeof(int)*(b->patlen+1));
        !          1346: -      if(b->delta2 == 0){
        !          1347: -              re_error("delta2 malloc");
        !          1348: -              free((char*)f);
        !          1349: -              return 0;
        !          1350: -      }               
        !          1351: -      for(i = 1; i <= m; i++)
        !          1352: -              b->delta2[i] = 2*m-i;
        !          1353: -      j = m;
        !          1354: -      k = m+1;
        !          1355: -      while(j > 0){
        !          1356: -              f[j] = k;
        !          1357: -              while((k <= m) && (pb[j] != pb[k])){
        !          1358: -                      if(m-j < b->delta2[k])
        !          1359: -                              b->delta2[k] = m-j;
        !          1360: -                      k = f[k];
        !          1361: -              }
        !          1362: -              j--;
        !          1363: -              k--;
        !          1364: -      }
        !          1365: -      for(i = 1; i <= k; i++){
        !          1366: -              if(b->delta2[i] > m+k-i)
        !          1367: -                      b->delta2[i] = m+k-i;
        !          1368: -      }
        !          1369: -      free((char *)f);
        !          1370: -      return 1;
        !          1371: -}
        !          1372: -
        !          1373: -re_bmexec(void *re_b, RDFN rdfn, MATCHFN matchfn)
        !          1374: -{
        !          1375: -      register re_bm *b = (re_bm*)re_b;
        !          1376: -      register unsigned char *sp;
        !          1377: -      register unsigned char *e, *s;
        !          1378: -      unsigned char *re, *rs;
        !          1379: -      register k;
        !          1380: -
        !          1381: -      for(rs = 0; (k = (*rdfn)((char**)&rs, (char**)&re)) > 0; rs = s, re = e){
        !          1382: -              e = re;
        !          1383: -              s = rs;
        !          1384: -              while(s < e){
        !          1385: -                      while((s += b->delta0[*s]) < e)
        !          1386: -                              ;
        !          1387: -                      if(s < e+b->patlen){    /* no match */
        !          1388: -                              s = e;
        !          1389: -                              break;
        !          1390: -                      }
        !          1391: -                      s -= LARGE;
        !          1392: -                      for(k = b->patlen-2, sp = s-1; k >= 0; k--)
        !          1393: -                              if(b->cmap[*sp--] != b->bmpat[k])
        !          1394: -                                      break;
        !          1395: -/*print("k=%d s=%d sp=%d\n", k, s, sp);/**/
        !          1396: -                      if(k < 0){
        !          1397: -                              unsigned char *bm = ++sp, *em = s+1;
        !          1398: -                              if((k = (*matchfn)((char**)&bm, (char**)&em)) <= 0)
        !          1399: -                                      return(k);
        !          1400: -                              s = bm;
        !          1401: -                              e = em;
        !          1402: -                      } else {
        !          1403: -                              /*j = b->delta2[k+1];
        !          1404: -                              k = b->delta0[cmap[*++sp]];
        !          1405: -                              if((j > k) || (k == LARGE))
        !          1406: -                                       k = j;
        !          1407: -                              s = sp+k;*/s++;
        !          1408: -                      }
        !          1409: -              }
        !          1410: -      }
        !          1411: -      return(k);
        !          1412: -}
        !          1413: -
        !          1414: -void
        !          1415: -re_bmfree(re_bm *pat)
        !          1416: -{
        !          1417: -      free((char *)pat->delta2);
        !          1418: -      free(pat->bmpat);
        !          1419: -      free((char *)pat);
        !          1420: -}
        !          1421: //GO.SYSIN DD bm.c
        !          1422: echo re.c 1>&2
        !          1423: sed 's/.//' >re.c <<'//GO.SYSIN DD re.c'
        !          1424: -#include      "re.h"
        !          1425: -#include      "lre.h"
        !          1426: -#include      "hdr.h"
        !          1427: -
        !          1428: -re_re *
        !          1429: -re_recomp(char *b, char *e, unsigned char *map)
        !          1430: -{
        !          1431: -      return(egprep(greparse, (unsigned char *)b, (unsigned char *)e, map, 1));
        !          1432: -}
        !          1433: -
        !          1434: -re_reexec(re_re *pat, char *b, char *e, char *match[10][2])
        !          1435: -{
        !          1436: -      unsigned char *mb[10], *me[10], **rb, **re;
        !          1437: -      int n, i;
        !          1438: -
        !          1439: -      if(match)
        !          1440: -              rb = mb, re = me;
        !          1441: -      else
        !          1442: -              rb = re = 0;
        !          1443: -      n = eg_match(pat, (unsigned char *)b, (unsigned char *)e, rb, re);
        !          1444: -      if(match)
        !          1445: -              for(i = 0; i < 10; i++){
        !          1446: -                      match[i][0] = (char *)mb[i];
        !          1447: -                      match[i][1] = (char *)me[i];
        !          1448: -              }
        !          1449: -      return(n);
        !          1450: -}
        !          1451: -
        !          1452: -static void
        !          1453: -freeexpr(register Expr *e)
        !          1454: -{
        !          1455: -      switch(e->type)
        !          1456: -      {
        !          1457: -      case Literal:
        !          1458: -      case Dot:
        !          1459: -      case Carat:
        !          1460: -      case Dollar:
        !          1461: -              if(e->follow)
        !          1462: -                      free((char *)e->follow);
        !          1463: -              break;
        !          1464: -      case Compcharclass:
        !          1465: -      case Charclass:
        !          1466: -              free((char *)e->r);
        !          1467: -              break;
        !          1468: -      case Cat:
        !          1469: -      case Alternate:
        !          1470: -              freeexpr(e->l);
        !          1471: -              freeexpr(e->r);
        !          1472: -              break;
        !          1473: -      case Star:
        !          1474: -      case Plus:
        !          1475: -      case Quest:
        !          1476: -      case Group:
        !          1477: -      case EOP:
        !          1478: -              freeexpr(e->l);
        !          1479: -              break;
        !          1480: -      case Backref:
        !          1481: -      default:
        !          1482: -              break;
        !          1483: -      }
        !          1484: -}
        !          1485: -
        !          1486: -void
        !          1487: -re_refree(re_re *re)
        !          1488: -{
        !          1489: -      if(re == 0)
        !          1490: -              return;
        !          1491: -      if(re->posbase)
        !          1492: -              free((char *)re->posbase);
        !          1493: -      if(re->root)
        !          1494: -              freeexpr(re->root);
        !          1495: -      if(re->ptr)
        !          1496: -              free((char *)re->ptr);
        !          1497: -      if(re->states)
        !          1498: -              free((char *)re->states);
        !          1499: -      /* leave br alone for now; it is hard to get right */
        !          1500: -      free((char *)re);
        !          1501: -}
        !          1502: //GO.SYSIN DD re.c
        !          1503: echo eg.c 1>&2
        !          1504: sed 's/.//' >eg.c <<'//GO.SYSIN DD eg.c'
        !          1505: -#include      "re.h"
        !          1506: -#include      "lre.h"
        !          1507: -#include      "hdr.h"
        !          1508: -
        !          1509: -int re_debug = 0;
        !          1510: -
        !          1511: -#define       RESET(r, ps)    COPY(r, ps, begin)
        !          1512: -#define       SET(r, ps, n)   {if(r->ps.base[n] == 0) r->ps.count++, r->ps.base[n] = r->ps.last, r->ps.last = n; }
        !          1513: -#define       GET(ps, n)      for(n = ps.last; n > 0; n = ps.base[n])
        !          1514: -#define       COPY(r, to, from)       memmove((char *)r->to.base, (char *)r->from.base, r->maxid*sizeof(int)), r->to.count = r->from.count, r->to.last = r->from.last
        !          1515: -
        !          1516: -static State *addstate(re_re *r, Positionset *ps);
        !          1517: -static int first(re_re *, Expr *);
        !          1518: -static int match(re_re *, Expr *, int);
        !          1519: -static State *nextstate(re_re *, State *, int);
        !          1520: -#ifdef        DEBUG
        !          1521: -static void ppr(Positionset *, char *);
        !          1522: -#endif
        !          1523: -
        !          1524: -typedef enum { NORMAL, ACCEPT, ACCEPT_EOP, FAIL } Out;
        !          1525: -
        !          1526: -static void
        !          1527: -eptr(register re_re *r, register Expr *e)
        !          1528: -{
        !          1529: -      if((e->id < 0) || (e->id >= r->maxid)){
        !          1530: -              EPR "eptr abort: r=%ld[maxid=%d] e=%ld[id=%d]\n", r, r->maxid, e, e->id);
        !          1531: -              abort();
        !          1532: -      }
        !          1533: -      r->ptr[e->id] = e;
        !          1534: -      if((e->type != Charclass) && (e->type != Compcharclass)){
        !          1535: -              if(e->l)
        !          1536: -                      eptr(r, e->l);
        !          1537: -              if(e->r)
        !          1538: -                      eptr(r, e->r);
        !          1539: -      }
        !          1540: -}
        !          1541: -
        !          1542: -re_re *
        !          1543: -egprep(enum Parsetype parser, unsigned char *b, unsigned char *e, unsigned char *map, int dotstar)
        !          1544: -{
        !          1545: -      register re_re *r;
        !          1546: -      Expr *ecomp;
        !          1547: -      int i;
        !          1548: -
        !          1549: -      r = (re_re *)egmalloc(sizeof (re_re), "allocating re_re");
        !          1550: -      if(r == 0)
        !          1551: -              return 0;
        !          1552: -      memset((char *)r, 0, sizeof (re_re));
        !          1553: -      eg_lexinit((char *)b, (char *)e);
        !          1554: -      if(map)
        !          1555: -              memmove(r->mymap, (char *)map, 256);
        !          1556: -      else
        !          1557: -              for(i = 0; i < 256; i++)
        !          1558: -                      r->mymap[i] = i;
        !          1559: -      eg_lex();
        !          1560: -      if(dotstar){
        !          1561: -              ecomp = eg_newexpr(Star, 0, eg_newexpr(Dot, '.', (Expr *)0, (Expr *)0), (Expr *)0);
        !          1562: -              ecomp = eg_newexpr(Cat, 0, ecomp, eg_eall(parser, r->mymap));
        !          1563: -      } else
        !          1564: -              ecomp = eg_eall(parser, r->mymap);
        !          1565: -      r->root = eg_newexpr(EOP, '#', ecomp, (Expr *)0);
        !          1566: -      egpost(r);
        !          1567: -      r->carat = 0;
        !          1568: -      if(r->backref || r->parens)
        !          1569: -              egbr(r);
        !          1570: -      else
        !          1571: -              eginit(r, dotstar);
        !          1572: -      return(r);
        !          1573: -}
        !          1574: -
        !          1575: -void
        !          1576: -eginit(register re_re *r, int dotstar)
        !          1577: -{
        !          1578: -      int n;
        !          1579: -
        !          1580: -#ifdef        DEBUG
        !          1581: -      if(TRACE(6))
        !          1582: -              PR "eginit(r=%d, dotstar=%d)\n", r, dotstar);
        !          1583: -#endif
        !          1584: -#ifdef        DEBUG
        !          1585: -      if(TRACE(10)){
        !          1586: -              char buf[EPRINTSIZE];
        !          1587: -              eg_epr(r->root, buf, 0);
        !          1588: -              PR "eginit: r=%d expr='%s'\n", r, buf);
        !          1589: -      }
        !          1590: -#endif
        !          1591: -      r->ptr = (Expr **)egmalloc(r->maxid*sizeof(Expr *), "ptr");
        !          1592: -      if (!r->ptr)
        !          1593: -              return;
        !          1594: -      eptr(r, r->root);
        !          1595: -      r->firstpos.base = (int *)egmalloc(n = r->maxid*sizeof(int), "first base");
        !          1596: -      if (!r->firstpos.base){
        !          1597: -              free((char*)r->ptr);
        !          1598: -              return;
        !          1599: -      }
        !          1600: -      r->begin.base = (int *)egmalloc(n, "begin base");
        !          1601: -      if (!r->begin.base){
        !          1602: -              free((char*)r->firstpos.base);
        !          1603: -              free((char*)r->ptr);
        !          1604: -              return;
        !          1605: -      }
        !          1606: -      r->tmp.base = (int *)egmalloc(n, "tmp base");
        !          1607: -      if (!r->tmp.base){
        !          1608: -              free((char*)r->begin.base);
        !          1609: -              free((char*)r->firstpos.base);
        !          1610: -              free((char*)r->ptr);
        !          1611: -              return;
        !          1612: -      }
        !          1613: -      memset((char *)r->begin.base, 0, n);
        !          1614: -      r->begin.count = 0;
        !          1615: -      r->begin.last = -1;
        !          1616: -      r->carat = dotstar;
        !          1617: -      RESET(r, firstpos);
        !          1618: -      if(first(r, r->root->l) == 0){
        !          1619: -              /*
        !          1620: -                      nullable, so include me
        !          1621: -              */
        !          1622: -              SET(r, firstpos, r->root->id)
        !          1623: -      }
        !          1624: -      if(dotstar)
        !          1625: -              COPY(r, begin, firstpos);
        !          1626: -      eg_stateinit(r);
        !          1627: -      eg_clrstates(r);
        !          1628: -      eg_posinit(r);
        !          1629: -      (void)addstate(r, &r->firstpos);
        !          1630: -      eg_savestate(r, dotstar? nextstate(r, r->states, RE_CARAT):r->states);
        !          1631: -      eg_posset(r);
        !          1632: -}
        !          1633: -
        !          1634: -unsigned char *
        !          1635: -eg_quickmatch(register re_re *r, register unsigned char *b, register unsigned char *e, int endpts)
        !          1636: -{
        !          1637: -      register State *s, *t;
        !          1638: -
        !          1639: -#ifdef        DEBUG
        !          1640: -      if(TRACE(10)){
        !          1641: -              char buf[EPRINTSIZE];
        !          1642: -              eg_epr(r->root, buf, 0);
        !          1643: -              PR "qm: r=%d expr='%s' endpts=%d\n", r, buf, endpts);
        !          1644: -      }
        !          1645: -#endif
        !          1646: -      s = eg_startstate(r);
        !          1647: -      if(endpts&RE_BEG){
        !          1648: -              if(!r->carat){
        !          1649: -                      if(t = s->tab[RE_CARAT])
        !          1650: -                              s = t;
        !          1651: -                      else
        !          1652: -                              s = nextstate(r, s, RE_CARAT);
        !          1653: -                      if(s->out == FAIL)
        !          1654: -                              s = eg_startstate(r);
        !          1655: -              }
        !          1656: -              if(s->out){
        !          1657: -#ifdef        DEBUG
        !          1658: -                      if(TRACE(6))
        !          1659: -                              PR "match at ^: '%s' out=%d\n", b, s->out);
        !          1660: -#endif
        !          1661: -                      return((s->out == FAIL)? 0:b);
        !          1662: -              }
        !          1663: -      }
        !          1664: -      while(b < e){
        !          1665: -#ifdef        DEBUG
        !          1666: -              if(TRACE(4))
        !          1667: -                      PR "state %d@%d[%d pos]: char '%c'\n", s-r->states, (int)s, s->npos, *b);
        !          1668: -#endif
        !          1669: -              if(t = s->tab[*(unsigned char *)b])
        !          1670: -                      s = t;
        !          1671: -              else
        !          1672: -                      s = nextstate(r, s, *(unsigned char *)b);
        !          1673: -              if(s->out){
        !          1674: -#ifdef        DEBUG
        !          1675: -                      if(TRACE(6))
        !          1676: -                              PR "match at input '%s' out=%d\n", b, s->out);
        !          1677: -#endif
        !          1678: -                      return((s->out == FAIL)? 0:b);
        !          1679: -              }
        !          1680: -              b++;
        !          1681: -      }
        !          1682: -      if(endpts&RE_END){
        !          1683: -              if(t = s->tab[RE_DOLLAR])
        !          1684: -                      s = t;
        !          1685: -              else
        !          1686: -                      s = nextstate(r, s, RE_DOLLAR);
        !          1687: -      }
        !          1688: -      if(s->out){
        !          1689: -#ifdef        DEBUG
        !          1690: -              if(TRACE(6))
        !          1691: -                      PR "match at $ '%s' out=%d\n", b, s->out);
        !          1692: -#endif
        !          1693: -              return((s->out == FAIL)? 0:b);
        !          1694: -      }
        !          1695: -#ifdef        DEBUG
        !          1696: -      if(TRACE(3)){
        !          1697: -              char buf[EPRINTSIZE];
        !          1698: -
        !          1699: -              eg_epr(r->root, buf, 1);
        !          1700: -              PR "pat = %s\n", buf);
        !          1701: -      }
        !          1702: -#endif
        !          1703: -      return(0);
        !          1704: -}
        !          1705: -
        !          1706: -unsigned char *
        !          1707: -eg_lquickmatch(register re_re *r, register unsigned char *b, register unsigned char *e, int endpts)
        !          1708: -{
        !          1709: -      register State *s, *t;
        !          1710: -      int outedness = 0;
        !          1711: -
        !          1712: -#ifdef        DEBUG
        !          1713: -      if(TRACE(10)){
        !          1714: -              char buf[EPRINTSIZE];
        !          1715: -              eg_epr(r->root, buf, 0);
        !          1716: -              PR "lqm: r=%d carat=%d expr='%s' endpts=%d\n", r, r->carat, buf, endpts);
        !          1717: -      }
        !          1718: -#endif
        !          1719: -      s = eg_startstate(r);
        !          1720: -      if(endpts&RE_BEG){
        !          1721: -              if(!r->carat){
        !          1722: -                      if(t = s->tab[RE_CARAT])
        !          1723: -                              s = t;
        !          1724: -                      else
        !          1725: -                              s = nextstate(r, s, RE_CARAT);
        !          1726: -                      if(s->out == FAIL)
        !          1727: -                              s = eg_startstate(r);
        !          1728: -              }
        !          1729: -              if(s->out){
        !          1730: -#ifdef        DEBUG
        !          1731: -                      if(TRACE(6))
        !          1732: -                              PR "match at ^: '%s' out=%d\n", b, s->out);
        !          1733: -#endif
        !          1734: -                      if(s->out == ACCEPT_EOP)
        !          1735: -                              return(b);
        !          1736: -                      else if(s->out == FAIL)
        !          1737: -                              return(0);
        !          1738: -                      outedness = 1;
        !          1739: -              }
        !          1740: -      }
        !          1741: -      /*
        !          1742: -              look for first match
        !          1743: -      */
        !          1744: -      if(outedness == 0)
        !          1745: -      for(; b < e; b++){
        !          1746: -#ifdef        DEBUG
        !          1747: -              if(TRACE(4))
        !          1748: -                      PR "state %d@%d[%d pos]: char '%c'\n", s-r->states, (int)s, s->npos, *b);
        !          1749: -#endif
        !          1750: -              if(t = s->tab[*(unsigned char *)b])
        !          1751: -                      s = t;
        !          1752: -              else
        !          1753: -                      s = nextstate(r, s, *(unsigned char *)b);
        !          1754: -              if(s->out){
        !          1755: -#ifdef        DEBUG
        !          1756: -                      if(TRACE(4))
        !          1757: -                              PR "    out=%d, state %d@%d\n", s->out,
        !          1758: -                                      s-r->states, (int)s);
        !          1759: -#endif
        !          1760: -                      b++;
        !          1761: -                      if((s->out == ACCEPT_EOP) || (s->out == FAIL))
        !          1762: -                              goto finish;
        !          1763: -                      outedness = 1;
        !          1764: -                      break;
        !          1765: -              }
        !          1766: -      }
        !          1767: -      /*
        !          1768: -              in the following loop, we have seen a match already
        !          1769: -              because only way outedness is zero is if b>=e
        !          1770: -      */
        !          1771: -      for(; b < e; b++){
        !          1772: -#ifdef        DEBUG
        !          1773: -              if(TRACE(4))
        !          1774: -                      PR "statex %d@%d[%d pos]: char '%c'\n", s-r->states, (int)s, s->npos, *b);
        !          1775: -#endif
        !          1776: -              if(t = s->tab[*(unsigned char *)b])
        !          1777: -                      s = t;
        !          1778: -              else
        !          1779: -                      s = nextstate(r, s, *(unsigned char *)b);
        !          1780: -              if(s->out == ACCEPT)
        !          1781: -                      continue;
        !          1782: -              if((s->out == NORMAL) || (s->out == FAIL)){
        !          1783: -#ifdef        DEBUG
        !          1784: -                      if(TRACE(6))
        !          1785: -                              PR "unmatch at input '%s' out=%d\n", b, s->out);
        !          1786: -#endif
        !          1787: -                      return(b);
        !          1788: -              }
        !          1789: -      }
        !          1790: -      if(endpts&RE_END){
        !          1791: -              if(t = s->tab[RE_DOLLAR])
        !          1792: -                      s = t;
        !          1793: -              else
        !          1794: -                      s = nextstate(r, s, RE_DOLLAR);
        !          1795: -      }
        !          1796: -finish:
        !          1797: -      if((s->out && (s->out != FAIL)) || outedness){
        !          1798: -#ifdef        DEBUG
        !          1799: -              if(TRACE(6))
        !          1800: -                      PR "match at $ '%s' out=%d\n", b, s->out);
        !          1801: -#endif
        !          1802: -              return(b);
        !          1803: -      }
        !          1804: -#ifdef        DEBUG
        !          1805: -      if(TRACE(3)){
        !          1806: -              char buf[EPRINTSIZE];
        !          1807: -
        !          1808: -              eg_epr(r->root, buf, 1);
        !          1809: -              PR "lqm('%s') failed; out=%d, s->out=%d \n", buf, outedness, s->out);
        !          1810: -      }
        !          1811: -#endif
        !          1812: -      return(0);
        !          1813: -}
        !          1814: -
        !          1815: -static
        !          1816: -match(register re_re *r, register Expr *e, int a)
        !          1817: -{
        !          1818: -      switch(e->type)
        !          1819: -      {
        !          1820: -      case Dollar:    return(a == RE_DOLLAR);
        !          1821: -      case Carat:     return(a == RE_CARAT);
        !          1822: -      case Dot:       return(a < 256);
        !          1823: -      case Literal:   return(r->mymap[a] == r->mymap[e->lit]);
        !          1824: -      case Charclass: if(a >= 256) return(0);
        !          1825: -                      return(memchr((char *)e->r, r->mymap[a], (int)e->l) != 0);
        !          1826: -      case Compcharclass:
        !          1827: -                      if(a >= 256) return(0);
        !          1828: -                      return(memchr((char *)e->r, r->mymap[a], (int)e->l) == 0);
        !          1829: -      }
        !          1830: -      return(0);
        !          1831: -}
        !          1832: -
        !          1833: -      /*
        !          1834: -              generates the followset for a node in firstpos
        !          1835: -      */
        !          1836: -
        !          1837: -static void
        !          1838: -follow(register re_re *r, register Expr *e)
        !          1839: -{
        !          1840: -      register Expr *p;
        !          1841: -
        !          1842: -      if(e->type == EOP)
        !          1843: -              return;
        !          1844: -      else
        !          1845: -              p = e->parent;
        !          1846: -      switch(p->type)
        !          1847: -      {
        !          1848: -      case EOP:
        !          1849: -              SET(r, firstpos, p->id)
        !          1850: -              break;
        !          1851: -      case Plus:
        !          1852: -      case Star:
        !          1853: -              (void)first(r, e);
        !          1854: -              follow(r, p);
        !          1855: -              break;
        !          1856: -      case Quest:
        !          1857: -      case Alternate:
        !          1858: -              follow(r, p);
        !          1859: -              break;
        !          1860: -      case Cat:
        !          1861: -              if(e == p->l){
        !          1862: -                      if(first(r, p->r) == 0){
        !          1863: -                              follow(r, p);
        !          1864: -                              break;
        !          1865: -                      }
        !          1866: -              } else
        !          1867: -                      follow(r, p);
        !          1868: -              break;
        !          1869: -      case Group:
        !          1870: -              follow(r, p);
        !          1871: -              break;
        !          1872: -      }
        !          1873: -}
        !          1874: -
        !          1875: -      /*
        !          1876: -              first returns 0 if e is nullable and in the process,
        !          1877: -              sets up firstpos.
        !          1878: -      */
        !          1879: -
        !          1880: -static
        !          1881: -first(register re_re *r, register Expr *e)
        !          1882: -{
        !          1883: -      int k;
        !          1884: -
        !          1885: -      switch(e->type)
        !          1886: -      {
        !          1887: -      case Carat:
        !          1888: -      case Dollar:
        !          1889: -      case Literal:
        !          1890: -      case Dot:
        !          1891: -      case Charclass:
        !          1892: -      case Compcharclass:
        !          1893: -              SET(r, firstpos, e->id)
        !          1894: -              return(1);
        !          1895: -      case EOP:
        !          1896: -      case Star:
        !          1897: -      case Quest:
        !          1898: -              (void)first(r, e->l);
        !          1899: -              return(0);
        !          1900: -      case Group:
        !          1901: -      case Plus:
        !          1902: -              return(first(r, e->l));
        !          1903: -      case Cat:
        !          1904: -              return(first(r, e->l) || first(r, e->r));
        !          1905: -      case Alternate:
        !          1906: -              k = first(r, e->r);
        !          1907: -              return(first(r, e->l) && k);
        !          1908: -      default:
        !          1909: -              EPR "bad type %d\n", e->type);
        !          1910: -              abort();
        !          1911: -              return(0);
        !          1912: -      }
        !          1913: -}
        !          1914: -
        !          1915: -static void
        !          1916: -efollow(register re_re *r, register Expr *e)
        !          1917: -{
        !          1918: -      register i, *p;
        !          1919: -
        !          1920: -      RESET(r, firstpos);
        !          1921: -      follow(r, e);
        !          1922: -      e->flen = r->firstpos.count;
        !          1923: -      e->follow = (int *)malloc((unsigned)(e->flen*sizeof(int)));
        !          1924: -      if(e->follow == 0){
        !          1925: -              char buf[100];
        !          1926: -              SPR buf, "efollow malloc fail(%ld)\n", e->flen);
        !          1927: -              re_error(buf);
        !          1928: -              return;
        !          1929: -      }
        !          1930: -      p = e->follow;
        !          1931: -      GET(r->firstpos, i)
        !          1932: -              *p++ = i;
        !          1933: -      if(p != e->follow+e->flen){
        !          1934: -              char buf[100];
        !          1935: -              SPR buf, "efollow length error: %d %ld\n", p-e->follow, e->flen);
        !          1936: -              re_error(buf);
        !          1937: -              return;
        !          1938: -      }
        !          1939: -}
        !          1940: -
        !          1941: -static State *
        !          1942: -addstate(register re_re *r, register Positionset *ps)
        !          1943: -{
        !          1944: -      register *p, j;
        !          1945: -      register State *s;
        !          1946: -
        !          1947: -      s = r->states + eg_getstate(r);
        !          1948: -      memset((char *)s->tab, 0, sizeof(s->tab));
        !          1949: -      s->pos = eg_posalloc(r, (int)ps->count);
        !          1950: -      s->npos = ps->count;
        !          1951: -      p = r->posbase+s->pos;
        !          1952: -      GET((*ps), j)
        !          1953: -              *p++ = j;
        !          1954: -      if(s->out = (ps->base[r->root->id] != 0)){
        !          1955: -              if((ps->base[r->root->id] <= 0) && (ps->last == r->root->id))
        !          1956: -                      s->out = ACCEPT_EOP;    /* marker for only the EOP marker */
        !          1957: -              else
        !          1958: -                      s->out = ACCEPT;
        !          1959: -      }
        !          1960: -      if(s->npos == 0)
        !          1961: -              s->out = FAIL;
        !          1962: -#ifdef        DEBUG
        !          1963: -      if(TRACE(3)){
        !          1964: -              char buf[2000];
        !          1965: -              eg_spr(s->npos, s->pos+r->posbase, buf);
        !          1966: -              PR "new state[%d]@%d %s,pos=%d out=%d\n", s-r->states, s, buf, s->pos, s->out);
        !          1967: -      }
        !          1968: -#endif
        !          1969: -      return(s);
        !          1970: -}
        !          1971: -
        !          1972: -static State *
        !          1973: -nextstate(register re_re *r, register State *s, int a)
        !          1974: -{
        !          1975: -      register int p, *q, *eq;
        !          1976: -      register long i;
        !          1977: -      State *news;
        !          1978: -      Expr *e;
        !          1979: -
        !          1980: -      RESET(r, tmp);
        !          1981: -#ifdef        DEBUG
        !          1982: -      if(TRACE(5)){
        !          1983: -              char buf[2000];
        !          1984: -              ppr(&r->tmp, buf);
        !          1985: -              PR "nextstate: reset: %s\n", buf);
        !          1986: -      }
        !          1987: -#endif
        !          1988: -      for(i = s->npos, p = s->pos; i > 0; i--){
        !          1989: -              e = r->ptr[r->posbase[p++]];
        !          1990: -#ifdef        DEBUG
        !          1991: -              if(TRACE(11)){
        !          1992: -                      PR "i=%d e->type=%d\n", i, e->type);
        !          1993: -              }
        !          1994: -#endif
        !          1995: -              if(e->type == EOP) continue;
        !          1996: -              if(match(r, e, a)){
        !          1997: -#ifdef        DEBUG
        !          1998: -                      if(TRACE(11)){PR "matched %c\n", a);}
        !          1999: -#endif
        !          2000: -                      if(e->follow == 0)
        !          2001: -                              efollow(r, e);
        !          2002: -                      for(q = e->follow, eq = q+e->flen; q < eq; q++){
        !          2003: -                              SET(r, tmp, *q)
        !          2004: -                      }
        !          2005: -              }
        !          2006: -      }
        !          2007: -#ifdef        DEBUG
        !          2008: -      if(TRACE(5)){
        !          2009: -              char buf[2000];
        !          2010: -              ppr(&r->tmp, buf);
        !          2011: -              PR "nextstate(%d, '%c'): found %s\n", s-r->states, a, buf);
        !          2012: -      }
        !          2013: -#endif
        !          2014: -      if(news = eg_stateof(r, &r->tmp)){
        !          2015: -              if(a <= RE_DOLLAR)
        !          2016: -                      s->tab[a] = news;
        !          2017: -      } else
        !          2018: -              news = addstate(r, &r->tmp);
        !          2019: -#ifdef        DEBUG
        !          2020: -      if(TRACE(5)){
        !          2021: -              PR "nextstate(%d, '%c'): returning %ld %d out=%d\n", s-r->states, a,
        !          2022: -                      (long)news, news-r->states, news->out);
        !          2023: -      }
        !          2024: -#endif
        !          2025: -      return(news);
        !          2026: -}
        !          2027: -
        !          2028: -void *
        !          2029: -egmalloc(int n, char *s)
        !          2030: -{
        !          2031: -      char *x;
        !          2032: -      char buf[256];
        !          2033: -
        !          2034: -      if((x = malloc(n)) == 0){
        !          2035: -              SPR buf, "malloc fail(%d): %s", n, s);
        !          2036: -              re_error(buf);
        !          2037: -              return 0;
        !          2038: -      }
        !          2039: -      return((void *)x);
        !          2040: -}
        !          2041: -
        !          2042: -void *
        !          2043: -egrealloc(char *p, int n, char *s)
        !          2044: -{
        !          2045: -      char *x;
        !          2046: -      char buf[256];
        !          2047: -
        !          2048: -      if((x = realloc(p, n)) == 0){
        !          2049: -              SPR buf, "realloc fail(%d): %s", n, s);
        !          2050: -              re_error(buf);
        !          2051: -              return 0;
        !          2052: -      }
        !          2053: -      return((void *)x);
        !          2054: -}
        !          2055: -
        !          2056: -#ifdef        DEBUG
        !          2057: -static void
        !          2058: -ppr(register Positionset *ps, register char *p)
        !          2059: -{
        !          2060: -      register n;
        !          2061: -
        !          2062: -      if(ps->count < 1){
        !          2063: -              SPR p, "{}");
        !          2064: -              return;
        !          2065: -      }
        !          2066: -      *p++ = '{';
        !          2067: -      GET((*ps), n){
        !          2068: -              SPR p, "%d[=%d],", n, ps->base[n]);
        !          2069: -              p = strchr(p, 0);
        !          2070: -      }
        !          2071: -      p[-1] = '}';
        !          2072: -}
        !          2073: -#endif
        !          2074: //GO.SYSIN DD eg.c
        !          2075: echo egcomp.c 1>&2
        !          2076: sed 's/.//' >egcomp.c <<'//GO.SYSIN DD egcomp.c'
        !          2077: -#include      "re.h"
        !          2078: -#include      "lre.h"
        !          2079: -#include      "hdr.h"
        !          2080: -
        !          2081: -static Exprtype toktype;
        !          2082: -static int toklit;
        !          2083: -static char *beg, *end;
        !          2084: -static int maxid;
        !          2085: -static Expr *e0(void);
        !          2086: -static Expr *d0(void);
        !          2087: -static Expr *r18(void);
        !          2088: -static void err(char*);
        !          2089: -static int parno;
        !          2090: -static jmp_buf gohome;
        !          2091: -static unsigned char *mymap;
        !          2092: -
        !          2093: -void
        !          2094: -egpost(re_re *r)
        !          2095: -{
        !          2096: -      r->maxid = maxid;
        !          2097: -      r->backref = r->root->backref;
        !          2098: -      r->parens = r->root->parens;
        !          2099: -}
        !          2100: -
        !          2101: -Expr *
        !          2102: -eg_newexpr(Exprtype t, int l, Expr *left, Expr *right)
        !          2103: -{
        !          2104: -      register Expr *e = (Expr *)egmalloc(sizeof(Expr), "eg_newexpr");
        !          2105: -
        !          2106: -      if (!e)
        !          2107: -              return 0;
        !          2108: -      e->type = t;
        !          2109: -      e->parent = 0;
        !          2110: -      e->lit = l;
        !          2111: -      if(e->lit)
        !          2112: -              e->id = maxid++;
        !          2113: -      else
        !          2114: -              e->id = 0;
        !          2115: -      e->backref = 0;
        !          2116: -      e->parens = 0;
        !          2117: -      if(e->l = left){
        !          2118: -              left->parent = e;
        !          2119: -              if(left->backref) e->backref = 1;
        !          2120: -              if(left->parens) e->parens = 1;
        !          2121: -      }
        !          2122: -      if(e->r = right){
        !          2123: -              right->parent = e;
        !          2124: -              if(right->backref) e->backref = 1;
        !          2125: -              if(right->parens) e->parens = 1;
        !          2126: -      }
        !          2127: -      e->follow = 0;
        !          2128: -      e->flen = 0;
        !          2129: -      e->reallit = 0;
        !          2130: -      return(e);
        !          2131: -}
        !          2132: -
        !          2133: -void
        !          2134: -eg_lexinit(char *b, char *e)
        !          2135: -{
        !          2136: -      beg = b;
        !          2137: -      end = e;
        !          2138: -      maxid = 1;
        !          2139: -      parno = 1;
        !          2140: -}
        !          2141: -
        !          2142: -void
        !          2143: -eg_lex(void)
        !          2144: -{
        !          2145: -      if(beg == end){
        !          2146: -              toktype = EOP;
        !          2147: -              toklit = -1;
        !          2148: -      } else switch(toklit = *beg++)
        !          2149: -      {
        !          2150: -      case '.':       toktype = Dot; break;
        !          2151: -      case '*':       toktype = Star; break;
        !          2152: -      case '+':       toktype = Plus; break;
        !          2153: -      case '?':       toktype = Quest; break;
        !          2154: -      case '^':       toktype = Carat; break;
        !          2155: -      case '$':       toktype = Dollar; break;
        !          2156: -      case '[':       toktype = Charclass; break;
        !          2157: -      case '\n':
        !          2158: -      case '|':       toktype = Alternate; break;
        !          2159: -      case '(':       toktype = Lpar; break;
        !          2160: -      case ')':       toktype = Rpar; break;
        !          2161: -      case '\\':      toktype = Backslash;
        !          2162: -                      if(beg == end)
        !          2163: -                              err("bad \\");
        !          2164: -                      else
        !          2165: -                              toklit = *beg++;
        !          2166: -                      break;
        !          2167: -      default:        toktype = Literal; break;
        !          2168: -      }
        !          2169: -}
        !          2170: -
        !          2171: -void
        !          2172: -eg_epr(register Expr *e, char *res, int doset)
        !          2173: -{
        !          2174: -      char r1[EPRINTSIZE], r2[EPRINTSIZE], rid[EPRINTSIZE];
        !          2175: -      int ids = 0;            /* sort of a debugging flag */
        !          2176: -
        !          2177: -      if(e == 0){
        !          2178: -              SPR res, "!0!");
        !          2179: -              return;
        !          2180: -      }
        !          2181: -      r1[0] = 0;
        !          2182: -      if(ids)
        !          2183: -              SPR rid, "%d:", e->id);
        !          2184: -      else
        !          2185: -              rid[0] = 0;
        !          2186: -      switch(e->type)
        !          2187: -      {
        !          2188: -      case Literal:
        !          2189: -              if(doset)
        !          2190: -                      eg_spr(e->flen, e->follow, r1);
        !          2191: -              SPR res, "%s'%c'%s", rid, e->lit, r1);
        !          2192: -              break;
        !          2193: -      case Dot:
        !          2194: -      case Carat:
        !          2195: -      case Dollar:
        !          2196: -              if(doset)
        !          2197: -                      eg_spr(e->flen, e->follow, r1);
        !          2198: -              SPR res, "%s%c%s", rid, e->lit, r1);
        !          2199: -              break;
        !          2200: -      case Compcharclass:
        !          2201: -      case Charclass:
        !          2202: -              *res++ = '[';
        !          2203: -              if(e->type == Compcharclass)
        !          2204: -                      *res++ = '^';
        !          2205: -              memmove(res, (char *)e->r, (int)e->l);
        !          2206: -              res += (int)e->l;
        !          2207: -              *res++ = ']';
        !          2208: -              *res = 0;
        !          2209: -              break;
        !          2210: -      case Cat:
        !          2211: -              eg_epr(e->l, r1, doset);
        !          2212: -              eg_epr(e->r, r2, doset);
        !          2213: -              SPR res, "%s%s%s", rid, r1, r2);
        !          2214: -              break;
        !          2215: -      case Alternate:
        !          2216: -              eg_epr(e->l, r1, doset);
        !          2217: -              eg_epr(e->r, r2, doset);
        !          2218: -              SPR res, "%s(%s|%s)", rid, r1, r2);
        !          2219: -              break;
        !          2220: -      case Star:
        !          2221: -              eg_epr(e->l, r1, doset);
        !          2222: -              SPR res, "%s(%s)*", rid, r1);
        !          2223: -              break;
        !          2224: -      case Plus:
        !          2225: -              eg_epr(e->l, r1, doset);
        !          2226: -              SPR res, "%s(%s)+", rid, r1);
        !          2227: -              break;
        !          2228: -      case Quest:
        !          2229: -              eg_epr(e->l, r1, doset);
        !          2230: -              SPR res, "%s(%s)?", rid, r1);
        !          2231: -              break;
        !          2232: -      case Group:
        !          2233: -              eg_epr(e->l, r1, doset);
        !          2234: -              SPR res, "%sG<%s>", rid, r1);
        !          2235: -              break;
        !          2236: -      case EOP:
        !          2237: -              eg_epr(e->l, r1, doset);
        !          2238: -              SPR res, "%s%s<EOP>", rid, r1);
        !          2239: -              break;
        !          2240: -      case Backref:
        !          2241: -              SPR res, "%s\\%d", rid, e->lit);
        !          2242: -              break;
        !          2243: -      default:
        !          2244: -              SPR res, "<undef type %d>", e->type);
        !          2245: -              err(res);
        !          2246: -              break;
        !          2247: -      }
        !          2248: -}
        !          2249: -
        !          2250: -static void
        !          2251: -ccl(int *count, char **str, int oldrange)
        !          2252: -{
        !          2253: -      register n;
        !          2254: -      int cnt;
        !          2255: -      char tab[256], *s;
        !          2256: -      int range, lastc, i;
        !          2257: -
        !          2258: -#define       TSET(b) {if(tab[n = mymap[(b)]] == 0){ tab[n] = 1; cnt++; } }
        !          2259: -
        !          2260: -      cnt = 0;
        !          2261: -      memset(tab, 0, sizeof tab);
        !          2262: -      lastc = -1;
        !          2263: -      range = 0;
        !          2264: -      /* scan for chars */
        !          2265: -      for(; (beg < end); beg++){
        !          2266: -              toklit = *beg;
        !          2267: -              if(*beg == ']'){
        !          2268: -                      if(!oldrange)
        !          2269: -                              break;
        !          2270: -                      if(lastc >= 0)
        !          2271: -                              break;
        !          2272: -              }
        !          2273: -              if(*beg == '-'){
        !          2274: -                      if(lastc < 0){
        !          2275: -                              TSET('-')
        !          2276: -                              lastc = *(unsigned char *)beg;
        !          2277: -                      } else
        !          2278: -                              range = 1;
        !          2279: -                      continue;
        !          2280: -              }
        !          2281: -              if(*beg == '\\'){
        !          2282: -                      if(++beg >= end){
        !          2283: -                              err("unexpected eop after \\ in char class");
        !          2284: -                              beg--;
        !          2285: -                      }
        !          2286: -              }
        !          2287: -              if(range){
        !          2288: -                      for(i = *(unsigned char *)beg; i >= lastc; i--)
        !          2289: -                              TSET(i)
        !          2290: -                      range = 0;
        !          2291: -              } else
        !          2292: -                      TSET(*(unsigned char *)beg)
        !          2293: -              lastc = *(unsigned char *)beg;
        !          2294: -      }
        !          2295: -      if(range){
        !          2296: -              if(oldrange)
        !          2297: -                      TSET('-')
        !          2298: -              else
        !          2299: -                      err("unterminated range in []");
        !          2300: -      }
        !          2301: -      if(beg < end)
        !          2302: -              beg++;
        !          2303: -      else
        !          2304: -              err("eop during ccl");
        !          2305: -      if(cnt == 0)
        !          2306: -              err("empty charclass");
        !          2307: -      eg_lex();
        !          2308: -      *count = cnt;
        !          2309: -      *str = s = (char *)egmalloc(cnt, "charclass defn");
        !          2310: -      if (!s)
        !          2311: -              return;
        !          2312: -      for(n = 0; n < 256; n++)
        !          2313: -              if(tab[n])
        !          2314: -                      *s++ = n;
        !          2315: -}
        !          2316: -
        !          2317: -/*
        !          2318: -      gre patterns:
        !          2319: -
        !          2320: -      e0:     e1 { '|' e1 }*
        !          2321: -      e1:     e2 { e2 }*
        !          2322: -      e2:     e3 { '*' | '?' | '+' | \{ m,n \} }*
        !          2323: -      e3:     lit | '.' | '^' | '$' | '(' e0 ')'
        !          2324: -*/
        !          2325: -
        !          2326: -static Expr *
        !          2327: -e3(void)
        !          2328: -{
        !          2329: -      Expr *e;
        !          2330: -      Exprtype t;
        !          2331: -      int cnt;
        !          2332: -      char *s;
        !          2333: -
        !          2334: -      switch(toktype)
        !          2335: -      {
        !          2336: -      case Backslash:
        !          2337: -              if((toklit >= '1') && (toklit <= '9')){
        !          2338: -                      e = eg_newexpr(Backref, toklit-'0', (Expr *)0, (Expr *)0);
        !          2339: -                      e->backref = 1;
        !          2340: -              } else
        !          2341: -                      e = eg_newexpr(Literal, toklit, (Expr *)0, (Expr *)0);
        !          2342: -              eg_lex();
        !          2343: -              break;
        !          2344: -      case Literal:
        !          2345: -              e = eg_newexpr(Literal, toklit, (Expr *)0, (Expr *)0);
        !          2346: -              eg_lex();
        !          2347: -              break;
        !          2348: -      case Dot:
        !          2349: -              e = eg_newexpr(Dot, '.', (Expr *)0, (Expr *)0);
        !          2350: -              eg_lex();
        !          2351: -              break;
        !          2352: -      case Carat:
        !          2353: -              e = eg_newexpr(Carat, '^', (Expr *)0, (Expr *)0);
        !          2354: -              eg_lex();
        !          2355: -              break;
        !          2356: -      case Dollar:
        !          2357: -              e = eg_newexpr(Dollar, '$', (Expr *)0, (Expr *)0);
        !          2358: -              eg_lex();
        !          2359: -              break;
        !          2360: -      case Charclass:
        !          2361: -              t = toktype;
        !          2362: -              if(*beg == '^'){
        !          2363: -                      t = Compcharclass;
        !          2364: -                      beg++;
        !          2365: -              }
        !          2366: -              ccl(&cnt, &s, 0);
        !          2367: -              e = eg_newexpr(t, '[', (Expr *)0, (Expr *)0);
        !          2368: -              e->l = (Expr *)cnt;     /* num of chars */
        !          2369: -              e->r = (Expr *)s;       /* chars */
        !          2370: -              break;
        !          2371: -      case Lpar:
        !          2372: -              eg_lex();
        !          2373: -              cnt = parno++;
        !          2374: -              e = e0();
        !          2375: -              if(toktype == Rpar)
        !          2376: -                      eg_lex();
        !          2377: -              else
        !          2378: -                      err("expected a ')'");
        !          2379: -              e = eg_newexpr(Group, cnt, e, (Expr *)0);
        !          2380: -              e->parens = 1;
        !          2381: -              return(e);
        !          2382: -      case EOP:
        !          2383: -      default:
        !          2384: -              err("expected a lit or '('");
        !          2385: -              e = 0;
        !          2386: -      }
        !          2387: -      return(e);
        !          2388: -}
        !          2389: -
        !          2390: -static int
        !          2391: -integer(void)
        !          2392: -{
        !          2393: -      int n;
        !          2394: -
        !          2395: -      n = 0;
        !          2396: -      while((toktype == Literal) && (toklit >= '0') && (toklit <= '9')){
        !          2397: -              n = 10*n + toklit-'0';
        !          2398: -              eg_lex();
        !          2399: -      }
        !          2400: -      return(n);
        !          2401: -}
        !          2402: -
        !          2403: -static Expr *
        !          2404: -ecopy(Expr *e)
        !          2405: -{
        !          2406: -      Expr *ee;
        !          2407: -      char res[256];
        !          2408: -
        !          2409: -      if(e == 0)
        !          2410: -              return(e);
        !          2411: -      switch(e->type)
        !          2412: -      {
        !          2413: -      case Literal:
        !          2414: -      case Dot:
        !          2415: -      case Carat:
        !          2416: -      case Dollar:
        !          2417: -      case Backref:
        !          2418: -              return(eg_newexpr(e->type, e->lit, (Expr *)0, (Expr *)0));
        !          2419: -      case Compcharclass:
        !          2420: -      case Charclass:
        !          2421: -              ee = eg_newexpr(e->type, e->lit, (Expr *)0, (Expr *)0);
        !          2422: -              ee->r = (Expr *)egmalloc((int)e->l, "expr copy");
        !          2423: -              if (!ee->r)
        !          2424: -                      return 0;
        !          2425: -              ee->l = e->l;
        !          2426: -              memmove((char *)ee->r, (char *)e->r, (int)e->l);
        !          2427: -              return(ee);
        !          2428: -      case Cat:
        !          2429: -      case Alternate:
        !          2430: -              return(eg_newexpr(e->type, e->lit, ecopy(e->l), ecopy(e->r)));
        !          2431: -      case Star:
        !          2432: -      case Plus:
        !          2433: -      case Quest:
        !          2434: -      case Group:
        !          2435: -      case EOP:
        !          2436: -              return(eg_newexpr(e->type, e->lit, ecopy(e->l), (Expr *)0));
        !          2437: -      default:
        !          2438: -              SPR res, "<undef type %d>", e->type);
        !          2439: -              err(res);
        !          2440: -              return((Expr *)0);
        !          2441: -      }
        !          2442: -}
        !          2443: -
        !          2444: -static Expr *
        !          2445: -edup(Expr *expr, int n, int opt)
        !          2446: -{
        !          2447: -      if(n == 1){
        !          2448: -              expr = ecopy(expr);
        !          2449: -              if(opt)
        !          2450: -                      expr = eg_newexpr(Quest, 0, expr, (Expr *)0);
        !          2451: -              return(expr);
        !          2452: -      }
        !          2453: -      return(eg_newexpr(Cat, 0, edup(expr, n-n/2, opt), edup(expr, n/2, opt)));
        !          2454: -}
        !          2455: -
        !          2456: -static Expr *
        !          2457: -range(Expr *expr)
        !          2458: -{
        !          2459: -      int beg, end;
        !          2460: -      Expr *e, *e1;
        !          2461: -
        !          2462: -      if((toktype == Literal) && (toklit >= '0') && (toklit <= '9'))
        !          2463: -              beg = integer();
        !          2464: -      else
        !          2465: -              err("expected a number in range");
        !          2466: -      if((toktype == Literal) && (toklit == ',')){
        !          2467: -              end = -1;
        !          2468: -              eg_lex();
        !          2469: -      } else
        !          2470: -              end = -2;
        !          2471: -      if((toktype == Literal) && (toklit >= '0') && (toklit <= '9'))
        !          2472: -              end = integer();
        !          2473: -      if((toktype == Backslash) && (toklit == '}'))
        !          2474: -              eg_lex();
        !          2475: -      else
        !          2476: -              err("expected \\} in range");
        !          2477: -      e1 = edup(expr, beg, 0);
        !          2478: -      if(end == -2)
        !          2479: -              e = e1;
        !          2480: -      else if(end == -1)
        !          2481: -              e = eg_newexpr(Cat, 0, e1, eg_newexpr(Star, 0, expr, (Expr *)0));
        !          2482: -      else {
        !          2483: -              if(end < beg)
        !          2484: -                      err("bad range specification");
        !          2485: -              e = (end > beg)? eg_newexpr(Cat, 0, e1, edup(expr, end-beg, 1)) : e1;
        !          2486: -      }
        !          2487: -      return(e);
        !          2488: -}
        !          2489: -
        !          2490: -static Expr *
        !          2491: -e2(void)
        !          2492: -{
        !          2493: -      Expr *e;
        !          2494: -      Exprtype t;
        !          2495: -
        !          2496: -      e = e3();
        !          2497: -      while((toktype == Star) || (toktype == Plus) || (toktype == Quest)
        !          2498: -                      || ((toktype == Backslash) && (toklit == '{'))){
        !          2499: -              if((toktype == Backslash) && (toklit == '{')){
        !          2500: -                      eg_lex();
        !          2501: -                      e = range(e);
        !          2502: -              } else {
        !          2503: -                      t = toktype;
        !          2504: -                      eg_lex();
        !          2505: -                      e = eg_newexpr(t, 0, e, (Expr *)0);
        !          2506: -              }
        !          2507: -      }
        !          2508: -      return(e);
        !          2509: -}
        !          2510: -
        !          2511: -static Expr *
        !          2512: -e1(void)
        !          2513: -{
        !          2514: -      Expr *e, *f;
        !          2515: -
        !          2516: -      e = e2();
        !          2517: -      while((toktype == Literal) || (toktype == Dot) || (toktype == Lpar)
        !          2518: -                      || (toktype == Backslash) || (toktype == Dollar)
        !          2519: -                      || (toktype == Carat) || (toktype == Charclass)){
        !          2520: -              f = e2();
        !          2521: -              e = eg_newexpr(Cat, 0, e, f);
        !          2522: -      }
        !          2523: -      return(e);
        !          2524: -}
        !          2525: -
        !          2526: -static Expr *
        !          2527: -e0(void)
        !          2528: -{
        !          2529: -      Expr *e, *f;
        !          2530: -
        !          2531: -      e = e1();
        !          2532: -      while(toktype == Alternate){
        !          2533: -              eg_lex();
        !          2534: -              if(toktype == EOP)
        !          2535: -                      continue;
        !          2536: -              f = e1();
        !          2537: -              e = eg_newexpr(Alternate, 0, e, f);
        !          2538: -      }
        !          2539: -      return(e);
        !          2540: -}
        !          2541: -
        !          2542: -/*
        !          2543: -      egrep patterns:
        !          2544: -
        !          2545: -      d0:     d1 { '|' d1 }*
        !          2546: -      d1:     d2 { d2 }*
        !          2547: -      d2:     d3 { '*' | '?' | '+' }
        !          2548: -      d3:     lit | '.' | '^' | '$' | '(' d0 ')'
        !          2549: -*/
        !          2550: -
        !          2551: -static Expr *
        !          2552: -d3(void)
        !          2553: -{
        !          2554: -      Expr *e;
        !          2555: -      Exprtype t;
        !          2556: -      int cnt;
        !          2557: -      char *s;
        !          2558: -
        !          2559: -      switch(toktype)
        !          2560: -      {
        !          2561: -      case Backslash:
        !          2562: -      case Literal:
        !          2563: -              e = eg_newexpr(Literal, toklit, (Expr *)0, (Expr *)0);
        !          2564: -              eg_lex();
        !          2565: -              break;
        !          2566: -      case Dot:
        !          2567: -              e = eg_newexpr(Dot, '.', (Expr *)0, (Expr *)0);
        !          2568: -              eg_lex();
        !          2569: -              break;
        !          2570: -      case Carat:
        !          2571: -              e = eg_newexpr(Carat, '^', (Expr *)0, (Expr *)0);
        !          2572: -              eg_lex();
        !          2573: -              break;
        !          2574: -      case Dollar:
        !          2575: -              e = eg_newexpr(Dollar, '$', (Expr *)0, (Expr *)0);
        !          2576: -              eg_lex();
        !          2577: -              break;
        !          2578: -      case Charclass:
        !          2579: -              t = toktype;
        !          2580: -              if(*beg == '^'){
        !          2581: -                      t = Compcharclass;
        !          2582: -                      beg++;
        !          2583: -              }
        !          2584: -              ccl(&cnt, &s, 1);
        !          2585: -              e = eg_newexpr(t, '[', (Expr *)0, (Expr *)0);
        !          2586: -              e->l = (Expr *)cnt;     /* num of chars */
        !          2587: -              e->r = (Expr *)s;       /* chars */
        !          2588: -              break;
        !          2589: -      case Lpar:
        !          2590: -              eg_lex();
        !          2591: -              e = d0();
        !          2592: -              if(toktype == Rpar)
        !          2593: -                      eg_lex();
        !          2594: -              else
        !          2595: -                      err("expected a ')'");
        !          2596: -              return(e);
        !          2597: -      default:
        !          2598: -              err("expected a lit or '('");
        !          2599: -              e = 0;
        !          2600: -      }
        !          2601: -      return(e);
        !          2602: -}
        !          2603: -
        !          2604: -static Expr *
        !          2605: -d2(void)
        !          2606: -{
        !          2607: -      Expr *e;
        !          2608: -      Exprtype t;
        !          2609: -
        !          2610: -      e = d3();
        !          2611: -      while((toktype == Star) || (toktype == Plus) || (toktype == Quest)){
        !          2612: -              t = toktype;
        !          2613: -              eg_lex();
        !          2614: -              e = eg_newexpr(t, 0, e, (Expr *)0);
        !          2615: -      }
        !          2616: -      return(e);
        !          2617: -}
        !          2618: -
        !          2619: -static Expr *
        !          2620: -d1(void)
        !          2621: -{
        !          2622: -      Expr *e, *f;
        !          2623: -
        !          2624: -      e = d2();
        !          2625: -      while((toktype == Literal) || (toktype == Dot) || (toktype == Lpar)
        !          2626: -                      || (toktype == Dollar) || (toktype == Backslash)
        !          2627: -                      || (toktype == Carat) || (toktype == Charclass)){
        !          2628: -              f = d2();
        !          2629: -              e = eg_newexpr(Cat, 0, e, f);
        !          2630: -      }
        !          2631: -      return(e);
        !          2632: -}
        !          2633: -
        !          2634: -static Expr *
        !          2635: -d0(void)
        !          2636: -{
        !          2637: -      Expr *e, *f;
        !          2638: -
        !          2639: -      e = d1();
        !          2640: -      while(toktype == Alternate){
        !          2641: -              eg_lex();
        !          2642: -              if(toktype == EOP)
        !          2643: -                      continue;
        !          2644: -              f = d1();
        !          2645: -              e = eg_newexpr(Alternate, 0, e, f);
        !          2646: -      }
        !          2647: -      return(e);
        !          2648: -}
        !          2649: -
        !          2650: -/*
        !          2651: -      grep patterns:
        !          2652: -
        !          2653: -      r0:     r18 | '^' r18 | '^' r18 '$' | r18 '$'
        !          2654: -      r18:    r17 { r17 }*
        !          2655: -      r17:    r14 | r14 '*' | '\(' r18 '\)'
        !          2656: -      r14:    lit | '.' | '*' | '\' d
        !          2657: -*/
        !          2658: -
        !          2659: -static Expr *
        !          2660: -r14(void)
        !          2661: -{
        !          2662: -      Expr *e;
        !          2663: -      Exprtype t;
        !          2664: -      int cnt;
        !          2665: -      char *s;
        !          2666: -
        !          2667: -      switch(toktype)
        !          2668: -      {
        !          2669: -      case Alternate:
        !          2670: -      case Plus:
        !          2671: -      case Quest:
        !          2672: -      case Star:
        !          2673: -      case Lpar:
        !          2674: -      case Rpar:
        !          2675: -      case Dollar:
        !          2676: -      case Carat:
        !          2677: -      case Literal:
        !          2678: -              e = eg_newexpr(Literal, toklit, (Expr *)0, (Expr *)0);
        !          2679: -              eg_lex();
        !          2680: -              break;
        !          2681: -      case Backslash:
        !          2682: -              if((toklit >= '1') && (toklit <= '9')){
        !          2683: -                      e = eg_newexpr(Backref, toklit-'0', (Expr *)0, (Expr *)0);
        !          2684: -                      e->backref = 1;
        !          2685: -              } else {
        !          2686: -                      e = eg_newexpr(Literal, toklit, (Expr *)0, (Expr *)0);
        !          2687: -                      e->reallit = 1;
        !          2688: -              }
        !          2689: -              eg_lex();
        !          2690: -              break;
        !          2691: -      case Dot:
        !          2692: -              e = eg_newexpr(Dot, '.', (Expr *)0, (Expr *)0);
        !          2693: -              eg_lex();
        !          2694: -              break;
        !          2695: -      case Charclass:
        !          2696: -              t = toktype;
        !          2697: -              if(*beg == '^'){
        !          2698: -                      t = Compcharclass;
        !          2699: -                      beg++;
        !          2700: -              }
        !          2701: -              ccl(&cnt, &s, 1);
        !          2702: -              e = eg_newexpr(t, '[', (Expr *)0, (Expr *)0);
        !          2703: -              e->l = (Expr *)cnt;     /* num of chars */
        !          2704: -              e->r = (Expr *)s;       /* chars */
        !          2705: -              break;
        !          2706: -      default:
        !          2707: -              err("expected a one-char RE");
        !          2708: -              eg_lex();               /* make sure we don't loop */
        !          2709: -              e = 0;
        !          2710: -      }
        !          2711: -      return(e);
        !          2712: -}
        !          2713: -
        !          2714: -static Expr *
        !          2715: -r17(void)
        !          2716: -{
        !          2717: -      Expr *e;
        !          2718: -      int cnt;
        !          2719: -
        !          2720: -      if((toktype == Backslash) && (toklit == '(')){
        !          2721: -              eg_lex();
        !          2722: -              cnt = parno++;
        !          2723: -              e = r18();
        !          2724: -              if((toktype == Backslash) && (toklit == ')'))
        !          2725: -                      eg_lex();
        !          2726: -              else
        !          2727: -                      err("expected a closing \\)");
        !          2728: -              e = eg_newexpr(Group, cnt, e, (Expr *)0);
        !          2729: -              e->parens = 1;
        !          2730: -      } else {
        !          2731: -              e = r14();
        !          2732: -              if(toktype == Star){
        !          2733: -                      e = eg_newexpr(Star, 0, e, (Expr *)0);
        !          2734: -                      eg_lex();
        !          2735: -              }
        !          2736: -      }
        !          2737: -      return(e);
        !          2738: -}
        !          2739: -
        !          2740: -static Expr *
        !          2741: -r18(void)
        !          2742: -{
        !          2743: -      Expr *e, *f;
        !          2744: -
        !          2745: -      e = r17();
        !          2746: -      while(toktype != EOP){
        !          2747: -              if((toktype == Backslash) && (toklit == ')'))
        !          2748: -                      break;
        !          2749: -              f = r17();
        !          2750: -              e = eg_newexpr(Cat, 0, e, f);
        !          2751: -      }
        !          2752: -      return(e);
        !          2753: -}
        !          2754: -
        !          2755: -static Expr *
        !          2756: -r0(void)
        !          2757: -{
        !          2758: -      Expr *e, *e1;
        !          2759: -
        !          2760: -      if(toktype == Carat){
        !          2761: -              e1 = eg_newexpr(Carat, '^', (Expr *)0, (Expr *)0);
        !          2762: -              eg_lex();
        !          2763: -      } else
        !          2764: -              e1 = 0;
        !          2765: -      if(toktype == EOP)
        !          2766: -              e = e1;
        !          2767: -      else {
        !          2768: -              e = r18();
        !          2769: -              /* did we see a dollar that is not a literal? */
        !          2770: -              if(e && (toktype == EOP)){
        !          2771: -                      /* singleton dollar */
        !          2772: -                      if((e->type == Literal) && (e->lit == '$'))
        !          2773: -                              e->type = Dollar;
        !          2774: -                      /* any other dollar */
        !          2775: -                      if((e->type == Cat) && !e->r->reallit && (e->r->type == Literal)
        !          2776: -                                      && (e->r->lit == '$'))
        !          2777: -                              e->r->type = Dollar;
        !          2778: -              }
        !          2779: -              if(e1){
        !          2780: -                      if(e)
        !          2781: -                              e = eg_newexpr(Cat, 0, e1, e);
        !          2782: -                      else
        !          2783: -                              e = e1;
        !          2784: -              }
        !          2785: -      }
        !          2786: -      if(toktype == Dollar){
        !          2787: -              if(e)
        !          2788: -                      e = eg_newexpr(Cat, 0, e, eg_newexpr(Dollar, '$', (Expr *)0, (Expr *)0));
        !          2789: -              else
        !          2790: -                      e = eg_newexpr(Dollar, '$', (Expr *)0, (Expr *)0);
        !          2791: -              eg_lex();
        !          2792: -      }
        !          2793: -      return(e);
        !          2794: -}
        !          2795: -
        !          2796: -Expr *
        !          2797: -eg_eall(enum Parsetype type, unsigned char *map)
        !          2798: -{
        !          2799: -      Expr *e;
        !          2800: -
        !          2801: -      mymap = map;
        !          2802: -      if(setjmp(gohome) == 0){
        !          2803: -              if(type == egrepparse)
        !          2804: -                      while(toktype == Alternate)     /* bogus but user-friendly */
        !          2805: -                              eg_lex();
        !          2806: -              switch(type)
        !          2807: -              {
        !          2808: -              case greparse:          e = e0(); break;
        !          2809: -              case grepparse:         e = r0(); break;
        !          2810: -              case egrepparse:        e = d0(); break;
        !          2811: -              }
        !          2812: -              if(type == egrepparse)
        !          2813: -                      while(toktype == Alternate)     /* bogus but user-friendly */
        !          2814: -                              eg_lex();
        !          2815: -              if(toktype != EOP)
        !          2816: -                      err("expected end of pattern");
        !          2817: -      } else
        !          2818: -              e = 0;
        !          2819: -/*{char buf1[4096]; e, buf1, 0); print("e='%s'\n", buf1);}/**/
        !          2820: -      return(e);
        !          2821: -}
        !          2822: -
        !          2823: -void
        !          2824: -eg_spr(long c, int *p, register char *buf)
        !          2825: -{
        !          2826: -      if(c > 0){
        !          2827: -              *buf++ = '{';
        !          2828: -              *buf = 0;
        !          2829: -              while(--c > 0){
        !          2830: -                      SPR buf, "%d,", *p++);
        !          2831: -                      buf = strchr(buf, 0);
        !          2832: -              }
        !          2833: -              SPR buf, "%d}", *p);
        !          2834: -      } else
        !          2835: -              SPR buf, "{}");
        !          2836: -}
        !          2837: -
        !          2838: -static void
        !          2839: -err(char *s)
        !          2840: -{
        !          2841: -      char buf[4096];
        !          2842: -
        !          2843: -      if(toklit < 0)
        !          2844: -              SPR buf, "expression error: %s but got end of expression", s);
        !          2845: -      else
        !          2846: -              SPR buf, "expression error: %s near '%c'", s, toklit);
        !          2847: -      re_error(buf);
        !          2848: -      longjmp(gohome, 1);
        !          2849: -}
        !          2850: //GO.SYSIN DD egcomp.c
        !          2851: echo eglit.c 1>&2
        !          2852: sed 's/.//' >eglit.c <<'//GO.SYSIN DD eglit.c'
        !          2853: -#include      "re.h"
        !          2854: -#include      "lre.h"
        !          2855: -#include      "hdr.h"
        !          2856: -
        !          2857: -static void traverse(Expr *);
        !          2858: -
        !          2859: -#define       MAXLIT  256     /* is plenty big enough */
        !          2860: -static unsigned char tmp[MAXLIT], best[MAXLIT];
        !          2861: -static unsigned char *p;
        !          2862: -static int bestlen;
        !          2863: -#define       START   { p = tmp ; }
        !          2864: -#define       ADD(c)  { if(p >= &tmp[MAXLIT]) p--; *p++ = c; }
        !          2865: -#define       FINISH  { ADD(0) if((p-tmp) > bestlen) memmove((char *)best, (char *)tmp, bestlen = p-tmp); }
        !          2866: -
        !          2867: -re_lit(re_re *r, unsigned char **b, unsigned char **e)
        !          2868: -{
        !          2869: -      bestlen = 0;
        !          2870: -      START
        !          2871: -      traverse(r->root);
        !          2872: -      FINISH
        !          2873: -      if(bestlen < 3)
        !          2874: -              return(0);
        !          2875: -      *b = best;
        !          2876: -      *e = best+bestlen-1;
        !          2877: -      return(1);
        !          2878: -}
        !          2879: -
        !          2880: -static void
        !          2881: -traverse(register Expr *e)
        !          2882: -{
        !          2883: -      switch(e->type)
        !          2884: -      {
        !          2885: -      case Literal:
        !          2886: -              ADD(e->lit)
        !          2887: -              break;
        !          2888: -      case Charclass:
        !          2889: -              if((int)e->l == 1)
        !          2890: -                      ADD(*(char *)e->r)
        !          2891: -              else {
        !          2892: -                      FINISH
        !          2893: -                      START
        !          2894: -              }
        !          2895: -              break;
        !          2896: -      case Cat:
        !          2897: -              traverse(e->l);
        !          2898: -              traverse(e->r);
        !          2899: -              break;
        !          2900: -      case Plus:
        !          2901: -              traverse(e->l);
        !          2902: -              FINISH  /* can't go on past a + */
        !          2903: -              START   /* but we can start with one! */
        !          2904: -              traverse(e->l);
        !          2905: -              break;
        !          2906: -      case EOP:
        !          2907: -              FINISH
        !          2908: -              START
        !          2909: -              traverse(e->l);
        !          2910: -              break;
        !          2911: -      default:
        !          2912: -              FINISH
        !          2913: -              START
        !          2914: -              break;
        !          2915: -      }
        !          2916: -}
        !          2917: //GO.SYSIN DD eglit.c
        !          2918: echo egpos.c 1>&2
        !          2919: sed 's/.//' >egpos.c <<'//GO.SYSIN DD egpos.c'
        !          2920: -#include      "re.h"
        !          2921: -#include      "lre.h"
        !          2922: -#include      "hdr.h"
        !          2923: -
        !          2924: -#ifndef       POSSTEP
        !          2925: -#define               POSSTEP         (8*1024)
        !          2926: -#endif
        !          2927: -
        !          2928: -void
        !          2929: -eg_posinit(re_re *r)
        !          2930: -{
        !          2931: -      if(r->nposalloc <= 0)
        !          2932: -              r->nposalloc = POSSTEP;
        !          2933: -      r->posbase = (int *)egmalloc(r->nposalloc*sizeof(int), "posbase");
        !          2934: -      if (!r->posbase)
        !          2935: -              return;
        !          2936: -      r->posnext = 0;
        !          2937: -}
        !          2938: -
        !          2939: -void
        !          2940: -eg_posset(re_re *r)
        !          2941: -{
        !          2942: -      r->posreset = r->posnext;
        !          2943: -}
        !          2944: -
        !          2945: -eg_posalloc(re_re *r, int n)
        !          2946: -{
        !          2947: -      register j;
        !          2948: -
        !          2949: -      if(n < 0){
        !          2950: -              r->posnext = r->posreset;
        !          2951: -              return(-1);
        !          2952: -      }
        !          2953: -      j = r->posnext;
        !          2954: -      r->posnext += n;
        !          2955: -      if(r->posnext >= r->nposalloc){
        !          2956: -              while((r->nposalloc < r->posnext) && (r->nposalloc < 256*1024))
        !          2957: -                      r->nposalloc *= 2;
        !          2958: -              if(r->nposalloc < r->posnext){
        !          2959: -                      r->nposalloc = (r->posnext+POSSTEP-1)/POSSTEP;
        !          2960: -                      r->nposalloc *= POSSTEP;
        !          2961: -              }
        !          2962: -              r->posbase = (int *)egrealloc((char *)r->posbase, r->nposalloc*sizeof(int), "posbase");
        !          2963: -              if (!r->posbase)
        !          2964: -                      return(-1);
        !          2965: -      }
        !          2966: -      return(j);
        !          2967: -}
        !          2968: //GO.SYSIN DD egpos.c
        !          2969: echo egstate.c 1>&2
        !          2970: sed 's/.//' >egstate.c <<'//GO.SYSIN DD egstate.c'
        !          2971: -#include      "re.h"
        !          2972: -#include      "lre.h"
        !          2973: -#include      "hdr.h"
        !          2974: -
        !          2975: -#ifndef       MINSTATE
        !          2976: -#define       MINSTATE        32
        !          2977: -#endif
        !          2978: -
        !          2979: -void
        !          2980: -eg_stateinit(re_re *r)
        !          2981: -{
        !          2982: -      r->statelim = MINSTATE;
        !          2983: -      r->states = 0;
        !          2984: -      r->threshhold = 2;
        !          2985: -}
        !          2986: -
        !          2987: -void
        !          2988: -eg_clrstates(re_re *r)
        !          2989: -{
        !          2990: -      r->nstates = 0;
        !          2991: -      if(r->states == 0){
        !          2992: -              r->states = (State *)egmalloc(r->statelim*sizeof(State), "states");
        !          2993: -              if (!r->states)
        !          2994: -                      return;
        !          2995: -      }
        !          2996: -}
        !          2997: -
        !          2998: -void
        !          2999: -eg_savestate(re_re *r, State *s)
        !          3000: -{
        !          3001: -      r->initialstate = s-r->states;
        !          3002: -      r->istate = r->states[r->initialstate]; /* save for reset */
        !          3003: -      r->istate.init = 1;
        !          3004: -      r->flushed = 0;
        !          3005: -}
        !          3006: -
        !          3007: -State *
        !          3008: -eg_startstate(re_re *r)
        !          3009: -{
        !          3010: -      register i;
        !          3011: -
        !          3012: -      if(r->flushed > r->threshhold){
        !          3013: -              int slim = r->statelim*2;
        !          3014: -              if(slim > 512)
        !          3015: -                      slim = 512;
        !          3016: -              if(slim > r->statelim){
        !          3017: -                      for(i = 0; i < r->statelim; i++)
        !          3018: -                              memset((char *)r->states[i].tab, 0, sizeof r->states[i].tab);
        !          3019: -                      r->states = (State *)egrealloc((char *)r->states,
        !          3020: -                              (r->statelim = slim)*sizeof(State), "states");
        !          3021: -                      if (!r->states)
        !          3022: -                              return 0;
        !          3023: -              }
        !          3024: -              r->flushed = 0;
        !          3025: -              r->threshhold++;
        !          3026: -              r->states[r->initialstate] = r->istate;
        !          3027: -              r->nstates = r->initialstate+1;
        !          3028: -      }
        !          3029: -      return(r->states+r->initialstate);
        !          3030: -}
        !          3031: -
        !          3032: -eg_getstate(register re_re *r)
        !          3033: -{
        !          3034: -      if(r->nstates >= r->statelim){
        !          3035: -              r->nstates = r->initialstate+1;
        !          3036: -              r->states[r->initialstate] = r->istate;
        !          3037: -              (void)eg_posalloc(r, -1);
        !          3038: -              r->flushed++;
        !          3039: -      }
        !          3040: -      r->states[r->nstates].init = 0;
        !          3041: -      return(r->nstates++);
        !          3042: -}
        !          3043: -
        !          3044: -State *
        !          3045: -eg_stateof(re_re *r, register Positionset *ps)
        !          3046: -{
        !          3047: -      register State *s;
        !          3048: -      register i;
        !          3049: -      register *p, *e;
        !          3050: -
        !          3051: -      for(i = 0, s = r->states; i < r->nstates; i++, s++){
        !          3052: -              if(s->npos == ps->count){
        !          3053: -                      for(p = s->pos+r->posbase, e = p+s->npos; p < e;)
        !          3054: -                              if(ps->base[*p++] == 0){
        !          3055: -                                      goto next;
        !          3056: -                              }
        !          3057: -                      return(s);
        !          3058: -              }
        !          3059: -      next:;
        !          3060: -      }
        !          3061: -      return(0);
        !          3062: -}
        !          3063: //GO.SYSIN DD egstate.c
        !          3064: echo egcw.c 1>&2
        !          3065: sed 's/.//' >egcw.c <<'//GO.SYSIN DD egcw.c'
        !          3066: -#include      "re.h"
        !          3067: -#include      "lre.h"
        !          3068: -#include      "hdr.h"
        !          3069: -
        !          3070: -static altlist(Expr*, unsigned char *);
        !          3071: -static word(Expr*, unsigned char*);
        !          3072: -static re_cw *pat;
        !          3073: -
        !          3074: -re_cw *
        !          3075: -re_recw(re_re *r, unsigned char *map)
        !          3076: -{
        !          3077: -      unsigned char buf[20000];
        !          3078: -      register Expr *e, *root = r->root;
        !          3079: -
        !          3080: -      if(root->type != EOP)
        !          3081: -              return(0);
        !          3082: -      if(root->l->type != Cat)
        !          3083: -              return(0);
        !          3084: -      if(root->l->l->type != Star)
        !          3085: -              return(0);
        !          3086: -      if(root->l->l->l->type != Dot)
        !          3087: -              return(0);
        !          3088: -      e = root->l->r;
        !          3089: -      pat = re_cwinit(map);
        !          3090: -      if(altlist(e, buf) == 0)
        !          3091: -              return(0);
        !          3092: -      re_cwcomp(pat);
        !          3093: -      return(pat);
        !          3094: -}
        !          3095: -
        !          3096: -static
        !          3097: -altlist(Expr *e, unsigned char *buf)
        !          3098: -{
        !          3099: -      if(e->type == Alternate)
        !          3100: -              return(altlist(e->l, buf) && altlist(e->r, buf));
        !          3101: -      return(word(e, buf));
        !          3102: -}
        !          3103: -
        !          3104: -static unsigned char *p;
        !          3105: -
        !          3106: -static
        !          3107: -word(Expr *e, unsigned char *buf)
        !          3108: -{
        !          3109: -      if(buf)
        !          3110: -              p = buf;
        !          3111: -      if(e->type == Cat){
        !          3112: -              if(word(e->l, (unsigned char *)0) == 0)
        !          3113: -                      return(0);
        !          3114: -              if(word(e->r, (unsigned char *)0) == 0)
        !          3115: -                      return(0);
        !          3116: -      } else if(e->type == Literal)
        !          3117: -              *p++ = e->lit;
        !          3118: -      else
        !          3119: -              return(0);
        !          3120: -      if(buf)
        !          3121: -              re_cwadd(pat, buf, p);
        !          3122: -      return(1);
        !          3123: -}
        !          3124: -
        !          3125: //GO.SYSIN DD egcw.c
        !          3126: echo egbr.c 1>&2
        !          3127: sed 's/.//' >egbr.c <<'//GO.SYSIN DD egbr.c'
        !          3128: -#include      "re.h"
        !          3129: -#include      "lre.h"
        !          3130: -#include      "hdr.h"
        !          3131: -
        !          3132: -#define       DEBUG
        !          3133: -
        !          3134: -static Br *seq(Expr *);
        !          3135: -static Br *spew(Br_type, Expr*, int);
        !          3136: -
        !          3137: -static Expr *eop;
        !          3138: -
        !          3139: -static char tabs[] = { '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t',
        !          3140: -      '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t', 0
        !          3141: -};
        !          3142: -#define       SPACE(d)        (&tabs[sizeof tabs - (d) - 1])
        !          3143: -
        !          3144: -static void
        !          3145: -init1(register Br *br, re_re *r)
        !          3146: -{
        !          3147: -      switch(br->type)
        !          3148: -      {
        !          3149: -      case br_re:
        !          3150: -              br->r = (re_re *)egmalloc(sizeof(re_re), "egbr");
        !          3151: -#ifdef        DEBUG
        !          3152: -              if(TRACE(3))
        !          3153: -                      PR "b@%ld->r = %ld\n", br, br->r);
        !          3154: -#endif
        !          3155: -              if(!br->r)
        !          3156: -                      return;
        !          3157: -              memcpy((char *)br->r, (char *)r, sizeof(*r));
        !          3158: -              if(br->e->type != EOP)
        !          3159: -                      br->e = eg_newexpr(EOP, '#', br->e, (Expr *)0);
        !          3160: -              br->r->root = br->e;
        !          3161: -              br->e->id = eop->id;
        !          3162: -              br->r->br = br;
        !          3163: -              br->r->backref = br->r->root->backref;
        !          3164: -              br->r->parens = br->r->root->parens;
        !          3165: -              eginit(br->r, br == r->br);
        !          3166: -              break;
        !          3167: -      case br_star:
        !          3168: -      case br_plus:
        !          3169: -      case br_quest:
        !          3170: -      case br_group:
        !          3171: -              init1(br->lb, r);
        !          3172: -              break;
        !          3173: -      case br_cat:
        !          3174: -      case br_alt:
        !          3175: -              init1(br->lb, r);
        !          3176: -              init1(br->rb, r);
        !          3177: -              break;
        !          3178: -      }
        !          3179: -}
        !          3180: -
        !          3181: -void
        !          3182: -egbr(re_re *r)
        !          3183: -{
        !          3184: -      eop = 0;
        !          3185: -/*
        !          3186: -#ifdef        DEBUG
        !          3187: -      if(1||TRACE(3)){
        !          3188: -              char buf[EPRINTSIZE];
        !          3189: -
        !          3190: -              eg_epr(r->root, buf, 0);
        !          3191: -              PR "egbr(%s) ->\n", buf);
        !          3192: -              eg_brpr(seq(r->root));
        !          3193: -      }
        !          3194: -#endif
        !          3195: -/**/
        !          3196: -      egcanon(r->root);
        !          3197: -      r->br = seq(r->root);
        !          3198: -#ifdef        DEBUG
        !          3199: -      if(TRACE(3)){
        !          3200: -              char buf[EPRINTSIZE];
        !          3201: -
        !          3202: -              eg_epr(r->root, buf, 0);
        !          3203: -              PR "egbr(%s) ->\n", buf);
        !          3204: -              eg_brpr(r->br);
        !          3205: -      }
        !          3206: -#endif
        !          3207: -      init1(r->br, r);
        !          3208: -}
        !          3209: -
        !          3210: -#ifdef        DEBUG
        !          3211: -static void
        !          3212: -brpr1(Br *b, int depth)
        !          3213: -{
        !          3214: -      char buf[EPRINTSIZE];
        !          3215: -
        !          3216: -      PR "%s%d@", SPACE(depth), (int)b);
        !          3217: -      switch(b->type)
        !          3218: -      {
        !          3219: -      case br_br:
        !          3220: -              PR "BR %d\n", b->group);
        !          3221: -              break;
        !          3222: -      case br_re:
        !          3223: -              eg_epr((Expr *)b->e, buf, 0);
        !          3224: -              if(((Expr *)b->e)->backref) PR "X");
        !          3225: -              if(((Expr *)b->e)->parens) PR "()");
        !          3226: -              PR "RE/%s/%d\n", buf, (int)b->r);
        !          3227: -              break;
        !          3228: -      case br_group:
        !          3229: -              PR "GROUP %d\n", b->group);
        !          3230: -              brpr1(b->lb, depth+1);
        !          3231: -              break;
        !          3232: -      case br_quest:
        !          3233: -              PR "BR?");
        !          3234: -              brpr1(b->lb, depth+1);
        !          3235: -              break;
        !          3236: -      case br_plus:
        !          3237: -              PR "BR+\n");
        !          3238: -              brpr1(b->lb, depth+1);
        !          3239: -              break;
        !          3240: -      case br_star:
        !          3241: -              PR "BR*\n");
        !          3242: -              brpr1(b->lb, depth+1);
        !          3243: -              break;
        !          3244: -      case br_cat:
        !          3245: -              PR "BR CAT\n");
        !          3246: -              brpr1(b->lb, depth+1);
        !          3247: -              brpr1(b->rb, depth+1);
        !          3248: -              break;
        !          3249: -      case br_alt:
        !          3250: -              PR "BR |\n");
        !          3251: -              brpr1(b->lb, depth+1);
        !          3252: -              brpr1(b->rb, depth+1);
        !          3253: -              break;
        !          3254: -      default:
        !          3255: -              PR "BADTYPE/%d/\n", b->type);
        !          3256: -              break;
        !          3257: -      }
        !          3258: -}
        !          3259: -
        !          3260: -void
        !          3261: -eg_brpr(Br *br)
        !          3262: -{
        !          3263: -      brpr1(br, 0);
        !          3264: -}
        !          3265: -#endif
        !          3266: -
        !          3267: -static Br *
        !          3268: -seq(Expr *e)
        !          3269: -{
        !          3270: -      Br *br;
        !          3271: -
        !          3272: -      if(e->type == EOP)
        !          3273: -              eop = e;
        !          3274: -      if(!e->backref && !e->parens)
        !          3275: -              return(spew(br_re, e, -1));
        !          3276: -      switch(e->type)
        !          3277: -      {
        !          3278: -      case Cat:
        !          3279: -              br = spew(br_cat, (Expr *)0, -1);
        !          3280: -              br->lb = seq(e->l);
        !          3281: -              br->rb = seq(e->r);
        !          3282: -              return(br);
        !          3283: -      case Alternate:
        !          3284: -              br = spew(br_alt, (Expr *)0, -1);
        !          3285: -              br->lb = seq(e->l);
        !          3286: -              br->rb = seq(e->r);
        !          3287: -              return(br);
        !          3288: -      case Star:
        !          3289: -              br = spew(br_star, (Expr *)0, -1);
        !          3290: -              br->lb = seq(e->l);
        !          3291: -              return(br);
        !          3292: -      case Plus:
        !          3293: -              br = spew(br_plus, (Expr *)0, -1);
        !          3294: -              br->lb = seq(e->l);
        !          3295: -              return(br);
        !          3296: -      case Quest:
        !          3297: -              br = spew(br_quest, (Expr *)0, -1);
        !          3298: -              br->lb = seq(e->l);
        !          3299: -              return(br);
        !          3300: -      case Group:
        !          3301: -              br = spew(br_group, (Expr *)0, e->lit);
        !          3302: -              br->lb = seq(e->l);
        !          3303: -              return(br);
        !          3304: -      case Backref:
        !          3305: -              return(spew(br_br, e->l, e->lit));
        !          3306: -      case EOP:
        !          3307: -              return(seq(e->l));
        !          3308: -      default:
        !          3309: -              return(spew(br_re, e, -1));
        !          3310: -      }
        !          3311: -}
        !          3312: -
        !          3313: -static Br *
        !          3314: -spew(Br_type t, Expr *d, int g)
        !          3315: -{
        !          3316: -      Br *b;
        !          3317: -
        !          3318: -      b = (Br *)egmalloc(sizeof(Br), "back ref malloc");
        !          3319: -      if(!b)
        !          3320: -              return(0);
        !          3321: -      b->type = t;
        !          3322: -      b->e = d;
        !          3323: -      b->group = g;
        !          3324: -      b->r = 0;
        !          3325: -      b->rb = b->lb = 0;
        !          3326: -      return(b);
        !          3327: -}
        !          3328: //GO.SYSIN DD egbr.c
        !          3329: echo egerror.c 1>&2
        !          3330: sed 's/.//' >egerror.c <<'//GO.SYSIN DD egerror.c'
        !          3331: -#include      <stdio.h>
        !          3332: -#include      "re.h"
        !          3333: -
        !          3334: -void
        !          3335: -re_error(char *s)
        !          3336: -{
        !          3337: -      fprintf(stderr, "pattern error: %s\n", s);
        !          3338: -      exit(1);
        !          3339: -      /* NOTREACHED */
        !          3340: -}
        !          3341: //GO.SYSIN DD egerror.c
        !          3342: echo refile.c 1>&2
        !          3343: sed 's/.//' >refile.c <<'//GO.SYSIN DD refile.c'
        !          3344: -#include      <string.h>
        !          3345: -#include      <stdio.h>
        !          3346: -#if defined(__STDC__) || defined(c_plusplus) || defined(__cplusplus)
        !          3347: -#include      <stdlib.h>
        !          3348: -#endif
        !          3349: -#include      "re.h"
        !          3350: -
        !          3351: -#ifdef        MAIN
        !          3352: -
        !          3353: -main(argc, argv)
        !          3354: -      char **argv;
        !          3355: -{
        !          3356: -      Expr *re;
        !          3357: -      re_re *r;
        !          3358: -      char *pat;
        !          3359: -      FILE *tmp;
        !          3360: -      char *tmpn;
        !          3361: -      extern char *tmpnam();
        !          3362: -      char e1[4096], e2[4096];
        !          3363: -      unsigned char map[256];
        !          3364: -      int n;
        !          3365: -
        !          3366: -      if(argc != 2){
        !          3367: -              fprintf(stderr, "Usage: efile pattern\n");
        !          3368: -              exit(1);
        !          3369: -      }
        !          3370: -      pat = argv[1];
        !          3371: -      for(n = 0; n < 256; n++)
        !          3372: -              map[n] = n;
        !          3373: -      r = re_recomp(pat, pat+strlen(pat), map);
        !          3374: -      if(r == 0)
        !          3375: -              exit(1);
        !          3376: -      re = r->root;
        !          3377: -      tmpn = tmpnam((char *)0);
        !          3378: -      if((tmp = fopen(tmpn, "w+r")) == NULL){
        !          3379: -              perror(tmpn);
        !          3380: -              exit(1);
        !          3381: -      }
        !          3382: -      eg_epr(re, e1, 0);
        !          3383: -      re_refile(r, tmp);
        !          3384: -      rewind(tmp);
        !          3385: -      r = re_filere(tmp);
        !          3386: -      eg_epr(r->root, e2, 0);
        !          3387: -      if(strcmp(e1, e2))
        !          3388: -              printf("MISMATCH!!\nbefore:\n%s\nafter:\n%s\n", e1, e2);
        !          3389: -      else
        !          3390: -              printf("ok\n");
        !          3391: -      re_refree(r);
        !          3392: -      exit(0);
        !          3393: -}
        !          3394: -#else
        !          3395: -
        !          3396: -#include      "lre.h"
        !          3397: -
        !          3398: -#if defined(__STDC__) || defined(c_plusplus) || defined(__cplusplus)
        !          3399: -static void etofile(Expr *, FILE *);
        !          3400: -static Expr *filetoe(FILE *);
        !          3401: -#else
        !          3402: -static void etofile();
        !          3403: -static Expr *filetoe();
        !          3404: -#endif
        !          3405: -
        !          3406: -#define               REVERSION               2
        !          3407: -
        !          3408: -void
        !          3409: -re_refile(re_re *re, FILE *fp)
        !          3410: -{
        !          3411: -      if(re == 0)
        !          3412: -              return;
        !          3413: -      if(putc(REVERSION, fp) != REVERSION){
        !          3414: -              re_error("couldn't write version");
        !          3415: -              return;
        !          3416: -      }
        !          3417: -      if(fwrite(re->mymap, 256, 1, fp) != 1){
        !          3418: -              re_error("couldn't write char map");
        !          3419: -              return;
        !          3420: -      }
        !          3421: -      putw(re->carat, fp);
        !          3422: -      etofile(re->root, fp);
        !          3423: -}
        !          3424: -
        !          3425: -static void
        !          3426: -etofile(Expr *e, FILE *fp)
        !          3427: -{
        !          3428: -      Expr ee;
        !          3429: -
        !          3430: -      if(e == 0){
        !          3431: -              e = &ee;
        !          3432: -              e->type = Null;
        !          3433: -      }
        !          3434: -      putw(e->type, fp);
        !          3435: -      putw(e->lit, fp);
        !          3436: -      putc(e->backref, fp);
        !          3437: -      putc(e->parens, fp);
        !          3438: -      switch(e->type)
        !          3439: -      {
        !          3440: -      case Null:
        !          3441: -      case Literal:
        !          3442: -      case Dot:
        !          3443: -      case Carat:
        !          3444: -      case Dollar:
        !          3445: -      case Backref:
        !          3446: -              break;
        !          3447: -      case Compcharclass:
        !          3448: -      case Charclass:
        !          3449: -              putw((int)e->l, fp);
        !          3450: -              fwrite((char *)e->r, (int)e->l, 1, fp);
        !          3451: -              break;
        !          3452: -      case Cat:
        !          3453: -      case Alternate:
        !          3454: -              etofile(e->l, fp);
        !          3455: -              etofile(e->r, fp);
        !          3456: -              break;
        !          3457: -      case Star:
        !          3458: -      case Plus:
        !          3459: -      case Quest:
        !          3460: -      case Group:
        !          3461: -      case EOP:
        !          3462: -              etofile(e->l, fp);
        !          3463: -              break;
        !          3464: -      }
        !          3465: -}
        !          3466: -
        !          3467: -re_re *
        !          3468: -re_filere(FILE *fp)
        !          3469: -{
        !          3470: -      register re_re *r;
        !          3471: -
        !          3472: -      r = (re_re *)egmalloc(sizeof (re_re), "allocating re_re");
        !          3473: -      if(r == 0)
        !          3474: -              return(0);
        !          3475: -      memset((char *)r, 0, sizeof (re_re));
        !          3476: -      if(getc(fp) != REVERSION){
        !          3477: -              re_error("read bad version number");
        !          3478: -              goto err;
        !          3479: -      }
        !          3480: -      if(fread(r->mymap, 256, 1, fp) != 1){
        !          3481: -              re_error("couldn't read char map");
        !          3482: -              goto err;
        !          3483: -      }
        !          3484: -      r->carat = getw(fp);
        !          3485: -      eg_lexinit((char *)0, (char *)0);
        !          3486: -      if((r->root = filetoe(fp)) == 0){
        !          3487: -err:
        !          3488: -              free((char *)r);
        !          3489: -              return(0);
        !          3490: -      }
        !          3491: -      egpost(r);
        !          3492: -      if(r->backref || r->parens)
        !          3493: -              egbr(r);
        !          3494: -      else
        !          3495: -              eginit(r, r->carat);
        !          3496: -      return(r);
        !          3497: -}
        !          3498: -
        !          3499: -static Expr *
        !          3500: -filetoe(FILE *fp)
        !          3501: -{
        !          3502: -      Expr *ee, *er, *el, *ret;
        !          3503: -      int t, l;
        !          3504: -      Exprtype et;
        !          3505: -      char res[256];
        !          3506: -      int br, parens;
        !          3507: -
        !          3508: -      t = getw(fp);
        !          3509: -      if((t == EOF) && feof(fp))
        !          3510: -              return(0);
        !          3511: -      et = (Exprtype)t;
        !          3512: -      l = getw(fp);
        !          3513: -      br = getc(fp);
        !          3514: -      parens = getc(fp);
        !          3515: -      switch(et)
        !          3516: -      {
        !          3517: -      case Null:
        !          3518: -              return(0);
        !          3519: -      case Literal:
        !          3520: -      case Dot:
        !          3521: -      case Carat:
        !          3522: -      case Dollar:
        !          3523: -      case Backref:
        !          3524: -              ret = eg_newexpr(et, l, (Expr *)0, (Expr *)0);
        !          3525: -              break;
        !          3526: -      case Compcharclass:
        !          3527: -      case Charclass:
        !          3528: -              ee = eg_newexpr(et, l, (Expr *)0, (Expr *)0);
        !          3529: -              l = getw(fp);
        !          3530: -              ee->r = (Expr *)egmalloc(l, "filetoe copy");
        !          3531: -              if (!ee->r)
        !          3532: -                      return 0;
        !          3533: -              ee->l = (Expr *)l;
        !          3534: -              fread((char *)ee->r, l, 1, fp);
        !          3535: -              ret = ee;
        !          3536: -              break;
        !          3537: -      case Cat:
        !          3538: -      case Alternate:
        !          3539: -              el = filetoe(fp);
        !          3540: -              er = filetoe(fp);
        !          3541: -              ret = eg_newexpr(et, l, el, er);
        !          3542: -              break;
        !          3543: -      case Star:
        !          3544: -      case Plus:
        !          3545: -      case Quest:
        !          3546: -      case Group:
        !          3547: -      case EOP:
        !          3548: -              el = filetoe(fp);
        !          3549: -              ret = eg_newexpr(et, l, el, (Expr *)0);
        !          3550: -              break;
        !          3551: -      default:
        !          3552: -              SPR res, "<reading expr undef type %d lit=%d>", t, l);
        !          3553: -              re_error(res);
        !          3554: -              return((Expr *)0);
        !          3555: -      }
        !          3556: -      ret->backref = br;
        !          3557: -      ret->parens = parens;
        !          3558: -      return(ret);
        !          3559: -}
        !          3560: -#endif
        !          3561: //GO.SYSIN DD refile.c
        !          3562: echo egparen.c 1>&2
        !          3563: sed 's/.//' >egparen.c <<'//GO.SYSIN DD egparen.c'
        !          3564: -#include      "re.h"
        !          3565: -#include      "lre.h"
        !          3566: -#include      "hdr.h"
        !          3567: -
        !          3568: -static int egparen(Expr *e);
        !          3569: -
        !          3570: -int
        !          3571: -re_paren(re_re *re)
        !          3572: -{
        !          3573: -      return egparen(re->root);
        !          3574: -}
        !          3575: -
        !          3576: -static int
        !          3577: -egparen(Expr *e)
        !          3578: -{
        !          3579: -      if(e == 0)
        !          3580: -              return(0);
        !          3581: -      switch(e->type)
        !          3582: -      {
        !          3583: -      case Null:
        !          3584: -      case Literal:
        !          3585: -      case Dot:
        !          3586: -      case Carat:
        !          3587: -      case Dollar:
        !          3588: -      case Backref:
        !          3589: -      case Compcharclass:
        !          3590: -      case Charclass:
        !          3591: -              break;
        !          3592: -      case Cat:
        !          3593: -      case Alternate:
        !          3594: -              return(egparen(e->l)+egparen(e->r));
        !          3595: -      case Star:
        !          3596: -      case Plus:
        !          3597: -      case Quest:
        !          3598: -      case EOP:
        !          3599: -              return(egparen(e->l));
        !          3600: -      case Group:
        !          3601: -              return(1+egparen(e->l));
        !          3602: -      }
        !          3603: -      return(0);
        !          3604: -}
        !          3605: //GO.SYSIN DD egparen.c
        !          3606: echo egmatch.c 1>&2
        !          3607: sed 's/.//' >egmatch.c <<'//GO.SYSIN DD egmatch.c'
        !          3608: -#include      "re.h"
        !          3609: -#include      "lre.h"
        !          3610: -#include      "hdr.h"
        !          3611: -
        !          3612: -#define       DEBUG
        !          3613: -
        !          3614: -static unsigned char *eg_slowmatch(Br *, unsigned char *, unsigned char *, int);
        !          3615: -static unsigned char *wholeb, *wholee;
        !          3616: -static unsigned char *start[10];
        !          3617: -static int len[10];
        !          3618: -static void undobr(Br *);     /* undo group assignements */
        !          3619: -
        !          3620: -eg_match(register re_re *r, register unsigned char *b, register unsigned char *e, unsigned char **rb, unsigned char **re)
        !          3621: -{
        !          3622: -      int i, ret;
        !          3623: -
        !          3624: -#ifdef        DEBUG
        !          3625: -      if(TRACE(2)){
        !          3626: -              PR "eg_match(%d->%d, %d, %d)\n", (int)r, (int)r->br, (int)b, (int)e);
        !          3627: -              if(r->br)
        !          3628: -                      eg_brpr(r->br);
        !          3629: -      }
        !          3630: -#endif
        !          3631: -      if((rb == 0) != (re == 0)){
        !          3632: -              re_error("must supply both or none of group pointers");
        !          3633: -              return(0);
        !          3634: -      }
        !          3635: -      if(r->backref || r->parens || rb){
        !          3636: -              wholeb = e;
        !          3637: -              for(i = 1; i < 10; i++)
        !          3638: -                      start[i] = 0;
        !          3639: -              if(r->br == 0)
        !          3640: -                      egbr(r);
        !          3641: -              ret = (wholee = eg_slowmatch(r->br, b, e, RE_BEG|RE_END)) != 0;
        !          3642: -              if(rb && ret){
        !          3643: -                      rb[0] = wholeb;
        !          3644: -                      re[0] = wholee;
        !          3645: -                      for(i = 1; i < 10; i++){
        !          3646: -                              rb[i] = start[i];
        !          3647: -                              re[i] = rb[i]+len[i];
        !          3648: -                      }
        !          3649: -#ifdef        DEBUG
        !          3650: -                      if(TRACE(1)){
        !          3651: -                              PR "eg_match groups:");
        !          3652: -                              for(i = 0; i < 10; i++)
        !          3653: -                                      if(rb[i])PR " %d: %d@%d", i, rb[i], re[i]-rb[i]);
        !          3654: -                              PR "\n");
        !          3655: -                      }
        !          3656: -#endif
        !          3657: -              }
        !          3658: -#ifdef        DEBUG
        !          3659: -               else {
        !          3660: -                      if(TRACE(1)){
        !          3661: -                              PR "eg_match groups: [%d - %d]\n", wholeb, wholee);
        !          3662: -                              for(i = 1; i < 10; i++)
        !          3663: -                                      if(start[i])PR " %d: %d@%d", i, start[i], len[i]);
        !          3664: -                              PR "\n");
        !          3665: -                      }
        !          3666: -              }
        !          3667: -#endif
        !          3668: -      } else
        !          3669: -              ret = eg_quickmatch(r, b, e, RE_BEG|RE_END) != 0;
        !          3670: -      return(ret);
        !          3671: -}
        !          3672: -
        !          3673: -static unsigned char *
        !          3674: -eg_slowmatch(Br *br, unsigned char *b, unsigned char *e, int endpts)
        !          3675: -{
        !          3676: -      int i;
        !          3677: -      unsigned char *me, *end;
        !          3678: -      unsigned char *beg, *lbeg, *llbeg, *rbeg, *rend, *lm, *rm;
        !          3679: -#ifdef        DEBUG
        !          3680: -      char buf[EPRINTSIZE];
        !          3681: -      static id = 1;
        !          3682: -      int myid = id++;
        !          3683: -#endif
        !          3684: -
        !          3685: -#define               BOFF(x)         ((x)? (endpts&~RE_BEG):endpts)
        !          3686: -#define               EOFF(x)         ((x)? (endpts&~RE_END):endpts)
        !          3687: -
        !          3688: -      if(br == 0)     /* nothing to match - we won! */
        !          3689: -              return(b);
        !          3690: -#ifdef        DEBUG
        !          3691: -      if(TRACE(3))
        !          3692: -              PR "slowmatch(br=%d, [b,e]=%d,%d id=%d, endpt=%d)\n", br, b, e, myid, endpts);
        !          3693: -#endif
        !          3694: -      switch(br->type)
        !          3695: -      {
        !          3696: -      case br_br:
        !          3697: -              i = br->group;
        !          3698: -#ifdef        DEBUG
        !          3699: -              if(TRACE(3))
        !          3700: -                      PR "br[%d]: %d,%d b=%d,e=%d\n", i, (int)start[i], len[i], b, e);
        !          3701: -#endif
        !          3702: -              if(start[i] == 0)
        !          3703: -                      return(0);
        !          3704: -              if((len[i] > e-b) || memcmp((char *)b, (char *)start[i], len[i]))
        !          3705: -                      return(0);
        !          3706: -              if(wholeb > b) wholeb = b;
        !          3707: -#ifdef        DEBUG
        !          3708: -              if(TRACE(3))
        !          3709: -                      PR "br[%d]: matched\n", i);
        !          3710: -#endif
        !          3711: -              return(b+len[i]);
        !          3712: -
        !          3713: -      case br_re:
        !          3714: -#ifdef        DEBUG
        !          3715: -              if(TRACE(3)){
        !          3716: -                      eg_epr(br->e, buf, 0);
        !          3717: -                      PR "matching RE(%s)@%d against '", buf, br->r);
        !          3718: -                      WR((char *)b, e-b);
        !          3719: -                      PR "' id=%d\n", myid);
        !          3720: -              }
        !          3721: -#endif
        !          3722: -              if((me = eg_lquickmatch(br->r, b, e, endpts)) == 0)
        !          3723: -                      return(0);
        !          3724: -#ifdef        DEBUG
        !          3725: -              if(TRACE(3)){
        !          3726: -                      PR "--%s matched '", buf);
        !          3727: -                      WR((char *)b, me-b);
        !          3728: -                      PR "'[%d %d] id=%d\n", (int)b, (int)me, myid);
        !          3729: -              }
        !          3730: -#endif
        !          3731: -              if(wholeb > b)
        !          3732: -                      wholeb = b;
        !          3733: -              return(me);
        !          3734: -
        !          3735: -      case br_group:
        !          3736: -#ifdef        DEBUG
        !          3737: -              if(TRACE(3)){
        !          3738: -                      PR "matching GROUP%d against '", br->group);
        !          3739: -                      WR((char *)b, e-b);
        !          3740: -                      PR "' id=%d\n", myid);
        !          3741: -              }
        !          3742: -#endif
        !          3743: -              if((me = eg_slowmatch(br->lb, b, e, endpts)) == 0){
        !          3744: -                      undobr(br->lb);
        !          3745: -                      return(0);
        !          3746: -              }
        !          3747: -#ifdef        DEBUG
        !          3748: -              if(TRACE(3)){
        !          3749: -                      PR "--G%d matched '", br->group);
        !          3750: -                      WR((char *)b, me-b);
        !          3751: -                      PR "'[%d %d]\n", (int)b, (int)me);
        !          3752: -              }
        !          3753: -#endif
        !          3754: -              if(wholeb > b)
        !          3755: -                      wholeb = b;
        !          3756: -              start[br->group] = b;
        !          3757: -              len[br->group] = me-b;
        !          3758: -              return(me);
        !          3759: -
        !          3760: -      case br_quest:
        !          3761: -#ifdef        DEBUG
        !          3762: -              if(TRACE(3)){
        !          3763: -                      PR "matching BR? against '", buf);
        !          3764: -                      WR((char *)b, e-b);
        !          3765: -                      PR "'\n");
        !          3766: -              }
        !          3767: -#endif
        !          3768: -              if(lbeg = eg_slowmatch(br->lb, b, e, endpts)){
        !          3769: -                      return(lbeg);
        !          3770: -              }
        !          3771: -              undobr(br->lb);
        !          3772: -              return(b);
        !          3773: -
        !          3774: -      case br_plus:
        !          3775: -#ifdef        DEBUG
        !          3776: -              if(TRACE(3)){
        !          3777: -                      PR "matching BR+ against '", buf);
        !          3778: -                      WR((char *)b, e-b);
        !          3779: -                      PR "' id=%d\n", myid);
        !          3780: -              }
        !          3781: -#endif
        !          3782: -              if((lbeg = eg_slowmatch(br->lb, b, e, endpts)) == 0){
        !          3783: -                      undobr(br->lb);
        !          3784: -                      return(0);
        !          3785: -              }
        !          3786: -              llbeg = b;
        !          3787: -              while(beg = eg_slowmatch(br->lb, lbeg, e, BOFF(lbeg != b))){
        !          3788: -                      llbeg = lbeg, lbeg = beg;
        !          3789: -              }
        !          3790: -#ifdef        DEBUG
        !          3791: -              if(TRACE(3)){
        !          3792: -                      PR "--+ matched [%d %d]'", (int)llbeg, (int)lbeg);
        !          3793: -                      WR((char *)llbeg, lbeg-llbeg);
        !          3794: -                      PR "' id=%d\n", myid);
        !          3795: -              }
        !          3796: -#endif
        !          3797: -              return(eg_slowmatch(br->lb, llbeg, e, BOFF(llbeg != b)));
        !          3798: -
        !          3799: -      case br_star:
        !          3800: -#ifdef        DEBUG
        !          3801: -              if(TRACE(3)){
        !          3802: -                      PR "matching BR* against '", buf);
        !          3803: -                      WR((char *)b, e-b);
        !          3804: -                      PR "'\n");
        !          3805: -              }
        !          3806: -#endif
        !          3807: -              llbeg = lbeg = b;
        !          3808: -              while(beg = eg_slowmatch(br->lb, lbeg, e, BOFF(lbeg != b)))
        !          3809: -                      llbeg = lbeg, lbeg = beg;
        !          3810: -#ifdef        DEBUG
        !          3811: -              if(TRACE(3)){
        !          3812: -                      PR "--* matched '");
        !          3813: -                      WR((char *)lbeg, lbeg-llbeg);
        !          3814: -                      PR "'[%d %d]\n", (int)llbeg, (int)lbeg);
        !          3815: -              }
        !          3816: -#endif
        !          3817: -              if(beg = eg_slowmatch(br->lb, llbeg, e, BOFF(llbeg != b)))
        !          3818: -                      return(beg);
        !          3819: -              undobr(br->lb);
        !          3820: -              return(b);
        !          3821: -
        !          3822: -      case br_cat:
        !          3823: -#ifdef        DEBUG
        !          3824: -              if(TRACE(3)){
        !          3825: -                      PR "matching BRcat against '", buf);
        !          3826: -                      WR((char *)b, e-b);
        !          3827: -                      PR "' id=%d\n", myid);
        !          3828: -              }
        !          3829: -#endif
        !          3830: -              /*
        !          3831: -                      this is not so hard.
        !          3832: -                      we try all possible matches of the left half,
        !          3833: -                      and record the match that gave the longest
        !          3834: -                      valid match on the right half
        !          3835: -              */
        !          3836: -              rend = 0;
        !          3837: -              for(end = e; b <= e; e = beg-1){
        !          3838: -                      if((beg = eg_slowmatch(br->lb, b, e, EOFF(e != end))) == 0){
        !          3839: -                              break;
        !          3840: -                      }
        !          3841: -#ifdef        DEBUG
        !          3842: -                      if(TRACE(3)){
        !          3843: -                              PR "--cat matched '");
        !          3844: -                              WR((char *)b, beg-b);
        !          3845: -                              PR "'[%d %d] id=%d\n", (int)b, (int)beg, myid);
        !          3846: -                      }
        !          3847: -#endif
        !          3848: -                      if((me = eg_slowmatch(br->rb, beg, end, BOFF(beg != b))) == 0){
        !          3849: -                              continue;       /* no match of right half */
        !          3850: -                      }
        !          3851: -#ifdef        DEBUG
        !          3852: -                      if(TRACE(3)){
        !          3853: -                              PR "----cat matched '");
        !          3854: -                              WR((char *)b, beg-b);
        !          3855: -                              PR "'[%d %d] id=%d\n", (int)b, (int)beg, myid);
        !          3856: -                      }
        !          3857: -#endif
        !          3858: -                      if(me > rend){
        !          3859: -                              rend = me;
        !          3860: -                              rbeg = beg;
        !          3861: -#ifdef        DEBUG
        !          3862: -                              if(TRACE(3)){
        !          3863: -                                      PR "--++-- cat new max rb=%d re=%d\n", (int)rbeg, (int)rend);
        !          3864: -                              }
        !          3865: -#endif
        !          3866: -                      }
        !          3867: -              }
        !          3868: -              if(rend == 0){
        !          3869: -                      undobr(br->lb);
        !          3870: -                      undobr(br->rb);
        !          3871: -                      return(0);
        !          3872: -              }
        !          3873: -              (void)eg_slowmatch(br->lb, b, rbeg, EOFF(rbeg != end));
        !          3874: -              return(eg_slowmatch(br->rb, rbeg, end, BOFF(rbeg != b)));
        !          3875: -
        !          3876: -      case br_alt:
        !          3877: -#ifdef        DEBUG
        !          3878: -              if(TRACE(3)){
        !          3879: -                      PR "matching BR| against '", buf);
        !          3880: -                      WR((char *)b, e-b);
        !          3881: -                      PR "'\n");
        !          3882: -              }
        !          3883: -#endif
        !          3884: -              if(lm = eg_slowmatch(br->lb, b, e, endpts)){
        !          3885: -#ifdef        DEBUG
        !          3886: -                      if(TRACE(3)){
        !          3887: -                              PR "--|L matched '");
        !          3888: -                              WR((char *)b, lm-b);
        !          3889: -                              PR "'[%d %d]\n", (int)b, (int)lm);
        !          3890: -                      }
        !          3891: -#endif
        !          3892: -              }
        !          3893: -              if(rm = eg_slowmatch(br->rb, b, e, endpts)){
        !          3894: -#ifdef        DEBUG
        !          3895: -                      if(TRACE(3)){
        !          3896: -                              PR "--|R matched '");
        !          3897: -                              WR((char *)b, rm-b);
        !          3898: -                              PR "'[%d %d]\n", (int)b, (int)rm);
        !          3899: -                      }
        !          3900: -#endif
        !          3901: -              }
        !          3902: -              if(lm > rm){
        !          3903: -                      undobr(br->rb);
        !          3904: -                      return(eg_slowmatch(br->lb, b, e, endpts));
        !          3905: -              } else {
        !          3906: -                      if(rm == 0){
        !          3907: -                              undobr(br->lb);
        !          3908: -                              undobr(br->rb);
        !          3909: -                              return(0);
        !          3910: -                      } else {
        !          3911: -                              undobr(br->lb);
        !          3912: -                              return(beg);
        !          3913: -                      }                       
        !          3914: -              }
        !          3915: -      }
        !          3916: -      abort();
        !          3917: -      return(0);
        !          3918: -}
        !          3919: -
        !          3920: -static void
        !          3921: -undobr(register Br *br)
        !          3922: -{
        !          3923: -      switch(br->type)
        !          3924: -      {
        !          3925: -      case br_group:
        !          3926: -              start[br->group] = 0;
        !          3927: -              undobr(br->lb);
        !          3928: -              break;
        !          3929: -      case br_star:
        !          3930: -      case br_plus:
        !          3931: -      case br_quest:
        !          3932: -              undobr(br->lb);
        !          3933: -              break;
        !          3934: -      case br_cat:
        !          3935: -      case br_alt:
        !          3936: -              undobr(br->lb);
        !          3937: -              undobr(br->rb);
        !          3938: -              break;
        !          3939: -      }
        !          3940: -}
        !          3941: //GO.SYSIN DD egmatch.c
        !          3942: echo egcanon.c 1>&2
        !          3943: sed 's/.//' >egcanon.c <<'//GO.SYSIN DD egcanon.c'
        !          3944: -#include      "re.h"
        !          3945: -#include      "lre.h"
        !          3946: -#include      "hdr.h"
        !          3947: -
        !          3948: -#define       DEBUG
        !          3949: -
        !          3950: -static Expr **proot;
        !          3951: -
        !          3952: -#define       PURE(e)         (!(e)->backref && !(e)->parens)
        !          3953: -#define       PROC(kid)       if(ee = proc(kid)){ ee->parent = (kid)->parent; free((char *)kid); kid = ee; }
        !          3954: -
        !          3955: -static Expr *
        !          3956: -proc(Expr *e)
        !          3957: -{
        !          3958: -      Expr *ee;
        !          3959: -
        !          3960: -      if(e->type == Cat){
        !          3961: -              if(PURE(e->l)){
        !          3962: -                      if(proot){
        !          3963: -                              *proot = eg_newexpr(Cat, 0, *proot, e->l);
        !          3964: -                              return((ee = proc(e->r))? ee:e->r);
        !          3965: -                      } else
        !          3966: -                              proot = &e->l;
        !          3967: -              } else {
        !          3968: -                      PROC(e->l)
        !          3969: -              }
        !          3970: -              if(PURE(e->r)){
        !          3971: -                      if(proot){
        !          3972: -                              *proot = eg_newexpr(Cat, 0, *proot, e->r);
        !          3973: -                              return(e->l);
        !          3974: -                      } else
        !          3975: -                              proot = &e->r;
        !          3976: -              } else {
        !          3977: -                      PROC(e->r)
        !          3978: -              }
        !          3979: -              return(0);
        !          3980: -      }
        !          3981: -      proot = 0;
        !          3982: -      switch(e->type)
        !          3983: -      {
        !          3984: -      case Alternate:
        !          3985: -              PROC(e->l)
        !          3986: -              proot = 0;
        !          3987: -              PROC(e->r)
        !          3988: -              break;
        !          3989: -      case Star:
        !          3990: -      case Plus:
        !          3991: -      case Quest:
        !          3992: -      case EOP:
        !          3993: -      case Group:
        !          3994: -              PROC(e->l)
        !          3995: -              break;
        !          3996: -      }
        !          3997: -      proot = 0;
        !          3998: -      return(0);
        !          3999: -}
        !          4000: -
        !          4001: -void
        !          4002: -egcanon(Expr *e)
        !          4003: -{
        !          4004: -#ifdef        DEBUG
        !          4005: -      char before[EPRINTSIZE], after[EPRINTSIZE];
        !          4006: -#endif
        !          4007: -
        !          4008: -#ifdef        DEBUG
        !          4009: -      eg_epr(e, before, 0);
        !          4010: -      if(TRACE(3)){
        !          4011: -              PR "egcanon(%s):\n", before);
        !          4012: -      }
        !          4013: -#endif
        !          4014: -      proot = 0;
        !          4015: -      if(!PURE(e))
        !          4016: -              proc(e);
        !          4017: -#ifdef        DEBUG
        !          4018: -      eg_epr(e, after, 0);
        !          4019: -      if(TRACE(3)){
        !          4020: -              PR "egcanon returns %s\n", after);
        !          4021: -      }
        !          4022: -      if(strcmp(before, after)){
        !          4023: -              EPR "URK! egcanon did not preserve!\nbefore=%s\n after=%s\n", before, after);
        !          4024: -              exit(1);
        !          4025: -      }
        !          4026: -#endif
        !          4027: -}
        !          4028: //GO.SYSIN DD egcanon.c
        !          4029: echo hdr.h 1>&2
        !          4030: sed 's/.//' >hdr.h <<'//GO.SYSIN DD hdr.h'
        !          4031: -#ifdef        MAIN
        !          4032: -#define       EXTERN
        !          4033: -#else
        !          4034: -#define       EXTERN extern
        !          4035: -#endif
        !          4036: -
        !          4037: -#include      "io.h"
        !          4038: -#include      <setjmp.h>
        !          4039: -
        !          4040: -EXTERN int ifd;
        !          4041: -
        !          4042: -EXTERN long lnum;
        !          4043: -EXTERN long nbytes;
        !          4044: -EXTERN long noverflow;
        !          4045: -EXTERN int bflag;
        !          4046: -EXTERN int cflag;
        !          4047: -EXTERN int hflag;
        !          4048: -EXTERN int iflag;
        !          4049: -EXTERN int lflag;
        !          4050: -EXTERN int Lflag;
        !          4051: -EXTERN int nflag;
        !          4052: -EXTERN int oneflag;
        !          4053: -EXTERN int sflag;
        !          4054: -EXTERN int vflag;
        !          4055: -EXTERN int xflag;
        !          4056: -EXTERN long nmatch;
        !          4057: -EXTERN char *progname;
        !          4058: -EXTERN char *curfile;
        !          4059: -EXTERN int prname;
        !          4060: -EXTERN int offsetunit;
        !          4061: -EXTERN jmp_buf env;
        !          4062: -EXTERN int longlinewarned;
        !          4063: -
        !          4064: -extern char *optarg;
        !          4065: -extern int optind;
        !          4066: -extern int getopt(int, char**, char*);
        !          4067: -extern void *memcpy(void*, const void*, int);
        !          4068: -#ifndef       MEMMOVE
        !          4069: -#define       memmove(to, from, n)    memcpy(to, from, n)
        !          4070: -#else
        !          4071: -extern void *memmove(void*, const void*, int);
        !          4072: -#endif
        !          4073: -extern void *memchr(void*, int, int);
        !          4074: -extern char *memset(void*, int, int);
        !          4075: -extern int memcmp(void*, void*, int);
        !          4076: -extern int strlen(char *);
        !          4077: -extern int strcmp(char *, char *);
        !          4078: -extern char *strchr(char *, int);
        !          4079: -extern char *strrchr(char *, int);
        !          4080: -extern void *calloc(int, int);
        !          4081: -extern void free(void*);
        !          4082: -extern void *malloc(int);
        !          4083: -extern void *realloc(void*, int);
        !          4084: -extern int open(char *, int, ...);
        !          4085: -extern int read(int, char*, unsigned);
        !          4086: -extern int close(int);
        !          4087: -extern int tolower(int);
        !          4088: -extern void abort(void);
        !          4089: -extern void perror(char*);
        !          4090: -extern void exit(int);
        !          4091: -
        !          4092: -typedef void (*SUCCFN)(char*,char*);
        !          4093: -extern void count(char *, char *);    /* updates lnum,nbytes */
        !          4094: -extern void count_m(char *, char *);  /* updates lnum,nbytes */
        !          4095: -extern int cwxrd(char**,char**);
        !          4096: -extern int cwxmatch(char**,char**);
        !          4097: -extern int bmxmatch(char**,char**);   /* variants for -x for cw/bm */
        !          4098: -extern void dogre(Parsetype, char*, char*, unsigned char*, PROCFN*, void**, RDFN*, MATCHFN*);
        !          4099: -extern void dofgrep(char*, char*, unsigned char*, PROCFN*, void**, RDFN*, MATCHFN*);
        !          4100: -extern re_re *egprep(enum Parsetype, unsigned char*, unsigned char*, unsigned char*, int);
        !          4101: -extern int greprd(char**, char**);
        !          4102: -extern int grepmatch(char**, char**); /* normal arguments to *find */
        !          4103: -extern void inc(char*, char*);
        !          4104: -extern void inc_m(char*, char*);      /* increments nmatch */
        !          4105: -extern void null(char*, char*);               /* does nothing */
        !          4106: -extern void oneshot(char*, char*);    /* increments nmatch, does the longjmp */
        !          4107: -extern void pr(char*, char*);
        !          4108: -extern void pr_m(char*, char*);
        !          4109: -extern int re_lit(re_re*, unsigned char**, unsigned char**);
        !          4110: -
        !          4111: -EXTERN SUCCFN succfn, failfn, succ2fn;
        !          4112: -EXTERN re_re *globre;         /* the current re */
        !          4113: -
        !          4114: -#define               MAXLINE         65536
        !          4115: -
        !          4116: -#ifdef c_plusplus
        !          4117: -#define UNUSED
        !          4118: -#define UNUSED2
        !          4119: -#else
        !          4120: -#ifdef __cplusplus
        !          4121: -#define UNUSED
        !          4122: -#define UNUSED2
        !          4123: -#else
        !          4124: -#define UNUSED unused
        !          4125: -#define UNUSED2 unused2
        !          4126: -#endif
        !          4127: -#endif
        !          4128: //GO.SYSIN DD hdr.h
        !          4129: echo io.h 1>&2
        !          4130: sed 's/.//' >io.h <<'//GO.SYSIN DD io.h'
        !          4131: -#ifndef       EPR
        !          4132: -
        !          4133: -#ifdef        USE_STDIO
        !          4134: -#define               PR      printf(
        !          4135: -#define               EPR     fprintf(stderr,
        !          4136: -#define               SPR     sprintf(
        !          4137: -#define               WR(b,n) fwrite(b, 1, n, stdout)
        !          4138: -#define               FLUSH   fflush(stdout)
        !          4139: -#else
        !          4140: -#include <fio.h>
        !          4141: -extern int fprint(int, char*, ...);
        !          4142: -extern int sprint(char*, char*, ...);
        !          4143: -
        !          4144: -#define               PR      fprint(1,
        !          4145: -#define               EPR     fprint(2,
        !          4146: -#define               SPR     sprint(
        !          4147: -#define               WR(b,n) write(1, b, (long)(n))
        !          4148: -#define               FLUSH   Fflush(1)
        !          4149: -#endif
        !          4150: -
        !          4151: -#endif
        !          4152: //GO.SYSIN DD io.h
        !          4153: echo re.h 1>&2
        !          4154: sed 's/.//' >re.h <<'//GO.SYSIN DD re.h'
        !          4155: -#ifndef       RE_H
        !          4156: -#define RE_H
        !          4157: -
        !          4158: -# if defined(__cplusplus)
        !          4159: -extern "C" {  /* C++ 2.0 */
        !          4160: -# endif
        !          4161: -
        !          4162: -typedef struct re_bm
        !          4163: -{
        !          4164: -      int delta0[256], *delta2;
        !          4165: -      unsigned char cmap[256];
        !          4166: -      char *bmpat;
        !          4167: -      int patlen;
        !          4168: -} re_bm;
        !          4169: -
        !          4170: -typedef struct re_cw
        !          4171: -{
        !          4172: -      int maxdepth, mindepth;
        !          4173: -      char seenerror;         /* set if we called re_error */
        !          4174: -      long nodeid;
        !          4175: -      int step[256];
        !          4176: -      unsigned char map[256];
        !          4177: -      struct Node *root;
        !          4178: -} re_cw;
        !          4179: -
        !          4180: -typedef enum
        !          4181: -{
        !          4182: -      Literal, Dot, Carat, Dollar, Charclass, Compcharclass,          /* 0-5 */
        !          4183: -      Cat, Alternate, Star, Plus, Quest, Backref, Group, EOP,         /* 6-13 */
        !          4184: -      /* not in grammar, just helping */
        !          4185: -      Lpar, Rpar, Backslash, Null
        !          4186: -} Exprtype;
        !          4187: -
        !          4188: -typedef struct Expr
        !          4189: -{
        !          4190: -      Exprtype type;
        !          4191: -      char reallit;           /* just for dollar and -G, dammit! */
        !          4192: -      char backref;           /* backref used here or below */
        !          4193: -      char parens;            /* parens used here or below */
        !          4194: -      char seenerror;         /* set if we called re_error */
        !          4195: -      int id;
        !          4196: -      unsigned int lit;
        !          4197: -      long flen;
        !          4198: -      int *follow;
        !          4199: -      struct Expr *l, *r, *parent;
        !          4200: -} Expr;
        !          4201: -typedef enum Parsetype { greparse, grepparse, egrepparse } Parsetype;
        !          4202: -
        !          4203: -#define               RE_DOLLAR       256
        !          4204: -#define               RE_CARAT        257
        !          4205: -#define               RE_HIGH         258     /* always 1+last constant */
        !          4206: -
        !          4207: -typedef struct State
        !          4208: -{
        !          4209: -      struct State *tab[RE_HIGH];
        !          4210: -      char out;       /* matched */
        !          4211: -      char init;      /* inital state */
        !          4212: -      long npos;
        !          4213: -      int pos;        /* index into posbase */
        !          4214: -} State;
        !          4215: -
        !          4216: -typedef struct Positionset
        !          4217: -{
        !          4218: -      long count;
        !          4219: -      int last;
        !          4220: -      int *base;
        !          4221: -} Positionset;
        !          4222: -
        !          4223: -typedef enum {
        !          4224: -      br_re, br_group, br_br, br_cat, br_alt, br_star, br_plus, br_quest
        !          4225: -} Br_type;
        !          4226: -
        !          4227: -typedef struct Br
        !          4228: -{
        !          4229: -      Br_type type;
        !          4230: -      Expr *e;
        !          4231: -      int group;
        !          4232: -      struct re_re *r;
        !          4233: -      struct Br *lb, *rb;
        !          4234: -} Br;
        !          4235: -
        !          4236: -typedef struct re_re
        !          4237: -{
        !          4238: -      int *posbase;
        !          4239: -      int nposalloc, posnext, posreset;
        !          4240: -      int maxid;
        !          4241: -      Expr *root;
        !          4242: -      Expr **ptr;
        !          4243: -      unsigned char mymap[256];
        !          4244: -      Positionset firstpos, begin, tmp;
        !          4245: -      int nstates, statelim;
        !          4246: -      State *states;
        !          4247: -      State istate;
        !          4248: -      int initialstate;
        !          4249: -      int carat;
        !          4250: -      int flushed;
        !          4251: -      int threshhold;         /* resize cache every threshhold flushes */
        !          4252: -      int backref;
        !          4253: -      int parens;
        !          4254: -      Br *br;
        !          4255: -} re_re;
        !          4256: -
        !          4257: -/*
        !          4258: -      matching routine endpoint markers
        !          4259: -*/
        !          4260: -#define               RE_BEG          1               /* beginning matches ^ */
        !          4261: -#define               RE_END          2               /* end matches $ */
        !          4262: -
        !          4263: -# ifdef USE_STDIO
        !          4264: -#  include <stdio.h>
        !          4265: -#  if defined(__STDC__) || defined(c_plusplus) || defined(__cplusplus)
        !          4266: -extern void re_refile(re_re*, FILE*);
        !          4267: -extern re_re *re_filere(FILE*);
        !          4268: -#  else
        !          4269: -extern void re_refile();
        !          4270: -extern re_re *re_filere();
        !          4271: -#  endif
        !          4272: -# endif /* USE_STDIO */
        !          4273: -
        !          4274: -# if defined(__STDC__) || defined(c_plusplus) || defined(__cplusplus)
        !          4275: -# define VOID void
        !          4276: -typedef int (*RDFN)(char**, char**);
        !          4277: -typedef int (*MATCHFN)(char**,char**);
        !          4278: -typedef int (*PROCFN)(VOID*, RDFN, MATCHFN);
        !          4279: -extern re_bm *re_bmcomp(char*, char*, unsigned char*);
        !          4280: -extern int re_bmexec(VOID*, RDFN, MATCHFN);
        !          4281: -extern void re_bmfree(re_bm*);
        !          4282: -extern void re_cwadd(re_cw*, unsigned char*, unsigned char*);
        !          4283: -extern void re_cwcomp(re_cw*);
        !          4284: -extern int re_cwexec(VOID*, RDFN, MATCHFN);
        !          4285: -extern void re_cwfree(re_cw*);
        !          4286: -extern re_cw *re_cwinit(unsigned char*);
        !          4287: -extern void re_error(char*);
        !          4288: -extern int re_paren(re_re *e);
        !          4289: -extern re_re *re_recomp(char*, char*, unsigned char*);
        !          4290: -extern re_cw *re_recw(re_re*, unsigned char*);
        !          4291: -extern int re_reexec(re_re*, char*, char*, char*[10][2]);
        !          4292: -extern void re_refree(re_re*);
        !          4293: -#else
        !          4294: -# define VOID char
        !          4295: -typedef int (*RDFN)();
        !          4296: -typedef int (*MATCHFN)();
        !          4297: -typedef int (*PROCFN)();
        !          4298: -extern re_bm *re_bmcomp();
        !          4299: -extern int re_bmexec();
        !          4300: -extern void re_bmfree();
        !          4301: -extern void re_cwadd();
        !          4302: -extern void re_cwcomp();
        !          4303: -extern int re_cwexec();
        !          4304: -extern void re_cwfree();
        !          4305: -extern re_cw *re_cwinit();
        !          4306: -extern void re_error();
        !          4307: -extern int re_paren();
        !          4308: -extern re_re *re_recomp();
        !          4309: -extern re_cw *re_recw();
        !          4310: -extern int re_reexec();
        !          4311: -extern void re_refree();
        !          4312: -# endif
        !          4313: -
        !          4314: -# if defined(__cplusplus)
        !          4315: -}             /* C++ 2.0 */
        !          4316: -# endif
        !          4317: -#endif
        !          4318: //GO.SYSIN DD re.h
        !          4319: echo lre.h 1>&2
        !          4320: sed 's/.//' >lre.h <<'//GO.SYSIN DD lre.h'
        !          4321: -#ifndef       LRE_H
        !          4322: -#define LRE_H
        !          4323: -
        !          4324: -# if defined(__cplusplus)
        !          4325: -extern "C" {  /* C++ 2.0 */
        !          4326: -# endif
        !          4327: -
        !          4328: -#include      "io.h"
        !          4329: -
        !          4330: -#ifndef       MEMMOVE
        !          4331: -#define       memmove(to, from, n)    memcpy(to, from, n)
        !          4332: -#endif
        !          4333: -
        !          4334: -#define               TRACE(n)        (n < re_debug)
        !          4335: -#define               EPRINTSIZE      32767
        !          4336: -extern int re_debug;
        !          4337: -
        !          4338: -# if defined(__STDC__) || defined(c_plusplus) || defined(__cplusplus)
        !          4339: -extern void eg_clrstates(re_re*);
        !          4340: -extern Expr *eg_eall(enum Parsetype, unsigned char*);
        !          4341: -extern void egbr(re_re*);
        !          4342: -extern int egdfabr(re_re*, unsigned char*, unsigned char*, unsigned char**, unsigned char**);
        !          4343: -extern int eg_match(re_re*, unsigned char*, unsigned char*, unsigned char**, unsigned char**);
        !          4344: -extern void eginit(re_re*, int);
        !          4345: -extern void *egmalloc(int, char*);
        !          4346: -extern void egpost(re_re*);
        !          4347: -extern void egcanon(Expr *);
        !          4348: -extern re_re *egprep(enum Parsetype, unsigned char*, unsigned char*, unsigned char*, int);
        !          4349: -extern void *egrealloc(char*, int, char*);
        !          4350: -extern void eg_epr(Expr*, char*, int);
        !          4351: -extern void eg_brpr(Br *);
        !          4352: -extern int eg_getstate(re_re*);
        !          4353: -extern void eg_lexinit(char*, char*);
        !          4354: -extern void eg_lex(void);
        !          4355: -extern Expr *eg_newexpr(Exprtype, int, Expr*, Expr*);
        !          4356: -extern int eg_posalloc(re_re*, int);
        !          4357: -extern void eg_posinit(re_re*);
        !          4358: -extern void eg_posset(re_re*);
        !          4359: -State *eg_startstate(re_re*);
        !          4360: -State *eg_stateof(re_re*, Positionset*);
        !          4361: -extern void eg_savestate(re_re*, State*);
        !          4362: -extern void eg_spr(long, int*, char*);
        !          4363: -extern void eg_stateinit(re_re*);
        !          4364: -extern unsigned char *eg_quickmatch(re_re *, unsigned char *, unsigned char *, int);
        !          4365: -extern unsigned char *eg_lquickmatch(re_re *, unsigned char *, unsigned char *, int);
        !          4366: -#else
        !          4367: -extern void clrstates();
        !          4368: -extern Expr *eg_eall();
        !          4369: -extern void egbr();
        !          4370: -extern int egdfabr();
        !          4371: -extern int eg_match();
        !          4372: -extern void eginit();
        !          4373: -extern char *egmalloc();
        !          4374: -extern void egpost();
        !          4375: -extern void egcanon();
        !          4376: -extern re_re *egprep();
        !          4377: -extern char *egrealloc();
        !          4378: -extern void eg_epr();
        !          4379: -extern void eg_brpr();
        !          4380: -extern int eg_getstate();
        !          4381: -extern void eg_lex();
        !          4382: -extern void eg_lexinit();
        !          4383: -extern Expr *eg_newexpr();
        !          4384: -extern int eg_posalloc();
        !          4385: -extern void eg_posinit();
        !          4386: -extern void eg_posset();
        !          4387: -extern void eg_savestate();
        !          4388: -extern void eg_spr();
        !          4389: -extern State *eg_startstate();
        !          4390: -extern void eg_stateinit();
        !          4391: -extern State *eg_stateof();
        !          4392: -extern unsigned char *eg_quickmatch();
        !          4393: -extern unsigned char *eg_lquickmatch();
        !          4394: -# endif
        !          4395: -
        !          4396: -# if defined(__cplusplus)
        !          4397: -}             /* C++ 2.0 */
        !          4398: -# endif
        !          4399: -#endif
        !          4400: //GO.SYSIN DD lre.h
        !          4401: echo libc.h 1>&2
        !          4402: sed 's/.//' >libc.h <<'//GO.SYSIN DD libc.h'
        !          4403: -/* system calls */
        !          4404: -extern unsigned alarm();
        !          4405: -extern void nap(), pause();
        !          4406: -extern char *sbrk();
        !          4407: -extern void exit(), _exit();
        !          4408: -extern long lseek();
        !          4409: -extern void nice();
        !          4410: -extern void profil();
        !          4411: -extern unsigned long settod();
        !          4412: -extern void sync();
        !          4413: -extern long time();
        !          4414: -
        !          4415: -/* libc et al */
        !          4416: -extern long lcm();
        !          4417: -extern double atof(), strtod();
        !          4418: -extern long atol();
        !          4419: -extern char *crypt();
        !          4420: -extern char *ctime();
        !          4421: -extern char *ecvt(), *fcvt(), *gcvt();
        !          4422: -extern char *galloc();
        !          4423: -extern char *getenv();
        !          4424: -extern char *getlogin();
        !          4425: -extern char *getpass();
        !          4426: -extern char *getwd(), *getcwd();
        !          4427: -extern char *malloc(), *realloc(), *calloc();
        !          4428: -extern char *memcpy(), *memchr(), *memccpy(), *memset(), *memmove();
        !          4429: -extern char *mktemp();
        !          4430: -extern double frand();
        !          4431: -extern char *setfields();
        !          4432: -extern char *strcpy(), *strncpy(), *strcat(), *strncat(), *strchr(), *strrchr();
        !          4433: -extern char *strpbrk(), *strtok(), *strdup();
        !          4434: -extern int atoi();
        !          4435: -extern char *tgetstr(), tgoto();
        !          4436: -extern char *ttyname(), *cttyname();
        !          4437: -
        !          4438: -#define       NONEXIT         33
        !          4439: //GO.SYSIN DD libc.h
        !          4440: echo getopt.c 1>&2
        !          4441: sed 's/.//' >getopt.c <<'//GO.SYSIN DD getopt.c'
        !          4442: -#include "re.h"
        !          4443: -#include "lre.h"
        !          4444: -#include "hdr.h"
        !          4445: -
        !          4446: -#define ERR(str, chr)       if(opterr){fprint(2, "%s%s%c\n", argv[0], str, chr);}
        !          4447: -#define       EOF     -1
        !          4448: -#define       NULL    0
        !          4449: -int     opterr = 1;
        !          4450: -int     optind = 1;
        !          4451: -int   optopt;
        !          4452: -char    *optarg;
        !          4453: -
        !          4454: -int
        !          4455: -getopt(int argc, char **argv, char *opts)
        !          4456: -{
        !          4457: -      static int sp = 1;
        !          4458: -      register c;
        !          4459: -      register char *cp;
        !          4460: -
        !          4461: -      if (sp == 1)
        !          4462: -              if (optind >= argc ||
        !          4463: -                 argv[optind][0] != '-' || argv[optind][1] == '\0')
        !          4464: -                      return EOF;
        !          4465: -              else if (strcmp(argv[optind], "--") == NULL) {
        !          4466: -                      optind++;
        !          4467: -                      return EOF;
        !          4468: -              }
        !          4469: -      optopt = c = argv[optind][sp];
        !          4470: -      if (c == ':' || (cp=strchr(opts, c)) == NULL) {
        !          4471: -              ERR (": illegal option -- ", c);
        !          4472: -              if (argv[optind][++sp] == '\0') {
        !          4473: -                      optind++;
        !          4474: -                      sp = 1;
        !          4475: -              }
        !          4476: -              return '?';
        !          4477: -      }
        !          4478: -      if (*++cp == ':') {
        !          4479: -              if (argv[optind][sp+1] != '\0')
        !          4480: -                      optarg = &argv[optind++][sp+1];
        !          4481: -              else if (++optind >= argc) {
        !          4482: -                      ERR (": option requires an argument -- ", c);
        !          4483: -                      sp = 1;
        !          4484: -                      return '?';
        !          4485: -              } else
        !          4486: -                      optarg = argv[optind++];
        !          4487: -              sp = 1;
        !          4488: -      } else {
        !          4489: -              if (argv[optind][++sp] == '\0') {
        !          4490: -                      sp = 1;
        !          4491: -                      optind++;
        !          4492: -              }
        !          4493: -              optarg = NULL;
        !          4494: -      }
        !          4495: -      return c;
        !          4496: -}
        !          4497: //GO.SYSIN DD getopt.c
        !          4498: echo regress.d/complex 1>&2
        !          4499: sed 's/.//' >regress.d/complex <<'//GO.SYSIN DD regress.d/complex'
        !          4500: -did=verified
        !          4501: -for i in `ls t*.sh | sed -e 's/.sh$//' | sort +0.1n`
        !          4502: -do
        !          4503: -      sh $i.sh > temp
        !          4504: -      if cmp -s temp $i.out
        !          4505: -      then 
        !          4506: -              :
        !          4507: -      else 
        !          4508: -              echo "test $i failed" 
        !          4509: -      fi 
        !          4510: -      rm temp
        !          4511: -      did="$did $i"
        !          4512: -done
        !          4513: -echo "$did"
        !          4514: //GO.SYSIN DD regress.d/complex
        !          4515: echo regress.d/lt0.c 1>&2
        !          4516: sed 's/.//' >regress.d/lt0.c <<'//GO.SYSIN DD regress.d/lt0.c'
        !          4517: -/*
        !          4518: -From pegasus.ATT.COM!hansen Tue Oct  9 00:34 EDT 1990
        !          4519: -Received: by pyxis; Tue Oct  9 00:34 EDT 1990
        !          4520: -FROM:       [email protected] (t.l.hansen)
        !          4521: -TO:         research!andrew
        !          4522: -DATE:        9 Oct 1990   0:27 EDT
        !          4523: -SUBJECT:    bug in re_reexec()!
        !          4524: -
        !          4525: -Compile and link the following program. The expected output is:
        !          4526: -
        !          4527: -parens = 2
        !          4528: -matched
        !          4529: -0: 0x80881430 - 0x80881445
        !          4530: -"!nosuchsystem!testing"
        !          4531: -1: 0x80886334 - 0xc0020c1c
        !          4532: -"nosuchsystem"
        !          4533: -2: 0xc0020a78 - 0x80883924
        !          4534: -"testing"
        !          4535: -
        !          4536: -Instead, I get this. (Note the strings after 1: and 2:.)
        !          4537: -
        !          4538: -parens = 2
        !          4539: -matched
        !          4540: -0: 0x80881430 - 0x80881445
        !          4541: -"!nosuchsystem!testing"
        !          4542: -1: 0x80886334 - 0xc0020c1c
        !          4543: -""
        !          4544: -2: 0xc0020a78 - 0x80883924
        !          4545: -""
        !          4546: -
        !          4547: -Can you please look into this soon? If not, let me know so that I can hunt
        !          4548: -for it. I probably won't be able to find it as quickly as you, though. This
        !          4549: -showed up within mail and I have an MR haunting me. Thanks.
        !          4550: -
        !          4551: -                                      Tony
        !          4552: -
        !          4553: -----------------------------------------------------------------
        !          4554: -*/
        !          4555: -#include <stdio.h>
        !          4556: -#include <ctype.h>
        !          4557: -#include "re.h"
        !          4558: -#include "lre.h"
        !          4559: -
        !          4560: -void prc(c)
        !          4561: -unsigned char c;
        !          4562: -{
        !          4563: -    if (c >= 0200)
        !          4564: -      {
        !          4565: -      (void) printf("M-");
        !          4566: -      c -= 0200;
        !          4567: -      }
        !          4568: -    if (isprint(c)) putchar(c);
        !          4569: -    else
        !          4570: -      {
        !          4571: -      putchar('^');
        !          4572: -      putchar(c ^ 0100);
        !          4573: -      }
        !          4574: -}
        !          4575: -
        !          4576: -void pr(i, mb, me)
        !          4577: -int i;
        !          4578: -char *mb;
        !          4579: -char *me;
        !          4580: -{
        !          4581: -    (void) printf("%d: %#x - %#x\n", i, mb, me);
        !          4582: -    putchar('"');
        !          4583: -    for (; mb < me; mb++)
        !          4584: -      {
        !          4585: -      if (!*mb)
        !          4586: -          break;
        !          4587: -      prc(*mb);
        !          4588: -      }
        !          4589: -    putchar('"');
        !          4590: -    putchar('\n');
        !          4591: -}
        !          4592: -
        !          4593: -main()
        !          4594: -{
        !          4595: -    re_re *regex;
        !          4596: -    int i;
        !          4597: -    unsigned char re_map[256];
        !          4598: -    static char lname[] = "!nosuchsystem!testing";
        !          4599: -    static char pat[] = "!([^!]+)!(.+)";
        !          4600: -    char *match[10][2];
        !          4601: -    int parens;
        !          4602: -
        !          4603: -    for (i = 0; i < 256; i++)
        !          4604: -      re_map[i] = i;
        !          4605: -    regex = re_recomp(pat, pat+strlen(pat), re_map);
        !          4606: -    parens = re_paren(regex);
        !          4607: -    (void) printf("parens = %d\n", parens);
        !          4608: -    if (parens != 2)
        !          4609: -      return 0;
        !          4610: -    if (!re_reexec(regex, lname, lname+strlen(lname), match))
        !          4611: -      {
        !          4612: -      (void) printf("no match\n");
        !          4613: -      return 0;
        !          4614: -      }
        !          4615: -
        !          4616: -    (void) printf("matched\n");
        !          4617: -    for (i = 0; i <= parens; i++)
        !          4618: -      pr(i, match[i][0], match[i][1]);
        !          4619: -    return 0;
        !          4620: -}
        !          4621: //GO.SYSIN DD regress.d/lt0.c
        !          4622: echo regress.d/makefile 1>&2
        !          4623: sed 's/.//' >regress.d/makefile <<'//GO.SYSIN DD regress.d/makefile'
        !          4624: -GRE=gre
        !          4625: -
        !          4626: -all:
        !          4627: -      @echo "checking $(GRE):"
        !          4628: -      @GRE=$(GRE) sh simple
        !          4629: -      @GRE=$(GRE) sh complex
        !          4630: //GO.SYSIN DD regress.d/makefile
        !          4631: echo regress.d/simple 1>&2
        !          4632: sed 's/.//' >regress.d/simple <<'//GO.SYSIN DD regress.d/simple'
        !          4633: -awk '
        !          4634: -BEGIN {
        !          4635: -      sq = "'"'"'"
        !          4636: -      FS = "\t"
        !          4637: -      gre = "'"$GRE"'"
        !          4638: -}
        !          4639: -NF == 0 {
        !          4640: -      next
        !          4641: -}
        !          4642: -$1 != "" {    # new test
        !          4643: -      re = $1
        !          4644: -      if($4 == ""){
        !          4645: -              nopts = 1; opts[0] = ""
        !          4646: -      } else if(substr($4, 1, 1) == "-"){
        !          4647: -              nopts = 1; opts[0] = " " $4
        !          4648: -      } else {
        !          4649: -              for(nopts = 0; nopts < length($4); nopts++){
        !          4650: -                      x = substr($4, nopts, 1)
        !          4651: -                      if(x == "~") opts[nopts] = ""
        !          4652: -                      else opts[nopts] = " -" x
        !          4653: -              }
        !          4654: -      }
        !          4655: -}
        !          4656: -$2 != "" {    # either ~ or !~
        !          4657: -      op = $2
        !          4658: -      if (op == "~")
        !          4659: -              neg = 0
        !          4660: -      else if (op == "!~")
        !          4661: -              neg = 1
        !          4662: -}
        !          4663: -$3 != "" {    # new test string
        !          4664: -      str = $3
        !          4665: -}
        !          4666: -$3 == "\"\"" {        # explicit empty line
        !          4667: -      $3 = ""
        !          4668: -}
        !          4669: -NF > 2 {      # generate a test
        !          4670: -      input = $3
        !          4671: -      for(i = 0; i < nopts; i++){
        !          4672: -      ntests++;
        !          4673: -      if(neg){
        !          4674: -              printf("if echo %s | %s -s %s; then echo %s%d fails %s %s %s %s%s ;else :; fi\n", sq input sq, gre opts[i], sq re sq, sq, NR, opts[i], re, op, input, sq)
        !          4675: -      } else {
        !          4676: -              printf("if echo %s | %s -s %s; then :; else echo %s%d fails %s %s %s %s%s ; fi\n", sq input sq, gre opts[i], sq re sq, sq, NR, opts[i], re, op, input, sq)
        !          4677: -      }
        !          4678: -      }
        !          4679: -}
        !          4680: -END   { print "echo " sq ntests " simple tests" sq }
        !          4681: -' > regress.i <<\!!!
        !          4682: -a     ~       a
        !          4683: -              ba
        !          4684: -              bab
        !          4685: -      !~      ""
        !          4686: -              x
        !          4687: -              xxxxx
        !          4688: -.     ~       x
        !          4689: -              xxx
        !          4690: -      !~      ""                      
        !          4691: -.a    ~       xa
        !          4692: -              xxa
        !          4693: -              xax
        !          4694: -      !~      a
        !          4695: -              ab
        !          4696: -              ""
        !          4697: -$     ~       x
        !          4698: -              ""
        !          4699: -.$    ~       x
        !          4700: -      !~      ""
        !          4701: -a$    ~       a
        !          4702: -              ba
        !          4703: -              bbba
        !          4704: -      !~      ab
        !          4705: -              x
        !          4706: -              ""
        !          4707: -^     ~       x
        !          4708: -              ""
        !          4709: -              ^
        !          4710: -^a$   ~       a
        !          4711: -      !~      xa
        !          4712: -              ax
        !          4713: -              xax
        !          4714: -              ""
        !          4715: -^a.$  ~       ax
        !          4716: -              aa
        !          4717: -      !~      xa
        !          4718: -              aaa
        !          4719: -              axy
        !          4720: -              ""
        !          4721: -^$    ~       ""
        !          4722: -      !~      x
        !          4723: -              ^
        !          4724: -^.a   ~       xa
        !          4725: -              xaa
        !          4726: -      !~      a
        !          4727: -              ""
        !          4728: -^.*a  ~       a
        !          4729: -              xa
        !          4730: -              xxxxxxa
        !          4731: -      !~      ""
        !          4732: -^.+a  ~       xa
        !          4733: -              xxxxxxa
        !          4734: -      !~      ""
        !          4735: -              a
        !          4736: -              ax
        !          4737: -a*    ~       ""
        !          4738: -              a
        !          4739: -              aaaa
        !          4740: -              xa
        !          4741: -              xxxx
        !          4742: -aa*   ~       a
        !          4743: -              aaa
        !          4744: -              xa
        !          4745: -      !~      xxxx
        !          4746: -              ""
        !          4747: -\$    ~       x$
        !          4748: -              $
        !          4749: -              $x
        !          4750: -      !~      ""
        !          4751: -              x
        !          4752: -\.    ~       .
        !          4753: -      !~      x
        !          4754: -              ""
        !          4755: -.^$   ~       a^      -G
        !          4756: -      !~      ""
        !          4757: -              a^$
        !          4758: -^x$   ~       x       -G
        !          4759: -      !~      yx
        !          4760: -              xy
        !          4761: -a\$   ~       a$      -G
        !          4762: -      !~      a
        !          4763: -\(ab\)$       ~       cab     -G
        !          4764: -              ab
        !          4765: -      !~      ab$
        !          4766: -xr+y  ~       xry     ~E
        !          4767: -              xrry
        !          4768: -              xrrrrrry
        !          4769: -      !~      ry
        !          4770: -              xy
        !          4771: -xr?y  ~       xy      ~E
        !          4772: -              xry
        !          4773: -      !~      xrry
        !          4774: -a(bc|def)g    ~       abcg    ~E
        !          4775: -              adefg
        !          4776: -      !~      abc
        !          4777: -              abg
        !          4778: -              adef
        !          4779: -              adeg
        !          4780: -[0-9] ~       1
        !          4781: -              567
        !          4782: -              x0y
        !          4783: -      !~      abc
        !          4784: -              ""
        !          4785: -[^0-9]        !~      1
        !          4786: -              567
        !          4787: -              ""
        !          4788: -      ~       abc
        !          4789: -              x0y
        !          4790: -x[0-9]+y      ~       x0y     ~E
        !          4791: -              x23y
        !          4792: -              x12345y
        !          4793: -      !~      0y
        !          4794: -              xy
        !          4795: -x[0-9]?y      ~       xy      ~E
        !          4796: -              x1y
        !          4797: -      !~      x23y
        !          4798: -X     ~       x       -i
        !          4799: -read  ~       read    -x
        !          4800: -      !~      xy read
        !          4801: -              x read y
        !          4802: -              xread
        !          4803: -              readx
        !          4804: -read  ~       read    -xF
        !          4805: -      !~      xy read
        !          4806: -              x read y
        !          4807: -              xread
        !          4808: -              readx
        !          4809: -read  ~       read    -F
        !          4810: -              xy read
        !          4811: -              x read y
        !          4812: -              xread
        !          4813: -              readx
        !          4814: -[.]de..       ~       .dexx
        !          4815: -              .deyyy
        !          4816: -      !~      .de
        !          4817: -              .dex
        !          4818: -^|s   ~       |sec    -G
        !          4819: -      !~      sec
        !          4820: -..B   ~       CDAB    -G
        !          4821: -      !~      ABCD
        !          4822: -$.*tt.*\$     ~       $tt$    -G
        !          4823: -^([a-z]+)\1$  ~       vivi
        !          4824: -      !~      vivify
        !          4825: -([a-z]+)\1    ~       vivi
        !          4826: -              vivify
        !          4827: -              revivi
        !          4828: -      !~      vovify
        !          4829: -              viv
        !          4830: -\(....\).*\1  ~       beriberi        -G
        !          4831: -(....).*\1    ~       beriberi
        !          4832: -^$    ~       
        !          4833: -^$    ~               -G
        !          4834: -[ab]\{2\}k    ~       abk
        !          4835: -              xyaak
        !          4836: -              zabak
        !          4837: -      !~      zad
        !          4838: -              bq
        !          4839: -              abq
        !          4840: -[ab]\{2,\}d   ~       abd
        !          4841: -              abababad
        !          4842: -      !~      ad
        !          4843: -              ababaq
        !          4844: -q[ab]\{2,4\}d ~       qabd
        !          4845: -              qababd
        !          4846: -              qaaad
        !          4847: -      !~      qad
        !          4848: -              qababad
        !          4849: -a[]]b ~       a]b     -E
        !          4850: -a[]]b ~       a]b     -G
        !          4851: -a[^]b]c       ~       adc     -E
        !          4852: -a[^]b]c       ~       adc     -G
        !          4853: -angel[^e]     ~       angelo  -i
        !          4854: -      ~       ANGELH
        !          4855: -      !~      angel
        !          4856: -              ANGEL
        !          4857: -              angele
        !          4858: -              ANGELE
        !          4859: -^[^-].*>      ~       abc>    -G
        !          4860: -      !~      -a>
        !          4861: -^[A-Z]        ~       abc     -i
        !          4862: -              ABC
        !          4863: -^[^A-Z]       !~      abc     -i
        !          4864: -              ABC
        !          4865: -      ~       123
        !          4866: -|abc  ~       |abc    -G
        !          4867: -      !~      abc
        !          4868: -\(ac*\)c*d[ac]*\1     ~       acdacaaa        -G
        !          4869: -(ac*)c*d[ac]*\1       ~       acdacaaa
        !          4870: -ram|am        ~       am
        !          4871: -.|..  !~      abc     -x
        !          4872: -[a-za-za-za-za-za-za-za-za-za-z]      ~       for this line   -E
        !          4873: -[a-za-za-za-za-za-za-za-za-za-z]      ~       for this line
        !          4874: -[a-za-za-za-za-za-za-za-za-z] ~       but watch out   -E
        !          4875: -[a-za-za-za-za-za-za-za-za-z] ~       but watch out
        !          4876: -!!!
        !          4877: -cp regress.i ../temp
        !          4878: -sh < regress.i && rm regress.i
        !          4879: -echo "verified simple"
        !          4880: //GO.SYSIN DD regress.d/simple
        !          4881: echo regress.d/t1.i 1>&2
        !          4882: sed 's/.//' >regress.d/t1.i <<'//GO.SYSIN DD regress.d/t1.i'
        !          4883: -.xxxxxxxxxxx
        !          4884: -.xxxxxxxxxxxxxxxxxxx
        !          4885: -.xxxxxxxxxxxxxxxxxxxxxxxx
        !          4886: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4887: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4888: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4889: -.xxxxxxxxxxxxxxxxxxxxxxxx
        !          4890: -.xxxxxxxxxxxxxxxxxxxxxxxx
        !          4891: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4892: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4893: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4894: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4895: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4896: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4897: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4898: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4899: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4900: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4901: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4902: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4903: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4904: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4905: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4906: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4907: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4908: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4909: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4910: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4911: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4912: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4913: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4914: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4915: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4916: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4917: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4918: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4919: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4920: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4921: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4922: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4923: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4924: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4925: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4926: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4927: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4928: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4929: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4930: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4931: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4932: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4933: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4934: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4935: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4936: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4937: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4938: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4939: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4940: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4941: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4942: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4943: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4944: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4945: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4946: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4947: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4948: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4949: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4950: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4951: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4952: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4953: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4954: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4955: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4956: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4957: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4958: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4959: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4960: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4961: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4962: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4963: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4964: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4965: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4966: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4967: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4968: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4969: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4970: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4971: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4972: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4973: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4974: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4975: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4976: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4977: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4978: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4979: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4980: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4981: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4982: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4983: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4984: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4985: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4986: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4987: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4988: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4989: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4990: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4991: -.xxxxxxxxxxxxxxxxxxxxxxx
        !          4992: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4993: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4994: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4995: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4996: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4997: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4998: -.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !          4999: //GO.SYSIN DD regress.d/t1.i
        !          5000: echo regress.d/t1.out 1>&2
        !          5001: sed 's/.//' >regress.d/t1.out <<'//GO.SYSIN DD regress.d/t1.out'
        !          5002: //GO.SYSIN DD regress.d/t1.out
        !          5003: echo regress.d/t1.sh 1>&2
        !          5004: sed 's/.//' >regress.d/t1.sh <<'//GO.SYSIN DD regress.d/t1.sh'
        !          5005: -cat t1.i | $GRE -v '^\.x'
        !          5006: //GO.SYSIN DD regress.d/t1.sh
        !          5007: echo regress.d/t10.i 1>&2
        !          5008: sed 's/.//' >regress.d/t10.i <<'//GO.SYSIN DD regress.d/t10.i'
        !          5009: -at
        !          5010: -hematic
        !          5011: //GO.SYSIN DD regress.d/t10.i
        !          5012: echo regress.d/t10.out 1>&2
        !          5013: sed 's/.//' >regress.d/t10.out <<'//GO.SYSIN DD regress.d/t10.out'
        !          5014: //GO.SYSIN DD regress.d/t10.out
        !          5015: echo regress.d/t10.sh 1>&2
        !          5016: sed 's/.//' >regress.d/t10.sh <<'//GO.SYSIN DD regress.d/t10.sh'
        !          5017: -$GRE -xvFf t10.i t10.i
        !          5018: //GO.SYSIN DD regress.d/t10.sh
        !          5019: echo regress.d/t11.i 1>&2
        !          5020: sed 's/.//' >regress.d/t11.i <<'//GO.SYSIN DD regress.d/t11.i'
        !          5021: -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaxyz
        !          5022: -abc
        !          5023: //GO.SYSIN DD regress.d/t11.i
        !          5024: echo regress.d/t11.out 1>&2
        !          5025: sed 's/.//' >regress.d/t11.out <<'//GO.SYSIN DD regress.d/t11.out'
        !          5026: -gre: t11.i: warning: line too long (> 500 chars); text skipped
        !          5027: -abc
        !          5028: //GO.SYSIN DD regress.d/t11.out
        !          5029: echo regress.d/t11.sh 1>&2
        !          5030: sed 's/.//' >regress.d/t11.sh <<'//GO.SYSIN DD regress.d/t11.sh'
        !          5031: -$GRE abc t11.i 2>&1
        !          5032: //GO.SYSIN DD regress.d/t11.sh
        !          5033: echo regress.d/t12.i 1>&2
        !          5034: sed 's/.//' >regress.d/t12.i <<'//GO.SYSIN DD regress.d/t12.i'
        !          5035: -AAA   n
        !          5036: -AAAS  n
        !          5037: -Aaron n
        !          5038: -AAU   n
        !          5039: -AAUP  d
        !          5040: -AAUW  d
        !          5041: -ABA   n
        !          5042: -Ababa pc
        !          5043: -aback d
        !          5044: -abacus        n
        !          5045: -abaft d
        !          5046: -abalone       n
        !          5047: -abandon       v,er,va
        !          5048: -abase v,er,va
        !          5049: -abash v,er,va
        !          5050: -abate v,er,va
        !          5051: -abattoir      n
        !          5052: -abbe  n
        !          5053: -abbess        n
        !          5054: -abbey n
        !          5055: -abbot n
        !          5056: -Abbott        n
        !          5057: -abbreviate    v,ion
        !          5058: -abc   n
        !          5059: -abdicate      v,ion,va
        !          5060: -abdomen       n
        !          5061: -abdominal     a
        !          5062: -abduct        v,ion
        !          5063: -Abe   pc
        !          5064: -abeam d
        !          5065: -abed  d
        !          5066: -Abel  pc
        !          5067: -Abelian       pc
        !          5068: -Abelson       n
        !          5069: -Aberdeen      pc
        !          5070: -Abernathy     n
        !          5071: -aberrant      n,a
        !          5072: -aberrate      v,ion
        !          5073: -abet  v,va,ms
        !          5074: -abettor       n
        !          5075: -abeyant       a
        !          5076: -abhor v,er,ms
        !          5077: -abhorrent     a
        !          5078: -abide v,er
        !          5079: -Abidjan       pc
        !          5080: -Abigail       pc
        !          5081: -abject        a,ion
        !          5082: -abjuration    n
        !          5083: -abjure        v,er
        !          5084: -ablate        v,ion
        !          5085: -ablaut        n
        !          5086: -ablaze        d
        !          5087: -able  v,a,comp,va
        !          5088: -abloom        d
        !          5089: -ablution      n
        !          5090: -ABM   n
        !          5091: -abnegate      v,ion
        !          5092: -Abner pc
        !          5093: -abnormal      n,a
        !          5094: -aboard        d
        !          5095: -abode n
        !          5096: -abolish       v,er,va
        !          5097: -abolition     n,na
        !          5098: -abolitionary  n
        !          5099: -abominable    a
        !          5100: -abominate     v,ion
        !          5101: -aboriginal    n,a
        !          5102: -aborigine     n
        !          5103: -aborning      d
        !          5104: -abort v,er,ion
        !          5105: -abortifacient n
        !          5106: -abound        vi
        !          5107: -about d,nopref
        !          5108: -above d
        !          5109: -aboveboard    d
        !          5110: -aboveground   d
        !          5111: -abovementioned        d
        !          5112: -abracadabra   n
        !          5113: -abrade        v,er,va
        !          5114: -Abraham       n
        !          5115: -Abram n
        !          5116: -Abramson      n
        !          5117: -abrasion      n,na
        !          5118: -abreact       v,ion
        !          5119: -abreast       d
        !          5120: -abridge       v,er,va
        !          5121: -abridgment    n
        !          5122: -abroad        d
        !          5123: -abrogate      v,ion
        !          5124: -abrupt        a,ion
        !          5125: -abscess       n,v
        !          5126: -abscissa      n
        !          5127: -abscissae     d
        !          5128: -abscission    n
        !          5129: -abscond       v,er
        !          5130: -absent        v,a
        !          5131: -absentee      n
        !          5132: -absenteeism   n
        !          5133: -absentia      n
        !          5134: -absentminded  a
        !          5135: -absinthe      n
        !          5136: -absolute      n,a,na
        !          5137: -absolution    n
        !          5138: -absolve       v,er
        !          5139: -absorb        v,er,va
        !          5140: -absorbent     a
        !          5141: -absorption    n,na
        !          5142: -abstain       v,er
        !          5143: -abstemious    a
        !          5144: -abstention    n
        !          5145: -abstinent     a
        !          5146: -abstract      n,v,a,er,ion
        !          5147: -abstruse      a
        !          5148: -absurd        a,na
        !          5149: -abuilding     d
        !          5150: -abundant      a
        !          5151: -abuse n,v,er,va
        !          5152: -abusive       a
        !          5153: -abut  v,er,va,ms
        !          5154: -abysmal       a
        !          5155: -abyss n
        !          5156: -abyssal       a
        !          5157: -Abyssinia     pc
        !          5158: -AC    d
        !          5159: -acacia        n
        !          5160: -academe       pc,na
        !          5161: -academia      pc
        !          5162: -academic      n,na
        !          5163: -academician   n
        !          5164: -academy       n
        !          5165: -Acadia        pc
        !          5166: -acanthus      n
        !          5167: -Acapulco      pc
        !          5168: -accede        v
        !          5169: -accelerando   d
        !          5170: -accelerate    v,ion
        !          5171: -accelerometer n
        !          5172: -accent        n,v,na
        !          5173: -accentual     a
        !          5174: -accentuate    v,ion
        !          5175: -accept        v,er,va
        !          5176: -acceptant     a
        !          5177: -acceptor      n
        !          5178: -access        n,v
        !          5179: -accessible    a,in
        !          5180: -accession     n,v,na
        !          5181: -accessory     n,na
        !          5182: -accident      n,a
        !          5183: -accidental    a
        !          5184: -accipiter     n
        !          5185: -acclaim       n,v,er
        !          5186: -acclamation   n
        !          5187: -acclimate     n,v,ion
        !          5188: -acclimatize   v,er,ion
        !          5189: -accolade      n
        !          5190: -accommodate   v,ion
        !          5191: -accompaniment n
        !          5192: -accompanist   n
        !          5193: -accompany     v,na
        !          5194: -accompli      d
        !          5195: -accomplice    n
        !          5196: -accomplish    v,er,va
        !          5197: -accord        n,v
        !          5198: -accordant     a
        !          5199: -accordion     n,na
        !          5200: -accost        v
        !          5201: -account       n,v,va
        !          5202: -accountant    n,a,na
        !          5203: -Accra pc
        !          5204: -accredit      v,va
        !          5205: -accreditation n
        !          5206: -accrete       v
        !          5207: -accretion     n,na
        !          5208: -accretionary  n
        !          5209: -accrual       a
        !          5210: -accrue        v,va
        !          5211: -acculturate   v,ion
        !          5212: -accumulate    v,ion
        !          5213: -accuracy      n,in
        !          5214: -accurate      a,in
        !          5215: -accursed      a
        !          5216: -accusation    n,na
        !          5217: -accusatory    d
        !          5218: -accuse        v,er
        !          5219: -accustom      v
        !          5220: -ace   n,v,nopref
        !          5221: -acentric      d
        !          5222: -acerb a
        !          5223: -acerbic       a
        !          5224: -acetaldehyde  n
        !          5225: -acetate       n
        !          5226: -acetic        d
        !          5227: -acetone       n
        !          5228: -acetyl        n,na
        !          5229: -acetylene     n
        !          5230: -ache  n,v,er
        !          5231: -achieve       v,er,va
        !          5232: -Achilles      pc
        !          5233: -aching        a
        !          5234: -achondrite    n,na
        !          5235: -achromatic    a
        !          5236: -acid  n,a
        !          5237: -acidic        d
        !          5238: -acidify       v,er,ion
        !          5239: -acidimeter    n,na
        !          5240: -acidulous     a
        !          5241: -Ackerman      n
        !          5242: -Ackley        n
        !          5243: -acknowledge   v,va
        !          5244: -acknowledgeable       d
        !          5245: -ACLU  pc
        !          5246: -ACM   pc
        !          5247: -acme  pc
        !          5248: -acne  n
        !          5249: -acolyte       n
        !          5250: -acorn n
        !          5251: -acoustic      n,a
        !          5252: -acoustician   n
        !          5253: -acoustoelectric       a,na
        !          5254: -acoustooptic  n,a,na
        !          5255: -acquaint      v
        !          5256: -acquaintance  n,na
        !          5257: -acquiesce     v
        !          5258: -acquiescent   a
        !          5259: -acquire       v,va
        !          5260: -acquisition   n,na
        !          5261: -acquit        v,ms
        !          5262: -acquittal     n
        !          5263: -acre  n
        !          5264: -acreage       pc
        !          5265: -acrid a
        !          5266: -acrimonious   a
        !          5267: -acrimony      n
        !          5268: -acrobat       n
        !          5269: -acrobatic     n,na
        !          5270: -acrolein      n
        !          5271: -acronym       n
        !          5272: -acrophobia    n
        !          5273: -acropolis     n
        !          5274: -across        d
        !          5275: -acrostic      a
        !          5276: -acrylate      n
        !          5277: -acrylic       n
        !          5278: -ACS   pc
        !          5279: -act   n,v,ion,va
        !          5280: -Actaeon       pc
        !          5281: -actinic       na
        !          5282: -actinide      n
        !          5283: -actinium      n
        !          5284: -actinometer   n,na
        !          5285: -activate      v,ion,in
        !          5286: -activism      pc
        !          5287: -Acton n
        !          5288: -actress       n
        !          5289: -actual        a,na
        !          5290: -actuarial     a
        !          5291: -actuary       n
        !          5292: -actuate       v,ion
        !          5293: -acuity        n
        !          5294: -acumen        n
        !          5295: -acupuncture   n
        !          5296: -acute a
        !          5297: -acyclic       a
        !          5298: -acyl  n
        !          5299: -ad    n
        !          5300: -Ada   pc
        !          5301: -adage n
        !          5302: -adagio        n
        !          5303: -Adair pc
        !          5304: -Adam  pc
        !          5305: -adamant       a
        !          5306: -adamantine    a
        !          5307: -Adams n
        !          5308: -Adamson       n
        !          5309: -adapt v,er,ion,va
        !          5310: -adaptation    n,na
        !          5311: -adaptive      a
        !          5312: -adaptor       n
        !          5313: -add   v,er,va
        !          5314: -addend        n
        !          5315: -addenda       pc
        !          5316: -addendum      pc
        !          5317: -addict        n,v,ion
        !          5318: -Addis pc
        !          5319: -Addison       n
        !          5320: -addition      n,na
        !          5321: -addle v
        !          5322: -address       n,v,er,na,va
        !          5323: -addressee     n
        !          5324: -Addressograph pc
        !          5325: -adduce        v,er,va
        !          5326: -Adelaide      pc
        !          5327: -Adele pc
        !          5328: -Adelia        pc
        !          5329: -Aden  pc
        !          5330: -adenoid       n,na
        !          5331: -adenoma       n
        !          5332: -adenosine     n
        !          5333: -adept n,a
        !          5334: -adequacy      n,in
        !          5335: -adequate      a,in
        !          5336: -adhere        v
        !          5337: -adherent      n,a
        !          5338: -adhesion      n,na
        !          5339: -adiabatic     n
        !          5340: -adieu n
        !          5341: -adipose       a
        !          5342: -Adirondack    n
        !          5343: -adjacent      a
        !          5344: -adjectival    a
        !          5345: -adjective     n,a
        !          5346: -adjoin        v
        !          5347: -adjoint       n
        !          5348: -adjourn       v,va
        !          5349: -adjudge       v
        !          5350: -adjudicate    v,ion
        !          5351: -adjunct       n,a,ion
        !          5352: -adjuration    n
        !          5353: -adjure        v
        !          5354: -adjust        v,er,va
        !          5355: -adjutant      n,a
        !          5356: -Adkins        n
        !          5357: -Adler n
        !          5358: -administer    v
        !          5359: -administrable d
        !          5360: -administrate  v,ion
        !          5361: -administratrix        d
        !          5362: -admiral       n
        !          5363: -admiralty     n
        !          5364: -admiration    n
        !          5365: -admire        v,er,va
        !          5366: -admissible    a,in
        !          5367: -admission     n,na
        !          5368: -admit v,er,ms
        !          5369: -admittance    n
        !          5370: -admix v
        !          5371: -admixture     n
        !          5372: -admonish      v,er,va
        !          5373: -admonition    n
        !          5374: -admonitory    a
        !          5375: -ado   d,nopref
        !          5376: -adobe n,er
        !          5377: -adolescent    n,a
        !          5378: -Adolph        pc
        !          5379: -Adolphus      pc
        !          5380: -Adonis        pc
        !          5381: -adopt v,er,ion,va
        !          5382: -adoration     n
        !          5383: -adore v,er,va
        !          5384: -adorn v,er,va
        !          5385: -adrenal       n,a
        !          5386: -adrenaline    n
        !          5387: -Adrian        pc
        !          5388: -Adriatic      pc
        !          5389: -Adrienne      pc
        !          5390: -adrift        d
        !          5391: -adroit        a,comp
        !          5392: -adsorb        v,va
        !          5393: -adsorbate     n
        !          5394: -adsorbent     n
        !          5395: -adsorption    n,na
        !          5396: -adulate       v,ion
        !          5397: -adult n,a
        !          5398: -adulterant    n
        !          5399: -adulterate    v,ion
        !          5400: -adulterer     n
        !          5401: -adulteress    n
        !          5402: -adulterous    a
        !          5403: -adultery      n
        !          5404: -adumbrate     v,ion
        !          5405: -advance       v,er,va
        !          5406: -advantage     n,v
        !          5407: -advantageous  a
        !          5408: -advection     n,na
        !          5409: -advent        n,na
        !          5410: -adventitial   a
        !          5411: -adventitious  a
        !          5412: -adventure     n,v,er,na
        !          5413: -adventuresome a
        !          5414: -adventuress   n
        !          5415: -adventurous   a
        !          5416: -adverb        n
        !          5417: -adverbial     a
        !          5418: -adversary     n,a
        !          5419: -adverse       a
        !          5420: -advert        n,v
        !          5421: -advertent     a,in
        !          5422: -advertise     v,er,va
        !          5423: -advice        pc
        !          5424: -advise        v,er,va
        !          5425: -advisee       n
        !          5426: -advisor       n,y
        !          5427: -advocacy      n
        !          5428: -advocate      v,ion
        !          5429: -adz   n
        !          5430: -adze  n
        !          5431: -Aegean        pc
        !          5432: -aegis n
        !          5433: -Aeneas        pc
        !          5434: -Aeneid        pc
        !          5435: -aeolian       d
        !          5436: -Aeolus        pc
        !          5437: -aerate        v,a,ion,va
        !          5438: -aerial        n,a,na
        !          5439: -aerie n
        !          5440: -Aerobacter    pc
        !          5441: -aerobatic     n
        !          5442: -aerobic       n,na
        !          5443: -aerodynamic   n,na
        !          5444: -aeronautic    n,na
        !          5445: -aerosol       n,na
        !          5446: -aerospace     n
        !          5447: -Aeschylus     pc
        !          5448: -aesthete      n
        !          5449: -aesthetic     n,na
        !          5450: -afar  d
        !          5451: -affable       a,va
        !          5452: -affair        n
        !          5453: -affect        n,v,ion,va
        !          5454: -affectation   n
        !          5455: -affectionate  a
        !          5456: -afferent      a
        !          5457: -affiance      n,v
        !          5458: -affidavit     n
        !          5459: -affiliate     n,v,ion
        !          5460: -affine        n,ed,a
        !          5461: -affinity      n
        !          5462: -affirm        v,va
        !          5463: -affirmation   n,na
        !          5464: -affix v,va
        !          5465: -affixation    n
        !          5466: -afflatus      n
        !          5467: -afflict       v,er,ion
        !          5468: -affluent      n,a
        !          5469: -afford        v,va
        !          5470: -afforest      v
        !          5471: -afforestation n
        !          5472: -affray        n,v
        !          5473: -affright      n,v
        !          5474: -affront       n,v
        !          5475: -afghan        n
        !          5476: -Afghanistan   pc
        !          5477: -aficionado    n
        !          5478: -afield        d
        !          5479: -afire d
        !          5480: -AFL   d
        !          5481: -aflame        d
        !          5482: -afloat        d
        !          5483: -aflutter      d
        !          5484: -afoot d
        !          5485: -aforementioned        d
        !          5486: -aforesaid     d
        !          5487: -aforethought  d
        !          5488: -afoul d
        !          5489: -afraid        d
        !          5490: -afresh        d
        !          5491: -Africa        pc
        !          5492: -Afrikaner     pc
        !          5493: -afro  n
        !          5494: -aft   er
        !          5495: -afterbirth    n
        !          5496: -afterburner   n
        !          5497: -afterdeck     n
        !          5498: -aftereffect   n
        !          5499: -afterglow     n
        !          5500: -afterimage    n
        !          5501: -afterlife     n
        !          5502: -aftermath     pc
        !          5503: -aftermost     pc
        !          5504: -afternoon     n
        !          5505: -aftershock    n
        !          5506: -aftertaste    n
        !          5507: -afterthought  n
        !          5508: -afterward     n
        !          5509: -afterworld    n
        !          5510: -again d,nopref
        !          5511: -against       d,nopref
        !          5512: -Agamemnon     pc
        !          5513: -agamic        a
        !          5514: -agape d
        !          5515: -agar  n,nopref
        !          5516: -agate n,nopref
        !          5517: -Agatha        pc
        !          5518: -agave n
        !          5519: -age   n,v
        !          5520: -Agee  n
        !          5521: -agelong       d
        !          5522: -agenda        pc,na
        !          5523: -agendum       pc
        !          5524: -agent n,a
        !          5525: -agglomerate   v,ion
        !          5526: -agglutinate   v,ion
        !          5527: -agglutinin    n
        !          5528: -aggrade       v
        !          5529: -aggravate     v,ion
        !          5530: -aggregate     n,v,a,ion
        !          5531: -aggression    n,na
        !          5532: -aggressor     n
        !          5533: -aggrieve      v
        !          5534: -aghast        d
        !          5535: -agile a
        !          5536: -agitate       v,ion
        !          5537: -agitprop      pc
        !          5538: -agleam        d
        !          5539: -agley d
        !          5540: -aglitter      d
        !          5541: -aglow d
        !          5542: -Agnes pc
        !          5543: -Agnew n
        !          5544: -agnomen       n
        !          5545: -agnostic      n,na
        !          5546: -ago   d,nopref
        !          5547: -agog  d
        !          5548: -agon  n
        !          5549: -agone na
        !          5550: -agony n
        !          5551: -agora n
        !          5552: -agoraphobia   n
        !          5553: -agouti        n
        !          5554: -agrarian      n,na
        !          5555: -agree v,va
        !          5556: -agreeable     a
        !          5557: -agreeing      d
        !          5558: -agribusiness  n
        !          5559: -Agricola      pc
        !          5560: -agricultural  a,na
        !          5561: -agriculture   n,na
        !          5562: -agrimony      n
        !          5563: -agronomist    n
        !          5564: -agronomy      n,na
        !          5565: -aground       d
        !          5566: -ague  n
        !          5567: -Agway pc
        !          5568: -ah    n,nopref
        !          5569: -Ahab  pc
        !          5570: -ahead d
        !          5571: -ahem  d
        !          5572: -Ahmadabad     pc
        !          5573: -ahoy  d
        !          5574: -aid   n,v,er,nopref
        !          5575: -Aida  pc
        !          5576: -aide  n,nopref
        !          5577: -Aiken pc
        !          5578: -ail   n,v,nopref
        !          5579: -ailanthus     pc
        !          5580: -Aileen        pc
        !          5581: -aileron       n
        !          5582: -ailment       n
        !          5583: -aim   n,v
        !          5584: -ain't d
        !          5585: -Ainu  n
        !          5586: -air   n,v,man,y
        !          5587: -airborne      d
        !          5588: -airbrush      n,v
        !          5589: -Airbus        n
        !          5590: -aircraft      n
        !          5591: -airdrop       n,v,va
        !          5592: -Aires pc
        !          5593: -airfare       n
        !          5594: -airfield      n
        !          5595: -airflow       n
        !          5596: -airfoil       n
        !          5597: -airframe      n
        !          5598: -airhead       n
        !          5599: -airlift       n,v
        !          5600: -airline       n,er
        !          5601: -airlock       n
        !          5602: -airmail       n,v
        !          5603: -airmass       n
        !          5604: -airpark       n
        !          5605: -airport       n
        !          5606: -airscrew      n
        !          5607: -airsick       a
        !          5608: -airspace      n
        !          5609: -airspeed      n
        !          5610: //GO.SYSIN DD regress.d/t12.i
        !          5611: echo regress.d/t12.out 1>&2
        !          5612: sed 's/.//' >regress.d/t12.out <<'//GO.SYSIN DD regress.d/t12.out'
        !          5613: //GO.SYSIN DD regress.d/t12.out
        !          5614: echo regress.d/t12.sh 1>&2
        !          5615: sed 's/.//' >regress.d/t12.sh <<'//GO.SYSIN DD regress.d/t12.sh'
        !          5616: -$GRE -Fxvf t12.i t12.i 2>&1
        !          5617: //GO.SYSIN DD regress.d/t12.sh
        !          5618: echo regress.d/t13.i 1>&2
        !          5619: sed 's/.//' >regress.d/t13.i <<'//GO.SYSIN DD regress.d/t13.i'
        !          5620: -/p1/usr/bin/pmxpc:
        !          5621: -       pm.sl  2.94
        !          5622: -       xdhu.sl        1.8
        !          5623: -      /lib/crt1.o.sl 1.1 4.0 01/15/86 12744 AT&T-SF
        !          5624: -      /usr/include/stdio.h.sl 1.1 4.0 01/15/86 4140 AT&T-SF
        !          5625: -      /usr/include/ctype.h.sl 1.1 4.0 01/15/86 45671 AT&T-SF
        !          5626: -      /usr/include/string.h.sl 1.1 4.0 01/15/86 51235 AT&T-SF
        !          5627: -      /usr/include/signal.h.sl 1.1 4.0 01/15/86 34302 AT&T-SF
        !          5628: -      /usr/include/sys/signal.h.sl 1.5 3.2 09/02/87 33640 AT&T-SF
        !          5629: -      /usr/include/sys/types.h.sl 1.3 3.1 06/02/86 48113 AT&T-SF
        !          5630: -      /usr/include/sys/stat.h.sl 1.3 3.0 12/19/85 41824 
        !          5631: -      /usr/include/termio.h.sl 1.1 4.0 01/15/86 29141 AT&T-SF
        !          5632: //GO.SYSIN DD regress.d/t13.i
        !          5633: echo regress.d/t13.out 1>&2
        !          5634: sed 's/.//' >regress.d/t13.out <<'//GO.SYSIN DD regress.d/t13.out'
        !          5635: -/p1/usr/bin/pmxpc:
        !          5636: -       pm.sl  2.94
        !          5637: -       xdhu.sl        1.8
        !          5638: //GO.SYSIN DD regress.d/t13.out
        !          5639: echo regress.d/t13.sh 1>&2
        !          5640: sed 's/.//' >regress.d/t13.sh <<'//GO.SYSIN DD regress.d/t13.sh'
        !          5641: -$GRE 'pm|xdhu' < t13.i 2>&1
        !          5642: //GO.SYSIN DD regress.d/t13.sh
        !          5643: echo regress.d/t2.out 1>&2
        !          5644: sed 's/.//' >regress.d/t2.out <<'//GO.SYSIN DD regress.d/t2.out'
        !          5645: //GO.SYSIN DD regress.d/t2.out
        !          5646: echo regress.d/t2.sh 1>&2
        !          5647: sed 's/.//' >regress.d/t2.sh <<'//GO.SYSIN DD regress.d/t2.sh'
        !          5648: -$GRE -v '^\.x' t1.i
        !          5649: //GO.SYSIN DD regress.d/t2.sh
        !          5650: echo regress.d/t3.i 1>&2
        !          5651: sed 's/.//' >regress.d/t3.i <<'//GO.SYSIN DD regress.d/t3.i'
        !          5652: -x
        !          5653: -abcd
        !          5654: -abcde
        !          5655: -eabcd
        !          5656: -defg
        !          5657: -xdefg
        !          5658: -defgx
        !          5659: -abcd defg
        !          5660: //GO.SYSIN DD regress.d/t3.i
        !          5661: echo regress.d/t3.out 1>&2
        !          5662: sed 's/.//' >regress.d/t3.out <<'//GO.SYSIN DD regress.d/t3.out'
        !          5663: -abcd
        !          5664: -defg
        !          5665: //GO.SYSIN DD regress.d/t3.out
        !          5666: echo regress.d/t3.sh 1>&2
        !          5667: sed 's/.//' >regress.d/t3.sh <<'//GO.SYSIN DD regress.d/t3.sh'
        !          5668: -$GRE -xF 'defg
        !          5669: -abcd' t3.i
        !          5670: //GO.SYSIN DD regress.d/t3.sh
        !          5671: echo regress.d/t4.i 1>&2
        !          5672: sed 's/.//' >regress.d/t4.i <<'//GO.SYSIN DD regress.d/t4.i'
        !          5673: -   1 ZIPPORI, Israel
        !          5674: -      /usr/spool/ap/88/07/15/a0471: Israel-MonaLisa
        !          5675: -   1 ZERIFIN, Israel
        !          5676: -      /usr/spool/ap/88/05/17/a0823: Israel-Baez
        !          5677: -   1 ZEPHYRHILLS, Fla.
        !          5678: -      /usr/spool/ap/88/04/27/a0963: HelicopterEscape
        !          5679: -   1 ZENICA, Yugoslavia
        !          5680: -      /usr/spool/ap/88/07/13/a0814: Yugoslavia
        !          5681: -   1 ZAP, N.D.
        !          5682: -      /usr/spool/ap/88/03/13/a0776: CoalStrike
        !          5683: -   1 ZAMBRANO, Honduras
        !          5684: -      /usr/spool/ap/88/03/24/a0512: Honduras-Soldiers
        !          5685: -   1 ZACHARY, La.
        !          5686: -      /usr/spool/ap/88/04/05/a0745: Brites
        !          5687: -   1 YUCCA VALLEY, Calif.
        !          5688: -      /usr/spool/ap/88/08/26/a0624: BRF--SoCalQuake
        !          5689: -   1 YORKVILLE, Ill.
        !          5690: -      /usr/spool/ap/88/08/31/a0687: ReformedStudent
        !          5691: -   1 YORK, Maine
        !          5692: -      /usr/spool/ap/88/10/09/a0772: SeaSearches
        !          5693: -   1 YENAN, China
        !          5694: -      /usr/spool/ap/88/02/24/a0419: China-Yenan
        !          5695: -   1 YELOWSTONE NATIONAL PARK, Wyo.
        !          5696: -      /usr/spool/ap/88/09/15/a0792: Dukakis
        !          5697: -   1 YEADON, Pa.
        !          5698: -      /usr/spool/ap/88/05/14/a0689: Brites
        !          5699: -   1 YATTA, Occupied West Bank
        !          5700: -      /usr/spool/ap/88/10/29/a0417: Israel-Undercover
        !          5701: -   1 YASSIHOYUK, Turkey
        !          5702: -      /usr/spool/ap/88/09/09/a0423: MidasTomb
        !          5703: -   1 YAPHANK, N.Y.
        !          5704: -      /usr/spool/ap/88/05/10/a0686: Brites
        !          5705: -   1 YAMOUSSOUKRO, Ivory Coast
        !          5706: -      /usr/spool/ap/88/09/25/a0635: Africa-UN
        !          5707: //GO.SYSIN DD regress.d/t4.i
        !          5708: echo regress.d/t4.out 1>&2
        !          5709: sed 's/.//' >regress.d/t4.out <<'//GO.SYSIN DD regress.d/t4.out'
        !          5710: -   1 ZIPPORI, Israel
        !          5711: -   1 ZERIFIN, Israel
        !          5712: -   1 ZEPHYRHILLS, Fla.
        !          5713: -   1 ZENICA, Yugoslavia
        !          5714: -   1 ZAP, N.D.
        !          5715: -   1 ZAMBRANO, Honduras
        !          5716: -   1 ZACHARY, La.
        !          5717: -   1 YUCCA VALLEY, Calif.
        !          5718: -   1 YORKVILLE, Ill.
        !          5719: -   1 YORK, Maine
        !          5720: -   1 YENAN, China
        !          5721: -   1 YELOWSTONE NATIONAL PARK, Wyo.
        !          5722: -   1 YEADON, Pa.
        !          5723: -   1 YATTA, Occupied West Bank
        !          5724: -   1 YASSIHOYUK, Turkey
        !          5725: -   1 YAPHANK, N.Y.
        !          5726: -   1 YAMOUSSOUKRO, Ivory Coast
        !          5727: //GO.SYSIN DD regress.d/t4.out
        !          5728: echo regress.d/t4.sh 1>&2
        !          5729: sed 's/.//' >regress.d/t4.sh <<'//GO.SYSIN DD regress.d/t4.sh'
        !          5730: -$GRE -v : t4.i
        !          5731: //GO.SYSIN DD regress.d/t4.sh
        !          5732: echo regress.d/t5.i 1>&2
        !          5733: sed 's/.//' >regress.d/t5.i <<'//GO.SYSIN DD regress.d/t5.i'
        !          5734: -com 1037117850
        !          5735: -com -113451303
        !          5736: -com -253844186
        !          5737: -com -591640727
        !          5738: -com -192085666
        !          5739: -com 875206176
        !          5740: -com -688908411
        !          5741: -com 116220732
        !          5742: -com -815364609
        !          5743: -com 393021566
        !          5744: -com -197586762
        !          5745: -com -979497332
        !          5746: -com 580876342
        !          5747: -com 857752251
        !          5748: -com -282427433
        !          5749: -com 440265772
        !          5750: -com 903702654
        !          5751: -com 377371259
        !          5752: -com -790446649
        !          5753: -com -407893353
        !          5754: -com 601447097
        !          5755: -com 311585929
        !          5756: -com -990601410
        !          5757: -com 273028495
        !          5758: -com -421520583
        !          5759: -com -620551282
        !          5760: -com -768217422
        !          5761: -com 722547274
        !          5762: -com 313902943
        !          5763: -com -729597068
        !          5764: -com 306062132
        !          5765: -com 773754585
        !          5766: -com -678639313
        !          5767: -com -345701409
        !          5768: -com -290065002
        !          5769: -com -974307104
        !          5770: -com 1047184566
        !          5771: -com 210828681
        !          5772: -com 108982822
        !          5773: -com 68031245
        !          5774: -com -1047141482
        !          5775: -com 227569703
        !          5776: -com -530798398
        !          5777: -com -822779044
        !          5778: -com 440691738
        !          5779: -com 624275796
        !          5780: -com 843073732
        !          5781: -com 228971433
        !          5782: -com 258376249
        !          5783: -com -308161170
        !          5784: -com -995590232
        !          5785: -com 856677272
        !          5786: -com 132296249
        !          5787: -com 633658628
        !          5788: -com 25935234
        !          5789: -com -1063085400
        !          5790: -com 148654970
        !          5791: -com -824172925
        !          5792: -com -659459669
        !          5793: -com 196909720
        !          5794: -com -393774825
        !          5795: -com 736667556
        !          5796: -com 674673107
        !          5797: -com 1007653812
        !          5798: -com -261383312
        !          5799: -com 263123663
        !          5800: -com -946595190
        !          5801: -com -396442
        !          5802: -com -506832213
        !          5803: -com 149702652
        !          5804: -com -937852087
        !          5805: -com -500943193
        !          5806: -com -288026147
        !          5807: -com -653808189
        !          5808: -com 801559288
        !          5809: -com -653395420
        !          5810: -com -405217270
        !          5811: -com -749529781
        !          5812: -com 965720542
        !          5813: -com 396739912
        !          5814: -com 250804267
        !          5815: -com 1058925867
        !          5816: -com 121948720
        !          5817: -com 129329115
        !          5818: -com -503214654
        !          5819: -com 758365427
        !          5820: -com -569717820
        !          5821: -com 191932303
        !          5822: -com 1041195498
        !          5823: -com -178872661
        !          5824: -com 719024931
        !          5825: -com 389365053
        !          5826: -com -695930677
        !          5827: -com -720993320
        !          5828: -com 659352079
        !          5829: -com -445359373
        !          5830: -com -405581235
        !          5831: -com -495515453
        !          5832: -com -861910553
        !          5833: -com -35979929
        !          5834: -com 1056535300
        !          5835: -com 188042833
        !          5836: -com -220408267
        !          5837: -com -766533595
        !          5838: -com 718865736
        !          5839: -com -614647852
        !          5840: -com 637296265
        !          5841: -com 607439702
        !          5842: -com -996163547
        !          5843: -com -354301843
        !          5844: -com 187216170
        !          5845: -com -524246340
        !          5846: -com 165453004
        !          5847: -com -922340816
        !          5848: -com -392313676
        !          5849: -com 933400965
        !          5850: -com -357455062
        !          5851: -com 876069330
        !          5852: -com 619850004
        !          5853: -com 34785127
        !          5854: -com -204461692
        !          5855: -com -1021142281
        !          5856: -com 261505948
        !          5857: -com 713447396
        !          5858: -com -264424205
        !          5859: -com -757624021
        !          5860: -com -697742264
        !          5861: -com -67902535
        !          5862: -com 813305897
        !          5863: -com 611213298
        !          5864: -com 810009586
        !          5865: -com -351033158
        !          5866: -com -757580248
        !          5867: -com -754765998
        !          5868: -com 96550293
        !          5869: -com 818835421
        !          5870: -com 625544984
        !          5871: -com -301866740
        !          5872: -com -363940120
        !          5873: -com 196940655
        !          5874: -com -990799410
        !          5875: -com -650380493
        !          5876: -com -823008037
        !          5877: -com 229313079
        !          5878: -com 480371766
        !          5879: -com 934025272
        !          5880: -com -223072319
        !          5881: -com 481173087
        !          5882: -com 101019846
        !          5883: -com -954562179
        !          5884: -com -267806909
        !          5885: -com 1004678320
        !          5886: -com 267997081
        !          5887: -com -691653747
        !          5888: -com 821221633
        !          5889: -com 11472834
        !          5890: -com -852175935
        !          5891: -com 145665121
        !          5892: -com 636788309
        !          5893: -com -38553220
        !          5894: -com -594562227
        !          5895: -com 893269786
        !          5896: -com -515632420
        !          5897: -com -504118519
        !          5898: -com -795555924
        !          5899: -com -896489800
        !          5900: -com 381679431
        !          5901: -com 451163332
        !          5902: -com 945690716
        !          5903: -com -474968721
        !          5904: -com -181646048
        !          5905: -com -477705084
        !          5906: -com 179336691
        !          5907: -com 944752723
        !          5908: -com -106013482
        !          5909: -com 295161509
        !          5910: -com -1026918852
        !          5911: -com -1008494120
        !          5912: -com -368542058
        !          5913: -com 6153383
        !          5914: -com 269567191
        !          5915: -com 221084616
        !          5916: -com -1015567145
        !          5917: -com 326752359
        !          5918: -com -253427460
        !          5919: -com -990923267
        !          5920: -com -745673545
        !          5921: -com -772482393
        !          5922: -com 12783572
        !          5923: -com 695087221
        !          5924: -com 782623860
        !          5925: -com 239322275
        !          5926: -com -920492686
        !          5927: -com -461345191
        !          5928: -com 304590436
        !          5929: -com -141131273
        !          5930: -com -1024267294
        !          5931: -com -289620401
        !          5932: -com -495626460
        !          5933: -com 948528218
        !          5934: -com 87006518
        !          5935: -com 395454722
        !          5936: -com 577392034
        !          5937: -com 814343604
        !          5938: -com 497169207
        !          5939: -com -567127307
        !          5940: -com 764271483
        !          5941: -com -866721319
        !          5942: -com -387005272
        !          5943: -com -501938820
        !          5944: -com 567881079
        !          5945: -com 453665993
        !          5946: -com -790328887
        !          5947: -com 390097892
        !          5948: -com 141055035
        !          5949: -com 990378016
        !          5950: -com -730626518
        !          5951: -com 732985962
        !          5952: -com -286073373
        !          5953: -com 22747858
        !          5954: -com -326949321
        !          5955: -com 1022500944
        !          5956: -com 905679100
        !          5957: -com -448120658
        !          5958: -com 363118089
        !          5959: -com 819248817
        !          5960: -com -691522154
        !          5961: -com 59581781
        !          5962: -com -450349154
        !          5963: -com -729823626
        !          5964: -com 646115018
        !          5965: -com -65922779
        !          5966: -com -373376656
        !          5967: -com 1004572328
        !          5968: -com 466654801
        !          5969: -com 128208377
        !          5970: -com 958497476
        !          5971: -com 22952708
        !          5972: -com -822443770
        !          5973: -com 689913706
        !          5974: -com 726815914
        !          5975: -com -128674860
        !          5976: -com 779809535
        !          5977: -com -316931412
        !          5978: -com -1025891272
        !          5979: -com 4804418
        !          5980: -com 309313283
        !          5981: -com 536922264
        !          5982: -com -876904372
        !          5983: -com 700688221
        !          5984: -com 186984467
        !          5985: -com 791829735
        !          5986: -com 237211732
        !          5987: -com 515173384
        !          5988: -com -911728294
        !          5989: -com -783718602
        !          5990: -com 160345621
        !          5991: -com -716237348
        !          5992: -com -185346360
        !          5993: -com -634816499
        !          5994: -com -845917397
        !          5995: -com 460946577
        !          5996: -com 777785415
        !          5997: -com -579223277
        !          5998: -com -127944050
        !          5999: -com -351414763
        !          6000: -com -1006508563
        !          6001: -com 934284417
        !          6002: -com -414601720
        !          6003: -com -328845777
        !          6004: -com 701421432
        !          6005: -com -680992028
        !          6006: -com 444048798
        !          6007: -com -277796693
        !          6008: -com -1014985030
        !          6009: -com 213438258
        !          6010: -com -863232710
        !          6011: -com -236044310
        !          6012: -com -593324426
        !          6013: -com -269273068
        !          6014: -com -163992668
        !          6015: -com -1026411186
        !          6016: -com 537134594
        !          6017: -com 321391768
        !          6018: -com -872419201
        !          6019: -com -795875760
        !          6020: -com 373186979
        !          6021: -com 616631783
        !          6022: -com -567696334
        !          6023: -com 554407297
        !          6024: -com 723377442
        !          6025: -com 1062001538
        !          6026: -com 152160308
        !          6027: -com 43834651
        !          6028: -com 902450760
        !          6029: -com -390697289
        !          6030: -com 431114551
        !          6031: -com -851289267
        !          6032: -com 454377388
        !          6033: -com 470923853
        !          6034: -com -950885734
        !          6035: -com -313255930
        !          6036: -com -388083168
        !          6037: -com -267037738
        !          6038: -com -601696282
        !          6039: -com -848277038
        !          6040: -com 745209391
        !          6041: -com -423687675
        !          6042: -com 646585818
        !          6043: -com -613632730
        !          6044: -com 151442994
        !          6045: -com 868010020
        !          6046: -com -589969477
        !          6047: -com 756495308
        !          6048: -com 482257575
        !          6049: -com -546245706
        !          6050: -com -56416295
        !          6051: -com -922688644
        !          6052: -com -927591869
        !          6053: -com -193091648
        !          6054: -com 505183574
        !          6055: -com -696294953
        !          6056: -com -676843648
        !          6057: -com -458233039
        !          6058: -com 1016060900
        !          6059: -com 235279194
        !          6060: -com 255314418
        !          6061: -com 821562352
        !          6062: -com 677435672
        !          6063: -com -137977226
        !          6064: -com -296008805
        !          6065: -com -284837634
        !          6066: -com 992052324
        !          6067: -com 848130900
        !          6068: -com -612135722
        !          6069: -com -242663012
        !          6070: -com 40910582
        !          6071: -com -633235255
        !          6072: //GO.SYSIN DD regress.d/t5.i
        !          6073: echo regress.d/t5.out 1>&2
        !          6074: sed 's/.//' >regress.d/t5.out <<'//GO.SYSIN DD regress.d/t5.out'
        !          6075: -com 1037117850
        !          6076: -com -113451303
        !          6077: -com -253844186
        !          6078: -com -591640727
        !          6079: -com -192085666
        !          6080: -com 875206176
        !          6081: -com -688908411
        !          6082: -com 116220732
        !          6083: -com -815364609
        !          6084: -com 393021566
        !          6085: -com -197586762
        !          6086: -com -979497332
        !          6087: -com 580876342
        !          6088: -com 857752251
        !          6089: -com -282427433
        !          6090: -com 440265772
        !          6091: -com 903702654
        !          6092: -com 377371259
        !          6093: -com -790446649
        !          6094: -com -407893353
        !          6095: -com 601447097
        !          6096: -com 311585929
        !          6097: -com -990601410
        !          6098: -com 273028495
        !          6099: -com -421520583
        !          6100: -com -620551282
        !          6101: -com -768217422
        !          6102: -com 722547274
        !          6103: -com 313902943
        !          6104: -com -729597068
        !          6105: -com 306062132
        !          6106: -com 773754585
        !          6107: -com -678639313
        !          6108: -com -345701409
        !          6109: -com -290065002
        !          6110: -com -974307104
        !          6111: -com 1047184566
        !          6112: -com 210828681
        !          6113: -com 108982822
        !          6114: -com 68031245
        !          6115: -com -1047141482
        !          6116: -com 227569703
        !          6117: -com -530798398
        !          6118: -com -822779044
        !          6119: -com 440691738
        !          6120: -com 624275796
        !          6121: -com 843073732
        !          6122: -com 228971433
        !          6123: -com 258376249
        !          6124: -com -308161170
        !          6125: -com -995590232
        !          6126: -com 856677272
        !          6127: -com 132296249
        !          6128: -com 633658628
        !          6129: -com 25935234
        !          6130: -com -1063085400
        !          6131: -com 148654970
        !          6132: -com -824172925
        !          6133: -com -659459669
        !          6134: -com 196909720
        !          6135: -com -393774825
        !          6136: -com 736667556
        !          6137: -com 674673107
        !          6138: -com 1007653812
        !          6139: -com -261383312
        !          6140: -com 263123663
        !          6141: -com -946595190
        !          6142: -com -396442
        !          6143: -com -506832213
        !          6144: -com 149702652
        !          6145: -com -937852087
        !          6146: -com -500943193
        !          6147: -com -288026147
        !          6148: -com -653808189
        !          6149: -com 801559288
        !          6150: -com -653395420
        !          6151: -com -405217270
        !          6152: -com -749529781
        !          6153: -com 965720542
        !          6154: -com 396739912
        !          6155: -com 250804267
        !          6156: -com 1058925867
        !          6157: -com 121948720
        !          6158: -com 129329115
        !          6159: -com -503214654
        !          6160: -com 758365427
        !          6161: -com -569717820
        !          6162: -com 191932303
        !          6163: -com 1041195498
        !          6164: -com -178872661
        !          6165: -com 719024931
        !          6166: -com 389365053
        !          6167: -com -695930677
        !          6168: -com -720993320
        !          6169: -com 659352079
        !          6170: -com -445359373
        !          6171: -com -405581235
        !          6172: -com -495515453
        !          6173: -com -861910553
        !          6174: -com -35979929
        !          6175: -com 1056535300
        !          6176: -com 188042833
        !          6177: -com -220408267
        !          6178: -com -766533595
        !          6179: -com 718865736
        !          6180: -com -614647852
        !          6181: -com 637296265
        !          6182: -com 607439702
        !          6183: -com -996163547
        !          6184: -com -354301843
        !          6185: -com 187216170
        !          6186: -com -524246340
        !          6187: -com 165453004
        !          6188: -com -922340816
        !          6189: -com -392313676
        !          6190: -com 933400965
        !          6191: -com -357455062
        !          6192: -com 876069330
        !          6193: -com 619850004
        !          6194: -com 34785127
        !          6195: -com -204461692
        !          6196: -com -1021142281
        !          6197: -com 261505948
        !          6198: -com 713447396
        !          6199: -com -264424205
        !          6200: -com -757624021
        !          6201: -com -697742264
        !          6202: -com -67902535
        !          6203: -com 813305897
        !          6204: -com 611213298
        !          6205: -com 810009586
        !          6206: -com -351033158
        !          6207: -com -757580248
        !          6208: -com -754765998
        !          6209: -com 96550293
        !          6210: -com 818835421
        !          6211: -com 625544984
        !          6212: -com -301866740
        !          6213: -com -363940120
        !          6214: -com 196940655
        !          6215: -com -990799410
        !          6216: -com -650380493
        !          6217: -com -823008037
        !          6218: -com 229313079
        !          6219: -com 480371766
        !          6220: -com 934025272
        !          6221: -com -223072319
        !          6222: -com 481173087
        !          6223: -com 101019846
        !          6224: -com -954562179
        !          6225: -com -267806909
        !          6226: -com 1004678320
        !          6227: -com 267997081
        !          6228: -com -691653747
        !          6229: -com 821221633
        !          6230: -com 11472834
        !          6231: -com -852175935
        !          6232: -com 145665121
        !          6233: -com 636788309
        !          6234: -com -38553220
        !          6235: -com -594562227
        !          6236: -com 893269786
        !          6237: -com -515632420
        !          6238: -com -504118519
        !          6239: -com -795555924
        !          6240: -com -896489800
        !          6241: -com 381679431
        !          6242: -com 451163332
        !          6243: -com 945690716
        !          6244: -com -474968721
        !          6245: -com -181646048
        !          6246: -com -477705084
        !          6247: -com 179336691
        !          6248: -com 944752723
        !          6249: -com -106013482
        !          6250: -com 295161509
        !          6251: -com -1026918852
        !          6252: -com -1008494120
        !          6253: -com -368542058
        !          6254: -com 6153383
        !          6255: -com 269567191
        !          6256: -com 221084616
        !          6257: -com -1015567145
        !          6258: -com 326752359
        !          6259: -com -253427460
        !          6260: -com -990923267
        !          6261: -com -745673545
        !          6262: -com -772482393
        !          6263: -com 12783572
        !          6264: -com 695087221
        !          6265: -com 782623860
        !          6266: -com 239322275
        !          6267: -com -920492686
        !          6268: -com -461345191
        !          6269: -com 304590436
        !          6270: -com -141131273
        !          6271: -com -1024267294
        !          6272: -com -289620401
        !          6273: -com -495626460
        !          6274: -com 948528218
        !          6275: -com 87006518
        !          6276: -com 395454722
        !          6277: -com 577392034
        !          6278: -com 814343604
        !          6279: -com 497169207
        !          6280: -com -567127307
        !          6281: -com 764271483
        !          6282: -com -866721319
        !          6283: -com -387005272
        !          6284: -com -501938820
        !          6285: -com 567881079
        !          6286: -com 453665993
        !          6287: -com -790328887
        !          6288: -com 390097892
        !          6289: -com 141055035
        !          6290: -com 990378016
        !          6291: -com -730626518
        !          6292: -com 732985962
        !          6293: -com -286073373
        !          6294: -com 22747858
        !          6295: -com -326949321
        !          6296: -com 1022500944
        !          6297: -com 905679100
        !          6298: -com -448120658
        !          6299: -com 363118089
        !          6300: -com 819248817
        !          6301: -com -691522154
        !          6302: -com 59581781
        !          6303: -com -450349154
        !          6304: -com -729823626
        !          6305: -com 646115018
        !          6306: -com -65922779
        !          6307: -com -373376656
        !          6308: -com 1004572328
        !          6309: -com 466654801
        !          6310: -com 128208377
        !          6311: -com 958497476
        !          6312: -com 22952708
        !          6313: -com -822443770
        !          6314: -com 689913706
        !          6315: -com 726815914
        !          6316: -com -128674860
        !          6317: -com 779809535
        !          6318: -com -316931412
        !          6319: -com -1025891272
        !          6320: -com 4804418
        !          6321: -com 309313283
        !          6322: -com 536922264
        !          6323: -com -876904372
        !          6324: -com 700688221
        !          6325: -com 186984467
        !          6326: -com 791829735
        !          6327: -com 237211732
        !          6328: -com 515173384
        !          6329: -com -911728294
        !          6330: -com -783718602
        !          6331: -com 160345621
        !          6332: -com -716237348
        !          6333: -com -185346360
        !          6334: -com -634816499
        !          6335: -com -845917397
        !          6336: -com 460946577
        !          6337: -com 777785415
        !          6338: -com -579223277
        !          6339: -com -127944050
        !          6340: -com -351414763
        !          6341: -com -1006508563
        !          6342: -com 934284417
        !          6343: -com -414601720
        !          6344: -com -328845777
        !          6345: -com 701421432
        !          6346: -com -680992028
        !          6347: -com 444048798
        !          6348: -com -277796693
        !          6349: -com -1014985030
        !          6350: -com 213438258
        !          6351: -com -863232710
        !          6352: -com -236044310
        !          6353: -com -593324426
        !          6354: -com -269273068
        !          6355: -com -163992668
        !          6356: -com -1026411186
        !          6357: -com 537134594
        !          6358: -com 321391768
        !          6359: -com -872419201
        !          6360: -com -795875760
        !          6361: -com 373186979
        !          6362: -com 616631783
        !          6363: -com -567696334
        !          6364: -com 554407297
        !          6365: -com 723377442
        !          6366: -com 1062001538
        !          6367: -com 152160308
        !          6368: -com 43834651
        !          6369: -com 902450760
        !          6370: -com -390697289
        !          6371: -com 431114551
        !          6372: -com -851289267
        !          6373: -com 454377388
        !          6374: -com 470923853
        !          6375: -com -950885734
        !          6376: -com -313255930
        !          6377: -com -388083168
        !          6378: -com -267037738
        !          6379: -com -601696282
        !          6380: -com -848277038
        !          6381: -com 745209391
        !          6382: -com -423687675
        !          6383: -com 646585818
        !          6384: -com -613632730
        !          6385: -com 151442994
        !          6386: -com 868010020
        !          6387: -com -589969477
        !          6388: -com 756495308
        !          6389: -com 482257575
        !          6390: -com -546245706
        !          6391: -com -56416295
        !          6392: -com -922688644
        !          6393: -com -927591869
        !          6394: -com -193091648
        !          6395: -com 505183574
        !          6396: -com -696294953
        !          6397: -com -676843648
        !          6398: -com -458233039
        !          6399: -com 1016060900
        !          6400: -com 235279194
        !          6401: -com 255314418
        !          6402: -com 821562352
        !          6403: -com 677435672
        !          6404: -com -137977226
        !          6405: -com -296008805
        !          6406: -com -284837634
        !          6407: -com 992052324
        !          6408: -com 848130900
        !          6409: -com -612135722
        !          6410: -com -242663012
        !          6411: -com 40910582
        !          6412: -com -633235255
        !          6413: //GO.SYSIN DD regress.d/t5.out
        !          6414: echo regress.d/t5.sh 1>&2
        !          6415: sed 's/.//' >regress.d/t5.sh <<'//GO.SYSIN DD regress.d/t5.sh'
        !          6416: -$GRE '^com ' t5.i
        !          6417: //GO.SYSIN DD regress.d/t5.sh
        !          6418: echo regress.d/t6.i 1>&2
        !          6419: sed 's/.//' >regress.d/t6.i <<'//GO.SYSIN DD regress.d/t6.i'
        !          6420: -#include "alloc.h"
        !          6421: -#include <libc.h>
        !          6422: -
        !          6423: -char *
        !          6424: -emalloc(unsigned long n)
        !          6425: -{
        !          6426: -      char *p;
        !          6427: -      p=malloc((unsigned)n);
        !          6428: -      if(p==0){
        !          6429: -              warn("out of memory; exiting");
        !          6430: -              exits("out of memory");
        !          6431: -      }
        !          6432: -      return p;
        !          6433: -}
        !          6434: -char *
        !          6435: -erealloc(char *p, unsigned long n)
        !          6436: -{
        !          6437: -      p=realloc(p, (unsigned)n);
        !          6438: -      if(p==0){
        !          6439: -              warn("out of memory; exiting");
        !          6440: -              exits("out of memory");
        !          6441: -      }
        !          6442: -      return p;
        !          6443: -}
        !          6444: -#include "alloc.h"
        !          6445: -#include "word.h"
        !          6446: -#include "store.h"
        !          6447: -#include "comm.h"
        !          6448: -#include <libc.h>
        !          6449: -
        !          6450: -/*
        !          6451: - * Push constants
        !          6452: - */
        !          6453: -
        !          6454: -ipushconst(Proc *proc)
        !          6455: -{
        !          6456: -      *proc->sp++=(SWord)*++proc->pc;
        !          6457: -      return 1;
        !          6458: -}
        !          6459: -
        !          6460: -ipush_2(Proc *proc)
        !          6461: -{
        !          6462: -      *proc->sp++=-2;
        !          6463: -      return 1;
        !          6464: -}
        !          6465: -
        !          6466: -ipush_1(Proc *proc)
        !          6467: -{
        !          6468: -      *proc->sp++=-1;
        !          6469: -      return 1;
        !          6470: -}
        !          6471: -
        !          6472: -ipush0(Proc *proc)
        !          6473: -{
        !          6474: -      *proc->sp++=0;
        !          6475: -      return 1;
        !          6476: -}
        !          6477: -
        !          6478: -ipush1(Proc *proc)
        !          6479: -{
        !          6480: -      *proc->sp++=1;
        !          6481: -      return 1;
        !          6482: -}
        !          6483: -
        !          6484: -ipush2(Proc *proc)
        !          6485: -{
        !          6486: -      *proc->sp++=2;
        !          6487: -      return 1;
        !          6488: -}
        !          6489: -
        !          6490: -ipush3(Proc *proc)
        !          6491: -{
        !          6492: -      *proc->sp++=3;
        !          6493: -      return 1;
        !          6494: -}
        !          6495: -
        !          6496: -ipush4(Proc *proc)
        !          6497: -{
        !          6498: -      *proc->sp++=4;
        !          6499: -      return 1;
        !          6500: -}
        !          6501: -
        !          6502: -ipush5(Proc *proc)
        !          6503: -{
        !          6504: -      *proc->sp++=5;
        !          6505: -      return 1;
        !          6506: -}
        !          6507: -
        !          6508: -ipush6(Proc *proc)
        !          6509: -{
        !          6510: -      *proc->sp++=6;
        !          6511: -      return 1;
        !          6512: -}
        !          6513: -
        !          6514: -ipush7(Proc *proc)
        !          6515: -{
        !          6516: -      *proc->sp++=7;
        !          6517: -      return 1;
        !          6518: -}
        !          6519: -
        !          6520: -ipush8(Proc *proc)
        !          6521: -{
        !          6522: -      *proc->sp++=8;
        !          6523: -      return 1;
        !          6524: -}
        !          6525: -
        !          6526: -ipush9(Proc *proc)
        !          6527: -{
        !          6528: -      *proc->sp++=9;
        !          6529: -      return 1;
        !          6530: -}
        !          6531: -
        !          6532: -ipush10(Proc *proc)
        !          6533: -{
        !          6534: -      *proc->sp++=10;
        !          6535: -      return 1;
        !          6536: -}
        !          6537: -
        !          6538: -/*
        !          6539: - * Binary operators
        !          6540: - */
        !          6541: -ige(Proc *proc)
        !          6542: -{
        !          6543: -      --proc->sp;
        !          6544: -      proc->sp[-1]=proc->sp[-1]>=proc->sp[0];
        !          6545: -      return 1;
        !          6546: -}
        !          6547: -
        !          6548: -ile(Proc *proc)
        !          6549: -{
        !          6550: -      --proc->sp;
        !          6551: -      proc->sp[-1]=proc->sp[-1]<=proc->sp[0];
        !          6552: -      return 1;
        !          6553: -}
        !          6554: -
        !          6555: -ine(Proc *proc)
        !          6556: -{
        !          6557: -      --proc->sp;
        !          6558: -      proc->sp[-1]=proc->sp[-1]!=proc->sp[0];
        !          6559: -      return 1;
        !          6560: -}
        !          6561: -
        !          6562: -ieq(Proc *proc)
        !          6563: -{
        !          6564: -      --proc->sp;
        !          6565: -      proc->sp[-1]=proc->sp[-1]==proc->sp[0];
        !          6566: -      return 1;
        !          6567: -}
        !          6568: -
        !          6569: -igt(Proc *proc)
        !          6570: -{
        !          6571: -      --proc->sp;
        !          6572: -      proc->sp[-1]=proc->sp[-1]>proc->sp[0];
        !          6573: -      return 1;
        !          6574: -}
        !          6575: -
        !          6576: -ilt(Proc *proc)
        !          6577: -{
        !          6578: -      --proc->sp;
        !          6579: -      proc->sp[-1]=proc->sp[-1]<proc->sp[0];
        !          6580: -      return 1;
        !          6581: -}
        !          6582: -
        !          6583: -iadd(Proc *proc)
        !          6584: -{
        !          6585: -      --proc->sp;
        !          6586: -      proc->sp[-1]+=proc->sp[0];
        !          6587: -      return 1;
        !          6588: -}
        !          6589: -
        !          6590: -isub(Proc *proc)
        !          6591: -{
        !          6592: -      --proc->sp;
        !          6593: -      proc->sp[-1]-=proc->sp[0];
        !          6594: -      return 1;
        !          6595: -}
        !          6596: -
        !          6597: -imul(Proc *proc)
        !          6598: -{
        !          6599: -      long l0, l1, l;
        !          6600: -      --proc->sp;
        !          6601: -      l0=proc->sp[-1];
        !          6602: -      l1=proc->sp[0];
        !          6603: -      l=l0*l1;
        !          6604: -      if(l1 && l/l1 != l0)
        !          6605: -              rerror("product overflow");
        !          6606: -      proc->sp[-1]=l;
        !          6607: -      return 1;
        !          6608: -}
        !          6609: -
        !          6610: -idiv(Proc *proc)
        !          6611: -{
        !          6612: -      --proc->sp;
        !          6613: -      if(proc->sp[0]==0)
        !          6614: -              rerror("zero divide");
        !          6615: -      proc->sp[-1]/=proc->sp[0];
        !          6616: -      return 1;
        !          6617: -}
        !          6618: -
        !          6619: -imod(Proc *proc)
        !          6620: -{
        !          6621: -      --proc->sp;
        !          6622: -      if(proc->sp[0]==0)
        !          6623: -              rerror("zero modulo");
        !          6624: -      proc->sp[-1]%=proc->sp[0];
        !          6625: -      return 1;
        !          6626: -}
        !          6627: -
        !          6628: -iand(Proc *proc)
        !          6629: -{
        !          6630: -      --proc->sp;
        !          6631: -      proc->sp[-1]&=proc->sp[0];
        !          6632: -      return 1;
        !          6633: -}
        !          6634: -
        !          6635: -ior(Proc *proc)
        !          6636: -{
        !          6637: -      --proc->sp;
        !          6638: -      proc->sp[-1]|=proc->sp[0];
        !          6639: -      return 1;
        !          6640: -}
        !          6641: -
        !          6642: -ixor(Proc *proc)
        !          6643: -{
        !          6644: -      --proc->sp;
        !          6645: -      proc->sp[-1]^=proc->sp[0];
        !          6646: -      return 1;
        !          6647: -}
        !          6648: -
        !          6649: -ilsh(Proc *proc)
        !          6650: -{
        !          6651: -      --proc->sp;
        !          6652: -      proc->sp[-1]<<=proc->sp[0];
        !          6653: -      return 1;
        !          6654: -}
        !          6655: -
        !          6656: -irsh(Proc *proc)
        !          6657: -{
        !          6658: -      --proc->sp;
        !          6659: -      proc->sp[-1]>>=proc->sp[0];
        !          6660: -      return 1;
        !          6661: -}
        !          6662: -
        !          6663: -imax(Proc *proc)
        !          6664: -{
        !          6665: -      SWord l;
        !          6666: -      l=*--proc->sp;
        !          6667: -      if(l>proc->sp[-1])
        !          6668: -              proc->sp[-1]=l;
        !          6669: -      return 1;
        !          6670: -}
        !          6671: -
        !          6672: -/*
        !          6673: - * Unary operators
        !          6674: - */
        !          6675: -
        !          6676: -ineg(Proc *proc)
        !          6677: -{
        !          6678: -      proc->sp[-1]=-proc->sp[-1];
        !          6679: -      return 1;
        !          6680: -}
        !          6681: -
        !          6682: -inot(Proc *proc)
        !          6683: -{
        !          6684: -      proc->sp[-1]=~proc->sp[-1];
        !          6685: -      return 1;
        !          6686: -}
        !          6687: -
        !          6688: -ilnot(Proc *proc)
        !          6689: -{
        !          6690: -      proc->sp[-1]=!proc->sp[-1];
        !          6691: -      return 1;
        !          6692: -}
        !          6693: -
        !          6694: -iref(Proc *proc)
        !          6695: -{
        !          6696: -      Store *s=(Store *)*--proc->sp;
        !          6697: -      *proc->sp++=s->ref-1;
        !          6698: -      decref(&s);
        !          6699: -      return 1;
        !          6700: -}
        !          6701: -
        !          6702: -ilen(Proc *proc)
        !          6703: -{
        !          6704: -      Store *s=(Store *)*--proc->sp;
        !          6705: -      *proc->sp++=s->len;
        !          6706: -      decref(&s);
        !          6707: -      return 1;
        !          6708: -}
        !          6709: -
        !          6710: -/*
        !          6711: - * String comparison: put value of strcmp() on stack
        !          6712: - */
        !          6713: -
        !          6714: -istrcmp(Proc *proc)
        !          6715: -{
        !          6716: -      int cmp;
        !          6717: -      Store *s1, *s2;
        !          6718: -      s1=(Store *)proc->sp[-2];
        !          6719: -      s2=(Store *)proc->sp[-1];
        !          6720: -      cmp=strcmp((char *)s1->data, (char *)s2->data);
        !          6721: -      decref(&s1);
        !          6722: -      decref(&s2);
        !          6723: -      proc->sp--;
        !          6724: -      proc->sp[-1]=cmp;
        !          6725: -      return 1;
        !          6726: -}
        !          6727: -
        !          6728: -/*
        !          6729: - * Print
        !          6730: - */
        !          6731: -
        !          6732: -iprintint(Proc *proc)
        !          6733: -{
        !          6734: -      pprint(proc, "%ld", *--proc->sp);
        !          6735: -      return 1;
        !          6736: -}
        !          6737: -
        !          6738: -iprintnewline(Proc *proc)
        !          6739: -{
        !          6740: -      pprint(proc, "\n");
        !          6741: -      return 1;
        !          6742: -}
        !          6743: -
        !          6744: -iprintblank(Proc *proc)
        !          6745: -{
        !          6746: -      pprint(proc, " ");
        !          6747: -      return 1;
        !          6748: -}
        !          6749: -
        !          6750: -iprintunit(Proc *proc)
        !          6751: -{
        !          6752: -      pprint(proc, "(unit)");
        !          6753: -      return 1;
        !          6754: -}
        !          6755: -
        !          6756: -iprintchar(Proc *proc)
        !          6757: -{
        !          6758: -      pprint(proc, "%c", *--proc->sp);
        !          6759: -      return 1;
        !          6760: -}
        !          6761: -
        !          6762: -pprint(proc, fmt, a, b, c, d, e)
        !          6763: -      Proc *proc;
        !          6764: -      char *fmt;
        !          6765: -{
        !          6766: -      char buf[1024];
        !          6767: -      long n;
        !          6768: -      n=sprint(buf, fmt, a, b, c, d, e);
        !          6769: -      if(proc->prbuf==0){
        !          6770: -              proc->prbuf=emalloc(64+n);
        !          6771: -              proc->maxprbuf=64+n;
        !          6772: -              proc->nprbuf=0;
        !          6773: -      }
        !          6774: -      if(n+proc->nprbuf+1>proc->maxprbuf){
        !          6775: -              proc->prbuf=erealloc(proc->prbuf, proc->maxprbuf+64+n);
        !          6776: -              proc->maxprbuf+=64+n;
        !          6777: -      }
        !          6778: -      strcpy(proc->prbuf+proc->nprbuf, buf);
        !          6779: -      proc->nprbuf+=n;
        !          6780: -}
        !          6781: -/*
        !          6782: - * Stack management
        !          6783: - */
        !          6784: -
        !          6785: -ipop(Proc *proc)
        !          6786: -{
        !          6787: -      --proc->sp;
        !          6788: -      return 1;
        !          6789: -}
        !          6790: -
        !          6791: -ipopptr(Proc *proc)
        !          6792: -{
        !          6793: -      decref((Store **)(proc->sp-1));
        !          6794: -      --proc->sp;
        !          6795: -      return 1;
        !          6796: -}
        !          6797: -
        !          6798: -idup(Proc *proc)
        !          6799: -{
        !          6800: -      proc->sp++;
        !          6801: -      proc->sp[-1]=proc->sp[-2];
        !          6802: -      return 1;
        !          6803: -}
        !          6804: -
        !          6805: -idupptr(Proc *proc)
        !          6806: -{
        !          6807: -      proc->sp++;
        !          6808: -      proc->sp[-1]=proc->sp[-2];
        !          6809: -      ((Store *)(proc->sp[-1]))->ref++;
        !          6810: -      return 1;
        !          6811: -}
        !          6812: -#include "node.h"
        !          6813: -#include "symbol.h"
        !          6814: -#include "alloc.h"
        !          6815: -#include "word.h"
        !          6816: -#include "store.h"
        !          6817: -#include "comm.h"
        !          6818: -#include "inst.h"
        !          6819: -#include <libc.h>
        !          6820: -
        !          6821: -#define       FNS
        !          6822: -#include "lib.h"
        !          6823: -#undef        FNS
        !          6824: -
        !          6825: -#define       C       0x40000000
        !          6826: -#define       I       0x20000000
        !          6827: -#define       F       0x10000000
        !          6828: -#define       M(x)    ((x)&~(C|I|F))
        !          6829: -
        !          6830: -long call0[]={        /* plain function, 0 arguments */
        !          6831: -      I+Ipushfp,      C+0,    F,      I+Iret, C+0*WS, I+Idone,        0
        !          6832: -};
        !          6833: -long call1[]={        /* plain function, 1 argument */
        !          6834: -      I+Ipushfp,      C+0,    F,      I+Iret, C+1*WS, I+Idone,        0
        !          6835: -};
        !          6836: -long call2[]={        /* plain function, 2 arguments */
        !          6837: -      I+Ipushfp,      C+0,    F,      I+Iret, C+2*WS, I+Idone,        0
        !          6838: -};
        !          6839: -long call3[]={        /* plain function, 3 arguments */
        !          6840: -      I+Ipushfp,      C+0,    F,      I+Iret, C+3*WS, I+Idone,        0
        !          6841: -};
        !          6842: -long call4[]={        /* plain function, 4 arguments */
        !          6843: -      I+Ipushfp,      C+0,    F,      I+Iret, C+4*WS, I+Idone,        0
        !          6844: -};
        !          6845: -long call5[]={        /* plain function, 5 arguments */
        !          6846: -      I+Ipushfp,      C+0,    F,      I+Iret, C+5*WS, I+Idone,        0
        !          6847: -};
        !          6848: -long call2_0[]={/* two-step function, 0 arguments */
        !          6849: -      I+Ipushfp,      C+0,    F+0,    F+1,    I+Iret, C+0*WS, I+Idone,        0
        !          6850: -};
        !          6851: -
        !          6852: -struct{
        !          6853: -      char    *name;
        !          6854: -      int     (*fn[3])();
        !          6855: -      int     nargs;
        !          6856: -      long    *template;
        !          6857: -}bltin[]={
        !          6858: -#include "lib.h"
        !          6859: -      0,      {0,     0,      0},     0,      0,
        !          6860: -};
        !          6861: -
        !          6862: -bltinlookup(char *s)
        !          6863: -{
        !          6864: -      int i;
        !          6865: -      for(i=0; bltin[i].name; i++)
        !          6866: -              if(strcmp(s, bltin[i].name)==0)
        !          6867: -                      return i;
        !          6868: -      error("%s not a builtin", s);
        !          6869: -      return -1;
        !          6870: -}
        !          6871: -
        !          6872: -long
        !          6873: -bltinval(char *name, Node *t)
        !          6874: -{
        !          6875: -      int i, nargs, len;
        !          6876: -      long *template, *p;
        !          6877: -      Store *s;
        !          6878: -      SWord *d;
        !          6879: -      if(t->o.t!=TProg)
        !          6880: -              error("builtin %s not a function", name);
        !          6881: -      i=bltinlookup(name);
        !          6882: -      nargs=bltin[i].nargs;
        !          6883: -      if(nargs!=length(t->l)) /* necessary but not sufficient */
        !          6884: -              error("wrong #args to builtin %s: %d (should be %d)", name, length(t->l), nargs);
        !          6885: -      template=bltin[i].template;
        !          6886: -      p=template;
        !          6887: -      for(len=0; *p; p++)
        !          6888: -              len++;
        !          6889: -      s=(Store *)emalloc(SHSZ+len*LWS);
        !          6890: -      s->ref=1;
        !          6891: -      s->type=Sprog;
        !          6892: -      s->sbits=0;
        !          6893: -      s->len=len;
        !          6894: -      d=s->data;
        !          6895: -      for(p=template; *p; p++)
        !          6896: -              if(*p&C)
        !          6897: -                      *d++=(SWord)M(*p);
        !          6898: -              else if(*p&I)
        !          6899: -                      *d++=(SWord)insttab[M(*p)].fp;
        !          6900: -              else if(*p&F)
        !          6901: -                      *d++=(SWord)bltin[i].fn[M(*p)];
        !          6902: -      return (long)s;
        !          6903: -}
        !          6904: -
        !          6905: -Store *
        !          6906: -mk(type, len)
        !          6907: -{
        !          6908: -      Store *s;
        !          6909: -      if(type==Sstruct)
        !          6910: -              len++;
        !          6911: -      s=(Store *)emalloc(SHSZ+len*LWS);
        !          6912: -      s->ref=1;
        !          6913: -      s->type=type;
        !          6914: -      if(type==Sstruct){
        !          6915: -              s->sbits=1;
        !          6916: -              s->data[0]=0;
        !          6917: -      }else
        !          6918: -              s->sbits=0;
        !          6919: -      s->len=len;
        !          6920: -      return s;
        !          6921: -}
        !          6922: -#include "node.h"
        !          6923: -#include "symbol.h"
        !          6924: -#include "alloc.h"
        !          6925: -#include "ydefs.h"
        !          6926: -#include "word.h"
        !          6927: -#include "store.h"
        !          6928: -#include "comm.h"
        !          6929: -#include "inst.h"
        !          6930: -#include "errjmp.h"
        !          6931: -#include <libc.h>
        !          6932: -
        !          6933: -long          resultloc;
        !          6934: -long          returnloc;
        !          6935: -Node          *formals;
        !          6936: -long          autooffset;
        !          6937: -extern int    bflag;
        !          6938: -extern int    cflag;
        !          6939: -extern int    nscope;
        !          6940: -extern Node   arychartype;
        !          6941: -
        !          6942: -compile(n)    /* called from parser only */
        !          6943: -      Node *n;
        !          6944: -{
        !          6945: -      extern long autooffset;
        !          6946: -      Errjmp x;
        !          6947: -      n=constants(n);
        !          6948: -      if(cflag){
        !          6949: -              fileline();
        !          6950: -              fprint(2, "constants:\n");
        !          6951: -              dump(n, 0);
        !          6952: -      }
        !          6953: -      errsave(x);
        !          6954: -      if(errmark()){
        !          6955: -              autooffset=0;
        !          6956: -              freenode(n);
        !          6957: -              errrest(x);
        !          6958: -              errjmp();
        !          6959: -      }
        !          6960: -      istart();
        !          6961: -      gen(n, 0);
        !          6962: -      freenode(n);
        !          6963: -      errrest(x);
        !          6964: -}
        !          6965: -
        !          6966: -gen(Node *n, int retain)
        !          6967: -{
        !          6968: -      int i;
        !          6969: -      if(n==0)
        !          6970: -              return;
        !          6971: -      switch(n->t){
        !          6972: -      case NArrayref:
        !          6973: -              arygen(n->l, n->r, 0, 0L);
        !          6974: -              if(!retain)
        !          6975: -                      popgen(n->l->o.s->val->type->r);
        !          6976: -              return;
        !          6977: -      case NBecome:
        !          6978: -              if(n->l->t==NCall && !bflag){
        !          6979: -                      callgen(n->l, Ibecome);
        !          6980: -                      return;
        !          6981: -              }
        !          6982: -              gen(n->l, 1);
        !          6983: -              n=n->r;
        !          6984: -              if(n->o.t==TID)
        !          6985: -                      n=typeoftid(n);
        !          6986: -              switch(n->o.t){
        !          6987: -              case TInt:
        !          6988: -              case TChar:
        !          6989: -                      emit(Istoreauto);
        !          6990: -                      emitconst(-LWS*(3+length(formals)));
        !          6991: -                      break;
        !          6992: -              case TArray:
        !          6993: -              case TChan:
        !          6994: -              case TProg:
        !          6995: -              case TStruct:
        !          6996: -                      emit(Istoreptrauto);
        !          6997: -                      emitconst(-LWS*(3+length(formals)));
        !          6998: -                      break;
        !          6999: -              case TUnit:
        !          7000: -                      break;
        !          7001: -              default:
        !          7002: -                      panic("can't compile %t become", n->o.t);
        !          7003: -              }
        !          7004: -              scopedecrefgen();
        !          7005: -              trlrgen();
        !          7006: -              return;
        !          7007: -      case NBegin:
        !          7008: -              callgen(n->l, Ibegin);
        !          7009: -              return;
        !          7010: -      case NCall:
        !          7011: -              callgen(n, Icall);
        !          7012: -              if(!retain)
        !          7013: -                      popgen(etypeoft(n->l)->r);
        !          7014: -              return;
        !          7015: -      case NDecl:
        !          7016: -      case NDeclsc:
        !          7017: -              declare(n, 0, 0, 1);
        !          7018: -              return;
        !          7019: -      case NExpr:
        !          7020: -              switch(n->o.i){
        !          7021: -              case GE:
        !          7022: -                      i=Ige;
        !          7023: -              Binop:
        !          7024: -                      gen(n->l, 1);
        !          7025: -                      gen(n->r, 1);
        !          7026: -                      if(eqtype(etypeof(n->l), &arychartype)){
        !          7027: -                              emit(Istrcmp);
        !          7028: -                              constgen(0L);
        !          7029: -                      }
        !          7030: -                      emit(i);
        !          7031: -              Popit:
        !          7032: -                      if(!retain)
        !          7033: -                              emit(Ipop);
        !          7034: -                      return;
        !          7035: -              case LE:
        !          7036: -                      i=Ile;
        !          7037: -                      goto Binop;
        !          7038: -              case NE:
        !          7039: -                      i=Ine;
        !          7040: -                      goto Binop;
        !          7041: -              case EQ:
        !          7042: -                      i=Ieq;
        !          7043: -                      goto Binop;
        !          7044: -              case '>':
        !          7045: -                      i=Igt;
        !          7046: -                      goto Binop;
        !          7047: -              case '<':
        !          7048: -                      i=Ilt;
        !          7049: -                      goto Binop;
        !          7050: -              case '+':
        !          7051: -                      i=Iadd;
        !          7052: -                      goto Binop;
        !          7053: -              case '-':
        !          7054: -                      i=Isub;
        !          7055: -                      goto Binop;
        !          7056: -              case '*':
        !          7057: -                      i=Imul;
        !          7058: -                      goto Binop;
        !          7059: -              case '/':
        !          7060: -                      i=Idiv;
        !          7061: -                      goto Binop;
        !          7062: -              case '%':
        !          7063: -                      i=Imod;
        !          7064: -                      goto Binop;
        !          7065: -              case '&':
        !          7066: -                      i=Iand;
        !          7067: -                      goto Binop;
        !          7068: -              case '|':
        !          7069: -                      i=Ior;
        !          7070: -                      goto Binop;
        !          7071: -              case '^':
        !          7072: -                      i=Ixor;
        !          7073: -                      goto Binop;
        !          7074: -              case LSH:
        !          7075: -                      i=Ilsh;
        !          7076: -                      goto Binop;
        !          7077: -              case RSH:
        !          7078: -                      i=Irsh;
        !          7079: -                      goto Binop;
        !          7080: -              case ANDAND:
        !          7081: -                      condgen(n->l, n->r, Ijmptrue, Ijmpfalse, 0L, 1L, retain);
        !          7082: -                      return;
        !          7083: -              case OROR:
        !          7084: -                      condgen(n->l, n->r, Ijmpfalse, Ijmptrue, 1L, 0L, retain);
        !          7085: -                      return;
        !          7086: -              case PRINT:
        !          7087: -                      gen(n->l, 1);
        !          7088: -                      printgen(n->l);
        !          7089: -                      emit(Isprint);
        !          7090: -                      if(!retain)
        !          7091: -                              emit(Iprint);
        !          7092: -                      return;
        !          7093: -              case SND:
        !          7094: -                      gen(n->l, 1);
        !          7095: -                      constgen((long)Cissnd);
        !          7096: -                      emit(Icommset1);
        !          7097: -                      emit(Icommcln1);
        !          7098: -                      gen(n->r, 1);
        !          7099: -                      if(isptrtype(etypeoft(n->l)->r))
        !          7100: -                              emit(Isndptr);
        !          7101: -                      else
        !          7102: -                              emit(Isnd);
        !          7103: -                      if(!retain)
        !          7104: -                              popgen(etypeof(n));
        !          7105: -                      return;
        !          7106: -              case RCV:
        !          7107: -                      gen(n->l, 1);
        !          7108: -                      constgen(0L);   /* not Cissnd */
        !          7109: -                      emit(Icommset1);
        !          7110: -                      emit(Icommcln1);
        !          7111: -                      return;
        !          7112: -              case '=':
        !          7113: -                      gen(n->r, 1);
        !          7114: -                      if(retain)
        !          7115: -                              dupgen(etypeof(n->r), 1);
        !          7116: -                      lgen(n->l);
        !          7117: -                      return;
        !          7118: -              case LEN:
        !          7119: -                      gen(n->l, 1);
        !          7120: -                      emit(Ilen);
        !          7121: -                      goto Popit;
        !          7122: -              case REF:
        !          7123: -                      if(isptrtype(etypeof(n->l))){
        !          7124: -                              gen(n->l, 1);
        !          7125: -                              emit(Iref);
        !          7126: -                      }else
        !          7127: -                              constgen(1L);
        !          7128: -                      goto Popit;
        !          7129: -              case DEF:
        !          7130: -                      if(retain && n->l->t==NID && isinttype(etypeof(n->l))){
        !          7131: -                              constgen(1L);
        !          7132: -                              return;
        !          7133: -                      }
        !          7134: -                      /*
        !          7135: -                       * don't really need to call lgen1, which will uniquify our
        !          7136: -                       * array for us, but it does no harm, and it's easy.
        !          7137: -                       */
        !          7138: -                      lgen1(n->l, Idefauto, Idef, Idefary);
        !          7139: -                      goto Popit;
        !          7140: -              case UMINUS:
        !          7141: -                      gen(n->l, 1);
        !          7142: -                      emit(Ineg);
        !          7143: -                      goto Popit;
        !          7144: -              case '~':
        !          7145: -                      gen(n->l, 1);
        !          7146: -                      emit(Inot);
        !          7147: -                      goto Popit;
        !          7148: -              case '!':
        !          7149: -                      gen(n->l, 1);
        !          7150: -                      emit(Ilnot);
        !          7151: -                      goto Popit;
        !          7152: -              case INC:
        !          7153: -                      lgen1(n->l, Iincauto, Iinc, Iincary);
        !          7154: -                      goto Popit;
        !          7155: -              case DEC:
        !          7156: -                      lgen1(n->l, Idecauto, Idec, Idecary);
        !          7157: -                      goto Popit;
        !          7158: -              default:
        !          7159: -                      panic("can't compile %e expression", n->o.i);
        !          7160: -              }
        !          7161: -
        !          7162: -      case NExprlist:
        !          7163: -              /*
        !          7164: -               * This is an arg or element list; first is pushed last
        !          7165: -               */
        !          7166: -              gen(n->r, 1);
        !          7167: -              gen(n->l, 1);
        !          7168: -              return;
        !          7169: -      case NID:
        !          7170: -              if(!retain)
        !          7171: -                      return;
        !          7172: -              switch(typeof(n)->o.t){
        !          7173: -              case TInt:
        !          7174: -              case TChar:
        !          7175: -                      if(n->o.s->val->isauto){
        !          7176: -                              emit(Ipushauto);
        !          7177: -                              emitconst(n->o.s->val->store.off);
        !          7178: -                      }else{
        !          7179: -                              emit(Ipush);
        !          7180: -                              emitconst((long)&n->o.s->val->store.l);
        !          7181: -                      }
        !          7182: -                      return;
        !          7183: -              case TProg:
        !          7184: -              case TArray:
        !          7185: -              case TChan:
        !          7186: -              case TStruct:
        !          7187: -                      if(n->o.s->val->isauto){
        !          7188: -                              emit(Ipushptrauto);
        !          7189: -                              emitconst(n->o.s->val->store.off);
        !          7190: -                      }else{
        !          7191: -                              emit(Ipushptr);
        !          7192: -                              emitconst((long)&n->o.s->val->store.l);
        !          7193: -                      }
        !          7194: -                      return;
        !          7195: -              case TUnit:
        !          7196: -                      if(retain)
        !          7197: -                              constgen(0L);
        !          7198: -                      return;
        !          7199: -              case TType:
        !          7200: -                      lerror(n, "attempt to evaluate type variable %m", n);
        !          7201: -              default:
        !          7202: -                      panic("can't compile type %t", n->o.s->val->type->o.t);
        !          7203: -              }
        !          7204: -      case NIf:
        !          7205: -              ifgen(n);
        !          7206: -              return;
        !          7207: -      case NList:
        !          7208: -              gen(n->l, 0);
        !          7209: -              gen(n->r, 0);
        !          7210: -              return;
        !          7211: -      case NLoop:
        !          7212: -              loopgen(n);
        !          7213: -              return;
        !          7214: -      case NMk:
        !          7215: -              mkgen(n->l, n->r);
        !          7216: -              return;
        !          7217: -      case NNum:
        !          7218: -              if(retain)
        !          7219: -                      constgen(n->o.l);
        !          7220: -              return;
        !          7221: -      case NProg:
        !          7222: -              if(retain)
        !          7223: -                      proggen(n->l, n->r);
        !          7224: -              return;
        !          7225: -      case NResult:
        !          7226: -              gen(n->l, 1);
        !          7227: -              emit(Ijmp);
        !          7228: -              emitconst((long)(resultloc-here()-1)*WS);
        !          7229: -              return;
        !          7230: -      case NScope:
        !          7231: -              pushscope();
        !          7232: -              if(nscope==1){
        !          7233: -                      int nauto;
        !          7234: -                      autooffset=0;
        !          7235: -                      emit(Ipushfp);
        !          7236: -                      nauto=here();
        !          7237: -                      emitconst(0L);
        !          7238: -                      gen(n->l, 0);
        !          7239: -                      patch((int)nauto, autooffset);
        !          7240: -              }else
        !          7241: -                      gen(n->l, 0);
        !          7242: -              scopedecrefgen();
        !          7243: -              popscope();
        !          7244: -              return;
        !          7245: -      case NSelect:
        !          7246: -              selgen(n->l);
        !          7247: -              return;
        !          7248: -      case NSmash:{
        !          7249: -              Value *vl, *vr;
        !          7250: -              vl=n->l->o.s->val;
        !          7251: -              vr=n->r->o.s->val;
        !          7252: -              if(vr->type->o.t==TType){
        !          7253: -                      freenode(vl->type);
        !          7254: -                      vl->type=dupnode(vr->type);
        !          7255: -                      return;
        !          7256: -              }
        !          7257: -              gen(n->r, 1);
        !          7258: -              /*
        !          7259: -               * Free old values; tricky: push as int, pop as ptr
        !          7260: -               */
        !          7261: -              if(isptrtype(vl->type)){
        !          7262: -                      if(vl->isauto){
        !          7263: -                              emit(Ipushauto);
        !          7264: -                              emitconst(vl->store.off);
        !          7265: -                      }else{
        !          7266: -                              emit(Ipush);
        !          7267: -                              emitconst((long)&vl->store.l);
        !          7268: -                      }
        !          7269: -                      emit(Ipopptr);
        !          7270: -              }
        !          7271: -              if(vl->isauto){
        !          7272: -                      emit(Istoreauto);
        !          7273: -                      emitconst(vl->store.l);
        !          7274: -                      return;
        !          7275: -              }
        !          7276: -              emit(Istore);
        !          7277: -              emitconst((long)&vl->store.l);
        !          7278: -              return;
        !          7279: -      }
        !          7280: -      case NString:
        !          7281: -              if(retain){
        !          7282: -                      Store *s;
        !          7283: -                      s=(Store *)emalloc(SHSZ+strlen(n->o.c)+1);
        !          7284: -                      strcpy((char *)(s->data), n->o.c);
        !          7285: -                      s->ref=1;
        !          7286: -                      s->len=strlen(n->o.c);
        !          7287: -                      s->type=Sarychar;
        !          7288: -                      emit(Ipushdata);
        !          7289: -                      emitconst((long)s);
        !          7290: -              }
        !          7291: -              return;
        !          7292: -      case NStructref:
        !          7293: -              arygen(n->l, n->r, 1, n->o.l);
        !          7294: -              return;
        !          7295: -      case NSwitch:
        !          7296: -              switchgen(n->l, n->r);
        !          7297: -              return;
        !          7298: -      case NUnit:
        !          7299: -              if(retain)
        !          7300: -                      constgen(0L);
        !          7301: -              return;
        !          7302: -      case NVal:
        !          7303: -              valgen(n->l);
        !          7304: -              if(!retain)
        !          7305: -                      popgen(n->o.n);
        !          7306: -              return;
        !          7307: -      }
        !          7308: -      panic("can't compile node %n", n->t);
        !          7309: -      return;
        !          7310: -}
        !          7311: -
        !          7312: -arygen(Node *a, Node *i, int isstr, long off)
        !          7313: -{
        !          7314: -      int ptr, ischar;
        !          7315: -      if(isstr){
        !          7316: -              ptr=isptrtype(i);
        !          7317: -              constgen(off);
        !          7318: -              ischar=0;
        !          7319: -      }else{
        !          7320: -              Node *t=etypeoft(a)->r;
        !          7321: -              ptr=isptrtype(t);
        !          7322: -              gen(i, 1);
        !          7323: -              ischar=t->o.t==TChar;
        !          7324: -      }
        !          7325: -      if(a->t!=NID){
        !          7326: -              gen(a, 1);
        !          7327: -              emit(ptr? Ipusharyptrexpr :
        !          7328: -                      (ischar? Ipusharycharexpr :Ipusharyexpr));
        !          7329: -      }else if(a->o.s->val->isauto){
        !          7330: -              emit(ptr? Ipusharyptrauto :
        !          7331: -                      (ischar? Ipusharycharauto :Ipusharyauto));
        !          7332: -              emitconst(a->o.s->val->store.off);
        !          7333: -      }else{
        !          7334: -              emit(ptr? Ipusharyptr :
        !          7335: -                      (ischar? Ipusharychar :Ipushary));
        !          7336: -              emitconst((long)&a->o.s->val->store.l);
        !          7337: -      }
        !          7338: -}
        !          7339: -
        !          7340: -lgen(Node *n)
        !          7341: -{
        !          7342: -      switch(n->t){
        !          7343: -      case NID:
        !          7344: -              switch(typeof(n)->o.t){
        !          7345: -              case TChar:
        !          7346: -                      if(n->o.s->val->isauto){
        !          7347: -                              emit(Istorecharauto);
        !          7348: -                              emitconst(n->o.s->val->store.off);
        !          7349: -                              return;
        !          7350: -                      }
        !          7351: -                      emit(Istorechar);
        !          7352: -                      emitconst((long)&n->o.s->val->store.l);
        !          7353: -                      return;
        !          7354: -              case TInt:
        !          7355: -              case TUnit:
        !          7356: -                      if(n->o.s->val->isauto){
        !          7357: -                              emit(Istoreauto);
        !          7358: -                              emitconst(n->o.s->val->store.off);
        !          7359: -                              return;
        !          7360: -                      }
        !          7361: -                      emit(Istore);
        !          7362: -                      emitconst((long)&n->o.s->val->store.l);
        !          7363: -                      return;
        !          7364: -              case TArray:
        !          7365: -              case TChan:
        !          7366: -              case TProg:
        !          7367: -              case TStruct:
        !          7368: -                      if(n->o.s->val->isauto){
        !          7369: -                              emit(Istoreptrauto);
        !          7370: -                              emitconst(n->o.s->val->store.off);
        !          7371: -                              return;
        !          7372: -                      }
        !          7373: -                      emit(Istoreptr);
        !          7374: -                      emitconst((long)&n->o.s->val->store.l);
        !          7375: -                      return;
        !          7376: -
        !          7377: -              default:
        !          7378: -                      panic("lgen: ID type %t", n->o.s->val->type->o.t);
        !          7379: -                      return;
        !          7380: -              }
        !          7381: -      case NArrayref:
        !          7382: -              gen(n->r, 1);
        !          7383: -              goto Genref;
        !          7384: -      case NStructref:
        !          7385: -              constgen(n->o.l);
        !          7386: -      Genref:
        !          7387: -              lgen1(n->l, Ipushuniqauto, Ipushuniq, Ipushuniqary);
        !          7388: -              emit(Istoreary);
        !          7389: -              return;
        !          7390: -      default:
        !          7391: -              panic("lgen: lvalue node %n", n->t);
        !          7392: -      }
        !          7393: -}
        !          7394: -
        !          7395: -/*
        !          7396: - * n is a compound object about to be assigned into
        !          7397: - */
        !          7398: -lgen1(Node *n, int Iauto, int Ivar, int Iary)
        !          7399: -{
        !          7400: -      switch(n->t){
        !          7401: -      case NID:
        !          7402: -              if(n->o.s->val->isauto){
        !          7403: -                      emit(Iauto);
        !          7404: -                      emitconst(n->o.s->val->store.off);
        !          7405: -                      return;
        !          7406: -              }
        !          7407: -              emit(Ivar);
        !          7408: -              emitconst((long)&n->o.s->val->store.l);
        !          7409: -              return;
        !          7410: -      case NArrayref:
        !          7411: -              gen(n->r, 1);
        !          7412: -              goto Genref;
        !          7413: -      case NStructref:
        !          7414: -              constgen(n->o.l);
        !          7415: -      Genref:
        !          7416: -              lgen1(n->l, Ipushuniqauto, Ipushuniq, Ipushuniqary);
        !          7417: -              emit(Iary);
        !          7418: -              return;
        !          7419: -      default:
        !          7420: -              panic("lgen1: lvalue node %n", n->t);
        !          7421: -      }
        !          7422: -}
        !          7423: -
        !          7424: -ifgen(Node *n)
        !          7425: -{
        !          7426: -      int loc1, loc2;
        !          7427: -      gen(n->o.n, 1);
        !          7428: -      emit(Ijmpfalse);
        !          7429: -      loc1=here();
        !          7430: -      emit(0);
        !          7431: -      gen(n->l, 0);
        !          7432: -      if(n->r==0){
        !          7433: -              patch(loc1, (long)(here()-loc1-1)*WS);
        !          7434: -              return;
        !          7435: -      }
        !          7436: -      emit(Ijmp);
        !          7437: -      loc2=here();
        !          7438: -      emit(0);
        !          7439: -      patch(loc1, (long)(here()-loc1-1)*WS);
        !          7440: -      gen(n->r, 0);
        !          7441: -      patch(loc2, (long)(here()-loc2-1)*WS);
        !          7442: -      return;
        !          7443: -}
        !          7444: -
        !          7445: -valgen(Node *n)
        !          7446: -{
        !          7447: -      int loc1, loc2;
        !          7448: -      int orl;
        !          7449: -      emit(Ijmp);
        !          7450: -      loc1=here();
        !          7451: -      emitconst(0L);
        !          7452: -      orl=resultloc;
        !          7453: -      resultloc=here();
        !          7454: -      emit(Ijmp);
        !          7455: -      loc2=here();
        !          7456: -      emitconst(0L);
        !          7457: -      patch(loc1, (long)(here()-loc1-1)*WS);
        !          7458: -      gen(n, 1);
        !          7459: -      emit(Ivalnoresult);
        !          7460: -      patch(loc2, (long)(here()-loc2-1)*WS);
        !          7461: -      resultloc=orl;
        !          7462: -}
        !          7463: -
        !          7464: -loopgen(Node *n)
        !          7465: -{
        !          7466: -      int loc0, loc1, loc2;
        !          7467: -      if(n->o.i){     /* enter loop at top, so jump to body */
        !          7468: -              emit(Ijmp);
        !          7469: -              loc0=here();
        !          7470: -              emit(0);
        !          7471: -      }
        !          7472: -      gen(n->r->l, 0);        /* left expr */
        !          7473: -      if(n->r->r){            /* jump to condition */
        !          7474: -              emit(Ijmp);
        !          7475: -              loc1=here();
        !          7476: -              emit(0);
        !          7477: -      }
        !          7478: -      if(n->o.i)
        !          7479: -              patch(loc0, (here()-loc0-1)*LWS);
        !          7480: -      loc2=here();
        !          7481: -      gen(n->l, 0);           /* body */
        !          7482: -      gen(n->r->o.n, 0);      /* right expr */
        !          7483: -      if(n->r->r){
        !          7484: -              patch(loc1, (here()-loc1-1)*LWS);
        !          7485: -              gen(n->r->r, 1);
        !          7486: -              emit(Ijmptrue);
        !          7487: -      }else
        !          7488: -              emit(Ijmp);
        !          7489: -      emitconst((loc2-here()-1)*LWS);
        !          7490: -}
        !          7491: -
        !          7492: -condgen(Node *l, Node *r, Inst i1, Inst i2, long t1, long t2, int retain)
        !          7493: -{
        !          7494: -      int loc1, loc2, loc3;
        !          7495: -      gen(l, 1);
        !          7496: -      emit(i1);
        !          7497: -      loc1=here();
        !          7498: -      emit(0);
        !          7499: -      loc2=here();
        !          7500: -      if(retain)
        !          7501: -              constgen(t1);
        !          7502: -      emit(Ijmp);
        !          7503: -      loc3=here();
        !          7504: -      emit(0);
        !          7505: -      patch(loc1, (long)(here()-loc1-1)*WS);
        !          7506: -      gen(r, 1);
        !          7507: -      emit(i2);
        !          7508: -      emitconst((long)(loc2-here()-1)*WS);
        !          7509: -      if(retain)
        !          7510: -              constgen(t2);
        !          7511: -      patch(loc3, (long)(here()-loc3-1)*WS);
        !          7512: -}
        !          7513: -
        !          7514: -callgen(Node *n, int callinst)
        !          7515: -{
        !          7516: -      Node *pt;
        !          7517: -      pt=etypeof(n->l);
        !          7518: -      /*
        !          7519: -       * Space for result
        !          7520: -       */
        !          7521: -      constgen(0L);
        !          7522: -      /*
        !          7523: -       * Args
        !          7524: -       */
        !          7525: -      gen(n->r, 1);
        !          7526: -      /*
        !          7527: -       * Call
        !          7528: -       */
        !          7529: -      emit(Ipushconst);
        !          7530: -      if(n->l->t==NID)
        !          7531: -              emitconst((long)n->l->o.s->name);
        !          7532: -      else{
        !          7533: -              char buf[128];
        !          7534: -              char *p;
        !          7535: -              sprint(buf, "prog(){call on line %d}", n->line);
        !          7536: -              p=emalloc((unsigned long)strlen(buf)+1);
        !          7537: -              strcpy(p, buf);
        !          7538: -              emitconst((long)p);
        !          7539: -      }
        !          7540: -      gen(n->l, 1);
        !          7541: -      switch(callinst){
        !          7542: -      case Icall:
        !          7543: -              emit(Icall);
        !          7544: -              return;
        !          7545: -      case Ibegin:
        !          7546: -              constgen(LWS*(1+1+length(pt->l)));      /* result+procname+args */
        !          7547: -              emit(Ibegin);
        !          7548: -              return;
        !          7549: -      case Ibecome:
        !          7550: -              constgen(LWS*(1+1+length(pt->l)));      /* result+procname+args */
        !          7551: -              scopedecrefgen();
        !          7552: -              fdecrefgen(formals, -3L*WS);
        !          7553: -              emit(Ibecome);
        !          7554: -              if(formals)
        !          7555: -                      emitconst(length(formals)*LWS);
        !          7556: -              else
        !          7557: -                      emitconst(0L);
        !          7558: -              return;
        !          7559: -      }
        !          7560: -      panic("callgen");
        !          7561: -}
        !          7562: -
        !          7563: -selgen(Node *n)
        !          7564: -{
        !          7565: -      int tbl, i;
        !          7566: -      long l;
        !          7567: -      int ends[200];
        !          7568: -      selchangen(n);
        !          7569: -      l=length(n);
        !          7570: -      constgen(l);
        !          7571: -      emit(Icommset);
        !          7572: -      emit(Icommcln);
        !          7573: -      if(l>(sizeof ends/sizeof ends[0]))
        !          7574: -              panic("selgen table too small");
        !          7575: -      tbl=here();
        !          7576: -      emitspace(l);
        !          7577: -      i=0;
        !          7578: -      seltblgen(n, tbl, ends, &i);
        !          7579: -      for(i=0; i<l; i++)
        !          7580: -              patch(ends[i], (long)(here()-ends[i]-1)*WS);
        !          7581: -}
        !          7582: -
        !          7583: -selchangen(Node *n)
        !          7584: -{
        !          7585: -      long flags;
        !          7586: -      if(n->t==NList){
        !          7587: -              selchangen(n->l);
        !          7588: -              selchangen(n->r);
        !          7589: -              return;
        !          7590: -      }
        !          7591: -      if(n->t!=NCase)
        !          7592: -              panic("selchangen");
        !          7593: -      n=n->l->l;
        !          7594: -      if(n->o.t=='=')
        !          7595: -              n=n->r;         /* n is now RCV or SND */
        !          7596: -      flags=0;
        !          7597: -      if(n->o.t==SND)
        !          7598: -              flags|=Cissnd;
        !          7599: -      n=n->l;                 /* n is now channel */
        !          7600: -      if(n->t==NArraycom){
        !          7601: -              flags|=Cisary;
        !          7602: -              n=n->l;
        !          7603: -      }else if(etypeoft(n)->o.t==TArray)
        !          7604: -              flags|=Cisary;
        !          7605: -      gen(n, 1);
        !          7606: -      constgen(flags);
        !          7607: -}
        !          7608: -
        !          7609: -seltblgen(Node *n, int tbl, int *ends, int *ip)
        !          7610: -{
        !          7611: -      Node *c, *s, *l, *t;
        !          7612: -      if(n->t==NList){
        !          7613: -              /* chans are eval'ed from the top, so table is backwards */
        !          7614: -              seltblgen(n->r, tbl, ends, ip);
        !          7615: -              seltblgen(n->l, tbl, ends, ip);
        !          7616: -              return;
        !          7617: -      }
        !          7618: -      if(n->t!=NCase)
        !          7619: -              panic("seltblgen");
        !          7620: -      if(n->l->t==NList)
        !          7621: -              error("sorry, empty cases not implemented");
        !          7622: -      patch(tbl+*ip, (long)(here()-tbl)*WS);
        !          7623: -      c=n->l->l;      /* communication */
        !          7624: -      s=n->r;         /* statement */
        !          7625: -      l=0;
        !          7626: -      if(c->o.t=='='){
        !          7627: -              l=c->l; /* lvalue */
        !          7628: -              c=c->r;
        !          7629: -      }
        !          7630: -      if(c->o.t==SND){
        !          7631: -              gen(c->r, 1);
        !          7632: -              if(isptrtype(etypeoft(c->l)->r))
        !          7633: -                      emit(Isndptr);
        !          7634: -              else
        !          7635: -                      emit(Isnd);
        !          7636: -      }
        !          7637: -      c=c->l; /* channel expression */
        !          7638: -      /*
        !          7639: -       * The value is still on the stack; save it or toss it
        !          7640: -       */
        !          7641: -      if(l)
        !          7642: -              lgen(l);
        !          7643: -      else if(c->t==NArraycom){
        !          7644: -              t=etypeoft(c->l)->r;
        !          7645: -              if(t->o.t==TID)
        !          7646: -                      t=typeoftid(t);
        !          7647: -              popgen(t->r);
        !          7648: -      }else
        !          7649: -              popgen(etypeoft(c)->r);
        !          7650: -      if(c->t==NArraycom){    /* save array index */
        !          7651: -              if(c->r)
        !          7652: -                      lgen(c->r);
        !          7653: -              else
        !          7654: -                      emit(Ipop);
        !          7655: -      }
        !          7656: -      gen(s, 0);
        !          7657: -      emit(Ijmp);
        !          7658: -      ends[*ip]=here();
        !          7659: -      (*ip)++;
        !          7660: -      emitconst(0L);
        !          7661: -}
        !          7662: -
        !          7663: -switchgen(Node *s, Node *e)
        !          7664: -{
        !          7665: -      int isptr, out;
        !          7666: -      isptr=isptrtype(etypeof(e));
        !          7667: -      gen(e, 1);
        !          7668: -      emit(Ijmp);
        !          7669: -      emitconst(2*LWS);
        !          7670: -      emit(Ijmp);     /* each case jumps to here to get out */
        !          7671: -      out=here();
        !          7672: -      emitconst(0L);
        !          7673: -      switchgen1(s, isptr, out-1);
        !          7674: -      /* pop leftover value if no case matched */
        !          7675: -      if(isptr)
        !          7676: -              emit(Ipopptr);
        !          7677: -      else
        !          7678: -              emit(Ipop);
        !          7679: -      patch(out, (here()-out-1)*LWS);
        !          7680: -}
        !          7681: -
        !          7682: -switchgen1(Node *s, int isptr, int out)
        !          7683: -{
        !          7684: -      Node *e;
        !          7685: -      int loc;
        !          7686: -      if(s->t==NList){
        !          7687: -              switchgen1(s->l, isptr, out);
        !          7688: -              switchgen1(s->r, isptr, out);
        !          7689: -              return;
        !          7690: -      }
        !          7691: -      if(s->t!=NCase)
        !          7692: -              panic("switchgen1");
        !          7693: -      if(s->r==0)
        !          7694: -              error("sorry; can't fold cases together yet");
        !          7695: -      if(s->l->t==NDefault)
        !          7696: -              loc=-1;
        !          7697: -      else{
        !          7698: -              e=s->l->l;
        !          7699: -              if(isptr){      /* string */
        !          7700: -                      emit(Idupptr);
        !          7701: -                      gen(e, 1);
        !          7702: -                      emit(Istrcmp);
        !          7703: -                      constgen(0L);
        !          7704: -              }else{
        !          7705: -                      emit(Idup);
        !          7706: -                      gen(e, 1);
        !          7707: -              }
        !          7708: -              emit(Ieq);
        !          7709: -              emit(Ijmpfalse);
        !          7710: -              loc=here();
        !          7711: -              emitconst(0L);
        !          7712: -      }
        !          7713: -      if(isptr)
        !          7714: -              emit(Ipopptr);
        !          7715: -      else
        !          7716: -              emit(Ipop);
        !          7717: -      gen(s->r, 0);
        !          7718: -      emit(Ijmp);
        !          7719: -      emitconst((out-here()-1)*LWS);
        !          7720: -      if(loc!=-1)
        !          7721: -              patch(loc, (here()-loc-1)*LWS);
        !          7722: -}
        !          7723: -
        !          7724: -popgen(Node *t)
        !          7725: -{
        !          7726: -      if(isptrtype(t))
        !          7727: -              emit(Ipopptr);
        !          7728: -      else if(isinttype(t) || t->o.t==TUnit)
        !          7729: -              emit(Ipop);
        !          7730: -      else
        !          7731: -              panic("popgen %t\n", t->o.t);
        !          7732: -}
        !          7733: -
        !          7734: -genfreeauto(Symbol *s)
        !          7735: -{
        !          7736: -      if(!s->val->isauto)
        !          7737: -              panic("genfreeauto");
        !          7738: -      if(isptrtype(s->val->type)){
        !          7739: -              emit(Idecrefauto);
        !          7740: -              emitconst(s->val->store.off);
        !          7741: -      }
        !          7742: -}
        !          7743: -
        !          7744: -printgen(Node *n)
        !          7745: -{
        !          7746: -      Node *t;
        !          7747: -      if(n==0)
        !          7748: -              return;
        !          7749: -      if(n->t==NExprlist){
        !          7750: -              printgen(n->l);
        !          7751: -              printgen(n->r);
        !          7752: -              return;
        !          7753: -      }
        !          7754: -      t=etypeoft(n);
        !          7755: -      switch(t->o.t){
        !          7756: -      case TArray:
        !          7757: -      case TChan:
        !          7758: -      case TProg:
        !          7759: -      case TStruct:
        !          7760: -              emit(Iprintary);
        !          7761: -              break;
        !          7762: -      case TChar:
        !          7763: -              emit(Iprintchar);
        !          7764: -              break;
        !          7765: -      case TInt:
        !          7766: -              emit(Iprintint);
        !          7767: -              break;
        !          7768: -      case TUnit:
        !          7769: -              emit(Iprintunit);
        !          7770: -              break;
        !          7771: -      default:
        !          7772: -              panic("printgen: bad type %t", t->o.t);
        !          7773: -      }
        !          7774: -}
        !          7775: -
        !          7776: -proggen(Node *t, Node *n)
        !          7777: -{
        !          7778: -      int or;
        !          7779: -      Node *of;
        !          7780: -      Errjmp s;
        !          7781: -      Store *p;
        !          7782: -      long len, loc;
        !          7783: -      long nauto, oao;
        !          7784: -      extern int (*prog[])();
        !          7785: -      oao=autooffset;
        !          7786: -      or=returnloc;
        !          7787: -      of=formals;
        !          7788: -      autooffset=0;
        !          7789: -      returnloc=0;
        !          7790: -      formals=t->l;
        !          7791: -      errsave(s);
        !          7792: -      if(errmark()){
        !          7793: -              returnloc=or;
        !          7794: -              formals=of;
        !          7795: -              autooffset=oao;
        !          7796: -              errrest(s);
        !          7797: -              errjmp();
        !          7798: -      }
        !          7799: -      loc=here();
        !          7800: -      pushscope();
        !          7801: -      dclformals(t->l);
        !          7802: -      autooffset=0;
        !          7803: -      emit(Ipushfp);
        !          7804: -      nauto=here();
        !          7805: -      emitconst(0L);
        !          7806: -      gen(n, 0);
        !          7807: -      trlrgen();
        !          7808: -      patch((int)nauto, autooffset);
        !          7809: -      popscope();
        !          7810: -      errrest(s);
        !          7811: -      autooffset=oao;
        !          7812: -      returnloc=or;
        !          7813: -      formals=of;
        !          7814: -      len=here()-loc+1;
        !          7815: -      p=(Store *)emalloc(SHSZ+len*LWS);
        !          7816: -      memcpy((char *)(p->data), (char *)(prog+loc), len*LWS);
        !          7817: -      p->ref=1;
        !          7818: -      p->len=len;
        !          7819: -      p->type=Sprog;
        !          7820: -      setprog(loc);
        !          7821: -      emit(Ipushdata);
        !          7822: -      emitconst((long)p);
        !          7823: -}
        !          7824: -
        !          7825: -trlrgen()
        !          7826: -{
        !          7827: -      if(returnloc){
        !          7828: -              emit(Ijmp);
        !          7829: -              emitconst((long)(returnloc-here()-1)*WS);
        !          7830: -              return;
        !          7831: -      }
        !          7832: -      returnloc=here();
        !          7833: -      fdecrefgen(formals, -3L*WS);
        !          7834: -      emit(Iret);
        !          7835: -      if(formals)
        !          7836: -              emitconst(length(formals)*LWS);
        !          7837: -      else
        !          7838: -              emitconst(0L);
        !          7839: -}
        !          7840: -
        !          7841: -fdecrefgen(Node *types, long offset)
        !          7842: -{
        !          7843: -      if(types==0)
        !          7844: -              return 0;
        !          7845: -      if(types->t==NList){
        !          7846: -              offset=fdecrefgen(types->l, offset);
        !          7847: -              return fdecrefgen(types->r, offset);
        !          7848: -      }
        !          7849: -      if(types->t!=NFormal)
        !          7850: -              panic("fdecrefgen");
        !          7851: -      types=types->r;
        !          7852: -      if(isptrtype(types)){
        !          7853: -              emit(Idecrefauto);
        !          7854: -              emitconst(offset);
        !          7855: -      }
        !          7856: -      return offset-WS;
        !          7857: -}
        !          7858: -
        !          7859: -dupgen(Node *t, int n)
        !          7860: -{
        !          7861: -      while(n--)
        !          7862: -              emit(isptrtype(t)? Idupptr : Idup);
        !          7863: -}
        !          7864: -
        !          7865: -mkgen(Node *t, Node *v)
        !          7866: -{
        !          7867: -      switch(t->o.t){
        !          7868: -      case TChar:
        !          7869: -      case TInt:
        !          7870: -      case TUnit:
        !          7871: -              if(v)
        !          7872: -                      gen(v, 1);
        !          7873: -              else
        !          7874: -                      constgen(0L);
        !          7875: -              return;
        !          7876: -      case TID:
        !          7877: -              mkgen(typeoftid(t), v);
        !          7878: -              return;
        !          7879: -      case TChan:
        !          7880: -              if(v)
        !          7881: -                      gen(v, 1);
        !          7882: -              else{
        !          7883: -                      constgen((long)(sizeof(Chan)-sizeof(Store)));
        !          7884: -                      mallocgen(t);
        !          7885: -              }
        !          7886: -              return;
        !          7887: -      case TArray:
        !          7888: -              if(v==0){
        !          7889: -                      gen(t->l, 1);
        !          7890: -                      mallocgen(t);
        !          7891: -                      return;
        !          7892: -              }
        !          7893: -              gen(v, 1);
        !          7894: -              if(v->t!=NExprlist && eqtype(t, etypeof(v)))
        !          7895: -                      return;
        !          7896: -              if(v->t==NString)
        !          7897: -                      constgen((long)strlen(v->o.c));
        !          7898: -              else
        !          7899: -                      constgen((long)length(v));
        !          7900: -              emit(Idup);
        !          7901: -              if(t->l)
        !          7902: -                      gen(t->l, 1);
        !          7903: -              else
        !          7904: -                      constgen(0L);
        !          7905: -              emit(Imax);
        !          7906: -              mallocgen(t);
        !          7907: -              if(t->r->o.t==TChar){
        !          7908: -                      if(v->t==NString)
        !          7909: -                              emit(Imemcpychar);
        !          7910: -                      else
        !          7911: -                              emit(Imemcpycharint);
        !          7912: -              }else
        !          7913: -                      emit(Imemcpy);
        !          7914: -              return;
        !          7915: -      case TProg:
        !          7916: -              if(v==0){
        !          7917: -                      v=new(NProg, dupnode(t), (Node *)0, (Node *)0);
        !          7918: -                      gen(v, 1);
        !          7919: -                      freenode(v);
        !          7920: -                      return;
        !          7921: -              }
        !          7922: -              gen(v, 1);
        !          7923: -              return;
        !          7924: -      case TStruct:
        !          7925: -              if(v==0){
        !          7926: -                      mallocgen(t);
        !          7927: -                      return;
        !          7928: -              }
        !          7929: -              gen(v, 1);
        !          7930: -              if(v->t!=NExprlist && eqtype(t, etypeof(v)))
        !          7931: -                      return;
        !          7932: -              constgen((long)length(v));
        !          7933: -              mallocgen(t);
        !          7934: -              emit(Imemcpystruct);
        !          7935: -              return;         
        !          7936: -      default:
        !          7937: -              panic("mkgen: bad type %t", t->o.t);
        !          7938: -      }
        !          7939: -}
        !          7940: -
        !          7941: -mallocgen(Node *t)
        !          7942: -{
        !          7943: -      switch(t->o.t){
        !          7944: -      case TArray:
        !          7945: -              t=t->r;
        !          7946: -              if(t->o.t==TID)
        !          7947: -                      t=typeoftid(t);
        !          7948: -              if(isptrtype(t)){
        !          7949: -                      constgen((long)Saryptr);
        !          7950: -                      emit(Imalloc);
        !          7951: -              }else if(t->o.t==TInt || t->o.t==TUnit){
        !          7952: -                      constgen((long)Saryint);
        !          7953: -                      emit(Imalloc);
        !          7954: -              }else if(t->o.t==TChar)
        !          7955: -                      emit(Imallocarychar);
        !          7956: -              else
        !          7957: -                      panic("mallocgen array of %t", t->o.t);
        !          7958: -              return;
        !          7959: -      case TStruct:{
        !          7960: -              int pos=0;
        !          7961: -              long bits=0;
        !          7962: -              t=t->l;
        !          7963: -              elembitsgen(t, &pos, &bits);
        !          7964: -              if(pos)
        !          7965: -                      constgen(bits);
        !          7966: -              constgen((long)length(t));
        !          7967: -              emit(Imallocstruct);
        !          7968: -              return;
        !          7969: -      }
        !          7970: -      case TChan:
        !          7971: -              constgen((long)Schan);
        !          7972: -              emit(Imalloc);
        !          7973: -              return;
        !          7974: -      }
        !          7975: -      panic("mallocgen of %t", t->o.t);
        !          7976: -}
        !          7977: -
        !          7978: -elembitsgen(Node *t, int *pos, long *bits)
        !          7979: -{
        !          7980: -      int i;
        !          7981: -      if(t->t==NList){
        !          7982: -              elembitsgen(t->l, pos, bits);
        !          7983: -              elembitsgen(t->r, pos, bits);
        !          7984: -              return;
        !          7985: -      }
        !          7986: -      if(t->t!=NElem)
        !          7987: -              panic("elembitsgen %n", t->t);
        !          7988: -      for(i=length(t); --i>=0; ){
        !          7989: -              if(*pos==BPW){
        !          7990: -                      constgen(*bits);
        !          7991: -                      *pos=0;
        !          7992: -                      *bits=0;
        !          7993: -              }
        !          7994: -              if(isptrtype(t->r))
        !          7995: -                      *bits|=1L<<*pos;
        !          7996: -              (*pos)++;
        !          7997: -      }
        !          7998: -}
        !          7999: -
        !          8000: -constgen(long l)
        !          8001: -{
        !          8002: -      if(l<-2 || l>10){
        !          8003: -              emit(Ipushconst);
        !          8004: -              emitconst(l);
        !          8005: -              return;
        !          8006: -      };
        !          8007: -      switch((int)l){
        !          8008: -      case -2:
        !          8009: -              emit(Ipush_2);
        !          8010: -              break;
        !          8011: -      case -1:
        !          8012: -              emit(Ipush_1);
        !          8013: -              break;
        !          8014: -      case 0:
        !          8015: -              emit(Ipush0);
        !          8016: -              break;
        !          8017: -      case 1:
        !          8018: -              emit(Ipush1);
        !          8019: -              break;
        !          8020: -      case 2:
        !          8021: -              emit(Ipush2);
        !          8022: -              break;
        !          8023: -      case 3:
        !          8024: -              emit(Ipush3);
        !          8025: -              break;
        !          8026: -      case 4:
        !          8027: -              emit(Ipush4);
        !          8028: -              break;
        !          8029: -      case 5:
        !          8030: -              emit(Ipush5);
        !          8031: -              break;
        !          8032: -      case 6:
        !          8033: -              emit(Ipush6);
        !          8034: -              break;
        !          8035: -      case 7:
        !          8036: -              emit(Ipush7);
        !          8037: -              break;
        !          8038: -      case 8:
        !          8039: -              emit(Ipush8);
        !          8040: -              break;
        !          8041: -      case 9:
        !          8042: -              emit(Ipush9);
        !          8043: -              break;
        !          8044: -      case 10:
        !          8045: -              emit(Ipush10);
        !          8046: -              break;
        !          8047: -      default:
        !          8048: -              panic("constgen");
        !          8049: -      }
        !          8050: -}
        !          8051: -
        !          8052: -printable(Node *n)
        !          8053: -{
        !          8054: -      if(n==0)
        !          8055: -              return 0;
        !          8056: -      switch(n->t){
        !          8057: -      case NExpr:
        !          8058: -              return n->o.t!='=';
        !          8059: -      case NArrayref:
        !          8060: -      case NCall:
        !          8061: -      case NID:
        !          8062: -      case NMk:
        !          8063: -      case NNum:
        !          8064: -      case NProg:
        !          8065: -      case NString:
        !          8066: -      case NStructref:
        !          8067: -      case NUnit:
        !          8068: -      case NVal:
        !          8069: -              return 1;
        !          8070: -      }
        !          8071: -      return 0;
        !          8072: -}
        !          8073: -#include "alloc.h"
        !          8074: -#include "node.h"
        !          8075: -#include "symbol.h"
        !          8076: -#include "ydefs.h"
        !          8077: -#include "word.h"
        !          8078: -#include "store.h"
        !          8079: -#include <libc.h>
        !          8080: -
        !          8081: -Node          *doconst();
        !          8082: -extern int    Cflag;
        !          8083: -
        !          8084: -Node *
        !          8085: -constants(Node *n)
        !          8086: -{
        !          8087: -      if(n==0)
        !          8088: -              return 0;
        !          8089: -      if(Cflag)
        !          8090: -              return n;
        !          8091: -      switch(n->t){
        !          8092: -      case NArrayref:
        !          8093: -              if(isconst(n))
        !          8094: -                      return doconst(n);
        !          8095: -              break;
        !          8096: -      case NArraycom:
        !          8097: -              break;
        !          8098: -      case NBecome:
        !          8099: -              break;
        !          8100: -      case NBegin:
        !          8101: -              break;
        !          8102: -      case NCall:
        !          8103: -              break;
        !          8104: -      case NCase:
        !          8105: -              break;
        !          8106: -      case NDecl:
        !          8107: -              n->r=constants(n->r);
        !          8108: -              n->o.n=constants(n->o.n);
        !          8109: -              declare(n, 0, 0, 0);
        !          8110: -              return n;
        !          8111: -      case NDeclsc:
        !          8112: -              break;
        !          8113: -      case NDefault:
        !          8114: -              return n;
        !          8115: -      case NElem:
        !          8116: -              n->r=constants(n->r);
        !          8117: -              return n;
        !          8118: -      case NExpr:
        !          8119: -              switch(n->o.i){
        !          8120: -              case GE:
        !          8121: -              case LE:
        !          8122: -              case NE:
        !          8123: -              case EQ:
        !          8124: -              case '>':
        !          8125: -              case '<':
        !          8126: -              case '+':
        !          8127: -              case '-':
        !          8128: -              case '*':
        !          8129: -              case '/':
        !          8130: -              case '%':
        !          8131: -              case '&':
        !          8132: -              case '|':
        !          8133: -              case '^':
        !          8134: -              case ANDAND:
        !          8135: -              case OROR:
        !          8136: -              case LSH:
        !          8137: -              case RSH:
        !          8138: -                      if(isconst(n->l) && isconst(n->r))
        !          8139: -                              return doconst(n);
        !          8140: -                      break;
        !          8141: -              case DEF:
        !          8142: -              case REF:
        !          8143: -              case LEN:
        !          8144: -              case UMINUS:
        !          8145: -              case '~':
        !          8146: -              case '!':
        !          8147: -                      if(isconst(n->l))
        !          8148: -                              return doconst(n);
        !          8149: -                      break;
        !          8150: -              case PRINT:
        !          8151: -              case RCV:
        !          8152: -              case SND:
        !          8153: -              case INC:
        !          8154: -              case DEC:
        !          8155: -                      break;
        !          8156: -              case '=':
        !          8157: -                      break;
        !          8158: -              default:
        !          8159: -                      fprint(2, "can't const expression %e\n", n->o.i);
        !          8160: -                      return n;
        !          8161: -              }
        !          8162: -              break;
        !          8163: -      case NExprlist:
        !          8164: -              break;
        !          8165: -      case NFormal:
        !          8166: -              n->r=constants(n->r);
        !          8167: -              return n;
        !          8168: -      case NLabel:
        !          8169: -              break;
        !          8170: -      case NID:
        !          8171: -              if(isconst(n))
        !          8172: -                      return doconst(n);
        !          8173: -              break;
        !          8174: -      case NIf:
        !          8175: -              n->l=constants(n->l);
        !          8176: -              n->r=constants(n->r);
        !          8177: -              n->o.n=constants(n->o.n);
        !          8178: -              if(isconst(n->o.n)){
        !          8179: -                      Node *m;
        !          8180: -                      gen(n->o.n, 1);
        !          8181: -                      execute();
        !          8182: -                      if(topofstack()){
        !          8183: -                              m=n->l;
        !          8184: -                              n->l=0;
        !          8185: -                      }else{
        !          8186: -                              m=n->r;
        !          8187: -                              n->r=0;
        !          8188: -                      }
        !          8189: -                      freenode(n);
        !          8190: -                      return m;
        !          8191: -              }
        !          8192: -              return n;
        !          8193: -      case NList:
        !          8194: -              break;
        !          8195: -      case NLoop:
        !          8196: -              break;
        !          8197: -      case NLoopexpr:
        !          8198: -              n->o.n=constants(n->o.n);
        !          8199: -              break;
        !          8200: -      case NMk:
        !          8201: -              break;
        !          8202: -      case NNum:
        !          8203: -              return n;
        !          8204: -      case NProg:
        !          8205: -              pushscope();
        !          8206: -              dclformals(n->l->l);
        !          8207: -              n->r=constants(n->r);
        !          8208: -              popscope();
        !          8209: -              return n;
        !          8210: -      case NResult:
        !          8211: -              break;
        !          8212: -      case NScope:
        !          8213: -              pushscope();
        !          8214: -              n->l=constants(n->l);
        !          8215: -              popscope();
        !          8216: -              return n;
        !          8217: -      case NSelect:
        !          8218: -              break;
        !          8219: -      case NSmash:
        !          8220: -              return n;
        !          8221: -      case NString:
        !          8222: -              return n;
        !          8223: -      case NSwitch:
        !          8224: -              break;
        !          8225: -      case NStructref:
        !          8226: -              if(isconst(n))
        !          8227: -                      return (n);
        !          8228: -              break;
        !          8229: -      case NType:
        !          8230: -              break;
        !          8231: -      case NUnit:
        !          8232: -              break;
        !          8233: -      case NVal:
        !          8234: -              if(isconst(n->l))
        !          8235: -                      return doconst(n);
        !          8236: -              break;
        !          8237: -      default:
        !          8238: -              fprint(2, "can't const node %n\n", n->t);
        !          8239: -              return n;
        !          8240: -      }
        !          8241: -      n->l=constants(n->l);
        !          8242: -      n->r=constants(n->r);
        !          8243: -      return n;
        !          8244: -}
        !          8245: -
        !          8246: -isconst(Node *n)
        !          8247: -{
        !          8248: -      if(n==0)
        !          8249: -              return 1;
        !          8250: -      switch(n->t){
        !          8251: -      case NArrayref:
        !          8252: -              return isconst(n->l) && isconst(n->r);
        !          8253: -      case NCall:
        !          8254: -              return 0;
        !          8255: -      case NExpr:
        !          8256: -              switch(n->o.i){
        !          8257: -              case GE:
        !          8258: -              case LE:
        !          8259: -              case NE:
        !          8260: -              case EQ:
        !          8261: -              case '>':
        !          8262: -              case '<':
        !          8263: -              case '+':
        !          8264: -              case '-':
        !          8265: -              case '*':
        !          8266: -              case '/':
        !          8267: -              case '%':
        !          8268: -              case '&':
        !          8269: -              case '|':
        !          8270: -              case '^':
        !          8271: -              case ANDAND:
        !          8272: -              case OROR:
        !          8273: -              case LSH:
        !          8274: -              case RSH:
        !          8275: -                      return isconst(n->l) && isconst(n->r);
        !          8276: -              case DEF:
        !          8277: -              case LEN:
        !          8278: -              case UMINUS:
        !          8279: -              case '~':
        !          8280: -              case '!':
        !          8281: -                      return isconst(n->l);
        !          8282: -              case REF:
        !          8283: -              case '=':
        !          8284: -              case RCV:
        !          8285: -              case SND:
        !          8286: -              case INC:
        !          8287: -              case DEC:
        !          8288: -                      return 0;
        !          8289: -              }
        !          8290: -              fprint(2, "can't isconst expression %e", n->o.i);
        !          8291: -              return 0;
        !          8292: -      case NID:
        !          8293: -              return n->o.s->val->scope==0 && (n->o.s->val->stclass&SCconst);
        !          8294: -      case NIf:
        !          8295: -              return isconst(n->o.n) && isconst(n->l) && isconst(n->r);
        !          8296: -      case NList:
        !          8297: -              return 0;
        !          8298: -      case NLoop:
        !          8299: -              return 0;
        !          8300: -      case NNum:
        !          8301: -              return 1;
        !          8302: -      case NResult:
        !          8303: -              return isconst(n->l);
        !          8304: -      case NScope:
        !          8305: -              return isconst(n->l);
        !          8306: -      case NString:
        !          8307: -              return 1;
        !          8308: -      case NStructref:
        !          8309: -              return isconst(n->l);
        !          8310: -      case NVal:
        !          8311: -              return isconst(n->l);
        !          8312: -      case NUnit:
        !          8313: -              return 1;
        !          8314: -      }
        !          8315: -      fprint(2, "can't isconst node %n\n", n->t);
        !          8316: -      return 0;
        !          8317: -}
        !          8318: -
        !          8319: -Node *
        !          8320: -doconst(Node *n)
        !          8321: -{
        !          8322: -      Node *t;
        !          8323: -      if(n->t==NNum || n->t==NString || n->t==NUnit)
        !          8324: -              return n;       /* already const */
        !          8325: -      t=etypeoft(n);
        !          8326: -      switch(t->o.t){
        !          8327: -      case TChar:
        !          8328: -      case TInt:
        !          8329: -              gen(n, 1);
        !          8330: -              freenode(n);
        !          8331: -              execute();
        !          8332: -              return new(NNum, (Node *)0, (Node *)0, (Node *)topofstack());
        !          8333: -      case TUnit:
        !          8334: -              return new(NUnit, (Node *)0, (Node *)0, (Node *)0);
        !          8335: -      case TArray:
        !          8336: -              if(t->r->o.t==TChar){
        !          8337: -                      Store *s;
        !          8338: -                      char *c;
        !          8339: -                      gen(n, 1);
        !          8340: -                      freenode(n);
        !          8341: -                      execute();
        !          8342: -                      s=(Store *)topofstack();
        !          8343: -                      c=emalloc(s->len+1);
        !          8344: -                      strncpy(c, (char *)s->data, (int)s->len);
        !          8345: -                      return newc(NString, (Node *)0, (Node *)0, c);
        !          8346: -              }
        !          8347: -              return n;
        !          8348: -      }
        !          8349: -      return n;
        !          8350: -}
        !          8351: -#include "alloc.h"
        !          8352: -#include "word.h"
        !          8353: -#include "store.h"
        !          8354: -#include "comm.h"
        !          8355: -#include <libc.h>
        !          8356: -
        !          8357: -extern        int     pflag;
        !          8358: -
        !          8359: -/*
        !          8360: - * Jumps
        !          8361: - */
        !          8362: -
        !          8363: -ijmp(Proc *proc)
        !          8364: -{
        !          8365: -      SWord l;
        !          8366: -      l=(SWord)*++proc->pc;
        !          8367: -      proc->pc+=l/WS;
        !          8368: -      return 1;
        !          8369: -}
        !          8370: -
        !          8371: -ijmpfalse(Proc *proc)
        !          8372: -{
        !          8373: -      SWord l;
        !          8374: -      l=(SWord)*++proc->pc;
        !          8375: -      if(*--proc->sp==0)
        !          8376: -              proc->pc+=l/WS;
        !          8377: -      return 1;
        !          8378: -}
        !          8379: -
        !          8380: -ijmptrue(Proc *proc)
        !          8381: -{
        !          8382: -      SWord l;
        !          8383: -      l=(SWord)*++proc->pc;
        !          8384: -      if(*--proc->sp!=0)
        !          8385: -              proc->pc+=l/WS;
        !          8386: -      return 1;
        !          8387: -}
        !          8388: -
        !          8389: -ivalnoresult(Proc *proc)
        !          8390: -{
        !          8391: -      rerror("val produces no result");
        !          8392: -      return 0;
        !          8393: -}
        !          8394: -
        !          8395: -/*
        !          8396: - * Progs
        !          8397: - *
        !          8398: - *   Layout of a stack frame
        !          8399: - *
        !          8400: - *    sp:
        !          8401: - *            automatics
        !          8402: - *    fp:     old fp
        !          8403: - *            old pc
        !          8404: - *            symbol
        !          8405: - *            arg1
        !          8406: - *            arg2
        !          8407: - *            ...
        !          8408: - *            result
        !          8409: - */
        !          8410: -
        !          8411: -iret(Proc *proc)
        !          8412: -{
        !          8413: -      SWord nargs;
        !          8414: -      nargs=(SWord)(proc->pc[1]);
        !          8415: -      proc->sp=(SWord *)proc->fp+1;
        !          8416: -      proc->fp=(SWord *)*--proc->sp;
        !          8417: -      proc->pc=(int (**)())*--proc->sp;
        !          8418: -      proc->sp-=(sizeof(char *)+nargs)/WS;
        !          8419: -      if(proc->pc==0){
        !          8420: -              if(pflag)
        !          8421: -                      fprint(2, "%d halts\n", proc->procnum);
        !          8422: -              halt(proc);
        !          8423: -              return 0;
        !          8424: -      }
        !          8425: -      return 1;
        !          8426: -}
        !          8427: -
        !          8428: -ibecome(Proc *proc)
        !          8429: -{
        !          8430: -      int nargs;
        !          8431: -      int (**newpc)();
        !          8432: -      SWord oldfp, oldpc, *oldresultaddr, *newresultaddr;
        !          8433: -      Store *s;
        !          8434: -      nargs=*--proc->sp/LWS;
        !          8435: -      nargs+=2;       /* includes result and sym; add pc, fp */
        !          8436: -      s=(Store *)*--proc->sp;
        !          8437: -      if(--(s->ref)==0)
        !          8438: -              rpanic("ibecome ref==0");
        !          8439: -      newpc=((int (**)())s->data);
        !          8440: -      oldfp=proc->fp[0];
        !          8441: -      oldpc=proc->fp[-1];
        !          8442: -      *proc->sp++=oldpc;
        !          8443: -      *proc->sp++=oldfp;
        !          8444: -      oldresultaddr=proc->fp-3-(long)(*++proc->pc)/LWS;
        !          8445: -      newresultaddr=proc->sp-nargs;
        !          8446: -      memcpy((char *)oldresultaddr, (char *)newresultaddr, LWS*nargs);
        !          8447: -      /* args in place.  do the call by hand, jmp to pushfp */
        !          8448: -      proc->sp=oldresultaddr+(nargs-2);
        !          8449: -      *proc->sp++=oldpc;
        !          8450: -      proc->fp=(SWord *)oldfp;
        !          8451: -      proc->pc=newpc-1;
        !          8452: -      return 1;
        !          8453: -}
        !          8454: -
        !          8455: -ipushfp(Proc *proc)
        !          8456: -{
        !          8457: -      int nauto;
        !          8458: -      *proc->sp=(SWord)proc->fp;
        !          8459: -      proc->fp=proc->sp++;
        !          8460: -      nauto=((SWord)*++proc->pc)/WS;
        !          8461: -      while(nauto--)
        !          8462: -              *proc->sp++=0;
        !          8463: -      if(proc->sp>=&proc->stack[NSTACK])
        !          8464: -              rerror("stack overflow");
        !          8465: -      return 1;
        !          8466: -}
        !          8467: -
        !          8468: -icall(Proc *proc)
        !          8469: -{
        !          8470: -      int (**newpc)();
        !          8471: -      Store *s;
        !          8472: -      s=(Store *)*--proc->sp;
        !          8473: -      if(--(s->ref)==0)
        !          8474: -              rpanic("icall ref==0");
        !          8475: -      newpc=((int (**)())s->data);
        !          8476: -      *proc->sp++=(SWord)proc->pc;
        !          8477: -      proc->pc=newpc-1;
        !          8478: -      return 1;
        !          8479: -}
        !          8480: -#include "node.h"
        !          8481: -#include "symbol.h"
        !          8482: -#include "alloc.h"
        !          8483: -#include "ydefs.h"
        !          8484: -#include "word.h"
        !          8485: -#include "store.h"
        !          8486: -#include <libc.h>
        !          8487: -
        !          8488: -extern int    nscope;
        !          8489: -
        !          8490: -declare(Node *n, int stclass, int dotypchk, int docomp)
        !          8491: -{
        !          8492: -      extern int iflag;
        !          8493: -      if(n==0)
        !          8494: -              return;
        !          8495: -      if(n->t==NList){
        !          8496: -              declare(n->l, stclass, dotypchk, docomp);
        !          8497: -              declare(n->r, stclass, dotypchk, docomp);
        !          8498: -              return;
        !          8499: -      }
        !          8500: -      if(n->t==NDeclsc){
        !          8501: -              declare(n->l, n->o.i, dotypchk, docomp);
        !          8502: -              return;
        !          8503: -      }
        !          8504: -      if(dotypchk)
        !          8505: -              type(n->o.n, 0);
        !          8506: -      if(n->r==0){
        !          8507: -              if(n->o.n==0)
        !          8508: -                      panic("declare: no type");
        !          8509: -              if(n->o.n->t==NMk && n->o.n->l==0)
        !          8510: -                      lerror(n, "can't derive type in declaration");
        !          8511: -              n->r=dupnode(etypeof(n->o.n));
        !          8512: -      }
        !          8513: -      if(dotypchk){
        !          8514: -              type(n->r, 0);
        !          8515: -              if(n->o.n){
        !          8516: -                      /*
        !          8517: -                       * Make it a mk
        !          8518: -                       */
        !          8519: -                      if(n->o.n->t!=NMk)
        !          8520: -                              n->o.n=new(NMk, (Node *)0, n->o.n, (Node *)0);
        !          8521: -                      /*
        !          8522: -                       * Default type for mk
        !          8523: -                       */
        !          8524: -                      if(n->o.n->l==0)
        !          8525: -                              n->o.n->l=dupnode(n->r);
        !          8526: -                      else if(!compattype(n->r, n->o.n->l))
        !          8527: -                              lerror(n, "type clash in declaration (%t %t)\n",
        !          8528: -                                      n->r->o.t, etypeof(n->o.n)->o.t);
        !          8529: -                      mkcheck(n->o.n->l, n->o.n->r);
        !          8530: -              }
        !          8531: -      }
        !          8532: -      if(docomp && n->o.n){
        !          8533: -              if(dotypchk)    /* top level declaration */
        !          8534: -                      n->o.n=constants(n->o.n);
        !          8535: -              gen(n->o.n, 1);
        !          8536: -              dupgen(n->r, length(n->l)-1);
        !          8537: -      }else
        !          8538: -              docomp=0;
        !          8539: -      dcl(n->l, n->r, stclass, n->o.n, docomp);
        !          8540: -      if(n->o.n && docomp && nscope==0){
        !          8541: -              if(iflag)
        !          8542: -                      idump();
        !          8543: -              execute();
        !          8544: -      }
        !          8545: -}
        !          8546: -
        !          8547: -dcl(id, typ, stclass, val, docomp)
        !          8548: -      Node *id, *typ, *val;
        !          8549: -{
        !          8550: -      if(id->t==NList){
        !          8551: -              dcl(id->l, typ, stclass, val, docomp);
        !          8552: -              dcl(id->r, typ, stclass, val, docomp);
        !          8553: -              return;
        !          8554: -      }
        !          8555: -      if(typ->o.t==TID && typ->l->o.s->val->type->o.t!=TType)
        !          8556: -              error("%m not a type", typ->l);
        !          8557: -      if(id->t!=NID)
        !          8558: -              panic("dcl not ID");
        !          8559: -      pushval(id->o.s, dupnode(typ));
        !          8560: -      if(stclass&SCbltin)
        !          8561: -              id->o.s->val->store.l=bltinval(id->o.s->name, typ);
        !          8562: -      if(docomp)
        !          8563: -              lgen(id);
        !          8564: -      id->o.s->val->stclass=stclass;
        !          8565: -}
        !          8566: -
        !          8567: -/*
        !          8568: - * To compile this
        !          8569: - *    rec {
        !          8570: - *            x : chan of T = f(x,y);
        !          8571: - *            y : chan of T = g(x,y);
        !          8572: - *    };
        !          8573: - * convert it to this
        !          8574: - *    x : chan of T = mk();
        !          8575: - *    y : chan of T = mk();
        !          8576: - *    x1 : chan of T = f(x,y);
        !          8577: - *    y1 : chan of T = g(x,y);
        !          8578: - *    x <- x1;
        !          8579: - *    y <- y1;
        !          8580: - *    toss x1, y1;
        !          8581: - * where the operator x <- x1 means copy the representation of x1 into x.
        !          8582: - *
        !          8583: - *    rec type T: struct of { t:T; };
        !          8584: - *
        !          8585: - * is handled similarly.
        !          8586: - */
        !          8587: -
        !          8588: -Node *
        !          8589: -op1(Node *n)
        !          8590: -{
        !          8591: -      Node *m;
        !          8592: -      if(n->t==NDeclsc){
        !          8593: -              m=op1(n->l);
        !          8594: -              return newi(NDeclsc, m, (Node *)0, n->o.i);
        !          8595: -      }
        !          8596: -      if(n->r==0){
        !          8597: -              if(n->o.n && (n->o.n->t==NProg || (n->o.n->t==NMk && n->o.n->l)))
        !          8598: -                      n->r=dupnode(n->o.n->l);
        !          8599: -              else                    
        !          8600: -                      lerror(n, "can't deduce type for rec decl");
        !          8601: -      }else if(n->r->o.t==TType){
        !          8602: -              m=newi(NType, (Node *)0, (Node *)0, n->r->l->o.t);
        !          8603: -              m=new(NDecl, dupnode(n->l), m, (Node *)0);
        !          8604: -              return m;
        !          8605: -      }
        !          8606: -      m=new(NMk, dupnode(n->r), (Node *)0, (Node *)0);
        !          8607: -      m=new(NDecl, dupnode(n->l), dupnode(n->r), m);
        !          8608: -      return m;
        !          8609: -}
        !          8610: -
        !          8611: -Node *
        !          8612: -op2(Node *n)
        !          8613: -{
        !          8614: -      Node *m;
        !          8615: -      char s[Namesize+2];
        !          8616: -      if(n->t==NDeclsc){
        !          8617: -              m=op2(n->l);
        !          8618: -              return newi(NDeclsc, m, (Node *)0, n->o.i);
        !          8619: -      }
        !          8620: -      if(n->l->t==NList)
        !          8621: -              error("no identifier lists in rec's, please");
        !          8622: -      strcpy(s+1, n->l->o.s->name);
        !          8623: -      s[0]='*';
        !          8624: -      m=new(NDecl, idnode(lookup(s, ID)), dupnode(n->r), dupnode(n->o.n));
        !          8625: -      return m;
        !          8626: -}
        !          8627: -
        !          8628: -Node *
        !          8629: -op3(Node *n)
        !          8630: -{
        !          8631: -      Node *m;
        !          8632: -      char s[Namesize+2];
        !          8633: -      if(n->t==NDeclsc)
        !          8634: -              return op3(n->l);
        !          8635: -      if(n->l->t==NList)
        !          8636: -              error("no lists in rec's, please");
        !          8637: -      strcpy(s+1, n->l->o.s->name);
        !          8638: -      s[0]='*';
        !          8639: -      m=new(NSmash, idnode(lookup(s+1, ID)), idnode(lookup(s, ID)), (Node *)0);
        !          8640: -      return m;
        !          8641: -}
        !          8642: -
        !          8643: -Node *
        !          8644: -rewr(Node *n, Node *(*f)())
        !          8645: -{
        !          8646: -      if(n->t==NList)
        !          8647: -              return new(NList, rewr(n->l, f), rewr(n->r, f), (Node *)0);
        !          8648: -      return (*f)(n);
        !          8649: -}
        !          8650: -
        !          8651: -recrewrite(Node *n)
        !          8652: -{
        !          8653: -      Node *n1, *n2, *n3;
        !          8654: -      n1=rewr(n->l, op1);
        !          8655: -      n2=rewr(n->l, op2);
        !          8656: -      n3=rewr(n->l, op3);
        !          8657: -      freenode(n->l);
        !          8658: -      n->t=NList;
        !          8659: -      n->r=n3;
        !          8660: -      n->l=new(NList, n1, n2, (Node *)0);
        !          8661: -      ndump(n);
        !          8662: -}
        !          8663: -
        !          8664: -/*
        !          8665: - *
        !          8666: - * To compile this
        !          8667: - *
        !          8668: - *    prog(a:int){
        !          8669: - *            begin prog(b:int){ f(a, b); }(b);
        !          8670: - *    }
        !          8671: - *
        !          8672: - * convert it to this
        !          8673: - *
        !          8674: - *    prog(a:int){
        !          8675: - *            begin prog(b:int, a:int){ f(a, b); }(b, a);
        !          8676: - *    }
        !          8677: - *
        !          8678: - */
        !          8679: -
        !          8680: -Node  *begf;
        !          8681: -Node  *bega;
        !          8682: -int   fscope;
        !          8683: -int   progerr;
        !          8684: -
        !          8685: -proglocals(Node *n)
        !          8686: -{
        !          8687: -      progerr=1;
        !          8688: -      pushscope();
        !          8689: -      fscope=nscope;
        !          8690: -      begf=n->l->l;
        !          8691: -      bega=0;
        !          8692: -      dclformals(begf);
        !          8693: -      progid(n->r);
        !          8694: -      popscope();
        !          8695: -}
        !          8696: -
        !          8697: -begrewrite(Node *n)
        !          8698: -{
        !          8699: -      progerr=0;
        !          8700: -      pushscope();
        !          8701: -      fscope=nscope;
        !          8702: -      begf=n->l->l->l;
        !          8703: -      bega=n->r;
        !          8704: -      dclformals(begf);
        !          8705: -      progid(n->l->r);
        !          8706: -      popscope();
        !          8707: -      n->l->l->l=begf;
        !          8708: -      n->r=bega;
        !          8709: -}
        !          8710: -
        !          8711: -addformal(Node *n)
        !          8712: -{
        !          8713: -      Node *nf;
        !          8714: -      if(!alreadyformal(n, begf)){
        !          8715: -              nf=new(NFormal, dupnode(n), dupnode(n->o.s->val->type), (Node *)0);
        !          8716: -              if(begf)
        !          8717: -                      begf=new(NList, begf, nf, (Node *)0);
        !          8718: -              else
        !          8719: -                      begf=nf;
        !          8720: -              nf=dupnode(n);
        !          8721: -              if(bega)
        !          8722: -                      bega=new(NExprlist, bega, nf, (Node *)0);
        !          8723: -              else
        !          8724: -                      bega=nf;
        !          8725: -      }               
        !          8726: -}
        !          8727: -
        !          8728: -alreadyformal(Node *n, Node *f)
        !          8729: -{
        !          8730: -      if(f==0)
        !          8731: -              return 0;
        !          8732: -      if(f->t==NList)
        !          8733: -              return alreadyformal(n, f->l) || alreadyformal(n, f->r);
        !          8734: -      return strcmp(n->o.s->name, f->l->o.s->name)==0;
        !          8735: -}
        !          8736: -
        !          8737: -progid(Node *n)
        !          8738: -{
        !          8739: -      if(n==0)
        !          8740: -              return;
        !          8741: -      switch(n->t){
        !          8742: -      case NArrayref:
        !          8743: -      case NArraycom:
        !          8744: -      case NBecome:
        !          8745: -      case NBegin:
        !          8746: -      case NCall:
        !          8747: -      case NCase:
        !          8748: -              break;
        !          8749: -      case NDecl:
        !          8750: -              progid(n->r);
        !          8751: -              progid(n->o.n);
        !          8752: -              declare(n, 0, 0, 0);
        !          8753: -              return;
        !          8754: -      case NDeclsc:
        !          8755: -      case NDefault:
        !          8756: -              break;
        !          8757: -      case NElem:
        !          8758: -              return;
        !          8759: -      case NExpr:
        !          8760: -      case NExprlist:
        !          8761: -      case NFormal:
        !          8762: -              break;
        !          8763: -      case NID:
        !          8764: -              if(n->o.s->val)
        !          8765: -              if(0<n->o.s->val->scope && n->o.s->val->scope<fscope){
        !          8766: -                      if(progerr)
        !          8767: -                              lerror(n, "%m not in an accessible scope", n);
        !          8768: -                      addformal(n);
        !          8769: -              }
        !          8770: -              return;
        !          8771: -      case NLabel:
        !          8772: -      case NList:
        !          8773: -      case NLoop:
        !          8774: -              break;
        !          8775: -      case NLoopexpr:
        !          8776: -              progid(n->o.n);
        !          8777: -              break;
        !          8778: -      case NIf:
        !          8779: -              progid(n->o.n);
        !          8780: -              break;
        !          8781: -      case NMk:
        !          8782: -              break;
        !          8783: -      case NNum:
        !          8784: -              return;
        !          8785: -      case NProg:
        !          8786: -              pushscope();
        !          8787: -              dclformals(n->l->l);
        !          8788: -              progid(n->r);
        !          8789: -              popscope();
        !          8790: -              return;
        !          8791: -      case NResult:
        !          8792: -              break;
        !          8793: -      case NScope:
        !          8794: -              pushscope();
        !          8795: -              progid(n->l);
        !          8796: -              popscope();
        !          8797: -              return;
        !          8798: -      case NSelect:
        !          8799: -              break;
        !          8800: -      case NSmash:
        !          8801: -              return; /* ?? */
        !          8802: -      case NString:
        !          8803: -              return;
        !          8804: -      case NSwitch:
        !          8805: -      case NStructref:
        !          8806: -              break;
        !          8807: -      case NType:
        !          8808: -              break;
        !          8809: -      case NUnit:
        !          8810: -              return;
        !          8811: -      case NVal:
        !          8812: -              break;
        !          8813: -      default:
        !          8814: -              fprint(2, "can't progid node %n\n", n->t);
        !          8815: -              return;
        !          8816: -      }
        !          8817: -      progid(n->l);
        !          8818: -      progid(n->r);
        !          8819: -}
        !          8820: -
        !          8821: -#include "nodenames.h"
        !          8822: -#include "typenames.h"
        !          8823: -#include "errjmp.h"
        !          8824: -#include "node.h"
        !          8825: -#include "symbol.h"
        !          8826: -#include "ydefs.h"
        !          8827: -#include <libc.h>
        !          8828: -
        !          8829: -lerror(Node *n, char *s, a, b, c, d, e, f)
        !          8830: -{
        !          8831: -      lfileline(n->line);
        !          8832: -      fprint(2, s, a, b, c, d, e, f);
        !          8833: -      if(s[strlen(s)-1]!='\n')
        !          8834: -              fprint(2, "\n");
        !          8835: -      errflush();
        !          8836: -      errjmp();
        !          8837: -}
        !          8838: -
        !          8839: -error(char *s, a, b, c, d, e, f)
        !          8840: -{
        !          8841: -      fileline();
        !          8842: -      fprint(2, s, a, b, c, d, e, f);
        !          8843: -      if(s[strlen(s)-1]!='\n')
        !          8844: -              fprint(2, "\n");
        !          8845: -      errflush();
        !          8846: -      errjmp();
        !          8847: -}
        !          8848: -
        !          8849: -rerror(char *s, a, b, c, d, e, f)
        !          8850: -{
        !          8851: -      fileline();
        !          8852: -      fprint(2, s, a, b, c, d, e, f);
        !          8853: -      fprint(2, "\n");
        !          8854: -      processes(0);
        !          8855: -      errflush();
        !          8856: -      errjmp();
        !          8857: -}
        !          8858: -
        !          8859: -warn(char *s, a, b, c, d, e, f)
        !          8860: -{
        !          8861: -      fileline();
        !          8862: -      fprint(2, "warning: ");
        !          8863: -      fprint(2, s, a, b, c, d, e, f);
        !          8864: -      fprint(2, "\n");
        !          8865: -}
        !          8866: -
        !          8867: -panic(char *s, a, b, c, d, e, f)
        !          8868: -{
        !          8869: -      fileline();
        !          8870: -      fprint(2, "internal error: ");
        !          8871: -      fprint(2, s, a, b, c, d, e, f);
        !          8872: -      fprint(2, "\n");
        !          8873: -      abort();
        !          8874: -}
        !          8875: -
        !          8876: -rpanic(char *s, a, b, c, d, e, f)
        !          8877: -{
        !          8878: -      fileline();
        !          8879: -      processes(0);
        !          8880: -      fprint(2, "internal error: ");
        !          8881: -      fprint(2, s, a, b, c, d, e, f);
        !          8882: -      fprint(2, "\n");
        !          8883: -      abort();
        !          8884: -}
        !          8885: -
        !          8886: -bconv(int *o, int f1, int f2)
        !          8887: -{
        !          8888: -      extern int printcol;
        !          8889: -      while(printcol<*o-8)
        !          8890: -              strconv("\t", f1, f2);
        !          8891: -      strconv("        "+(8-(*o-printcol)), f1, f2);
        !          8892: -      return sizeof(int);
        !          8893: -}
        !          8894: -
        !          8895: -nconv(int *o, int f1, int f2)
        !          8896: -{
        !          8897: -      if(*o<0 || sizeof(Ntypename)/sizeof(Ntypename[0])<=*o)
        !          8898: -              strconv("mystery node", f1, f2);
        !          8899: -      else
        !          8900: -              strconv(Ntypename[*o], f1, f2);
        !          8901: -      return sizeof(int);
        !          8902: -}
        !          8903: -
        !          8904: -tconv(int *o, int f1, int f2)
        !          8905: -{
        !          8906: -      if(*o<0 || sizeof(Ttypename)/sizeof(Ttypename[0])<=*o)
        !          8907: -              strconv("mystery type", f1, f2);
        !          8908: -      else
        !          8909: -              strconv(Ttypename[*o], f1, f2);
        !          8910: -      return sizeof(int);
        !          8911: -}
        !          8912: -
        !          8913: -char  bufx[128][10];
        !          8914: -int   bufno=9;
        !          8915: -
        !          8916: -char *
        !          8917: -prbuf(){
        !          8918: -      if(++bufno==10)
        !          8919: -              bufno=0;
        !          8920: -      return bufx[bufno];
        !          8921: -}
        !          8922: -
        !          8923: -econv(int *o, int f1, int f2)
        !          8924: -{
        !          8925: -      char *buf=prbuf();
        !          8926: -      char *x;
        !          8927: -      int t=*o;
        !          8928: -      if(t<128 && strchr("+-*/%|&^~?!><=", t))
        !          8929: -              sprint(buf, "%c", t);
        !          8930: -      else{
        !          8931: -              switch(t){
        !          8932: -              case GE:
        !          8933: -                      x=">=";
        !          8934: -                      break;
        !          8935: -              case LE:
        !          8936: -                      x="<=";
        !          8937: -                      break;
        !          8938: -              case NE:
        !          8939: -                      x="!=";
        !          8940: -                      break;
        !          8941: -              case EQ:
        !          8942: -                      x="==";
        !          8943: -                      break;
        !          8944: -              case ANDAND:
        !          8945: -                      x="&&";
        !          8946: -                      break;
        !          8947: -              case OROR:
        !          8948: -                      x="||";
        !          8949: -                      break;
        !          8950: -              case REF:
        !          8951: -                      x="ref";
        !          8952: -                      break;
        !          8953: -              case LEN:
        !          8954: -                      x="len";
        !          8955: -                      break;
        !          8956: -              case UMINUS:
        !          8957: -                      x="unary -";
        !          8958: -                      break;
        !          8959: -              case RCV:
        !          8960: -                      x="rcv";
        !          8961: -                      break;
        !          8962: -              case SND:
        !          8963: -                      x="send";
        !          8964: -                      break;
        !          8965: -              case LSH:
        !          8966: -                      x="<<";
        !          8967: -                      break;
        !          8968: -              case RSH:
        !          8969: -                      x=">>";
        !          8970: -                      break;
        !          8971: -              case DEC:
        !          8972: -                      x="--";
        !          8973: -                      break;
        !          8974: -              case INC:
        !          8975: -                      x="++";
        !          8976: -                      break;
        !          8977: -              default:
        !          8978: -                      x="mystery expression";
        !          8979: -                      break;
        !          8980: -              }
        !          8981: -              strcpy(buf, x);
        !          8982: -      }
        !          8983: -      strconv(buf, f1, f2);
        !          8984: -      return sizeof(int);
        !          8985: -}
        !          8986: -
        !          8987: -mconv(int *o, int f1, int f2)
        !          8988: -{
        !          8989: -      char *buf=prbuf();
        !          8990: -      Node *n=(Node *)*o;
        !          8991: -      switch(n->t){
        !          8992: //GO.SYSIN DD regress.d/t6.i
        !          8993: echo regress.d/t6.out 1>&2
        !          8994: sed 's/.//' >regress.d/t6.out <<'//GO.SYSIN DD regress.d/t6.out'
        !          8995: -emalloc(unsigned long n)
        !          8996: -erealloc(char *p, unsigned long n)
        !          8997: -pprint(proc, fmt, a, b, c, d, e)
        !          8998: -bltinval(char *name, Node *t)
        !          8999: -mk(type, len)
        !          9000: -compile(n)    /* called from parser only */
        !          9001: -gen(Node *n, int retain)
        !          9002: -lgen(Node *n)
        !          9003: -genfreeauto(Symbol *s)
        !          9004: -dupgen(Node *t, int n)
        !          9005: -printable(Node *n)
        !          9006: -constants(Node *n)
        !          9007: -declare(Node *n, int stclass, int dotypchk, int docomp)
        !          9008: -recrewrite(Node *n)
        !          9009: -proglocals(Node *n)
        !          9010: -begrewrite(Node *n)
        !          9011: -lerror(Node *n, char *s, a, b, c, d, e, f)
        !          9012: -error(char *s, a, b, c, d, e, f)
        !          9013: -rerror(char *s, a, b, c, d, e, f)
        !          9014: -warn(char *s, a, b, c, d, e, f)
        !          9015: -panic(char *s, a, b, c, d, e, f)
        !          9016: -rpanic(char *s, a, b, c, d, e, f)
        !          9017: -bconv(int *o, int f1, int f2)
        !          9018: -nconv(int *o, int f1, int f2)
        !          9019: -tconv(int *o, int f1, int f2)
        !          9020: -econv(int *o, int f1, int f2)
        !          9021: -mconv(int *o, int f1, int f2)
        !          9022: //GO.SYSIN DD regress.d/t6.out
        !          9023: echo regress.d/t6.pat 1>&2
        !          9024: sed 's/.//' >regress.d/t6.pat <<'//GO.SYSIN DD regress.d/t6.pat'
        !          9025: -^Aconv\(
        !          9026: -^Cconv\(
        !          9027: -^Uconv\(
        !          9028: -^bconv\(
        !          9029: -^begrewrite\(
        !          9030: -^bi_bread\(
        !          9031: -^bi_close\(
        !          9032: -^bi_open\(
        !          9033: -^bi_rand\(
        !          9034: -^bi_read\(
        !          9035: -^bi_write\(
        !          9036: -^bltinval\(
        !          9037: -^compattype\(
        !          9038: -^compile\(
        !          9039: -^concat\(
        !          9040: -^constants\(
        !          9041: -^curproc\(
        !          9042: -^dclformals\(
        !          9043: -^declare\(
        !          9044: -^decref\(
        !          9045: -^dump\(
        !          9046: -^dupgen\(
        !          9047: -^dupnode\(
        !          9048: -^econv\(
        !          9049: -^elemrewr\(
        !          9050: -^emalloc\(
        !          9051: -^emit\(
        !          9052: -^emitconst\(
        !          9053: -^emitspace\(
        !          9054: -^eqtype\(
        !          9055: -^erealloc\(
        !          9056: -^errflush\(
        !          9057: -^error\(
        !          9058: -^etypeof\(
        !          9059: -^etypeoft\(
        !          9060: -^execute\(
        !          9061: -^exits\(
        !          9062: -^fileline\(
        !          9063: -^freenode\(
        !          9064: -^gen\(
        !          9065: -^genfreeauto\(
        !          9066: -^halt\(
        !          9067: -^here\(
        !          9068: -^iconv\(
        !          9069: -^idnode\(
        !          9070: -^idump\(
        !          9071: -^istart\(
        !          9072: -^istopscope\(
        !          9073: -^length\(
        !          9074: -^lerror\(
        !          9075: -^lexinit\(
        !          9076: -^lfileline\(
        !          9077: -^lgen\(
        !          9078: -^lookup\(
        !          9079: -^mconv\(
        !          9080: -^mk\(
        !          9081: -^mkcheck\(
        !          9082: -^nargs\(
        !          9083: -^nconv\(
        !          9084: -^ndump\(
        !          9085: -^new\(
        !          9086: -^newc\(
        !          9087: -^newfile\(
        !          9088: -^newi\(
        !          9089: -^newl\(
        !          9090: -^panic\(
        !          9091: -^patch\(
        !          9092: -^popscope\(
        !          9093: -^pprint\(
        !          9094: -^printable\(
        !          9095: -^processes\(
        !          9096: -^procinit\(
        !          9097: -^proglocals\(
        !          9098: -^pushscope\(
        !          9099: -^pushval\(
        !          9100: -^recrewrite\(
        !          9101: -^rerror\(
        !          9102: -^rpanic\(
        !          9103: -^run\(
        !          9104: -^scopedecrefgen\(
        !          9105: -^setprog\(
        !          9106: -^tconv\(
        !          9107: -^topofstack\(
        !          9108: -^topscope\(
        !          9109: -^type\(
        !          9110: -^typeinit\(
        !          9111: -^typeof\(
        !          9112: -^typeoftid\(
        !          9113: -^warn\(
        !          9114: -^yylex\(
        !          9115: -^yyparse\(
        !          9116: //GO.SYSIN DD regress.d/t6.pat
        !          9117: echo regress.d/t6.sh 1>&2
        !          9118: sed 's/.//' >regress.d/t6.sh <<'//GO.SYSIN DD regress.d/t6.sh'
        !          9119: -$GRE -f t6.pat < t6.i
        !          9120: //GO.SYSIN DD regress.d/t6.sh
        !          9121: echo regress.d/t7.i 1>&2
        !          9122: sed 's/.//' >regress.d/t7.i <<'//GO.SYSIN DD regress.d/t7.i'
        !          9123: -      if [ `cat $HISTFILE | lct` -gt "$HISTMAXL" ]
        !          9124: -
        !          9125: -for i in `ls [0-9]*# | egrep '^[0-9]+##?$' | sed -e 's/#*$//'`
        !          9126: -
        !          9127: -do case "`ps -lx$i" in ?*);; *) rm -f ${i}# ${i}##;; esac
        !          9128: -
        !          9129: -NBRFILES=`ls -f $pubdir/jbk | fgrep -vi -x '.
        !          9130: -
        !          9131: -..'|lct`
        !          9132: //GO.SYSIN DD regress.d/t7.i
        !          9133: echo regress.d/t7.out 1>&2
        !          9134: sed 's/.//' >regress.d/t7.out <<'//GO.SYSIN DD regress.d/t7.out'
        !          9135: -do case "`ps -lx$i" in ?*);; *) rm -f ${i}# ${i}##;; esac
        !          9136: -NBRFILES=`ls -f $pubdir/jbk | fgrep -vi -x '.
        !          9137: -..'|lct`
        !          9138: //GO.SYSIN DD regress.d/t7.out
        !          9139: echo regress.d/t7.sh 1>&2
        !          9140: sed 's/.//' >regress.d/t7.sh <<'//GO.SYSIN DD regress.d/t7.sh'
        !          9141: -$GRE -G '^[^`]*`[^`]*$' < t7.i
        !          9142: //GO.SYSIN DD regress.d/t7.sh
        !          9143: echo regress.d/t8.i 1>&2
        !          9144: sed 's/.//' >regress.d/t8.i <<'//GO.SYSIN DD regress.d/t8.i'
        !          9145: -b
        !          9146: -ba
        !          9147: //GO.SYSIN DD regress.d/t8.i
        !          9148: echo regress.d/t8.out 1>&2
        !          9149: sed 's/.//' >regress.d/t8.out <<'//GO.SYSIN DD regress.d/t8.out'
        !          9150: -b
        !          9151: -ba
        !          9152: //GO.SYSIN DD regress.d/t8.out
        !          9153: echo regress.d/t8.sh 1>&2
        !          9154: sed 's/.//' >regress.d/t8.sh <<'//GO.SYSIN DD regress.d/t8.sh'
        !          9155: -$GRE -F -x -f t8.i < t8.i
        !          9156: //GO.SYSIN DD regress.d/t8.sh
        !          9157: echo regress.d/t9.i 1>&2
        !          9158: sed 's/.//' >regress.d/t9.i <<'//GO.SYSIN DD regress.d/t9.i'
        !          9159: -aba
        !          9160: -cad
        !          9161: -bad
        !          9162: -acb
        !          9163: //GO.SYSIN DD regress.d/t9.i
        !          9164: echo regress.d/t9.out 1>&2
        !          9165: sed 's/.//' >regress.d/t9.out <<'//GO.SYSIN DD regress.d/t9.out'
        !          9166: -aba
        !          9167: -bad
        !          9168: -acb
        !          9169: //GO.SYSIN DD regress.d/t9.out
        !          9170: echo regress.d/t9.sh 1>&2
        !          9171: sed 's/.//' >regress.d/t9.sh <<'//GO.SYSIN DD regress.d/t9.sh'
        !          9172: -$GRE -F -f t8.i < t9.i
        !          9173: //GO.SYSIN DD regress.d/t9.sh
        !          9174: echo mkfile 1>&2
        !          9175: sed 's/.//' >mkfile <<'//GO.SYSIN DD mkfile'
        !          9176: -NPROC=2
        !          9177: -CFLAGS=-DMEMMOVE -N -I/usr/include/lcc -I/usr/include/libc # -A -p -DPROFILING # -DUSE_STDIO
        !          9178: -# CC should be an ansi compiler (or c++); OCC any old compiler
        !          9179: -CC=lcc
        !          9180: -OCC=cc
        !          9181: -NAMES=main dofgrep dogre fns buffer
        !          9182: -OBJ=${NAMES:%=%.o}
        !          9183: -LIB=libc.a
        !          9184: -LNAMES=cw bm re eg egcomp eglit egpos egstate egcw egbr egerror refile\
        !          9185: -      egparen egmatch egcanon
        !          9186: -LOBJ=${LNAMES:%=$LIB(%.o)}
        !          9187: -LLOBJ=${LNAMES:%=%.o}
        !          9188: -SRC=${NAMES:%=%.c} ${LNAMES:%=%.c}
        !          9189: -BUILTINS='%.o:        %.c
        !          9190: -      $CC $CFLAGS -c $stem.c
        !          9191: -'"`cat DEPEND`"
        !          9192: -
        !          9193: -all:V:        gre cyntax
        !          9194: -
        !          9195: -gre:  $OBJ $LIB
        !          9196: -      $CC $CFLAGS -o $target $prereq
        !          9197: -
        !          9198: -regress:VQ:   #hcheck
        !          9199: -      make CC=$CC regress
        !          9200: -
        !          9201: -oregress:VQ:
        !          9202: -      rm -fr tmp
        !          9203: -      mkdir tmp tmp/regress.d
        !          9204: -      for i in $SRC *.h
        !          9205: -      do
        !          9206: -              awk -f deansify.awk $i > tmp/$i
        !          9207: -      done
        !          9208: -      cp makefile tmp
        !          9209: -      cp regress.d/* tmp/regress.d
        !          9210: -      (cd tmp; make CC=$OCC regress)
        !          9211: -      rm -fr tmp
        !          9212: -
        !          9213: -lt1:  lt1.o $LIB
        !          9214: -      $CC $CFLAGS -o $target $prereq
        !          9215: -
        !          9216: -pp:V:
        !          9217: -      pr mkfile hdr.h $SRC | lp -dpsu -n2
        !          9218: -
        !          9219: -htest.o:      htest.c
        !          9220: -      $CC $CFLAGS -DUSE_STDIO -c $prereq
        !          9221: -htest:        htest.o $LIB
        !          9222: -      $CC $CFLAGS -o $target $prereq
        !          9223: -hcheck:       htest
        !          9224: -      echo aabcdd | htest 'a+(b|c)*d+' tempa 0
        !          9225: -      echo abccccc | htest '^(a|b)*(abc+|c)' tempa 0
        !          9226: -      echo bccc | htest '(bc|bc+)' tempa 0
        !          9227: -      echo abab | htest '((b|a)+)\1' tempa 0
        !          9228: -      echo vivi | htest '^.+$' tempa '^(.+)$' tempb 01
        !          9229: -      echo acbb | htest '((.)+)\1' tempa 0
        !          9230: -      echo !gryphon.att.com!eby | time htest '^!([^!.]+)\.att\.com!(.+)$' tempa 0
        !          9231: -
        !          9232: -h1:V: htest
        !          9233: -      echo abc | time htest '^^.+!([^!]+2!([^!]+)$$' tempa 0
        !          9234: -
        !          9235: -check:V:
        !          9236: -      rm -f *.o gre refile libc.a
        !          9237: -      mk gre refile regress oregress
        !          9238: -      rm -f *.o gre refile libc.a
        !          9239: -
        !          9240: -bm.o: re.h lre.h hdr.h
        !          9241: -buffer.o: re.h lre.h hdr.h
        !          9242: -cw.o: re.h lre.h hdr.h
        !          9243: -dofgrep.o: re.h lre.h hdr.h
        !          9244: -dogre.o: re.h lre.h hdr.h
        !          9245: -eg.o: re.h lre.h hdr.h
        !          9246: -egbr.o: re.h lre.h hdr.h
        !          9247: -egcomp.o: re.h lre.h hdr.h
        !          9248: -egcw.o: re.h lre.h hdr.h
        !          9249: -egerror.o: re.h /usr/include/stdio.h
        !          9250: -eglit.o: re.h lre.h hdr.h
        !          9251: -egmatch.o: re.h lre.h hdr.h
        !          9252: -egparen.o: re.h lre.h hdr.h
        !          9253: -egpos.o: re.h lre.h hdr.h
        !          9254: -egstate.o: re.h lre.h hdr.h
        !          9255: -fns.o: re.h lre.h hdr.h
        !          9256: -main.o: re.h lre.h hdr.h
        !          9257: -re.o: re.h lre.h hdr.h
        !          9258: -refile.o: re.h lre.h
        !          9259: -
        !          9260: -$LIB(%.o):N:  %.o
        !          9261: -
        !          9262: -$LIB:Q:       $LOBJ
        !          9263: -      names=`membername $newprereq`
        !          9264: -      ar rv $target $names && rm $names
        !          9265: -      ranlib $target
        !          9266: -
        !          9267: -export:VQ:
        !          9268: -      what="$SRC hdr.h io.h re.h lre.h libc.h"
        !          9269: -      what="$what getopt.c"           # for those without
        !          9270: -      what="$what `echo regress.d/*` mkfile makefile README"
        !          9271: -      what="$what tmac.an re.3 gre.1 deansify.awk"
        !          9272: -      cp /n/bowell/usr/man/man3/re.3 .
        !          9273: -      cp /n/bowell/usr/man/man1/gre.1 .
        !          9274: -      cp /usr/lib/tmac/tmac.an .
        !          9275: -      cp /usr/include/libc.h .
        !          9276: -      (echo mkdir regress.d; bundle $what) > gre.bundle
        !          9277: -      ls -l gre.bundle
        !          9278: -      rm re.3 libc.h gre.1 tmac.an
        !          9279: -
        !          9280: -%.rcp:V:
        !          9281: -      rcp gre.bundle $stem:/tmp
        !          9282: -      rsh $stem "cd /tmp; rm -fr gre; mkdir gre; cd gre; sh < ../gre.bundle; make regress && (cd ..; rm -fr gre gre.bundle)"
        !          9283: -
        !          9284: -DEPEND:D:     $SRC
        !          9285: -      cdepend $OBJ $LLOBJ > DEPEND
        !          9286: -
        !          9287: -refile:       refile.c $LIB
        !          9288: -      $CC $CFLAGS -DUSE_STDIO -o $target -DMAIN $prereq && rm refile.o
        !          9289: -refile.o:     refile.c
        !          9290: -      $CC $CFLAGS -DUSE_STDIO -c refile.c
        !          9291: -extern:V:     $LIB
        !          9292: -      nm $LIB | egrep -v ' [dtUb] |:| _re| _eg' | sort -u | mc
        !          9293: -
        !          9294: -poot:V:       gre
        !          9295: -      gre -x '.|..' filex
        !          9296: //GO.SYSIN DD mkfile
        !          9297: echo makefile 1>&2
        !          9298: sed 's/.//' >makefile <<'//GO.SYSIN DD makefile'
        !          9299: -CFLAGS=-g -DUSE_STDIO -I. #-p -DPROFILING #
        !          9300: -OBJ=main.o dofgrep.o dogre.o fns.o buffer.o cw.o bm.o eg.o egcomp.o eglit.o egpos.o egstate.o egcw.o egbr.o egmatch.o egcanon.o
        !          9301: -HOBJ=htest.o eg.o egcomp.o eglit.o egpos.o egstate.o egcw.o egbr.o egmatch.o re.o cw.o refile.o egerror.o #dofgrep.o dogre.o fns.o buffer.o cw.o bm.o egcanon.o
        !          9302: -
        !          9303: -gre:  $(OBJ)
        !          9304: -      $(CC) $(CFLAGS) -o gre $(OBJ)
        !          9305: -
        !          9306: -htest:        $(HOBJ)
        !          9307: -      $(CC) $(CFLAGS) -o htest $(HOBJ)
        !          9308: -
        !          9309: -regress:
        !          9310: -      rm -f buffer.o; make CC=$(CC) CFLAGS="$(CFLAGS) -DBUFSIZE=500" gre
        !          9311: -      cd regress.d; make GRE=../gre
        !          9312: -      rm -f buffer.o gre
        !          9313: //GO.SYSIN DD makefile
        !          9314: echo README 1>&2
        !          9315: sed 's/.//' >README <<'//GO.SYSIN DD README'
        !          9316: -installation should be quite easy. set CFLAGS (in makefile)
        !          9317: -to include a -DUSE_STDIO if you want to use stdio. otherwise
        !          9318: -you will need fio. if you have a memmove in your C library,
        !          9319: -use -DMEMMOVE; otherwise it will use memcpy (definition in hdr.h).
        !          9320: -
        !          9321: -a simple regression test can be done by make regress.
        !          9322: -
        !          9323: -the default C compiler is assumed to be ansi compliant (or c++).
        !          9324: -if you don't have one, there is a deansify.awk to help.
        !          9325: -look at the target oregress for how i use it.
        !          9326: -
        !          9327: -bugs to [email protected]
        !          9328: -
        !          9329: -
        !          9330: -things to do:
        !          9331: -      multibyte chars
        !          9332: //GO.SYSIN DD README
        !          9333: echo tmac.an 1>&2
        !          9334: sed 's/.//' >tmac.an <<'//GO.SYSIN DD tmac.an'
        !          9335: -'''\" PWB Manual Entry Macros - 1.36 of 11/11/80
        !          9336: -'''\" Nroff/Troff Version     @(#)1.36
        !          9337: -'''\"  Option -rs1 short (9") pages
        !          9338: -'''\"  Option -rp# set no. of first page, put no. of pgs. on stderr
        !          9339: -'''\"  Option -rd1 give modified date instead of printed date
        !          9340: -.deth
        !          9341: -.tmwrong version of man entry macros - use -man6
        !          9342: -.ab
        !          9343: -..
        !          9344: -.ifn .ds Tm \uTM\d
        !          9345: -.ift .ds Tm \v'-0.5m'\s-4TM\s+4\v'0.5m'
        !          9346: -.de}E
        !          9347: -.}f
        !          9348: -.in\\n()Ru+\\n(INu
        !          9349: -.ll\\n(LLu
        !          9350: -.lt\\n(LLu
        !          9351: -.pl\\n()Lu
        !          9352: -..
        !          9353: -.deDT
        !          9354: -.ift .ta 3.6m 7.2m 10.8m 14.4m 18m 21.6m 25.2m 28.8m 32.4m 36m 39.6m 43.2m 46.8m
        !          9355: -.ifn .ta 5n 10n 15n 20n 25n 30n 35n 40n 45n 50n 55n 60n 65n
        !          9356: -..
        !          9357: -.de HY
        !          9358: -.hy14
        !          9359: -..
        !          9360: -.de}f
        !          9361: -.ift .vs \\n()Vp
        !          9362: -.ps\\n()S
        !          9363: -.ft1
        !          9364: -..
        !          9365: -.de}H
        !          9366: -.ev1
        !          9367: -.}C
        !          9368: -.}E
        !          9369: -.ie\\n()s 'sp |2v
        !          9370: -.el'sp |3v
        !          9371: -.".ps\\n()S-1
        !          9372: -.".iet .bd1 3
        !          9373: -.".el.bd1 0
        !          9374: -.tl \\*(]H\\*(]L\\*(]H
        !          9375: -.bd1
        !          9376: -.ps\\n()S
        !          9377: -.ie\\n()s 'sp 1.5v
        !          9378: -.el'sp 3v
        !          9379: -.ev
        !          9380: -.ns
        !          9381: -.if \\n(CL .2C
        !          9382: -..
        !          9383: -.de}F
        !          9384: -.ev1
        !          9385: -.}E
        !          9386: -.if\\n()s 'sp |\\n(.pu-1v-1p
        !          9387: -.if\\n()t 'sp |\\n(.pu-3v
        !          9388: -.ifn 'sp |\\n(.pu-4v
        !          9389: -.ifn .tl Page %\\*(]D\\*(]W
        !          9390: -.if\\n()s .tl - % -
        !          9391: -.if\\n()t \{.if o .tl Page %\\*(]D\\*(]W
        !          9392: -.ife .tl \\*(]W\\*(]DPage % \}
        !          9393: -.ev
        !          9394: -'bp
        !          9395: -..
        !          9396: -.ifn .ig
        !          9397: -.de}C
        !          9398: -.if "\\*(.T"aps"\{\
        !          9399: -.     po0i
        !          9400: -.     lt7.5i
        !          9401: -.     if\\n()s .tl \l0.25i\l0.25i\h1i\l0.25i
        !          9402: -.     if\\n()t .tl \l0.25i\l0.25i
        !          9403: -.     lt
        !          9404: -.     po\}
        !          9405: -..
        !          9406: -.de}M
        !          9407: -.}N
        !          9408: -.wh-.5p }C
        !          9409: -.ll\\n(LLu
        !          9410: -.}P
        !          9411: -..
        !          9412: -.de}K
        !          9413: -.}N
        !          9414: -.pl1
        !          9415: -.ll\\n(LLu
        !          9416: -..
        !          9417: -.de}P
        !          9418: -.nr )P \\n%+1-\\np
        !          9419: -.if \\nq .tm \\n(.F \\n()P \\np
        !          9420: -.bp
        !          9421: -.if \\nq .nr p \\n%
        !          9422: -..
        !          9423: -.deTH
        !          9424: -.PD
        !          9425: -.nrIN \\n()Mu
        !          9426: -.ift .ds ]H \\$1\^(\^\\$2\^)
        !          9427: -.ifn .ds ]H \\$1(\\$2)
        !          9428: -.if\\n()s .ds ]D
        !          9429: -.if\\n()t .ds ]D Tenth Edition
        !          9430: -.ifn .ds ]D Tenth Edition
        !          9431: -.ds]L
        !          9432: -.if!\\$3 .ds ]L (\^\\$3\^)
        !          9433: -.if!\\$4 .ds ]D \\$4
        !          9434: -.wh0 }H
        !          9435: -.wh-\\n(:mu }F
        !          9436: -.em}M
        !          9437: -.if\\n(nl .}P
        !          9438: -.nr)I \\n()Mu
        !          9439: -.nr)R 0
        !          9440: -.}E
        !          9441: -.DT
        !          9442: -.ifn \{.na
        !          9443: -.nh\}
        !          9444: -.ift \{.bd S 3 3
        !          9445: -.HY \}
        !          9446: -..
        !          9447: -.deSH
        !          9448: -.PD
        !          9449: -.}X 0 "\\$1" smaller
        !          9450: -.nr)E 2
        !          9451: -\&\\$1 \|\\$2 \|\\$3 \|\\$4 \|\\$5 \|\\$6
        !          9452: -..
        !          9453: -.deSS
        !          9454: -.}X 3n "" ""
        !          9455: -.nr)E 2
        !          9456: -\&\\$1 \|\\$2 \|\\$3 \|\\$4 \|\\$5 \|\\$6
        !          9457: -..
        !          9458: -.de}X
        !          9459: -.}E
        !          9460: -.ti\\$1
        !          9461: -.sp\\n(PDu
        !          9462: -.ne1.1v
        !          9463: -.nr)R 0
        !          9464: -.fi
        !          9465: -'''ss12
        !          9466: -'''if\\$2SYNOPSIS .ss 18
        !          9467: -.it1 }N
        !          9468: -.if!\\$3 .SM
        !          9469: -.iet .bd1 3
        !          9470: -.el.bd1 0
        !          9471: -..
        !          9472: -.de}2
        !          9473: -.nr)E 0
        !          9474: -.}E
        !          9475: -.nr)I \\n()Mu
        !          9476: -.ns
        !          9477: -.bd1
        !          9478: -..
        !          9479: -.deSM
        !          9480: -.nh
        !          9481: -.ps\\n()S-1
        !          9482: -.if!\\$1 \&\\$1
        !          9483: -.if!\\$2 \&\\$2
        !          9484: -.if!\\$3 \&\\$3
        !          9485: -.if!\\$4 \&\\$4
        !          9486: -.if!\\$5 \&\\$5
        !          9487: -.if!\\$6 \&\\$6
        !          9488: -.if!\\$1 .ps \\n()S
        !          9489: -.if\\$1 .it 1 }N
        !          9490: -.HY
        !          9491: -..
        !          9492: -.deI
        !          9493: -.nh
        !          9494: -.ft2
        !          9495: -.it1 }N
        !          9496: -.if!\\$1 \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
        !          9497: -.HY
        !          9498: -..
        !          9499: -.deB
        !          9500: -.nh
        !          9501: -.it1 }N
        !          9502: -.ie!\\$1 \%\&\f5\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
        !          9503: -.el .ft5
        !          9504: -.HY
        !          9505: -..
        !          9506: -.deL
        !          9507: -.nh
        !          9508: -.it1 }N
        !          9509: -.ift \{.ie!\\$1 \%\&\f5\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
        !          9510: -.el .ft5 \}
        !          9511: -.ifn \{.ft5
        !          9512: -.if!\\$1 \{.ie\\$2 `\\$1'
        !          9513: -.el .ie\\$3 `\\$1 \\$2'
        !          9514: -.el .ie\\$4 `\\$1 \\$2 \\$3'
        !          9515: -.el .ie\\$5 `\\$1 \\$2 \\$3 \\$4'
        !          9516: -.el .ie\\$6 `\\$1 \\$2 \\$3 \\$4 \\$5'
        !          9517: -.el `\\$1 \\$2 \\$3 \\$4 \\$5 \\$6'\}\}
        !          9518: -.HY
        !          9519: -..
        !          9520: -.deF
        !          9521: -.nh
        !          9522: -.it1 }N
        !          9523: -.ie!\\$1 \%\&\f5\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
        !          9524: -.el .ft5
        !          9525: -.HY
        !          9526: -..
        !          9527: -.deRI
        !          9528: -.nh
        !          9529: -.}S 1 2 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9530: -.HY
        !          9531: -.}f
        !          9532: -..
        !          9533: -.deIR
        !          9534: -.nh
        !          9535: -.}S 2 1 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9536: -.HY
        !          9537: -.}f
        !          9538: -..
        !          9539: -.deIB
        !          9540: -.nh
        !          9541: -.ift .}S 2 5 \%\& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9542: -.ifn .}S 2 1 \%\& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9543: -.HY
        !          9544: -.}f
        !          9545: -..
        !          9546: -.deRB
        !          9547: -.nh
        !          9548: -.ift .}S 1 5 \%\& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9549: -.ifn .}S 1 1 \%\& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9550: -.HY
        !          9551: -.}f
        !          9552: -..
        !          9553: -.deBR
        !          9554: -.nh
        !          9555: -.ift .}S 5 1 \%\& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9556: -.ifn .}S 1 1 \%\& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9557: -.HY
        !          9558: -.}f
        !          9559: -..
        !          9560: -.deBI
        !          9561: -.nh
        !          9562: -.ift .}S 5 2 \%\& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9563: -.ifn .}S 1 2 \%\& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          9564: -.HY
        !          9565: -.}f
        !          9566: -..
        !          9567: -.de LR
        !          9568: -.nh
        !          9569: -.ift \%\&\f5\\$1\f1\\$2
        !          9570: -.ifn \%`\\$1'\\$2
        !          9571: -.HY
        !          9572: -..
        !          9573: -.de RL
        !          9574: -.nh
        !          9575: -.ift \%\&\f1\\$1\\f5\\$2\\f1\\$3
        !          9576: -.ifn \%\\$1`\\$2'\\$3
        !          9577: -.HY
        !          9578: -..
        !          9579: -.de}S
        !          9580: -.ds]F
        !          9581: -.if\\$12 .if !\\$5 .ds ]F \^
        !          9582: -.if\\$22 .if !\\$5 .ds ]F \^
        !          9583: -.ie!\\$4 .}S \\$2 \\$1 "\\$3\f\\$1\\$4\\*(]F" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
        !          9584: -.el\\$3
        !          9585: -.}f
        !          9586: -..
        !          9587: -.deFR
        !          9588: -\%\&\f5\\$1\f1\\$2 \\$3 \\$4 \\$5 \\$6
        !          9589: -..
        !          9590: -.deRF
        !          9591: -\%\&\f1\\$1\f5\\$2\f1\\$3
        !          9592: -..
        !          9593: -.deEX
        !          9594: -.ift .ft5
        !          9595: -.nf
        !          9596: -..
        !          9597: -.deEE
        !          9598: -.ft1
        !          9599: -.fi
        !          9600: -..
        !          9601: -.dePP
        !          9602: -.sp\\n(PDu
        !          9603: -.ne1.1v
        !          9604: -.}E
        !          9605: -.nr)I \\n()Mu
        !          9606: -.ns
        !          9607: -..
        !          9608: -.deP
        !          9609: -.PP
        !          9610: -..
        !          9611: -.deLP
        !          9612: -.PP
        !          9613: -..
        !          9614: -.dePD
        !          9615: -.ift .nr PD .4v
        !          9616: -.ifn .nr PD 1v
        !          9617: -.if!\\$1 .nr PD \\$1v
        !          9618: -..
        !          9619: -.deHP
        !          9620: -.sp\\n(PDu
        !          9621: -.ne1.1v
        !          9622: -.if!\\$1 .nr )I \\$1n
        !          9623: -.ll\\n(LLu
        !          9624: -.in\\n()Ru+\\n(INu+\\n()Iu
        !          9625: -.ti\\n()Ru+\\n(INu
        !          9626: -.}f
        !          9627: -..
        !          9628: -.deIP
        !          9629: -.ie!\\$1 \{.TP "\\$2"
        !          9630: -\&\\$1\}
        !          9631: -.el\{.sp\\n(PDu
        !          9632: -.ne1.1v
        !          9633: -.if!\\$2 .nr )I \\$2n
        !          9634: -.}f
        !          9635: -.ll\\n(LLu
        !          9636: -.in\\n()Ru+\\n(INu+\\n()Iu
        !          9637: -.lg\}
        !          9638: -..
        !          9639: -.deTP
        !          9640: -.if!\\$1 \{.nr )I \\$1n
        !          9641: -.if\\$10 .nr )I \\n()M\}
        !          9642: -.sp\\n(PDu
        !          9643: -.ne1.1v
        !          9644: -.in\\n()Ru
        !          9645: -.lg0
        !          9646: -.ns
        !          9647: -.it1 }N
        !          9648: -.nr)E 1
        !          9649: -.di]B
        !          9650: -..
        !          9651: -.deTF
        !          9652: -.IP "" \w'\f5\\$1\ \ \fP'u
        !          9653: -.PD0
        !          9654: -..
        !          9655: -.de}1
        !          9656: -.ds]X \&\\*(]B\\
        !          9657: -.rm]B
        !          9658: -.nr)E 0
        !          9659: -.if!\\$1 .nr )I \\$1n
        !          9660: -.}f
        !          9661: -.ll\\n(LLu
        !          9662: -.in\\n()Ru+\\n(INu+\\n()Iu
        !          9663: -.ti\\n(INu
        !          9664: -.ie!\\n()Iu+\\n()Ru-\w\\*(]Xu-3p \{\\*(]X
        !          9665: -.br\}
        !          9666: -.el\\*(]X\h|\\n()Iu+\\n()Ru\c
        !          9667: -.}f
        !          9668: -.lg
        !          9669: -..
        !          9670: -.de}N
        !          9671: -.if\\n()E .br
        !          9672: -.if\\n()E1 .di
        !          9673: -.if\\n()E0 .}f
        !          9674: -.if\\n()E1 .}1
        !          9675: -.if\\n()E2 .}2
        !          9676: -..
        !          9677: -.deRS
        !          9678: -.nr]\\n+()p \\n()I
        !          9679: -.nr)\\n()p \\n()R
        !          9680: -.ie!\\$1 .nr )R +\\$1n
        !          9681: -.el.nr )R +\\n()I
        !          9682: -.nr)I \\n()Mu
        !          9683: -.}E
        !          9684: -..
        !          9685: -.deRE
        !          9686: -.if!\\$1 \{.ie \\$10 .nr )p 1 1
        !          9687: -.el.nr )p \\$1 1 \}
        !          9688: -.ds]i \\*(]I\\n()p
        !          9689: -.ds]r \\*(]R\\n()p
        !          9690: -.nr)I \\*(]i
        !          9691: -.nr)R \\*(]r
        !          9692: -.if\\n()p .nr )p -1
        !          9693: -.}E
        !          9694: -..
        !          9695: -'''\" .2C begin 2-column display, by diversion
        !          9696: -'''\"   CC=amount of text that will fit on page
        !          9697: -'''\" CL=1 multicolumn in effect, else 0
        !          9698: -'''\" CI saved indent
        !          9699: -'''\" CB contains diverted text
        !          9700: -.de 2C
        !          9701: -.ne 2
        !          9702: -.nf
        !          9703: -.nr CC \\n(.t/1v*2v
        !          9704: -.nr CI \\n(IN
        !          9705: -.nr IN 0
        !          9706: -.di CB
        !          9707: -.nr CL 1
        !          9708: -.}E
        !          9709: -.dt \\n(CCu C1
        !          9710: -..
        !          9711: -'''\" .1C return to 1-column
        !          9712: -.de 1C
        !          9713: -.nr CL 0
        !          9714: -.C1
        !          9715: -.fi
        !          9716: -..
        !          9717: -'''\" end of diversion, at end of page or return to 1-column
        !          9718: -'''\" CC=pos of nominal column end
        !          9719: -.de C1
        !          9720: -.dt
        !          9721: -\!.C3
        !          9722: -.di
        !          9723: -.if \\n(dn \{.nr CC \\n(dnu/2u+\\n(nlu
        !          9724: -.wh \\n(CCu C2
        !          9725: -.mk
        !          9726: -.nf
        !          9727: -.nr IN \\n(CIu
        !          9728: -.}E
        !          9729: -.CB \}
        !          9730: -..
        !          9731: -'''\" end of first column retrieved from diversion
        !          9732: -'''\" CC=pos of actual column end
        !          9733: -.de C2
        !          9734: -.wh \\n(CCu
        !          9735: -.mk CC
        !          9736: -.po +(\\n(LLu/2u)u
        !          9737: -.rt
        !          9738: -.if \\n(dn>1v .ns
        !          9739: -..
        !          9740: -'''\" end of second column
        !          9741: -.de C3
        !          9742: -.br
        !          9743: -.po -(\\n(LLu/2u)u
        !          9744: -.if \\n(CC>\\n(nl .sp |\\n(CCu
        !          9745: -.ne 2
        !          9746: -..
        !          9747: -.dePM
        !          9748: -.if\\$1 .nr !K 0
        !          9749: -.if\w\\$1 \{\
        !          9750: -.ie\\$1P .nr !K 1
        !          9751: -.el.ie \\$1BP .nr !K 3
        !          9752: -.el.ie \\$1BR .nr !K 4
        !          9753: -.el.nr !K 2 \}
        !          9754: -.if\\n(!K .wh -(\\n(:mu+5v) )G
        !          9755: -..
        !          9756: -.de)G
        !          9757: -.if\\n(!K 'sp 2v
        !          9758: -.ie\\n(!K=1 \{\
        !          9759: -.iet .bd1 3
        !          9760: -.el.bd1 0
        !          9761: -.tlPRIVATE
        !          9762: -.bd1
        !          9763: -.tlThis information should not be disclosed to unauthorized persons.
        !          9764: -.tlIt is meant solely for use by authorized Bell System employees. \}
        !          9765: -.el.ie \\n(!K=3 \{\
        !          9766: -.iet .bd1 3
        !          9767: -.el.bd1 0
        !          9768: -.tlBELL LABORATORIES PROPRIETARY
        !          9769: -.bd1
        !          9770: -.tlNot for use or disclosure outside Bell Laboratories except by
        !          9771: -.tlwritten approval of the director of the distributing organization. \}
        !          9772: -.el.ie \\n(!K=4 \{\
        !          9773: -.iet .bd1 3
        !          9774: -.el.bd1 0
        !          9775: -.tlBELL LABORATORIES RESTRICTED
        !          9776: -.bd1
        !          9777: -.tlThe information herein is meant solely for use by authorized
        !          9778: -.tlBell Laboratories employees and is not to be disclosed to others. \}
        !          9779: -.el.if \\n(!K=2 \{\
        !          9780: -.iet .bd1 3
        !          9781: -.el.bd1 0
        !          9782: -.tlNOTICE
        !          9783: -.bd1
        !          9784: -.tlNot for use or disclosure outside the
        !          9785: -.tlBell System except under written agreement. \}
        !          9786: -..
        !          9787: -.nr)s 0
        !          9788: -.ift .if \ns .nr )s 1
        !          9789: -.nr)t 0
        !          9790: -.ift .if !\ns .nr )t 1
        !          9791: -.if\n()s \{.nr )L 9i
        !          9792: -.nrLL 4.75i
        !          9793: -.nr)O .75i
        !          9794: -.nr)S 9
        !          9795: -.nr)V 10 \}
        !          9796: -.if\n()t \{.nr )L 11i
        !          9797: -.nrLL 6.5i
        !          9798: -.nr)O 1i
        !          9799: -.nr)S 10
        !          9800: -.nr)V 12 \}
        !          9801: -.ift \{.ds R \(rg
        !          9802: -.dsS \s\n()S
        !          9803: -..\}
        !          9804: -.ifn \{.nr )L 11i
        !          9805: -.nrLL 6.5i
        !          9806: -.nr)O .463i
        !          9807: -.if '\*(.T'think' \{.nrLL 80n
        !          9808: -.nr)O 0\}
        !          9809: -.if '\*(.T'thinksmall' \{.nrLL 142n
        !          9810: -.vs 9p
        !          9811: -.nr)O 0\}
        !          9812: -.dsR (Reg.)
        !          9813: -.dsS
        !          9814: -..\}
        !          9815: -.if\nT .nr LL 80n
        !          9816: -.if\nV>1 \{
        !          9817: -.nrLL 82n
        !          9818: -.nr)L 84v
        !          9819: -.rmul \}
        !          9820: -.nr)p 0 1
        !          9821: -.ds]I \\\\n(]
        !          9822: -.ds]R \\\\n()
        !          9823: -.if\nd0 .nr m \n(mo-1
        !          9824: -.if\nm0 .ds ]m January
        !          9825: -.if\nm1 .ds ]m February
        !          9826: -.if\nm2 .ds ]m March
        !          9827: -.if\nm3 .ds ]m April
        !          9828: -.if\nm4 .ds ]m May
        !          9829: -.if\nm5 .ds ]m June
        !          9830: -.if\nm6 .ds ]m July
        !          9831: -.if\nm7 .ds ]m August
        !          9832: -.if\nm8 .ds ]m September
        !          9833: -.if\nm9 .ds ]m October
        !          9834: -.if\nm10 .ds ]m November
        !          9835: -.if\nm11 .ds ]m December
        !          9836: -.ifn \{.nr m \nm+1
        !          9837: -.ie\nd .ds ]W (last mod. \nm/\nd/\ny)
        !          9838: -.el.ds ]W (printed \n(mo/\n(dy/\n(yr)
        !          9839: -..\}
        !          9840: -.if\n()s .ds ]W
        !          9841: -.if\n()t \{.ie \nd .ds ]W \*(]m \nd, 19\ny
        !          9842: -.el.ds ]W \*(]m \n(dy, 19\n(yr
        !          9843: -..\}
        !          9844: -.pl\n()Lu
        !          9845: -.ll\n(LLu
        !          9846: -.lt\n(LLu
        !          9847: -.po\n()Ou
        !          9848: -.fp 5 L CW
        !          9849: -.ift .tr \``\''
        !          9850: -.}f
        !          9851: -.if\n()s .nr :m 3.5v
        !          9852: -.if\n()t .nr :m 6v
        !          9853: -.ifn .nr :m 7v
        !          9854: -.ift .nr )M 3.6m
        !          9855: -.ifn .nr )M 5n
        !          9856: -.em}K
        !          9857: -.nr q \np
        !          9858: -.if!\np .nr p 1
        !          9859: -.pn \np
        !          9860: //GO.SYSIN DD tmac.an
        !          9861: echo re.3 1>&2
        !          9862: sed 's/.//' >re.3 <<'//GO.SYSIN DD re.3'
        !          9863: -.TH RE 3
        !          9864: -.CT 2 data_man
        !          9865: -.SH NAME
        !          9866: -re_bm, re_cw, re_re \(mi string and pattern matching
        !          9867: -.SH SYNOPSIS
        !          9868: -.nf
        !          9869: -.2C
        !          9870: -.B "#include <re.h>"
        !          9871: -.PP
        !          9872: -.B "re_bm *re_bmcomp(b, e, map)"
        !          9873: -.B "char *b, *e;"
        !          9874: -.B "unsigned char map[256];"
        !          9875: -.PP
        !          9876: -.B "int re_bmexec(pat, rdfn, matchfn)"
        !          9877: -.B re_bm *pat;
        !          9878: -.B int (*rdfn)(), (*matchfn)();
        !          9879: -.PP
        !          9880: -.B void re_bmfree(pat);
        !          9881: -.B re_bm *pat;
        !          9882: -.PP
        !          9883: -.BR "re_cw *re_cwinit(map)"
        !          9884: -.B unsigned char map[256];
        !          9885: -.PP
        !          9886: -.BR "void re_cwadd(pat, b, e)"
        !          9887: -.B re_cw *pat;
        !          9888: -.B char *b, *e;
        !          9889: -.PP
        !          9890: -.BR "void re_cwcomp(pat)"
        !          9891: -.B re_cw *pat;
        !          9892: -.PP
        !          9893: -.B "int re_cwexec(pat, rdfn, matchfn)"
        !          9894: -.B re_cw *pat;
        !          9895: -.B int (*rdfn)(), (*matchfn)();
        !          9896: -.PP
        !          9897: -.B void re_cwfree(pat);
        !          9898: -.B re_cw *pat;
        !          9899: -.PP
        !          9900: -.BR "re_re *re_recomp(b, e, map)"
        !          9901: -.B char *b, *e;
        !          9902: -.B unsigned char map[256];
        !          9903: -.PP
        !          9904: -.B "re_reexec(pat, b, e, match)"
        !          9905: -.B re_re *pat;
        !          9906: -.B char *b, *e, *match[10][2];
        !          9907: -.PP
        !          9908: -.B void re_refree(pat);
        !          9909: -.B re_re *pat;
        !          9910: -.PP
        !          9911: -.B void re_error(str);
        !          9912: -.B char *str;
        !          9913: -.1C
        !          9914: -.fi
        !          9915: -.SH DESCRIPTION
        !          9916: -These routines search for patterns in strings.
        !          9917: -The
        !          9918: -.I re_re
        !          9919: -routines search for general regular expressions (defined below)
        !          9920: -using a lazily evaluated deterministic finite automaton.
        !          9921: -The more specialized and faster
        !          9922: -.I re_cw
        !          9923: -routines search for multiple literal strings
        !          9924: -using the Commentz-Walter algorithm.
        !          9925: -The still more specialized and efficient
        !          9926: -.I re_bm
        !          9927: -routines search for a single string using the Boyer-Moore algorithm.
        !          9928: -The routines handle strings designated by pointers to
        !          9929: -the first character of the string
        !          9930: -and to the character following the string.
        !          9931: -.PP
        !          9932: -To use the
        !          9933: -.I re_bm
        !          9934: -routines, first build a recognizer by calling
        !          9935: -.I re_bmcomp,
        !          9936: -which takes the search string and a character map;
        !          9937: -all characters are compared after mapping.
        !          9938: -Typically,
        !          9939: -.I map
        !          9940: -is initialized by a loop similar to
        !          9941: -.EE
        !          9942: -for(i = 0; i < 256; i++) map[i] = i;
        !          9943: -.EX
        !          9944: -and its value is no longer required after the call to
        !          9945: -.I re_bmcomp.
        !          9946: -The recognizer can be run (multiple times) by calling
        !          9947: -.I re_bmexec,
        !          9948: -which stops and returns the first non-positive return from either
        !          9949: -.I rdfn
        !          9950: -or
        !          9951: -.IR matchfn .
        !          9952: -The recognizer calls the supplied function
        !          9953: -.I rdfn
        !          9954: -to obtain input and
        !          9955: -.I matchfn
        !          9956: -to report text matching the search string.
        !          9957: -.PP
        !          9958: -.I Rdfn
        !          9959: -should be declared as
        !          9960: -.IP
        !          9961: -.EX
        !          9962: -int rdfn(pb, pe)
        !          9963: -char **pb, **pe;
        !          9964: -.EE
        !          9965: -.LP
        !          9966: -where
        !          9967: -.B *pb
        !          9968: -and
        !          9969: -.B *pe
        !          9970: -delimit an as yet unprocessed text fragment
        !          9971: -(none if
        !          9972: -.LR *pb==*pe )
        !          9973: -to be saved across the call to
        !          9974: -.IR rdfn .
        !          9975: -On return,
        !          9976: -.B *pb
        !          9977: -and
        !          9978: -.B *pe
        !          9979: -point to the new text, including the saved fragment.
        !          9980: -.I Rdfn
        !          9981: -returns 0 for EOF, negative for error, and positive otherwise.
        !          9982: -The first call to
        !          9983: -.I rdfn
        !          9984: -from each invocation of
        !          9985: -.I re_bmexec
        !          9986: -has
        !          9987: -.BR *pb==0 .
        !          9988: -.PP
        !          9989: -.I Matchfn
        !          9990: -should be declared as
        !          9991: -.IP
        !          9992: -.EX
        !          9993: -int matchfn(pb, pe)
        !          9994: -char **pb, **pe;
        !          9995: -.EE
        !          9996: -.LP
        !          9997: -where
        !          9998: -.B *pb
        !          9999: -and
        !          10000: -.B *pe
        !          10001: -delimit the matched text.
        !          10002: -.I Matchfn
        !          10003: -sets
        !          10004: -.BR *pb ,
        !          10005: -.BR *pe ,
        !          10006: -and returns a value in the same way as
        !          10007: -.I rdfn.
        !          10008: -.PP
        !          10009: -To use the
        !          10010: -.I re_cw
        !          10011: -routines, first build the recognizer by calling
        !          10012: -.IR re_cwinit ,
        !          10013: -then
        !          10014: -.I re_cwadd
        !          10015: -for each string, and finally
        !          10016: -.IR re_cwcomp .
        !          10017: -The recognizer is run by
        !          10018: -.I re_cwexec
        !          10019: -analogously to
        !          10020: -.IR re_bmexec .
        !          10021: -.PP
        !          10022: -A full regular expression recognizer is compiled by
        !          10023: -.I re_recomp
        !          10024: -and executed by
        !          10025: -.I re_reexec,
        !          10026: -which returns 1 if there was a match and 0 if there wasn't.
        !          10027: -The strings that match subexpressions are returned in array
        !          10028: -.I match
        !          10029: -using the above convention.
        !          10030: -.L match[0]
        !          10031: -refers to the whole matched expression.
        !          10032: -If
        !          10033: -.I match
        !          10034: -is zero, then no match delimiters are set.
        !          10035: -.PP
        !          10036: -The routine
        !          10037: -.I re_error
        !          10038: -prints its argument on standard error and exits.
        !          10039: -You may supply your own version for specialized error handling.
        !          10040: -If
        !          10041: -.I re_error
        !          10042: -returns rather than exits, the compiling routines (e.g.
        !          10043: -.IR re_bmcomp )
        !          10044: -will return 0.
        !          10045: -.PP
        !          10046: -The recognizers that these routines construct occupy storage
        !          10047: -obtained from
        !          10048: -.IR malloc (3).
        !          10049: -The storage can be deallocated by
        !          10050: -.I re_refree.
        !          10051: -.SS Regular Expressions
        !          10052: -The syntax for a regular expression
        !          10053: -.B e0
        !          10054: -is
        !          10055: -.EX
        !          10056: -e3:  literal | charclass | '.' | '^' | '$' | '\e'\fIn\fP | '(' e0 ')'
        !          10057: -
        !          10058: -e2:  e3
        !          10059: -  |  e2 REP
        !          10060: -REP: '*' | '+' | '?' | '\e{' RANGE '\e}'
        !          10061: -RANGE: int | int ',' | int ',' int
        !          10062: -
        !          10063: -e1:  e2
        !          10064: -  |  e1 e2
        !          10065: -
        !          10066: -e0:  e1
        !          10067: -  |  e0 ALT e1
        !          10068: -ALT: '|' | newline
        !          10069: -.EE
        !          10070: -.PP
        !          10071: -A literal is any non-metacharacter or a metacharacter
        !          10072: -(one of
        !          10073: -.BR .*+?[]()|\e^$ )
        !          10074: -preceded by 
        !          10075: -.LR \e .
        !          10076: -.PP
        !          10077: -A charclass is a nonempty string
        !          10078: -.I s
        !          10079: -bracketed
        !          10080: -.BI [ \|s\| ]
        !          10081: -(or
        !          10082: -.BI [^ s\| ]\fR);
        !          10083: -it matches any character in (or not in)
        !          10084: -.I s.
        !          10085: -In 
        !          10086: -.I s,
        !          10087: -the metacharacters other than
        !          10088: -.L ]
        !          10089: -have no special meaning, and
        !          10090: -.L ]
        !          10091: -may only appear as
        !          10092: -the first letter.
        !          10093: -A substring 
        !          10094: -.IB a - b ,
        !          10095: -with
        !          10096: -.I a
        !          10097: -and
        !          10098: -.I b
        !          10099: -in ascending
        !          10100: -.SM ASCII 
        !          10101: -order, stands for the inclusive
        !          10102: -range of
        !          10103: -.SM ASCII 
        !          10104: -characters between
        !          10105: -.I a
        !          10106: -and
        !          10107: -.IR b .
        !          10108: -.PP
        !          10109: -A
        !          10110: -.L \e
        !          10111: -followed by a digit 
        !          10112: -.I n
        !          10113: -matches a copy of the string that the
        !          10114: -parenthesized subexpression beginning with the
        !          10115: -.IR n th
        !          10116: -.LR ( ,
        !          10117: -counting from 1, matched.
        !          10118: -.PP
        !          10119: -A 
        !          10120: -.L .
        !          10121: -matches any character.
        !          10122: -.PP
        !          10123: -A
        !          10124: -.L ^
        !          10125: -matches the beginning of the input string;
        !          10126: -.L $
        !          10127: -matches the end.
        !          10128: -.PP
        !          10129: -The 
        !          10130: -.B REP
        !          10131: -operators match zero or more
        !          10132: -.RB ( * ),
        !          10133: -one or more
        !          10134: -.RB ( + ),
        !          10135: -zero or one
        !          10136: -.RB ( ? ),
        !          10137: -exactly
        !          10138: -.I m
        !          10139: -.BI \f1(\fP\e{ m \e}\f1),\fP
        !          10140: -.I m
        !          10141: -or more
        !          10142: -.BI \f1(\fP\e{ m ,\e}\f1),\fP
        !          10143: -and any number between
        !          10144: -.I m
        !          10145: -and
        !          10146: -.I n
        !          10147: -inclusive
        !          10148: -.BI \f1(\fP\e{ m , n \e}\f1),\fP
        !          10149: -instances respectively of the preceding regular expression 
        !          10150: -.BR e2 .
        !          10151: -.PP
        !          10152: -A concatenated regular expression,
        !          10153: -.BR "e1 e2" ,
        !          10154: -matches a match to 
        !          10155: -.B e1
        !          10156: -followed by a match to
        !          10157: -.BR e2 .
        !          10158: -.PP
        !          10159: -An alternative regular expression,
        !          10160: -.BR "e0 ALT e1" ,
        !          10161: -matches either a match to
        !          10162: -.B e0
        !          10163: -or a match to
        !          10164: -.BR e1 .
        !          10165: -.PP
        !          10166: -A match to any part of a regular expression
        !          10167: -extends as far as possible without preventing
        !          10168: -a match to the remainder of the regular expression.
        !          10169: -.SH SEE ALSO
        !          10170: -.IR regexp (3),
        !          10171: -.IR gre (1)
        !          10172: -.SH DIAGNOSTICS
        !          10173: -Routines that return pointers return 0 on error.
        !          10174: -.SH BUGS
        !          10175: -Between 
        !          10176: -.IR re (3)
        !          10177: -and
        !          10178: -.IR regexp (3)
        !          10179: -there are too many routines.
        !          10180: //GO.SYSIN DD re.3
        !          10181: echo gre.1 1>&2
        !          10182: sed 's/.//' >gre.1 <<'//GO.SYSIN DD gre.1'
        !          10183: -.TH GRE 1
        !          10184: -.CT 1 files
        !          10185: -.SH NAME
        !          10186: -gre, grep, egrep, fgrep \(mi search a file for a pattern
        !          10187: -.SH SYNOPSIS
        !          10188: -.B gre
        !          10189: -[
        !          10190: -.I option ...
        !          10191: -]
        !          10192: -.I pattern
        !          10193: -[
        !          10194: -.I file ...
        !          10195: -]
        !          10196: -.PP
        !          10197: -.B grep
        !          10198: -[
        !          10199: -.I option ...
        !          10200: -]
        !          10201: -.I pattern
        !          10202: -[
        !          10203: -.I file ...
        !          10204: -]
        !          10205: -.PP
        !          10206: -.B egrep
        !          10207: -[
        !          10208: -.I option ...
        !          10209: -]
        !          10210: -.I pattern
        !          10211: -[
        !          10212: -.I file ...
        !          10213: -]
        !          10214: -.PP
        !          10215: -.B fgrep
        !          10216: -[
        !          10217: -.I option ...
        !          10218: -]
        !          10219: -.I strings
        !          10220: -[
        !          10221: -.I file ...
        !          10222: -]
        !          10223: -.SH DESCRIPTION
        !          10224: -.I Gre\^
        !          10225: -searches the input
        !          10226: -.I files\^
        !          10227: -(standard input default)
        !          10228: -for lines (with newlines excluded) that match the
        !          10229: -.I pattern,
        !          10230: -a regular expression as defined in
        !          10231: -.IR re (3).
        !          10232: -A file name of
        !          10233: -.B -
        !          10234: -is interpreted as standard input.
        !          10235: -Normally, each line matching the pattern is `selected',
        !          10236: -and each selected line is copied to the standard output.
        !          10237: -The options are
        !          10238: -.TP
        !          10239: -.B -1
        !          10240: -Print only the first selected line of each file argument.
        !          10241: -.PD 0
        !          10242: -.TP
        !          10243: -.B -b
        !          10244: -Mark each printed line with its byte position in its file.
        !          10245: -This is sometimes useful in locating patterns in non-text files.
        !          10246: -.TP
        !          10247: -.B -c
        !          10248: -Print only a count of matching lines.
        !          10249: -.TP
        !          10250: -.BI -e " pattern"
        !          10251: -Same as a simple
        !          10252: -.I pattern
        !          10253: -argument,
        !          10254: -but useful when
        !          10255: -.I pattern
        !          10256: -begins with a
        !          10257: -.BR - .
        !          10258: -.TP
        !          10259: -.B -E
        !          10260: -Simulate
        !          10261: -.IR egrep.
        !          10262: -.TP
        !          10263: -.BI -f " file"
        !          10264: -Read the pattern from
        !          10265: -.IR file ;
        !          10266: -there is no
        !          10267: -.I pattern
        !          10268: -argument
        !          10269: -.TP
        !          10270: -.B -F
        !          10271: -Simulate 
        !          10272: -.IR fgrep.
        !          10273: -.TP
        !          10274: -.B -G
        !          10275: -Simulate 
        !          10276: -.IR grep.
        !          10277: -.TP
        !          10278: -.B -h
        !          10279: -Do not print filename tags (headers) with output lines.
        !          10280: -.TP
        !          10281: -.B -i
        !          10282: -Ignore alphabetic case distinctions.
        !          10283: -.TP
        !          10284: -.B -l
        !          10285: -Print the names of files with selected lines; don't print the lines.
        !          10286: -.TP
        !          10287: -.B -L
        !          10288: -Print the names of files with no selected lines;
        !          10289: -the converse of
        !          10290: -.BR -l .
        !          10291: -.TP
        !          10292: -.B -n
        !          10293: -Mark each printed line with its line number counted in its file.
        !          10294: -.TP
        !          10295: -.B -s
        !          10296: -Produce no output, but return status.
        !          10297: -.TP
        !          10298: -.B -v
        !          10299: -Reverse: print lines that do not match the pattern.
        !          10300: -.TP
        !          10301: -.B -x
        !          10302: -Exact match: The pattern is
        !          10303: -.BI ^( pattern )$ .
        !          10304: -The implicit parentheses count in back references.
        !          10305: -.PD
        !          10306: -.PP
        !          10307: -Output lines are tagged by filename when there is more than one
        !          10308: -input file.
        !          10309: -(To force this tagging, include
        !          10310: -.B /dev/null
        !          10311: -as a filename argument.)
        !          10312: -If the output line exceeds some internal limit,
        !          10313: -a warning is given and a small block of text surrounding the match is printed.
        !          10314: -.PP
        !          10315: -Care should be taken when
        !          10316: -using the shell metacharacters
        !          10317: -.B $*[^|()\e
        !          10318: -and newline
        !          10319: -in
        !          10320: -.IR pattern ;
        !          10321: -it is safest to enclose the
        !          10322: -entire expression
        !          10323: -in single quotes
        !          10324: -.BR \&\|\(fm \|.\|.\|.\| \(fm .
        !          10325: -.PP
        !          10326: -.I Gre
        !          10327: -supplants three classic programs, which are still available:
        !          10328: -.PP
        !          10329: -.I Grep
        !          10330: -handles only
        !          10331: -.IR ed (1)-like
        !          10332: -regular expressions.
        !          10333: -It uses
        !          10334: -.L \e(\|\e)
        !          10335: -instead of
        !          10336: -.LR (\|) .
        !          10337: -.PP
        !          10338: -.I Egrep
        !          10339: -handles the same patterns as
        !          10340: -.I gre
        !          10341: -except for back-referencing with
        !          10342: -.BR \e1 ,
        !          10343: -.BR \e2 ,
        !          10344: -\&...
        !          10345: -.PP
        !          10346: -.I Fgrep
        !          10347: -handles no operators except newline (alternation).
        !          10348: -.SH SEE ALSO
        !          10349: -.IR re (3),
        !          10350: -.IR awk (1),
        !          10351: -.IR sed (1),
        !          10352: -.IR sam (9.1),
        !          10353: -.IR strings (1)
        !          10354: -.SH DIAGNOSTICS
        !          10355: -Exit status is 0 if any lines are selected,
        !          10356: -1 if none, 2 for syntax errors, inaccessible files
        !          10357: -(even if matches were found).
        !          10358: -Warnings will be given for input lines that exceed
        !          10359: -a (generous) internal limit.
        !          10360: -.SH BUGS
        !          10361: -.I Grep, egrep,
        !          10362: -and 
        !          10363: -.I fgrep
        !          10364: -do not support some options and print block numbers
        !          10365: -rather than byte numbers for option
        !          10366: -.BR -b .
        !          10367: //GO.SYSIN DD gre.1
        !          10368: echo deansify.awk 1>&2
        !          10369: sed 's/.//' >deansify.awk <<'//GO.SYSIN DD deansify.awk'
        !          10370: -# De-ANSI-fy C programs
        !          10371: -
        !          10372: -# change void* to char *
        !          10373: -      { gsub(/void *\*/, "char *") }
        !          10374: -
        !          10375: -# remove args from function declarations and typedefs
        !          10376: -# assume one per line (fitting on one line)
        !          10377: -
        !          10378: -/^[a-zA-Z0-9_]+.*\([^(]*\);.*/ {
        !          10379: -      if($0 !~ /^print\(/ && $0 !~ /^fprint\(/ && $0 !~ /^if\(/) {
        !          10380: -              sub(/\([^(]*\);/, "();")
        !          10381: -              print
        !          10382: -              next
        !          10383: -      }
        !          10384: -    }
        !          10385: -
        !          10386: -#    change function definition headers to old-style
        !          10387: -#    function definition headers on one line, ending with ')',
        !          10388: -#       with the return type (if not omitted) on previous line
        !          10389: -#    assume no parentheses inside arg list
        !          10390: -
        !          10391: -/^[a-zA-Z0-9_]+\(.*\)$/ {
        !          10392: -      st = index($0, "(") + 1
        !          10393: -      n = length($0) - st
        !          10394: -      rawargs = substr($0, st, n)
        !          10395: -      printf("%s(", substr($0, 1, st-2))
        !          10396: -      if( rawargs == "void" ) {
        !          10397: -              printf(")\n");
        !          10398: -              next
        !          10399: -      }
        !          10400: -      nargs = split(rawargs, args, ", *")
        !          10401: -      for(i = 1; i <= nargs; i++){
        !          10402: -              if(! match(args[i], /[a-zA-Z0-9_]+ *$/)){
        !          10403: -                      if(! match(args[i], /[a-zA-Z0-9_]+\[.*\]$/))
        !          10404: -                              id = "OOPS"
        !          10405: -                      else {
        !          10406: -                              id = substr(args[i], RSTART)
        !          10407: -                              sub(/\[.*\]/, "", id)
        !          10408: -                      }
        !          10409: -              } else
        !          10410: -                      id = substr(args[i], RSTART, RLENGTH)
        !          10411: -              printf("%s", id)
        !          10412: -              if(i < nargs) printf(", ")
        !          10413: -      }
        !          10414: -      printf(")\n")
        !          10415: -      for(i = 1; i <= nargs; i++)
        !          10416: -              printf("\t%s;\n", args[i])
        !          10417: -      next
        !          10418: -    }
        !          10419: -
        !          10420: -# remove pragmas
        !          10421: -
        !          10422: -/^#[    ]*pragma/ { next }
        !          10423: -
        !          10424: -# just print remaining lines
        !          10425: -      { print }
        !          10426: //GO.SYSIN DD deansify.awk

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.