Hi Biterider!
I found interesting to make a little modification of StrLCompA to mimic a function available in Java. In theory is going to work.
Perhaps you could add something similar to ObjAsm package.
invoke StrStartsWithA, element, $OfsCStr("TBL")
Regards. HSE
What's the difference to .if instr("The string to be tested", "The")==1 ?
Hi JJ!
The name is more easy :biggrin:
Hi HSE
Good idea :icon_idea:
What is the expected return value of the Java function, TRUE/FALSE?
Biterider
OK, found it https://beginnersbook.com/2013/12/java-string-startswith-method-example/ (https://beginnersbook.com/2013/12/java-string-startswith-method-example/)
I'll add it.
Biterider
glib: g_str_has_prefix (https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-str-has-prefix)
And : g_str_has_suffix (https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-str-has-suffix)
Hi HSE
Here is a quick update of the ObjMem library. It contains all changed files since the C.1.0 release and StrStartsWith (ANSI, WIDE & BSTR) for 32/64 bit.
@mabdelouahab: "g_str_has_suffix" is a good idea => StrEndsWith. Maybe I'll implement it too.
Biterider
Quote from: Biterider on April 28, 2020, 09:39:17 PM
Here is a quick update of the ObjMem library. It contains all changed files since the C.1.0 release and StrStartsWith (ANSI, WIDE & BSTR) for 32/64 bit.
Fantastic :thumbsup:
But you are the author. I just give the idea (fortunately, in ASCII, you can't write that in small letters :biggrin:)
Thanks.
int strncmp(const char *s1, const char *s2, size_t n) {
while (1) {
if (n <= 0)
return 0;
if (*s1 != *s2)
return *s1 - *s2;
if (*s1 == 0)
return 0;
s1++;
s2++;
n--;
}
}
gboolean g_str_has_suffix(const gchar *str, const gchar *suffix) {
size_t str_length;
size_t suffix_length;
g_return_val_if_fail(str != NULL, FALSE);
g_return_val_if_fail(suffix != NULL, FALSE);
str_length = strlen(str);
suffix_length = strlen(suffix);
return suffix_length <= str_length ?
strncmp(str + str_length - suffix_length, suffix, suffix_length) == 0 :
FALSE;
}
gboolean g_str_has_prefix(const gchar *str, const gchar *prefix) {
size_t str_length;
size_t prefix_length;
g_return_val_if_fail(str != NULL, FALSE);
g_return_val_if_fail(prefix != NULL, FALSE);
str_length = strlen(str);
prefix_length = strlen(prefix);
return prefix_length <= str_length ?
strncmp(str, prefix, prefix_length) == 0 :
FALSE;
}
Hi
For the record, I added StrEndsWith to the ObjMem library too.
It will be available soon in the next update unless someone needs it earlier.
Biterider