bin/186294: calendar(1): calendar' preprocessor process comments
oliver
oliver at beefrankly.org
Wed Feb 19 17:10:01 UTC 2014
The following reply was made to PR bin/186294; it has been noted by GNATS.
From: oliver <oliver at beefrankly.org>
To: bug-followup at FreeBSD.org, romain at FreeBSD.org
Cc:
Subject: Re: bin/186294: calendar(1): calendar' preprocessor process
comments
Date: Wed, 19 Feb 2014 18:02:47 +0100
--MP_/ONNxqFP+Gg.1MY4tHsvQ6Bf
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
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..
--MP_/ONNxqFP+Gg.1MY4tHsvQ6Bf
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=patch.txt
--- calcpp.c 2014-02-19 17:56:34.000000000 +0100
+++ /usr/src/usr.bin/calendar/calcpp.c 2014-02-19 00:43:47.000000000 +0100
@@ -52,8 +52,6 @@
static void pushfp(FILE *fp);
static FILE *popfp(void);
static int tokenscpp(char *buf, char *string);
-static void striptags(char *buf, int size, const char *ts, const char *te);
-static void rmcomments(char *buf, int size);
#define T_INVALID -1
#define T_INCLUDE 0
@@ -95,7 +93,6 @@
return(fp);
}
}
- rmcomments(buf,size);
switch (tokenscpp(buf, name)) {
case T_INCLUDE:
*buf = '\0';
@@ -233,46 +230,3 @@
return (1);
return (0);
}
-
-
-
-
-
-static void
-rmcomments(char *buf, int size)
-{
- striptags(buf,size,"/*", "*/");
-}
-
-
-static void
-striptags(char *buf, int size, const char *ts, const char *te)
-{
- static int cf = 0; /* carry flag */
- int te_len = strlen(te); /* end tag length */
- char *idx_ts = strstr(buf, ts);
- char *idx_te = strstr(buf, te);
-
- if (idx_ts == NULL && idx_te == NULL) {
- if (cf == 0)
- return;
- else
- *buf='\0';
- } else if (idx_ts != NULL && idx_te == NULL) {
- if (cf == 0) {
- cf = 1;
- while (buf++ != idx_ts);
- }
- *buf = '\0';
- } else if (idx_ts != NULL && idx_te != NULL && cf == 0
- && idx_ts < idx_te) {
- memmove(idx_ts, idx_te+te_len,
- (buf+size)-(idx_ts+te_len));
- striptags(buf,size,ts,te);
- } else if (idx_ts == NULL && idx_te != NULL && cf == 1) {
- memmove(buf, idx_te+te_len,
- (buf+size)-(idx_te+te_len));
- cf = 0;
- }
- return;
-}
--MP_/ONNxqFP+Gg.1MY4tHsvQ6Bf
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=patch.txt
--- calcpp.c 2014-02-19 17:56:34.000000000 +0100
+++ /usr/src/usr.bin/calendar/calcpp.c 2014-02-19 00:43:47.000000000 +0100
@@ -52,8 +52,6 @@
static void pushfp(FILE *fp);
static FILE *popfp(void);
static int tokenscpp(char *buf, char *string);
-static void striptags(char *buf, int size, const char *ts, const char *te);
-static void rmcomments(char *buf, int size);
#define T_INVALID -1
#define T_INCLUDE 0
@@ -95,7 +93,6 @@
return(fp);
}
}
- rmcomments(buf,size);
switch (tokenscpp(buf, name)) {
case T_INCLUDE:
*buf = '\0';
@@ -233,46 +230,3 @@
return (1);
return (0);
}
-
-
-
-
-
-static void
-rmcomments(char *buf, int size)
-{
- striptags(buf,size,"/*", "*/");
-}
-
-
-static void
-striptags(char *buf, int size, const char *ts, const char *te)
-{
- static int cf = 0; /* carry flag */
- int te_len = strlen(te); /* end tag length */
- char *idx_ts = strstr(buf, ts);
- char *idx_te = strstr(buf, te);
-
- if (idx_ts == NULL && idx_te == NULL) {
- if (cf == 0)
- return;
- else
- *buf='\0';
- } else if (idx_ts != NULL && idx_te == NULL) {
- if (cf == 0) {
- cf = 1;
- while (buf++ != idx_ts);
- }
- *buf = '\0';
- } else if (idx_ts != NULL && idx_te != NULL && cf == 0
- && idx_ts < idx_te) {
- memmove(idx_ts, idx_te+te_len,
- (buf+size)-(idx_ts+te_len));
- striptags(buf,size,ts,te);
- } else if (idx_ts == NULL && idx_te != NULL && cf == 1) {
- memmove(buf, idx_te+te_len,
- (buf+size)-(idx_te+te_len));
- cf = 0;
- }
- return;
-}
--MP_/ONNxqFP+Gg.1MY4tHsvQ6Bf--
More information about the freebsd-bugs
mailing list