Bugfix: strcmp
#1

I didn't know where to post it so i did here.. If it is wrong section , mods please move it to correct...

Here is code:
Код:
stock strcmpEx(const string1[], const string2[], bool:ignorecase=false, length=cellmax)
{
	if((!strlen(string1) || !strlen(string2))) return -1; // JoeBullet's brain -_- Written in 10 sec lol
	return strcmp(string1, string2, ignorecase, length);
}
Here is test command to confirm work:
Код:
if(!strcmp(cmd, "/strcmpex", true))
{
  if(strcmpEx(" ","How are you?",false)==0) return SendClientMessage(playerid, COLOR_YELLOW, "Dont Work !!!");
  else return SendClientMessage(playerid, COLOR_YELLOW, "Work :))");
}
I tested It with GF mod IRC wich returned same on normal STRCMP because of strcmp bug..
Reply
#2

Quote:
Originally Posted by JoeBullet
I didn't know where to post it so i did here.. If it is wrong section , mods please move it to correct...

Here is code:
Код:
stock strcmpEx(const string1[], const string2[], bool:ignorecase=false, length=cellmax)
{
	if((!strlen(string1) || !strlen(string2))) return -1; // JoeBullet's brain -_- Written in 10 sec lol
	return strcmp(string1, string2, ignorecase, length);
}
Here is test command to confirm work:
Код:
if(!strcmp(cmd, "/strcmpex", true))
{
  if(strcmpEx(" ","How are you?",false)==0) return SendClientMessage(playerid, COLOR_YELLOW, "Dont Work !!!");
  else return SendClientMessage(playerid, COLOR_YELLOW, "Work :))");
}
I tested It with GF mod IRC wich returned same on normal STRCMP because of strcmp bug..
Quote:
Originally Posted by JoeBullet
I didn't know where to post it so i did here.. If it is wrong section , mods please move it to correct...

Here is code:
Код:
stock strcmpEx(const string1[], const string2[], bool:ignorecase=false, length=cellmax)
{
	if((!strlen(string1) || !strlen(string2))) return -1; // JoeBullet's brain -_- Written in 10 sec lol
	return strcmp(string1, string2, ignorecase, length);
}
Here is test command to confirm work:
Код:
if(!strcmp(cmd, "/strcmpex", true))
{
  if(strcmpEx(" ","How are you?",false)==0) return SendClientMessage(playerid, COLOR_YELLOW, "Dont Work !!!");
  else return SendClientMessage(playerid, COLOR_YELLOW, "Work :))");
}
I tested It with GF mod IRC wich returned same on normal STRCMP because of strcmp bug..
Nice job althouhgt the bug was fixed in gto^^
Reply
#3

It says on Wiki that it isnt fixed and in all where i looked
Reply
#4

pawn Код:
// strcmp() returns are fucked, this is an override to fix returns
// will return 1/true if strings are equal
public strcomp(str1[],str2[],bool:ignorecase)
{
    if ((!strlen(str1)) && (!strlen(str2))) return 1;
    if (!strlen(str1)) return 0;
    if (!strlen(str2)) return 0;
    if (strcmp(str1,str2,ignorecase) == 0)
    {
      return 1;
    }
    return 0;
}
Credits to the creator of GTO.
Reply
#5

I did my strcmp fix myself and i didn't copied it.. You can see by code...
And I never did looked into that called GTO ...
My script is simply and working
Reply
#6

There was a version in dutils or dini by dracoblue called "equal", which used basicly the same code as your strcmpex. (So similar it looked copied at first :P (Ofcourse I'm not accusing you, it's simple code so could look similar (I'm just explaining myself to prevent flame wars)))
Reply
#7

Personally, I would use this:

pawn Код:
stock strcmpEx(const string1[], const string2[], bool:ignorecase=false, length=cellmax)
{
    if((!strlen(string1) && !strlen(string2))) return 0; // Added this, i'll explain
    if((!strlen(string1) || !strlen(string2))) return -1; // JoeBullet's brain -_- Written in 10 sec lol
    return strcmp(string1, string2, ignorecase, length);
}
If I want to see if one string is the same as another, I wouldn't return -1 if they were both empty, seeing as that would be logically incorrect, because the strings ARE exactly the same =]
Reply
#8

Should be in Usefull functions.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)