Subject: Re: mark parsing in fast-import

From: Jörg Sommer <[email-masked]>
Date: Mon, 21 Apr 2008 10:41:51 +0200

Hi Shawn,

Shawn O. Pearce schrieb am Sun 20. Apr, 20:26 (-0400):
> Jrg Sommer <[email-masked]> wrote:
> > +static inline int parse_mark(const const char *str, uintmax_t* mark,

Is inline okay?

> > +	char **after_mark)
> > +{
> > +	if (!str || str[0] != ':' || !isdigit(str[1]))
> > +		return 1;
> > +
> > +	char *am;
> 
> Although we conform to mostly C99 style, variables should be
> declared at the top of the scope and not after a statement.

Changed.

> >  static void cmd_mark(void)
> >  {
> > -	if (!prefixcmp(command_buf.buf, "mark :")) {
> > -		next_mark = strtoumax(command_buf.buf + 6, NULL, 10);
> > +	uintmax_t mark = 0;
> > +	char *after_mark = NULL;
> > +
> > +	if (!prefixcmp(command_buf.buf, "mark ") &&
> > +		parse_mark(&command_buf.buf[5], &mark, &after_mark) &&
> 
> Hmm.  Shouldn't this be ! parse_mark given that it returns 0
> on success and 1 on failure?

Yes, you're right. I've checked some other functions and found this
behaviour. Can I use a different behabiour, i.e. return 0 on failure and
!0 on success?

Bye, Jörg.
-- 
„Wer im Usenet gelesen werden will, sollte leserorientiert schreiben. Wer nur
 für sich schreiben will, dem ist mit einem Tagebuch vielleicht besser
 geholfen. Gelesen zu werden ist kein Recht, sondern ein Privileg.“
     Thore Tams in <[email-masked]>