From a8a967d91bd62cae4be4386f80cf6a2738da3a45 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sat, 17 Aug 2013 01:08:42 +0300 Subject: [PATCH] cosmetix in comments --- src/libre9/re9.c | 62 ++++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/src/libre9/re9.c b/src/libre9/re9.c index a28e1e6..e462c7c 100644 --- a/src/libre9/re9.c +++ b/src/libre9/re9.c @@ -24,7 +24,7 @@ #include -//////////////////////////////////////////////////////////////////////////////// +/******************************************************************************/ #define ARRAYLEN(_a) ((sizeof((_a)))/sizeof((_a)[0])) #ifdef RE9_DEBUG @@ -34,9 +34,8 @@ #endif -//////////////////////////////////////////////////////////////////////////////// -// re9_compile.h -// +/******************************************************************************/ +/* re9_compile.h */ /* substitution list */ typedef unsigned char uchar; @@ -109,9 +108,9 @@ static const opinfo_t opnames[] = { #endif -//////////////////////////////////////////////////////////////////////////////// -// regutf.c -// +/******************************************************************************/ +/* regutf.c */ + enum { RE9_UTF_MAX_BYTES = 4, /* maximum bytes per rune */ RE9_RUNE_SYNC = 0x80, /* cannot represent part of a UTF sequence (<) */ @@ -231,9 +230,8 @@ static inline const char *re8_rune_strchr (const char *s, long c) { } -//////////////////////////////////////////////////////////////////////////////// -// regcomp.c -// +/******************************************************************************/ +/* regcomp.c */ enum { RE9_FALSE = 0, @@ -274,7 +272,7 @@ typedef struct { } re9_compileinfo_t; -//////////////////////////////////////////////////////////////////////////////// +/******************************************************************************/ static __attribute__((noreturn)) void rcerror (re9_compileinfo_t *ci, const char *s) { ++ci->errors; snprintf(ci->errormsg, sizeof(ci->errormsg), "%s", s); @@ -298,7 +296,7 @@ static __attribute__((noreturn)) void cant (re9_compileinfo_t *ci, const char *s } -//////////////////////////////////////////////////////////////////////////////// +/******************************************************************************/ static inline void peekc (re9_compileinfo_t *ci, re9_rune *rp) { if (ci->lexdone) *rp = 0; else if ((ci->flags&RE9_FLAG_NONUTF8) == 0) re9_char2rune(rp, ci->exprp); @@ -306,7 +304,7 @@ static inline void peekc (re9_compileinfo_t *ci, re9_rune *rp) { } -// return 1 if char is quoted +/* return 1 if char is quoted */ static int nextc (re9_compileinfo_t *ci, re9_rune *rp) { if (ci->lexdone) { *rp = 0; return 1; } if (ci->exprp[0] == 0) { ci->lexdone = 1; *rp = 0; return 0; } @@ -426,7 +424,7 @@ static int lex (re9_compileinfo_t *ci) { } -//////////////////////////////////////////////////////////////////////////////// +/******************************************************************************/ static re9_inst_t *newinst (re9_compileinfo_t *ci, int t) { #ifdef RE9_DEBUG memset(ci->freep, 0, sizeof(*ci->freep)); @@ -535,7 +533,7 @@ static void evaluntil (re9_compileinfo_t *ci, int pri) { } -//////////////////////////////////////////////////////////////////////////////// +/******************************************************************************/ static void operator (re9_compileinfo_t *ci, int t) { int csi = ci->cursubid; if (t == RBRA && --ci->nbra < 0) rcerror(ci, "unmatched right paren"); @@ -544,7 +542,6 @@ static void operator (re9_compileinfo_t *ci, int t) { if (!ci->lexdone && ci->exprp[0] == '?') { if (ci->exprp[1] == ':') { ci->exprp += 2; - //skipsub = 1; } else { rcerror(ci, "invalid paren flags"); } @@ -744,9 +741,9 @@ void re9_free (re9_prog_t *p) { } -//////////////////////////////////////////////////////////////////////////////// -// regexec.c -// +/******************************************************************************/ +/* regexec.c */ + #ifdef RE9_DEBUG # define FARG , const re9_inst_t *fi # define XARG , progp->firstinst @@ -881,7 +878,7 @@ static inline re9_listitem_t *re9l_newemptythread (re9_list_t *lp, const re9_ins } } */ - // + /* */ re9_listitem_t *p = lp->free++; if (p >= lp->end-1) return NULL; dlogf("newemptythread:%p; new at %u(%u)\n", lp->start, p-lp->start, ip-fi); @@ -907,16 +904,12 @@ static inline re9_listitem_t *re9l_newemptythread (re9_list_t *lp, const re9_ins */ static int regexec1 (const re9_prog_t *progp, const char *bol, re9_sub_t *mp, int ms, re9_ljunk_t *j) { int flag = 0; - //int maxt = 0; + /*int maxt = 0;*/ const char *s, *p; int checkstart; re9_rune r, *rp, *ep; int n; - re9_list_t tl, nl; // this list, next list -/* - re9_list_t *tle, *nle; // ends of this and next list - re9_list_t *tlp, *tlxn; -*/ + re9_list_t tl, nl; /* this list, next list */ re9_listitem_t *tlp, *tlxn; int match, i; /* */ @@ -928,7 +921,7 @@ static int regexec1 (const re9_prog_t *progp, const char *bol, re9_sub_t *mp, in j->relistf[1] = j->relist[1]; /* execute machine once for each character, including terminal NUL */ s = j->starts; - do { + for (;;) { /* fast check for first char */ if (checkstart) { dlogf("checkstart!\n"); @@ -982,12 +975,11 @@ static int regexec1 (const re9_prog_t *progp, const char *bol, re9_sub_t *mp, in #endif /* execute machine until current list is empty */ if (tl.start->inst == NULL) break; /* nothing to do */ - //for (tlxn = tl; tlxn->inst != NULL; ++tlxn) ; /* last 'old' instruction */ - //if (tlxn-tl > maxt) maxt = tlxn-tl; + /*if (tlxn-tl > maxt) maxt = tlxn-tl;*/ for (tlp = tl.start; tlp->inst != NULL; ++tlp) { const re9_inst_t *inst; dlogf("* new thread (%d) at %u\n", flag, tlp-tl.start); - //if (tlp-tl > maxt) maxt = tlp-tl; + /*if (tlp-tl > maxt) maxt = tlp-tl;*/ for (inst = tlp->inst; inst != NULL; inst = inst->u2.next) { #ifdef RE9_DEBUG const opinfo_t *op = findop(inst->type); @@ -1038,7 +1030,7 @@ static int regexec1 (const re9_prog_t *progp, const char *bol, re9_sub_t *mp, in /* evaluate right choice later */ if (re9l_newthread(&tl, inst->u1.right, ms, &tlp->se XARG) == NULL) return -1; /* efficiency: advance and re-evaluate */ - //continue; + /*continue;*/ break; case ORX: /* evaluate right choice first */ @@ -1071,8 +1063,8 @@ static int regexec1 (const re9_prog_t *progp, const char *bol, re9_sub_t *mp, in checkstart = (j->starttype && nl.start->inst == NULL && !match); s += n; dlogf("+++ (%d) eol=%d\n", r, s == j->eol); - } while (r); - //fprintf(stderr, "maxt=%d\n", maxt); + } + /*fprintf(stderr, "maxt=%d\n", maxt);*/ return match; } @@ -1209,10 +1201,10 @@ int re9_execute (const re9_prog_t *progp, int flags, const char *bol, re9_sub_t j.relist[1] = relist1; rv = regexec1(progp, bol, mp, ms, &j); if (rv >= 0) return rv; - //fprintf(stderr, "OMEM0\n"); + /*fprintf(stderr, "OMEM0\n");*/ rv = regexec2(progp, bol, mp, ms, &j); if (rv >= 0) return rv; - //fprintf(stderr, "OMEM1\n"); + /*fprintf(stderr, "OMEM1\n");*/ return -1; } -- 2.11.4.GIT