News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

StrStartsWith ?

Started by HSE, April 28, 2020, 10:18:13 AM

Previous topic - Next topic

HSE

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
Equations in Assembly: SmplMath

jj2007

What's the difference to .if instr("The string to be tested", "The")==1 ?

HSE

Hi JJ!

The name is more easy :biggrin:
Equations in Assembly: SmplMath

Biterider

Hi HSE
Good idea  :icon_idea:
What is the expected return value of the Java function, TRUE/FALSE?



Biterider

Biterider


mabdelouahab


Biterider

#6
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

HSE

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.
Equations in Assembly: SmplMath

mabdelouahab


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;
}

Biterider

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