X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/44c01adf506b1087bff724dcb65b92a12b012836..20f65ac3b82b354496b5bb469ff184ba8b0bcd96:/lib.c diff --git a/lib.c b/lib.c index c1f124e..17cc516 100644 --- a/lib.c +++ b/lib.c @@ -758,7 +758,8 @@ char *mutt_read_line (char *s, size_t *size, FILE *fp, int *line, int flags) } if ((ch = strchr (s + offset, '\n')) != NULL) { - (*line)++; + if (line) + (*line)++; if (flags & M_EOL) return s; *ch = 0; @@ -779,7 +780,8 @@ char *mutt_read_line (char *s, size_t *size, FILE *fp, int *line, int flags) if (c == EOF) { /* The last line of fp isn't \n terminated */ - (*line)++; + if (line) + (*line)++; return s; } else @@ -1007,6 +1009,24 @@ mutt_strsysexit(int e) return sysexits_h[i].str; } +void mutt_debug (FILE *fp, const char *fmt, ...) +{ + va_list ap; + time_t now = time (NULL); + static char buf[23] = ""; + static time_t last = 0; + + if (now > last) + { + strftime (buf, sizeof (buf), "%Y-%m-%d %H:%M:%S", localtime (&now)); + last = now; + } + fprintf (fp, "[%s] ", buf); + va_start (ap, fmt); + vfprintf (fp, fmt, ap); + va_end (ap); +} + int mutt_atos (const char *str, short *dst) { int rc; @@ -1057,7 +1077,8 @@ int mutt_atol (const char *str, long *dst) } *res = strtol (str, &e, 10); - if (e && *e != '\0') + if ((*res == LONG_MAX && errno == ERANGE) || + (e && *e != '\0')) return -1; return 0; }