Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1905 → Rev 1906

/programs/develop/libraries/newlib/ctype/isascii.c
0,0 → 1,43
/*
FUNCTION
<<isascii>>---ASCII character predicate
 
INDEX
isascii
 
ANSI_SYNOPSIS
#include <ctype.h>
int isascii(int <[c]>);
 
TRAD_SYNOPSIS
#include <ctype.h>
int isascii(<[c]>);
 
DESCRIPTION
<<isascii>> is a macro which returns non-zero when <[c]> is an ASCII
character, and 0 otherwise. It is defined for all integer values.
 
You can use a compiled subroutine instead of the macro definition by
undefining the macro using `<<#undef isascii>>'.
 
RETURNS
<<isascii>> returns non-zero if the low order byte of <[c]> is in the range
0 to 127 (<<0x00>>--<<0x7F>>).
 
PORTABILITY
<<isascii>> is ANSI C.
 
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
 
 
 
#undef isascii
 
int
_DEFUN(isascii,(c),int c)
{
return c >= 0 && c< 128;
}
/programs/develop/libraries/newlib/ctype/isblank.c
0,0 → 1,41
 
/*
FUNCTION
<<isblank>>---blank character predicate
 
INDEX
isblank
 
ANSI_SYNOPSIS
#include <ctype.h>
int isblank(int <[c]>);
 
TRAD_SYNOPSIS
#include <ctype.h>
int isblank(<[c]>);
 
DESCRIPTION
<<isblank>> is a function which classifies ASCII integer values by table
lookup. It is a predicate returning non-zero for blank characters, and 0
for other characters.
 
RETURNS
<<isblank>> returns non-zero if <[c]> is a blank character.
 
PORTABILITY
<<isblank>> is C99.
 
No supporting OS subroutines are required.
*/
 
#include <_ansi.h>
#include <ctype.h>
 
 
 
#undef isblank
int
_DEFUN(isblank,(c),int c)
{
return ((__ctype_ptr__[c+1] & _B) || (c == '\t'));
}
/programs/develop/libraries/newlib/ctype/toascii.c
0,0 → 1,41
/*
FUNCTION
<<toascii>>---force integers to ASCII range
 
INDEX
toascii
 
ANSI_SYNOPSIS
#include <ctype.h>
int toascii(int <[c]>);
 
TRAD_SYNOPSIS
#include <ctype.h>
int toascii(<[c]>);
int (<[c]>);
 
DESCRIPTION
<<toascii>> is a macro which coerces integers to the ASCII range (0--127) by zeroing any higher-order bits.
 
You can use a compiled subroutine instead of the macro definition by
undefining this macro using `<<#undef toascii>>'.
 
RETURNS
<<toascii>> returns integers between 0 and 127.
 
PORTABILITY
<<toascii>> is not ANSI C.
 
No supporting OS subroutines are required.
*/
 
#include <_ansi.h>
#include <ctype.h>
#undef toascii
 
int
_DEFUN(toascii,(c),int c)
{
return (c)&0177;
}
 
/programs/develop/libraries/newlib/ctype/towctrans.c
0,0 → 1,97
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
 
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/*
FUNCTION
<<towctrans>>---extensible wide-character translation
 
INDEX
towctrans
 
ANSI_SYNOPSIS
#include <wctype.h>
wint_t towctrans(wint_t <[c]>, wctrans_t <[w]>);
 
TRAD_SYNOPSIS
#include <wctype.h>
wint_t towctrans(<[c]>, <[w]>)
wint_t <[c]>;
wctrans_t <[w]>;
 
 
DESCRIPTION
<<towctrans>> is a function which converts wide characters based on
a specified translation type <[w]>. If the translation type is
invalid or cannot be applied to the current character, no change
to the character is made.
 
RETURNS
<<towctrans>> returns the translated equivalent of <[c]> when it is a
valid for the given translation, otherwise, it returns the input character.
When the translation type is invalid, <<errno>> is set <<EINVAL>>.
 
PORTABILITY
<<towctrans>> is C99.
 
No supporting OS subroutines are required.
*/
 
#include <_ansi.h>
#include <string.h>
#include <reent.h>
#include <wctype.h>
#include <errno.h>
#include "local.h"
 
wint_t
_DEFUN (_towctrans_r, (r, c, w),
struct _reent *r _AND
wint_t c _AND
wctrans_t w)
{
if (w == WCT_TOLOWER)
return towlower (c);
else if (w == WCT_TOUPPER)
return towupper (c);
else
{
r->_errno = EINVAL;
return c;
}
}
 
