Welcome!

By registering with us, you'll be able to discuss, share and exchange private messages with other members of our community.

SignUp Now!

Has NthArgument changed?

May
12,621
152
Code like this, at the beginning of a plugin function
Code:
INT WINAPI PLUGGO ( WCHAR *psz )
{
   Printf(L"psz: %s\r\n", psz);
   WCHAR *pArgs = NthArgument(psz, 0, NULL, NULL);
   Printf(L"Args: %s\r\n", pArgs);
suggests that NthArgument behaves differently in v17 from how it behaved in v16. Calling this function with args
Code:
e f
gives me
Code:
psz:  e f
Args: e f
in v16, and
Code:
psz:  e f
Args: e
in v17.
 
Since your example is meaningless, I presume your real issue is something a bit different.

Yes, NthArgument changed in v17. It was removed, and replaced with a renamed function that processes string classes. A stub wrapper named NthArgument was kept, but it doesn't support the "..., NULL, NULL)" format. (Was that ever even documented?) If you are trying to get a pointer to the remainder of the string following argument n (not argument 0 as in your example), use the "nthptr" fourth argument.
 
Since your example is meaningless, I presume your real issue is something a bit different.

Yes, NthArgument changed in v17. It was removed, and replaced with a renamed function that processes string classes. A stub wrapper named NthArgument was kept, but it doesn't support the "..., NULL, NULL)" format. (Was that ever even documented?) If you are trying to get a pointer to the remainder of the string following argument n (not argument 0 as in your example), use the "nthptr" fourth argument.
I've used that syntax as a quick way to bypass leading whitespace in the function's string argument. How will using ppNthPtr help?
It's no big deal; easy enough to bypass leading whitespace by other means. The hard part might be finding all the places I relied on that behavior.
 
That's a truly horrible perversion of that function. It's far simpler (and about 1000x faster) to skip white space with the SkipWhiteSpace function.
Yeah, well ... that goes way back. I even have my own StripWhiteSpace function. In the case in point, I can even simply increment psz until it' non-white.
 
Where's SkipWhiteSpace? It's not in my TakeCmd.h (but I haven't updated my SDK).
 
// skip past leading white space and return pointer to first non-space char
DLLExports LPCTSTR SkipWhiteSpace( LPCTSTR pszLine )
{
while (( *pszLine == _TEXT(' ') ) || ( *pszLine == _TEXT('\t') ))
pszLine++;
return pszLine;
}
I did just that inline. For as long as I can, I'll stay away from exports that differ in various TCC versions (LPWSTR vs. LPCWSTR).
 

Similar threads

Back
Top