From nobody Fri Mar 04 19:48:12 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9CE0A19F1170; Fri, 4 Mar 2022 19:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K9JLN3zlYz4t0V; Fri, 4 Mar 2022 19:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646423292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ioJdvM2H8HW4HkIUZqafXQ6Xo3J1wp9aTviD4/o4BSU=; b=i2G2o1ny3wiMvkJVbP3U+Z6yxtRhWedt1uaoslweei7J/J3+OFhD/AuYy3r98PYDZmyLTK 8H2L1u8hqRwzCPnfWtiHpli9KtayQnHe/U61BS5jXVN5kavEHc48xaxO+vorDCpCLnqT5/ Xb5KBBW8IFPlRM/S65zJT/PJJ8FOSh80rDD4rltNE4hJ2AEAsa7qVLMu2J5pxTLtp4Exrr 7sDrIyexLoz6lD31kOl9Z2EYAZ7J9V1oXe4NI1PdVJiSahupLkth/myVbG3PaoXZ/vAkc+ rWcqOiI9Eb0VeqrJvtRZShXkIHA998MxnryIUOH+8u5cFZxVDncB3eDDD0bu5g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 68DFD12914; Fri, 4 Mar 2022 19:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 224JmCE9069103; Fri, 4 Mar 2022 19:48:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 224JmCKd069102; Fri, 4 Mar 2022 19:48:12 GMT (envelope-from git) Date: Fri, 4 Mar 2022 19:48:12 GMT Message-Id: <202203041948.224JmCKd069102@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Stefan E=C3=9Fer?= Subject: git: c82c2fb1ae91 - stable/13 - usr.bin/calendar: do not treat // in text as comment List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c82c2fb1ae91c5cddc1096c2141b694f2bd3cdce Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646423292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ioJdvM2H8HW4HkIUZqafXQ6Xo3J1wp9aTviD4/o4BSU=; b=Sla985vHsWI1KAzCG2+N7cnFqm/CkUbG6jgyFppe6gTAHXFs0bCWZn2sQc5LtFr1XtUh74 BY0jMf88ixqZcKcXz2HKSo56tGQTv7vK8JqsLHsXhnImD1ZML42Fn/yqqyffTraGVzLD5L nF/Xml/W8b97+j+vvDK2HbHCJs8z4gLSpn8/Qw4eF1w47kZJFWQthCFvJ8eyV95xmTyYjL sPiuicXuNWK0R4DqR8Mtl1lUPQFygM43AXLBZRhIXyMSM4MBRGghPQD7jH+pVcVuh3WTln u4vvE4iphkmC86sbRtwWbTP2x5pEL+uN0Uk6skXOSw4csu7qu4TOvviQi+Dtvg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646423292; a=rsa-sha256; cv=none; b=JKTIflteNaXgd0GbpPZMRK1nciysSJEBMo8UKueBY5jElsYur9MX+THVGu275dJc/sthNR S1ItdhlPyHCXi9Ke1XsUrPPoMEwLxdL+WxH5493Ors7q6bRF+m8NSf3IppBtjxU8HxVjkV PDRsdmDknvVeR8fEShc4T7uZ0KBChB9SdfrLWcVpsCXZKtyLH7d1pvEeOLZBE9y4ENQ6My 7kK/I4Zp23QF+Rfbkob/fPjOqHdNRz2vACFSbRwc1PmJBJ5VWcnrMFjkOG3gC5H9vCj+qT vG0Ym4MaAOJaHou9Rg4HAsTwQsqGnwbKPO0WkLYwFffqRJkJGgKrYB8FS8ZofQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=c82c2fb1ae91c5cddc1096c2141b694f2bd3cdce commit c82c2fb1ae91c5cddc1096c2141b694f2bd3cdce Author: Stefan Eßer AuthorDate: 2021-06-07 13:46:24 +0000 Commit: Stefan Eßer CommitDate: 2022-03-04 19:41:02 +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. (cherry picked from commit 35b8fd0b699a20f71d5636069347b243eb336979) --- 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(-) diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index 24966399c179..5afcb1a33314 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -405,7 +405,7 @@ cal_parse(FILE *in, FILE *out) { char *mylocale = NULL; char *line = NULL; - char *buf; + char *buf, *bufp; size_t linecap = 0; ssize_t linelen; ssize_t l; @@ -443,21 +443,27 @@ cal_parse(FILE *in, FILE *out) } } if (!incomment) { + bufp = buf; do { - c = strstr(buf, "//"); - cc = strstr(buf, "/*"); + c = strstr(bufp, "//"); + cc = strstr(bufp, "/*"); if (c != NULL && (cc == NULL || c - cc < 0)) { - /* single line comment */ - *c = '\0'; - linelen = c - buf; - break; + bufp = c + 2; + /* ignore "//" within string to allow it in an URL */ + if (c == buf || isspace(c[-1])) { + /* single line comment */ + *c = '\0'; + linelen = c - buf; + break; + } } else if (cc != NULL) { c = strstr(cc + 2, "*/"); - if (c != NULL) { + if (c != NULL) { // 'a /* b */ c' -- cc=2, c=7+2 /* multi-line comment ending on same line */ c += 2; memmove(cc, c, buf + linelen + 1 - c); linelen -= c - cc; + bufp = cc; } else { /* multi-line comment */ *cc = '\0'; diff --git a/usr.bin/calendar/tests/calendar.comment b/usr.bin/calendar/tests/calendar.comment index 6af037ec7e9d..837e5af9e89e 100644 --- a/usr.bin/calendar/tests/calendar.comment +++ b/usr.bin/calendar/tests/calendar.comment @@ -7,4 +7,5 @@ 1/* comment */ 6 jan 6 1 7 jan 7 // /* comment */ comment 1 1/* comment */1 jan /* comment */11 // comment - +1 12 http://localhost.local/ +1 13 http://localhost.local/ // URL with additional comment diff --git a/usr.bin/calendar/tests/regress.comment.out b/usr.bin/calendar/tests/regress.comment.out index 1ba3d8cc640e..fb58fd29ff05 100644 --- a/usr.bin/calendar/tests/regress.comment.out +++ b/usr.bin/calendar/tests/regress.comment.out @@ -6,3 +6,5 @@ Jan 5 jan 5 Jan 6 jan 6 Jan 7 jan 7 Jan 11 jan 11 +Jan 12 http://localhost.local/ +Jan 13 http://localhost.local/