From aa07d08e5c2505d3f9dffe9f07b7f3b8f7ef866a Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 3 May 2003 07:29:29 +0000 Subject: [PATCH] Remove typedefs for uint/uchar/ushort/ulong to avoid compiler warnings on Linux. svn path=/trunk/yasm/; revision=922 --- tools/re2c/actions.c | 44 ++++++++-------- tools/re2c/basics.h | 7 ++- tools/re2c/code.c | 107 ++++++++++++++++++++------------------- tools/re2c/dfa.c | 22 ++++---- tools/re2c/dfa.h | 42 +++++++-------- tools/re2c/globals.h | 6 +-- tools/re2c/ins.h | 6 +-- tools/re2c/re.h | 18 +++---- tools/re2c/re2c-parser.y | 2 +- tools/re2c/scanner.c | 20 ++++---- tools/re2c/scanner.h | 8 +-- tools/re2c/scanner.re | 20 ++++---- tools/re2c/substr.c | 2 +- tools/re2c/substr.h | 18 +++---- tools/re2c/token.h | 10 ++-- tools/re2c/translate.c | 10 ++-- 16 files changed, 172 insertions(+), 170 deletions(-) diff --git a/tools/re2c/actions.c b/tools/re2c/actions.c index 890422d5..83cd2293 100644 --- a/tools/re2c/actions.c +++ b/tools/re2c/actions.c @@ -55,28 +55,28 @@ void showIns(FILE *o, const Ins *i, const Ins *base){ } */ -static uint +static unsigned int AltOp_fixedLength(RegExp *r) { - uint l1 = RegExp_fixedLength(r->d.AltCatOp.exp1); + unsigned int l1 = RegExp_fixedLength(r->d.AltCatOp.exp1); /* XXX? Should be exp2? */ - uint l2 = RegExp_fixedLength(r->d.AltCatOp.exp1); + unsigned int l2 = RegExp_fixedLength(r->d.AltCatOp.exp1); if(l1 != l2 || l1 == ~0u) return ~0; return l1; } -static uint +static unsigned int CatOp_fixedLength(RegExp *r) { - uint l1, l2; + unsigned int l1, l2; if((l1 = RegExp_fixedLength(r->d.AltCatOp.exp1)) != ~0u ) if((l2 = RegExp_fixedLength(r->d.AltCatOp.exp2)) != ~0u) return l1+l2; return ~0; } -uint +unsigned int RegExp_fixedLength(RegExp *r) { switch (r->type) { @@ -98,7 +98,7 @@ void RegExp_calcSize(RegExp *re, Char *rep) { Range *r; - uint c; + unsigned int c; switch (re->type) { case NULLOP: @@ -138,9 +138,9 @@ static void MatchOp_compile(RegExp *re, Char *rep, Ins *i) { Ins *j; - uint bump; + unsigned int bump; Range *r; - uint c; + unsigned int c; i->i.tag = CHAR; i->i.link = &i[re->size]; @@ -209,7 +209,7 @@ static void MatchOp_split(RegExp *re, CharSet *s) { Range *r; - uint c; + unsigned int c; for(r = re->d.match; r; r = r->next){ for(c = r->lb; c < r->ub; ++c){ @@ -328,7 +328,7 @@ static Range *doUnion(Range *r1, Range *r2){ if(r1->ub > s->ub) s->ub = r1->ub; if(!(r1 = r1->next)){ - uint ub = 0; + unsigned int ub = 0; for(; r2 && r2->lb <= s->ub; r2 = r2->next) ub = r2->ub; if(ub > s->ub) @@ -342,7 +342,7 @@ static Range *doUnion(Range *r1, Range *r2){ if(r2->ub > s->ub) s->ub = r2->ub; if(!(r2 = r2->next)){ - uint ub = 0; + unsigned int ub = 0; for(; r1 && r1->lb <= s->ub; r1 = r1->next) ub = r1->ub; if(ub > s->ub) @@ -360,7 +360,7 @@ static Range *doUnion(Range *r1, Range *r2){ static Range *doDiff(Range *r1, Range *r2){ Range *r, *s, **rP = &r; for(; r1; r1 = r1->next){ - uint lb = r1->lb; + unsigned int lb = r1->lb; for(; r2 && r2->ub <= r1->lb; r2 = r2->next); for(; r2 && r2->lb < r1->ub; r2 = r2->next){ if(lb < r2->lb){ @@ -423,9 +423,9 @@ RegExp *mkAlt(RegExp *e1, RegExp *e2){ return doAlt(merge(m1, m2), doAlt(e1, e2)); } -static uchar unescape(SubStr *s){ - uchar c; - uchar v; +static unsigned char unescape(SubStr *s){ + unsigned char c; + unsigned char v; s->len--; if((c = *s->str++) != '\\' || s->len == 0) return xlat[c]; @@ -457,21 +457,21 @@ static uchar unescape(SubStr *s){ } static Range *getRange(SubStr *s){ - uchar lb = unescape(s), ub; + unsigned char lb = unescape(s), ub; if(s->len < 2 || *s->str != '-'){ ub = lb; } else { s->len--; s->str++; ub = unescape(s); if(ub < lb){ - uchar tmp; + unsigned char tmp; tmp = lb; lb = ub; ub = tmp; } } return Range_new(lb, ub+1); } -static RegExp *matchChar(uint c){ +static RegExp *matchChar(unsigned int c){ return RegExp_new_MatchOp(Range_new(c, c+1)); } @@ -498,7 +498,7 @@ RegExp *ranToRE(SubStr s){ } RegExp * -RegExp_new_RuleOp(RegExp *e, RegExp *c, Token *t, uint a) +RegExp_new_RuleOp(RegExp *e, RegExp *c, Token *t, unsigned int a) { RegExp *r = malloc(sizeof(RegExp)); r->type = RULEOP; @@ -539,7 +539,7 @@ static void optimize(Ins *i){ void genCode(FILE *o, RegExp *re){ CharSet cs; - uint j; + unsigned int j; Char rep[nChars]; Ins *ins, *eoi; DFA *dfa; @@ -555,7 +555,7 @@ void genCode(FILE *o, RegExp *re){ cs.ptn[0].nxt = NULL; RegExp_split(re, &cs); /* - for(uint k = 0; k < nChars;){ + for(unsigned int k = 0; k < nChars;){ for(j = k; ++k < nChars && cs.rep[k] == cs.rep[j];); printSpan(cerr, j, k); cerr << "\t" << cs.rep[j] - &cs.ptn[0] << endl; diff --git a/tools/re2c/basics.h b/tools/re2c/basics.h index 48d07820..6eae65a9 100644 --- a/tools/re2c/basics.h +++ b/tools/re2c/basics.h @@ -5,9 +5,8 @@ #define inline __inline__ #endif -typedef unsigned int uint; -typedef unsigned char uchar, byte; -typedef unsigned short ushort, word; -typedef unsigned long ulong, dword; +typedef unsigned char byte; +typedef unsigned short word; +typedef unsigned long dword; #endif diff --git a/tools/re2c/code.c b/tools/re2c/code.c index 10827838..73c21887 100644 --- a/tools/re2c/code.c +++ b/tools/re2c/code.c @@ -13,7 +13,7 @@ void Go_compact(Go *g){ /* arrange so that adjacent spans have different targets */ - uint i = 0, j; + unsigned int i = 0, j; for(j = 1; j < g->nSpans; ++j){ if(g->span[j].to != g->span[i].to){ ++i; g->span[i].to = g->span[j].to; @@ -25,7 +25,7 @@ void Go_compact(Go *g){ void Go_unmap(Go *g, Go *base, State *x){ Span *s = g->span, *b = base->span, *e = &b[base->nSpans]; - uint lb = 0; + unsigned int lb = 0; s->ub = 0; s->to = NULL; for(; b != e; ++b){ @@ -46,9 +46,9 @@ void Go_unmap(Go *g, Go *base, State *x){ g->nSpans = s - g->span; } -static void doGen(Go *g, State *s, uchar *bm, uchar m){ +static void doGen(Go *g, State *s, unsigned char *bm, unsigned char m){ Span *b = g->span, *e = &b[g->nSpans]; - uint lb = 0; + unsigned int lb = 0; for(; b < e; ++b){ if(b->to == s) for(; lb < b->ub; ++lb) bm[lb] |= m; @@ -58,7 +58,7 @@ static void doGen(Go *g, State *s, uchar *bm, uchar m){ #if 0 static void prt(FILE *o, Go *g, State *s){ Span *b = g->span, *e = &b[g->nSpans]; - uint lb = 0; + unsigned int lb = 0; for(; b < e; ++b){ if(b->to == s) printSpan(o, lb, b->ub); @@ -68,9 +68,9 @@ static void prt(FILE *o, Go *g, State *s){ #endif static int matches(Go *g1, State *s1, Go *g2, State *s2){ Span *b1 = g1->span, *e1 = &b1[g1->nSpans]; - uint lb1 = 0; + unsigned int lb1 = 0; Span *b2 = g2->span, *e2 = &b2[g2->nSpans]; - uint lb2 = 0; + unsigned int lb2 = 0; for(;;){ for(; b1 < e1 && b1->to != s1; ++b1) lb1 = b1->ub; for(; b2 < e2 && b2->to != s2; ++b2) lb2 = b2->ub; @@ -85,13 +85,13 @@ typedef struct BitMap { Go *go; State *on; struct BitMap *next; - uint i; - uchar m; + unsigned int i; + unsigned char m; } BitMap; static BitMap *BitMap_find_go(Go*, State*); static BitMap *BitMap_find(State*); -static void BitMap_gen(FILE *, uint, uint); +static void BitMap_gen(FILE *, unsigned int, unsigned int); /* static void BitMap_stats(void);*/ static BitMap *BitMap_new(Go*, State*); @@ -128,24 +128,24 @@ BitMap_find(State *x){ return NULL; } -void BitMap_gen(FILE *o, uint lb, uint ub){ +void BitMap_gen(FILE *o, unsigned int lb, unsigned int ub){ BitMap *b = BitMap_first; if(b){ - uint n = ub - lb; - uint i; - uchar *bm = malloc(sizeof(uchar)*n); + unsigned int n = ub - lb; + unsigned int i; + unsigned char *bm = malloc(sizeof(unsigned char)*n); memset(bm, 0, n); fputs("\tstatic unsigned char yybm[] = {", o); for(i = 0; b; i += n){ - uchar m; - uint j; + unsigned char m; + unsigned int j; for(m = 0x80; b && m; b = b->next, m >>= 1){ b->i = i; b->m = m; doGen(b->go, b->on, bm-lb, m); } for(j = 0; j < n; ++j){ if(j%8 == 0) {fputs("\n\t", o); oline++;} - fprintf(o, "%3u, ", (uint) bm[j]); + fprintf(o, "%3u, ", (unsigned int) bm[j]); } } fputs("\n\t};\n", o); oline+=2; @@ -154,7 +154,7 @@ void BitMap_gen(FILE *o, uint lb, uint ub){ #if 0 void BitMap_stats(void){ - uint n = 0; + unsigned int n = 0; BitMap *b; for(b = BitMap_first; b; b = b->next){ prt(stderr, b->go, b->on); fputs("\n", stderr); @@ -169,18 +169,18 @@ static void genGoTo(FILE *o, State *to){ fprintf(o, "\tgoto yy%u;\n", to->label); oline++; } -static void genIf(FILE *o, const char *cmp, uint v){ +static void genIf(FILE *o, const char *cmp, unsigned int v){ fprintf(o, "\tif(yych %s '", cmp); prtCh(o, v); fputs("')", o); } -static void indent(FILE *o, uint i){ +static void indent(FILE *o, unsigned int i){ while(i-- > 0) fputc('\t', o); } -static void need(FILE *o, uint n){ +static void need(FILE *o, unsigned int n){ if(n == 1) { fputs("\tif(YYLIMIT == YYCURSOR) YYFILL(1);\n", o); oline++; } else { @@ -194,8 +194,8 @@ void Action_emit(Action *a, FILE *o) { int first = 1; - uint i; - uint back; + unsigned int i; + unsigned int back; switch (a->type) { case MATCHACT: @@ -256,7 +256,7 @@ Action_emit(Action *a, FILE *o) } Action * -Action_new_Accept(State *x, uint n, uint *s, State **r) +Action_new_Accept(State *x, unsigned int n, unsigned int *s, State **r) { Action *a = malloc(sizeof(Action)); a->type = ACCEPTACT; @@ -268,7 +268,8 @@ Action_new_Accept(State *x, uint n, uint *s, State **r) return a; } -static void doLinear(FILE *o, uint i, Span *s, uint n, State *next){ +static void doLinear(FILE *o, unsigned int i, Span *s, unsigned int n, + State *next){ for(;;){ State *bg = s[0].to; while(n >= 3 && s[2].to == bg && (s[1].ub - s[0].ub) == 1){ @@ -300,7 +301,7 @@ Go_genLinear(Go *g, FILE *o, State *next){ doLinear(o, 0, g->span, g->nSpans, next); } -static void genCases(FILE *o, uint lb, Span *s){ +static void genCases(FILE *o, unsigned int lb, Span *s){ if(lb < s->ub){ for(;;){ fputs("\tcase '", o); prtCh(o, lb); fputs("':", o); @@ -318,7 +319,7 @@ Go_genSwitch(Go *g, FILE *o, State *next){ } else { State *def = g->span[g->nSpans-1].to; Span **sP = malloc(sizeof(Span*)*(g->nSpans-1)), **r, **s, **t; - uint i; + unsigned int i; t = &sP[0]; for(i = 0; i < g->nSpans; ++i) @@ -351,11 +352,12 @@ Go_genSwitch(Go *g, FILE *o, State *next){ } } -static void doBinary(FILE *o, uint i, Span *s, uint n, State *next){ +static void doBinary(FILE *o, unsigned int i, Span *s, unsigned int n, + State *next){ if(n <= 4){ doLinear(o, i, s, n, next); } else { - uint h = n/2; + unsigned int h = n/2; indent(o, i); genIf(o, "<=", s[h-1].ub - 1); fputs("{\n", o); oline++; doBinary(o, i+1, &s[0], h, next); indent(o, i); fputs("\t} else {\n", o); oline++; @@ -379,7 +381,7 @@ Go_genBase(Go *g, FILE *o, State *next){ } if(g->nSpans > 8){ Span *bot = &g->span[0], *top = &g->span[g->nSpans-1]; - uint util; + unsigned int util; if(bot[0].to == top[0].to){ util = (top[-1].ub - bot[0].ub)/(g->nSpans - 2); } else { @@ -403,7 +405,7 @@ Go_genBase(Go *g, FILE *o, State *next){ void Go_genGoto(Go *g, FILE *o, State *next){ - uint i; + unsigned int i; if(bFlag){ for(i = 0; i < g->nSpans; ++i){ State *to = g->span[i].to; @@ -413,7 +415,8 @@ Go_genGoto(Go *g, FILE *o, State *next){ Go go; go.span = malloc(sizeof(Span)*g->nSpans); Go_unmap(&go, g, to); - fprintf(o, "\tif(yybm[%u+yych] & %u)", b->i, (uint) b->m); + fprintf(o, "\tif(yybm[%u+yych] & %u)", b->i, + (unsigned int) b->m); genGoTo(o, to); Go_genBase(&go, o, next); free(go.span); @@ -430,9 +433,9 @@ void State_emit(State *s, FILE *o){ Action_emit(s->action, o); } -static uint merge(Span *x0, State *fg, State *bg){ +static unsigned int merge(Span *x0, State *fg, State *bg){ Span *x = x0, *f = fg->go.span, *b = bg->go.span; - uint nf = fg->go.nSpans, nb = bg->go.nSpans; + unsigned int nf = fg->go.nSpans, nb = bg->go.nSpans; State *prev = NULL, *to; /* NB: we assume both spans are for same range */ for(;;){ @@ -471,26 +474,26 @@ static uint merge(Span *x0, State *fg, State *bg){ } } -const uint cInfinity = ~0; +const unsigned int cInfinity = ~0; typedef struct SCC { State **top, **stk; } SCC; -static void SCC_init(SCC*, uint); -static SCC *SCC_new(uint); +static void SCC_init(SCC*, unsigned int); +static SCC *SCC_new(unsigned int); static void SCC_destroy(SCC*); static void SCC_delete(SCC*); static void SCC_traverse(SCC*, State*); static inline void -SCC_init(SCC *s, uint size) +SCC_init(SCC *s, unsigned int size) { s->top = s->stk = malloc(sizeof(State*)*size); } static inline SCC * -SCC_new(uint size){ +SCC_new(unsigned int size){ SCC *s = malloc(sizeof(SCC)); s->top = s->stk = malloc(sizeof(State*)*size); return s; @@ -508,7 +511,7 @@ SCC_delete(SCC *s){ } static void SCC_traverse(SCC *s, State *x){ - uint k, i; + unsigned int k, i; *s->top = x; k = ++s->top - s->stk; @@ -529,12 +532,12 @@ static void SCC_traverse(SCC *s, State *x){ } while(*s->top != x); } -static uint maxDist(State *s){ - uint mm = 0, i; +static unsigned int maxDist(State *s){ + unsigned int mm = 0, i; for(i = 0; i < s->go.nSpans; ++i){ State *t = s->go.span[i].to; if(t){ - uint m = 1; + unsigned int m = 1; if(!t->link) m += maxDist(t); if(m > mm) @@ -548,7 +551,7 @@ static void calcDepth(State *head){ State *t, *s; for(s = head; s; s = s->next){ if(s->link == s){ - uint i; + unsigned int i; for(i = 0; i < s->go.nSpans; ++i){ t = s->go.span[i].to; if(t && t->link == s) @@ -596,12 +599,12 @@ void DFA_split(DFA *d, State *s){ } void DFA_emit(DFA *d, FILE *o){ - static uint label = 0; + static unsigned int label = 0; State *s; - uint i; - uint nRules = 0; - uint nSaves = 0; - uint *saves; + unsigned int i; + unsigned int nRules = 0; + unsigned int nSaves = 0; + unsigned int *saves; State **rules; State *accept = NULL; Span *span; @@ -614,8 +617,8 @@ void DFA_emit(DFA *d, FILE *o){ if(s->rule && s->rule->d.RuleOp.accept >= nRules) nRules = s->rule->d.RuleOp.accept + 1; - saves = malloc(sizeof(uint)*nRules); - memset(saves, ~0, (nRules)*sizeof(uint)); + saves = malloc(sizeof(unsigned int)*nRules); + memset(saves, ~0, (nRules)*sizeof(unsigned int)); /* mark backtracking points */ for(s = d->head; s; s = s->next){ @@ -684,7 +687,7 @@ void DFA_emit(DFA *d, FILE *o){ for(i = 0; i < s->go.nSpans; ++i){ State *to = s->go.span[i].to; if(to && to->isBase){ - uint nSpans; + unsigned int nSpans; to = to->go.span[0].to; nSpans = merge(span, s, to); if(nSpans < s->go.nSpans){ diff --git a/tools/re2c/dfa.c b/tools/re2c/dfa.c index e3e6d83c..356604ee 100644 --- a/tools/re2c/dfa.c +++ b/tools/re2c/dfa.c @@ -9,8 +9,8 @@ #define octCh(c) ('0' + c%8) -void prtCh(FILE *o, uchar c){ - uchar oc = talx[c]; +void prtCh(FILE *o, unsigned char c){ + unsigned char oc = talx[c]; switch(oc){ case '\'': fputs("\\'", o); break; case '\n': fputs("\\n", o); break; @@ -29,7 +29,7 @@ void prtCh(FILE *o, uchar c){ } } -void printSpan(FILE *o, uint lb, uint ub){ +void printSpan(FILE *o, unsigned int lb, unsigned int ub){ if(lb > ub) fputc('*', o); fputc('[', o); @@ -43,8 +43,8 @@ void printSpan(FILE *o, uint lb, uint ub){ fputc(']', o); } -uint -Span_show(Span *s, FILE *o, uint lb) +unsigned int +Span_show(Span *s, FILE *o, unsigned int lb) { if(s->to){ printSpan(o, lb, s->ub); @@ -55,7 +55,7 @@ Span_show(Span *s, FILE *o, uint lb) void State_out(FILE *o, const State *s){ - uint lb, i; + unsigned int lb, i; fprintf(o, "state %u", s->label); if(s->rule) fprintf(o, " accepts %u", s->rule->d.RuleOp.accept); @@ -119,11 +119,11 @@ typedef struct GoTo { } GoTo; DFA * -DFA_new(Ins *ins, uint ni, uint lb, uint ub, Char *rep) +DFA_new(Ins *ins, unsigned int ni, unsigned int lb, unsigned int ub, Char *rep) { DFA *d = malloc(sizeof(DFA)); Ins **work = malloc(sizeof(Ins*)*(ni+1)); - uint nc = ub - lb; + unsigned int nc = ub - lb; GoTo *goTo = malloc(sizeof(GoTo)*nc); Span *span = malloc(sizeof(Span)*nc); @@ -139,8 +139,8 @@ DFA_new(Ins *ins, uint ni, uint lb, uint ub, Char *rep) State *s = d->toDo; Ins **cP, **iP, *i; - uint nGoTos = 0; - uint j; + unsigned int nGoTos = 0; + unsigned int j; d->toDo = s->link; s->rule = NULL; @@ -208,7 +208,7 @@ void DFA_addState(DFA *d, State **a, State *s){ d->tail = &s->next; } -State *DFA_findState(DFA *d, Ins **kernel, uint kCount){ +State *DFA_findState(DFA *d, Ins **kernel, unsigned int kCount){ Ins **cP, **iP, *i; State *s; diff --git a/tools/re2c/dfa.h b/tools/re2c/dfa.h index 6b4e8be9..24db87f0 100644 --- a/tools/re2c/dfa.h +++ b/tools/re2c/dfa.h @@ -4,8 +4,8 @@ #include #include "tools/re2c/re.h" -extern void prtCh(FILE *, uchar); -extern void printSpan(FILE *, uint, uint); +extern void prtCh(FILE *, unsigned char); +extern void printSpan(FILE *, unsigned int, unsigned int); struct DFA; struct State; @@ -24,13 +24,13 @@ typedef struct Action { ActionType type; union { /* data for Enter */ - uint label; + unsigned int label; /* data for SaveMatch */ - uint selector; + unsigned int selector; /* data for Accept */ struct { - uint nRules; - uint *saves; + unsigned int nRules; + unsigned int *saves; struct State **rules; } Accept; /* data for Rule */ @@ -41,26 +41,26 @@ typedef struct Action { void Action_emit(Action*, FILE *); typedef struct Span { - uint ub; + unsigned int ub; struct State *to; } Span; -uint Span_show(Span*, FILE *, uint); +unsigned int Span_show(Span*, FILE *, unsigned int); typedef struct Go { - uint nSpans; + unsigned int nSpans; Span *span; } Go; typedef struct State { - uint label; + unsigned int label; RegExp *rule; /* RuleOp */ struct State *next; struct State *link; - uint depth; /* for finding SCCs */ - uint kCount; + unsigned int depth; /* for finding SCCs */ + unsigned int kCount; Ins **kernel; - uint isBase:1; + unsigned int isBase:1; Go go; Action *action; } State; @@ -79,17 +79,17 @@ void State_emit(State*, FILE *); void State_out(FILE *, const State*); typedef struct DFA { - uint lbChar; - uint ubChar; - uint nStates; + unsigned int lbChar; + unsigned int ubChar; + unsigned int nStates; State *head, **tail; State *toDo; } DFA; -DFA *DFA_new(Ins*, uint, uint, uint, Char*); +DFA *DFA_new(Ins*, unsigned int, unsigned int, unsigned int, Char*); void DFA_delete(DFA*); void DFA_addState(DFA*, State**, State*); -State *DFA_findState(DFA*, Ins**, uint); +State *DFA_findState(DFA*, Ins**, unsigned int); void DFA_split(DFA*, State*); void DFA_findSCCs(DFA*); @@ -107,7 +107,7 @@ Action_new_Match(State *s) } static inline Action * -Action_new_Enter(State *s, uint l) +Action_new_Enter(State *s, unsigned int l) { Action *a = malloc(sizeof(Action)); a->type = ENTERACT; @@ -118,7 +118,7 @@ Action_new_Enter(State *s, uint l) } static inline Action * -Action_new_Save(State *s, uint i) +Action_new_Save(State *s, unsigned int i) { Action *a = malloc(sizeof(Action)); a->type = SAVEMATCHACT; @@ -138,7 +138,7 @@ Action_new_Move(State *s) return a; } -Action *Action_new_Accept(State*, uint, uint*, State**); +Action *Action_new_Accept(State*, unsigned int, unsigned int*, State**); static inline Action * Action_new_Rule(State *s, RegExp *r) /* RuleOp */ diff --git a/tools/re2c/globals.h b/tools/re2c/globals.h index 676a9fd1..9900da58 100644 --- a/tools/re2c/globals.h +++ b/tools/re2c/globals.h @@ -8,9 +8,9 @@ extern int sFlag; extern int bFlag; extern unsigned int oline; -extern uchar asc2ebc[256]; -extern uchar ebc2asc[256]; +extern unsigned char asc2ebc[256]; +extern unsigned char ebc2asc[256]; -extern uchar *xlat, *talx; +extern unsigned char *xlat, *talx; #endif diff --git a/tools/re2c/ins.h b/tools/re2c/ins.h index 0fc6ee00..4bf447d0 100644 --- a/tools/re2c/ins.h +++ b/tools/re2c/ins.h @@ -4,7 +4,7 @@ #include "tools/re2c/basics.h" #define nChars 256 -typedef uchar Char; +typedef unsigned char Char; #define CHAR 0 #define GOTO 1 @@ -19,8 +19,8 @@ typedef union Ins { void *link; } i; struct { - ushort value; - ushort bump; + unsigned short value; + unsigned short bump; void *link; } c; } Ins; diff --git a/tools/re2c/re.h b/tools/re2c/re.h index 6c87d10d..9503897e 100644 --- a/tools/re2c/re.h +++ b/tools/re2c/re.h @@ -6,7 +6,7 @@ #include "tools/re2c/ins.h" typedef struct CharPtn { - uint card; + unsigned int card; struct CharPtn *fix; struct CharPtn *nxt; } CharPtn; @@ -20,11 +20,11 @@ typedef struct CharSet { typedef struct Range { struct Range *next; - uint lb, ub; /* [lb,ub) */ + unsigned int lb, ub; /* [lb,ub) */ } Range; static inline void -Range_init(Range *r, uint l, uint u) +Range_init(Range *r, unsigned int l, unsigned int u) { r->next = NULL; r->lb = l; @@ -32,7 +32,7 @@ Range_init(Range *r, uint l, uint u) } static inline Range * -Range_new(uint l, uint u) +Range_new(unsigned int l, unsigned int u) { Range *r = malloc(sizeof(Range)); r->next = NULL; @@ -72,7 +72,7 @@ typedef enum { typedef struct RegExp { RegExpType type; - uint size; + unsigned int size; union { /* for MatchOp */ Range *match; @@ -81,9 +81,9 @@ typedef struct RegExp { struct RegExp *exp; struct RegExp *ctx; Ins *ins; - uint accept; + unsigned int accept; Token *code; - uint line; + unsigned int line; } RuleOp; /* for AltOp and CatOp*/ struct { @@ -102,7 +102,7 @@ RegExp_isA(RegExp *r, RegExpType t) void RegExp_split(RegExp*, CharSet*); void RegExp_calcSize(RegExp*, Char*); -uint RegExp_fixedLength(RegExp*); +unsigned int RegExp_fixedLength(RegExp*); void RegExp_compile(RegExp*, Char*, Ins*); void RegExp_display(RegExp*, FILE *); @@ -123,7 +123,7 @@ RegExp_new_MatchOp(Range *m) return r; } -RegExp *RegExp_new_RuleOp(RegExp*, RegExp*, Token*, uint); +RegExp *RegExp_new_RuleOp(RegExp*, RegExp*, Token*, unsigned int); static inline RegExp * RegExp_new_AltOp(RegExp *e1, RegExp *e2) diff --git a/tools/re2c/re2c-parser.y b/tools/re2c/re2c-parser.y index 374d4f23..6885a017 100644 --- a/tools/re2c/re2c-parser.y +++ b/tools/re2c/re2c-parser.y @@ -12,7 +12,7 @@ void yyerror(const char*); static char *mystrdup(const char *str); -static uint accept; +static unsigned int accept; static RegExp *spec; static Scanner *in; diff --git a/tools/re2c/scanner.c b/tools/re2c/scanner.c index 1467de3c..436a5a4e 100644 --- a/tools/re2c/scanner.c +++ b/tools/re2c/scanner.c @@ -12,7 +12,7 @@ #define BSIZE 8192 -#define YYCTYPE uchar +#define YYCTYPE unsigned char #define YYCURSOR cursor #define YYLIMIT s->lim #define YYMARKER s->ptr @@ -20,7 +20,7 @@ #define RETURN(i) {s->cur = cursor; return i;} -static uchar *fill(Scanner*, uchar*); +static unsigned char *fill(Scanner*, unsigned char*); void Scanner_init(Scanner *s, FILE *i) @@ -32,11 +32,11 @@ Scanner_init(Scanner *s, FILE *i) s->cline = 1; } -static uchar * -fill(Scanner *s, uchar *cursor) +static unsigned char * +fill(Scanner *s, unsigned char *cursor) { if(!s->eof){ - uint cnt = s->tok - s->bot; + unsigned int cnt = s->tok - s->bot; if(cnt){ memcpy(s->bot, s->tok, s->lim - s->tok); s->tok = s->bot; @@ -46,7 +46,7 @@ fill(Scanner *s, uchar *cursor) s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ - uchar *buf = malloc(sizeof(uchar)*((s->lim - s->bot) + BSIZE)); + unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE)); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot]; @@ -58,7 +58,7 @@ fill(Scanner *s, uchar *cursor) free(s->bot); s->bot = buf; } - if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){ + if((cnt = fread(s->lim, 1, BSIZE, s->in)) != BSIZE){ s->eof = &s->lim[cnt]; *s->eof++ = '\n'; } s->lim += cnt; @@ -72,7 +72,7 @@ fill(Scanner *s, uchar *cursor) int Scanner_echo(Scanner *s, FILE *out) { - uchar *cursor = s->cur; + unsigned char *cursor = s->cur; s->tok = cursor; echo: @@ -134,8 +134,8 @@ yy9: yych = *++YYCURSOR; int Scanner_scan(Scanner *s) { - uchar *cursor = s->cur; - uint depth; + unsigned char *cursor = s->cur; + unsigned int depth; scan: s->tchar = cursor - s->pos; diff --git a/tools/re2c/scanner.h b/tools/re2c/scanner.h index 2c2d0200..9a997af1 100644 --- a/tools/re2c/scanner.h +++ b/tools/re2c/scanner.h @@ -6,8 +6,8 @@ typedef struct Scanner { FILE *in; - uchar *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof; - uint tchar, tline, cline; + unsigned char *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof; + unsigned int tchar, tline, cline; } Scanner; void Scanner_init(Scanner*, FILE *); @@ -17,7 +17,7 @@ int Scanner_echo(Scanner*, FILE *); int Scanner_scan(Scanner*); void Scanner_fatal(Scanner*, const char*); static inline SubStr Scanner_token(Scanner*); -static inline uint Scanner_line(Scanner*); +static inline unsigned int Scanner_line(Scanner*); static inline SubStr Scanner_token(Scanner *s) @@ -27,7 +27,7 @@ Scanner_token(Scanner *s) return r; } -static inline uint +static inline unsigned int Scanner_line(Scanner *s) { return s->cline; diff --git a/tools/re2c/scanner.re b/tools/re2c/scanner.re index 5897271d..13bf62e0 100644 --- a/tools/re2c/scanner.re +++ b/tools/re2c/scanner.re @@ -9,7 +9,7 @@ #define BSIZE 8192 -#define YYCTYPE uchar +#define YYCTYPE unsigned char #define YYCURSOR cursor #define YYLIMIT s->lim #define YYMARKER s->ptr @@ -17,7 +17,7 @@ #define RETURN(i) {s->cur = cursor; return i;} -static uchar *fill(Scanner*, uchar*); +static unsigned char *fill(Scanner*, unsigned char*); void Scanner_init(Scanner *s, FILE *i) @@ -29,11 +29,11 @@ Scanner_init(Scanner *s, FILE *i) s->cline = 1; } -static uchar * -fill(Scanner *s, uchar *cursor) +static unsigned char * +fill(Scanner *s, unsigned char *cursor) { if(!s->eof){ - uint cnt = s->tok - s->bot; + unsigned int cnt = s->tok - s->bot; if(cnt){ memcpy(s->bot, s->tok, s->lim - s->tok); s->tok = s->bot; @@ -43,7 +43,7 @@ fill(Scanner *s, uchar *cursor) s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ - uchar *buf = malloc(sizeof(uchar)*((s->lim - s->bot) + BSIZE)); + unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE)); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot]; @@ -55,7 +55,7 @@ fill(Scanner *s, uchar *cursor) free(s->bot); s->bot = buf; } - if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){ + if((cnt = fread(s->lim, 1, BSIZE, s->in)) != BSIZE){ s->eof = &s->lim[cnt]; *s->eof++ = '\n'; } s->lim += cnt; @@ -77,7 +77,7 @@ digit = [0-9]; int Scanner_echo(Scanner *s, FILE *out) { - uchar *cursor = s->cur; + unsigned char *cursor = s->cur; s->tok = cursor; echo: /*!re2c @@ -96,8 +96,8 @@ echo: int Scanner_scan(Scanner *s) { - uchar *cursor = s->cur; - uint depth; + unsigned char *cursor = s->cur; + unsigned int depth; scan: s->tchar = cursor - s->pos; diff --git a/tools/re2c/substr.c b/tools/re2c/substr.c index 57558b2c..476d25ec 100644 --- a/tools/re2c/substr.c +++ b/tools/re2c/substr.c @@ -62,6 +62,6 @@ Str_new_empty(void) void Str_delete(Str *s) { free(s->str); s->str = (char*)-1; - s->len = (uint)-1; + s->len = (unsigned int)-1; free(s); } diff --git a/tools/re2c/substr.h b/tools/re2c/substr.h index 6bf82b44..93498344 100644 --- a/tools/re2c/substr.h +++ b/tools/re2c/substr.h @@ -7,18 +7,18 @@ struct SubStr { char *str; - uint len; + unsigned int len; }; typedef struct SubStr SubStr; int SubStr_eq(const SubStr *, const SubStr *); -static inline void SubStr_init_u(SubStr*, uchar*, uint); -static inline SubStr *SubStr_new_u(uchar*, uint); +static inline void SubStr_init_u(SubStr*, unsigned char*, unsigned int); +static inline SubStr *SubStr_new_u(unsigned char*, unsigned int); -static inline void SubStr_init(SubStr*, char*, uint); -static inline SubStr *SubStr_new(char*, uint); +static inline void SubStr_init(SubStr*, char*, unsigned int); +static inline SubStr *SubStr_new(char*, unsigned int); static inline void SubStr_copy(SubStr*, const SubStr*); static inline SubStr *SubStr_new_copy(const SubStr*); @@ -39,14 +39,14 @@ void Str_destroy(Str *); void Str_delete(Str *); static inline void -SubStr_init_u(SubStr *r, uchar *s, uint l) +SubStr_init_u(SubStr *r, unsigned char *s, unsigned int l) { r->str = (char*)s; r->len = l; } static inline SubStr * -SubStr_new_u(uchar *s, uint l) +SubStr_new_u(unsigned char *s, unsigned int l) { SubStr *r = malloc(sizeof(SubStr)); r->str = (char*)s; @@ -55,14 +55,14 @@ SubStr_new_u(uchar *s, uint l) } static inline void -SubStr_init(SubStr *r, char *s, uint l) +SubStr_init(SubStr *r, char *s, unsigned int l) { r->str = s; r->len = l; } static inline SubStr * -SubStr_new(char *s, uint l) +SubStr_new(char *s, unsigned int l) { SubStr *r = malloc(sizeof(SubStr)); r->str = s; diff --git a/tools/re2c/token.h b/tools/re2c/token.h index 1acf4f44..14915bde 100644 --- a/tools/re2c/token.h +++ b/tools/re2c/token.h @@ -5,21 +5,21 @@ typedef struct Token { Str text; - uint line; + unsigned int line; } Token; -static inline void Token_init(Token *, SubStr, uint); -static inline Token *Token_new(SubStr, uint); +static inline void Token_init(Token *, SubStr, unsigned int); +static inline Token *Token_new(SubStr, unsigned int); static inline void -Token_init(Token *r, SubStr t, uint l) +Token_init(Token *r, SubStr t, unsigned int l) { Str_copy(&r->text, &t); r->line = l; } static inline Token * -Token_new(SubStr t, uint l) +Token_new(SubStr t, unsigned int l) { Token *r = malloc(sizeof(Token)); Str_init(&r->text, &t); diff --git a/tools/re2c/translate.c b/tools/re2c/translate.c index 17b9adca..8bcdaf42 100644 --- a/tools/re2c/translate.c +++ b/tools/re2c/translate.c @@ -2,7 +2,7 @@ #include "tools/re2c/globals.h" -uchar asc2asc[256] = { +unsigned char asc2asc[256] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, @@ -21,10 +21,10 @@ uchar asc2asc[256] = { 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff }; -uchar *xlat = asc2asc; -uchar *talx = asc2asc; +unsigned char *xlat = asc2asc; +unsigned char *talx = asc2asc; -uchar asc2ebc[256] = { /* Based on ISO 8859/1 and Code Page 37 */ +unsigned char asc2ebc[256] = { /* Based on ISO 8859/1 and Code Page 37 */ 0x00,0x01,0x02,0x03,0x37,0x2d,0x2e,0x2f,0x16,0x05,0x25,0x0b,0x0c,0x0d,0x0e,0x0f, 0x10,0x11,0x12,0x13,0x3c,0x3d,0x32,0x26,0x18,0x19,0x3f,0x27,0x1c,0x1d,0x1e,0x1f, 0x40,0x5a,0x7f,0x7b,0x5b,0x6c,0x50,0x7d,0x4d,0x5d,0x5c,0x4e,0x6b,0x60,0x4b,0x61, @@ -43,7 +43,7 @@ uchar asc2ebc[256] = { /* Based on ISO 8859/1 and Code Page 37 */ 0x8c,0x49,0xcd,0xce,0xcb,0xcf,0xcc,0xe1,0x70,0xdd,0xde,0xdb,0xdc,0x8d,0xae,0xdf }; -uchar ebc2asc[256] = { /* Based on ISO 8859/1 and Code Page 37 */ +unsigned char ebc2asc[256] = { /* Based on ISO 8859/1 and Code Page 37 */ 0x00,0x01,0x02,0x03,0x9c,0x09,0x86,0x7f,0x97,0x8d,0x8e,0x0b,0x0c,0x0d,0x0e,0x0f, 0x10,0x11,0x12,0x13,0x9d,0x85,0x08,0x87,0x18,0x19,0x92,0x8f,0x1c,0x1d,0x1e,0x1f, 0x80,0x81,0x82,0x83,0x84,0x0a,0x17,0x1b,0x88,0x89,0x8a,0x8b,0x8c,0x05,0x06,0x07,