mirror of
https://github.com/cc65/cc65.git
synced 2025-08-08 22:25:28 +00:00
Added SB_Compare
git-svn-id: svn://svn.cc65.org/cc65/trunk@3153 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2001-2003 Ullrich von Bassewitz */
|
/* (C) 2001-2004 Ullrich von Bassewitz */
|
||||||
/* R<>merstrasse 52 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@@ -202,7 +202,7 @@ void SB_AppendChar (StrBuf* B, int C)
|
|||||||
if (NewLen > B->Allocated) {
|
if (NewLen > B->Allocated) {
|
||||||
SB_Realloc (B, NewLen);
|
SB_Realloc (B, NewLen);
|
||||||
}
|
}
|
||||||
B->Buf[B->Len] = (char) C;
|
B->Buf[B->Len] = (char) C;
|
||||||
B->Len = NewLen;
|
B->Len = NewLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,3 +302,27 @@ void SB_Move (StrBuf* Target, StrBuf* Source)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int SB_Compare (const StrBuf* S1, const StrBuf* S2)
|
||||||
|
/* Do a lexical compare of S1 and S2. See strcmp for result codes. */
|
||||||
|
{
|
||||||
|
int Result;
|
||||||
|
if (S1->Len < S2->Len) {
|
||||||
|
Result = memcmp (S1->Buf, S2->Buf, S1->Len);
|
||||||
|
if (Result == 0) {
|
||||||
|
/* S1 considered lesser because it's shorter */
|
||||||
|
Result = -1;
|
||||||
|
}
|
||||||
|
} else if (S1->Len > S2->Len) {
|
||||||
|
Result = memcmp (S1->Buf, S2->Buf, S2->Len);
|
||||||
|
if (Result == 0) {
|
||||||
|
/* S2 considered lesser because it's shorter */
|
||||||
|
Result = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Result = memcmp (S1->Buf, S2->Buf, S1->Len);
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2001-2003 Ullrich von Bassewitz */
|
/* (C) 2001-2004 Ullrich von Bassewitz */
|
||||||
/* R<>merstrasse 52 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@@ -343,6 +343,9 @@ void SB_Move (StrBuf* Target, StrBuf* Source);
|
|||||||
* contents of Target, and Source will be empty after the call.
|
* contents of Target, and Source will be empty after the call.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int SB_Compare (const StrBuf* S1, const StrBuf* S2);
|
||||||
|
/* Do a lexical compare of S1 and S2. See strcmp for result codes. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of strbuf.h */
|
/* End of strbuf.h */
|
||||||
|
Reference in New Issue
Block a user