1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-22 08:58:47 +00:00

Update to FreeBSD SVN revision r367167

This update implements comment handling lost when calendar was changed
from using an external cpp to an internal pre-processor
This commit is contained in:
Stefan Eßer 2020-10-30 15:01:04 +00:00
parent 19c7012647
commit 320ace80a3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=553696
5 changed files with 205 additions and 30 deletions

View File

@ -1,7 +1,7 @@
# $FreeBSD$
PORTNAME= calendar
DISTVERSION= 0.3
DISTVERSION= 0.5
CATEGORIES= deskutils
MAINTAINER= se@FreeBSD.org
@ -15,7 +15,7 @@ USE_GITHUB= yes
GH_ACCOUNT= bsdimp
GH_TAGNAME= fcc5d31
CFLAGS+= -DLOCALBASE=${LOCALBASE}
CFLAGS+= -D_PATH_LOCALBASE=\"${LOCALBASE}\" -g -O0 # -DDEBUG
LDFLAGS+= -lm -lutil
PLIST_FILES= bin/calendar \

View File

@ -1,3 +1,3 @@
TIMESTAMP = 1603969583
SHA256 (bsdimp-calendar-0.3-fcc5d31_GH0.tar.gz) = ad7d0b51c4b834241aebbf6c50d187e5720f6c46c02615b27841a923e082aebc
SIZE (bsdimp-calendar-0.3-fcc5d31_GH0.tar.gz) = 132824
TIMESTAMP = 1604068556
SHA256 (bsdimp-calendar-0.5-fcc5d31_GH0.tar.gz) = ad7d0b51c4b834241aebbf6c50d187e5720f6c46c02615b27841a923e082aebc
SIZE (bsdimp-calendar-0.5-fcc5d31_GH0.tar.gz) = 132824

View File

@ -1,11 +0,0 @@
--- calendar.h.orig 2020-10-18 03:01:26 UTC
+++ calendar.h
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: head/usr.bin/calendar/calendar.h 358562 2020-03-03 00:20:08Z cem $
*/
#include <sys/types.h>

View File

