From owner-freebsd-stable@freebsd.org Thu Oct 29 00:30:02 2020 Return-Path: Delivered-To: freebsd-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A3FEF453A3C for ; Thu, 29 Oct 2020 00:30:02 +0000 (UTC) (envelope-from jhs@berklix.com) Received: from slim.berklix.org (slim.berklix.org [94.185.90.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "slim.berklix.org", Issuer "slim.berklix.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CM5td4ScDz3XLC; Thu, 29 Oct 2020 00:30:01 +0000 (UTC) (envelope-from jhs@berklix.com) Received: from mart.js.berklix.net (p4fc4cc8e.dip0.t-ipconnect.de [79.196.204.142]) (authenticated bits=128) by slim.berklix.org (8.15.2/8.15.2) with ESMTPSA id 09T0TsHI026052 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 29 Oct 2020 01:29:58 +0100 (CET) (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (fire.js.berklix.net [192.168.91.41]) by mart.js.berklix.net (8.14.3/8.14.3) with ESMTP id 09T0Ts94093919; Thu, 29 Oct 2020 01:29:54 +0100 (CET) (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (localhost [127.0.0.1]) by fire.js.berklix.net (8.14.7/8.14.7) with ESMTP id 09T0Td4m004819; Thu, 29 Oct 2020 01:29:49 +0100 (CET) (envelope-from jhs@berklix.com) Message-Id: <202010290029.09T0Td4m004819@fire.js.berklix.net> To: Stefan Esser cc: freebsd-stable cc: Greg Balfour Subject: Re: calendar (1) - patch to correct error description From: "Julian H. Stacey" Organization: http://berklix.com/jhs/ User-agent: EXMH on FreeBSD http://berklix.com/free/ X-From: http://www.berklix.org/~jhs/ In-reply-to: Your message "Wed, 28 Oct 2020 14:18:48 +0100." <3ec7872e-c264-e05f-cc3b-bbd2f421a97f@freebsd.org> Date: Thu, 29 Oct 2020 01:29:39 +0100 X-Rspamd-Queue-Id: 4CM5td4ScDz3XLC X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of jhs@berklix.com has no SPF policy when checking 94.185.90.68) smtp.mailfrom=jhs@berklix.com X-Spamd-Result: default: False [0.19 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; MULTIPLE_UNIQUE_HEADERS(0.70)[Cc]; HAS_ORG_HEADER(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:33824, ipnet:94.185.88.0/22, country:DE]; MIME_TRACE(0.00)[0:+]; RECEIVED_SPAMHAUS_PBL(0.00)[79.196.204.142:received]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.67)[-0.667]; FREEFALL_USER(0.00)[jhs]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_SPAM_SHORT(0.19)[0.191]; NEURAL_HAM_LONG(-0.93)[-0.931]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[berklix.com]; AUTH_NA(1.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; R_SPF_NA(0.00)[no SPF record]; FREEMAIL_CC(0.00)[gmail.com]; MAILMAN_DEST(0.00)[freebsd-stable] X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 00:30:02 -0000 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