Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 (MU) 9/23/84; site munnari.OZ
Path: utzoo!watmath!clyde!bonnie!akgua!whuxle!harpo!decvax!mulga!munnari!kre
From: kre@munnari.OZ (Robert Elz)
Newsgroups: net.sources
Subject: fdate.c - bug report and correction
Message-ID: <539@munnari.OZ>
Date: Sun, 30-Sep-84 01:41:22 EDT
Article-I.D.: munnari.539
Posted: Sun Sep 30 01:41:22 1984
Date-Received: Mon, 1-Oct-84 04:24:54 EDT
Distribution: net
Organization: Comp Sci, Melbourne Uni, Australia
Lines: 109

echo x - "BUG" 2>&1
sed "s/^X//" >"BUG" <<'!The!End!'
X
X    Andrew Sharpe (drivax!sharpe) pointed out a bug in the
X    fdate program that I posted a week or so ago.  Its amazing
X    how bugs infest programs the day that they're posted.
X    (Well, not really, this one has been there hibernating
X    for ever).
X
X    This is a sh archive, unpack it & you'll get 3 files,
X    BUG (this file), fdate.c.ed, and fdate.c.diffs.  Fdate.c.ed
X    is an ed script (diff -e output) that you can run
X    as
X	    ed - fdate.c &1
sed "s/^X//" >"fdate.c.diffs" <<'!The!End!'
X*** fdate.c.distrib	Fri Sep 21 07:37:27 1984
X--- fdate.c	Wed Sep 26 18:45:49 1984
X***************
X*** 187,192
X  			case 'M':	incr.tm_min = i;	break;
X  			case 'S':	incr.tm_sec = i;	break;
X  
X  			default:	hadincr--;		break;
X  			}
X  		}
X
X--- 187,193 -----
X  			case 'M':	incr.tm_min = i;	break;
X  			case 'S':	incr.tm_sec = i;	break;
X  
X+ 			case '\0':	aptr--;		/* fall through */
X  			default:	hadincr--;		break;
X  			}
X  		}
X***************
X*** 297,303
X  						continue;
X  					}
X  				}
X! 				switch (*aptr++) {
X  				case '%':
X  					putchar('%');
X  					continue;
X
X--- 298,304 -----
X  						continue;
X  					}
X  				}
X! 				switch (c = *aptr++) {
X  				case '%':
X  					putchar('%');
X  					continue;
X***************
X*** 445,451
X  						putchar(c);
X  						break;
X  					}
X! 					fprintf(stderr, "fdate: bad format character - %c\n", *--aptr);
X  					exit(2);
X  
X  				}	/* endsw */
X
X--- 446,456 -----
X  						putchar(c);
X  						break;
X  					}
X! 					if (c == '\0' || c == ' ')
X! 						fprintf(stderr, "fdate: missing format character in \"%s\"\n", *argv);
X! 					else
X! 						fprintf(stderr, "fdate: bad format character - %c\n", c);
X! 					close(1);	/* trash stdout! */
X  					exit(2);
X  
X  				}	/* endsw */
!The!End!

echo x - "fdate.c.ed" 2>&1
sed "s/^X//" >"fdate.c.ed" <<'!The!End!'
X448c
X					if (c == '\0' || c == ' ')
X						fprintf(stderr, "fdate: missing format character in \"%s\"\n", *argv);
X					else
X						fprintf(stderr, "fdate: bad format character - %c\n", c);
X					close(1);	/* trash stdout! */
X.
X300c
X				switch (c = *aptr++) {
X.
X189a
X			case '\0':	aptr--;		/* fall through */
X.
Xw
Xq
!The!End!
exit