From 022204dd533c5741bfd1b59077aaf14af3f6f853 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Sun, 13 Jun 2010 13:12:00 +0000 Subject: chktex bugfix, from Jukka git-svn-id: svn://tug.org/texlive/trunk@18936 c570f23f-e606-0410-a88d-b1316a301751 --- .../utils/chktex/chktex-1.6.4-PATCHES/ChangeLog | 6 + .../chktex/chktex-1.6.4-PATCHES/patch-05-ctype-bug | 346 +++++++++++++++++++++ Build/source/utils/chktex/chktex-1.6.4/ChkTeX.c | 12 +- Build/source/utils/chktex/chktex-1.6.4/FindErrs.c | 60 ++-- Build/source/utils/chktex/chktex-1.6.4/Resource.c | 14 +- Build/source/utils/chktex/chktex-1.6.4/Utility.c | 6 +- 6 files changed, 398 insertions(+), 46 deletions(-) create mode 100644 Build/source/utils/chktex/chktex-1.6.4-PATCHES/patch-05-ctype-bug (limited to 'Build') diff --git a/Build/source/utils/chktex/chktex-1.6.4-PATCHES/ChangeLog b/Build/source/utils/chktex/chktex-1.6.4-PATCHES/ChangeLog index 8f9a0ae66fb..2b7e41bb492 100644 --- a/Build/source/utils/chktex/chktex-1.6.4-PATCHES/ChangeLog +++ b/Build/source/utils/chktex/chktex-1.6.4-PATCHES/ChangeLog @@ -1,3 +1,9 @@ +2010-06-13 Peter Breitenlohner + + * patch-05-ctype-bug (new): Bug fix: + Cast all arguments of isalpha() and similar to 'unsigned char'. + Patch from Jukka Salmi [tlbuild, 10 Jun 2010]. + 2010-05-21 Peter Breitenlohner * patch-01-const: Change OutputFormat and PipeOutputFormat back diff --git a/Build/source/utils/chktex/chktex-1.6.4-PATCHES/patch-05-ctype-bug b/Build/source/utils/chktex/chktex-1.6.4-PATCHES/patch-05-ctype-bug new file mode 100644 index 00000000000..4bd7463558a --- /dev/null +++ b/Build/source/utils/chktex/chktex-1.6.4-PATCHES/patch-05-ctype-bug @@ -0,0 +1,346 @@ + The argument of the functions isalpha() and similar, declared + in , must have the value of an unsigned char or be EOF. + Everything else is not portable. + + This patch from Jukka Salmi uses the + brute force approach casting all arguments to 'unsigned char'. + + A proper solution would require to use 'unsigned char' variables + in the first place; we leave that to the chktex maintainer. + +diff -ur chktex-1.6.4.orig/ChkTeX.c chktex-1.6.4/ChkTeX.c +--- chktex-1.6.4.orig/ChkTeX.c 2010-05-05 21:46:44.000000000 +0200 ++++ chktex-1.6.4/ChkTeX.c 2010-06-13 14:50:28.989565047 +0200 +@@ -243,11 +243,11 @@ + + FORWL(i, AbbrevCase) + { +- if (isalpha(ThisItem[0])) ++ if (isalpha((unsigned char)ThisItem[0])) + { +- ThisItem[0] = toupper(ThisItem[0]); ++ ThisItem[0] = toupper((unsigned char)ThisItem[0]); + InsertWord(ThisItem, &Abbrev); +- ThisItem[0] = tolower(ThisItem[0]); ++ ThisItem[0] = tolower((unsigned char)ThisItem[0]); + } + InsertWord(ThisItem, &Abbrev); + } +@@ -401,7 +401,7 @@ + NOCOMMON(Italic, ItalCmd); + NOCOMMON(LowDots, CenterDots); + +- if (TabSize && isdigit(*TabSize)) ++ if (TabSize && isdigit((unsigned char)*TabSize)) + Tab = strtol(TabSize, NULL, 10); + + if (OpenOut()) +@@ -691,7 +691,7 @@ + long Default, /* Value to put in if no in argue */ + char **Argument) /* optarg or similar */ + { +- if (Argument && *Argument && isdigit(**Argument)) ++ if (Argument && *Argument && isdigit((unsigned char)**Argument)) + *Dest = strtol(*Argument, Argument, 10); + else + *Dest = Default; +@@ -838,7 +838,7 @@ + ErrType = etWarn; InUse = iuOK; LAST(warntype); case 'e': + ErrType = etErr; InUse = iuOK; LAST(warntype); case 'm': + ErrType = etMsg; InUse = iuOK; LAST(warntype); case 'n': +- ErrType = etMsg; InUse = iuNotUser; LAST(warntype);) if (isdigit(*optarg)) ++ ErrType = etMsg; InUse = iuNotUser; LAST(warntype);) if (isdigit((unsigned char)*optarg)) + { + nextc = ParseNumArg(&Err, -1, &optarg); + if (betw(emMinFault, Err, emMaxFault)) +diff -ur chktex-1.6.4.orig/FindErrs.c chktex-1.6.4/FindErrs.c +--- chktex-1.6.4.orig/FindErrs.c 2010-05-20 16:28:35.000000000 +0200 ++++ chktex-1.6.4/FindErrs.c 2010-06-13 14:50:28.989565047 +0200 +@@ -42,7 +42,7 @@ + ERRMSGS {emMaxFault, etErr, iuOK, 0, INTERNFAULT} + }; + +-#define istex(c) (isalpha(c) || (AtLetter && (c == '@'))) ++#define istex(c) (isalpha((unsigned char)c) || (AtLetter && (c == '@'))) + #define CTYPE(func) \ + static int my_##func(int c) \ + { \ +@@ -517,7 +517,7 @@ + PSERR(CmdPtr - Buf, CmdLen, emNoArgFound); + } + +- if (HasWord(CmdBuffer, &NotPreSpaced) && isspace(CmdPtr[-1])) ++ if (HasWord(CmdBuffer, &NotPreSpaced) && isspace((unsigned char)CmdPtr[-1])) + PSERRA(CmdPtr - Buf - 1, 1, emRemPSSpace, CmdBuffer); + + if ((TmpPtr = HasWord(CmdBuffer, &NoCharNext))) +@@ -622,7 +622,7 @@ + for (i = Abbrev.MaxLen; i >= 0; i--) + { + *--TmpPtr = *AbbPtr--; +- if (!isalpha(*AbbPtr) && HasWord(TmpPtr, &Abbrev)) ++ if (!isalpha((unsigned char)*AbbPtr) && HasWord(TmpPtr, &Abbrev)) + PSERR(Buffer - Buf + 1, 1, emInterWord); + if (!*AbbPtr) + break; +@@ -702,9 +702,9 @@ + { + if (LATEX_SPACE(*PrePtr) && LATEX_SPACE(*TmpPtr)) + wl = &WordDash; +- if (isdigit(*PrePtr) && isdigit(*TmpPtr)) ++ if (isdigit((unsigned char)*PrePtr) && isdigit((unsigned char)*TmpPtr)) + wl = &NumDash; +- if (isalpha(*PrePtr) && isalpha(*TmpPtr)) ++ if (isalpha((unsigned char)*PrePtr) && isalpha((unsigned char)*TmpPtr)) + wl = &HyphDash; + + if (wl) +@@ -845,16 +845,16 @@ + { + PrePtr = BufPtr - 1; + Char = *BufPtr++; +- if (isspace(Char)) ++ if (isspace((unsigned char)Char)) + Char = ' '; + + switch (Char) + { + case '~': + TmpPtr = NULL; +- if (isspace(*PrePtr)) ++ if (isspace((unsigned char)*PrePtr)) + TmpPtr = PrePtr; +- else if (isspace(*BufPtr)) ++ else if (isspace((unsigned char)*BufPtr)) + TmpPtr = BufPtr; + + if (TmpPtr) +@@ -868,14 +868,14 @@ + SKIP_BACK(TmpPtr, TmpC, + (LATEX_SPACE(TmpC) || strchr("{}$", TmpC))); + +- if (isdigit(*TmpPtr)) ++ if (isdigit((unsigned char)*TmpPtr)) + { + TmpPtr = BufPtr; + + SKIP_AHEAD(TmpPtr, TmpC, + (LATEX_SPACE(TmpC) || strchr("{}$", TmpC))); + +- if (isdigit(*TmpPtr)) ++ if (isdigit((unsigned char)*TmpPtr)) + HERE(1, emUseTimes); + } + /* FALLTHRU */ +@@ -931,7 +931,7 @@ + case 'W': /* case 'X': */ + case 'Y': + case 'Z': +- if (!isalpha(*PrePtr) && (*PrePtr != '\\') && MathMode) ++ if (!isalpha((unsigned char)*PrePtr) && (*PrePtr != '\\') && MathMode) + { + TmpPtr = BufPtr; + CmdPtr = CmdBuffer; +@@ -940,7 +940,7 @@ + *CmdPtr++ = Char; + Char = *TmpPtr++; + } +- while (isalpha(Char)); ++ while (isalpha((unsigned char)Char)); + + *CmdPtr = 0; + +@@ -978,11 +978,11 @@ + SKIP_AHEAD(TmpPtr, TmpC, strchr(LTX_GenPunc, TmpC)); + if (LATEX_SPACE(*TmpPtr)) + { +- if (!isupper(*PrePtr) && (*PrePtr != '@') && ++ if (!isupper((unsigned char)*PrePtr) && (*PrePtr != '@') && + (*PrePtr != '.')) + { + SKIP_AHEAD(TmpPtr, TmpC, LATEX_SPACE(TmpC)); +- if (islower(*TmpPtr)) ++ if (islower((unsigned char)*TmpPtr)) + PSERR(BufPtr - Buf, 1, emInterWord); + else + CheckAbbrevs(&BufPtr[-1]); +@@ -996,14 +996,14 @@ + case ';': + /* Regexp: "[A-Z][A-Z][.!?:;]\s+" */ + +- if (isspace(*BufPtr) && isupper(*PrePtr) && +- (isupper(PrePtr[-1]) || (Char != '.'))) ++ if (isspace((unsigned char)*BufPtr) && isupper((unsigned char)*PrePtr) && ++ (isupper((unsigned char)PrePtr[-1]) || (Char != '.'))) + HERE(1, emInterSent); + + /* FALLTHRU */ + case ',': +- if (isspace(*PrePtr) && +- !(isdigit(*BufPtr) && ++ if (isspace((unsigned char)*PrePtr) && ++ !(isdigit((unsigned char)*BufPtr) && + ((BufPtr[-1] == '.') || (BufPtr[-1] == ',')))) + PSERR(PrePtr - Buf, 1, emSpacePunct); + +@@ -1050,8 +1050,8 @@ + switch (Char) + { + case '\'': +- if (isalpha(*TmpPtr) && +- (strchr(LTX_GenPunc, *PrePtr) || isspace(*PrePtr))) ++ if (isalpha((unsigned char)*TmpPtr) && ++ (strchr(LTX_GenPunc, *PrePtr) || isspace((unsigned char)*PrePtr))) + HERE(TmpPtr - BufPtr + 1, emBeginQ); + + /* Now check quote style */ +@@ -1061,7 +1061,7 @@ + + { + char *WordPtr = PrePtr; +- SKIP_BACK(WordPtr, TmpC, (isalnum(TmpC) || ++ SKIP_BACK(WordPtr, TmpC, (isalnum((unsigned char)TmpC) || + strchr(LTX_GenPunc, TmpC))); + + if (*WordPtr != '`') +@@ -1080,8 +1080,8 @@ + + break; + case '`': +- if (isalpha(*PrePtr) && +- (strchr(LTX_GenPunc, *TmpPtr) || isspace(*TmpPtr))) ++ if (isalpha((unsigned char)*PrePtr) && ++ (strchr(LTX_GenPunc, *TmpPtr) || isspace((unsigned char)*TmpPtr))) + HERE(TmpPtr - BufPtr + 1, emEndQ); + break; + } +@@ -1129,9 +1129,9 @@ + + ErrPtr = TmpPtr; + +- if (isalpha(*TmpPtr)) ++ if (isalpha((unsigned char)*TmpPtr)) + pstcb = &my_isalpha; +- else if (isdigit(*TmpPtr)) ++ else if (isdigit((unsigned char)*TmpPtr)) + pstcb = &my_isdigit; + else + break; +@@ -1164,7 +1164,7 @@ + { + PSERR(BufPtr - Buf, 1, emSpaceTerm); + } +- else if ((*BufPtr == '\\') && (!isalpha(BufPtr[1])) && ++ else if ((*BufPtr == '\\') && (!isalpha((unsigned char)BufPtr[1])) && + (!LATEX_SPACE(BufPtr[1]))) + PSERR(BufPtr - Buf, 2, emNotIntended); + +@@ -1174,7 +1174,7 @@ + break; + + case '(': +- if (!(!*PrePtr || LATEX_SPACE(*PrePtr) || isdigit(*PrePtr)) || ++ if (!(!*PrePtr || LATEX_SPACE(*PrePtr) || isdigit((unsigned char)*PrePtr)) || + strchr("([{`~", *PrePtr)) + { + if (PrePtr[-1] != '\\') /* Short cmds */ +@@ -1186,16 +1186,16 @@ + "in front of"); + } + } +- if (isspace(*BufPtr)) ++ if (isspace((unsigned char)*BufPtr)) + PSERRA(BufPtr - Buf, 1, emNoSpaceParen, "after"); + HandleBracket(Char); + break; + + case ')': +- if (isspace(*PrePtr)) ++ if (isspace((unsigned char)*PrePtr)) + PSERRA(BufPtr - Buf - 1, 1, emNoSpaceParen, + "in front of"); +- if (isalpha(*BufPtr)) ++ if (isalpha((unsigned char)*BufPtr)) + PSERRA(BufPtr - Buf, 1, emSpaceParen, "after"); + HandleBracket(Char); + break; +diff -ur chktex-1.6.4.orig/Resource.c chktex-1.6.4/Resource.c +--- chktex-1.6.4.orig/Resource.c 2010-05-02 21:32:29.000000000 +0200 ++++ chktex-1.6.4/Resource.c 2010-06-13 14:50:28.989565047 +0200 +@@ -348,7 +348,7 @@ + while (Cont) + { + Chr = *String++; +- if (isalpha(Chr)) ++ if (isalpha((unsigned char)Chr)) + *Ptr++ = Chr; + else + Cont = FALSE; +@@ -374,7 +374,7 @@ + *Ptr++ = Chr; + break; + default: +- if (!isspace(Chr)) ++ if (!isspace((unsigned char)Chr)) + *Ptr++ = Chr; + else + Cont = FALSE; +@@ -417,7 +417,7 @@ + + Chr = *((char *) (*String)++); + +- switch (tolower(Chr)) ++ switch (tolower((unsigned char)Chr)) + { + MAP(QUOTE, QUOTE); + MAP(ESCAPE, ESCAPE); +@@ -439,12 +439,12 @@ + for (Cnt = 0; Cnt < 2; Cnt++) + { + Chr = *((*String)++); +- if (isxdigit(Chr)) ++ if (isxdigit((unsigned char)Chr)) + { +- Chr = toupper(Chr); ++ Chr = toupper((unsigned char)Chr); + Tmp = (Tmp << 4) + Chr; + +- if (isdigit(Chr)) ++ if (isdigit((unsigned char)Chr)) + Tmp -= '0'; + else + Tmp -= 'A' - 10; +@@ -490,7 +490,7 @@ + case 'd': + for (Cnt = 0; Cnt < 3; Cnt++) + { +- if (isdigit(Chr = *((*String)++))) ++ if (isdigit((unsigned char)(Chr = *((*String)++)))) + Tmp = (Tmp * 10) + Chr - '0'; + else + { +diff -ur chktex-1.6.4.orig/Utility.c chktex-1.6.4/Utility.c +--- chktex-1.6.4.orig/Utility.c 2010-05-02 21:59:51.000000000 +0200 ++++ chktex-1.6.4/Utility.c 2010-06-13 14:50:28.989565047 +0200 +@@ -231,7 +231,7 @@ + char TmpC; + + for (Bufptr = String; (TmpC = *Bufptr); Bufptr++) +- *Bufptr = tolower(TmpC); ++ *Bufptr = tolower((unsigned char)TmpC); + + return (String); + } +@@ -291,10 +291,10 @@ + aa = *a++; + bb = *b++; + } +- while (aa && (tolower(aa) == tolower(bb))); ++ while (aa && (tolower((unsigned char)aa) == tolower((unsigned char)bb))); + /* bb != 0 is implicit */ + +- return (tolower(aa) - tolower(bb)); ++ return (tolower((unsigned char)aa) - tolower((unsigned char)bb)); + } + #endif + diff --git a/Build/source/utils/chktex/chktex-1.6.4/ChkTeX.c b/Build/source/utils/chktex/chktex-1.6.4/ChkTeX.c index 276a579e7ec..d3565b4a2d5 100644 --- a/Build/source/utils/chktex/chktex-1.6.4/ChkTeX.c +++ b/Build/source/utils/chktex/chktex-1.6.4/ChkTeX.c @@ -243,11 +243,11 @@ static void SetupLists(void) FORWL(i, AbbrevCase) { - if (isalpha(ThisItem[0])) + if (isalpha((unsigned char)ThisItem[0])) { - ThisItem[0] = toupper(ThisItem[0]); + ThisItem[0] = toupper((unsigned char)ThisItem[0]); InsertWord(ThisItem, &Abbrev); - ThisItem[0] = tolower(ThisItem[0]); + ThisItem[0] = tolower((unsigned char)ThisItem[0]); } InsertWord(ThisItem, &Abbrev); } @@ -401,7 +401,7 @@ int main(int argc, char **argv) NOCOMMON(Italic, ItalCmd); NOCOMMON(LowDots, CenterDots); - if (TabSize && isdigit(*TabSize)) + if (TabSize && isdigit((unsigned char)*TabSize)) Tab = strtol(TabSize, NULL, 10); if (OpenOut()) @@ -691,7 +691,7 @@ static int ParseNumArg(long *Dest, /* Where to put the value */ long Default, /* Value to put in if no in argue */ char **Argument) /* optarg or similar */ { - if (Argument && *Argument && isdigit(**Argument)) + if (Argument && *Argument && isdigit((unsigned char)**Argument)) *Dest = strtol(*Argument, Argument, 10); else *Dest = Default; @@ -838,7 +838,7 @@ static int ParseArgs(int argc, char **argv) ErrType = etWarn; InUse = iuOK; LAST(warntype); case 'e': ErrType = etErr; InUse = iuOK; LAST(warntype); case 'm': ErrType = etMsg; InUse = iuOK; LAST(warntype); case 'n': - ErrType = etMsg; InUse = iuNotUser; LAST(warntype);) if (isdigit(*optarg)) + ErrType = etMsg; InUse = iuNotUser; LAST(warntype);) if (isdigit((unsigned char)*optarg)) { nextc = ParseNumArg(&Err, -1, &optarg); if (betw(emMinFault, Err, emMaxFault)) diff --git a/Build/source/utils/chktex/chktex-1.6.4/FindErrs.c b/Build/source/utils/chktex/chktex-1.6.4/FindErrs.c index cb5269eb4f3..40249ff78db 100644 --- a/Build/source/utils/chktex/chktex-1.6.4/FindErrs.c +++ b/Build/source/utils/chktex/chktex-1.6.4/FindErrs.c @@ -42,7 +42,7 @@ struct ErrMsg LaTeXMsgs[emMaxFault + 1] = { ERRMSGS {emMaxFault, etErr, iuOK, 0, INTERNFAULT} }; -#define istex(c) (isalpha(c) || (AtLetter && (c == '@'))) +#define istex(c) (isalpha((unsigned char)c) || (AtLetter && (c == '@'))) #define CTYPE(func) \ static int my_##func(int c) \ { \ @@ -517,7 +517,7 @@ static void PerformBigCmd(char *CmdPtr) PSERR(CmdPtr - Buf, CmdLen, emNoArgFound); } - if (HasWord(CmdBuffer, &NotPreSpaced) && isspace(CmdPtr[-1])) + if (HasWord(CmdBuffer, &NotPreSpaced) && isspace((unsigned char)CmdPtr[-1])) PSERRA(CmdPtr - Buf - 1, 1, emRemPSSpace, CmdBuffer); if ((TmpPtr = HasWord(CmdBuffer, &NoCharNext))) @@ -622,7 +622,7 @@ static void CheckAbbrevs(const char *Buffer) for (i = Abbrev.MaxLen; i >= 0; i--) { *--TmpPtr = *AbbPtr--; - if (!isalpha(*AbbPtr) && HasWord(TmpPtr, &Abbrev)) + if (!isalpha((unsigned char)*AbbPtr) && HasWord(TmpPtr, &Abbrev)) PSERR(Buffer - Buf + 1, 1, emInterWord); if (!*AbbPtr) break; @@ -702,9 +702,9 @@ static void CheckDash(void) { if (LATEX_SPACE(*PrePtr) && LATEX_SPACE(*TmpPtr)) wl = &WordDash; - if (isdigit(*PrePtr) && isdigit(*TmpPtr)) + if (isdigit((unsigned char)*PrePtr) && isdigit((unsigned char)*TmpPtr)) wl = &NumDash; - if (isalpha(*PrePtr) && isalpha(*TmpPtr)) + if (isalpha((unsigned char)*PrePtr) && isalpha((unsigned char)*TmpPtr)) wl = &HyphDash; if (wl) @@ -845,16 +845,16 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) { PrePtr = BufPtr - 1; Char = *BufPtr++; - if (isspace(Char)) + if (isspace((unsigned char)Char)) Char = ' '; switch (Char) { case '~': TmpPtr = NULL; - if (isspace(*PrePtr)) + if (isspace((unsigned char)*PrePtr)) TmpPtr = PrePtr; - else if (isspace(*BufPtr)) + else if (isspace((unsigned char)*BufPtr)) TmpPtr = BufPtr; if (TmpPtr) @@ -868,14 +868,14 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) SKIP_BACK(TmpPtr, TmpC, (LATEX_SPACE(TmpC) || strchr("{}$", TmpC))); - if (isdigit(*TmpPtr)) + if (isdigit((unsigned char)*TmpPtr)) { TmpPtr = BufPtr; SKIP_AHEAD(TmpPtr, TmpC, (LATEX_SPACE(TmpC) || strchr("{}$", TmpC))); - if (isdigit(*TmpPtr)) + if (isdigit((unsigned char)*TmpPtr)) HERE(1, emUseTimes); } /* FALLTHRU */ @@ -931,7 +931,7 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) case 'W': /* case 'X': */ case 'Y': case 'Z': - if (!isalpha(*PrePtr) && (*PrePtr != '\\') && MathMode) + if (!isalpha((unsigned char)*PrePtr) && (*PrePtr != '\\') && MathMode) { TmpPtr = BufPtr; CmdPtr = CmdBuffer; @@ -940,7 +940,7 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) *CmdPtr++ = Char; Char = *TmpPtr++; } - while (isalpha(Char)); + while (isalpha((unsigned char)Char)); *CmdPtr = 0; @@ -978,11 +978,11 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) SKIP_AHEAD(TmpPtr, TmpC, strchr(LTX_GenPunc, TmpC)); if (LATEX_SPACE(*TmpPtr)) { - if (!isupper(*PrePtr) && (*PrePtr != '@') && + if (!isupper((unsigned char)*PrePtr) && (*PrePtr != '@') && (*PrePtr != '.')) { SKIP_AHEAD(TmpPtr, TmpC, LATEX_SPACE(TmpC)); - if (islower(*TmpPtr)) + if (islower((unsigned char)*TmpPtr)) PSERR(BufPtr - Buf, 1, emInterWord); else CheckAbbrevs(&BufPtr[-1]); @@ -996,14 +996,14 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) case ';': /* Regexp: "[A-Z][A-Z][.!?:;]\s+" */ - if (isspace(*BufPtr) && isupper(*PrePtr) && - (isupper(PrePtr[-1]) || (Char != '.'))) + if (isspace((unsigned char)*BufPtr) && isupper((unsigned char)*PrePtr) && + (isupper((unsigned char)PrePtr[-1]) || (Char != '.'))) HERE(1, emInterSent); /* FALLTHRU */ case ',': - if (isspace(*PrePtr) && - !(isdigit(*BufPtr) && + if (isspace((unsigned char)*PrePtr) && + !(isdigit((unsigned char)*BufPtr) && ((BufPtr[-1] == '.') || (BufPtr[-1] == ',')))) PSERR(PrePtr - Buf, 1, emSpacePunct); @@ -1050,8 +1050,8 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) switch (Char) { case '\'': - if (isalpha(*TmpPtr) && - (strchr(LTX_GenPunc, *PrePtr) || isspace(*PrePtr))) + if (isalpha((unsigned char)*TmpPtr) && + (strchr(LTX_GenPunc, *PrePtr) || isspace((unsigned char)*PrePtr))) HERE(TmpPtr - BufPtr + 1, emBeginQ); /* Now check quote style */ @@ -1061,7 +1061,7 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) { char *WordPtr = PrePtr; - SKIP_BACK(WordPtr, TmpC, (isalnum(TmpC) || + SKIP_BACK(WordPtr, TmpC, (isalnum((unsigned char)TmpC) || strchr(LTX_GenPunc, TmpC))); if (*WordPtr != '`') @@ -1080,8 +1080,8 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) break; case '`': - if (isalpha(*PrePtr) && - (strchr(LTX_GenPunc, *TmpPtr) || isspace(*TmpPtr))) + if (isalpha((unsigned char)*PrePtr) && + (strchr(LTX_GenPunc, *TmpPtr) || isspace((unsigned char)*TmpPtr))) HERE(TmpPtr - BufPtr + 1, emEndQ); break; } @@ -1129,9 +1129,9 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) ErrPtr = TmpPtr; - if (isalpha(*TmpPtr)) + if (isalpha((unsigned char)*TmpPtr)) pstcb = &my_isalpha; - else if (isdigit(*TmpPtr)) + else if (isdigit((unsigned char)*TmpPtr)) pstcb = &my_isdigit; else break; @@ -1164,7 +1164,7 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) { PSERR(BufPtr - Buf, 1, emSpaceTerm); } - else if ((*BufPtr == '\\') && (!isalpha(BufPtr[1])) && + else if ((*BufPtr == '\\') && (!isalpha((unsigned char)BufPtr[1])) && (!LATEX_SPACE(BufPtr[1]))) PSERR(BufPtr - Buf, 2, emNotIntended); @@ -1174,7 +1174,7 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) break; case '(': - if (!(!*PrePtr || LATEX_SPACE(*PrePtr) || isdigit(*PrePtr)) || + if (!(!*PrePtr || LATEX_SPACE(*PrePtr) || isdigit((unsigned char)*PrePtr)) || strchr("([{`~", *PrePtr)) { if (PrePtr[-1] != '\\') /* Short cmds */ @@ -1186,16 +1186,16 @@ int FindErr(const char *_RealBuf, const unsigned long _Line) "in front of"); } } - if (isspace(*BufPtr)) + if (isspace((unsigned char)*BufPtr)) PSERRA(BufPtr - Buf, 1, emNoSpaceParen, "after"); HandleBracket(Char); break; case ')': - if (isspace(*PrePtr)) + if (isspace((unsigned char)*PrePtr)) PSERRA(BufPtr - Buf - 1, 1, emNoSpaceParen, "in front of"); - if (isalpha(*BufPtr)) + if (isalpha((unsigned char)*BufPtr)) PSERRA(BufPtr - Buf, 1, emSpaceParen, "after"); HandleBracket(Char); break; diff --git a/Build/source/utils/chktex/chktex-1.6.4/Resource.c b/Build/source/utils/chktex/chktex-1.6.4/Resource.c index 3d8fd09fa5a..21e0cb408c8 100644 --- a/Build/source/utils/chktex/chktex-1.6.4/Resource.c +++ b/Build/source/utils/chktex/chktex-1.6.4/Resource.c @@ -348,7 +348,7 @@ static enum Token ReadWord(char *Buffer, FILE * fh) while (Cont) { Chr = *String++; - if (isalpha(Chr)) + if (isalpha((unsigned char)Chr)) *Ptr++ = Chr; else Cont = FALSE; @@ -374,7 +374,7 @@ static enum Token ReadWord(char *Buffer, FILE * fh) *Ptr++ = Chr; break; default: - if (!isspace(Chr)) + if (!isspace((unsigned char)Chr)) *Ptr++ = Chr; else Cont = FALSE; @@ -417,7 +417,7 @@ static char MapChars(char **String) Chr = *((char *) (*String)++); - switch (tolower(Chr)) + switch (tolower((unsigned char)Chr)) { MAP(QUOTE, QUOTE); MAP(ESCAPE, ESCAPE); @@ -439,12 +439,12 @@ static char MapChars(char **String) for (Cnt = 0; Cnt < 2; Cnt++) { Chr = *((*String)++); - if (isxdigit(Chr)) + if (isxdigit((unsigned char)Chr)) { - Chr = toupper(Chr); + Chr = toupper((unsigned char)Chr); Tmp = (Tmp << 4) + Chr; - if (isdigit(Chr)) + if (isdigit((unsigned char)Chr)) Tmp -= '0'; else Tmp -= 'A' - 10; @@ -490,7 +490,7 @@ static char MapChars(char **String) case 'd': for (Cnt = 0; Cnt < 3; Cnt++) { - if (isdigit(Chr = *((*String)++))) + if (isdigit((unsigned char)(Chr = *((*String)++)))) Tmp = (Tmp * 10) + Chr - '0'; else { diff --git a/Build/source/utils/chktex/chktex-1.6.4/Utility.c b/Build/source/utils/chktex/chktex-1.6.4/Utility.c index b13e4249151..6fa26f3cd79 100644 --- a/Build/source/utils/chktex/chktex-1.6.4/Utility.c +++ b/Build/source/utils/chktex/chktex-1.6.4/Utility.c @@ -231,7 +231,7 @@ char *strlwr(char *String) char TmpC; for (Bufptr = String; (TmpC = *Bufptr); Bufptr++) - *Bufptr = tolower(TmpC); + *Bufptr = tolower((unsigned char)TmpC); return (String); } @@ -291,10 +291,10 @@ int strcasecmp(const char *a, const char *b) aa = *a++; bb = *b++; } - while (aa && (tolower(aa) == tolower(bb))); + while (aa && (tolower((unsigned char)aa) == tolower((unsigned char)bb))); /* bb != 0 is implicit */ - return (tolower(aa) - tolower(bb)); + return (tolower((unsigned char)aa) - tolower((unsigned char)bb)); } #endif -- cgit v1.2.3