Hi Stefan
> 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.

Ah OK, here's 2 test cases
---Ex 1
* 29    bla1
#ifndef RAINEY
* 29    bla4
#endif
* 29    bla5
--- Ex 2
* 29    bla1
#define RAINEY YES
#ifndef RAINEY
* 29    bla4
#endif
* 29    bla5
---

They both produce:
---
Oct 29  bla5
Oct 29  bla4
Oct 29  bla1
---
Where manual misleads with:
        "internal cpp ... will discard the rest-of the file if a
        #ifndef is triggered"
Triggered or not, that #ifndef to cpp seems not discard rest of file.


> There is no mention of #ifdef being supported ...

OK, I just assumed that would be supported if #ifndef was.


> And your "#ifndef DEBUG4" did not trigger, since the whole line after
> #define is used as the identifier, in your case "DEBUG4 TRUE".

There lies the problem, Thanks !
Nasty, I dont recall anything called cpp aka C Pre Processor ever being
that limited, back to 1983 on a C compiler that ran on CP/M,
where masses of other C things were broken.  Best that calendar
not call it cpp at all, as name misleads.

OK, tested with
---
* 29    bla1
#define RAINEY
#ifndef RAINEY
* 29    bla4
#endif
* 29    bla5
---
& got
---
Oct 29  bla5
Oct 29  bla1
---
& finaly in this special case current manual correctly reports a bug.


> 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,

Yes

> 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.

Hopefully not too late. 
Either way, Ameliorations:
- Do a global edit in manual from "cpp" to "pre-processor"
  to remove expectation of similarity to cpp.
- Define in manual exactly how the pre-processor handles defines.


> I have updated the code in -CURRENT to support #ifdef (MFC in 3 days)

Nice 


> and I plan to add supported for nested conditions in -CURRENT 

Nice


> (not
> sure whether that should be merged to -STABLE, though).

Probably yes ?


> 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.

Would be good if you did, silently swallowing space seperated text
as extended name of a define instead of value of define, is not
intuitive, At least document if you have no time to change it please ?

Fixing documenting & extanding a pp in calendar could become like
re-inventing the wheel ?  As a cpp is in src/ & not ports, can't
calendar use popen(/usr/bin/cpp) & save work ?  Looks like there's
enough work to do in main calendar without extra work of a custom
pre processor ?

Thanks for copy of your reply to Greg Balfour's off list mail, ref
        https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=205580
which notes:
        "This patch is against 11.4-RELEASE.  Note that it requires
        the installation of the devel/tradcpp port/package."

I agree your policy point, FreeBSD can't use a port as dependency
to build calendar, while calendar is still build by src/ world.  (&
not just for Free, but Net & Open BSD etc will have similiar views
I presume)

I don't know which cpp's from where might have been looked at in the past,

> Regards, STefan

Thanks !

Cheers,
-- 
Julian Stacey, Consultant Sys. Eng. BSD Linux Unix, http://berklix.com/jhs/cv/
Crash Brexit profits financial speculators in cabinet damaging Britain.
UK stole 3.7 million votes from Brits abroad 700 K in EU http://stolenvotes.uk
_______________________________________________
freebsd-stable@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to