From 8add1ad057aa7461e5ef10e1a02ca191844dff20 Mon Sep 17 00:00:00 2001 From: cuz Date: Fri, 5 Jan 2001 19:24:47 +0000 Subject: [PATCH] Use chartype.h instead of ctype.h git-svn-id: svn://svn.cc65.org/cc65/trunk@593 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/main.c | 6 +++--- src/ca65/objcode.c | 6 +++--- src/ca65/scanner.c | 41 +++++------------------------------------ src/cc65/declare.c | 3 +-- src/cc65/ident.c | 8 +++++--- src/cc65/main.c | 6 +++--- src/cc65/optimize.c | 11 ++++++----- src/cc65/pragma.c | 3 +-- src/cc65/preproc.c | 6 ++++-- src/cc65/scanner.c | 13 +++++++------ src/cc65/segname.c | 10 +++++----- src/cc65/util.c | 8 -------- src/cc65/util.h | 3 --- 13 files changed, 43 insertions(+), 81 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index 1601699e2..1d90ea75e 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -36,10 +36,10 @@ #include #include #include -#include #include /* common */ +#include "chartype.h" #include "cmdline.h" #include "target.h" #include "tgttrans.h" @@ -137,14 +137,14 @@ static void DefineSymbol (const char* Def) char SymName [MAX_STR_LEN+1]; /* The symbol must start with a character or underline */ - if (Def [0] != '_' && !isalpha (Def [0])) { + if (Def [0] != '_' && !IsAlpha (Def [0])) { InvDef (Def); } P = Def; /* Copy the symbol, checking the rest */ I = 0; - while (isalnum (*P) || *P == '_') { + while (IsAlNum (*P) || *P == '_') { if (I <= MAX_STR_LEN) { SymName [I++] = *P; } diff --git a/src/ca65/objcode.c b/src/ca65/objcode.c index b1ae6f841..da6d3e3bb 100644 --- a/src/ca65/objcode.c +++ b/src/ca65/objcode.c @@ -35,9 +35,9 @@ #include #include -#include /* common */ +#include "chartype.h" #include "check.h" #include "segdefs.h" #include "xmalloc.h" @@ -131,11 +131,11 @@ static Segment* NewSegment (const char* Name, unsigned SegType) /* Check the segment name for invalid names */ N = Name; - if ((*N != '_' && !isalpha (*N)) || strlen (Name) > 80) { + if ((*N != '_' && !IsAlpha (*N)) || strlen (Name) > 80) { Error (ERR_ILLEGAL_SEGMENT, Name); } do { - if (*N != '_' && !isalnum (*N)) { + if (*N != '_' && !IsAlNum (*N)) { Error (ERR_ILLEGAL_SEGMENT, Name); break; } diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index e1a08e2e4..0c5d753a3 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -42,6 +42,7 @@ #include /* common */ +#include "chartype.h" #include "check.h" #include "fname.h" #include "xmalloc.h" @@ -252,42 +253,10 @@ static void NextChar (void); -static int IsBlank (int C) -/* Return true if the character is a blank or tab */ -{ - return (C == ' ' || C == '\t'); -} - - - -static int IsDigit (int C) -/* Return true if the character is a digit */ -{ - return isdigit (C); -} - - - -static int IsXDigit (int C) -/* Return true if the character is a hexadecimal digit */ -{ - return isxdigit (C); -} - - - -static int IsDDigit (int C) -/* Return true if the character is a dual digit */ -{ - return (C == '0' || C == '1'); -} - - - static int IsIdChar (int C) /* Return true if the character is a valid character for an identifier */ { - return isalnum (C) || + return IsAlNum (C) || (C == '_') || (C == '@' && AtInIdents) || (C == '$' && DollarInIdents); @@ -298,7 +267,7 @@ static int IsIdChar (int C) static int IsIdStart (int C) /* Return true if the character may start an identifier */ { - return isalpha (C) || C == '_'; + return IsAlpha (C) || C == '_'; } @@ -692,13 +661,13 @@ Again: NextChar (); /* 0 or 1 must follow */ - if (!IsDDigit (C)) { + if (!IsBDigit (C)) { Error (ERR_01_EXPECTED); } /* Read the number */ IVal = 0; - while (IsDDigit (C)) { + while (IsBDigit (C)) { if (IVal & 0x80000000) { Error (ERR_NUM_OVERFLOW); IVal = 0; diff --git a/src/cc65/declare.c b/src/cc65/declare.c index b303adc35..dc8ae2460 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -9,7 +9,6 @@ #include #include #include -#include /* common */ #include "xmalloc.h" @@ -59,7 +58,7 @@ static type OptionalQualifiers (type Q) case TOK_CONST: if (Q & T_QUAL_CONST) { Error ("Duplicate qualifier: `const'"); - } + } Q |= T_QUAL_CONST; break; diff --git a/src/cc65/ident.c b/src/cc65/ident.c index 615997ab9..f29f06a74 100644 --- a/src/cc65/ident.c +++ b/src/cc65/ident.c @@ -33,8 +33,10 @@ -#include - +/* common */ +#include "chartype.h" + +/* cc65 */ #include "ident.h" @@ -48,7 +50,7 @@ int IsIdent (char c) /* Return true if the given char may start an identifier */ { - return (isalpha (c) || c == '_'); + return (IsAlpha (c) || c == '_'); } diff --git a/src/cc65/main.c b/src/cc65/main.c index a73622c25..ea83acca1 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -36,11 +36,11 @@ #include #include #include -#include #include /* common */ #include "abend.h" +#include "chartype.h" #include "cmdline.h" #include "fname.h" #include "target.h" @@ -215,12 +215,12 @@ static void DefineSym (const char* Def) const char* P = Def; /* The symbol must start with a character or underline */ - if (Def [0] != '_' && !isalpha (Def [0])) { + if (Def [0] != '_' && !IsAlpha (Def [0])) { InvDef (Def); } /* Check the symbol name */ - while (isalnum (*P) || *P == '_') { + while (IsAlNum (*P) || *P == '_') { ++P; } diff --git a/src/cc65/optimize.c b/src/cc65/optimize.c index c52683ca8..c714cf96f 100644 --- a/src/cc65/optimize.c +++ b/src/cc65/optimize.c @@ -36,10 +36,11 @@ #include #include #include -#include +//#include /* common */ #include "attrib.h" +#include "chartype.h" #include "check.h" #include "xmalloc.h" #include "xsprintf.h" @@ -531,7 +532,7 @@ static int LCHasLine (LineColl* LC, Line* L) static int IsLocalLabel (const Line* L) /* Return true if the line is a local label line */ { - return (L->Line [0] == 'L' && isxdigit (L->Line [1])); + return (L->Line [0] == 'L' && IsXDigit (L->Line [1])); } @@ -547,7 +548,7 @@ static int IsExtLabel (const Line* L) static int IsLabel (const Line* L) /* Return true if the line is a label line */ { - return (L->Line [0] == 'L' && isxdigit (L->Line [1])) || + return (L->Line [0] == 'L' && IsXDigit (L->Line [1])) || (L->Line [0] == '_');; } @@ -647,7 +648,7 @@ static unsigned GetHexNum (const char* S) { unsigned I = 0; unsigned Val = 0; - while (isxdigit (S [I])) { + while (IsXDigit (S [I])) { int C = (unsigned char) (S [I++]); if (C >= 'A') { C -= 'A' - 10; @@ -3168,7 +3169,7 @@ static void OptJumpRTS (void) Line* L = FirstCode; while (L) { /* Is this a jump to a numbered label? */ - if (LineMatch (L, "\tjmp\t") && L->Line [5] == 'L' && isdigit (L->Line [6])) { + if (LineMatch (L, "\tjmp\t") && L->Line [5] == 'L' && IsDigit (L->Line [6])) { /* Yes. Get the target label */ Line* Target = GetTargetLine (L->Line+5); diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index c68009c02..b4b9bae16 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -35,8 +35,7 @@ #include #include -#include - + /* cc65 */ #include "codegen.h" #include "error.h" diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index 4877dad3b..2a9935ac5 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -5,10 +5,12 @@ #include #include #include -#include -#include "../common/xmalloc.h" +/* common */ +#include "chartype.h" +#include "xmalloc.h" +/* cc65 */ #include "codegen.h" #include "error.h" #include "expr.h" diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 7af2e8dd4..e8939052c 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -13,6 +13,7 @@ #include /* common */ +#include "chartype.h" #include "tgttrans.h" /* cc65 */ @@ -170,7 +171,7 @@ void SymName (char* s) *s++ = CurC; } NextChar (); - } while (IsIdent (CurC) || isdigit (CurC)); + } while (IsIdent (CurC) || IsDigit (CurC)); *s = '\0'; } @@ -201,10 +202,10 @@ static void unknown (char C) static unsigned hexval (int c) /* Convert a hex digit into a value */ { - if (!isxdigit (c)) { + if (!IsXDigit (c)) { Error ("Invalid hexadecimal digit: `%c'", c); } - if (isdigit (c)) { + if (IsDigit (c)) { return c - '0'; } else { return toupper (c) - 'A' + 10; @@ -389,7 +390,7 @@ void NextToken (void) } /* Determine the next token from the lookahead */ - if (isdigit (CurC)) { + if (IsDigit (CurC)) { /* A number */ int HaveSuffix; /* True if we have a type suffix */ @@ -415,9 +416,9 @@ void NextToken (void) } } while (1) { - if (isdigit (CurC)) { + if (IsDigit (CurC)) { k = k * base + (CurC - '0'); - } else if (base == 16 && isxdigit (CurC)) { + } else if (base == 16 && IsXDigit (CurC)) { k = (k << 4) + hexval (CurC); } else { break; /* not digit */ diff --git a/src/cc65/segname.c b/src/cc65/segname.c index aa138d65c..4bfbf7c44 100644 --- a/src/cc65/segname.c +++ b/src/cc65/segname.c @@ -34,9 +34,9 @@ #include -#include /* common */ +#include "chartype.h" #include "check.h" #include "xmalloc.h" @@ -46,7 +46,7 @@ /*****************************************************************************/ -/* Data */ +/* Data */ /*****************************************************************************/ @@ -57,7 +57,7 @@ char* SegmentNames[SEG_COUNT]; /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ @@ -90,13 +90,13 @@ int ValidSegName (const char* Name) /* Return true if the given segment name is valid, return false otherwise */ { /* Must start with '_' or a letter */ - if ((*Name != '_' && !isalpha(*Name)) || strlen(Name) > 80) { + if ((*Name != '_' && !IsAlpha(*Name)) || strlen(Name) > 80) { return 0; } /* Can have letters, digits or the underline */ while (*++Name) { - if (*Name != '_' && !isalnum(*Name)) { + if (*Name != '_' && !IsAlNum(*Name)) { return 0; } } diff --git a/src/cc65/util.c b/src/cc65/util.c index c39232dc0..46e959d19 100644 --- a/src/cc65/util.c +++ b/src/cc65/util.c @@ -25,14 +25,6 @@ -int IsBlank (char c) -/* Return true if c is a space, tab or newline */ -{ - return (c == ' ' || c == '\t' || c == '\n'); -} - - - int IsQuoteChar (char c) /* Return true if c is a single or double quote */ { diff --git a/src/cc65/util.h b/src/cc65/util.h index 240a3ec34..bfbe1e04e 100644 --- a/src/cc65/util.h +++ b/src/cc65/util.h @@ -17,9 +17,6 @@ -int IsBlank (char c); -/* Return true if c is a space, tab or newline */ - int IsQuoteChar (char c); /* Return true if c is a single or double quote */ -- 2.39.5