On 06/01/2013 10:59 AM, Kornel Benko wrote:
Am Samstag, 1. Juni 2013 um 16:32:35, schrieb Richard Heck
<rgh...@lyx.org>
> The branch, rgh/CounterValue, has been updated.
>
> - Log -----------------------------------------------------------------
>
> commit 19d53d609a136efb28154de3aa7769ee95c30be7
> Author: Richard Heck <rgh...@lyx.org>
> Date: Sat Jun 1 10:32:06 2013 -0400
>
> Allow initial value of 0 for counters.
>
> diff --git a/src/Counters.cpp b/src/Counters.cpp
> index 7800856..917044a 100644
> --- a/src/Counters.cpp
> +++ b/src/Counters.cpp
> @@ -87,11 +87,15 @@ bool Counter::read(Lexer & lex)
> break;
> case CT_INITIALVALUE:
> lex.next();
> - initial_value_ = lex.getInteger() - 1;
> - // we get -1 on an error, and negative values don't make
> - // much sense anyway.
> - if (initial_value_ < 0)
> + initial_value_ = lex.getInteger();
> + // getInteger() returns -1 on error, and larger
> + // negative values do not make much sense.
> + // In the other case, we subtract one, since the
> + // counter will be incremented before its first use.
> + if (initial_value_ <= -1)
> initial_value_ = 0;
> + else
> + initial_value_ -= 1;
> break;
> case CT_PRETTYFORMAT:
> lex.next();
>
Did you meant:
> + if (initial_value_ <= 0) <---
> initial_value_ = 0;
> + else
> + initial_value_ -= 1;
> break;
No, I think it's correct as is. We want to allow 0 to be given as intial
value, and if so then initial_value_ should be set to -1. This is all a
bit confusing, since the actual first value will then be 0: The counter
gets incremented before it is used.
Richard
Kornel