Changeset 21abb9a in mainline


Ignore:
Timestamp:
2011-06-22T14:12:45Z (13 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:
0319e104
Parents:
8d7e82c1
Message:

Add the rest of C99 functions to ctype.h

Location:
uspace/lib/posix
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/ctype.c

    r8d7e82c1 r21abb9a  
    3838#include "ctype.h"
    3939
     40// TODO: propose for inclusion in libc
     41
    4042/**
    41  *
    42  * @param ch
     43 * Checks whether character is a hexadecimal digit.
     44 *
     45 * @param c
    4346 * @return
    4447 */
    45 int posix_isxdigit(int ch)
     48int posix_isxdigit(int c)
    4649{
    47         return isdigit(ch) ||
    48             (ch >= 'a' && ch <= 'f') ||
    49             (ch >= 'A' && ch <= 'F');
     50        return isdigit(c) ||
     51            (c >= 'a' && c <= 'f') ||
     52            (c >= 'A' && c <= 'F');
     53}
     54
     55/**
     56 * Checks whether character is a word separator.
     57 *
     58 * @param c
     59 * @return
     60 */
     61int posix_isblank(int c)
     62{
     63        return c == ' ' || c == '\t';
     64}
     65
     66/**
     67 * Checks whether character is a control character.
     68 *
     69 * @param c
     70 * @return
     71 */
     72int posix_iscntrl(int c)
     73{
     74        return c < 0x20 || c == 0x7E;
     75}
     76
     77/**
     78 * Checks whether character is any printing character except space.
     79 *
     80 * @param c
     81 * @return
     82 */
     83int posix_isgraph(int c)
     84{
     85        return posix_isprint(c) && c != ' ';
     86}
     87
     88/**
     89 * Checks whether character is a printing character.
     90 *
     91 * @param c
     92 * @return
     93 */
     94int posix_isprint(int c)
     95{
     96        return !posix_iscntrl(c);
     97}
     98
     99/**
     100 * Checks whether character is a punctuation.
     101 *
     102 * @param c
     103 * @return
     104 */
     105int posix_ispunct(int c)
     106{
     107        return !isspace(c) && !isalnum(c);
    50108}
    51109
  • uspace/lib/posix/ctype.h

    r8d7e82c1 r21abb9a  
    4040
    4141/* Classification of Characters */
    42 extern int posix_isxdigit(int ch);
     42extern int posix_isxdigit(int c);
     43extern int posix_isblank(int c);
     44extern int posix_iscntrl(int c);
     45extern int posix_isgraph(int c);
     46extern int posix_isprint(int c);
     47extern int posix_ispunct(int c);
    4348
    4449#ifndef LIBPOSIX_INTERNAL
    4550        #define isxdigit posix_isxdigit
     51        #define isblank posix_isblank
     52        #define iscntrl posix_iscntrl
     53        #define isgraph posix_isgraph
     54        #define isprint posix_isprint
     55        #define ispunct posix_ispunct
    4656#endif
    4757
Note: See TracChangeset for help on using the changeset viewer.