Bug 256455 - calendar(1) always considers // as the start of a comment
Summary: calendar(1) always considers // as the start of a comment
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: Stefan Eßer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-06 20:36 UTC by Philippe Michel
Modified: 2021-06-07 20:15 UTC (History)
1 user (show)

See Also:


Attachments
Ignore // within words to allow URLs in calendar entries (1.16 KB, patch)
2021-06-07 13:54 UTC, Stefan Eßer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Michel 2021-06-06 20:36:44 UTC
calendar apparently always considers // as the start of a comment.

This is annoying if one wishes to put an URL in a calendar entry. This used to be possible until a few months ago in 12-STABLE

Could you consider restricting this behaviour to cases where it is at the beginning of a line or preceded by a white-space character ?
Comment 1 Stefan Eßer freebsd_committer 2021-06-06 21:07:50 UTC
I have added the C++ style comments to calendar as part of the changes that brought back features lost when a very restricted internal pre-processor had been implemented to replace piping of calendar files through an external C pre-processor.

It is of course possible to ignore // if it is used as part of a URL (i.e. if it follows a colon) or if it is preceded by any non-whitespace character.

I'll prepare a patch for review on phabricator and attach it to this PR.
Comment 2 Stefan Eßer freebsd_committer 2021-06-07 13:54:48 UTC
Created attachment 225624 [details]
Ignore // within words to allow URLs in calendar entries

The parsing of // has been changed to only start a comment at begin of line or after white-space.
Comment 3 commit-hook freebsd_committer 2021-06-07 13:56:48 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=35b8fd0b699a20f71d5636069347b243eb336979

commit 35b8fd0b699a20f71d5636069347b243eb336979
Author:     Stefan EÃer <se@FreeBSD.org>
AuthorDate: 2021-06-07 13:46:24 +0000
Commit:     Stefan EÃer <se@FreeBSD.org>
CommitDate: 2021-06-07 13:55:23 +0000

    usr.bin/calendar: do not treat // in text as comment

    The C++-style comment marker "//" has been added with the rewrite of
    the preprocessor features. Since this character sequence occurs in
    ULRS, the reminder of the URL was considered a comment and stripped
    from the calendar line.

    Change parsing of "//" to only start a comment at the begin of a line
    or when preceeded by a white-space character.

    PR:             256455
    Reported by:    Philippe Michel (philippe.michel7 at free.fr)
    MFC after:      3 days

 usr.bin/calendar/io.c                      | 22 ++++++++++++++--------
 usr.bin/calendar/tests/calendar.comment    |  3 ++-
 usr.bin/calendar/tests/regress.comment.out |  2 ++
 3 files changed, 18 insertions(+), 9 deletions(-)