Changeset dbbbe75b in mainline


Ignore:
Timestamp:
2018-01-15T21:54:21Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8348846
Parents:
c718bda
Message:

Add missing standard functions to <ctype.h>

Location:
uspace/lib
Files:
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/ctype.h

    rc718bda rdbbbe75b  
    6161}
    6262
     63static inline int isblank(int c)
     64{
     65        return c == ' ' || c == '\t';
     66}
     67
     68static inline int iscntrl(int c)
     69{
     70        return (c >= 0 && c < 0x20) || c == 0x7E;
     71}
     72
     73static inline int isprint(int c)
     74{
     75        return c >= 0 && c < 0x80 && !iscntrl(c);
     76}
     77
     78static inline int isgraph(int c)
     79{
     80        return isprint(c) && c != ' ';
     81}
     82
    6383static inline int isspace(int c)
    6484{
     
    7595                return 0;
    7696        }
     97}
     98
     99static inline int ispunct(int c)
     100{
     101        return !isspace(c) && !isalnum(c) && isprint(c);
     102}
     103
     104static inline int isxdigit(int c)
     105{
     106        return isdigit(c) ||
     107            (c >= 'a' && c <= 'f') ||
     108            (c >= 'A' && c <= 'F');
    77109}
    78110
  • uspace/lib/posix/include/posix/ctype.h

    rc718bda rdbbbe75b  
    4343#include "libc/ctype.h"
    4444
    45 /* Classification of Characters */
    46 extern int __POSIX_DEF__(isxdigit)(int c);
    47 extern int __POSIX_DEF__(isblank)(int c);
    48 extern int __POSIX_DEF__(iscntrl)(int c);
    49 extern int __POSIX_DEF__(isgraph)(int c);
    50 extern int __POSIX_DEF__(isprint)(int c);
    51 extern int __POSIX_DEF__(ispunct)(int c);
     45/* Obsolete Functions and Macros */
     46extern int isascii(int c);
     47extern int toascii(int c);
    5248
    53 /* Obsolete Functions and Macros */
    54 extern int __POSIX_DEF__(isascii)(int c);
    55 extern int __POSIX_DEF__(toascii)(int c);
    56 #undef _tolower
    5749#define _tolower(c) ((c) - 'A' + 'a')
    58 #undef _toupper
    5950#define _toupper(c) ((c) - 'a' + 'A')
    60 
    61 
    6251
    6352#endif /* POSIX_CTYPE_H_ */
  • uspace/lib/posix/source/ctype.c

    rc718bda rdbbbe75b  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "posix/ctype.h"
    40 
    41 /**
    42  * Checks whether character is a hexadecimal digit.
    43  *
    44  * @param c Character to inspect.
    45  * @return Non-zero if character match the definition, zero otherwise.
    46  */
    47 int posix_isxdigit(int c)
    48 {
    49         return isdigit(c) ||
    50             (c >= 'a' && c <= 'f') ||
    51             (c >= 'A' && c <= 'F');
    52 }
    53 
    54 /**
    55  * Checks whether character is a word separator.
    56  *
    57  * @param c Character to inspect.
    58  * @return Non-zero if character match the definition, zero otherwise.
    59  */
    60 int posix_isblank(int c)
    61 {
    62         return c == ' ' || c == '\t';
    63 }
    64 
    65 /**
    66  * Checks whether character is a control character.
    67  *
    68  * @param c Character to inspect.
    69  * @return Non-zero if character match the definition, zero otherwise.
    70  */
    71 int posix_iscntrl(int c)
    72 {
    73         return c < 0x20 || c == 0x7E;
    74 }
    75 
    76 /**
    77  * Checks whether character is any printing character except space.
    78  *
    79  * @param c Character to inspect.
    80  * @return Non-zero if character match the definition, zero otherwise.
    81  */
    82 int posix_isgraph(int c)
    83 {
    84         return posix_isprint(c) && c != ' ';
    85 }
    86 
    87 /**
    88  * Checks whether character is a printing character.
    89  *
    90  * @param c Character to inspect.
    91  * @return Non-zero if character match the definition, zero otherwise.
    92  */
    93 int posix_isprint(int c)
    94 {
    95         return posix_isascii(c) && !posix_iscntrl(c);
    96 }
    97 
    98 /**
    99  * Checks whether character is a punctuation.
    100  *
    101  * @param c Character to inspect.
    102  * @return Non-zero if character match the definition, zero otherwise.
    103  */
    104 int posix_ispunct(int c)
    105 {
    106         return !isspace(c) && !isalnum(c) && posix_isprint(c);
    107 }
    10837
    10938/**
     
    11342 * @return Non-zero if character match the definition, zero otherwise.
    11443 */
    115 int posix_isascii(int c)
     44int isascii(int c)
    11645{
    11746        return c >= 0 && c < 128;
     
    12453 * @return Coverted character.
    12554 */
    126 int posix_toascii(int c)
     55int toascii(int c)
    12756{
    12857        return c & 0x7F;
  • uspace/lib/posix/source/fnmatch.c

    rc718bda rdbbbe75b  
    183183        { "alnum", isalnum },
    184184        { "alpha", isalpha },
    185         { "blank", posix_isblank },
    186         { "cntrl", posix_iscntrl },
     185        { "blank", isblank },
     186        { "cntrl", iscntrl },
    187187        { "digit", isdigit },
    188         { "graph", posix_isgraph },
     188        { "graph", isgraph },
    189189        { "lower", islower },
    190         { "print", posix_isprint },
    191         { "punct", posix_ispunct },
     190        { "print", isprint },
     191        { "punct", ispunct },
    192192        { "space", isspace },
    193193        { "upper", isupper },
    194         { "xdigit", posix_isxdigit }
     194        { "xdigit", isxdigit }
    195195};
    196196
  • uspace/lib/posix/source/stdlib/strtold.c

    rc718bda rdbbbe75b  
    347347        bool after_decimal = false;
    348348       
    349         while (posix_isxdigit(*str) || (!after_decimal && *str == DECIMAL_POINT)) {
     349        while (isxdigit(*str) || (!after_decimal && *str == DECIMAL_POINT)) {
    350350                if (*str == DECIMAL_POINT) {
    351351                        after_decimal = true;
     
    459459        /* check for a hex number */
    460460        if (nptr[i] == '0' && tolower(nptr[i + 1]) == 'x' &&
    461             (posix_isxdigit(nptr[i + 2]) ||
    462             (nptr[i + 2] == RADIX && posix_isxdigit(nptr[i + 3])))) {
     461            (isxdigit(nptr[i + 2]) ||
     462            (nptr[i + 2] == RADIX && isxdigit(nptr[i + 3])))) {
    463463                i += 2;
    464464               
  • uspace/lib/uri/uri.c

    rc718bda rdbbbe75b  
    4242
    4343#include "uri.h"
    44 #include "ctype.h"
     44#include "internal/ctype.h"
    4545
    4646static char *cut_str(const char *start, const char *end)
Note: See TracChangeset for help on using the changeset viewer.