Browse Source

indent array for readability (merged [288])

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@508 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.2
Jan Kneschke 16 years ago
parent
commit
9e75ba0096
  1. 14
      src/array.c
  2. 5
      src/array.h
  3. 12
      src/data_array.c
  4. 10
      src/data_config.c
  5. 3
      src/data_count.c
  6. 3
      src/data_fastcgi.c
  7. 5
      src/data_integer.c
  8. 5
      src/data_string.c

14
src/array.c

@ -178,12 +178,20 @@ int array_insert_unique(array *a, data_unset *str) {
return 0;
}
int array_print(array *a) {
void array_print_indent(int depth) {
int i;
for (i = 0; i < depth; i ++) {
fprintf(stderr, " ");
}
}
int array_print(array *a, int depth) {
size_t i;
for (i = 0; i < a->used; i++) {
array_print_indent(depth);
fprintf(stderr, "%d: ", i);
a->data[i]->print(a->data[i]);
a->data[i]->print(a->data[i], depth + 1);
fprintf(stderr, "\n");
}
@ -229,7 +237,7 @@ int main (int argc, char **argv) {
array_insert_unique(a, (data_unset *)dc);
array_print(a);
array_print(a, 0);
array_free(a);

5
src/array.h

@ -17,7 +17,7 @@ typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_COUNT, TYPE_ARRAY, TYPE_INTEGER, TY
void (* free)(struct data_unset *p); \
void (* reset)(struct data_unset *p); \
int (*insert_dup)(struct data_unset *dst, struct data_unset *src); \
void (*print)(struct data_unset *p)
void (*print)(struct data_unset *p, int depth)
typedef struct data_unset {
DATA_UNSET;
@ -115,9 +115,10 @@ array *array_init(void);
void array_free(array *a);
void array_reset(array *a);
int array_insert_unique(array *a, data_unset *str);
int array_print(array *a);
int array_print(array *a, int depth);
data_unset *array_get_unused_element(array *a, data_type_t t);
data_unset *array_get_element(array *a, const char *key);
int array_strcasecmp(const char *a, size_t a_len, const char *b, size_t b_len);
void array_print_indent(int depth);
#endif

12
src/data_array.c

@ -29,12 +29,14 @@ static int data_array_insert_dup(data_unset *dst, data_unset *src) {
return 0;
}
static void data_array_print(data_unset *d) {
static void data_array_print(data_unset *d, int depth) {
data_array *ds = (data_array *)d;
printf("{%s:\n", ds->key->ptr);
array_print(ds->value);
printf("}");
array_print_indent(depth);
fprintf(stderr, "{%s:\n", ds->key->ptr);
array_print(ds->value, depth + 1);
array_print_indent(depth);
fprintf(stderr, "}");
}

10
src/data_config.c

@ -41,12 +41,14 @@ static int data_config_insert_dup(data_unset *dst, data_unset *src) {
return 0;
}
static void data_config_print(data_unset *d) {
static void data_config_print(data_unset *d, int depth) {
data_config *ds = (data_config *)d;
printf("{%s:\n", ds->key->ptr);
array_print(ds->value);
printf("}");
array_print_indent(depth);
fprintf(stderr, "{%s:\n", ds->key->ptr);
array_print(ds->value, depth + 1);
array_print_indent(depth);
fprintf(stderr, "}");
}

3
src/data_count.c

@ -31,9 +31,10 @@ static int data_count_insert_dup(data_unset *dst, data_unset *src) {
return 0;
}
static void data_count_print(data_unset *d) {
static void data_count_print(data_unset *d, int depth) {
data_count *ds = (data_count *)d;
array_print_indent(depth);
printf("{%s: %d}", ds->key->ptr, ds->count);
}

3
src/data_fastcgi.c

@ -30,9 +30,10 @@ static int data_fastcgi_insert_dup(data_unset *dst, data_unset *src) {
return 0;
}
static void data_fastcgi_print(data_unset *d) {
static void data_fastcgi_print(data_unset *d, int depth) {
data_fastcgi *ds = (data_fastcgi *)d;
array_print_indent(depth);
printf("{%s: %s}", ds->key->ptr, ds->host->ptr);
}

5
src/data_integer.c

@ -28,9 +28,10 @@ static int data_integer_insert_dup(data_unset *dst, data_unset *src) {
return 0;
}
static void data_integer_print(data_unset *d) {
static void data_integer_print(data_unset *d, int depth) {
data_integer *ds = (data_integer *)d;
array_print_indent(depth);
printf("{%s: %d}", ds->key->ptr, ds->value);
}

5
src/data_string.c

@ -57,9 +57,10 @@ static int data_response_insert_dup(data_unset *dst, data_unset *src) {
}
static void data_string_print(data_unset *d) {
static void data_string_print(data_unset *d, int depth) {
data_string *ds = (data_string *)d;
array_print_indent(depth);
fprintf(stderr, "{%s: %s}", ds->key->ptr, ds->value->used ? ds->value->ptr : "");
}

Loading…
Cancel
Save