diff options
author | dcs <dcs@FreeBSD.org> | 1999-10-02 12:33:37 +0000 |
---|---|---|
committer | dcs <dcs@FreeBSD.org> | 1999-10-02 12:33:37 +0000 |
commit | cfc542d60b8377a34cf887219e9e32805a961106 (patch) | |
tree | 1455cdf08d841e600fb41f75abe94c598d72c0bb /games | |
parent | 6ec3cab4edb509aedd42535c08459a2c9c67825f (diff) | |
download | FreeBSD-src-cfc542d60b8377a34cf887219e9e32805a961106.zip FreeBSD-src-cfc542d60b8377a34cf887219e9e32805a961106.tar.gz |
Add -C flag to indicate the presence of comments. Files thus processed
will be marked as having comments, which are indicated by two delimiter
characters at the beginning of a line.
Diffstat (limited to 'games')
-rw-r--r-- | games/fortune/strfile/strfile.c | 10 | ||||
-rw-r--r-- | games/fortune/strfile/strfile.h | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/games/fortune/strfile/strfile.c b/games/fortune/strfile/strfile.c index 1a57d2b..711f8d5 100644 --- a/games/fortune/strfile/strfile.c +++ b/games/fortune/strfile/strfile.c @@ -69,6 +69,7 @@ static const char rcsid[] = * * % strfile [-iorsx] [ -cC ] sourcefile [ datafile ] * + * C - Allow comments marked by a double delimiter at line's beginning * c - Change delimiting character from '%' to 'C' * s - Silent. Give no summary of data processed at the end of * the run. @@ -112,6 +113,7 @@ char *Infile = NULL, /* input file name */ 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 */ @@ -214,6 +216,9 @@ char **av; (void) fclose(inf); Tbl.str_numstr = Num_pts - 1; + if (Cflag) + Tbl.str_flags |= STR_COMMENTS; + if (Oflag) do_order(); else if (Rflag) @@ -261,8 +266,11 @@ char **argv; extern int optind; int ch; - while ((ch = getopt(argc, argv, "c:iorsx")) != EOF) + while ((ch = getopt(argc, argv, "Cc:iorsx")) != EOF) switch(ch) { + case 'C': /* embedded comments */ + Cflag++; + break; case 'c': /* new delimiting char */ Delimch = *optarg; if (!isascii(Delimch)) { diff --git a/games/fortune/strfile/strfile.h b/games/fortune/strfile/strfile.h index 7d35acb..24c94e9 100644 --- a/games/fortune/strfile/strfile.h +++ b/games/fortune/strfile/strfile.h @@ -35,6 +35,7 @@ * * @(#)strfile.h 8.1 (Berkeley) 5/31/93 */ +/* $FreeBSD$ */ #define STR_ENDSTRING(line,tbl) \ (((unsigned char)(line)[0]) == (tbl).str_delim && (line)[1] == '\n') @@ -48,6 +49,7 @@ typedef struct { /* information table */ #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 */ |