From 1239d6d8a89943020af5622786839550801370a4 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Sun, 25 Oct 2009 21:12:06 +0000 Subject: [PATCH] Added some more string functions git-svn-id: http://picoc.googlecode.com/svn/trunk@349 21eae674-98b7-11dd-bd71-f92a316d2d60 --- clibrary.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/clibrary.c b/clibrary.c index 3ce6375..0dfec0f 100644 --- a/clibrary.c +++ b/clibrary.c @@ -508,6 +508,26 @@ void LibStrncmp(struct ParseState *Parser, struct Value *ReturnValue, struct Val ReturnValue->Val->Integer = strncmp(Param[0]->Val->NativePointer, Param[1]->Val->NativePointer, Param[2]->Val->Integer); } +void LibStrcat(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) +{ + strcat(Param[0]->Val->NativePointer, Param[1]->Val->NativePointer); +} + +void LibIndex(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) +{ + ReturnValue->Val->NativePointer = index(Param[0]->Val->NativePointer, Param[1]->Val->Integer); +} + +void LibRindex(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) +{ + ReturnValue->Val->NativePointer = rindex(Param[0]->Val->NativePointer, Param[1]->Val->Integer); +} + +void LibStrlen(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) +{ + ReturnValue->Val->Integer = strlen(Param[0]->Val->NativePointer); +} + void LibMemset(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) { memset(Param[0]->Val->NativePointer, Param[1]->Val->Integer, Param[2]->Val->Integer); @@ -561,6 +581,10 @@ struct LibraryFunction CLibrary[] = { LibStrncpy, "void strncpy(char *,char *,int)" }, { LibStrcmp, "int strcmp(char *,char *)" }, { LibStrncmp, "int strncmp(char *,char *,int)" }, + { LibStrcat, "void strcat(char *,char *)" }, + { LibIndex, "char *index(char *,int)" }, + { LibRindex, "char *rindex(char *,int)" }, + { LibStrlen, "int strlen(char *)" }, { LibMemset, "void memset(void *,int,int)" }, { LibMemcpy, "void memcpy(void *,void *,int)" }, { LibMemcmp, "int memcmp(void *,void *,int)" },