Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Dec 1999 17:34:21 +0800
From:      Peter Wemm <peter@netplex.com.au>
To:        "Daniel C. Sobral" <dcs@newsguy.com>
Cc:        Marcel Moolenaar <marcel@scc.nl>, Bruce Evans <bde@zeta.org.au>, Dag-Erling Smorgrav <des@flood.ping.uio.no>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src Makefile.inc1 
Message-ID:  <19991226093421.875B91CC6@overcee.netplex.com.au>
In-Reply-To: Message from "Daniel C. Sobral" <dcs@newsguy.com>  of "Sun, 26 Dec 1999 15:52:33 %2B0900." <3865BB31.880BDA2D@newsguy.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
"Daniel C. Sobral" wrote:
> Peter Wemm wrote:
> > 
> > -C is silly.  It adds a flag to the header of the generated files to say
> > "this data *might* have a comment".  fortune looks to see if there "might"
> > be a comment and skips the double delimiters if so.  The double delimiter
> > is otherwise illegal.  If an old fortune binary sees a new file, it won't
> > know about the double delimiter.  If a new fortune sees the double
> > delimiter it will ignore it.  This is exactly the same behavior that would
> > happen if -C was unconditional.
> 
> That is not true. Just try making a file without -C containing a
> "comment" and then fortune'ing it.

No problem, RELENG_2_2's strfile and fortune, *with* the ignore-comments patch
but without -C:

...
 96162 fortune  NAMI  "/usr/share/games/fortune/fortunes2"
 96162 fortune  RET   open 3
...
 96162 fortune  CALL  open(0x8051000,0,0x1)
 96162 fortune  NAMI  "/usr/share/games/fortune/fortunes2.dat"
 96162 fortune  RET   open 4
...

 96162 fortune  CALL  write(0x1,0x8054000,0x27)
 96162 fortune  GIO   fd 1 wrote 39 bytes
       "Others will look to you for stability,
       "
 96162 fortune  RET   write 39/0x27
 96162 fortune  CALL  write(0x1,0x8054000,0x22)
 96162 fortune  GIO   fd 1 wrote 34 bytes
       "so hide when you bite your nails.
       "
 96162 fortune  RET   write 34/0x22

pwroot@overcee[5:18pm]~src/games/fortune/datfiles-269# strfile
No input file name
strfile [-iorsx] [-c char] sourcefile [datafile]

pwroot@overcee[5:19pm]~src/games/fortune/datfiles-270# more /usr/share/games/fortune/fortunes2
%% $FreeBSD: src/games/fortune/datfiles/fortunes2,v 1.17 1999/11/27 07:18:33 wes
 Exp $
=======================================================================
||                                                                   ||
|| The FORTUNE-COOKIE program is soon to be a Major Motion Picture!  ||
...

-C is just a build inconvenience to make %% parsing optional.  We have 
enough options already without adding them for things that don't make sense
to be an option.

And.. with an *unpatched* RELENG_2_2 fortune and strfile:
pwroot@overcee[5:21pm]~src/games/fortune/fortune-274# fortune /usr/share/games/fortune/fortunes2
The more the merrier.
                -- John Heywood

ie: it still works.  Even if it didn't, we don't need -C at 'make world'
time because strfile does nothing special with the %% lines, and a new
fortune(1) is installed at exactly the same time as the new datfiles.
strfile from as far back as RELEASE_2_0 works with the -current datfiles
and -current fortune(1).  (However, an x86 strfile won't generate a .dat file
that will work on an Alpha because there are 'unsigned long's in the header.
IMHO, we should make thie u_int32_t before 4.0-R.  strfile would need to be
a x86->alpha cross build tool).

A patch to remove the bogus -C (but keep comment skip code), and to fix a
couple of style bugs (long/int32 stuff left out, but I have that too):

Index: datfiles/Makefile
===================================================================
RCS file: /home/ncvs/src/games/fortune/datfiles/Makefile,v
retrieving revision 1.24
diff -u -r1.24 Makefile
--- datfiles/Makefile	1999/12/23 19:09:59	1.24
+++ datfiles/Makefile	1999/12/26 09:00:48
@@ -34,12 +34,12 @@
 .for f in fortunes fortunes2 fortunes2-o limerick startrek zippy
 $f.dat: $f
 	PATH=$$PATH:/usr/games:${.OBJDIR}/../strfile \
-	    strfile -Crs ${.ALLSRC} ${.TARGET}
+	    strfile -rs ${.ALLSRC} ${.TARGET}
 .endfor
 
 fortunes-o.dat: fortunes-o
 	PATH=$$PATH:/usr/games:${.OBJDIR}/../strfile \
-	    strfile -Crsx ${.ALLSRC} ${.TARGET}
+	    strfile -rsx ${.ALLSRC} ${.TARGET}
 
 fortunes-o: fortunes-o.${TYPE}
 	tr a-zA-Z n-za-mN-ZA-M < ${.ALLSRC} > ${.TARGET}
