*
* char[] prefix; // nul terminated
*
- * unsigned char first;
- * unsigned char last;
+ * uint8_t first;
+ * uint8_t last;
* uint32_t children[last - first + 1];
*
* uint32_t value_count;
struct index_file *idx;
char *prefix; /* path compression */
struct index_value *values;
- unsigned char first; /* range of child nodes */
- unsigned char last;
+ uint8_t first; /* range of child nodes */
+ uint8_t last;
uint32_t children[0];
};
if (node == NULL)
goto err;
- node->first = (unsigned char)first;
- node->last = (unsigned char)last;
+ node->first = (uint8_t)first;
+ node->last = (uint8_t)last;
if (!read_u32s(fp, node->children, child_count))
goto err;
return index_read(in, in->root_offset);
}
-static struct index_node_f *index_readchild(const struct index_node_f *parent, int ch)
+static struct index_node_f *index_readchild(const struct index_node_f *parent, uint8_t ch)
{
if (parent->first <= ch && ch <= parent->last) {
return index_read(parent->idx, parent->children[ch - parent->first]);
{
struct index_value *v;
size_t pushed;
- int ch;
pushed = strbuf_pushchars(buf, node->prefix);
write_str_safe(fd, "\n", 1);
}
- for (ch = node->first; ch <= node->last; ch++) {
+ for (uint8_t ch = node->first; ch <= node->last; ch++) {
struct index_node_f *child = index_readchild(node, ch);
if (!child)
{
char *value;
struct index_node_f *child;
- int ch;
int j;
while (node) {
for (j = 0; node->prefix[j]; j++) {
- ch = node->prefix[j];
+ uint8_t ch = node->prefix[j];
if (ch != key[i + j]) {
index_close(node);
const char *subkey, struct index_value **out)
{
size_t pushed;
- int ch;
pushed = strbuf_pushchars(buf, &node->prefix[j]);
- for (ch = node->first; ch <= node->last; ch++) {
+ for (uint8_t ch = node->first; ch <= node->last; ch++) {
struct index_node_f *child = index_readchild(node, ch);
if (!child)
{
struct index_node_f *child;
int j;
- int ch;
while (node) {
for (j = 0; node->prefix[j]; j++) {
- ch = node->prefix[j];
+ uint8_t ch = node->prefix[j];
if (ch == '*' || ch == '?' || ch == '[') {
index_searchwild__all(node, j, buf, &key[j], out);
}
static struct index_mm_node *index_mm_readchild(const struct index_mm_node *parent,
- int ch, struct index_mm_node *child)
+ uint8_t ch, struct index_mm_node *child)
{
if (parent->first <= ch && ch <= parent->last) {
const void *p;
{
const void *p;
size_t i, pushed;
- int ch;
pushed = strbuf_pushchars(buf, node->prefix);
write_str_safe(fd, "\n", 1);
}
- for (ch = node->first; ch <= node->last; ch++) {
+ for (uint8_t ch = node->first; ch <= node->last; ch++) {
struct index_mm_node *child, nbuf;
child = index_mm_readchild(node, ch, &nbuf);
static char *index_mm_search_node(struct index_mm_node *node, const char *key)
{
char *value;
- int ch;
int j;
while (node) {
for (j = 0; node->prefix[j]; j++) {
- ch = node->prefix[j];
+ uint8_t ch = node->prefix[j];
if (ch != key[j])
return NULL;
const char *subkey, struct index_value **out)
{
size_t pushed;
- int ch;
pushed = strbuf_pushchars(buf, &node->prefix[j]);
- for (ch = node->first; ch <= node->last; ch++) {
+ for (uint8_t ch = node->first; ch <= node->last; ch++) {
struct index_mm_node *child, nbuf;
child = index_mm_readchild(node, ch, &nbuf);
int j;
for (j = 0; node->prefix[j]; j++) {
- int ch = node->prefix[j];
+ uint8_t ch = node->prefix[j];
if (ch == '*' || ch == '?' || ch == '[') {
index_mm_searchwild_all(node, j, buf, key + j, out);