Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/crunch/crunchgen Make this produce proper ansi c and...
details: https://anonhg.NetBSD.org/src/rev/37164a52419e
branches: trunk
changeset: 765009:37164a52419e
user: christos <christos%NetBSD.org@localhost>
date: Sun May 15 21:28:51 2011 +0000
description:
Make this produce proper ansi c and knf.
diffstat:
usr.bin/crunch/crunchgen/crunched_main.c | 87 +++++++++++++++----------------
usr.bin/crunch/crunchgen/crunchgen.c | 9 +-
2 files changed, 48 insertions(+), 48 deletions(-)
diffs (159 lines):
diff -r 005446d3dd0f -r 37164a52419e usr.bin/crunch/crunchgen/crunched_main.c
--- a/usr.bin/crunch/crunchgen/crunched_main.c Sun May 15 21:25:33 2011 +0000
+++ b/usr.bin/crunch/crunchgen/crunched_main.c Sun May 15 21:28:51 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crunched_main.c,v 1.4 2006/05/10 21:34:20 mrg Exp $ */
+/* $NetBSD: crunched_main.c,v 1.5 2011/05/15 21:28:51 christos Exp $ */
/*
* Copyright (c) 1994 University of Maryland
* All Rights Reserved.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: crunched_main.c,v 1.4 2006/05/10 21:34:20 mrg Exp $");
+__RCSID("$NetBSD: crunched_main.c,v 1.5 2011/05/15 21:28:51 christos Exp $");
#endif
#include <stdio.h>
@@ -42,68 +42,67 @@
#include <stdlib.h>
struct stub {
- char *name;
- int (*f)();
+ const char *name;
+ int (*f)(int, char **, char **);
};
-extern struct stub entry_points[];
+static const struct stub entry_points[];
-int main(int argc, char **argv, char **envp)
+static int crunched_main(int , char **, char **);
+static int crunched_usage(void) __attribute__((__noreturn__));
+
+int
+main(int argc, char **argv, char **envp)
{
- char *slash, *basename;
- struct stub *ep;
-
- if(argv[0] == NULL || *argv[0] == '\0')
- crunched_usage();
+ const char *basename;
+ const struct stub *ep;
- slash = strrchr(argv[0], '/');
- basename = slash? slash+1 : argv[0];
+ if (argv[0] == NULL || *argv[0] == '\0')
+ crunched_usage();
- for(ep=entry_points; ep->name != NULL; ep++)
- if(!strcmp(basename, ep->name)) break;
+ basename = strrchr(argv[0], '/');
+ basename = basename ? basename + 1 : argv[0];
- if(ep->name)
- return ep->f(argc, argv, envp);
- else {
+ for (ep = entry_points; ep->name != NULL; ep++)
+ if (strcmp(basename, ep->name) == 0)
+ return ep->f(argc, argv, envp);
+
fprintf(stderr, "%s: %s not compiled in\n", EXECNAME, basename);
crunched_usage();
- }
}
-int crunched_main(int argc, char **argv, char **envp)
+static int
+crunched_main(int argc, char **argv, char **envp)
{
- struct stub *ep;
- int columns, len;
+ if(argc <= 1)
+ crunched_usage();
- if(argc <= 1)
- crunched_usage();
-
- return main(--argc, ++argv, envp);
+ return main(--argc, ++argv, envp);
}
-int crunched_usage()
+static int
+crunched_usage(void)
{
- int columns, len;
- struct stub *ep;
+ size_t columns, len;
+ const struct stub *ep;
- fprintf(stderr, "Usage: %s <prog> <args> ..., where <prog> is one of:\n",
- EXECNAME);
- columns = 0;
- for(ep=entry_points; ep->name != NULL; ep++) {
- len = strlen(ep->name) + 1;
- if(columns+len < 80)
- columns += len;
- else {
- fprintf(stderr, "\n");
- columns = len;
+ fprintf(stderr, "Usage: %s <prog> <args> ..., "
+ "where <prog> is one of:\n", EXECNAME);
+ columns = 0;
+ for (ep = entry_points; ep->name != NULL; ep++) {
+ len = strlen(ep->name) + 1;
+ if (columns + len < 80)
+ columns += len;
+ else {
+ fprintf(stderr, "\n");
+ columns = len;
+ }
+ fprintf(stderr, " %s", ep->name);
}
- fprintf(stderr, " %s", ep->name);
- }
- fprintf(stderr, "\n");
- exit(1);
+ fprintf(stderr, "\n");
+ exit(1);
}
/* end of crunched_main.c */
-
diff -r 005446d3dd0f -r 37164a52419e usr.bin/crunch/crunchgen/crunchgen.c
--- a/usr.bin/crunch/crunchgen/crunchgen.c Sun May 15 21:25:33 2011 +0000
+++ b/usr.bin/crunch/crunchgen/crunchgen.c Sun May 15 21:28:51 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crunchgen.c,v 1.78 2010/04/24 17:58:40 christos Exp $ */
+/* $NetBSD: crunchgen.c,v 1.79 2011/05/15 21:28:51 christos Exp $ */
/*
* Copyright (c) 1994 University of Maryland
* All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: crunchgen.c,v 1.78 2010/04/24 17:58:40 christos Exp $");
+__RCSID("$NetBSD: crunchgen.c,v 1.79 2011/05/15 21:28:51 christos Exp $");
#endif
#include <stdlib.h>
@@ -855,9 +855,10 @@
fprintf(outcf, "%s\n", *cp);
for (p = progs; p != NULL; p = p->next)
- fprintf(outcf, "extern int _crunched_%s_stub();\n", p->ident);
+ fprintf(outcf, "extern int _crunched_%s_stub(int, char **, char **);\n",
+ p->ident);
- fprintf(outcf, "\nstruct stub entry_points[] = {\n");
+ fprintf(outcf, "\nstatic const struct stub entry_points[] = {\n");
for (p = progs; p != NULL; p = p->next) {
fprintf(outcf, "\t{ \"%s\", _crunched_%s_stub },\n",
p->name, p->ident);
Home |
Main Index |
Thread Index |
Old Index