run GNU protoize
protect header files nuke some dead code regenerate configure script let silly code die
This commit is contained in:
143
misc.c
143
misc.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: misc.c,v 1.11 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: misc.c,v 1.12 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -11,7 +11,7 @@
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirBSD: misc.c,v 1.11 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: misc.c,v 1.12 2004/10/28 11:53:42 tg Exp $");
|
||||
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX 0xFF
|
||||
@ -28,9 +28,7 @@ static const unsigned char *cclass(const unsigned char *p, int sub);
|
||||
* Fast character classes
|
||||
*/
|
||||
void
|
||||
setctypes(s, t)
|
||||
const char *s;
|
||||
int t;
|
||||
setctypes(const char *s, int t)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -44,7 +42,7 @@ setctypes(s, t)
|
||||
}
|
||||
|
||||
void
|
||||
initctypes()
|
||||
initctypes(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -65,9 +63,7 @@ initctypes()
|
||||
/* convert unsigned long to base N string */
|
||||
|
||||
char *
|
||||
ulton(n, base)
|
||||
unsigned long n;
|
||||
int base;
|
||||
ulton(long unsigned int n, int base)
|
||||
{
|
||||
char *p;
|
||||
static char buf [20];
|
||||
@ -82,9 +78,7 @@ ulton(n, base)
|
||||
}
|
||||
|
||||
char *
|
||||
str_save(s, ap)
|
||||
const char *s;
|
||||
Area *ap;
|
||||
str_save(const char *s, Area *ap)
|
||||
{
|
||||
size_t len;
|
||||
char *p;
|
||||
@ -102,10 +96,7 @@ str_save(s, ap)
|
||||
* (unless n < 0).
|
||||
*/
|
||||
char *
|
||||
str_nsave(s, n, ap)
|
||||
const char *s;
|
||||
int n;
|
||||
Area *ap;
|
||||
str_nsave(const char *s, int n, Area *ap)
|
||||
{
|
||||
char *ns;
|
||||
|
||||
@ -118,10 +109,7 @@ str_nsave(s, n, ap)
|
||||
|
||||
/* called from expand.h:XcheckN() to grow buffer */
|
||||
char *
|
||||
Xcheck_grow_(xsp, xp, more)
|
||||
XString *xsp;
|
||||
char *xp;
|
||||
size_t more;
|
||||
Xcheck_grow_(XString *xsp, char *xp, size_t more)
|
||||
{
|
||||
char *old_beg = xsp->beg;
|
||||
|
||||
@ -195,8 +183,7 @@ const struct option options[] = {
|
||||
* translate -o option into F* constant (also used for test -o option)
|
||||
*/
|
||||
int
|
||||
option(n)
|
||||
const char *n;
|
||||
option(const char *n)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -220,11 +207,7 @@ static void printoptions(int verbose);
|
||||
|
||||
/* format a single select menu item */
|
||||
static char *
|
||||
options_fmt_entry(arg, i, buf, buflen)
|
||||
void *arg;
|
||||
int i;
|
||||
char *buf;
|
||||
int buflen;
|
||||
options_fmt_entry(void *arg, int i, char *buf, int buflen)
|
||||
{
|
||||
struct options_info *oi = (struct options_info *) arg;
|
||||
|
||||
@ -235,8 +218,7 @@ options_fmt_entry(arg, i, buf, buflen)
|
||||
}
|
||||
|
||||
static void
|
||||
printoptions(verbose)
|
||||
int verbose;
|
||||
printoptions(int verbose)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -268,7 +250,7 @@ printoptions(verbose)
|
||||
}
|
||||
|
||||
char *
|
||||
getoptions()
|
||||
getoptions(void)
|
||||
{
|
||||
unsigned i;
|
||||
char m[(int) FNFLAGS + 1];
|
||||
@ -283,10 +265,10 @@ getoptions()
|
||||
|
||||
/* change a Flag(*) value; takes care of special actions */
|
||||
void
|
||||
change_flag(f, what, newval)
|
||||
enum sh_flag f; /* flag to change */
|
||||
int what; /* what is changing the flag (command line vs set) */
|
||||
int newval;
|
||||
change_flag(enum sh_flag f, int what, int newval)
|
||||
/* flag to change */
|
||||
/* what is changing the flag (command line vs set) */
|
||||
|
||||
{
|
||||
int oldval;
|
||||
|
||||
@ -346,10 +328,10 @@ change_flag(f, what, newval)
|
||||
* non-option arguments, -1 if there is an error.
|
||||
*/
|
||||
int
|
||||
parse_args(argv, what, setargsp)
|
||||
char **argv;
|
||||
int what; /* OF_CMDLINE or OF_SET */
|
||||
int *setargsp;
|
||||
parse_args(char **argv, int what, int *setargsp)
|
||||
|
||||
/* OF_CMDLINE or OF_SET */
|
||||
|
||||
{
|
||||
static char cmd_opts[NELEM(options) + 3]; /* o:\0 */
|
||||
static char set_opts[NELEM(options) + 5]; /* Ao;s\0 */
|
||||
@ -487,9 +469,7 @@ parse_args(argv, what, setargsp)
|
||||
|
||||
/* parse a decimal number: returns 0 if string isn't a number, 1 otherwise */
|
||||
int
|
||||
getn(as, ai)
|
||||
const char *as;
|
||||
int *ai;
|
||||
getn(const char *as, int *ai)
|
||||
{
|
||||
char *p;
|
||||
long n;
|
||||
@ -505,9 +485,7 @@ getn(as, ai)
|
||||
|
||||
/* getn() that prints error */
|
||||
int
|
||||
bi_getn(as, ai)
|
||||
const char *as;
|
||||
int *ai;
|
||||
bi_getn(const char *as, int *ai)
|
||||
{
|
||||
int rv = getn(as, ai);
|
||||
|
||||
@ -527,9 +505,7 @@ bi_getn(as, ai)
|
||||
*/
|
||||
|
||||
int
|
||||
gmatch(s, p, isfile)
|
||||
const char *s, *p;
|
||||
int isfile;
|
||||
gmatch(const char *s, const char *p, int isfile)
|
||||
{
|
||||
const char *se, *pe;
|
||||
|
||||
@ -570,8 +546,7 @@ gmatch(s, p, isfile)
|
||||
- return ?
|
||||
*/
|
||||
int
|
||||
has_globbing(xp, xpe)
|
||||
const char *xp, *xpe;
|
||||
has_globbing(const char *xp, const char *xpe)
|
||||
{
|
||||
const unsigned char *p = (const unsigned char *) xp;
|
||||
const unsigned char *pe = (const unsigned char *) xpe;
|
||||
@ -625,10 +600,7 @@ has_globbing(xp, xpe)
|
||||
|
||||
/* Function must return either 0 or 1 (assumed by code for 0x80|'!') */
|
||||
static int
|
||||
do_gmatch(s, se, p, pe, isfile)
|
||||
const unsigned char *s, *p;
|
||||
const unsigned char *se, *pe;
|
||||
int isfile;
|
||||
do_gmatch(const unsigned char *s, const unsigned char *se, const unsigned char *p, const unsigned char *pe, int isfile)
|
||||
{
|
||||
int sc, pc;
|
||||
const unsigned char *prest, *psub, *pnext;
|
||||
@ -760,9 +732,7 @@ do_gmatch(s, se, p, pe, isfile)
|
||||
}
|
||||
|
||||
static const unsigned char *
|
||||
cclass(p, sub)
|
||||
const unsigned char *p;
|
||||
int sub;
|
||||
cclass(const unsigned char *p, int sub)
|
||||
{
|
||||
int c, d, not, found = 0;
|
||||
const unsigned char *orig_p = p;
|
||||
@ -807,10 +777,7 @@ cclass(p, sub)
|
||||
|
||||
/* Look for next ) or | (if match_sep) in *(foo|bar) pattern */
|
||||
const unsigned char *
|
||||
pat_scan(p, pe, match_sep)
|
||||
const unsigned char *p;
|
||||
const unsigned char *pe;
|
||||
int match_sep;
|
||||
pat_scan(const unsigned char *p, const unsigned char *pe, int match_sep)
|
||||
{
|
||||
int nest = 0;
|
||||
|
||||
@ -835,10 +802,10 @@ pat_scan(p, pe, match_sep)
|
||||
static void qsort1(void **base, void **lim, int (*f)(void *, void *));
|
||||
|
||||
void
|
||||
qsortp(base, n, f)
|
||||
void **base; /* base address */
|
||||
size_t n; /* elements */
|
||||
int (*f)(void *, void *); /* compare function */
|
||||
qsortp(void **base, size_t n, int (*f) (void *, void *))
|
||||
/* base address */
|
||||
/* elements */
|
||||
/* compare function */
|
||||
{
|
||||
qsort1(base, base + n, f);
|
||||
}
|
||||
@ -851,9 +818,7 @@ qsortp(base, n, f)
|
||||
}
|
||||
|
||||
static void
|
||||
qsort1(base, lim, f)
|
||||
void **base, **lim;
|
||||
int (*f)(void *, void *);
|
||||
qsort1(void **base, void **lim, int (*f) (void *, void *))
|
||||
{
|
||||
void **i, **j;
|
||||
void **lptr, **hptr;
|
||||
@ -922,17 +887,14 @@ qsort1(base, lim, f)
|
||||
}
|
||||
|
||||
int
|
||||
xstrcmp(p1, p2)
|
||||
void *p1, *p2;
|
||||
xstrcmp(void *p1, void *p2)
|
||||
{
|
||||
return (strcmp((char *)p1, (char *)p2));
|
||||
}
|
||||
|
||||
/* Initialize a Getopt structure */
|
||||
void
|
||||
ksh_getopt_reset(go, flags)
|
||||
Getopt *go;
|
||||
int flags;
|
||||
ksh_getopt_reset(Getopt *go, int flags)
|
||||
{
|
||||
go->optind = 1;
|
||||
go->optarg = (char *) 0;
|
||||
@ -968,10 +930,7 @@ ksh_getopt_reset(go, flags)
|
||||
* in go->info.
|
||||
*/
|
||||
int
|
||||
ksh_getopt(argv, go, options)
|
||||
char **argv;
|
||||
Getopt *go;
|
||||
const char *options;
|
||||
ksh_getopt(char **argv, Getopt *go, const char *options)
|
||||
{
|
||||
char c;
|
||||
char *o;
|
||||
@ -1071,8 +1030,7 @@ ksh_getopt(argv, go, options)
|
||||
* No trailing newline is printed.
|
||||
*/
|
||||
void
|
||||
print_value_quoted(s)
|
||||
const char *s;
|
||||
print_value_quoted(const char *s)
|
||||
{
|
||||
const char *p;
|
||||
int inquote = 0;
|
||||
@ -1105,13 +1063,7 @@ print_value_quoted(s)
|
||||
* element
|
||||
*/
|
||||
void
|
||||
print_columns(shf, n, func, arg, max_width, prefcol)
|
||||
struct shf *shf;
|
||||
int n;
|
||||
char *(*func)(void *, int, char *, int);
|
||||
void *arg;
|
||||
int max_width;
|
||||
int prefcol;
|
||||
print_columns(struct shf *shf, int n, char *(*func) (void *, int, char *, int), void *arg, int max_width, int prefcol)
|
||||
{
|
||||
char *str = (char *) alloc(max_width + 1, ATEMP);
|
||||
int i;
|
||||
@ -1157,9 +1109,7 @@ print_columns(shf, n, func, arg, max_width, prefcol)
|
||||
|
||||
/* Strip any nul bytes from buf - returns new length (nbytes - # of nuls) */
|
||||
int
|
||||
strip_nuls(buf, nbytes)
|
||||
char *buf;
|
||||
int nbytes;
|
||||
strip_nuls(char *buf, int nbytes)
|
||||
{
|
||||
char *dst;
|
||||
|
||||
@ -1190,10 +1140,7 @@ strip_nuls(buf, nbytes)
|
||||
* Returns dst.
|
||||
*/
|
||||
char *
|
||||
str_zcpy(dst, src, dsize)
|
||||
char *dst;
|
||||
const char *src;
|
||||
int dsize;
|
||||
str_zcpy(char *dst, const char *src, int dsize)
|
||||
{
|
||||
if (dsize > 0) {
|
||||
int len = strlen(src);
|
||||
@ -1210,10 +1157,7 @@ str_zcpy(dst, src, dsize)
|
||||
* and restarts read.
|
||||
*/
|
||||
int
|
||||
blocking_read(fd, buf, nbytes)
|
||||
int fd;
|
||||
char *buf;
|
||||
int nbytes;
|
||||
blocking_read(int fd, char *buf, int nbytes)
|
||||
{
|
||||
int ret;
|
||||
int tried_reset = 0;
|
||||
@ -1242,8 +1186,7 @@ blocking_read(fd, buf, nbytes)
|
||||
* 1 if it was.
|
||||
*/
|
||||
int
|
||||
reset_nonblock(fd)
|
||||
int fd;
|
||||
reset_nonblock(int fd)
|
||||
{
|
||||
int flags;
|
||||
int blocking_flags;
|
||||
@ -1296,9 +1239,7 @@ reset_nonblock(fd)
|
||||
|
||||
/* Like getcwd(), except bsize is ignored if buf is 0 (MAXPATHLEN is used) */
|
||||
char *
|
||||
ksh_get_wd(buf, bsize)
|
||||
char *buf;
|
||||
int bsize;
|
||||
ksh_get_wd(char *buf, int bsize)
|
||||
{
|
||||
#ifdef HAVE_GETCWD
|
||||
char *b;
|
||||
|
Reference in New Issue
Block a user