More code clean up (KNF): de-__P and ANSI'ify function declarations

This commit is contained in:
ginsbach 2007-10-11 03:42:38 +00:00
parent d7ef1da684
commit 18072a963c
1 changed files with 42 additions and 65 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: gencat.c,v 1.22 2007/10/10 02:34:18 ginsbach Exp $ */
/* $NetBSD: gencat.c,v 1.23 2007/10/11 03:42:38 ginsbach Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: gencat.c,v 1.22 2007/10/10 02:34:18 ginsbach Exp $");
__RCSID("$NetBSD: gencat.c,v 1.23 2007/10/11 03:42:38 ginsbach Exp $");
#endif
/***********************************************************
@ -121,41 +121,39 @@ static char *curline = NULL;
static long lineno = 0;
#if 0 /* XXX unused */
static void corrupt __P((void));
static void corrupt(void);
#endif
static char *cskip __P((char *));
static void error __P((const char *));
static void nomem __P((void));
static char *getline __P((int));
static char *getmsg __P((int, char *, char));
static void warning __P((const char *, const char *));
static char *wskip __P((char *));
static char *xstrdup __P((const char *));
static void *xmalloc __P((size_t));
static void *xrealloc __P((void *, size_t));
static char *cskip(char *);
static void error(const char *);
static void nomem(void);
static char *getline(int);
static char *getmsg(int, char *, char);
static void warning(const char *, const char *);
static char *wskip(char *);
static char *xstrdup(const char *);
static void *xmalloc(size_t);
static void *xrealloc(void *, size_t);
void MCParse __P((int fd));
void MCReadCat __P((int fd));
void MCWriteCat __P((int fd));
void MCDelMsg __P((int msgId));
void MCAddMsg __P((int msgId, const char *msg));
void MCAddSet __P((int setId));
void MCDelSet __P((int setId));
int main __P((int, char **));
void usage __P((void));
void MCParse(int fd);
void MCReadCat(int fd);
void MCWriteCat(int fd);
void MCDelMsg(int msgId);
void MCAddMsg(int msgId, const char *msg);
void MCAddSet(int setId);
void MCDelSet(int setId);
int main(int, char **);
void usage(void);
void
usage()
usage(void)
{
fprintf(stderr, "usage: %s catfile msgfile ...\n", getprogname());
exit(1);
}
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
int ofd, ifd;
char *catfile = NULL;
@ -192,9 +190,7 @@ main(argc, argv)
}
static void
warning(cptr, msg)
const char *cptr;
const char *msg;
warning(const char *cptr, const char *msg)
{
fprintf(stderr, "%s: %s on line %ld\n", getprogname(), msg, lineno);
fprintf(stderr, "%s\n", curline);
@ -207,8 +203,7 @@ warning(cptr, msg)
}
static void
error(msg)
const char *msg;
error(const char *msg)
{
warning(NULL, msg);
exit(1);
@ -216,21 +211,20 @@ error(msg)
#if 0 /* XXX unused */
static void
corrupt()
corrupt(void)
{
error("corrupt message catalog");
}
#endif
static void
nomem()
nomem(void)
{
error("out of memory");
}
static void *
xmalloc(len)
size_t len;
xmalloc(size_t len)
{
void *p;
@ -240,9 +234,7 @@ xmalloc(len)
}
static void *
xrealloc(ptr, size)
void *ptr;
size_t size;
xrealloc(void *ptr, size_t size)
{
if ((ptr = realloc(ptr, size)) == NULL)
nomem();
@ -250,8 +242,7 @@ xrealloc(ptr, size)
}
static char *
xstrdup(str)
const char *str;
xstrdup(const char *str)
{
char *nstr;
@ -261,8 +252,7 @@ xstrdup(str)
}
static char *
getline(fd)
int fd;
getline(int fd)
{
static long curlen = BUFSIZ;
static char buf[BUFSIZ], *bptr = buf, *bend = buf;
@ -305,8 +295,7 @@ getline(fd)
}
static char *
wskip(cptr)
char *cptr;
wskip(char *cptr)
{
if (!*cptr || !isspace((unsigned char) *cptr)) {
warning(cptr, "expected a space");
@ -318,8 +307,7 @@ wskip(cptr)
}
static char *
cskip(cptr)
char *cptr;
cskip(char *cptr)
{
if (!*cptr || isspace((unsigned char) *cptr)) {
warning(cptr, "wasn't expecting a space");
@ -331,10 +319,7 @@ cskip(cptr)
}
static char *
getmsg(fd, cptr, quote)
int fd;
char *cptr;
char quote;
getmsg(int fd, char *cptr, char quote)
{
static char *msg = NULL;
static long msglen = 0;
@ -434,8 +419,7 @@ getmsg(fd, cptr, quote)
}
void
MCParse(fd)
int fd;
MCParse(int fd)
{
char *cptr, *str;
int msgid = 0;
@ -521,8 +505,7 @@ MCParse(fd)
}
void
MCReadCat(fd)
int fd;
MCReadCat(int fd)
{
#if 0
MCHeaderT mcHead;
@ -613,8 +596,7 @@ MCReadCat(fd)
* that would otherwise be required.
*/
void
MCWriteCat(fd)
int fd;
MCWriteCat(int fd)
{
int nsets; /* number of sets */
int nmsgs; /* number of msgs */
@ -719,8 +701,7 @@ MCWriteCat(fd)
}
void
MCAddSet(setId)
int setId;
MCAddSet(int setId)
{
struct _setT *p, *q;
@ -757,9 +738,7 @@ MCAddSet(setId)
}
void
MCAddMsg(msgId, str)
int msgId;
const char *str;
MCAddMsg(int msgId, const char *str)
{
struct _msgT *p, *q;
@ -797,8 +776,7 @@ MCAddMsg(msgId, str)
}
void
MCDelSet(setId)
int setId;
MCDelSet(int setId)
{
struct _setT *set;
struct _msgT *msg;
@ -829,8 +807,7 @@ MCDelSet(setId)
}
void
MCDelMsg(msgId)
int msgId;
MCDelMsg(int msgId)
{
struct _msgT *msg;