my @cr_results;
my @trailing_whitespace_results;
+my @tabs_results;
while (my $r = $tree->next_obj())
{
if ($r->is_file)
{
push @trailing_whitespace_results, $fn;
}
+ elsif ($r->basename =~ /\.[ch]\z/ and $contents =~ /\t/)
+ {
+ push @tabs_results, $fn;
+ }
}
}
}
-if (@cr_results or @trailing_whitespace_results)
+if (@cr_results or @trailing_whitespace_results or @tabs_results)
{
print "The following files contain carriage returns:\n\n";
-
foreach my $r (@cr_results)
{
print "$r\n";
}
- print "The following files contain trailing whitespace:\n\n";
+ print "The following files contain trailing whitespace:\n\n";
foreach my $r (@trailing_whitespace_results)
{
print "$r\n";
}
+
+ print "The following source files contain tabs:\n\n";
+ foreach my $r (@tabs_results)
+ {
+ print "$r\n";
+ }
exit(-1);
}
else
/*-
* Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ken Arnold.
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Who're you gonna quote? Dan Quayle?
*/
-#include <netinet/in.h>
-#include <sys/param.h>
-#include "strfile.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
+#include <netinet/in.h>
+#include <sys/param.h>
+#include "strfile.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
+#define MAXPATHLEN 1024
#endif /* MAXPATHLEN */
-char *Infile, /* name of input file */
- Datafile[MAXPATHLEN], /* name of data file */
- Delimch; /* delimiter character */
+char *Infile, /* name of input file */
+ Datafile[MAXPATHLEN], /* name of data file */
+ Delimch; /* delimiter character */
FILE *Inf, *Dataf, *Outf;
-off_t pos, Seekpts[2]; /* seek pointers to fortunes */
+off_t pos, Seekpts[2]; /* seek pointers to fortunes */
void getargs(int ac, char *av[])
if (*av)
{
- Infile = *av;
+ Infile = *av;
/* Hmm. Don't output anything if we can help it.
* fprintf(stderr, "Input file: %s\n",Infile); */
- if (!strrchr(Infile, '.'))
- {
- strcpy(Datafile, Infile);
- strcat(Datafile, ".dat");
- }
- else
- {
- strcpy(Datafile, Infile);
- extc = strrchr(Infile, '.');
- *extc = '\0';
- }
+ if (!strrchr(Infile, '.'))
+ {
+ strcpy(Datafile, Infile);
+ strcat(Datafile, ".dat");
+ }
+ else
+ {
+ strcpy(Datafile, Infile);
+ extc = strrchr(Infile, '.');
+ *extc = '\0';
+ }
}
else
/* {
{
pos = random() % fp->str_numstr;
if (++(pos) >= fp->str_numstr)
- pos -= fp->str_numstr;
+ pos -= fp->str_numstr;
}
/*
fseek(fp, (long) Seekpts[0], 0);
for (i = 0; fgets(line, sizeof line, fp) != NULL &&
- !STR_ENDSTRING(line, table); i++)
+ !STR_ENDSTRING(line, table); i++)
{
- if (table.str_flags & STR_ROTATED)
- for (p = line; (ch = *p); ++p)
- if (isupper(ch))
- *p = 'A' + (ch - 'A' + 13) % 26;
- else if (islower(ch))
- *p = 'a' + (ch - 'a' + 13) % 26;
- fputs(line, stdout);
+ if (table.str_flags & STR_ROTATED)
+ for (p = line; (ch = *p); ++p)
+ if (isupper(ch))
+ *p = 'A' + (ch - 'A' + 13) % 26;
+ else if (islower(ch))
+ *p = 'a' + (ch - 'a' + 13) % 26;
+ fputs(line, stdout);
}
fflush(stdout);
}
int main(int ac, char **av)
{
- static STRFILE tbl; /* description table */
+ static STRFILE tbl; /* description table */
getargs(ac, av);
if ((Inf = fopen(Infile, "r")) == NULL)
{
- perror(Infile);
- exit(1);
+ perror(Infile);
+ exit(1);
}
if ((Dataf = fopen(Datafile, "r")) == NULL)
{
- perror(Datafile);
- exit(1);
+ perror(Datafile);
+ exit(1);
}
fread((char *) &tbl, sizeof tbl, 1, Dataf);
tbl.str_version = ntohl(tbl.str_version);
while ((a = getchar()) != EOF)
{
- if (isupper(a))
- b = 'A' + (a - 'A' + 13) % 26;
- else if (islower(a))
- b = 'a' + (a - 'a' + 13) % 26;
- else
- b = a;
- putchar(b);
+ if (isupper(a))
+ b = 'A' + (a - 'A' + 13) % 26;
+ else if (islower(a))
+ b = 'a' + (a - 'a' + 13) % 26;
+ else
+ b = a;
+ putchar(b);
}
exit(0);
}
-/* $NetBSD: strfile.h,v 1.3 1995/03/23 08:28:49 cgd Exp $ */
+/* $NetBSD: strfile.h,v 1.3 1995/03/23 08:28:49 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ken Arnold.
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)strfile.h 8.1 (Berkeley) 5/31/93
+ * @(#)strfile.h 8.1 (Berkeley) 5/31/93
*/
-#define STR_ENDSTRING(line,tbl) \
- ((line)[0] == (tbl).str_delim && (line)[1] == '\n')
+#define STR_ENDSTRING(line,tbl) \
+ ((line)[0] == (tbl).str_delim && (line)[1] == '\n')
-typedef struct { /* information table */
-#define VERSION 2
- u_int32_t str_version; /* version number */
- u_int32_t str_numstr; /* # of strings in the file */
- u_int32_t str_longlen; /* length of longest string */
- u_int32_t str_shortlen; /* length of shortest string */
-#define STR_RANDOM 0x1 /* randomized pointers */
-#define STR_ORDERED 0x2 /* ordered pointers */
-#define STR_ROTATED 0x4 /* rot-13'd text */
- u_int32_t str_flags; /* bit field for flags */
- u_int8_t stuff[4]; /* long aligned space */
-#define str_delim stuff[0] /* delimiting character */
+typedef struct { /* information table */
+#define VERSION 2
+ u_int32_t str_version; /* version number */
+ u_int32_t str_numstr; /* # of strings in the file */
+ u_int32_t str_longlen; /* length of longest string */
+ u_int32_t str_shortlen; /* length of shortest string */
+#define STR_RANDOM 0x1 /* randomized pointers */
+#define STR_ORDERED 0x2 /* ordered pointers */
+#define STR_ROTATED 0x4 /* rot-13'd text */
+ u_int32_t str_flags; /* bit field for flags */
+ u_int8_t stuff[4]; /* long aligned space */
+#define str_delim stuff[0] /* delimiting character */
} STRFILE;
/*-
* Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ken Arnold.
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+ The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)unstr.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)unstr.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
#endif /* comment out the dreck, kill the warnings */
* get a fortune that contains nothing but a newline. Karo syrup, syrup.
* For the gory details, and lots of cussing, see strfile.c
*/
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/param.h>
-#include "strfile.h"
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <sys/param.h>
+#include "strfile.h"
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
+#define MAXPATHLEN 1024
#endif /* MAXPATHLEN */
-char *Infile, /* name of input file */
- Datafile[MAXPATHLEN], /* name of data file */
- Delimch, /* delimiter character */
+char *Infile, /* name of input file */
+ Datafile[MAXPATHLEN], /* name of data file */
+ Delimch, /* delimiter character */
Outfile[MAXPATHLEN];
-char NewDelch = '\0'; /* a replacement delimiter character */
+char NewDelch = '\0'; /* a replacement delimiter character */
FILE *Inf, *Dataf, *Outf;
int ch;
while ((ch = getopt(ac, av, "c:")) != EOF)
- switch (ch)
- {
- case 'c':
- NewDelch = *optarg;
- if (!isascii(NewDelch))
- {
- fprintf(stderr, "Bad delimiting characher: '\\%o'\n", NewDelch);
- }
- break;
- case '?':
- default:
- fprintf(stderr, "Usage:\n\tunstr [-c C] datafile[.ext] [outputfile]\n");
- exit(1);
- }
+ switch (ch)
+ {
+ case 'c':
+ NewDelch = *optarg;
+ if (!isascii(NewDelch))
+ {
+ fprintf(stderr, "Bad delimiting characher: '\\%o'\n", NewDelch);
+ }
+ break;
+ case '?':
+ default:
+ fprintf(stderr, "Usage:\n\tunstr [-c C] datafile[.ext] [outputfile]\n");
+ exit(1);
+ }
av += optind;
if (*av)
{
- Infile = *av;
- fprintf(stderr, "Input file: %s\n", Infile);
- if (!strrchr(Infile, '.'))
- {
- strcpy(Datafile, Infile);
- strcat(Datafile, ".dat");
- }
- else
- {
- strcpy(Datafile, Infile);
- extc = strrchr(Infile, '.');
- *extc = '\0';
- }
- if (*++av)
- {
- strcpy(Outfile, *av);
- fprintf(stderr, "Output file: %s\n", Outfile);
- }
+ Infile = *av;
+ fprintf(stderr, "Input file: %s\n", Infile);
+ if (!strrchr(Infile, '.'))
+ {
+ strcpy(Datafile, Infile);
+ strcat(Datafile, ".dat");
+ }
+ else
+ {
+ strcpy(Datafile, Infile);
+ extc = strrchr(Infile, '.');
+ *extc = '\0';
+ }
+ if (*++av)
+ {
+ strcpy(Outfile, *av);
+ fprintf(stderr, "Output file: %s\n", Outfile);
+ }
}
else
{
- fprintf(stderr, "No input file name\n");
- fprintf(stderr, "Usage:\n\tunstr [-c C] datafile[.ext] [outputfile]\n");
- exit(1);
+ fprintf(stderr, "No input file name\n");
+ fprintf(stderr, "Usage:\n\tunstr [-c C] datafile[.ext] [outputfile]\n");
+ exit(1);
}
if (!strcmp(Infile, Outfile))
{
- fprintf(stderr, "The input file for strings (%s) must be different from the output file (%s)\n", Infile, Outfile);
- exit(1);
+ fprintf(stderr, "The input file for strings (%s) must be different from the output file (%s)\n", Infile, Outfile);
+ exit(1);
}
}
for (i = 0; i <= tbl->str_numstr; i++)
{
- fread((char *) &pos, 1, sizeof pos, Dataf);
- fseek(Inf, ntohl(pos), 0);
- printedsome = 0;
- for (;;)
- {
- sp = fgets(buf, sizeof buf, Inf);
- if (sp == NULL || STR_ENDSTRING(sp, *tbl))
- {
- if (sp || printedsome)
- fprintf(Outf, "%c\n", Delimch);
- break;
- }
- else
- {
- printedsome = 1;
- fputs(sp, Outf);
- }
- }
+ fread((char *) &pos, 1, sizeof pos, Dataf);
+ fseek(Inf, ntohl(pos), 0);
+ printedsome = 0;
+ for (;;)
+ {
+ sp = fgets(buf, sizeof buf, Inf);
+ if (sp == NULL || STR_ENDSTRING(sp, *tbl))
+ {
+ if (sp || printedsome)
+ fprintf(Outf, "%c\n", Delimch);
+ break;
+ }
+ else
+ {
+ printedsome = 1;
+ fputs(sp, Outf);
+ }
+ }
}
}
int main(int ac, char **av)
{
- static STRFILE tbl; /* description table */
+ static STRFILE tbl; /* description table */
getargs(ac, av);
if ((Inf = fopen(Infile, "r")) == NULL)
{
- perror(Infile);
- exit(1);
+ perror(Infile);
+ exit(1);
}
if ((Dataf = fopen(Datafile, "r")) == NULL)
{
- perror(Datafile);
- exit(1);
+ perror(Datafile);
+ exit(1);
}
if (*Outfile == '\0')
- Outf = stdout;
+ Outf = stdout;
else if ((Outf = fopen(Outfile, "w+")) == NULL)
{
- perror(Outfile);
- exit(1);
+ perror(Outfile);
+ exit(1);
}
fread(&tbl.str_version, sizeof(tbl.str_version), 1, Dataf);
fread(&tbl.str_numstr, sizeof(tbl.str_numstr), 1, Dataf);
fread( tbl.stuff, sizeof(tbl.stuff), 1, Dataf);
if (!(tbl.str_flags & (STR_ORDERED | STR_RANDOM)) && (!NewDelch))
{
- fprintf(stderr, "nothing to do -- table in file order\n");
- exit(1);
+ fprintf(stderr, "nothing to do -- table in file order\n");
+ exit(1);
}
if (NewDelch)
- Delimch = NewDelch;
+ Delimch = NewDelch;
else
- Delimch = tbl.str_delim;
+ Delimch = tbl.str_delim;
order_unstr(&tbl);
fclose(Inf);
fclose(Dataf);