|
@@ -32,11 +32,9 @@ static const unsigned char *cclass ARGS((const unsigned char *p, int sub));
|
|
|
* Fast character classes
|
|
|
*/
|
|
|
void
|
|
|
-setctypes(s, t)
|
|
|
- register const char *s;
|
|
|
- register int t;
|
|
|
+setctypes(const char *s, int t)
|
|
|
{
|
|
|
- register int i;
|
|
|
+ int i;
|
|
|
|
|
|
if (t & C_IFS) {
|
|
|
for (i = 0; i < UCHAR_MAX+1; i++)
|
|
@@ -50,7 +48,7 @@ setctypes(s, t)
|
|
|
void
|
|
|
initctypes()
|
|
|
{
|
|
|
- register int c;
|
|
|
+ int c;
|
|
|
|
|
|
for (c = 'a'; c <= 'z'; c++)
|
|
|
ctypes[c] |= C_ALPHA;
|
|
@@ -69,11 +67,9 @@ initctypes()
|
|
|
/* convert unsigned long to base N string */
|
|
|
|
|
|
char *
|
|
|
-ulton(n, base)
|
|
|
- register unsigned long n;
|
|
|
- int base;
|
|
|
+ulton(unsigned long n, int base)
|
|
|
{
|
|
|
- register char *p;
|
|
|
+ char *p;
|
|
|
static char buf [20];
|
|
|
|
|
|
p = &buf[sizeof(buf)];
|
|
@@ -86,9 +82,7 @@ ulton(n, base)
|
|
|
}
|
|
|
|
|
|
char *
|
|
|
-str_save(s, ap)
|
|
|
- register const char *s;
|
|
|
- Area *ap;
|
|
|
+str_save(const char *s, Area *ap)
|
|
|
{
|
|
|
return s ? strcpy((char*) alloc((size_t)strlen(s)+1, ap), s) : NULL;
|
|
|
}
|
|
@@ -98,10 +92,7 @@ str_save(s, ap)
|
|
|
* (unless n < 0).
|
|
|
*/
|
|
|
char *
|
|
|
-str_nsave(s, n, ap)
|
|
|
- register const char *s;
|
|
|
- int n;
|
|
|
- Area *ap;
|
|
|
+str_nsave(const char *s, int n, Area *ap)
|
|
|
{
|
|
|
char *ns;
|
|
|
|
|
@@ -114,10 +105,7 @@ str_nsave(s, n, ap)
|
|
|
|
|
|
/* called from expand.h:XcheckN() to grow buffer */
|
|
|
char *
|
|
|
-Xcheck_grow_(xsp, xp, more)
|
|
|
- XString *xsp;
|
|
|
- char *xp;
|
|
|
- int more;
|
|
|
+Xcheck_grow_(XString *xsp, char *xp, int more)
|
|
|
{
|
|
|
char *old_beg = xsp->beg;
|
|
|
|
|
@@ -177,8 +165,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)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
@@ -202,11 +189,7 @@ static void printoptions ARGS((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;
|
|
|
|
|
@@ -217,8 +200,7 @@ options_fmt_entry(arg, i, buf, buflen)
|
|
|
}
|
|
|
|
|
|
static void
|
|
|
-printoptions(verbose)
|
|
|
- int verbose;
|
|
|
+printoptions(int verbose)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
@@ -254,7 +236,7 @@ getoptions()
|
|
|
{
|
|
|
int i;
|
|
|
char m[(int) FNFLAGS + 1];
|
|
|
- register char *cp = m;
|
|
|
+ char *cp = m;
|
|
|
|
|
|
for (i = 0; i < NELEM(options); i++)
|
|
|
if (options[i].c && Flag(i))
|
|
@@ -265,10 +247,9 @@ 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, /* flag to change */
|
|
|
+ int what, /* what is changing the flag (command line vs set) */
|
|
|
+ int newval)
|
|
|
{
|
|
|
int oldval;
|
|
|
|
|
@@ -298,10 +279,9 @@ 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, /* OF_CMDLINE or OF_SET */
|
|
|
+ int *setargsp)
|
|
|
{
|
|
|
static char cmd_opts[NELEM(options) + 3]; /* o:\0 */
|
|
|
static char set_opts[NELEM(options) + 5]; /* Ao;s\0 */
|
|
@@ -436,12 +416,10 @@ 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)
|
|
|
{
|
|
|
const char *s;
|
|
|
- register int n;
|
|
|
+ int n;
|
|
|
int sawdigit = 0;
|
|
|
|
|
|
s = as;
|
|
@@ -457,9 +435,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);
|
|
|
|
|
@@ -479,9 +455,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;
|
|
|
|
|
@@ -522,8 +496,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;
|
|
@@ -577,12 +550,9 @@ 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 *p, const unsigned char *se, const unsigned char *pe, int isfile;
|
|
|
{
|
|
|
- register int sc, pc;
|
|
|
+ int sc, pc;
|
|
|
const unsigned char *prest, *psub, *pnext;
|
|
|
const unsigned char *srest;
|
|
|
|
|
@@ -712,11 +682,9 @@ do_gmatch(s, se, p, pe, isfile)
|
|
|
}
|
|
|
|
|
|
static const unsigned char *
|
|
|
-cclass(p, sub)
|
|
|
- const unsigned char *p;
|
|
|
- register int sub;
|
|
|
+cclass(const unsigned char *p, int sub)
|
|
|
{
|
|
|
- register int c, d, not, found = 0;
|
|
|
+ int c, d, not, found = 0;
|
|
|
const unsigned char *orig_p = p;
|
|
|
|
|
|
if ((not = (ISMAGIC(*p) && *++p == NOT)))
|
|
@@ -759,10 +727,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;
|
|
|
|
|
@@ -784,31 +749,28 @@ pat_scan(p, pe, match_sep)
|
|
|
/*
|
|
|
* quick sort of array of generic pointers to objects.
|
|
|
*/
|
|
|
-static void qsort1 ARGS((void **base, void **lim, int (*f)(void *, void *)));
|
|
|
+static void qsort1 ARGS((void **base, void **lim, int (*f)(const void *, const void *)));
|
|
|
|
|
|
void
|
|
|
-qsortp(base, n, f)
|
|
|
- void **base; /* base address */
|
|
|
- size_t n; /* elements */
|
|
|
- int (*f) ARGS((void *, void *)); /* compare function */
|
|
|
+qsortp(void **base, /* base address */
|
|
|
+ size_t n, /* elements */
|
|
|
+ int (*f) ARGS((const void *, const void *))) /* compare function */
|
|
|
{
|
|
|
qsort1(base, base + n, f);
|
|
|
}
|
|
|
|
|
|
#define swap2(a, b) {\
|
|
|
- register void *t; t = *(a); *(a) = *(b); *(b) = t;\
|
|
|
+ void *t; t = *(a); *(a) = *(b); *(b) = t;\
|
|
|
}
|
|
|
#define swap3(a, b, c) {\
|
|
|
- register void *t; t = *(a); *(a) = *(c); *(c) = *(b); *(b) = t;\
|
|
|
+ void *t; t = *(a); *(a) = *(c); *(c) = *(b); *(b) = t;\
|
|
|
}
|
|
|
|
|
|
static void
|
|
|
-qsort1(base, lim, f)
|
|
|
- void **base, **lim;
|
|
|
- int (*f) ARGS((void *, void *));
|
|
|
+qsort1(void **base, void **lim, int (*f) ARGS((const void *, const void *)))
|
|
|
{
|
|
|
- register void **i, **j;
|
|
|
- register void **lptr, **hptr;
|
|
|
+ void **i, **j;
|
|
|
+ void **lptr, **hptr;
|
|
|
size_t n;
|
|
|
int c;
|
|
|
|
|
@@ -874,17 +836,14 @@ qsort1(base, lim, f)
|
|
|
}
|
|
|
|
|
|
int
|
|
|
-xstrcmp(p1, p2)
|
|
|
- void *p1, *p2;
|
|
|
+xstrcmp(const void *p1, const 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;
|
|
@@ -920,10 +879,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;
|
|
@@ -1023,8 +979,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;
|
|
@@ -1057,12 +1012,7 @@ print_value_quoted(s)
|
|
|
* element
|
|
|
*/
|
|
|
void
|
|
|
-print_columns(shf, n, func, arg, max_width)
|
|
|
- struct shf *shf;
|
|
|
- int n;
|
|
|
- char *(*func) ARGS((void *, int, char *, int));
|
|
|
- void *arg;
|
|
|
- int max_width;
|
|
|
+print_columns(struct shf *shf, int n, char *(*func) ARGS((void *, int, char *, int)), void *arg, int max_width)
|
|
|
{
|
|
|
char *str = (char *) alloc(max_width + 1, ATEMP);
|
|
|
int i;
|
|
@@ -1108,9 +1058,7 @@ print_columns(shf, n, func, arg, max_width)
|
|
|
|
|
|
/* 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;
|
|
|
|
|
@@ -1141,10 +1089,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);
|
|
@@ -1161,10 +1106,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;
|
|
@@ -1193,8 +1135,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;
|
|
@@ -1250,9 +1191,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;
|