diff options
| author | Gerd Moellmann | 2000-12-15 14:32:55 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-12-15 14:32:55 +0000 |
| commit | af03e6abc14fcffaee36ba0a18c84f99b73decb4 (patch) | |
| tree | 6baa60c08bf7921fc103ae90d86aa40dc427c898 /lib-src | |
| parent | 88ee79179163a41c4a16c5ee083776a035a164e2 (diff) | |
| download | emacs-af03e6abc14fcffaee36ba0a18c84f99b73decb4.tar.gz emacs-af03e6abc14fcffaee36ba0a18c84f99b73decb4.zip | |
(ISALNUM, ISALPHA, ISDIGIT, ISLOWER): New macros.
Use them throughout instead of ctype functions/macros.
(lowcase): Cast to unsigned char.
(UPCASE): New macro.
(canonicalize_filename): Use UPCASE instead toupper.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index 4a24bbfa375..72970642d82 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -160,7 +160,8 @@ char pot_etags_version[] = "@(#) pot revision number is 13.44"; | |||
| 160 | #define strneq(s,t,n) ((DEBUG && (s) == NULL && (t) == NULL \ | 160 | #define strneq(s,t,n) ((DEBUG && (s) == NULL && (t) == NULL \ |
| 161 | && (abort (), 1)) || !strncmp (s, t, n)) | 161 | && (abort (), 1)) || !strncmp (s, t, n)) |
| 162 | 162 | ||
| 163 | #define lowcase(c) tolower ((char)c) | 163 | #define lowcase(c) tolower ((unsigned char)(c)) |
| 164 | #define UPCASE(c) toupper ((unsigned char)(c)) | ||
| 164 | 165 | ||
| 165 | #define CHARS 256 /* 2^sizeof(char) */ | 166 | #define CHARS 256 /* 2^sizeof(char) */ |
| 166 | #define CHAR(x) ((unsigned int)x & (CHARS - 1)) | 167 | #define CHAR(x) ((unsigned int)x & (CHARS - 1)) |
| @@ -170,6 +171,11 @@ char pot_etags_version[] = "@(#) pot revision number is 13.44"; | |||
| 170 | #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */ | 171 | #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */ |
| 171 | #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */ | 172 | #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */ |
| 172 | 173 | ||
| 174 | #define ISALNUM(c) isalnum ((unsigned char) (c)) | ||
| 175 | #define ISALPHA(c) isalpha ((unsigned char) (c)) | ||
| 176 | #define ISDIGIT(c) isdigit ((unsigned char) (c)) | ||
| 177 | #define ISLOWER(c) islower ((unsigned char) (c)) | ||
| 178 | |||
| 173 | 179 | ||
| 174 | /* | 180 | /* |
| 175 | * xnew, xrnew -- allocate, reallocate storage | 181 | * xnew, xrnew -- allocate, reallocate storage |
| @@ -3403,14 +3409,14 @@ takeprec () | |||
| 3403 | dbp += 3; | 3409 | dbp += 3; |
| 3404 | return; | 3410 | return; |
| 3405 | } | 3411 | } |
| 3406 | if (!isdigit (*dbp)) | 3412 | if (!ISDIGIT (*dbp)) |
| 3407 | { | 3413 | { |
| 3408 | --dbp; /* force failure */ | 3414 | --dbp; /* force failure */ |
| 3409 | return; | 3415 | return; |
| 3410 | } | 3416 | } |
| 3411 | do | 3417 | do |
| 3412 | dbp++; | 3418 | dbp++; |
| 3413 | while (isdigit (*dbp)); | 3419 | while (ISDIGIT (*dbp)); |
| 3414 | } | 3420 | } |
| 3415 | 3421 | ||
| 3416 | static void | 3422 | static void |
| @@ -3431,7 +3437,7 @@ getit (inf) | |||
| 3431 | dbp += 6; | 3437 | dbp += 6; |
| 3432 | dbp = skip_spaces (dbp); | 3438 | dbp = skip_spaces (dbp); |
| 3433 | } | 3439 | } |
| 3434 | if (!isalpha (*dbp) && *dbp != '_' && *dbp != '$') | 3440 | if (!ISALPHA (*dbp) && *dbp != '_' && *dbp != '$') |
| 3435 | return; | 3441 | return; |
| 3436 | for (cp = dbp + 1; *cp != '\0' && intoken (*cp); cp++) | 3442 | for (cp = dbp + 1; *cp != '\0' && intoken (*cp); cp++) |
| 3437 | continue; | 3443 | continue; |
| @@ -3572,7 +3578,7 @@ adagetit (inf, name_qualifier) | |||
| 3572 | dbp = skip_spaces (dbp); | 3578 | dbp = skip_spaces (dbp); |
| 3573 | for (cp = dbp; | 3579 | for (cp = dbp; |
| 3574 | (*cp != '\0' | 3580 | (*cp != '\0' |
| 3575 | && (isalpha (*cp) || isdigit (*cp) || *cp == '_' || *cp == '.')); | 3581 | && (ISALPHA (*cp) || ISDIGIT (*cp) || *cp == '_' || *cp == '.')); |
| 3576 | cp++) | 3582 | cp++) |
| 3577 | continue; | 3583 | continue; |
| 3578 | if (cp == dbp) | 3584 | if (cp == dbp) |
| @@ -3696,11 +3702,11 @@ Asm_labels (inf) | |||
| 3696 | { | 3702 | { |
| 3697 | /* If first char is alphabetic or one of [_.$], test for colon | 3703 | /* If first char is alphabetic or one of [_.$], test for colon |
| 3698 | following identifier. */ | 3704 | following identifier. */ |
| 3699 | if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$') | 3705 | if (ISALPHA (*cp) || *cp == '_' || *cp == '.' || *cp == '$') |
| 3700 | { | 3706 | { |
| 3701 | /* Read past label. */ | 3707 | /* Read past label. */ |
| 3702 | cp++; | 3708 | cp++; |
| 3703 | while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$') | 3709 | while (ISALNUM (*cp) || *cp == '_' || *cp == '.' || *cp == '$') |
| 3704 | cp++; | 3710 | cp++; |
| 3705 | if (*cp == ':' || iswhite (*cp)) | 3711 | if (*cp == ':' || iswhite (*cp)) |
| 3706 | { | 3712 | { |
| @@ -3760,7 +3766,7 @@ Perl_functions (inf) | |||
| 3760 | if (*cp == '$' || *cp == '@' || *cp == '%') | 3766 | if (*cp == '$' || *cp == '@' || *cp == '%') |
| 3761 | { | 3767 | { |
| 3762 | char* varstart = ++cp; | 3768 | char* varstart = ++cp; |
| 3763 | while (isalnum (*cp) || *cp == '_') | 3769 | while (ISALNUM (*cp) || *cp == '_') |
| 3764 | cp++; | 3770 | cp++; |
| 3765 | varname = savenstr (varstart, cp-varstart); | 3771 | varname = savenstr (varstart, cp-varstart); |
| 3766 | } | 3772 | } |
| @@ -3837,10 +3843,10 @@ Cobol_paragraphs (inf) | |||
| 3837 | bp += 8; | 3843 | bp += 8; |
| 3838 | 3844 | ||
| 3839 | /* If eoln, compiler option or comment ignore whole line. */ | 3845 | /* If eoln, compiler option or comment ignore whole line. */ |
| 3840 | if (bp[-1] != ' ' || !isalnum (bp[0])) | 3846 | if (bp[-1] != ' ' || !ISALNUM (bp[0])) |
| 3841 | continue; | 3847 | continue; |
| 3842 | 3848 | ||
| 3843 | for (ep = bp; isalnum (*ep) || *ep == '-'; ep++) | 3849 | for (ep = bp; ISALNUM (*ep) || *ep == '-'; ep++) |
| 3844 | continue; | 3850 | continue; |
| 3845 | if (*ep++ == '.') | 3851 | if (*ep++ == '.') |
| 3846 | pfnote (savenstr (bp, ep-bp), TRUE, | 3852 | pfnote (savenstr (bp, ep-bp), TRUE, |
| @@ -4529,11 +4535,11 @@ prolog_atom (s, pos) | |||
| 4529 | 4535 | ||
| 4530 | origpos = pos; | 4536 | origpos = pos; |
| 4531 | 4537 | ||
| 4532 | if (islower(s[pos]) || (s[pos] == '_')) | 4538 | if (ISLOWER(s[pos]) || (s[pos] == '_')) |
| 4533 | { | 4539 | { |
| 4534 | /* The atom is unquoted. */ | 4540 | /* The atom is unquoted. */ |
| 4535 | pos++; | 4541 | pos++; |
| 4536 | while (isalnum(s[pos]) || (s[pos] == '_')) | 4542 | while (ISALNUM(s[pos]) || (s[pos] == '_')) |
| 4537 | { | 4543 | { |
| 4538 | pos++; | 4544 | pos++; |
| 4539 | } | 4545 | } |
| @@ -4710,11 +4716,11 @@ erlang_atom (s, pos) | |||
| 4710 | 4716 | ||
| 4711 | origpos = pos; | 4717 | origpos = pos; |
| 4712 | 4718 | ||
| 4713 | if (isalpha (s[pos]) || s[pos] == '_') | 4719 | if (ISALPHA (s[pos]) || s[pos] == '_') |
| 4714 | { | 4720 | { |
| 4715 | /* The atom is unquoted. */ | 4721 | /* The atom is unquoted. */ |
| 4716 | pos++; | 4722 | pos++; |
| 4717 | while (isalnum (s[pos]) || s[pos] == '_') | 4723 | while (ISALNUM (s[pos]) || s[pos] == '_') |
| 4718 | pos++; | 4724 | pos++; |
| 4719 | return pos - origpos; | 4725 | return pos - origpos; |
| 4720 | } | 4726 | } |
| @@ -4939,7 +4945,7 @@ substitute (in, out, regs) | |||
| 4939 | for (t = etags_strchr (out, '\\'); | 4945 | for (t = etags_strchr (out, '\\'); |
| 4940 | t != NULL; | 4946 | t != NULL; |
| 4941 | t = etags_strchr (t + 2, '\\')) | 4947 | t = etags_strchr (t + 2, '\\')) |
| 4942 | if (isdigit (t[1])) | 4948 | if (ISDIGIT (t[1])) |
| 4943 | { | 4949 | { |
| 4944 | dig = t[1] - '0'; | 4950 | dig = t[1] - '0'; |
| 4945 | diglen = regs->end[dig] - regs->start[dig]; | 4951 | diglen = regs->end[dig] - regs->start[dig]; |
| @@ -4952,7 +4958,7 @@ substitute (in, out, regs) | |||
| 4952 | result = xnew (size + 1, char); | 4958 | result = xnew (size + 1, char); |
| 4953 | 4959 | ||
| 4954 | for (t = result; *out != '\0'; out++) | 4960 | for (t = result; *out != '\0'; out++) |
| 4955 | if (*out == '\\' && isdigit (*++out)) | 4961 | if (*out == '\\' && ISDIGIT (*++out)) |
| 4956 | { | 4962 | { |
| 4957 | /* Using "dig2" satisfies my debugger. Bleah. */ | 4963 | /* Using "dig2" satisfies my debugger. Bleah. */ |
| 4958 | dig = *out - '0'; | 4964 | dig = *out - '0'; |
| @@ -5472,7 +5478,7 @@ filename_is_absolute (fn) | |||
| 5472 | { | 5478 | { |
| 5473 | return (fn[0] == '/' | 5479 | return (fn[0] == '/' |
| 5474 | #ifdef DOS_NT | 5480 | #ifdef DOS_NT |
| 5475 | || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/') | 5481 | || (ISALPHA(fn[0]) && fn[1] == ':' && fn[2] == '/') |
| 5476 | #endif | 5482 | #endif |
| 5477 | ); | 5483 | ); |
| 5478 | } | 5484 | } |
| @@ -5484,8 +5490,8 @@ canonicalize_filename (fn) | |||
| 5484 | { | 5490 | { |
| 5485 | #ifdef DOS_NT | 5491 | #ifdef DOS_NT |
| 5486 | /* Canonicalize drive letter case. */ | 5492 | /* Canonicalize drive letter case. */ |
| 5487 | if (fn[0] && fn[1] == ':' && islower (fn[0])) | 5493 | if (fn[0] && fn[1] == ':' && ISLOWER (fn[0])) |
| 5488 | fn[0] = toupper (fn[0]); | 5494 | fn[0] = upcase (fn[0]); |
| 5489 | /* Convert backslashes to slashes. */ | 5495 | /* Convert backslashes to slashes. */ |
| 5490 | for (; *fn != '\0'; fn++) | 5496 | for (; *fn != '\0'; fn++) |
| 5491 | if (*fn == '\\') | 5497 | if (*fn == '\\') |