Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.24
 
1.25
 
MAIN:ragge:20030126223556
 
pftn.c
_>44 
 55 # include "pass1.h"
 66 
<> 7+# include <stdlib.h>
  8+
79 unsigned int offsz;
 810 
 911 struct symtab *schain[MAXSCOPES];       /* sym chains for clearst */
     
 !
989991         }
 990992 }
 991993 
<>992 -static int strarr; /* Current string is written as an array */
 993 -static int instr; /* # of chars written out so far */
 994 -static int lxarg;
 995 -static int strtemp, strlab;
  994+#define MAXNSTRING      1000
  995+static char *strarray[MAXNSTRING];
  996+static int labarray[MAXNSTRING];
  997+static int nstring;
  998+
996999 /*
<>997 - * First element of a string to write.
  1000+ * Write last part of string.
9981001  */
<>999 -void
 1000 -strbeg()
  1002+NODE *
  1003+strend(char *str)
10011004 {
<>1002 -        strarr = lxarg = 0;
  1005+        int lxarg, i, val, strtemp, strlab;
  1006+        char *wr = str;
  1007+        NODE *p;
  1008+
  1009+        i = 0;
10031010         if ((iclass == EXTDEF || iclass==STATIC) &&
 10041011             (pstk->in_t == CHAR || pstk->in_t == UCHAR) &&
<>1005 -            pstk != instack && ISARY(pstk[-1].in_t))
 1006 -                strarr = 1;
 1007 -
 1008 -        if (strarr) {
  1012+            pstk != instack && ISARY(pstk[-1].in_t)) {
10091013                 /* treat "abc" as { 'a', 'b', 'c', 0 } */
 10101014                 ilbrace();  /* simulate { */
 10111015                 inforce(pstk->in_off);
     
 !
10161020                  */
 10171021 
 10181022                 lxarg = (pstk-1) != instack ? dimtab[(pstk-1)->in_d] : 0;
<>1019 -        } else {
 1020 -                /* make a label, and get the contents and stash them away */
 1021 -                if (iclass != SNULL) { /* initializing */
 1022 -                        /* fill out previous word, to permit pointer */
 1023 -                        vfdalign(ALPOINT);
  1023+                while (*wr != 0) {
  1024+                        if (*wr++ == '\\')
  1025+                                val = esccon(&wr);
  1026+                        else
  1027+                                val = wr[-1];
  1028+                        if (lxarg == 0 || i < lxarg)
  1029+                                putbyte(val);
  1030+                        else if (i == lxarg)
  1031+                                werror("non-null byte ignored in string"
  1032+                                    "initializer");
  1033+                        i++;
10241034                 }
<>1025 -                 /* set up location counter */
 1026 -                strtemp = locctr(blevel==0 ? ISTRNG : STRNG);
 1027 -                deflab(strlab = getlab());
 1028 -        }
 1029 -        instr = lxstr(lxarg, strarr, 0);
10301035 
<>1031 -}
 1032 -
 1033 -/*
 1034 - * Write more string elements.
 1035 - */
 1036 -void
 1037 -strcont()
 1038 -{
 1039 -        instr = lxstr(lxarg, strarr, instr);
 1040 -}
 1041 -
 1042 -/*
 1043 - * Write last part of string.
 1044 - */
 1045 -NODE *
 1046 -strend()
 1047 -{
 1048 -        NODE *p;
 1049 -
 1050 -        if (strarr) {
 1051 -                if (lxarg == 0 || instr < lxarg)
  1036+                if (lxarg == 0 || i < lxarg)
10521037                         putbyte(0);
 10531038                 irbrace();  /* simulate } */
<> 1039+                free(str);
10541040                 return(NIL);
 10551041         }
<>1056 -        bycode(0, instr++);
 1057 -        bycode(-1, instr);
 1058 -        dimtab[curdim] = instr; /* in case of later sizeof ... */
 1059 -        (void) locctr(blevel==0 ? ilocctr : strtemp);
  1042+        /* make a label, and get the contents and stash them away */
  1043+        if (iclass != SNULL) { /* initializing */
  1044+                /* fill out previous word, to permit pointer */
  1045+                vfdalign(ALPOINT);
  1046+        }
  1047+        /* If an identical string is already emitted, just forget this one */
  1048+        for (i = 0; i < nstring; i++) {
  1049+                if (strarray[i][0] == *wr && strcmp(strarray[i], wr) == 0)
  1050+                        break;
  1051+        }
  1052+        if (i == nstring) { /* No string */
  1053+                if (nstring == MAXNSTRING) {
  1054+                        cerror("out of string space");
  1055+                        nstring = 0;
  1056+                }
  1057+                 /* set up location counter */
  1058+                strtemp = locctr(blevel==0 ? ISTRNG : STRNG);
  1059+                deflab(strlab = getlab());
  1060+                strarray[nstring] = str;
  1061+                labarray[nstring] = strlab;
  1062+                i = 0;
  1063+                while (*wr != 0) {
  1064+                        if (*wr++ == '\\')
  1065+                                val = esccon(&wr);
  1066+                        else
  1067+                                val = wr[-1];
  1068+                        bycode(val, i);
  1069+                        i++;
  1070+                }
  1071+                bycode(0, i++);
  1072+                bycode(-1, i);
  1073+                (void) locctr(blevel==0 ? ilocctr : strtemp);
  1074+                nstring++;
  1075+        } else {
  1076+                strlab = labarray[i];
  1077+                i = strlen(strarray[i]);
  1078+                free(str);
  1079+        }
  1080+
  1081+        dimtab[curdim] = i; /* in case of later sizeof ... */
10601082         p = buildtree(STRING, NIL, NIL);
 10611083         p->tn.rval = -strlab;
 10621084         return(p);
     
 !
12091231         inforce( pstk->in_off );
 12101232 
 12111233         p = buildtree( ASSIGN, block( NAME, NIL,NIL, t, d, s ), p );
<>1212 -#ifdef LINT
 1213 -        /* force lint to treat this like an assignment */
 1214 -        ecode(p);
 1215 -#endif
12161234         p->in.left->in.op = FREE;
 12171235         p->in.left = p->in.right;
 12181236         p->in.right = NIL;
     
 !
17841802         if( class == PARAM || ( class==REGISTER && blevel==1 ) ){
 17851803                 if( type == FLOAT ) type = DOUBLE;
 17861804                 else if( ISARY(type) ){
<>1787 -#ifdef LINT
 1788 -                        if( hflag && dimtab[p->fn.cdim]!=0 )
 1789 -                                werror("array[%d] type changed to pointer",
 1790 -                                        dimtab[p->fn.cdim]);
 1791 -#endif
17921805                         ++p->fn.cdim;
 17931806                         type += (PTR-ARY);
 17941807                         }
     
 !
21912204         *q = *p;
 21922205         p->sflags |= SHIDDEN;
 21932206         q->sflags = (p->sflags&(SMOS|STAG)) | SHIDES;
<>2194 -        if( hflag ) werror( "%s redefinition hides earlier one", p->sname );
  2207+        if (p->slevel > 0)
  2208+                werror("%s redefinition hides earlier one", p->sname);
<_21952209 # ifndef BUG1
 21962210         if( ddebug ) printf( "  %d hidden in %d\n", p-stab, q-stab );
 21972211 # endif
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-25 15:16 +0100