#ifndef _REENT_ONLY
wint_t
_DEFUN (towctrans, (c, w),
wint_t c _AND
wctrans_t w)
{
return _towctrans_r (_REENT, c, w);
}
#endif /* !_REENT_ONLY */
/programs/develop/libraries/newlib/ctype/wctrans.c
0,0 → 1,94
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
 
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/*
FUNCTION
<<wctrans>>---get wide-character translation type
 
INDEX
wctrans
 
ANSI_SYNOPSIS
#include <wctype.h>
wctrans_t wctrans(const char *<[c]>);
 
TRAD_SYNOPSIS
#include <wctype.h>
wctrans_t wctrans(<[c]>)
const char * <[c]>;
 
 
DESCRIPTION
<<wctrans>> is a function which takes a string <[c]> and gives back
the appropriate wctrans_t type value associated with the string,
if one exists. The following values are guaranteed to be recognized:
"tolower" and "toupper".
 
RETURNS
<<wctrans>> returns 0 and sets <<errno>> to <<EINVAL>> if the
given name is invalid. Otherwise, it returns a valid non-zero wctrans_t
value.
 
PORTABILITY
<<wctrans>> is C99.
 
No supporting OS subroutines are required.
*/
 
#include <_ansi.h>
#include <string.h>
#include <reent.h>
#include <wctype.h>
#include <errno.h>
#include "local.h"
 
wctrans_t
_DEFUN (_wctrans_r, (r, c),
struct _reent *r _AND
const char *c)
{
if (!strcmp (c, "tolower"))
return WCT_TOLOWER;
else if (!strcmp (c, "toupper"))
return WCT_TOUPPER;
else
{
r->_errno = EINVAL;
return 0;
}
}
 
#ifndef _REENT_ONLY
wctrans_t
_DEFUN (wctrans, (c),
const char *c)
{
return _wctrans_r (_REENT, c);
}
#endif /* !_REENT_ONLY */
/programs/develop/libraries/newlib/ctype/wctype.c
0,0 → 1,137
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
 
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/*
FUNCTION
<<wctype>>---get wide-character classification type
 
INDEX
wctype
 
ANSI_SYNOPSIS
#include <wctype.h>
wctype_t wctype(const char *<[c]>);
 
TRAD_SYNOPSIS
#include <wctype.h>
wctype_t wctype(<[c]>)
const char * <[c]>;
 
 
DESCRIPTION
<<wctype>> is a function which takes a string <[c]> and gives back
the appropriate wctype_t type value associated with the string,
if one exists. The following values are guaranteed to be recognized:
"alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print",
"punct", "space", "upper", and "xdigit".
 
RETURNS
<<wctype>> returns 0 and sets <<errno>> to <<EINVAL>> if the
given name is invalid. Otherwise, it returns a valid non-zero wctype_t
value.
 
PORTABILITY
<<wctype>> is C99.
 
No supporting OS subroutines are required.
*/
 
#include <_ansi.h>
#include <string.h>
#include <reent.h>
#include <wctype.h>
#include <errno.h>
#include "local.h"
 
wctype_t
_DEFUN (_wctype_r, (r, c),
struct _reent *r _AND
const char *c)
{
switch (*c)
{
case 'a':
if (!strcmp (c, "alnum"))
return WC_ALNUM;
else if (!strcmp (c, "alpha"))
return WC_ALPHA;
break;
case 'b':
if (!strcmp (c, "blank"))
return WC_BLANK;
break;
case 'c':
if (!strcmp (c, "cntrl"))
return WC_CNTRL;
break;
case 'd':
if (!strcmp (c, "digit"))
return WC_DIGIT;
break;
case 'g':
if (!strcmp (c, "graph"))
return WC_GRAPH;
break;
case 'l':
if (!strcmp (c, "lower"))
return WC_LOWER;
break;
case 'p':
if (!strcmp (c, "print"))
return WC_PRINT;
else if (!strcmp (c, "punct"))
return WC_PUNCT;
break;
case 's':
if (!strcmp (c, "space"))
return WC_SPACE;
break;
case 'u':
if (!strcmp (c, "upper"))
return WC_UPPER;
break;
case 'x':
if (!strcmp (c, "xdigit"))
return WC_XDIGIT;
break;
}
 
/* otherwise invalid */
r->_errno = EINVAL;
return 0;
}
 
#ifndef _REENT_ONLY
wctype_t
_DEFUN (wctype, (c),
const char *c)
{
return _wctype_r (_REENT, c);
}
#endif /* !_REENT_ONLY */