svn commit: r367103 - head/usr.bin/calendar

Kyle Evans kevans at freebsd.org
Wed Oct 28 13:12:26 UTC 2020


On Wed, Oct 28, 2020 at 8:06 AM Stefan Eßer <se at freebsd.org> wrote:
>
> Author: se
> Date: Wed Oct 28 13:06:39 2020
> New Revision: 367103
> URL: https://svnweb.freebsd.org/changeset/base/367103
>
> Log:
>   Fix parsing of #ifdef in calendar files
>
>   There was code to process an #ifndef tokens, but none for #ifdef.
>   The #ifdef token was mentioned as unsupported in the BUGS section,
>   but no reason was given and I do not see why it should stay omitted.
>
>   Misleading information in The BUGS section of the man-page regarding
>   the maximum number of #define and #include statements supported has
>   been removed. These limits might have applied to a prior version of
>   this program, but do not seem to apply to the current implementation.
>
>   I have not tried to test for the existence of the limits, but the
>   include file processing just recursively calls the parser (without
>   counting the recursion depth) and the stringlist functions do not
>   impose a limit on the number of entries.
>
>   Reported by:  jhs at berklix.com
>   MFC after:    3 days
>
> Modified:
>   head/usr.bin/calendar/calendar.1
>   head/usr.bin/calendar/io.c
>
> Modified: head/usr.bin/calendar/calendar.1
> ==============================================================================
> --- head/usr.bin/calendar/calendar.1    Wed Oct 28 11:54:09 2020        (r367102)
> +++ head/usr.bin/calendar/calendar.1    Wed Oct 28 13:06:39 2020        (r367103)
> @@ -346,11 +346,9 @@ double-check the start and end time of solar and lunar
>  .Sh BUGS
>  The
>  .Nm
> -internal cpp does not correctly do #ifndef and will discard the rest
> -of the file if a #ifndef is triggered.
> -It also has a maximum of 50 include file and/or 100 #defines
> -and only recognises #include, #define and
> -#ifndef.
> +internal cpp does not support nested conditions and will continue
> +parsing of the input file on the next #endif even in nested contexts.
> +It does only recognise #include, #define, #ifdef and #ifndef.
>  .Pp
>  There is no possibility to properly specify the local position
>  needed for solar and lunar calculations.
>
> Modified: head/usr.bin/calendar/io.c
> ==============================================================================
> --- head/usr.bin/calendar/io.c  Wed Oct 28 11:54:09 2020        (r367102)
> +++ head/usr.bin/calendar/io.c  Wed Oct 28 13:06:39 2020        (r367103)
> @@ -212,6 +212,21 @@ token(char *line, FILE *out, bool *skip)
>                 return (T_OK);
>         }
>
> +       if (strncmp(line, "ifdef", 5) == 0) {
> +               walk = line + 6;
> +               trimlr(&walk);
> +

I think you wanted to step walk forward 5 instead of 6 here


More information about the svn-src-head mailing list