Changeset f7428b1 in buchla-68k for include/ctype.h


Ignore:
Timestamp:
07/10/2017 01:26:59 AM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
5fa506d
Parents:
c3aee8a
Message:

Started to rework include files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/ctype.h

    rc3aee8a rf7428b1  
    1010        the equivalent Lattice C macros.  This means that isascii(c) should
    1111        be used if it is necessary to restrict the results to true ASCII.
    12 
    13         If SYS5CODE is TRUE these macros will use the same table definitions
    14         as System 5 Unix(tm).  In this case these behave well even when fed
    15         an EOF.  The EOF character value, -1, is not defined as being in any
    16         of the classes tested for.  If SYS5CODE is FALSE, the Alcyon table
    17         will be used, and EOF will not work properly.
    18 
    19         Define _CTYPE_C for compiling the ctype.c file, undefine otherwise.
    20 
    21         The symbol _ii_ is defined to be the base of the table used.
    2212
    2313                isascii(c)  non-zero if c is ASCII
     
    4636                _tolower(c) returns the lower case version of c
    4737                _toupper(c) returns the upper case version of c
    48 
    49                 tonumber(c) converts c from ASCII to integer
    5038   ============================================================================
    5139*/
     
    5543*/
    5644
    57 #define SYS5CODE        0       /* define non-zero for System 5 / Aztec C */
    58 
    59 #if     SYS5CODE
    60 
    61 #define _ii_    _ctype+1
    62 
    63 /* System 5 Unix(tm) / Aztec C table definitions */
    64 
    65 #define _U      0x01    /* upper case */
    66 #define _L      0x02    /* lower case */
    67 #define _N      0x04    /* numeric 0..9 */
    68 #define _S      0x08    /* whitespace */
    69 #define _P      0x10    /* punctuation */
    70 #define _C      0x20    /* control 00..1F */
    71 #define _B      0x40    /* blank */
    72 #define _X      0x80    /* hex digit */
    73 
    74 #else
    75 
    76 #define _ii_    __atab
     45#pragma once
    7746
    7847/* Digital Research / Alcyon C table definitions */
     
    8756#define _X      0x80    /* hex digit */
    8857
    89 #endif
    90 
    91 #ifndef _CTYPE_C
    92 
    93 #if     SYS5CODE
    94 
    95 extern  char _ctype[];          /* character type table */
    96 
    97 #else   /* SYS5CODE */
    98 
    99 extern  void    ___atab(void);
    100 extern  int8_t __atab[];                /* character type table */
    101 
    102 #endif  /* SYS5CODE */
    103 
    104 extern  int16_t tolower(int16_t c);
    105 extern  int16_t toupper(int16_t c);
    106 
    107 #endif  /* _CTYPE_C */
    108 
    10958/*
    11059
    11160*/
    11261
    113 #define isascii(c)      (!((c)&~0x7F))
     62#define isascii(c)      (!((c) & ~0x7f))
    11463
    115 #define isprint(c)      ((_ii_)[c]&(_P|_U|_L|_N|_B))
    116 #define isgraph(c)      ((_ii_)[c]&(_P|_U|_L|_N))
    117 #define iscntrl(c)      ((_ii_)[c]&_C)
     64#define isprint(c)      (__atab[(c) & 0xff] & (_P | _U | _L | _N | _B))
     65#define isgraph(c)      (__atab[(c) & 0xff] & (_P | _U | _L | _N))
     66#define iscntrl(c)      (__atab[(c) & 0xff] & _C)
    11867
    119 #define isalpha(c)      ((_ii_)[c]&(_U|_L))
    120 #define isupper(c)      ((_ii_)[c]&_U)
    121 #define islower(c)      ((_ii_)[c]&_L)
     68#define isalpha(c)      (__atab[(c) & 0xff] & (_U | _L))
     69#define isupper(c)      (__atab[(c) & 0xff] & _U)
     70#define islower(c)      (__atab[(c) & 0xff] & _L)
    12271
    123 #define isdigit(c)      ((_ii_)[c]&_N)
    124 #define isxdigit(c)     ((_ii_)[c]&_X)
     72#define isdigit(c)      (__atab[(c) & 0xff] & _N)
     73#define isxdigit(c)     (__atab[(c) & 0xff] & _X)
    12574
    126 #define isalnum(c)      ((_ii_)[c]&(_U|_L|_N))
     75#define isalnum(c)      (__atab[(c) & 0xff] & (_U | _L | _N))
    12776
    128 #define isspace(c)      ((_ii_)[c]&_S)
    129 #define ispunct(c)      ((_ii_)[c]&_P)
     77#define isspace(c)      (__atab[(c) & 0xff] & _S)
     78#define ispunct(c)      (__atab[(c) & 0xff] & _P)
    13079
    131 #define iscsym(c)       (isalnum(c)||(((c)&127)==0x5F))
    132 #define iscsymf(c)      (isalpha(c)||(((c)&127)==0x5F))
     80#define iscsym(c)       (isalnum(c) || (((c) & 0x7f) == 0x5f))
     81#define iscsymf(c)      (isalpha(c) || (((c) & 0x7f) == 0x5f))
    13382
    134 #define toascii(c)      ((c)&0x7F)
     83#define toascii(c)      ((c) & 0x7f)
    13584
    136 #define _toupper(c)     ((c)-'a'+'A')
    137 #define _tolower(c)     ((c)-'A'+'a')
    138 
    139 #define tonumber(c)     ((((c)&0x7F)>'9')?((islower(c)?_toupper(c):c)-'A'+10):(c&0x0F))
    140 
     85#define _toupper(c)     ((c) - 'a' + 'A')
     86#define _tolower(c)     ((c) - 'A' + 'a')
Note: See TracChangeset for help on using the changeset viewer.