Welcome!

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

SignUp Now!

Question about GetToken()

May
12,846
164
TakeCmd.h says (and TakeCmd.lib agrees)

Code:
int WINAPI GetToken( LPTSTR pszLine, LPTSTR pszDelims, int nStart, int nEnd );
/*
    Return a string starting at token # nStart and ending at tken # nEnd
      (without quote processing)
      
    pszDelims - token delimiter characters
*/
Where's the "returned" string and what's the significance of the return value?
 
vefatica wrote:

> TakeCmd.h says (and TakeCmd.lib agrees)
>
>
> Code:
> ---------
> int WINAPI GetToken( LPTSTR pszLine, LPTSTR pszDelims, int nStart, int nEnd );
> /*
> Return a string starting at token # nStart and ending at tken # nEnd
> (without quote processing)
>
> pszDelims - token delimiter characters
> */
> ---------
> Where's the "returned" string and what's the significance of the return value?

The returned string is in pszLine, and it returns 0 if it found the
token between start/end.

Rex Conn
JP Software
 
On Wed, 15 Apr 2009 20:15:20 -0500, rconn <> wrote:

|vefatica wrote:
|
|
|---Quote---
|> TakeCmd.h says (and TakeCmd.lib agrees)
|>
|>
|> Code:
|> ---------
|> int WINAPI GetToken( LPTSTR pszLine, LPTSTR pszDelims, int nStart, int nEnd );
|> /*
|> Return a string starting at token # nStart and ending at tken # nEnd
|> (without quote processing)
|>
|> pszDelims - token delimiter characters
|> */
|> ---------
|> Where's the "returned" string and what's the significance of the return value?
|---End Quote---
|The returned string is in pszLine, and it returns 0 if it found the
|token between start/end.

Is pszLine altered so as to contain **only** the "returned" string?
--
- Vince
 
On Wed, 15 Apr 2009 20:39:02 -0500, rconn <> wrote:

|---Quote---
|> Is pszLine altered so as to contain **only** the "returned" string?
|---End Quote---
|Yes.

Rather destructive! In what situations is it of value?
--
- Vince
 
vefatica wrote:

> On Wed, 15 Apr 2009 20:39:02 -0500, rconn <> wrote:
>
> |---Quote---
> |> Is pszLine altered so as to contain **only** the "returned" string?
> |---End Quote---
> |Yes.
>
> Rather destructive! In what situations is it of value?

It's of value to me internally in several hundred places in TCC; in
those instances I either don't care about preserving the string, or I
copy the string to a temp buffer and pass that to GetToken. If I don't
want the passed buffer overridden I use different routines (like
NthArgument) that don't do that.

The functions in TakeCmd.dll are all intended and optimized for internal
TCC use. If GetToken is not of value to you then don't use it!

Rex Conn
JP Software
 
Doesn't the C RTL function strtok() behave the same way?

-Scott

vefatica <> wrote on 04/15/2009 09:50:58 PM:


> On Wed, 15 Apr 2009 20:39:02 -0500, rconn <> wrote:
>
> |---Quote---
> |> Is pszLine altered so as to contain **only** the "returned" string?
> |---End Quote---
> |Yes.
>
> Rather destructive! In what situations is it of value?
> --
> - Vince
>
>
>
>
 
On Thu, 16 Apr 2009 12:27:39 -0500, samintz <> wrote:

|Doesn't the C RTL function strtok() behave the same way?

Not exactly. The entire original string is still there, but altered slightly,
chopped up by delimiters having been replaced by nul-terminators. Whereas
strtok() (actually wcstok_s() for me) might turn

My dog has fleas.\0 (located at address 0xXXXXXXXX)

into

My\0dog\0has\0fleas.\0 (located at 0xXXXXXXXX)

GetToken() might, if I understand correctly, for example, turn it into

dog has\0 (located at 0xXXXXXXXX)
--
- Vince
 

Similar threads

Back
Top