diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2015-11-20 18:54:50 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2015-11-20 18:54:50 +0000 |
commit | 9fa14b4b6462d61286bd4fb1675b216f721a239a (patch) | |
tree | a533553f2189ee77cee606a6765baae94ab24044 /usr.bin/lex | |
parent | 53fbe7c442e483fee0bf4c198c7ef3183f141a5c (diff) |
ansi
Diffstat (limited to 'usr.bin/lex')
-rw-r--r-- | usr.bin/lex/buf.c | 28 | ||||
-rw-r--r-- | usr.bin/lex/ecs.c | 68 |
2 files changed, 43 insertions, 53 deletions
diff --git a/usr.bin/lex/buf.c b/usr.bin/lex/buf.c index 3275f302759..5daf9fb5c6b 100644 --- a/usr.bin/lex/buf.c +++ b/usr.bin/lex/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.6 2015/11/19 23:36:46 tedu Exp $ */ +/* $OpenBSD: buf.c,v 1.7 2015/11/20 18:54:49 tedu Exp $ */ /* flex - tool to generate fast lexical analyzers */ @@ -136,10 +136,7 @@ buf_concat(struct Buf * dest, const struct Buf * src) /* Appends n characters in str to buf. */ struct Buf * -buf_strnappend(buf, str, n) - struct Buf *buf; - const char *str; - int n; +buf_strnappend(struct Buf *buf, const char *str, int n) { buf_append(buf, str, n + 1); @@ -151,19 +148,14 @@ buf_strnappend(buf, str, n) /* Appends characters in str to buf. */ struct Buf * -buf_strappend(buf, str) - struct Buf *buf; - const char *str; +buf_strappend(struct Buf *buf, const char *str) { return buf_strnappend(buf, str, strlen(str)); } /* appends "#define str def\n" */ struct Buf * -buf_strdefine(buf, str, def) - struct Buf *buf; - const char *str; - const char *def; +buf_strdefine(struct Buf *buf, const char *str, const char *def) { buf_strappend(buf, "#define "); buf_strappend(buf, " "); @@ -222,9 +214,7 @@ buf_m4_undefine(struct Buf * buf, const char *def) /* create buf with 0 elements, each of size elem_size. */ void -buf_init(buf, elem_size) - struct Buf *buf; - size_t elem_size; +buf_init(struct Buf *buf, size_t elem_size) { buf->elts = NULL; buf->nelts = 0; @@ -234,8 +224,7 @@ buf_init(buf, elem_size) /* frees memory */ void -buf_destroy(buf) - struct Buf *buf; +buf_destroy(struct Buf *buf) { free(buf->elts); buf->elts = NULL; @@ -249,10 +238,7 @@ buf_destroy(buf) */ struct Buf * -buf_append(buf, ptr, n_elem) - struct Buf *buf; - const void *ptr; - int n_elem; +buf_append(struct Buf *buf, const void *ptr, int n_elem) { int n_alloc = 0; diff --git a/usr.bin/lex/ecs.c b/usr.bin/lex/ecs.c index 09ba90e4c33..c5267516b17 100644 --- a/usr.bin/lex/ecs.c +++ b/usr.bin/lex/ecs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs.c,v 1.8 2015/11/19 23:34:56 mmcc Exp $ */ +/* $OpenBSD: ecs.c,v 1.9 2015/11/20 18:54:49 tedu Exp $ */ /* ecs - equivalence class routines */ @@ -38,16 +38,18 @@ /* ccl2ecl - convert character classes to set of equivalence classes */ -void ccl2ecl () +void +ccl2ecl(void) { - int i, ich, newlen, cclp, ccls, cclmec; + int i, ich, newlen, cclp, ccls, cclmec; for (i = 1; i <= lastccl; ++i) { - /* We loop through each character class, and for each character - * in the class, add the character's equivalence class to the - * new "character" class we are creating. Thus when we are all - * done, character classes will really consist of collections - * of equivalence classes + /* + * We loop through each character class, and for each + * character in the class, add the character's equivalence + * class to the new "character" class we are creating. Thus + * when we are all done, character classes will really + * consist of collections of equivalence classes */ newlen = 0; @@ -76,17 +78,17 @@ void ccl2ecl () * Returned is the number of classes. */ -int cre8ecs (fwd, bck, num) - int fwd[], bck[], num; +int +cre8ecs(int *fwd, int *bck, int num) { - int i, j, numcl; + int i, j, numcl; numcl = 0; - /* Create equivalence class numbers. From now on, ABS( bck(x) ) - * is the equivalence class number for object x. If bck(x) - * is positive, then x is the representative of its equivalence - * class. + /* + * Create equivalence class numbers. From now on, ABS( bck(x) ) is + * the equivalence class number for object x. If bck(x) is positive, + * then x is the representative of its equivalence class. */ for (i = 1; i <= num; ++i) if (bck[i] == NIL) { @@ -94,7 +96,6 @@ int cre8ecs (fwd, bck, num) for (j = fwd[i]; j != NIL; j = fwd[j]) bck[j] = -numcl; } - return numcl; } @@ -114,15 +115,15 @@ int cre8ecs (fwd, bck, num) * NUL_mapping is the value which NUL (0) should be mapped to. */ -void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping) - u_char ccls[]; - int lenccl, fwd[], bck[], llsiz, NUL_mapping; +void +mkeccl(u_char *ccls, int lenccl, int *fwd, int *bck, int llsiz, int NUL_mapping) { - int cclp, oldec, newec; - int cclm, i, j; + int cclp, oldec, newec; + int cclm, i, j; static unsigned char cclflags[CSIZE]; /* initialized to all '\0' */ - /* Note that it doesn't matter whether or not the character class is + /* + * Note that it doesn't matter whether or not the character class is * negated. The same results will be obtained in either case. */ @@ -139,7 +140,8 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping) j = cclp + 1; - for (i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i]) { /* look for the symbol in the character class */ + for (i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i]) { + /* look for the symbol in the character class */ for (; j < lenccl; ++j) { int ccl_char; @@ -152,7 +154,8 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping) break; if (ccl_char == i && !cclflags[j]) { - /* We found an old companion of cclm + /* + * We found an old companion of cclm * in the ccl. Link it into the new * equivalence class and flag it as * having been processed. @@ -170,8 +173,9 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping) } } - /* Symbol isn't in character class. Put it in the old - * equivalence class. + /* + * Symbol isn't in character class. Put it in the + * old equivalence class. */ bck[i] = oldec; @@ -181,14 +185,13 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping) oldec = i; - next_pt:; + next_pt: ; } if (bck[cclm] != NIL || oldec != bck[cclm]) { bck[cclm] = NIL; fwd[oldec] = NIL; } - fwd[newec] = NIL; /* Find next ccl member to process. */ @@ -203,11 +206,12 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping) /* mkechar - create equivalence class for single character */ -void mkechar (tch, fwd, bck) - int tch, fwd[], bck[]; +void +mkechar(int tch, int *fwd, int *bck) { - /* If until now the character has been a proper subset of - * an equivalence class, break it away to create a new ec + /* + * If until now the character has been a proper subset of an + * equivalence class, break it away to create a new ec */ if (fwd[tch] != NIL) |