summaryrefslogtreecommitdiff
path: root/deskutils
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2020-10-28 21:10:46 +0000
committerStefan Eßer <se@FreeBSD.org>2020-10-28 21:10:46 +0000
commit83ba4864583bf5a5c3ce31772c03e6195bf0c07b (patch)
tree24bd7fe23f8c105c93f8609c1dd2e3cdd5fd7687 /deskutils
parentdevel/sd-mux: create port (diff)
Upgrade to FreeBSD base SVN version r367108
This version add support for nested conditionals, #ifdef and #else.
Notes
Notes: svn path=/head/; revision=553563
Diffstat (limited to 'deskutils')
-rw-r--r--deskutils/calendar/files/patch-io.c122
1 files changed, 107 insertions, 15 deletions
diff --git a/deskutils/calendar/files/patch-io.c b/deskutils/calendar/files/patch-io.c
index e037a2d3efc3..fc59ec38396d 100644
--- a/deskutils/calendar/files/patch-io.c
+++ b/deskutils/calendar/files/patch-io.c
@@ -1,20 +1,112 @@
---- io.c.orig 2020-10-18 03:01:26 UTC
+--- io.c.orig 2020-10-28 20:58:10 UTC
+++ io.c
-@@ -42,7 +42,7 @@ static char sccsid[] = "@(#)calendar.c 8.3 (Berkeley)
- #endif
+@@ -134,18 +134,66 @@ cal_fopen(const char *file)
+ }
- #include <sys/cdefs.h>
--__FBSDID("$FreeBSD$");
-+__FBSDID("$FreeBSD: head/usr.bin/calendar/io.c 366962 2020-10-23 09:22:23Z se $");
+ static int
+-token(char *line, FILE *out, bool *skip)
++token(char *line, FILE *out, int *skip)
+ {
+ char *walk, c, a;
- #include <sys/param.h>
- #include <sys/stat.h>
-@@ -71,7 +71,7 @@ enum {
- };
+ if (strncmp(line, "endif", 5) == 0) {
+- *skip = false;
++ if (*skip > 0)
++ --*skip;
+ return (T_OK);
+ }
- 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 */
+- 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);
++ }
- static char path[MAXPATHLEN];
++ 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;
+
+@@ -206,21 +254,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,7 +281,7 @@ 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;
+@@ -278,7 +311,7 @@ cal_parse(FILE *in, FILE *out)
+ }
+ }
+
+- if (skip)
++ if (skip != 0)
+ continue;
+
+ buf = line;