diff options
Diffstat (limited to 'Build/source/texk/chktex/chktex-1.7.1')
-rw-r--r-- | Build/source/texk/chktex/chktex-1.7.1/ChkTeX.c | 36 | ||||
-rw-r--r-- | Build/source/texk/chktex/chktex-1.7.1/ChkTeX.h | 67 | ||||
-rw-r--r-- | Build/source/texk/chktex/chktex-1.7.1/FindErrs.c | 24 | ||||
-rw-r--r-- | Build/source/texk/chktex/chktex-1.7.1/OpSys.c | 33 | ||||
-rw-r--r-- | Build/source/texk/chktex/chktex-1.7.1/Resource.c | 6 | ||||
-rw-r--r-- | Build/source/texk/chktex/chktex-1.7.1/configure.in | 1 |
6 files changed, 99 insertions, 68 deletions
diff --git a/Build/source/texk/chktex/chktex-1.7.1/ChkTeX.c b/Build/source/texk/chktex/chktex-1.7.1/ChkTeX.c index 495a518f37f..95688728af4 100644 --- a/Build/source/texk/chktex/chktex-1.7.1/ChkTeX.c +++ b/Build/source/texk/chktex/chktex-1.7.1/ChkTeX.c @@ -195,9 +195,9 @@ enum Quote Quote; char VerbNormal[] = "%k %n in %f line %l: %m\n" "%r%s%t\n" "%u\n"; -#define DEF(type, name, value) type name = value; -OPTION_DEFAULTS -STATE_VARS +#define DEF(type, name, value) type name = value +OPTION_DEFAULTS; +STATE_VARS; #undef DEF FILE *OutputFile = NULL; @@ -334,7 +334,15 @@ int main(int argc, char **argv) #endif OutputFile = stdout; +#ifdef KPATHSEA + kpse_set_program_name(argv[0], "chktex"); + PrgName = kpse_program_name; +#ifdef WIN32 + setmode(fileno(stdout), _O_BINARY); +#endif +#else PrgName = argv[0]; +#endif #undef KEY #undef LCASE @@ -426,7 +434,7 @@ int main(int argc, char **argv) for (Count = 0; Count < NUMBRACKETS; Count++) Brackets[Count] = 0L; -#define DEF(type, name, value) name = value; +#define DEF(type, name, value) name = value STATE_VARS; #undef DEF if (UsingStdIn) @@ -512,7 +520,11 @@ static int OpenOut(void) if (Success) { +#ifdef KPATHSEA + if (!(OutputFile = fopen(OutputName, "wb"))) +#else if (!(OutputFile = fopen(OutputName, "w"))) +#endif { PrintPrgErr(pmOutOpen); Success = FALSE; @@ -687,8 +699,8 @@ static void ResetStacks(void) static void ResetSettings(void) { -#define DEF(type, name, value) name = value; - OPTION_DEFAULTS +#define DEF(type, name, value) name = value + OPTION_DEFAULTS; #undef DEF if (OutputFile != stdout) { @@ -855,11 +867,13 @@ static int ParseArgs(int argc, char **argv) nextc = ShiftArg(&optarg); break; - LOOP(warntype, case 'w': - 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((unsigned char)*optarg)) + LOOP(warntype, + case 'w': 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((unsigned char)*optarg)) { nextc = ParseNumArg(&Err, -1, &optarg); if (betw(emMinFault, Err, emMaxFault)) diff --git a/Build/source/texk/chktex/chktex-1.7.1/ChkTeX.h b/Build/source/texk/chktex/chktex-1.7.1/ChkTeX.h index f2b2e13c386..aba2c215239 100644 --- a/Build/source/texk/chktex/chktex-1.7.1/ChkTeX.h +++ b/Build/source/texk/chktex/chktex-1.7.1/ChkTeX.h @@ -72,6 +72,14 @@ # include <strings.h> #endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif + +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif + #include "types.h" #ifndef LONG_MAX @@ -286,38 +294,39 @@ extern unsigned long Brackets[NUMBRACKETS]; extern FILE *OutputFile, *InputFile; #define OPTION_DEFAULTS \ - DEF(int, GlobalRC, TRUE) \ - DEF(int, WipeVerb, TRUE) \ - DEF(int, BackupOut, TRUE) \ - DEF(int, Quiet, FALSE) \ - DEF(int, LicenseOnly, FALSE) \ - DEF(int, UsingStdIn, FALSE) \ - DEF(int, InputFiles, TRUE) \ - DEF(int, HeadErrOut, TRUE) \ - DEF(const char *, OutputName, "") \ - DEF(const char *, PseudoInName, NULL) \ - DEF(char *, OutputFormat, VerbNormal) \ - DEF(char *, PipeOutputFormat, NULL) \ - DEF(const char *, Delimit, ":") \ - DEF(long, DebugLevel, 0) \ + DEF(int, GlobalRC, TRUE); \ + DEF(int, WipeVerb, TRUE); \ + DEF(int, BackupOut, TRUE); \ + DEF(int, Quiet, FALSE); \ + DEF(int, LicenseOnly, FALSE); \ + DEF(int, UsingStdIn, FALSE); \ + DEF(int, InputFiles, TRUE); \ + DEF(int, HeadErrOut, TRUE); \ + DEF(const char *, OutputName, ""); \ + DEF(const char *, PseudoInName, NULL); \ + DEF(char *, OutputFormat, VerbNormal); \ + DEF(char *, PipeOutputFormat, NULL); \ + DEF(const char *, Delimit, ":"); \ + DEF(long, DebugLevel, 0); \ DEF(int, NoLineSupp, FALSE) #define STATE_VARS \ - DEF(enum ItState, ItState, itOff) /* Are we doing italics? */ \ - DEF(int, AtLetter, FALSE) /* Whether `@' is a letter or not. */ \ - DEF(int, InHeader, TRUE) /* Whether we're in the header */ \ - DEF(int, VerbMode, FALSE) /* Whether we're in complete ignore-mode */ \ - DEF(long, MathMode, 0) /* Whether we're in math mode or not */ \ - DEF(const char *, VerbStr, "") /* String we'll terminate verbmode upon */ \ - DEF(unsigned long, ErrPrint, 0) /* # errors printed */ \ - DEF(unsigned long, WarnPrint, 0) /* # warnings printed */ \ - DEF(unsigned long, UserSupp, 0) /* # user suppressed warnings */ \ - DEF(unsigned long, LineSupp, 0) /* # warnings suppressed on a single line */ \ - DEF(unsigned long long, FileSuppressions, 0) /* # warnings suppressed in a file */ \ - DEF(unsigned long long, UserFileSuppressions, 0) /* # User warnings suppressed in a file */ - -#define DEF(type, name, value) extern type name; -OPTION_DEFAULTS STATE_VARS + DEF(enum ItState, ItState, itOff); /* Are we doing italics? */ \ + DEF(int, AtLetter, FALSE); /* Whether `@' is a letter or not. */ \ + DEF(int, InHeader, TRUE); /* Whether we're in the header */ \ + DEF(int, VerbMode, FALSE); /* Whether we're in complete ignore-mode */ \ + DEF(long, MathMode, 0); /* Whether we're in math mode or not */ \ + DEF(const char *, VerbStr, ""); /* String we'll terminate verbmode upon */ \ + DEF(unsigned long, ErrPrint, 0); /* # errors printed */ \ + DEF(unsigned long, WarnPrint, 0); /* # warnings printed */ \ + DEF(unsigned long, UserSupp, 0); /* # user suppressed warnings */ \ + DEF(unsigned long, LineSupp, 0); /* # warnings suppressed on a single line */ \ + DEF(uint64_t, FileSuppressions, 0); /* # warnings suppressed in a file */ \ + DEF(uint64_t, UserFileSuppressions, 0); /* # User warnings suppressed in a file */ + +#define DEF(type, name, value) extern type name +OPTION_DEFAULTS; +STATE_VARS; #undef DEF extern struct Stack CharStack, InputStack, EnvStack; diff --git a/Build/source/texk/chktex/chktex-1.7.1/FindErrs.c b/Build/source/texk/chktex/chktex-1.7.1/FindErrs.c index 6ec6e6828f8..7d4eed52066 100644 --- a/Build/source/texk/chktex/chktex-1.7.1/FindErrs.c +++ b/Build/source/texk/chktex/chktex-1.7.1/FindErrs.c @@ -75,7 +75,7 @@ static int my_##func(int c) \ return(func(c)); \ } -#define SUPPRESSED_ON_LINE(c) (LineSuppressions & (1LL<<c)) +#define SUPPRESSED_ON_LINE(c) (LineSuppressions & ((uint64_t)1<<c)) #define INUSE(c) \ ((LaTeXMsgs[(enum ErrNum) c].InUse == iuOK) && !SUPPRESSED_ON_LINE(c)) @@ -146,12 +146,12 @@ const char FileSuppDelim[] = "chktex-file "; /* * A bit field used to hold the suppressions for the current line. */ -static unsigned long long LineSuppressions; +static uint64_t LineSuppressions; /* * A bit field used to hold the suppressions of numbered user warnings * for the current line. */ -static unsigned long long UserLineSuppressions; +static uint64_t UserLineSuppressions; static unsigned long Line; @@ -344,7 +344,7 @@ static char *PreProcess(void) if (!NoLineSupp) { int error; - const int MaxSuppressionBits = sizeof(unsigned long long)*8-1; + const int MaxSuppressionBits = 63; /* Convert to lowercase to compare with LineSuppDelim */ EscapePtr = ++TmpPtr; /* move past NUL terminator */ @@ -365,13 +365,13 @@ static char *PreProcess(void) } if (error > 0) { - FileSuppressions |= (1LL << error); - LineSuppressions |= (1LL << error); + FileSuppressions |= ((uint64_t)1 << error); + LineSuppressions |= ((uint64_t)1 << error); } else { - UserFileSuppressions |= (1LL << (-error)); - UserLineSuppressions |= (1LL << (-error)); + UserFileSuppressions |= ((uint64_t)1 << (-error)); + UserLineSuppressions |= ((uint64_t)1 << (-error)); } } TmpPtr = EscapePtr; @@ -388,11 +388,11 @@ static char *PreProcess(void) if (error > 0) { - LineSuppressions |= (1LL << error); + LineSuppressions |= ((uint64_t)1 << error); } else { - UserLineSuppressions |= (1LL << (-error)); + UserLineSuppressions |= ((uint64_t)1 << (-error)); } } } @@ -882,11 +882,11 @@ static void CheckRest(void) while (offset < len) { /* Check if this warning should be suppressed. */ - if (UserLineSuppressions != 0LL && NamedWarning) + if (UserLineSuppressions && NamedWarning) { /* The warning can be named with positive or negative numbers. */ int UserWarningNumber = abs(atoi(ErrMessage)); - if (UserLineSuppressions & (1LL << UserWarningNumber)) + if (UserLineSuppressions & ((uint64_t)1 << UserWarningNumber)) { break; } diff --git a/Build/source/texk/chktex/chktex-1.7.1/OpSys.c b/Build/source/texk/chktex/chktex-1.7.1/OpSys.c index d2891b08581..3c6ad702bcb 100644 --- a/Build/source/texk/chktex/chktex-1.7.1/OpSys.c +++ b/Build/source/texk/chktex/chktex-1.7.1/OpSys.c @@ -37,6 +37,10 @@ #include "OpSys.h" #include "Utility.h" +#ifdef KPATHSEA +#include <kpathsea/variable.h> +#endif + #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif @@ -105,6 +109,8 @@ static char term_buffer[2048]; #ifdef __MSDOS__ # define LOCALRCFILE RCBASENAME +#elif defined(WIN32) +# define LOCALRCFILE RCBASENAME #else # define LOCALRCFILE "." RCBASENAME #endif @@ -173,6 +179,8 @@ int SetupVars(void) #ifdef __MSDOS__ if ((Env = getenv("CHKTEXRC")) || (Env = getenv("CHKTEX_HOME"))) +#elif defined(TEX_LIVE) + if ((Env = kpse_var_value("CHKTEXRC"))) #else if ((Env = getenv("CHKTEXRC"))) @@ -181,6 +189,9 @@ int SetupVars(void) { strcpy(ConfigFile, Env); tackon(ConfigFile, LOCALRCFILE); +#ifdef TEX_LIVE + free(Env); +#endif } else #ifdef __MSDOS__ @@ -217,24 +228,20 @@ int SetupVars(void) break; case liSysDir: /* System dir for resource files */ #ifdef TEX_LIVE - if ((Env = getenv("CHKTEX_CONFIG"))) + if ((Env = kpse_var_value("CHKTEX_CONFIG"))) { strcpy(ConfigFile, Env); + free(Env); } - else + else if ((Env = kpse_var_value("TEXMFMAIN"))) { - FILE *f; - *ConfigFile = 0; - if ((f = popen("kpsewhich -expand-var='$TEXMFMAIN'", "r"))) - { - if (1 == fscanf(f, "%1024s", ConfigFile)) - { - tackon(ConfigFile, "chktex"); - tackon(ConfigFile, RCBASENAME); - } - (void)pclose(f); - } + strcpy(ConfigFile, Env); + tackon(ConfigFile, "chktex"); + tackon(ConfigFile, RCBASENAME); + free(Env); } + else + *ConfigFile = 0; #else /* TEX_LIVE */ #if defined(__unix__) || defined(__MSDOS__) strcpy(ConfigFile, SYSCONFDIR); diff --git a/Build/source/texk/chktex/chktex-1.7.1/Resource.c b/Build/source/texk/chktex/chktex-1.7.1/Resource.c index 68a4b3196e5..f589d65d0a7 100644 --- a/Build/source/texk/chktex/chktex-1.7.1/Resource.c +++ b/Build/source/texk/chktex/chktex-1.7.1/Resource.c @@ -75,7 +75,7 @@ struct KeyWord Keys[] = { BIT(Equal), /* = */ \ BIT(Word), /* Keyword */ \ BIT(Item) /* List item */ \ -}; +} #undef BIT #define BIT BITDEF1 @@ -323,7 +323,7 @@ static enum Token ReadWord(char *Buffer, FILE * fh) #define DONEKEY (FLG_Open | FLG_Equal | FLG_BrOpen) #define DONELIST (FLG_Close | FLG_BrClose) -#define TOKEN(c, ctxt, tk) case c: if(Expect & (ctxt)) Retval = tk; LAST(token); +#define TOKEN(c, ctxt, tk) case c: if(Expect & (ctxt)) Retval = tk; LAST(token) LOOP(token, TOKEN('{', DONEKEY, FLG_Open); @@ -331,7 +331,7 @@ static enum Token ReadWord(char *Buffer, FILE * fh) TOKEN('=', DONEKEY, FLG_Equal); TOKEN(']', DONELIST, FLG_BrClose); TOKEN('}', DONELIST, FLG_Close); - ); + ) if (Retval != FLG_Eof) { OnceMore = FALSE; diff --git a/Build/source/texk/chktex/chktex-1.7.1/configure.in b/Build/source/texk/chktex/chktex-1.7.1/configure.in index eacc296d951..bedb8d4b1a7 100644 --- a/Build/source/texk/chktex/chktex-1.7.1/configure.in +++ b/Build/source/texk/chktex/chktex-1.7.1/configure.in @@ -158,6 +158,7 @@ dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T +AC_TYPE_UINT64_T dnl Checks for library functions. AC_FUNC_VPRINTF |