Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.31
 
1.32
 
MAIN:ragge:20060730093330
 
cpp.c
_>238238                  * Manually move in the predefined macros.
 239239                  */
 240240                 nl = lookup("__TIME__", ENTER);
<> 241+#ifdef ragge
  242+                nl->value = stringbuf;
  243+                savch(OBJCT);
  244+                savch('"'); savstr(&n[11]); n[19] = 0; savch('"'); savch(0);
  245+#else
241246                 savch(0); savch('"');  n[19] = 0; savstr(&n[11]); savch('"');
 242247                 savch(OBJCT);
 243248                 nl->value = stringbuf-1;
<> 249+#endif
244250 
 245251                 nl = lookup("__DATE__", ENTER);
<> 252+#ifdef ragge
  253+                nl->value = stringbuf;
  254+                savch(OBJCT); savch('"') savstr(&n[20]);
  255+                savstr(&n[4]); n[24] = n[11] = 0; savch('"'); savch(0);
  256+#else
246257                 savch(0); savch('"'); n[24] = n[11] = 0; savstr(&n[4]);
 247258                 savstr(&n[20]); savch('"'); savch(OBJCT);
 248259                 nl->value = stringbuf-1;
<> 260+#endif
249261 
 250262                 nl = lookup("__STDC__", ENTER);
<> 263+#ifdef ragge
  264+                nl->value = stringbuf;
  265+                savch(OBJCT); savch('1'); savch(0);
  266+#else
251267                 savch(0); savch('1'); savch(OBJCT);
 252268                 nl->value = stringbuf-1;
<> 269+#endif
253270         }
 254271 
 255272         if (argc == 2) {
     
 !
364381         }
 365382 }
 366383 
<> 384+#if 0
  385+struct noexp {
  386+        struct noexp *prev;
  387+        struct symtab *nl;
  388+};
  389+
