Bug 186294

Summary: calendar(1): calendar' preprocessor process comments
Product: Base System Reporter: Romain Tartière <romain>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: gonzo
Priority: Normal    
Version: 10.0-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch.txt
none
patch.txt
none
patch.txt
none
patch3.txt none

Description Romain Tartière freebsd_committer freebsd_triage 2014-01-31 08:50:00 UTC
After updating to 10.0, calendar now shows events it did not displayed
in 9.2.

Fix: 

No fix yet, but a workaround is to #define a macro checked in the
included calendar
---------------------------------- 8< ----------------------------------
/*
 * #define _calendar_computer_
 * #include <calendar.computer>
 */
---------------------------------- 8< ----------------------------------
How-To-Repeat: 
My ~/.calendar/calendar appears to have a commented-out comment:

---------------------------------- 8< ----------------------------------
/*
 * #include <calendar.computer>
 */

01 Jan	Sample entry
---------------------------------- 8< ----------------------------------

When I ask events for a particular date, events from this included
calendar.computer are unexpectedly returned:

---------------------------------- 8< ----------------------------------
% calendar -t 01.01
 1 jan  Sample entry
 1 jan  The Epoch (Time 0 for UNIX systems, Midnight GMT, 1970)
 1 jan  AT&T officially divests its local Bell companies, 1984
---------------------------------- 8< ----------------------------------
Comment 1 oliver 2014-02-19 17:02:47 UTC
This issue is caused by the reimplementation of some cpp features in
the application, to get rid of cpp itself. The implementation lacks
the removal of c-style /* */ comments completely.

This bug seems to be a duplicate  / same issue as PR: bin/184648

Attached is a patch that removes single-line and multi-line comments
included in the calendar files by removing them in the temporary buffer.

This patch fixes this issue and bin/184648.

Feel free to give me some feedback about the code (style) itself, the
report followup itself, etc..
Comment 2 oliver 2014-02-19 17:16:25 UTC
sorry wrong patch file, patch again - correct version.
Comment 3 Romain Tartière 2014-02-19 18:29:00 UTC
Hi Oliver,

On Wed, Feb 19, 2014 at 06:16:25PM +0100, oliver wrote:
> sorry wrong patch file, patch again - correct version.


After applying this patch, I confirm this problem is fixed.

> +    	} else if (idx_ts != NULL && idx_te == NULL) {
> +            	if (cf == 0) {
> +                	cf = 1;
> +                	while (buf++ != idx_ts); 

                        ^^^^^^^^^^^^^^^^^^^^^^^

While copying/pasting the patch, this line confused me a bit.  Isn't it
more obvious to write this as a simple assignment ?

> buf = idx_ts + 1;


Thanks!

Romain

-- 
Romain Tartière <romain@blogreen.org>        http://romain.blogreen.org/
pgp: 8234 9A78 E7C0 B807 0B59  80FF BA4D 1D95 5112 336F (ID: 0x5112336F)
(plain text =non-HTML= PGP/GPG encrypted/signed e-mail much appreciated)
Comment 4 oliver 2014-02-19 19:47:24 UTC
Hello Romain,

that is very true...when removing the original block, I didn't remove
the while condition, even stepping through is not anymore required.

Sorry, I will fix that. 

For so long, please don't commit the patch. I'm digging a bit deeper
for PR: bin/162211 and found another issue..please stand by, will
post the corrected version shortly...but need to make other
tests first.


Greetings, Oliver



>Hi Oliver,

>On Wed, Feb 19, 2014 at 06:16:25PM +0100, oliver wrote:
>> sorry wrong patch file, patch again - correct version.

>After applying this patch, I confirm this problem is fixed.

>> + } else if (idx_ts != NULL && idx_te == NULL) {
>> + if (cf == 0) {
>> + cf = 1;
>> + while (buf++ != idx_ts); 
> ^^^^^^^^^^^^^^^^^^^^^^^

>While copying/pasting the patch, this line confused me a bit. Isn't it
>more obvious to write this as a simple assignment ?

>> buf = idx_ts + 1;

>Thanks!

>Romain
Comment 5 oliver 2014-03-03 18:54:02 UTC
okay, here is my final patch for this issue and issue bin/184648

I modified my original patch for removing multiple inline comments. I
tested it against an original version of calendar and did not find any
additional issues.

Greetings, Oliver
Comment 6 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:26 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 7 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2020-04-03 02:13:29 UTC
Closing as OBE since the affected file was removed as a part of calendar parser rework in base r279597