svn commit: r367127 - head/usr.bin/calendar

Stefan Eßer se at FreeBSD.org
Thu Oct 29 08:31:48 UTC 2020


Author: se
Date: Thu Oct 29 08:31:47 2020
New Revision: 367127
URL: https://svnweb.freebsd.org/changeset/base/367127

Log:
  Simplify test for closing delimiter of #include argument (no functional
  change).
  
  While here: Fix invalid parameters of a commented-out debug printf() found
  when testing with this code enabled.
  
  MFC after:	3 days

Modified:
  head/usr.bin/calendar/events.c
  head/usr.bin/calendar/io.c

Modified: head/usr.bin/calendar/events.c
==============================================================================
--- head/usr.bin/calendar/events.c	Thu Oct 29 08:26:38 2020	(r367126)
+++ head/usr.bin/calendar/events.c	Thu Oct 29 08:31:47 2020	(r367127)
@@ -207,8 +207,9 @@ event_print_all(FILE *fp)
 
 	while (walkthrough_dates(&e) != 0) {
 #ifdef DEBUG
-		fprintf(stderr, "event_print_allmonth: %d, day: %d\n",
-		    month, day);
+		if (e)
+			fprintf(stderr, "event_print_all month: %d, day: %d\n",
+			    e->month, e->day);
 #endif
 
 		/*

Modified: head/usr.bin/calendar/io.c
==============================================================================
--- head/usr.bin/calendar/io.c	Thu Oct 29 08:26:38 2020	(r367126)
+++ head/usr.bin/calendar/io.c	Thu Oct 29 08:31:47 2020	(r367127)
@@ -215,26 +215,12 @@ token(char *line, FILE *out, int *skip)
 			return (T_ERR);
 		}
 
-		a = *walk;
+		a = *walk == '<' ? '>' : '\"';
 		walk++;
 		c = walk[strlen(walk) - 1];
 
-		switch(c) {
-		case '>':
-			if (a != '<') {
-				warnx("Unterminated include expecting '\"'");
-				return (T_ERR);
-			}
-			break;
-		case '\"':
-			if (a != '\"') {
-				warnx("Unterminated include expecting '>'");
-				return (T_ERR);
-			}
-			break;
-		default:
-			warnx("Unterminated include expecting '%c'",
-			    a == '<' ? '>' : '\"' );
+		if (a != c) {
+			warnx("Unterminated include expecting '%c'", a);
 			return (T_ERR);
 		}
 		walk[strlen(walk) - 1] = '\0';


More information about the svn-src-head mailing list