StrCmpZstr
StrCmpZstr
Description
Compare string with a null-terminated const char* string
Parameters
| Name | Direction | Description |
|---|---|---|
str |
in | Pointer to Str object to compare with. |
zstr |
in | Null-terminated string to compare with. |
Returns
+ve or -ve depending on above or below in lexical ordering 0 if both are equal
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Str.c:208:
char *zstr = generate_cstring(data, offset, size, 20);
if (zstr) {
int result = StrCmpZstr(str, zstr);
(void)result; // Suppress unused variable warning
free(zstr);- In
Parse.c:23:
result = result && (KvConfigLen(&cfg) == 3);
result = result && KvConfigContains(&cfg, "host");
result = result && host && StrCmpZstr(host, "localhost") == 0;
result = result && KvConfigGetI64(&cfg, "port", &port) && (port == 8080);
result = result && KvConfigGetBool(&cfg, "debug", &debug) && debug;- In
Parse.c:53:
result = result && (si.pos == si.length);
result = result && (KvConfigLen(&cfg) == 4);
result = result && path && StrCmpZstr(path, "/srv/my app") == 0;
result = result && user && StrCmpZstr(user, "root") == 0;
result = result && greet && StrCmpZstr(greet, "hello world") == 0;- In
Parse.c:54:
result = result && (KvConfigLen(&cfg) == 4);
result = result && path && StrCmpZstr(path, "/srv/my app") == 0;
result = result && user && StrCmpZstr(user, "root") == 0;
result = result && greet && StrCmpZstr(greet, "hello world") == 0;
result = result && empty && (empty->length == 0);- In
Parse.c:55:
result = result && path && StrCmpZstr(path, "/srv/my app") == 0;
result = result && user && StrCmpZstr(user, "root") == 0;
result = result && greet && StrCmpZstr(greet, "hello world") == 0;
result = result && empty && (empty->length == 0);- In
Parse.c:80:
result = result && (host_copy.length > 0);
result = result && (host_copy.data != stored_host->data);
result = result && (StrCmpZstr(&host_copy, "localhost") == 0);
result = result && (StrCmpZstr(stored_host, "localhost") == 0);- In
Parse.c:81:
result = result && (host_copy.data != stored_host->data);
result = result && (StrCmpZstr(&host_copy, "localhost") == 0);
result = result && (StrCmpZstr(stored_host, "localhost") == 0);
host_copy.data[0] = 'L';- In
Parse.c:85:
host_copy.data[0] = 'L';
result = result && (StrCmpZstr(&host_copy, "Localhost") == 0);
result = result && (StrCmpZstr(stored_host, "localhost") == 0);- In
Parse.c:86:
result = result && (StrCmpZstr(&host_copy, "Localhost") == 0);
result = result && (StrCmpZstr(stored_host, "localhost") == 0);
StrDeinit(&host_copy);- In
Io.Read.c:707:
WriteFmt("Input: '{}', Output: '{} {}'", in, result1, result2);
bool test2_pass = (StrCmpZstr(&result1, "HELLO") == 0);
test2_pass &= (StrCmpZstr(&result2, "WORLD") == 0);
WriteFmt("Expected: 'HELLO WORLD', Pass: {}\n\n", test2_pass ? "true" : "false");- In
Io.Read.c:708:
bool test2_pass = (StrCmpZstr(&result1, "HELLO") == 0);
test2_pass &= (StrCmpZstr(&result2, "WORLD") == 0);
WriteFmt("Expected: 'HELLO WORLD', Pass: {}\n\n", test2_pass ? "true" : "false");
success = success && test2_pass;- In
Io.Read.c:730:
WriteFmt("Input: '{}', Output: '{}{}'", in, result1, result2);
bool test2_pass = (StrCmpZstr(&result1, "HELLO") == 0);
test2_pass &= (StrCmpZstr(&result2, " WORLD MIGHTY MISRA") == 0); // notice the extra space
WriteFmt("Expected: 'HELLO WORLD MIGHTY MISRA', Pass: {}\n\n", test2_pass ? "true" : "false");- In
Io.Read.c:731:
bool test2_pass = (StrCmpZstr(&result1, "HELLO") == 0);
test2_pass &= (StrCmpZstr(&result2, " WORLD MIGHTY MISRA") == 0); // notice the extra space
WriteFmt("Expected: 'HELLO WORLD MIGHTY MISRA', Pass: {}\n\n", test2_pass ? "true" : "false");
success = success && test2_pass;- In
JSON.h:240:
#define JR_STR_KV(si, k, str) \
do { \
if (!StrCmpZstr(&key, (k))) { \
Str my_str = StrInit(); \
si = JReadString((si), &my_str); \- In
JSON.h:285:
#define JR_INT_KV(si, k, i) \
do { \
if (!StrCmpZstr(&key, (k))) { \
i64 my_int = 0; \
si = JReadInteger((si), &my_int); \- In
JSON.h:330:
#define JR_FLT_KV(si, k, f) \
do { \
if (!StrCmpZstr(&key, (k))) { \
f64 my_flt = 0; \
si = JReadFloat((si), &my_flt); \- In
JSON.h:375:
#define JR_BOOL_KV(si, k, b) \
do { \
if (!StrCmpZstr(&key, (k))) { \
bool my_b = 0; \
si = JReadBool((si), &my_b); \- In
JSON.h:623:
#define JR_OBJ_KV(si, k, reader) \
do { \
if (!StrCmpZstr(&key, (k))) { \
JR_OBJ(si, reader); \
} \- In
JSON.h:648:
#define JR_ARR_KV(si, k, reader) \
do { \
if (!StrCmpZstr(&key, (k))) { \
JR_ARR(si, reader); \
} \
Last updated on