S
smnoff
I am trying to use the strstr function but it doesn't seem to work with a
dynamically allocated string that I pass into a function.
Specifically, I am using a Macromedia C-level extensibility and the
JavaScript interpreter to write an extension.
http://livedocs.macromedia.com/drea...text=LiveDocs_Parts&file=22_c_le2.htm#wp80297
http://livedocs.macromedia.com/dreamweaver/8/extending/wwhelp/wwhimpl/js/html/wwhelp.htm
While the example in the link above doesn't input 2 strings for me to do a
strstr function, my custom function does.
So something like this seem to work:
char const *stringBIG, *strSUB;
char *stringBIGIndex;
stringBIGIndex= strstr("this is a test", "test"); // this is a const and
it works
HOWEVER, this doesn't seem to work:
char const *stringBIG, *strSUB;
char *stringBIGIndex;
unsigned int strSUBlen, stringBIGlen;
// Convert the stringBIG to a string
stringBIG = JS_ValueToString(cx, argv[0], &stringBIGlen);
strSUB= JS_ValueToString(cx, argv[1], &strSUBlen);
stringBIGIndex= strstr(*stringBIG , *strSUB);
So, if you have a spelled out hard coded constant string, like "this is a
test", it works. But if I want to pass a string dynamically in, convert it
and use the strstr function it doesn't.
I also tried declaring the line
char const *stringBIG, *strSUB;
previously without the const keyword
char *stringBIG, *strSUB;
And that didn't seem to work originally, so I added the const in there.
Still no success.
I am trying to use the <string.h> library but I can't seem to use it in
practical manner.
Thanks.
dynamically allocated string that I pass into a function.
Specifically, I am using a Macromedia C-level extensibility and the
JavaScript interpreter to write an extension.
http://livedocs.macromedia.com/drea...text=LiveDocs_Parts&file=22_c_le2.htm#wp80297
http://livedocs.macromedia.com/dreamweaver/8/extending/wwhelp/wwhimpl/js/html/wwhelp.htm
While the example in the link above doesn't input 2 strings for me to do a
strstr function, my custom function does.
So something like this seem to work:
char const *stringBIG, *strSUB;
char *stringBIGIndex;
stringBIGIndex= strstr("this is a test", "test"); // this is a const and
it works
HOWEVER, this doesn't seem to work:
char const *stringBIG, *strSUB;
char *stringBIGIndex;
unsigned int strSUBlen, stringBIGlen;
// Convert the stringBIG to a string
stringBIG = JS_ValueToString(cx, argv[0], &stringBIGlen);
strSUB= JS_ValueToString(cx, argv[1], &strSUBlen);
stringBIGIndex= strstr(*stringBIG , *strSUB);
So, if you have a spelled out hard coded constant string, like "this is a
test", it works. But if I want to pass a string dynamically in, convert it
and use the strstr function it doesn't.
I also tried declaring the line
char const *stringBIG, *strSUB;
previously without the const keyword
char *stringBIG, *strSUB;
And that didn't seem to work originally, so I added the const in there.
Still no success.
I am trying to use the <string.h> library but I can't seem to use it in
practical manner.
Thanks.