367390 /*
<> 391+ * Create a replace list from nl, avoiding to expand bd.
  392+ */
  393+static usch *
  394+replfun(struct symtab *nl, struct noexp *bd, inp...)
  395+{
  396+        usch **args;
  397+
  398+}
  399+
  400+/*
  401+ * Replace the object-type macro nl with its value.
  402+ */
  403+static usch *
  404+replobj(struct symtab *nl, struct noexp *bd, inp...)
  405+{
  406+        usch *base = stringbuf;
  407+
  408+        while ((t = intok(nl->value)) != 0) {
  409+                if (t != IDENT) {
  410+                        wstr(
  411+}
  412+
  413+/*
  414+ * Macro-expand the occurrence of string str with its relacement-list.
  415+ * Return the expanded and replaced string.
  416+ */
  417+static usch *
  418+replace(struct symtab *nl, struct noexp *bd, inp...)
  419+{
  420+        struct noexp n;
  421+
  422+        n.prev = bd;
  423+        n.nl = nl;
  424+
  425+        /* is this macro something we want? */
  426+        if (nl->value[0] == OBJCT)
  427+                return replobj(nl, &n, inp);
  428+        /* search for first ( */
  429+        while ((c = tokget(inp)) == WSPACE || c == NL)
  430+                if (c == NL) /* happens only when read from file */
  431+                        putc('\n', obuf);
  432+        if (c != '(')
  433+                return tokput(c), NULL; /* not correct, ignore */
  434+        return replfun(nl, &n, inp);
  435+}
  436+#endif
  437+
  438+/*
368439  * do something when a '#' is found.
 369440  */
 370441 void
     
 !
617688         struct symtab *np;
 618689         usch *args[MAXARG], *ubuf, *sbeg;
 619690         int c, i, redef;
<> 691+#ifdef ragge
  692+        int mkstr = 0, narg = OBJCT;
  693+#else
620694         int mkstr = 0, narg = -1;
<> 695+#endif
621696 
 622697         np = lookup(yystr, ENTER);
 623698         redef = np->value != NULL;
     
 !
651726                 c = yylex();
 652727 
 653728         /* parse replacement-list, substituting arguments */
<> 729+#ifdef ragge
  730+        savch(narg);
  731+#else
654732         savch('\0');
<> 733+#endif
655734         while (c != NL) {
 656735                 switch (c) {
 657736                 case WSPACE:
     
 !
688767 
 689768                         /* FALLTHROUGH */
 690769                 case IDENT:
<> 770+#ifdef ragge
  771+                        if (narg == OBJCT)
  772+#else
691773                         if (narg < 0)
<> 774+#endif
692775                                 goto id; /* just add it if object */
 693776                         /* check if its an argument */
 694777                         for (i = 0; i < narg; i++)
     
 !
699782                                         error("not argument");
 700783                                 goto id;
 701784                         }
<> 785+#ifdef ragge
  786+                        savch(WARN);
702787                         savch(i);
<> 788+#else
  789+                        savch(i);
703790                         savch(WARN);
<> 791+#endif
704792                         if (mkstr)
 705793                                 savch(SNUFF), mkstr = 0;
 706794                         break;
     
 !
718806                 else
 719807                         break;
 720808         }
<> 809+#ifdef ragge
  810+        savch(0); /* end of macro */
  811+#else
721812         savch(narg < 0 ? OBJCT : narg);
<> 813+#endif
722814         if (redef) {
 723815                 usch *o = np->value, *n = stringbuf-1;
 724816 
     
 !
729821                         error("%s redefined", np->namep);
 730822                 stringbuf = sbeg/* forget this space */
 731823         } else
<> 824+#ifdef ragge
  825+                np->value = sbeg;
  826+#else
732827                 np->value = stringbuf-1;
<> 828+#endif
733829         putc('\n', obuf);
 734830 
 735831 #ifdef CPP_DEBUG
     
 !
741837                         printf("[object]");
 742838                 else
 743839                         printf("[%d]", *w);
<> 840+#ifdef ragge
  841+                while (*++w) {
  842+                        switch (*w) {
  843+                        case WARN: printf("<%d>", *++w); break;
  844+#else
744845                 while (*--w) {
 745846                         switch (*w) {
 746847                         case WARN: printf("<%d>", *--w); break;
<> 848+#endif
747849                         case CONC: printf("<##>"); break;
 748850                         case SNUFF: printf("<\">"); break;
 749851                         default: putchar(*w); break;
     
 !
818920         return(sp->namep ? sp : 0);
 819921 }
 820922 
<> 923+#ifdef ragge
821924 /*
<> 925+ * Scan over a string, copying its contents to the heap until
  926+ * an identifier or an argument is reached. When reached,
  927+ * return a pointer to the object.
  928+ */
  929+static usch *
  930+tokenize(usch *s)
  931+{
  932+        for (; *s; s++) {
  933+                switch (utype[*s] & TOKTYP) {
  934+                case CHSTR: /* char or string constant */
  935+                do {
  936+                        savch(*s);
  937+                }
  938+}
  939+#endif
  940+
  941+#ifdef ragge
  942+/*
  943+ * Replace the symbol sp with its replacement list, macroexpand the list
  944+ * and return the fully replaced list.
  945+ * If substitution fails return NULL.
  946+ */
  947+usch *
  948+subst(struct symtab *sp, struct recur *rp)
  949+#else
  950+/*
822951  * substitute namep for sp->value.
 823952  */
 824953 int
 825954 subst(np, sp, rp)
 826955 char *np;
 827956 struct symtab *sp;
 828957 struct recur *rp;
<> 958+#endif
829959 {
 830960         struct recur rp2;
 831961         register usch *vp, *cp;
     
 !
851981         rp2.next = rp;
 852982         rp2.sp = sp;
 853983 
<> 984+#ifdef ragge
  985+        if (*vp++ != OBJCT) {
  986+#else
854987         if (*vp-- != OBJCT) {
<> 988+#endif
855989                 int gotwarn = 0;
 856990 
 857991                 /* should we be here at all? */
     
 !
8911025                         return 0;
 8921026                 }
 8931027         } else {
<> 1028+#ifdef ragge
  1029+                while ((*vp
  1030+                        tokenize(
  1031+                expmac(&rp2);
  1032+#else
8941033                 cunput(WARN);
 8951034                 cp = vp;
 8961035                 while (*cp) {
     
 !
8991038                         cp--;
 9001039                 }
 9011040                 expmac(&rp2);
<> 1041+#endif
<_9021042         }
 9031043         return 1;
 9041044 }
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-10-02 16:34 +0200