Added ctype.h module
git-svn-id: http://picoc.googlecode.com/svn/trunk@448 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
9969c4881a
commit
b313de2aa1
2
Makefile
2
Makefile
|
@ -7,7 +7,7 @@ SRCS = picoc.c table.c lex.c parse.c expression.c heap.c type.c \
|
|||
variable.c clibrary.c platform.c include.c \
|
||||
platform/platform_unix.c platform/library_unix.c \
|
||||
cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \
|
||||
cstdlib/time.c cstdlib/errno.c
|
||||
cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c
|
||||
OBJS := $(SRCS:%.c=%.o)
|
||||
|
||||
all: depend $(TARGET)
|
||||
|
|
109
cstdlib/ctype.c
Normal file
109
cstdlib/ctype.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/* string.h library for large systems - small embedded systems use clibrary.c instead */
|
||||
#include <ctype.h>
|
||||
#include "../picoc.h"
|
||||
|
||||
#ifndef BUILTIN_MINI_STDLIB
|
||||
|
||||
void StdIsalnum(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isalnum(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsalpha(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isalpha(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsblank(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isblank(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIscntrl(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = iscntrl(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsdigit(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isdigit(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsgraph(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isgraph(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIslower(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = islower(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsprint(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isprint(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIspunct(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = ispunct(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsspace(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isspace(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsupper(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isupper(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsxdigit(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isxdigit(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdTolower(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = tolower(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdToupper(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = toupper(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsascii(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = isascii(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdToascii(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = toascii(Param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
/* all string.h functions */
|
||||
struct LibraryFunction StdCtypeFunctions[] =
|
||||
{
|
||||
{ StdIsalnum, "int isalnum(int);" },
|
||||
{ StdIsalpha, "int isalpha(int);" },
|
||||
{ StdIsblank, "int isblank(int);" },
|
||||
{ StdIscntrl, "int iscntrl(int);" },
|
||||
{ StdIsdigit, "int isdigit(int);" },
|
||||
{ StdIsgraph, "int isgraph(int);" },
|
||||
{ StdIslower, "int islower(int);" },
|
||||
{ StdIsprint, "int isprint(int);" },
|
||||
{ StdIspunct, "int ispunct(int);" },
|
||||
{ StdIsspace, "int isspace(int);" },
|
||||
{ StdIsupper, "int isupper(int);" },
|
||||
{ StdIsxdigit, "int isxdigit(int);" },
|
||||
{ StdTolower, "int tolower(int);" },
|
||||
{ StdToupper, "int toupper(int);" },
|
||||
{ StdIsascii, "int isascii(int);" },
|
||||
{ StdToascii, "int toascii(int);" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
#endif /* !BUILTIN_MINI_STDLIB */
|
|
@ -18,6 +18,7 @@ struct IncludeLibrary *IncludeLibList = NULL;
|
|||
/* initialise the built-in include libraries */
|
||||
void IncludeInit()
|
||||
{
|
||||
IncludeRegister("ctype.h", NULL, &StdCtypeFunctions, NULL);
|
||||
IncludeRegister("errno.h", &StdErrnoSetupFunc, NULL, NULL);
|
||||
IncludeRegister("stdio.h", &StdioSetupFunc, &StdioFunctions, StdioDefs);
|
||||
IncludeRegister("math.h", &MathSetupFunc, &MathFunctions, NULL);
|
||||
|
|
Loading…
Reference in a new issue