X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fdebug.c;h=9e042f53f7d3b3e578146a9a492c78bac4d4c205;hb=9242a7e8cfa94bbc9dd7eca6bd651b569b871c4e;hp=ee284d0be7540d23953bdde94116dc04c3c5a803;hpb=398f9af3b35c79d142dcbfd7b56758eea88c8f43;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/debug.c b/src/src/debug.c index ee284d0be..9e042f53f 100644 --- a/src/src/debug.c +++ b/src/src/debug.c @@ -2,7 +2,7 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2015 */ +/* Copyright (c) University of Cambridge 1995 - 2017 */ /* See the file NOTICE for conditions of use and distribution. */ @@ -40,11 +40,11 @@ static void tree_printsub(tree_node *p, int pos, int barswitch) { int i; -if (p->right != NULL) tree_printsub(p->right, pos+2, 1); +if (p->right) tree_printsub(p->right, pos+2, 1); for (i = 0; i <= pos-1; i++) debug_printf("%c", tree_printline[i]); debug_printf("-->%s [%d]\n", p->name, p->balance); tree_printline[pos] = barswitch? '|' : ' '; -if (p->left != NULL) +if (p->left) { tree_printline[pos+2] = '|'; tree_printsub(p->left, pos+2, 0); @@ -58,7 +58,7 @@ debug_print_tree(tree_node *p) { int i; for (i = 0; i < tree_printlinesize; i++) tree_printline[i] = ' '; -if (p == NULL) debug_printf("Empty Tree\n"); else tree_printsub(p, 0, 0); +if (!p) debug_printf("Empty Tree\n"); else tree_printsub(p, 0, 0); debug_printf("---- End of tree ----\n"); } @@ -78,7 +78,7 @@ void debug_print_argv(const uschar ** argv) { debug_printf("exec"); -while (*argv != NULL) debug_printf(" %.256s", *argv++); +while (*argv) debug_printf(" %.256s", *argv++); debug_printf("\n"); } @@ -98,11 +98,11 @@ Returns: nothing void debug_print_string(uschar *debug_string) { -if (debug_string == NULL) return; +if (!debug_string) return; HDEBUG(D_any|D_v) { uschar *s = expand_string(debug_string); - if (s == NULL) + if (!s) debug_printf("failed to expand debug_output \"%s\": %s\n", debug_string, expand_string_message); else if (s[0] != 0) @@ -182,18 +182,20 @@ if (debug_ptr == debug_buffer) { DEBUG(D_timestamp) { - time_t now = time(NULL); - struct tm *t = timestamps_utc? gmtime(&now) : localtime(&now); - (void) sprintf(CS debug_ptr, "%02d:%02d:%02d ", t->tm_hour, t->tm_min, - t->tm_sec); - while(*debug_ptr != 0) debug_ptr++; + struct timeval now; + time_t tmp; + struct tm * t; + + gettimeofday(&now, NULL); + tmp = now.tv_sec; + t = timestamps_utc ? gmtime(&tmp) : localtime(&tmp); + debug_ptr += sprintf(CS debug_ptr, + LOGGING(millisec) ? "%02d:%02d:%02d.%03d " : "%02d:%02d:%02d ", + t->tm_hour, t->tm_min, t->tm_sec, (int)(now.tv_usec/1000)); } DEBUG(D_pid) - { - sprintf(CS debug_ptr, "%5d ", (int)getpid()); - while(*debug_ptr != 0) debug_ptr++; - } + debug_ptr += sprintf(CS debug_ptr, "%5d ", (int)getpid()); /* Set up prefix if outputting for host checking and not debugging */ @@ -211,11 +213,13 @@ if (indent > 0) int i; for (i = indent >> 2; i > 0; i--) { - Ustrcpy(debug_ptr, " ."); - debug_ptr += 4; + Ustrcpy(debug_ptr, " " UTF8_VERT_2DASH); + debug_ptr += 6; /* 3 spaces + 3 UTF-8 octets */ + debug_prefix_length += 6; } - Ustrncpy(debug_ptr, " ", indent & 3); - debug_ptr += indent & 3; + Ustrncpy(debug_ptr, " ", indent &= 3); + debug_ptr += indent; + debug_prefix_length += indent; } /* Use the checked formatting routine to ensure that the buffer