4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-08 10:09:32 +08:00

Change various declarations to ANSI style to avoid problems with gcc 15

This commit is contained in:
Radek Barton 2024-12-03 16:36:45 -05:00 committed by Jeff Johnston
parent c48d58d838
commit d636b11d2e
14 changed files with 468 additions and 358 deletions

View File

@ -58,8 +58,9 @@ struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE];
void __collate_err(int ex, const char *f); void __collate_err(int ex, const char *f);
int int
__collate_load_tables(encoding) __collate_load_tables(
char *encoding; char *encoding
)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
FILE *fp; FILE *fp;
@ -113,8 +114,9 @@ __collate_load_tables(encoding)
} }
u_char * u_char *
__collate_substitute(s) __collate_substitute(
const u_char *s; const u_char *s
)
{ {
int dest_len, len, nlen; int dest_len, len, nlen;
int delta = strlen((const char *) s); int delta = strlen((const char *) s);
@ -143,9 +145,12 @@ __collate_substitute(s)
} }
void void
__collate_lookup(t, len, prim, sec) __collate_lookup(
const u_char *t; const u_char *t,
int *len, *prim, *sec; int *len,
int *prim,
int *sec
)
{ {
struct __collate_st_chain_pri *p2; struct __collate_st_chain_pri *p2;
@ -165,8 +170,7 @@ __collate_lookup(t, len, prim, sec)
} }
u_char * u_char *
__collate_strdup(s) __collate_strdup(u_char *s)
u_char *s;
{ {
u_char *t = (u_char *) strdup((const char *) s); u_char *t = (u_char *) strdup((const char *) s);

View File

@ -40,8 +40,10 @@
* "[a-z]"-type ranges with national characters. * "[a-z]"-type ranges with national characters.
*/ */
int __collate_range_cmp (c1, c2) int __collate_range_cmp (
int c1, c2; int c1,
int c2
)
{ {
static char s1[2], s2[2]; static char s1[2], s2[2];
int ret; int ret;

View File

@ -135,12 +135,13 @@ static char *pchar(int ch);
== size_t nmatch, regmatch_t pmatch[], int eflags); == size_t nmatch, regmatch_t pmatch[], int eflags);
*/ */
static int /* 0 success, REG_NOMATCH failure */ static int /* 0 success, REG_NOMATCH failure */
matcher(g, string, nmatch, pmatch, eflags) matcher(
struct re_guts *g; struct re_guts *g,
char *string; char *string,
size_t nmatch; size_t nmatch,
regmatch_t pmatch[]; regmatch_t pmatch[],
int eflags; int eflags
)
{ {
char *endp; char *endp;
int i; int i;
@ -346,12 +347,13 @@ int eflags;
== char *stop, sopno startst, sopno stopst); == char *stop, sopno startst, sopno stopst);
*/ */
static char * /* == stop (success) always */ static char * /* == stop (success) always */
dissect(m, start, stop, startst, stopst) dissect(
struct match *m; struct match *m,
char *start; char *start,
char *stop; char *stop,
sopno startst; sopno startst,
sopno stopst; sopno stopst
)
{ {
int i; int i;
sopno ss; /* start sop of current subRE */ sopno ss; /* start sop of current subRE */
@ -539,13 +541,14 @@ sopno stopst;
== char *stop, sopno startst, sopno stopst, sopno lev); == char *stop, sopno startst, sopno stopst, sopno lev);
*/ */
static char * /* == stop (success) or NULL (failure) */ static char * /* == stop (success) or NULL (failure) */
backref(m, start, stop, startst, stopst, lev) backref(
struct match *m; struct match *m,
char *start; char *start,
char *stop; char *stop,
sopno startst; sopno startst,
sopno stopst; sopno stopst,
sopno lev; /* PLUS nesting level */ sopno lev /* PLUS nesting level */
)
{ {
int i; int i;
sopno ss; /* start sop of current subRE */ sopno ss; /* start sop of current subRE */
@ -744,12 +747,13 @@ sopno lev; /* PLUS nesting level */
== char *stop, sopno startst, sopno stopst); == char *stop, sopno startst, sopno stopst);
*/ */
static char * /* where tentative match ended, or NULL */ static char * /* where tentative match ended, or NULL */
fast(m, start, stop, startst, stopst) fast(
struct match *m; struct match *m,
char *start; char *start,
char *stop; char *stop,
sopno startst; sopno startst,
sopno stopst; sopno stopst
)
{ {
states st = m->st; states st = m->st;
states fresh = m->fresh; states fresh = m->fresh;
@ -835,12 +839,13 @@ sopno stopst;
== char *stop, sopno startst, sopno stopst); == char *stop, sopno startst, sopno stopst);
*/ */
static char * /* where it ended */ static char * /* where it ended */
slow(m, start, stop, startst, stopst) slow(
struct match *m; struct match *m,
char *start; char *start,
char *stop; char *stop,
sopno startst; sopno startst,
sopno stopst; sopno stopst
)
{ {
states st = m->st; states st = m->st;
states empty = m->empty; states empty = m->empty;
@ -931,13 +936,14 @@ sopno stopst;
== #define NNONCHAR (CODEMAX-CHAR_MAX) == #define NNONCHAR (CODEMAX-CHAR_MAX)
*/ */
static states static states
step(g, start, stop, bef, ch, aft) step(
struct re_guts *g; struct re_guts *g,
sopno start; /* start state within strip */ sopno start, /* start state within strip */
sopno stop; /* state after stop state within strip */ sopno stop, /* state after stop state within strip */
states bef; /* states reachable before */ states bef, /* states reachable before */
int ch; /* character or NONCHAR code */ int ch, /* character or NONCHAR code */
states aft; /* states already known reachable after */ states aft /* states already known reachable after */
)
{ {
cset *cs; cset *cs;
sop s; sop s;

View File

@ -163,11 +163,12 @@ fnmatch(pattern, string, flags)
} }
static int static int
rangematch(pattern, test, flags, newp) rangematch(
const char *pattern; const char *pattern,
char test; char test,
int flags; int flags,
char **newp; char **newp
)
{ {
int negate, ok; int negate, ok;
char c, c2; char c, c2;

View File

@ -303,9 +303,10 @@ int cflags;
== static void p_ere(struct parse *p, int stop); == static void p_ere(struct parse *p, int stop);
*/ */
static void static void
p_ere(p, stop) p_ere(
struct parse *p; struct parse *p,
int stop; /* character this ERE should end at */ int stop /* character this ERE should end at */
)
{ {
char c; char c;
sopno prevback = 0; sopno prevback = 0;
@ -349,8 +350,7 @@ int stop; /* character this ERE should end at */
== static void p_ere_exp(struct parse *p); == static void p_ere_exp(struct parse *p);
*/ */
static void static void
p_ere_exp(p) p_ere_exp(struct parse *p)
struct parse *p;
{ {
char c; char c;
sopno pos; sopno pos;
@ -498,8 +498,7 @@ struct parse *p;
== static void p_str(struct parse *p); == static void p_str(struct parse *p);
*/ */
static void static void
p_str(p) p_str(struct parse *p)
struct parse *p;
{ {
(void)REQUIRE(MORE(), REG_EMPTY); (void)REQUIRE(MORE(), REG_EMPTY);
while (MORE()) while (MORE())
@ -519,10 +518,11 @@ struct parse *p;
* The amount of lookahead needed to avoid this kludge is excessive. * The amount of lookahead needed to avoid this kludge is excessive.
*/ */
static void static void
p_bre(p, end1, end2) p_bre(
struct parse *p; struct parse *p,
int end1; /* first terminating character */ int end1, /* first terminating character */
int end2; /* second terminating character */ int end2 /* second terminating character */
)
{ {
sopno start = HERE(); sopno start = HERE();
int first = 1; /* first subexpression? */ int first = 1; /* first subexpression? */
@ -552,9 +552,10 @@ int end2; /* second terminating character */
== static int p_simp_re(struct parse *p, int starordinary); == static int p_simp_re(struct parse *p, int starordinary);
*/ */
static int /* was the simple RE an unbackslashed $? */ static int /* was the simple RE an unbackslashed $? */
p_simp_re(p, starordinary) p_simp_re(
struct parse *p; struct parse *p,
int starordinary; /* is a leading * an ordinary character? */ int starordinary /* is a leading * an ordinary character? */
)
{ {
int c; int c;
int count; int count;
@ -670,8 +671,7 @@ int starordinary; /* is a leading * an ordinary character? */
== static int p_count(struct parse *p); == static int p_count(struct parse *p);
*/ */
static int /* the value */ static int /* the value */
p_count(p) p_count(struct parse *p)
struct parse *p;
{ {
int count = 0; int count = 0;
int ndigits = 0; int ndigits = 0;
@ -693,8 +693,7 @@ struct parse *p;
* no set operations are done. * no set operations are done.
*/ */
static void static void
p_bracket(p) p_bracket(struct parse *p)
struct parse *p;
{ {
cset *cs = allocset(p); cset *cs = allocset(p);
int invert = 0; int invert = 0;
@ -767,9 +766,10 @@ struct parse *p;
== static void p_b_term(struct parse *p, cset *cs); == static void p_b_term(struct parse *p, cset *cs);
*/ */
static void static void
p_b_term(p, cs) p_b_term(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
char c; char c;
char start, finish; char start, finish;
@ -846,9 +846,10 @@ cset *cs;
== static void p_b_cclass(struct parse *p, cset *cs); == static void p_b_cclass(struct parse *p, cset *cs);
*/ */
static void static void
p_b_cclass(p, cs) p_b_cclass(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
int c; int c;
char *sp = p->next; char *sp = p->next;
@ -942,9 +943,10 @@ cset *cs;
* This implementation is incomplete. xxx * This implementation is incomplete. xxx
*/ */
static void static void
p_b_eclass(p, cs) p_b_eclass(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
char c; char c;
@ -957,8 +959,7 @@ cset *cs;
== static char p_b_symbol(struct parse *p); == static char p_b_symbol(struct parse *p);
*/ */
static char /* value of symbol */ static char /* value of symbol */
p_b_symbol(p) p_b_symbol(struct parse *p)
struct parse *p;
{ {
char value; char value;
@ -977,9 +978,10 @@ struct parse *p;
== static char p_b_coll_elem(struct parse *p, int endc); == static char p_b_coll_elem(struct parse *p, int endc);
*/ */
static char /* value of collating element */ static char /* value of collating element */
p_b_coll_elem(p, endc) p_b_coll_elem(
struct parse *p; struct parse *p,
int endc; /* name ended by endc,']' */ int endc /* name ended by endc,']' */
)
{ {
char *sp = p->next; char *sp = p->next;
struct cname *cp; struct cname *cp;
@ -1006,8 +1008,9 @@ int endc; /* name ended by endc,']' */
== static char othercase(int ch); == static char othercase(int ch);
*/ */
static char /* if no counterpart, return ch */ static char /* if no counterpart, return ch */
othercase(ch) othercase(
int ch; int ch
)
{ {
ch = (uch)ch; ch = (uch)ch;
assert(isalpha(ch)); assert(isalpha(ch));
@ -1026,9 +1029,10 @@ int ch;
* Boy, is this implementation ever a kludge... * Boy, is this implementation ever a kludge...
*/ */
static void static void
bothcases(p, ch) bothcases(
struct parse *p; struct parse *p,
int ch; int ch
)
{ {
char *oldnext = p->next; char *oldnext = p->next;
char *oldend = p->end; char *oldend = p->end;
@ -1052,9 +1056,10 @@ int ch;
== static void ordinary(struct parse *p, int ch); == static void ordinary(struct parse *p, int ch);
*/ */
static void static void
ordinary(p, ch) ordinary(
struct parse *p; struct parse *p,
int ch; int ch
)
{ {
cat_t *cap = p->g->categories; cat_t *cap = p->g->categories;
@ -1074,8 +1079,9 @@ int ch;
* Boy, is this implementation ever a kludge... * Boy, is this implementation ever a kludge...
*/ */
static void static void
nonnewline(p) nonnewline(
struct parse *p; struct parse *p
)
{ {
char *oldnext = p->next; char *oldnext = p->next;
char *oldend = p->end; char *oldend = p->end;
@ -1098,11 +1104,12 @@ struct parse *p;
== static void repeat(struct parse *p, sopno start, int from, int to); == static void repeat(struct parse *p, sopno start, int from, int to);
*/ */
static void static void
repeat(p, start, from, to) repeat(
struct parse *p; struct parse *p,
sopno start; /* operand from here to end of strip */ sopno start, /* operand from here to end of strip */
int from; /* repeated from this number */ int from, /* repeated from this number */
int to; /* to this number of times (maybe INFINITY) */ int to /* to this number of times (maybe INFINITY) */
)
{ {
sopno finish = HERE(); sopno finish = HERE();
# define N 2 # define N 2
@ -1170,9 +1177,10 @@ int to; /* to this number of times (maybe INFINITY) */
== static int seterr(struct parse *p, int e); == static int seterr(struct parse *p, int e);
*/ */
static int /* useless but makes type checking happy */ static int /* useless but makes type checking happy */
seterr(p, e) seterr(
struct parse *p; struct parse *p,
int e; int e
)
{ {
if (p->error == 0) /* keep earliest error condition */ if (p->error == 0) /* keep earliest error condition */
p->error = e; p->error = e;
@ -1186,8 +1194,7 @@ int e;
== static cset *allocset(struct parse *p); == static cset *allocset(struct parse *p);
*/ */
static cset * static cset *
allocset(p) allocset(struct parse *p)
struct parse *p;
{ {
int no = p->g->ncsets++; int no = p->g->ncsets++;
size_t nc; size_t nc;
@ -1241,9 +1248,10 @@ struct parse *p;
== static void freeset(struct parse *p, cset *cs); == static void freeset(struct parse *p, cset *cs);
*/ */
static void static void
freeset(p, cs) freeset(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
int i; int i;
cset *top = &p->g->sets[p->g->ncsets]; cset *top = &p->g->sets[p->g->ncsets];
@ -1266,9 +1274,10 @@ cset *cs;
* the same value! * the same value!
*/ */
static int /* set number */ static int /* set number */
freezeset(p, cs) freezeset(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
short h = cs->hash; short h = cs->hash;
int i; int i;
@ -1300,9 +1309,10 @@ cset *cs;
== static int firstch(struct parse *p, cset *cs); == static int firstch(struct parse *p, cset *cs);
*/ */
static int /* character; there is no "none" value */ static int /* character; there is no "none" value */
firstch(p, cs) firstch(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
int i; int i;
size_t css = (size_t)p->g->csetsize; size_t css = (size_t)p->g->csetsize;
@ -1319,9 +1329,10 @@ cset *cs;
== static int nch(struct parse *p, cset *cs); == static int nch(struct parse *p, cset *cs);
*/ */
static int static int
nch(p, cs) nch(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
int i; int i;
size_t css = (size_t)p->g->csetsize; size_t css = (size_t)p->g->csetsize;
@ -1428,9 +1439,10 @@ char *cp;
* is deferred. * is deferred.
*/ */
static void static void
mcinvert(p, cs) mcinvert(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
assert(cs->multis == NULL); /* xxx */ assert(cs->multis == NULL); /* xxx */
} }
@ -1443,9 +1455,10 @@ cset *cs;
* is deferred. * is deferred.
*/ */
static void static void
mccase(p, cs) mccase(
struct parse *p; struct parse *p,
cset *cs; cset *cs
)
{ {
assert(cs->multis == NULL); /* xxx */ assert(cs->multis == NULL); /* xxx */
} }
@ -1455,9 +1468,10 @@ cset *cs;
== static int isinsets(struct re_guts *g, int c); == static int isinsets(struct re_guts *g, int c);
*/ */
static int /* predicate */ static int /* predicate */
isinsets(g, c) isinsets(
struct re_guts *g; struct re_guts *g,
int c; int c
)
{ {
uch *col; uch *col;
int i; int i;
@ -1475,10 +1489,11 @@ int c;
== static int samesets(struct re_guts *g, int c1, int c2); == static int samesets(struct re_guts *g, int c1, int c2);
*/ */
static int /* predicate */ static int /* predicate */
samesets(g, c1, c2) samesets(
struct re_guts *g; struct re_guts *g,
int c1; int c1,
int c2; int c2
)
{ {
uch *col; uch *col;
int i; int i;
@ -1497,9 +1512,10 @@ int c2;
== static void categorize(struct parse *p, struct re_guts *g); == static void categorize(struct parse *p, struct re_guts *g);
*/ */
static void static void
categorize(p, g) categorize(
struct parse *p; struct parse *p,
struct re_guts *g; struct re_guts *g
)
{ {
cat_t *cats = g->categories; cat_t *cats = g->categories;
int c; int c;
@ -1525,10 +1541,11 @@ struct re_guts *g;
== static sopno dupl(struct parse *p, sopno start, sopno finish); == static sopno dupl(struct parse *p, sopno start, sopno finish);
*/ */
static sopno /* start of duplicate */ static sopno /* start of duplicate */
dupl(p, start, finish) dupl(
struct parse *p; struct parse *p,
sopno start; /* from here */ sopno start, /* from here */
sopno finish; /* to this less one */ sopno finish /* to this less one */
)
{ {
sopno ret = HERE(); sopno ret = HERE();
sopno len = finish - start; sopno len = finish - start;
@ -1553,10 +1570,11 @@ sopno finish; /* to this less one */
* some changes to the data structures. Maybe later. * some changes to the data structures. Maybe later.
*/ */
static void static void
doemit(p, op, opnd) doemit(
struct parse *p; struct parse *p,
sop op; sop op,
size_t opnd; size_t opnd
)
{ {
/* avoid making error situations worse */ /* avoid making error situations worse */
if (p->error != 0) if (p->error != 0)
@ -1579,11 +1597,12 @@ size_t opnd;
== static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos); == static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos);
*/ */
static void static void
doinsert(p, op, opnd, pos) doinsert(
struct parse *p; struct parse *p,
sop op; sop op,
size_t opnd; size_t opnd,
sopno pos; sopno pos
)
{ {
sopno sn; sopno sn;
sop s; sop s;
@ -1619,10 +1638,11 @@ sopno pos;
== static void dofwd(struct parse *p, sopno pos, sop value); == static void dofwd(struct parse *p, sopno pos, sop value);
*/ */
static void static void
dofwd(p, pos, value) dofwd(
struct parse *p; struct parse *p,
sopno pos; sopno pos,
sop value; sop value
)
{ {
/* avoid making error situations worse */ /* avoid making error situations worse */
if (p->error != 0) if (p->error != 0)
@ -1637,9 +1657,10 @@ sop value;
== static void enlarge(struct parse *p, sopno size); == static void enlarge(struct parse *p, sopno size);
*/ */
static void static void
enlarge(p, size) enlarge(
struct parse *p; struct parse *p,
sopno size; sopno size
)
{ {
sop *sp; sop *sp;
@ -1660,9 +1681,10 @@ sopno size;
== static void stripsnug(struct parse *p, struct re_guts *g); == static void stripsnug(struct parse *p, struct re_guts *g);
*/ */
static void static void
stripsnug(p, g) stripsnug(
struct parse *p; struct parse *p,
struct re_guts *g; struct re_guts *g
)
{ {
g->nstates = p->slen; g->nstates = p->slen;
g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop)); g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop));
@ -1683,9 +1705,10 @@ struct re_guts *g;
* Note that must and mlen got initialized during setup. * Note that must and mlen got initialized during setup.
*/ */
static void static void
findmust(p, g) findmust(
struct parse *p; struct parse *p,
struct re_guts *g; struct re_guts *g
)
{ {
sop *scan; sop *scan;
sop *start = NULL; sop *start = NULL;
@ -1852,10 +1875,11 @@ struct re_guts *g;
* re paths. * re paths.
*/ */
static int static int
altoffset(scan, offset, mccs) altoffset(
sop *scan; sop *scan,
int offset; int offset,
int mccs; int mccs
)
{ {
int largest; int largest;
int try; int try;
@ -1932,9 +1956,10 @@ int mccs;
* the value of the character from the text that was mismatched. * the value of the character from the text that was mismatched.
*/ */
static void static void
computejumps(p, g) computejumps(
struct parse *p; struct parse *p,
struct re_guts *g; struct re_guts *g
)
{ {
int ch; int ch;
int mindex; int mindex;
@ -1978,9 +2003,10 @@ struct re_guts *g;
* the search algorithm works. * the search algorithm works.
*/ */
static void static void
computematchjumps(p, g) computematchjumps(
struct parse *p; struct parse *p,
struct re_guts *g; struct re_guts *g
)
{ {
int mindex; /* General "must" iterator */ int mindex; /* General "must" iterator */
int suffix; /* Keeps track of matching suffix */ int suffix; /* Keeps track of matching suffix */
@ -2056,9 +2082,10 @@ struct re_guts *g;
== static sopno pluscount(struct parse *p, struct re_guts *g); == static sopno pluscount(struct parse *p, struct re_guts *g);
*/ */
static sopno /* nesting depth */ static sopno /* nesting depth */
pluscount(p, g) pluscount(
struct parse *p; struct parse *p,
struct re_guts *g; struct re_guts *g
)
{ {
sop *scan; sop *scan;
sop s; sop s;

View File

@ -160,9 +160,10 @@ size_t errbuf_size;
== static char *regatoi(const regex_t *preg, char *localbuf); == static char *regatoi(const regex_t *preg, char *localbuf);
*/ */
static char * static char *
regatoi(preg, localbuf) regatoi(
const regex_t *preg; const regex_t *preg,
char *localbuf; char *localbuf
)
{ {
struct rerr *r; struct rerr *r;

View File

@ -276,8 +276,9 @@ error0:
} }
static int static int
hash_close(dbp) hash_close(
DB *dbp; DB *dbp
)
{ {
HTAB *hashp; HTAB *hashp;
int retval; int retval;
@ -292,8 +293,9 @@ hash_close(dbp)
} }
static int static int
hash_fd(dbp) hash_fd(
const DB *dbp; const DB *dbp
)
{ {
HTAB *hashp; HTAB *hashp;
@ -310,10 +312,11 @@ hash_fd(dbp)
/************************** LOCAL CREATION ROUTINES **********************/ /************************** LOCAL CREATION ROUTINES **********************/
static HTAB * static HTAB *
init_hash(hashp, file, info) init_hash(
HTAB *hashp; HTAB *hashp,
const char *file; const char *file,
const HASHINFO *info; const HASHINFO *info
)
{ {
#ifdef __USE_INTERNAL_STAT64 #ifdef __USE_INTERNAL_STAT64
struct stat64 statbuf; struct stat64 statbuf;
@ -385,9 +388,10 @@ init_hash(hashp, file, info)
* Returns 0 on No Error * Returns 0 on No Error
*/ */
static int static int
init_htab(hashp, nelem) init_htab(
HTAB *hashp; HTAB *hashp,
int nelem; int nelem
)
{ {
int nbuckets, nsegs; int nbuckets, nsegs;
int l2; int l2;
@ -431,8 +435,9 @@ init_htab(hashp, nelem)
* structure, freeing all allocated space. * structure, freeing all allocated space.
*/ */
static int static int
hdestroy(hashp) hdestroy(
HTAB *hashp; HTAB *hashp
)
{ {
int i, save_errno; int i, save_errno;
@ -491,9 +496,10 @@ hdestroy(hashp)
* -1 ERROR * -1 ERROR
*/ */
static int static int
hash_sync(dbp, flags) hash_sync(
const DB *dbp; const DB *dbp,
u_int flags; u_int flags
)
{ {
HTAB *hashp; HTAB *hashp;
@ -520,8 +526,9 @@ hash_sync(dbp, flags)
* -1 indicates that errno should be set * -1 indicates that errno should be set
*/ */
static int static int
flush_meta(hashp) flush_meta(
HTAB *hashp; HTAB *hashp
)
{ {
HASHHDR *whdrp; HASHHDR *whdrp;
#if (BYTE_ORDER == LITTLE_ENDIAN) #if (BYTE_ORDER == LITTLE_ENDIAN)
@ -568,11 +575,12 @@ flush_meta(hashp)
* -1 to indicate an internal ERROR (i.e. out of memory, etc) * -1 to indicate an internal ERROR (i.e. out of memory, etc)
*/ */
static int static int
hash_get(dbp, key, data, flag) hash_get(
const DB *dbp; const DB *dbp,
const DBT *key; const DBT *key,
DBT *data; DBT *data,
u_int flag; u_int flag
)
{ {
HTAB *hashp; HTAB *hashp;
@ -585,11 +593,12 @@ hash_get(dbp, key, data, flag)
} }
static int static int
hash_put(dbp, key, data, flag) hash_put(
const DB *dbp; const DB *dbp,
DBT *key; DBT *key,
const DBT *data; const DBT *data,
u_int flag; u_int flag
)
{ {
HTAB *hashp; HTAB *hashp;
@ -608,10 +617,11 @@ hash_put(dbp, key, data, flag)
} }
static int static int
hash_delete(dbp, key, flag) hash_delete(
const DB *dbp; const DB *dbp,
const DBT *key; const DBT *key,
u_int flag; /* Ignored */ u_int flag /* Ignored */
)
{ {
HTAB *hashp; HTAB *hashp;
@ -631,10 +641,12 @@ hash_delete(dbp, key, flag)
* Assume that hashp has been set in wrapper routine. * Assume that hashp has been set in wrapper routine.
*/ */
static int static int
hash_access(hashp, action, key, val) hash_access(
HTAB *hashp; HTAB *hashp,
ACTION action; ACTION action,
DBT *key, *val; DBT *key,
DBT *val
)
{ {
BUFHEAD *rbufp; BUFHEAD *rbufp;
BUFHEAD *bufp, *save_bufp; BUFHEAD *bufp, *save_bufp;
@ -760,10 +772,12 @@ found:
} }
static int static int
hash_seq(dbp, key, data, flag) hash_seq(
const DB *dbp; const DB *dbp,
DBT *key, *data; DBT *key,
u_int flag; DBT *data,
u_int flag
)
{ {
__uint32_t bucket; __uint32_t bucket;
BUFHEAD *bufp; BUFHEAD *bufp;
@ -850,8 +864,9 @@ hash_seq(dbp, key, data, flag)
* -1 ==> Error * -1 ==> Error
*/ */
extern int extern int
__expand_table(hashp) __expand_table(
HTAB *hashp; HTAB *hashp
)
{ {
__uint32_t old_bucket, new_bucket; __uint32_t old_bucket, new_bucket;
int dirsize, new_segnum, spare_ndx; int dirsize, new_segnum, spare_ndx;
@ -905,9 +920,11 @@ __expand_table(hashp)
* fails, then this routine can go away. * fails, then this routine can go away.
*/ */
static void * static void *
hash_realloc(p_ptr, oldsize, newsize) hash_realloc(
SEGMENT **p_ptr; SEGMENT **p_ptr,
int oldsize, newsize; int oldsize,
int newsize
)
{ {
void *p; void *p;
@ -921,10 +938,11 @@ hash_realloc(p_ptr, oldsize, newsize)
} }
extern __uint32_t extern __uint32_t
__call_hash(hashp, k, len) __call_hash(
HTAB *hashp; HTAB *hashp,
char *k; char *k,
int len; int len
)
{ {
int n, bucket; int n, bucket;
@ -941,9 +959,10 @@ __call_hash(hashp, k, len)
* Returns 0 on success * Returns 0 on success
*/ */
static int static int
alloc_segs(hashp, nsegs) alloc_segs(
HTAB *hashp; HTAB *hashp,
int nsegs; int nsegs
)
{ {
int i; int i;
SEGMENT store; SEGMENT store;
@ -975,8 +994,10 @@ alloc_segs(hashp, nsegs)
* Hashp->hdr needs to be byteswapped. * Hashp->hdr needs to be byteswapped.
*/ */
static void static void
swap_header_copy(srcp, destp) swap_header_copy(
HASHHDR *srcp, *destp; HASHHDR *srcp,
HASHHDR *destp
)
{ {
int i; int i;
@ -1004,8 +1025,9 @@ swap_header_copy(srcp, destp)
} }
static void static void
swap_header(hashp) swap_header(
HTAB *hashp; HTAB *hashp
)
{ {
HASHHDR *hdrp; HASHHDR *hdrp;
int i; int i;

View File

@ -83,10 +83,12 @@ static int collect_data(HTAB *, BUFHEAD *, int, int);
*-1 ==> ERROR *-1 ==> ERROR
*/ */
extern int extern int
__big_insert(hashp, bufp, key, val) __big_insert(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp,
const DBT *key, *val; const DBT *key,
const DBT *val
)
{ {
__uint16_t *p; __uint16_t *p;
int key_size, n, val_size; int key_size, n, val_size;
@ -183,9 +185,10 @@ __big_insert(hashp, bufp, key, val)
*-1 => ERROR *-1 => ERROR
*/ */
extern int extern int
__big_delete(hashp, bufp) __big_delete(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp
)
{ {
BUFHEAD *last_bfp, *rbufp; BUFHEAD *last_bfp, *rbufp;
__uint16_t *bp, pageno; __uint16_t *bp, pageno;
@ -262,12 +265,13 @@ __big_delete(hashp, bufp)
* -3 error * -3 error
*/ */
extern int extern int
__find_bigpair(hashp, bufp, ndx, key, size) __find_bigpair(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp,
int ndx; int ndx,
char *key; char *key,
int size; int size
)
{ {
__uint16_t *bp; __uint16_t *bp;
char *p; char *p;
@ -314,9 +318,10 @@ __find_bigpair(hashp, bufp, ndx, key, size)
* bucket) * bucket)
*/ */
extern __uint16_t extern __uint16_t
__find_last_page(hashp, bpp) __find_last_page(
HTAB *hashp; HTAB *hashp,
BUFHEAD **bpp; BUFHEAD **bpp
)
{ {
BUFHEAD *bufp; BUFHEAD *bufp;
__uint16_t *bp, pageno; __uint16_t *bp, pageno;
@ -355,12 +360,13 @@ __find_last_page(hashp, bpp)
* index (index should always be 1). * index (index should always be 1).
*/ */
extern int extern int
__big_return(hashp, bufp, ndx, val, set_current) __big_return(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp,
int ndx; int ndx,
DBT *val; DBT *val,
int set_current; int set_current
)
{ {
BUFHEAD *save_p; BUFHEAD *save_p;
__uint16_t *bp, len, off, save_addr; __uint16_t *bp, len, off, save_addr;
@ -446,10 +452,12 @@ __big_return(hashp, bufp, ndx, val, set_current)
* allocate a buffer and copy the data as you recurse up. * allocate a buffer and copy the data as you recurse up.
*/ */
static int static int
collect_data(hashp, bufp, len, set) collect_data(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp,
int len, set; int len,
int set
)
{ {
__uint16_t *bp; __uint16_t *bp;
char *p; char *p;
@ -502,11 +510,13 @@ collect_data(hashp, bufp, len, set)
* Fill in the key and data for this big pair. * Fill in the key and data for this big pair.
*/ */
extern int extern int
__big_keydata(hashp, bufp, key, val, set) __big_keydata(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp,
DBT *key, *val; DBT *key,
int set; DBT *val,
int set
)
{ {
key->size = collect_key(hashp, bufp, 0, val, set); key->size = collect_key(hashp, bufp, 0, val, set);
if (key->size == -1) if (key->size == -1)
@ -520,12 +530,13 @@ __big_keydata(hashp, bufp, key, val, set)
* collect the data, allocate a buffer and copy the key as you recurse up. * collect the data, allocate a buffer and copy the key as you recurse up.
*/ */
static int static int
collect_key(hashp, bufp, len, val, set) collect_key(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp,
int len; int len,
DBT *val; DBT *val,
int set; int set
)
{ {
BUFHEAD *xbp; BUFHEAD *xbp;
char *p; char *p;
@ -565,15 +576,16 @@ collect_key(hashp, bufp, len, val, set)
* -1 => error * -1 => error
*/ */
extern int extern int
__big_split(hashp, op, np, big_keyp, addr, obucket, ret) __big_split(
HTAB *hashp; HTAB *hashp,
BUFHEAD *op; /* Pointer to where to put keys that go in old bucket */ BUFHEAD *op, /* Pointer to where to put keys that go in old bucket */
BUFHEAD *np; /* Pointer to new bucket page */ BUFHEAD *np, /* Pointer to new bucket page */
/* Pointer to first page containing the big key/data */ /* Pointer to first page containing the big key/data */
BUFHEAD *big_keyp; BUFHEAD *big_keyp,
int addr; /* Address of big_keyp */ int addr, /* Address of big_keyp */
__uint32_t obucket;/* Old Bucket */ __uint32_t obucket,/* Old Bucket */
SPLIT_RETURN *ret; SPLIT_RETURN *ret
)
{ {
BUFHEAD *tmpp; BUFHEAD *tmpp;
__uint16_t *tp; __uint16_t *tp;

View File

@ -107,11 +107,12 @@ static BUFHEAD *newbuf(HTAB *, __uint32_t, BUFHEAD *);
* address you are seeking. * address you are seeking.
*/ */
extern BUFHEAD * extern BUFHEAD *
__get_buf(hashp, addr, prev_bp, newpage) __get_buf(
HTAB *hashp; HTAB *hashp,
__uint32_t addr; __uint32_t addr,
BUFHEAD *prev_bp; BUFHEAD *prev_bp,
int newpage; /* If prev_bp set, indicates a new overflow page. */ int newpage /* If prev_bp set, indicates a new overflow page. */
)
{ {
BUFHEAD *bp; BUFHEAD *bp;
__uint32_t is_disk_mask; __uint32_t is_disk_mask;
@ -162,10 +163,11 @@ __get_buf(hashp, addr, prev_bp, newpage)
* If newbuf finds an error (returning NULL), it also sets errno. * If newbuf finds an error (returning NULL), it also sets errno.
*/ */
static BUFHEAD * static BUFHEAD *
newbuf(hashp, addr, prev_bp) newbuf(
HTAB *hashp; HTAB *hashp,
__uint32_t addr; __uint32_t addr,
BUFHEAD *prev_bp; BUFHEAD *prev_bp
)
{ {
BUFHEAD *bp; /* The buffer we're going to use */ BUFHEAD *bp; /* The buffer we're going to use */
BUFHEAD *xbp; /* Temp pointer */ BUFHEAD *xbp; /* Temp pointer */
@ -292,9 +294,10 @@ newbuf(hashp, addr, prev_bp)
} }
extern void extern void
__buf_init(hashp, nbytes) __buf_init(
HTAB *hashp; HTAB *hashp,
int nbytes; int nbytes
)
{ {
BUFHEAD *bfp; BUFHEAD *bfp;
int npages; int npages;
@ -317,9 +320,11 @@ __buf_init(hashp, nbytes)
} }
extern int extern int
__buf_free(hashp, do_free, to_disk) __buf_free(
HTAB *hashp; HTAB *hashp,
int do_free, to_disk; int do_free,
int to_disk
)
{ {
BUFHEAD *bp; BUFHEAD *bp;
@ -348,9 +353,10 @@ __buf_free(hashp, do_free, to_disk)
} }
extern void extern void
__reclaim_buf(hashp, bp) __reclaim_buf(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bp; BUFHEAD *bp
)
{ {
bp->ovfl = 0; bp->ovfl = 0;
bp->addr = 0; bp->addr = 0;

View File

@ -167,9 +167,10 @@ hash3(keyarg, len)
/* Hash function from Chris Torek. */ /* Hash function from Chris Torek. */
static __uint32_t static __uint32_t
hash4(keyarg, len) hash4(
const void *keyarg; const void *keyarg,
size_t len; size_t len
)
{ {
const u_char *key; const u_char *key;
size_t loop; size_t loop;

View File

@ -40,8 +40,9 @@ static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94";
#include "db_local.h" #include "db_local.h"
__uint32_t __uint32_t
__log2(num) __log2(
__uint32_t num; __uint32_t num
)
{ {
__uint32_t i, limit; __uint32_t i, limit;

View File

@ -91,9 +91,11 @@ static int ugly_split
* stuff on. * stuff on.
*/ */
static void static void
putpair(p, key, val) putpair(
char *p; char *p,
const DBT *key, *val; const DBT *key,
const DBT *val
)
{ {
__uint16_t *bp, n, off; __uint16_t *bp, n, off;
@ -123,10 +125,11 @@ putpair(p, key, val)
* -1 error * -1 error
*/ */
extern int extern int
__delpair(hashp, bufp, ndx) __delpair(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp,
int ndx; int ndx
)
{ {
__uint16_t *bp, newoff; __uint16_t *bp, newoff;
int n; int n;
@ -176,9 +179,11 @@ __delpair(hashp, bufp, ndx)
* -1 ==> Error * -1 ==> Error
*/ */
extern int extern int
__split_page(hashp, obucket, nbucket) __split_page(
HTAB *hashp; HTAB *hashp,
__uint32_t obucket, nbucket; __uint32_t obucket,
__uint32_t nbucket
)
{ {
BUFHEAD *new_bufp, *old_bufp; BUFHEAD *new_bufp, *old_bufp;
__uint16_t *ino; __uint16_t *ino;
@ -272,12 +277,14 @@ __split_page(hashp, obucket, nbucket)
* -1 ==> failure * -1 ==> failure
*/ */
static int static int
ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved) ugly_split(
HTAB *hashp; HTAB *hashp,
__uint32_t obucket; /* Same as __split_page. */ __uint32_t obucket, /* Same as __split_page. */
BUFHEAD *old_bufp, *new_bufp; BUFHEAD *old_bufp,
int copyto; /* First byte on page which contains key/data values. */ BUFHEAD *new_bufp,
int moved; /* Number of pairs moved to new page. */ int copyto, /* First byte on page which contains key/data values. */
int moved /* Number of pairs moved to new page. */
)
{ {
BUFHEAD *bufp; /* Buffer header for ino */ BUFHEAD *bufp; /* Buffer header for ino */
__uint16_t *ino; /* Page keys come off of */ __uint16_t *ino; /* Page keys come off of */
@ -393,10 +400,12 @@ ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved)
* 1 ==> failure * 1 ==> failure
*/ */
extern int extern int
__addel(hashp, bufp, key, val) __addel(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp,
const DBT *key, *val; const DBT *key,
const DBT *val
)
{ {
__uint16_t *bp, *sop; __uint16_t *bp, *sop;
int do_expand; int do_expand;
@ -460,9 +469,10 @@ __addel(hashp, bufp, key, val)
* NULL on error * NULL on error
*/ */
extern BUFHEAD * extern BUFHEAD *
__add_ovflpage(hashp, bufp) __add_ovflpage(
HTAB *hashp; HTAB *hashp,
BUFHEAD *bufp; BUFHEAD *bufp
)
{ {
__uint16_t *sp; __uint16_t *sp;
__uint16_t ndx, ovfl_num; __uint16_t ndx, ovfl_num;
@ -513,11 +523,14 @@ __add_ovflpage(hashp, bufp)
* -1 indicates FAILURE * -1 indicates FAILURE
*/ */
extern int extern int
__get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) __get_page(
HTAB *hashp; HTAB *hashp,
char *p; char *p,
__uint32_t bucket; __uint32_t bucket,
int is_bucket, is_disk, is_bitmap; int is_bucket,
int is_disk,
int is_bitmap
)
{ {
int fd, page, size; int fd, page, size;
int rsize; int rsize;
@ -573,11 +586,13 @@ __get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap)
* -1 ==>failure * -1 ==>failure
*/ */
extern int extern int
__put_page(hashp, p, bucket, is_bucket, is_bitmap) __put_page(
HTAB *hashp; HTAB *hashp,
char *p; char *p,
__uint32_t bucket; __uint32_t bucket,
int is_bucket, is_bitmap; int is_bucket,
int is_bitmap
)
{ {
int fd, page, size; int fd, page, size;
int wsize; int wsize;
@ -622,9 +637,12 @@ __put_page(hashp, p, bucket, is_bucket, is_bitmap)
* once they are read in. * once they are read in.
*/ */
extern int extern int
__ibitmap(hashp, pnum, nbits, ndx) __ibitmap(
HTAB *hashp; HTAB *hashp,
int pnum, nbits, ndx; int pnum,
int nbits,
int ndx
)
{ {
__uint32_t *ip; __uint32_t *ip;
int clearbytes, clearints; int clearbytes, clearints;
@ -645,8 +663,9 @@ __ibitmap(hashp, pnum, nbits, ndx)
} }
static __uint32_t static __uint32_t
first_free(map) first_free(
__uint32_t map; __uint32_t map
)
{ {
__uint32_t i, mask; __uint32_t i, mask;
@ -660,8 +679,9 @@ first_free(map)
} }
static __uint16_t static __uint16_t
overflow_page(hashp) overflow_page(
HTAB *hashp; HTAB *hashp
)
{ {
__uint32_t *freep = NULL; __uint32_t *freep = NULL;
int max_free, offset, splitnum; int max_free, offset, splitnum;
@ -808,9 +828,10 @@ found:
* Mark this overflow page as free. * Mark this overflow page as free.
*/ */
extern void extern void
__free_ovflpage(hashp, obufp) __free_ovflpage(
HTAB *hashp; HTAB *hashp,
BUFHEAD *obufp; BUFHEAD *obufp
)
{ {
__uint16_t addr; __uint16_t addr;
__uint32_t *freep; __uint32_t *freep;
@ -854,8 +875,9 @@ __free_ovflpage(hashp, obufp)
* -1 failure * -1 failure
*/ */
static int static int
open_temp(hashp) open_temp(
HTAB *hashp; HTAB *hashp
)
{ {
sigset_t set, oset; sigset_t set, oset;
static char namestr[] = "_hashXXXXXX"; static char namestr[] = "_hashXXXXXX";
@ -878,9 +900,11 @@ open_temp(hashp)
* an overflow pair, so we need to shift things. * an overflow pair, so we need to shift things.
*/ */
static void static void
squeeze_key(sp, key, val) squeeze_key(
__uint16_t *sp; __uint16_t *sp,
const DBT *key, *val; const DBT *key,
const DBT *val
)
{ {
char *p; char *p;
__uint16_t free_space, n, off, pageno; __uint16_t free_space, n, off, pageno;
@ -905,9 +929,10 @@ squeeze_key(sp, key, val)
} }
static __uint32_t * static __uint32_t *
fetch_bitmap(hashp, ndx) fetch_bitmap(
HTAB *hashp; HTAB *hashp,
int ndx; int ndx
)
{ {
if (ndx >= hashp->nmaps) if (ndx >= hashp->nmaps)
return (NULL); return (NULL);

View File

@ -26,9 +26,10 @@ __RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
/* Walk the nodes of a tree */ /* Walk the nodes of a tree */
static void static void
trecurse(root, free_action) trecurse(
node_t *root; /* Root of the tree to be walked */ node_t *root, /* Root of the tree to be walked */
void (*free_action)(void *); void (*free_action)(void *)
)
{ {
if (root->llink != NULL) if (root->llink != NULL)
trecurse(root->llink, free_action); trecurse(root->llink, free_action);

View File

@ -28,10 +28,11 @@ static void trecurse(const node_t *,
/* Walk the nodes of a tree */ /* Walk the nodes of a tree */
static void static void
trecurse(root, action, level) trecurse(
const node_t *root; /* Root of the tree to be walked */ const node_t *root, /* Root of the tree to be walked */
void (*action)(const void *, VISIT, int); void (*action)(const void *, VISIT, int),
int level; int level
)
{ {
if (root->llink == NULL && root->rlink == NULL) if (root->llink == NULL && root->rlink == NULL)