@ -1,6 +1,85 @@
--- io.c.orig 2020-10-29 11:04:06 UTC
--- io.c.orig 2020-10-18 03:01:26 UTC
+++ io.c
@@ -209,26 +209,12 @@ token(char *line, FILE *out, int *skip)
@@ -71,7 +71,7 @@ enum {
};
const char *calendarFile = "calendar"; /* default calendar file */
-static const char *calendarHomes[] = {".calendar", _PATH_INCLUDE}; /* HOME */
+static const char *calendarHomes[] = {".calendar", _PATH_INCLUDE_LOCAL, _PATH_INCLUDE}; /* HOME */
static const char *calendarNoMail = "nomail";/* don't sent mail if file exist */
static char path[MAXPATHLEN];
@@ -134,18 +134,66 @@ cal_fopen(const char *file)
}
static int
-token(char *line, FILE *out, bool *skip)
+token(char *line, FILE *out, int *skip)
{
char *walk, c, a;
if (strncmp(line, "endif", 5) == 0) {
- *skip = false;
+ if (*skip > 0)
+ --*skip;
return (T_OK);
}
- if (*skip)
+ if (strncmp(line, "ifdef", 5) == 0) {
+ walk = line + 5;
+ trimlr(&walk);
+
+ if (*walk == '\0') {
+ warnx("Expecting arguments after #ifdef");
+ return (T_ERR);
+ }
+
+ if (*skip != 0 || definitions == NULL || sl_find(definitions, walk) == NULL)
+ ++*skip;
+
return (T_OK);
+ }
+ if (strncmp(line, "ifndef", 6) == 0) {
+ walk = line + 6;
+ trimlr(&walk);
+
+ if (*walk == '\0') {
+ warnx("Expecting arguments after #ifndef");
+ return (T_ERR);
+ }
+
+ if (*skip != 0 || (definitions != NULL && sl_find(definitions, walk) != NULL))
+ ++*skip;
+
+ return (T_OK);
+ }
+
+ if (strncmp(line, "else", 4) == 0) {
+ walk = line + 4;
+ trimlr(&walk);
+
+ if (*walk != '\0') {
+ warnx("Expecting no arguments after #else");
+ return (T_ERR);
+ }
+
+ if (*skip == 0)
+ *skip = 1;
+ else if (*skip == 1)
+ *skip = 0;
+
+ return (T_OK);
+ }
+
+ if (*skip != 0)
+ return (T_OK);
+
if (strncmp(line, "include", 7) == 0) {
walk = line + 7;
@@ -161,26 +209,12 @@ token(char *line, FILE *out, bool *skip)
return (T_ERR);
}
@ -30,3 +109,119 @@
return (T_ERR);
}
walk[strlen(walk) - 1] = '\0';
@@ -206,21 +240,6 @@ token(char *line, FILE *out, bool *skip)
return (T_OK);
}
- if (strncmp(line, "ifndef", 6) == 0) {
- walk = line + 6;
- trimlr(&walk);
-
- if (*walk == '\0') {
- warnx("Expecting arguments after #ifndef");
- return (T_ERR);
- }
-
- if (definitions != NULL && sl_find(definitions, walk) != NULL)
- *skip = true;
-
- return (T_OK);
- }
-
return (T_PROCESS);
}
@@ -248,11 +267,13 @@ cal_parse(FILE *in, FILE *out)
int month[MAXCOUNT];
int day[MAXCOUNT];
int year[MAXCOUNT];
- bool skip = false;
+ int skip = 0;
char dbuf[80];
char *pp, p;
struct tm tm;
int flags;
+ char *c, *cc;
+ bool incomment = false;
/* Unused */
tm.tm_sec = 0;
@@ -264,8 +285,58 @@ cal_parse(FILE *in, FILE *out)
return (1);
while ((linelen = getline(&line, &linecap, in)) > 0) {
- if (*line == '#') {
- switch (token(line+1, out, &skip)) {
+ buf = line;
+ if (buf[linelen - 1] == '\n')
+ buf[--linelen] = '\0';
+
+ if (incomment) {
+ c = strstr(buf, "*/");
+ if (c) {
+ c += 2;
+ linelen -= c - buf;
+ buf = c;
+ incomment = false;
+ } else {
+ continue;
+ }
+ }
+ if (!incomment) {
+ do {
+ c = strstr(buf, "//");
+ cc = strstr(buf, "/*");
+ if (c != NULL && (cc == NULL || c - cc < 0)) {
+ /* single line comment */
+ *c = '\0';
+ linelen = c - buf;
+ break;
+ } else if (cc != NULL) {
+ c = strstr(cc + 2, "*/");
+ if (c != NULL) {
+ /* multi-line comment ending on same line */
+ c += 2;
+ memmove(cc, c, buf + linelen + 1 - c);
+ linelen -= c - cc;
+ } else {
+ /* multi-line comment */
+ *cc = '\0';
+ linelen = cc - buf;
+ incomment = true;
+ break;
+ }
+ }
+ } while (c != NULL || cc != NULL);
+ }
+
+ for (l = linelen;
+ l > 0 && isspace((unsigned char)buf[l - 1]);
+ l--)
+ ;
+ buf[l] = '\0';
+ if (buf[0] == '\0')
+ continue;
+
+ if (buf == line && *buf == '#') {
+ switch (token(buf+1, out, &skip)) {
case T_ERR:
free(line);
return (1);
@@ -278,16 +349,7 @@ cal_parse(FILE *in, FILE *out)
}
}
- if (skip)
- continue;
-
- buf = line;
- for (l = linelen;
- l > 0 && isspace((unsigned char)buf[l - 1]);
- l--)
- ;
- buf[l] = '\0';
- if (buf[0] == '\0')
+ if (skip != 0)
continue;
/*

View File

@ -1,16 +1,7 @@
--- pathnames.h.orig 2020-10-18 03:01:26 UTC
--- pathnames.h.orig 2020-10-30 14:47:55 UTC
+++ pathnames.h
@@ -29,9 +29,12 @@
* SUCH DAMAGE.
*
* @(#)pathnames.h 8.1 (Berkeley) 6/6/93
- * $FreeBSD$
+ * $FreeBSD: head/usr.bin/calendar/pathnames.h 366962 2020-10-23 09:22:23Z se $
*/
@@ -35,3 +35,4 @@
#include <paths.h>
+#define s1(s) #s
+#define s2(s) s1(s)
#define _PATH_INCLUDE "/usr/share/calendar"
+#define _PATH_INCLUDE_LOCAL s2(LOCALBASE) "/share/calendar"
+#define _PATH_INCLUDE_LOCAL _PATH_LOCALBASE "/share/calendar"