Archived
1
0
Fork 0

Change indentation to follow the updated standard.

Alot of mixed indentation. use 4 chars wide soft tabs.
This commit is contained in:
Henrik Hautakoski 2011-03-19 12:28:48 +02:00
parent 9cc5420447
commit f46ae1970b
51 changed files with 634 additions and 639 deletions

View file

@ -3,8 +3,8 @@
# Helper for touching a number of files in a directory.
if [ $# -lt 1 ]; then
echo "usage: $0 <dir> [ <nfiles> ]"
exit 1
echo "usage: $0 <dir> [ <nfiles> ]"
exit 1
fi
if [ ! -d $1 ]; then
@ -23,5 +23,5 @@ if [ $# -gt 1 ]; then
fi
for i in `seq 0 ${NFILES}`; do
touch "${1}/file${i}"
touch "${1}/file${i}"
done

View file

@ -4,43 +4,43 @@
#include "../src/fscrawl.h"
int main(int argc, char *argv[]) {
fscrawl_t crawl;
unsigned int c_ent = 0, verbose = 0;
fscrawl_t crawl;
unsigned int c_ent = 0, verbose = 0;
time_t t1, t2, tdiff;
if (argc < 2)
return 1;
if (argc < 2)
return 1;
if (argc > 2 && (argv[2][0] == '1' && argv[2][1] == '\0'))
verbose = 1;
crawl = fsc_open(argv[1]);
if (crawl == NULL) {
printf("Invalid path\n");
return 1;
}
crawl = fsc_open(argv[1]);
if (crawl == NULL) {
printf("Invalid path\n");
return 1;
}
t1 = time(NULL);
for(;;) {
fs_entry *ent = fsc_read(crawl);
for(;;) {
fs_entry *ent = fsc_read(crawl);
if (!ent)
break;
break;
if (verbose)
printf("%s%s%c\n", ent->base, ent->name,
ent->dir ? '/' : '\0');
c_ent++;
}
c_ent++;
}
t2 = time(NULL);
fsc_close(crawl);
tdiff = t2 - t1;
printf("Nodes: %u\n"
printf("Nodes: %u\n"
"Time (sec): %ld\n", c_ent, tdiff);
printf("Node/sec: ");
@ -50,5 +50,5 @@ int main(int argc, char *argv[]) {
puts("INF");
}
return 0;
return 0;
}

View file

@ -40,7 +40,7 @@ static void validate_list(int index, struct list *list) {
if (i != wdref[index])
continue;
assert(list_has(list, pathref[index], cmp));
}
}
@ -78,7 +78,7 @@ void test_inotify_unmap_path() {
void test_inotify_unmap_all() {
setup();
inotify_unmap_all();
assert(inotify_map_isempty());
@ -90,7 +90,7 @@ void test_inotify_map_get_wd() {
int i;
setup();
for(i=0; i < 4; i++)
assert(inotify_map_get_wd(pathref[i]) == wdref[i]);
@ -107,7 +107,7 @@ void test_inotify_map_get_path() {
validate_list(i, inotify_map_get_path(wdref[i]));
assert(inotify_map_get_path(25) == NULL);
teardown();
}
@ -118,6 +118,6 @@ int main() {
test_inotify_unmap_all();
test_inotify_map_get_wd();
test_inotify_map_get_path();
return 0;
}

View file

@ -42,7 +42,7 @@ int main() {
printf("---\n");
tree_traverse((struct tree*)root, print_node, NULL);
inotify_watch_destroy(root, NULL);
return 0;

View file

@ -89,7 +89,7 @@ void test_size() {
list_insert(l, NULL);
list_insert(l, NULL);
assert(list_size(l) == 2);
list_destroy(l);
}

View file

@ -19,7 +19,7 @@ int main() {
logerrno(LOG_CRIT, "malloc", ENOMEM);
logerrno(LOG_CRIT, NULL, ENOENT);
logmsg(LOG_DEBUG, "Should not show");
logmsg(LOG_INFO | LOG_CRIT, "Should not work, can only log to one priority");

View file

@ -3,34 +3,35 @@
#include "../src/notify.h"
int main(int argc, char *argv[]) {
notify_event *event;
if (argc < 2)
return 1;
notify_event *event;
notify_init();
if (!notify_add_watch(argv[1]))
return 1;
printf("begin watching on: %s\n", argv[1]);
for (;;) {
event = notify_read();
if (event == NULL)
continue;
printf("====================\n"
"Type: %s\n"
"Path: %s\n"
"Filename: %s\n"
"Directory: %u\n"
"====================\n"
, notify_event_typetostr(event), event->path, event->filename, event->dir);
}
return 0;
if (argc < 2)
return 1;
notify_init();
if (!notify_add_watch(argv[1]))
return 1;
printf("begin watching on: %s\n", argv[1]);
for (;;) {
event = notify_read();
if (event == NULL)
continue;
printf("====================\n"
"Type: %s\n"
"Path: %s\n"
"Filename: %s\n"
"Directory: %u\n"
"====================\n"
, notify_event_typetostr(event), event->path,
event->filename, event->dir);
}
return 0;
}

View file

@ -43,7 +43,7 @@ void test_dequeue() {
for(i=0; i < 512; i++)
assert(queue_dequeue(q) == &map[i]);
tierdown();
}
@ -57,7 +57,7 @@ void test_isempty() {
assert(queue_isempty(q));
assert(queue_isempty(NULL));
tierdown();
}
@ -94,6 +94,6 @@ int main() {
if (q)
queue_destroy(q);
return 0;
return 0;
}

View file

@ -31,7 +31,7 @@ static void vdelete(void *ptr) {
break;
}
}
assert(exists);
}
@ -68,7 +68,7 @@ static void setup(int sorted) {
if (sorted)
qsort(keyref, NODES, sizeof(keyref[0]), vcmp);
for(i=0; i < NODES; i++)
rbtree_insert(&tree, &keyref[i]);
}
@ -106,7 +106,7 @@ void test_rbtree_delete() {
if (keyref_exists(NODES/2, i-1, keyref[i]))
continue;
assert(rbtree_delete(&tree, &keyref[i]));
}
@ -127,7 +127,7 @@ void test_rbtree_delete_all() {
if (keyref_exists(0, i-1, keyref[i]))
continue;
assert(rbtree_delete(&tree, &keyref[i]));
}

View file

@ -15,10 +15,10 @@ void test_insert() {
str_list_insert(l, "c");
str_list_insert(l, "b");
str_list_insert(l, "d");
for(i=0; i < 4; i++)
assert(strcmp(l->items[i], ref[i]) == 0);
str_list_clear_fn(l, NULL);
str_list_destroy(l);
}
@ -27,36 +27,36 @@ void test_remove() {
char *ref[2] = { "a", "c" };
struct str_list *l = str_list_create();
str_list_insert(l, "a");
str_list_insert(l, "c");
str_list_insert(l, "b");
str_list_insert(l, "d");
str_list_remove(l, "d");
str_list_remove(l, "b");
assert(str_list_size(l) == 2);
assert(strcmp(l->items[0], ref[0]) == 0);
assert(strcmp(l->items[1], ref[1]) == 0);
str_list_remove(l, "c");
str_list_remove(l, "a");
assert(str_list_size(l) == 0);
str_list_destroy(l);
}
void test_isempty() {
struct str_list *l = NULL;
assert(str_list_isempty(l));
l = str_list_create();
assert(str_list_isempty(l));
str_list_insert(l, "string");
assert(str_list_isempty(l) == 0);
str_list_clear_fn(l, NULL);
str_list_destroy(l);
}
@ -64,14 +64,14 @@ void test_isempty() {
void test_size() {
struct str_list *l = NULL;
assert(str_list_size(l) == 0);
l = str_list_create();
assert(str_list_size(l) == 0);
str_list_insert(l, "a");
str_list_insert(l, "b");
assert(str_list_size(l) == 2);
str_list_clear_fn(l, NULL);
str_list_destroy(l);
}
@ -105,7 +105,7 @@ void test_foreach() {
str_list_foreach(item, l) {
assert_string(ref[i], *item);
i++;
i++;
}
str_list_clear_fn(l, NULL);
@ -115,12 +115,12 @@ void test_foreach() {
void test_has() {
struct str_list *l = str_list_create();
str_list_insert(l, "something");
str_list_insert(l, "somethingelse");
assert(str_list_has(l, l->items[1]));
assert(str_list_has(l, "don't exists") == 0);
str_list_clear_fn(l, NULL);
str_list_destroy(l);
}
@ -132,10 +132,10 @@ void test_lookup() {
str_list_insert(l, "something");
str_list_insert(l, "find me");
str_list_insert(l, "random");
assert(strcmp(str_list_lookup(l, "find me"), "find me") == 0);
assert(str_list_lookup(l, "don't exists") == NULL);
str_list_clear_fn(l, NULL);
str_list_destroy(l);
}
@ -160,7 +160,7 @@ void test_export() {
assert(i == 3);
free(export);
str_list_clear_fn(l, NULL);
str_list_destroy(l);
}

View file

@ -20,7 +20,7 @@ void test_setlen() {
strbuf_setlen(&b, 25);
assert(b.len == 0);
strbuf_expand(&b, 25);
strbuf_setlen(&b, b.alloc_size);
assert(b.len == b.alloc_size-1);
@ -60,10 +60,10 @@ void test_release() {
print_strbuf(&b);
str = strbuf_release(&b);
printf("released |%s|\n", str);
free(str);
printf("released |%s|\n", str);
free(str);
}
void test_release_empty() {
@ -107,7 +107,7 @@ void test_chop() {
print_strbuf(&b);
strbuf_append_str(&b, "X");
strbuf_rchop(&b, 'X');
print_strbuf(&b);
@ -118,7 +118,7 @@ void test_chop() {
strbuf_rchop(&b, 'X');
print_strbuf(&b);
strbuf_free(&b);
}
@ -138,16 +138,16 @@ void test_term() {
void test_trim() {
strbuf_t b = STRBUF_INIT;
print_strbuf(&b);
strbuf_append_repeat(&b, ' ', 4);
strbuf_append(&b, "abcdef", 6);
print_strbuf(&b);
print_strbuf(&b);
strbuf_append(&b, "012345678901234567890123456789", 30);
strbuf_append_ch(&b, 'a');
strbuf_append_ch(&b, 'a');
strbuf_append_repeat(&b, ' ', 6);
print_strbuf(&b);
@ -155,10 +155,10 @@ void test_trim() {
strbuf_rtrim(&b);
print_strbuf(&b);
strbuf_ltrim(&b);
print_strbuf(&b);
strbuf_ltrim(&b);
print_strbuf(&b);
strbuf_free(&b);
}
@ -171,9 +171,9 @@ void test_rev() {
print_strbuf(&b);
strbuf_rev(&b);
print_strbuf(&b);
strbuf_rev(&b);
print_strbuf(&b);
strbuf_free(&b);
}
@ -239,6 +239,6 @@ int main() {
test_chop();
test_explode();
test_free_empty();
return 0;
}

View file

@ -52,7 +52,7 @@ void test_unlink() {
assert(nodes[0].parent == NULL);
assert(nodes[0].next == NULL);
assert(nodes[0].child == &nodes[1]);
/* move to depth 2 */
assert(nodes[1].parent == &nodes[0]);
assert(nodes[2].parent == &nodes[0]);
@ -71,14 +71,14 @@ void test_unlink() {
assert(nodes[3].child == NULL);
assert(nodes[4].child == NULL);
assert(nodes[5].child == NULL);
tree_unlink(&nodes[1]);
/* check the new tree */
assert(nodes[0].parent == NULL);
assert(nodes[0].next == NULL);
assert(nodes[0].child == &nodes[2]);
/* move to depth 2 */
assert(nodes[2].parent == &nodes[0]);
assert(nodes[3].parent == &nodes[0]);
@ -89,7 +89,7 @@ void test_unlink() {
assert(nodes[2].child == &nodes[5]);
assert(nodes[3].child == NULL);
assert(nodes[4].child == NULL);
/* move to depth 3 */
assert(nodes[5].parent == &nodes[2]);
assert(nodes[5].next == NULL);
@ -111,7 +111,7 @@ void test_detach() {
assert(nodes[0].parent == NULL);
assert(nodes[0].next == NULL);
assert(nodes[0].child == &nodes[1]);
/* move to depth 2 */
assert(nodes[1].parent == &nodes[0]);
assert(nodes[2].parent == &nodes[0]);
@ -137,7 +137,7 @@ void test_detach() {
assert(nodes[0].parent == NULL);
assert(nodes[0].next == NULL);
assert(nodes[0].child == &nodes[2]);
/* move to depth 2 */
assert(nodes[2].parent == &nodes[0]);
assert(nodes[2].next == NULL);

View file

@ -15,22 +15,21 @@ static inline char ranchr() {
}
void __assert_str(const char *file, int line, const char *func, const char *a, const char *b) {
if (a == NULL || b == NULL)
__uexit(file, line, func, "a or b is null\n", NULL);
if (strcmp(a, b) != 0)
__uexit(file, line, func, "\"%s\" != \"%s\"\n", a, b);
}
void utest_init_RNG() {
static unsigned char init = 0;
if (init)
return;
srand(time(NULL));
init = 1;
}
@ -52,7 +51,7 @@ char* utest_ran_string(size_t size) {
return NULL;
utest_init_RNG();
for(i=0; i < size; i++)
str[i] = ranchr();
str[i] = 0;