Index: fortune/fortune.c
===================================================================
RCS file: /home/ncvs/src/games/fortune/fortune/fortune.c,v
retrieving revision 1.18
diff -u -r1.18 fortune.c
--- fortune/fortune.c	1999/11/30 03:48:52	1.18
+++ fortune/fortune.c	1999/12/26 09:00:48
@@ -262,9 +262,8 @@
 						*p = 'a' + (ch - 'a' + 13) % 26;
 				}
 			}
-		if (fp->tbl.str_flags & STR_COMMENTS
-		    && line[0] == fp->tbl.str_delim
-		    && line[1] == fp->tbl.str_delim)
+		if (line[0] == fp->tbl.str_delim &&
+		    line[1] == fp->tbl.str_delim)
 			continue;
 		fputs(line, stdout);
 	}
@@ -1359,9 +1358,8 @@
 		sp = Fortbuf;
 		in_file = FALSE;
 		while (fgets(sp, Fort_len, fp->inf) != NULL)
-			if (fp->tbl.str_flags & STR_COMMENTS
-			    && sp[0] == fp->tbl.str_delim
-			    && sp[1] == fp->tbl.str_delim)
+			if (sp[0] == fp->tbl.str_delim &&
+			    sp[1] == fp->tbl.str_delim)
 				continue;
 			else if (!STR_ENDSTRING(sp, fp->tbl))
 				sp += strlen(sp);
Index: strfile/strfile.8
===================================================================
RCS file: /home/ncvs/src/games/fortune/strfile/strfile.8,v
retrieving revision 1.5
diff -u -r1.5 strfile.8
--- strfile/strfile.8	1999/10/27 18:34:04	1.5
+++ strfile/strfile.8	1999/12/26 09:00:48
@@ -65,15 +65,6 @@
 .Pp
 The options are as follows:
 .Bl -tag -width "-c char"
-.It Fl C
-Flag the file as containing comments. This option cases the
-.Dv STR_COMMENTS
-bit in the header
-.Ar str_flags
-field to be set.
-Comments are designated by two delimiter characters at the
-beginning of the line, though strfile does not give any special
-treatment to comment lines.
 .It Fl c Ar char
 Change the delimiting character from the percent sign to
 .Ar char .
@@ -108,6 +99,9 @@
 .Ar str_flags
 field to be set.
 .El
+.Pp
+Comments are designated by two delimiter characters at the
+beginning of the line.
 .Pp
 The format of the header is:
 .Bd -literal
Index: strfile/strfile.c
===================================================================
RCS file: /home/ncvs/src/games/fortune/strfile/strfile.c,v
retrieving revision 1.15
diff -u -r1.15 strfile.c
--- strfile/strfile.c	1999/11/16 02:57:00	1.15
+++ strfile/strfile.c	1999/12/26 09:00:48
@@ -115,7 +115,6 @@
 	Outfile[MAXPATHLEN] = "",	/* output file name */
 	Delimch		= '%';		/* delimiting character */
 
-int	Cflag		= FALSE;	/* embedded comments */
 int	Sflag		= FALSE;	/* silent run flag */
 int	Oflag		= FALSE;	/* ordering flag */
 int	Iflag		= FALSE;	/* ignore case flag */
@@ -218,9 +217,6 @@
 	(void) fclose(inf);
 	Tbl.str_numstr = Num_pts - 1;
 
-	if (Cflag)
-		Tbl.str_flags |= STR_COMMENTS;
-
 	if (Oflag)
 		do_order();
 	else if (Rflag)
@@ -268,11 +264,8 @@
 	extern int	optind;
 	int	ch;
 
-	while ((ch = getopt(argc, argv, "Cc:iorsx")) != EOF)
+	while ((ch = getopt(argc, argv, "c:iorsx")) != EOF)
 		switch(ch) {
-		case 'C':			/* embedded comments */
-			Cflag++;
-			break;
 		case 'c':			/* new delimiting char */
 			Delimch = *optarg;
 			if (!isascii(Delimch)) {
@@ -319,7 +312,7 @@
 void usage()
 {
 	(void) fprintf(stderr,
-	    "strfile [-Ciorsx] [-c char] sourcefile [datafile]\n");
+	    "strfile [-iorsx] [-c char] sourcefile [datafile]\n");
 	exit(1);
 }
 
Index: strfile/strfile.h
===================================================================
RCS file: /home/ncvs/src/games/fortune/strfile/strfile.h,v
retrieving revision 1.3
diff -u -r1.3 strfile.h
--- strfile/strfile.h	1999/10/02 12:33:37	1.3
+++ strfile/strfile.h	1999/12/26 09:00:49
@@ -49,7 +49,6 @@
 #define	STR_RANDOM	0x1			/* randomized pointers */
 #define	STR_ORDERED	0x2			/* ordered pointers */
 #define	STR_ROTATED	0x4			/* rot-13'd text */
-#define	STR_COMMENTS	0x8			/* embedded comments */
 	unsigned long	str_flags;		/* bit field for flags */
 	unsigned char	stuff[4];		/* long aligned space */
 #define	str_delim	stuff[0]		/* delimiting character */




Cheers,
-Peter
--
Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991226093421.875B91CC6>