masqmail
diff src/parse.c @ 273:00724782b6c9
parse.c: comments, better debugging, tiny refactoring
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Fri, 03 Dec 2010 19:25:43 -0300 |
parents | 899175e8dff0 |
children | 89199eda6144 |
line diff
1.1 --- a/src/parse.c Fri Dec 03 19:13:25 2010 -0300 1.2 +++ b/src/parse.c Fri Dec 03 19:25:43 2010 -0300 1.3 @@ -146,7 +146,7 @@ 1.4 *domain_begin = *domain_end = NULL; 1.5 1.6 /* might be some memory left from previous call: */ 1.7 - if (parse_error != NULL) { 1.8 + if (parse_error) { 1.9 g_free(parse_error); 1.10 parse_error = NULL; 1.11 } 1.12 @@ -250,6 +250,9 @@ 1.13 1.14 } else if (strchr(specials, *p) || iscntrl(*p) || isspace(*p)) { 1.15 parse_error = g_strdup_printf("unexpected character: %c", *p); 1.16 +#ifdef PARSE_TEST 1.17 + g_print("unexpected character: %c", *p); 1.18 +#endif 1.19 return FALSE; 1.20 } 1.21 } 1.22 @@ -382,6 +385,7 @@ 1.23 gchar *addr_end; 1.24 gboolean ret; 1.25 1.26 + /* TODO: what about (string == NULL)? */ 1.27 if (string && (string[0] == '\0')) { 1.28 address *addr = g_malloc(sizeof(address)); 1.29 addr->address = g_strdup(""); 1.30 @@ -423,7 +427,7 @@ 1.31 1.32 if (dom_beg != NULL) { 1.33 addr->domain = g_strndup(dom_beg, dom_end - dom_beg); 1.34 - } else if (addr->local_part[0] == 0) { 1.35 + } else if (addr->local_part[0] == '\0') { 1.36 /* 'NULL' address (failure notice), 1.37 "" makes sure it will not be qualified with a hostname */ 1.38 addr->domain = g_strdup(""); 1.39 @@ -431,7 +435,7 @@ 1.40 addr->domain = NULL; 1.41 } 1.42 1.43 - if (end != NULL) { 1.44 + if (end) { 1.45 *end = p; 1.46 } 1.47 1.48 @@ -461,18 +465,24 @@ 1.49 gchar *end; 1.50 1.51 while (*p) { 1.52 +#ifdef PARSE_TEST 1.53 + g_print("string: %s\n", p); 1.54 +#endif 1.55 + 1.56 address *addr = _create_address(p, &end, FALSE); 1.57 - fprintf(stderr, "string: %s\n", p); 1.58 - 1.59 if (!addr) { 1.60 break; 1.61 } 1.62 1.63 - fprintf(stderr, " addr: %s (%s<@>%s)\n", addr->address, addr->local_part, addr->domain); 1.64 +#ifdef PARSE_TEST 1.65 + g_print("addr: %s (%s<@>%s)", addr->address, addr->local_part, addr->domain); 1.66 +#endif 1.67 if (domain && !addr->domain) { 1.68 addr->domain = g_strdup(domain); 1.69 } 1.70 - fprintf(stderr, " %s (%s<@>%s)\n", addr->address, addr->local_part, addr->domain); 1.71 +#ifdef PARSE_TEST 1.72 + g_print(" (%s<@>%s)\n", addr->local_part, addr->domain); 1.73 +#endif 1.74 1.75 addr_list = g_list_append(addr_list, addr); 1.76 p = end;