strings are stored as length+text and NULL byte is not a terminator

This commit is contained in:
krangelov
2021-07-30 13:45:22 +02:00
parent a8b3537184
commit 17629e4821
6 changed files with 44 additions and 6 deletions

19
src/runtime/c/text.cxx Normal file
View 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++;
}
}