Date: Wed, 28 Oct 2020 14:18:48 +0100 From: Stefan Esser <se@freebsd.org> To: "Julian H. Stacey" <jhs@berklix.com> Cc: freebsd-stable <freebsd-stable@freebsd.org> Subject: Re: calendar (1) - patch to correct error description Message-ID: <3ec7872e-c264-e05f-cc3b-bbd2f421a97f@freebsd.org> In-Reply-To: <202010281202.09SC23PC035979@fire.js.berklix.net> References: <202010281202.09SC23PC035979@fire.js.berklix.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Am 28.10.20 um 13:02 schrieb Julian H. Stacey: > man calendar states: > "The calendar internal cpp does not correctly do #ifndef and will discard > the rest of the file if a #ifndef is triggered." > That is wrong, as proved by test file: > --- > // Test data for ~/.calendar/calendar > * bla0 > #ifdef DEBUG1 > * 28 bla1 > #endif > #ifdef DEBUG2 > * 28 bla2 > #endif > #ifndef DEBUG3 > * 28 bla3 > #endif > #define DEBUG4 TRUE > #ifndef DEBUG4 > * 28 bla4 > #endif > * 28 bla5 > --- > Produces: > --- > Oct 28 bla5 > Oct 28 bla4 > Oct 28 bla3 > Oct 28 bla2 > Oct 28 bla1 > --- > Correction: > The calendar internal cpp ignores directives #ifdef , #ifndef and #endif , > and simply including intervening text regardless. Hi Julian, no, the calendar program worked as documented, see the BUGS section of the man-page: .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. There is no mention of #ifdef being supported ... And your "#ifndef DEBUG4" did not trigger, since the whole line after #define is used as the identifier, in your case "DEBUG4 TRUE". This is not obvious from reading the man-page and it might be more intuitive, if the identifier was only the word up to the first blank, but the code in the calendar program does just strip off leading and trailing white-space. It might be too late to change this behavior. I have updated the code in -CURRENT to support #ifdef (MFC in 3 days) and I plan to add supported for nested conditions in -CURRENT (not sure whether that should be merged to -STABLE, though). I could change the #define and #if/ifndef to only consider the first following word, but do not plan to do that at this time. Regards, STefan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3ec7872e-c264-e05f-cc3b-bbd2f421a97f>