Changeset dbbbe75b in mainline for uspace/lib/posix/source/ctype.c


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>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.