+2001-06-21 Ezra Peisach <epeisach@mit.edu>
+
+ * test/dbtest.c: Cast argument to isspace() to int. Do not shadow
+ global variables type and flags.
+
+ * btree/bt_search.c, btree/bt_seq.c, recno/rec_search.c: Change
+ local variable index to idx.
+
2001-06-21 Ezra Peisach <epeisach@mit.edu>
* btree/bt_delete.c, btree/bt_put.c, recno/rec_delete.c,
int *exactp;
{
PAGE *h;
- indx_t base, index, lim;
+ indx_t base, idx, lim;
db_pgno_t pg;
int cmp;
/* Do a binary search on the current page. */
t->bt_cur.page = h;
for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) {
- t->bt_cur.index = index = base + (lim >> 1);
+ t->bt_cur.index = idx = base + (lim >> 1);
if ((cmp = __bt_cmp(t, key, &t->bt_cur)) == 0) {
if (h->flags & P_BLEAF) {
*exactp = 1;
goto next;
}
if (cmp > 0) {
- base = index + 1;
+ base = idx + 1;
--lim;
}
}
* be a parent page for the key. If a split later occurs, the
* inserted page will be to the right of the saved page.
*/
- index = base ? base - 1 : base;
+ idx = base ? base - 1 : base;
-next: BT_PUSH(t, h->pgno, index);
- pg = GETBINTERNAL(h, index)->pgno;
+next: BT_PUSH(t, h->pgno, idx);
+ pg = GETBINTERNAL(h, idx)->pgno;
mpool_put(t->bt_mp, h, 0);
}
}
BINTERNAL *bi;
EPG e;
EPGNO *parent;
- indx_t index;
+ indx_t idx;
db_pgno_t pgno;
int level;
/* Move to the next index. */
if (parent->index != NEXTINDEX(h) - 1) {
- index = parent->index + 1;
- BT_PUSH(t, h->pgno, index);
+ idx = parent->index + 1;
+ BT_PUSH(t, h->pgno, idx);
break;
}
mpool_put(t->bt_mp, h, 0);
/* Restore the stack. */
while (level--) {
/* Push the next level down onto the stack. */
- bi = GETBINTERNAL(h, index);
+ bi = GETBINTERNAL(h, idx);
pgno = bi->pgno;
BT_PUSH(t, pgno, 0);
/* Get the next level down. */
if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL)
return (0);
- index = 0;
+ idx = 0;
}
mpool_put(t->bt_mp, h, 0);
return (1);
BINTERNAL *bi;
EPG e;
EPGNO *parent;
- indx_t index;
+ indx_t idx;
db_pgno_t pgno;
int level;
/* Move to the next index. */
if (parent->index != 0) {
- index = parent->index - 1;
- BT_PUSH(t, h->pgno, index);
+ idx = parent->index - 1;
+ BT_PUSH(t, h->pgno, idx);
break;
}
mpool_put(t->bt_mp, h, 0);
/* Restore the stack. */
while (level--) {
/* Push the next level down onto the stack. */
- bi = GETBINTERNAL(h, index);
+ bi = GETBINTERNAL(h, idx);
pgno = bi->pgno;
/* Lose the currently pinned page. */
if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL)
return (1);
- index = NEXTINDEX(h) - 1;
- BT_PUSH(t, pgno, index);
+ idx = NEXTINDEX(h) - 1;
+ BT_PUSH(t, pgno, idx);
}
mpool_put(t->bt_mp, h, 0);
return (1);
{
CURSOR *c;
PAGE *h;
- indx_t index;
+ indx_t idx;
db_pgno_t pg;
int exact, rval;
*/
if (F_ISSET(c, CURS_AFTER))
goto usecurrent;
- index = c->pg.index;
- if (++index == NEXTINDEX(h)) {
+ idx = c->pg.index;
+ if (++idx == NEXTINDEX(h)) {
pg = h->nextpg;
mpool_put(t->bt_mp, h, 0);
if (pg == P_INVALID)
return (RET_SPECIAL);
if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
return (RET_ERROR);
- index = 0;
+ idx = 0;
}
break;
case R_PREV: /* Previous record. */
ep->index = c->pg.index;
return (RET_SUCCESS);
}
- index = c->pg.index;
- if (index == 0) {
+ idx = c->pg.index;
+ if (idx == 0) {
pg = h->prevpg;
mpool_put(t->bt_mp, h, 0);
if (pg == P_INVALID)
return (RET_SPECIAL);
if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
return (RET_ERROR);
- index = NEXTINDEX(h) - 1;
+ idx = NEXTINDEX(h) - 1;
} else
- --index;
+ --idx;
break;
}
ep->page = h;
- ep->index = index;
+ ep->index = idx;
return (RET_SUCCESS);
}
* index: page index
*/
void
-__bt_setcur(t, pgno, index)
+__bt_setcur(t, pgno, idx)
BTREE *t;
db_pgno_t pgno;
- u_int index;
+ u_int idx;
{
/* Lose any already deleted key. */
if (t->bt_cursor.key.data != NULL) {
/* Update the cursor. */
t->bt_cursor.pg.pgno = pgno;
- t->bt_cursor.pg.index = index;
+ t->bt_cursor.pg.index = idx;
F_SET(&t->bt_cursor, CURS_INIT);
}
recno_t recno;
enum SRCHOP op;
{
- register indx_t index;
+ register indx_t idx;
register PAGE *h;
EPGNO *parent;
RINTERNAL *r;
t->bt_cur.index = recno - total;
return (&t->bt_cur);
}
- for (index = 0, top = NEXTINDEX(h);;) {
- r = GETRINTERNAL(h, index);
- if (++index == top || total + r->nrecs > recno)
+ for (idx = 0, top = NEXTINDEX(h);;) {
+ r = GETRINTERNAL(h, idx);
+ if (++idx == top || total + r->nrecs > recno)
break;
total += r->nrecs;
}
- BT_PUSH(t, pg, index - 1);
+ BT_PUSH(t, pg, idx - 1);
pg = r->pgno;
switch (op) {
case SDELETE:
- --GETRINTERNAL(h, (index - 1))->nrecs;
+ --GETRINTERNAL(h, (idx - 1))->nrecs;
mpool_put(t->bt_mp, h, MPOOL_DIRTY);
break;
case SINSERT:
- ++GETRINTERNAL(h, (index - 1))->nrecs;
+ ++GETRINTERNAL(h, (idx - 1))->nrecs;
mpool_put(t->bt_mp, h, MPOOL_DIRTY);
break;
case SEARCH:
/* Delete the newline, displaying the key/data is easier. */
if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL)
*t = '\0';
- if ((len = strlen(buf)) == 0 || isspace(*p) || *p == '#')
+ if ((len = strlen(buf)) == 0 || isspace((int) *p) || *p == '#')
continue;
/* Convenient gdb break point. */
int rev;
{
DBT key, data;
- int flags, nflags;
+ int lflags, nflags;
if (rev) {
- flags = R_LAST;
+ lflags = R_LAST;
nflags = R_PREV;
} else {
- flags = R_FIRST;
+ lflags = R_FIRST;
nflags = R_NEXT;
}
- for (;; flags = nflags)
- switch (dbp->seq(dbp, &key, &data, flags)) {
+ for (;; lflags = nflags)
+ switch (dbp->seq(dbp, &key, &data, lflags)) {
case 0:
(void)write(ofd, data.data, data.size);
if (ofd == STDOUT_FILENO)
{
char *p;
- for (; isspace(*s); ++s);
+ for (; isspace((int) *s); ++s);
if (*s == '\n' || *s == '\0')
return (0);
if ((p = strchr(s, '\n')) != NULL)
}
char *
-sflags(flags)
- int flags;
+sflags(lflags)
+ int lflags;
{
- switch (flags) {
+ switch (lflags) {
case R_CURSOR: return ("R_CURSOR");
case R_FIRST: return ("R_FIRST");
case R_IAFTER: return ("R_IAFTER");
}
void *
-setinfo(type, s)
- DBTYPE type;
+setinfo(db_type, s)
+ DBTYPE db_type;
char *s;
{
static BTREEINFO ib;
if ((eq = strchr(s, '=')) == NULL)
err("%s: illegal structure set statement", s);
*eq++ = '\0';
- if (!isdigit(*eq))
+ if (!isdigit((int) *eq))
err("%s: structure set statement must be a number", s);
- switch (type) {
+ switch (db_type) {
case DB_BTREE:
if (!strcmp("flags", s)) {
ib.flags = atoi(eq);
int fd;
char *np;
- for (; isspace(*name); ++name);
+ for (; isspace((int) *name); ++name);
if ((np = strchr(name, '\n')) != NULL)
*np = '\0';
if ((fd = open(name, O_RDONLY, 0)) < 0 ||