]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Remove trailing whitespaces
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 30 Nov 2011 17:59:36 +0000 (15:59 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 30 Nov 2011 17:59:47 +0000 (15:59 -0200)
libkmod/libkmod-index.c

index 513a88fed7a4d7fdfc9c706e3a0f298b63b8c597..3d697d60a6843350bb881826a488f22851e8f43a 100644 (file)
@@ -37,7 +37,7 @@ struct index_node *index_create()
        node = NOFAIL(calloc(sizeof(struct index_node), 1));
        node->prefix = NOFAIL(strdup(""));
        node->first = INDEX_CHILDMAX;
-       
+
        return node;
 }
 
@@ -54,10 +54,10 @@ void index_values_free(struct index_value *values)
 void index_destroy(struct index_node *node)
 {
        int c;
-       
+
        for (c = node->first; c <= node->last; c++) {
                struct index_node *child = node->children[c];
-               
+
                if (child)
                        index_destroy(child);
        }
@@ -69,10 +69,10 @@ void index_destroy(struct index_node *node)
 static void index__checkstring(const char *str)
 {
        int i;
-       
+
        for (i = 0; str[i]; i++) {
                int ch = str[i];
-               
+
                if (ch >= INDEX_CHILDMAX)
                        fatal("Module index: bad character '%c'=0x%x - only 7-bit ASCII is supported:"
                              "\n%s\n", (char) ch, (int) ch, str);
@@ -111,27 +111,27 @@ int index_insert(struct index_node *node, const char *key,
 {
        int i = 0; /* index within str */
        int ch;
-       
+
        index__checkstring(key);
        index__checkstring(value);
-       
+
        while(1) {
                int j; /* index within node->prefix */
-       
+
                /* Ensure node->prefix is a prefix of &str[i].
                   If it is not already, then we must split node. */
                for (j = 0; node->prefix[j]; j++) {
                        ch = node->prefix[j];
-               
+
                        if (ch != key[i+j]) {
                                char *prefix = node->prefix;
                                struct index_node *n;
-                               
+
                                /* New child is copy of node with prefix[j+1..N] */
                                n = NOFAIL(calloc(sizeof(struct index_node), 1));
                                memcpy(n, node, sizeof(struct index_node));
                                n->prefix = NOFAIL(strdup(&prefix[j+1]));
-                               
+
                                /* Parent has prefix[0..j], child at prefix[j] */
                                memset(node, 0, sizeof(struct index_node));
                                prefix[j] = '\0';
@@ -139,26 +139,26 @@ int index_insert(struct index_node *node, const char *key,
                                node->first = ch;
                                node->last = ch;
                                node->children[ch] = n;
-                               
+
                                break;
                        }
                }
                /* j is now length of node->prefix */
                i += j;
-       
+
                ch = key[i];
                if(ch == '\0')
                        return add_value(&node->values, value, priority);
-               
+
                if (!node->children[ch]) {
                        struct index_node *child;
-               
+
                        if (ch < node->first)
                                node->first = ch;
                        if (ch > node->last)
                                node->last = ch;
                        node->children[ch] = NOFAIL(calloc(sizeof(struct index_node), 1));
-                       
+
                        child = node->children[ch];
                        child->prefix = NOFAIL(strdup(&key[i+1]));
                        child->first = INDEX_CHILDMAX;
@@ -166,7 +166,7 @@ int index_insert(struct index_node *node, const char *key,
 
                        return 0;
                }
-               
+
                /* Descend into child node and continue */
                node = node->children[ch];
                i++;
@@ -190,33 +190,33 @@ static uint32_t index_write__node(const struct index_node *node, FILE *out)
        uint32_t *child_offs = NULL;
        int child_count = 0;
        long offset;
-       
+
        if (!node)
                return 0;
-       
+
        /* Write children and save their offsets */
        if (index__haschildren(node)) {
                const struct index_node *child;
                int i;
-               
+
                child_count = node->last - node->first + 1;
                child_offs = NOFAIL(malloc(child_count * sizeof(uint32_t)));
-               
+
                for (i = 0; i < child_count; i++) {
                        child = node->children[node->first + i];
                        child_offs[i] = htonl(index_write__node(child, out));
                }
        }
-               
+
        /* Now write this node */
        offset = ftell(out);
-       
+
        if (node->prefix[0]) {
                fputs(node->prefix, out);
                fputc('\0', out);
                offset |= INDEX_NODE_PREFIX;
        }
-               
+
        if (child_count) {
                fputc(node->first, out);
                fputc(node->last, out);
@@ -224,7 +224,7 @@ static uint32_t index_write__node(const struct index_node *node, FILE *out)
                free(child_offs);
                offset |= INDEX_NODE_CHILDS;
        }
-       
+
        if (node->values) {
                const struct index_value *v;
                unsigned int value_count;
@@ -244,7 +244,7 @@ static uint32_t index_write__node(const struct index_node *node, FILE *out)
                }
                offset |= INDEX_NODE_VALUES;
        }
-       
+
        return offset;
 }
 
@@ -252,20 +252,20 @@ void index_write(const struct index_node *node, FILE *out)
 {
        long initial_offset, final_offset;
        uint32_t u;
-       
+
        u = htonl(INDEX_MAGIC);
        fwrite(&u, sizeof(u), 1, out);
        u = htonl(INDEX_VERSION);
        fwrite(&u, sizeof(u), 1, out);
-       
+
        /* Second word is reserved for the offset of the root node */
        initial_offset = ftell(out);
        u = 0;
        fwrite(&u, sizeof(uint32_t), 1, out);
-       
+
        /* Dump trie */
        u = htonl(index_write__node(node, out));
-       
+
        /* Update first word */
        final_offset = ftell(out);
        fseek(out, initial_offset, SEEK_SET);
@@ -327,7 +327,7 @@ static void buf__realloc(struct buffer *buf, unsigned size)
 static struct buffer *buf_create()
 {
        struct buffer *buf;
-        
+
        buf = NOFAIL(calloc(sizeof(struct buffer), 1));
        buf__realloc(buf, 256);
        return buf;
@@ -437,22 +437,22 @@ static struct index_node_f *index_read(FILE *in, uint32_t offset)
                return NULL;
 
        fseek(in, offset & INDEX_NODE_MASK, SEEK_SET);
-       
+
        if (offset & INDEX_NODE_PREFIX) {
                struct buffer *buf = buf_create();
                buf_freadchars(buf, in);
                prefix = buf_detach(buf);
        } else
                prefix = NOFAIL(strdup(""));
-               
+
        if (offset & INDEX_NODE_CHILDS) {
                char first = read_char(in);
                char last = read_char(in);
                child_count = last - first + 1;
-               
+
                node = NOFAIL(malloc(sizeof(struct index_node_f) +
                                     sizeof(uint32_t) * child_count));
-               
+
                node->first = first;
                node->last = last;
 
@@ -463,7 +463,7 @@ static struct index_node_f *index_read(FILE *in, uint32_t offset)
                node->first = INDEX_CHILDMAX;
                node->last = 0;
        }
-       
+
        node->values = NULL;
        if (offset & INDEX_NODE_VALUES) {
                int value_count;
@@ -561,9 +561,9 @@ static void index_dump_node(struct index_node_f *node,
 {
        struct index_value *v;
        int ch, pushed;
-       
+
        pushed = buf_pushchars(buf, node->prefix);
-       
+
        for (v = node->values; v != NULL; v = v->next) {
                fputs(prefix, out);
                buf_fwrite(buf, out);
@@ -571,18 +571,18 @@ static void index_dump_node(struct index_node_f *node,
                fputs(v->value, out);
                fputc('\n', out);
        }
-       
+
        for (ch = node->first; ch <= node->last; ch++) {
                struct index_node_f *child = index_readchild(node, ch);
-               
+
                if (!child)
                        continue;
-                       
+
                buf_pushchar(buf, ch);
                index_dump_node(child, buf, out, prefix);
                buf_popchar(buf);
        }
-       
+
        buf_popchars(buf, pushed);
        index_close(node);
 }
@@ -591,7 +591,7 @@ void index_dump(struct index_file *in, FILE *out, const char *prefix)
 {
        struct index_node_f *root;
        struct buffer *buf;
-       
+
        buf = buf_create();
        root = index_readroot(in);
        index_dump_node(root, buf, out, prefix);
@@ -613,10 +613,10 @@ char *index_search(struct index_file *in, const char *key)
 {
        struct index_node_f *root;
        char *value;
-       
+
        root = index_readroot(in);
        value = index_search__node(root, key, 0);
-       
+
        return value;
 }
 
@@ -630,14 +630,14 @@ static char *index_search__node(struct index_node_f *node, const char *key, int
        while(node) {
                for (j = 0; node->prefix[j]; j++) {
                        ch = node->prefix[j];
-                       
+
                        if (ch != key[i+j]) {
                                index_close(node);
                                return NULL;
                        }
                }
                i += j;
-               
+
                if (key[i] == '\0') {
                        if (node->values) {
                                value = strdup(node->values[0].value);
@@ -647,13 +647,13 @@ static char *index_search__node(struct index_node_f *node, const char *key, int
                                return NULL;
                        }
                }
-               
+
                child = index_readchild(node, key[i]);
                index_close(node);
                node = child;
                i++;
        }
-       
+
        return NULL;
 }
 
@@ -690,7 +690,7 @@ struct index_value *index_searchwild(struct index_file *in, const char *key)
        struct index_node_f *root = index_readroot(in);
        struct buffer *buf = buf_create();
        struct index_value *out = NULL;
-       
+
        index_searchwild__node(root, buf, key, 0, &out);
        buf_destroy(buf);
        return out;
@@ -708,47 +708,47 @@ static void index_searchwild__node(struct index_node_f *node,
        while(node) {
                for (j = 0; node->prefix[j]; j++) {
                        ch = node->prefix[j];
-                       
+
                        if (ch == '*' || ch == '?' || ch == '[') {
                                index_searchwild__all(node, j, buf,
                                                      &key[i+j], out);
                                return;
                        }
-                       
+
                        if (ch != key[i+j]) {
                                index_close(node);
                                return;
                        }
                }
                i += j;
-               
+
                child = index_readchild(node, '*');
                if (child) {
                        buf_pushchar(buf, '*');
                        index_searchwild__all(child, 0, buf, &key[i], out);
                        buf_popchar(buf);
                }
-               
+
                child = index_readchild(node, '?');
                if (child) {
                        buf_pushchar(buf, '?');
                        index_searchwild__all(child, 0, buf, &key[i], out);
                        buf_popchar(buf);
                }
-               
+
                child = index_readchild(node, '[');
                if (child) {
                        buf_pushchar(buf, '[');
                        index_searchwild__all(child, 0, buf, &key[i], out);
                        buf_popchar(buf);
                }
-               
+
                if (key[i] == '\0') {
                        index_searchwild__allvalues(node, out);
 
                        return;
                }
-               
+
                child = index_readchild(node, key[i]);
                index_close(node);
                node = child;
@@ -763,10 +763,10 @@ static void index_searchwild__all(struct index_node_f *node, int j,
 {
        int pushed = 0;
        int ch;
-       
+
        while (node->prefix[j]) {
                ch = node->prefix[j];
-               
+
                buf_pushchar(buf, ch);
                pushed++;
                j++;
@@ -774,22 +774,22 @@ static void index_searchwild__all(struct index_node_f *node, int j,
 
        for (ch = node->first; ch <= node->last; ch++) {
                struct index_node_f *child = index_readchild(node, ch);
-               
+
                if (!child)
                        continue;
-                       
+
                buf_pushchar(buf, ch);
                index_searchwild__all(child, 0, buf, subkey, out);
                buf_popchar(buf);
        }
-       
+
        if (node->values) {
                if (fnmatch(buf_str(buf), subkey, 0) == 0)
                        index_searchwild__allvalues(node, out);
        } else {
                index_close(node);
        }
-       
+
        buf_popchars(buf, pushed);
 }
 
@@ -797,7 +797,7 @@ static void index_searchwild__allvalues(struct index_node_f *node,
                                        struct index_value **out)
 {
        struct index_value *v;
-       
+
        for (v = node->values; v != NULL; v = v->next)
                add_value(out, v->value, v->priority);