bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] Splitting of multiple arguments


From: Jim Segrave
Subject: Re: [Bug-gnubg] Splitting of multiple arguments
Date: Sun, 23 Nov 2003 22:13:33 +0100
User-agent: Mutt/1.4.1i

On Sun 23 Nov 2003 (03:20 +0100), Holger wrote:
> Hi all,
> 
> I'm trying to figure out how commands with multiple arguments are
> processed. As I've understood it, when I finally reach my command handler
> the arguments are passed in sz and still need to be split.

Yes.

> In particular I was looking at the helper functions at the start of
> gnubg.c. What exactly do they return under which circumstances? Could
> someone please add some comments in front of every function about the
> general behaviour?

I've added function header comment blocks

> What do the lines
>           *pchSave++ = **ppch;
> serve in NextTokenGeneral()? It seems the character is being copied on top
> of itself. Or am I missing something?

Sometimes it copies onto itself, but, if there are quoted strings as
part of the token, then the quotes are removed and the contents of the
quoted string overwrites the opening quote and any following token
characters overwrite the closing quote. Similarly, if there are
escaped characters, the backslash gets overwritten.

Example:
address    :  0  1  2  3  4  5  6  7  8  0
sz at entry:  a  "  b  c  "  d  e \t  f \0
sz at exit:   a  b  c  d  e  \0 e \t  f \0

The returned value points to the 'a', ppch points to the 'f'

> If the first token starts on the first byte (thus no leading whitespace) it
> returns this on the first call, and a pointer to the start of the next in
> the passed ppch, correct?

yes

> The Parse*() functions, at least ParseNumber(), seem only to accept strings
> that only contain numbers (and minus signs) and nothing else? Is some
> trailing whitespace cut off earlier on?

yes - they call NextToken() which will have removed trailing
whitespace on the token they are converting.
 
> I'll probably also have some questions about the command arrays and the
> handling of commands but will ask this later when I've looked a bit more
> into it.

This is mostly a matter of going over the getoptlong man page.

-- 
Jim Segrave           address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]