mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 00:22:51 -06:00
strings are stored as length+text and NULL byte is not a terminator
This commit is contained in:
19
src/runtime/c/text.cxx
Normal file
19
src/runtime/c/text.cxx
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "data.h"
|
||||
|
||||
PGF_INTERNAL
|
||||
int textcmp(PgfText &t1, PgfText &t2)
|
||||
{
|
||||
for (size_t i = 0; ; i++) {
|
||||
if (i >= t1.size)
|
||||
return (i - t2.size);
|
||||
if (i >= t2.size)
|
||||
return 1;
|
||||
|
||||
if (t1.text[i] > t2.text[i])
|
||||
return 1;
|
||||
else if (t1.text[i] < t2.text[i])
|
||||
return -1;
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user