1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-09 22:29:35 +00:00

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 <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
/* 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;
}

View File

@ -35,9 +35,9 @@
#include <string.h>
#include <errno.h>
#include <ctype.h>
/* 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;
}

View File

@ -42,6 +42,7 @@
#include <sys/stat.h>
/* 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;

View File

@ -9,7 +9,6 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
/* 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;

View File

@ -33,8 +33,10 @@
#include <ctype.h>
/* 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 == '_');
}

View File

@ -36,11 +36,11 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
/* 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;
}

View File

@ -36,10 +36,11 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//#include <ctype.h>
/* 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);

View File

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

View File

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

View File

@ -13,6 +13,7 @@
#include <ctype.h>
/* 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 */

View File

@ -34,9 +34,9 @@
#include <string.h>
#include <ctype.h>
/* 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;
}
}

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)
/* 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);
/* Return true if c is a single or double quote */