Made strcmp() results more consistent for testing

git-svn-id: http://picoc.googlecode.com/svn/trunk@376 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-11-04 20:45:32 +00:00
parent d2718f62c5
commit aea16db269
2 changed files with 8 additions and 5 deletions

View file

@ -450,12 +450,14 @@ void LibStrncpy(struct ParseState *Parser, struct Value *ReturnValue, struct Val
void LibStrcmp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
{
ReturnValue->Val->Integer = strcmp(Param[0]->Val->NativePointer, Param[1]->Val->NativePointer);
int Result = strcmp(Param[0]->Val->NativePointer, Param[1]->Val->NativePointer);
ReturnValue->Val->Integer = (Result > 0) ? 1 : ((Result < 0) ? -1 : 0);
}
void LibStrncmp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
{
ReturnValue->Val->Integer = strncmp(Param[0]->Val->NativePointer, Param[1]->Val->NativePointer, Param[2]->Val->Integer);
int Result = strncmp(Param[0]->Val->NativePointer, Param[1]->Val->NativePointer, Param[2]->Val->Integer);
ReturnValue->Val->Integer = (Result > 0) ? 1 : ((Result < 0) ? -1 : 0);
}
void LibStrcat(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
@ -490,7 +492,8 @@ void LibMemcpy(struct ParseState *Parser, struct Value *ReturnValue, struct Valu
void LibMemcmp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
{
ReturnValue->Val->Integer = memcmp(Param[0]->Val->NativePointer, Param[1]->Val->NativePointer, Param[2]->Val->Integer);
int Result = memcmp(Param[0]->Val->NativePointer, Param[1]->Val->NativePointer, Param[2]->Val->Integer);
ReturnValue->Val->Integer = (Result > 0) ? 1 : ((Result < 0) ? -1 : 0);
}
#endif

View file

@ -5,10 +5,10 @@ gollo
-1
5
gollo!
6
1
0
0
-19
-1
ollo!
lo!
NULL