Use chartype.h instead of ctype.h

git-svn-id: svn://svn.cc65.org/cc65/trunk@593 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2001-01-05 19:24:47 +00:00
parent 37da7dff98
commit 8add1ad057
13 changed files with 43 additions and 81 deletions

View File

@@ -36,10 +36,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include <time.h> #include <time.h>
/* common */ /* common */
#include "chartype.h"
#include "cmdline.h" #include "cmdline.h"
#include "target.h" #include "target.h"
#include "tgttrans.h" #include "tgttrans.h"
@@ -137,14 +137,14 @@ static void DefineSymbol (const char* Def)
char SymName [MAX_STR_LEN+1]; char SymName [MAX_STR_LEN+1];
/* The symbol must start with a character or underline */ /* The symbol must start with a character or underline */
if (Def [0] != '_' && !isalpha (Def [0])) { if (Def [0] != '_' && !IsAlpha (Def [0])) {
InvDef (Def); InvDef (Def);
} }
P = Def; P = Def;
/* Copy the symbol, checking the rest */ /* Copy the symbol, checking the rest */
I = 0; I = 0;
while (isalnum (*P) || *P == '_') { while (IsAlNum (*P) || *P == '_') {
if (I <= MAX_STR_LEN) { if (I <= MAX_STR_LEN) {
SymName [I++] = *P; SymName [I++] = *P;
} }

View File

@@ -35,9 +35,9 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <ctype.h>
/* common */ /* common */
#include "chartype.h"
#include "check.h" #include "check.h"
#include "segdefs.h" #include "segdefs.h"
#include "xmalloc.h" #include "xmalloc.h"
@@ -131,11 +131,11 @@ static Segment* NewSegment (const char* Name, unsigned SegType)
/* Check the segment name for invalid names */ /* Check the segment name for invalid names */
N = Name; N = Name;
if ((*N != '_' && !isalpha (*N)) || strlen (Name) > 80) { if ((*N != '_' && !IsAlpha (*N)) || strlen (Name) > 80) {
Error (ERR_ILLEGAL_SEGMENT, Name); Error (ERR_ILLEGAL_SEGMENT, Name);
} }
do { do {
if (*N != '_' && !isalnum (*N)) { if (*N != '_' && !IsAlNum (*N)) {
Error (ERR_ILLEGAL_SEGMENT, Name); Error (ERR_ILLEGAL_SEGMENT, Name);
break; break;
} }

View File

@@ -42,6 +42,7 @@
#include <sys/stat.h> #include <sys/stat.h>
/* common */ /* common */
#include "chartype.h"
#include "check.h" #include "check.h"
#include "fname.h" #include "fname.h"
#include "xmalloc.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) static int IsIdChar (int C)
/* Return true if the character is a valid character for an identifier */ /* Return true if the character is a valid character for an identifier */
{ {
return isalnum (C) || return IsAlNum (C) ||
(C == '_') || (C == '_') ||
(C == '@' && AtInIdents) || (C == '@' && AtInIdents) ||
(C == '$' && DollarInIdents); (C == '$' && DollarInIdents);
@@ -298,7 +267,7 @@ static int IsIdChar (int C)
static int IsIdStart (int C) static int IsIdStart (int C)
/* Return true if the character may start an identifier */ /* Return true if the character may start an identifier */
{ {
return isalpha (C) || C == '_'; return IsAlpha (C) || C == '_';
} }
@@ -692,13 +661,13 @@ Again:
NextChar (); NextChar ();
/* 0 or 1 must follow */ /* 0 or 1 must follow */
if (!IsDDigit (C)) { if (!IsBDigit (C)) {
Error (ERR_01_EXPECTED); Error (ERR_01_EXPECTED);
} }
/* Read the number */ /* Read the number */
IVal = 0; IVal = 0;
while (IsDDigit (C)) { while (IsBDigit (C)) {
if (IVal & 0x80000000) { if (IVal & 0x80000000) {
Error (ERR_NUM_OVERFLOW); Error (ERR_NUM_OVERFLOW);
IVal = 0; IVal = 0;

View File

@@ -9,7 +9,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <ctype.h>
/* common */ /* common */
#include "xmalloc.h" #include "xmalloc.h"

View File

@@ -33,8 +33,10 @@
#include <ctype.h> /* common */
#include "chartype.h"
/* cc65 */
#include "ident.h" #include "ident.h"
@@ -48,7 +50,7 @@
int IsIdent (char c) int IsIdent (char c)
/* Return true if the given char may start an identifier */ /* Return true if the given char may start an identifier */
{ {
return (isalpha (c) || c == '_'); return (IsAlpha (c) || c == '_');
} }

View File

@@ -36,11 +36,11 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
#include <errno.h> #include <errno.h>
/* common */ /* common */
#include "abend.h" #include "abend.h"
#include "chartype.h"
#include "cmdline.h" #include "cmdline.h"
#include "fname.h" #include "fname.h"
#include "target.h" #include "target.h"
@@ -215,12 +215,12 @@ static void DefineSym (const char* Def)
const char* P = Def; const char* P = Def;
/* The symbol must start with a character or underline */ /* The symbol must start with a character or underline */
if (Def [0] != '_' && !isalpha (Def [0])) { if (Def [0] != '_' && !IsAlpha (Def [0])) {
InvDef (Def); InvDef (Def);
} }
/* Check the symbol name */ /* Check the symbol name */
while (isalnum (*P) || *P == '_') { while (IsAlNum (*P) || *P == '_') {
++P; ++P;
} }

View File

@@ -36,10 +36,11 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h> //#include <ctype.h>
/* common */ /* common */
#include "attrib.h" #include "attrib.h"
#include "chartype.h"
#include "check.h" #include "check.h"
#include "xmalloc.h" #include "xmalloc.h"
#include "xsprintf.h" #include "xsprintf.h"
@@ -531,7 +532,7 @@ static int LCHasLine (LineColl* LC, Line* L)
static int IsLocalLabel (const Line* L) static int IsLocalLabel (const Line* L)
/* Return true if the line is a local label line */ /* 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) static int IsLabel (const Line* L)
/* Return true if the line is a label line */ /* 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] == '_');; (L->Line [0] == '_');;
} }
@@ -647,7 +648,7 @@ static unsigned GetHexNum (const char* S)
{ {
unsigned I = 0; unsigned I = 0;
unsigned Val = 0; unsigned Val = 0;
while (isxdigit (S [I])) { while (IsXDigit (S [I])) {
int C = (unsigned char) (S [I++]); int C = (unsigned char) (S [I++]);
if (C >= 'A') { if (C >= 'A') {
C -= 'A' - 10; C -= 'A' - 10;
@@ -3168,7 +3169,7 @@ static void OptJumpRTS (void)
Line* L = FirstCode; Line* L = FirstCode;
while (L) { while (L) {
/* Is this a jump to a numbered label? */ /* 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 */ /* Yes. Get the target label */
Line* Target = GetTargetLine (L->Line+5); Line* Target = GetTargetLine (L->Line+5);

View File

@@ -35,7 +35,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
/* cc65 */ /* cc65 */
#include "codegen.h" #include "codegen.h"

View File

@@ -5,10 +5,12 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <ctype.h>
#include "../common/xmalloc.h" /* common */
#include "chartype.h"
#include "xmalloc.h"
/* cc65 */
#include "codegen.h" #include "codegen.h"
#include "error.h" #include "error.h"
#include "expr.h" #include "expr.h"

View File

@@ -13,6 +13,7 @@
#include <ctype.h> #include <ctype.h>
/* common */ /* common */
#include "chartype.h"
#include "tgttrans.h" #include "tgttrans.h"
/* cc65 */ /* cc65 */
@@ -170,7 +171,7 @@ void SymName (char* s)
*s++ = CurC; *s++ = CurC;
} }
NextChar (); NextChar ();
} while (IsIdent (CurC) || isdigit (CurC)); } while (IsIdent (CurC) || IsDigit (CurC));
*s = '\0'; *s = '\0';
} }
@@ -201,10 +202,10 @@ static void unknown (char C)
static unsigned hexval (int c) static unsigned hexval (int c)
/* Convert a hex digit into a value */ /* Convert a hex digit into a value */
{ {
if (!isxdigit (c)) { if (!IsXDigit (c)) {
Error ("Invalid hexadecimal digit: `%c'", c); Error ("Invalid hexadecimal digit: `%c'", c);
} }
if (isdigit (c)) { if (IsDigit (c)) {
return c - '0'; return c - '0';
} else { } else {
return toupper (c) - 'A' + 10; return toupper (c) - 'A' + 10;
@@ -389,7 +390,7 @@ void NextToken (void)
} }
/* Determine the next token from the lookahead */ /* Determine the next token from the lookahead */
if (isdigit (CurC)) { if (IsDigit (CurC)) {
/* A number */ /* A number */
int HaveSuffix; /* True if we have a type suffix */ int HaveSuffix; /* True if we have a type suffix */
@@ -415,9 +416,9 @@ void NextToken (void)
} }
} }
while (1) { while (1) {
if (isdigit (CurC)) { if (IsDigit (CurC)) {
k = k * base + (CurC - '0'); k = k * base + (CurC - '0');
} else if (base == 16 && isxdigit (CurC)) { } else if (base == 16 && IsXDigit (CurC)) {
k = (k << 4) + hexval (CurC); k = (k << 4) + hexval (CurC);
} else { } else {
break; /* not digit */ break; /* not digit */

View File

@@ -34,9 +34,9 @@
#include <string.h> #include <string.h>
#include <ctype.h>
/* common */ /* common */
#include "chartype.h"
#include "check.h" #include "check.h"
#include "xmalloc.h" #include "xmalloc.h"
@@ -90,13 +90,13 @@ int ValidSegName (const char* Name)
/* Return true if the given segment name is valid, return false otherwise */ /* Return true if the given segment name is valid, return false otherwise */
{ {
/* Must start with '_' or a letter */ /* Must start with '_' or a letter */
if ((*Name != '_' && !isalpha(*Name)) || strlen(Name) > 80) { if ((*Name != '_' && !IsAlpha(*Name)) || strlen(Name) > 80) {
return 0; return 0;
} }
/* Can have letters, digits or the underline */ /* Can have letters, digits or the underline */
while (*++Name) { while (*++Name) {
if (*Name != '_' && !isalnum(*Name)) { if (*Name != '_' && !IsAlNum(*Name)) {
return 0; return 0;
} }
} }

View File

@@ -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) int IsQuoteChar (char c)
/* Return true if c is a single or double quote */ /* Return true if c is a single or double quote */
{ {

View File

@@ -17,9 +17,6 @@
int IsBlank (char c);
/* Return true if c is a space, tab or newline */
int IsQuoteChar (char c); int IsQuoteChar (char c);
/* Return true if c is a single or double quote */ /* Return true if c is a single or double quote */