From 5d73e4cf196abcfe2ef2a39ce2233ac080156cdb Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 26 Jan 2021 12:58:54 -0800 Subject: Convert all mutt_atoX functions to behave strictly. * Remove the automatic conversion of NULL and '\0' to 0. Add a flag for the cases that require lax evaluation. * Make trailing characters generate an error by default for the mutt_atouX functions. Add a flag for that case. Most of the IMAP code parses numbers out of a stream, so add the flag to those calls. * The mutt_atouX functions were also behaving incorrectly with invalid input, e.g. "ABC", returning and setting 0. Fix them to return an error in those cases. * Add a mutt_atoll() function, to be used in the next commit. * Change converters to store 0 on error. atos, atoi, and atoui were already doing this, but the others were not. --- mh.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mh.c') diff --git a/mh.c b/mh.c index 67e63824..1cea86ea 100644 --- a/mh.c +++ b/mh.c @@ -154,12 +154,12 @@ static int mh_read_token (char *t, int *first, int *last) if ((p = strchr (t, '-'))) { *p++ = '\0'; - if (mutt_atoi (t, first) < 0 || mutt_atoi (p, last) < 0) + if (mutt_atoi (t, first, 0) < 0 || mutt_atoi (p, last, 0) < 0) return -1; } else { - if (mutt_atoi (t, first) < 0) + if (mutt_atoi (t, first, 0) < 0) return -1; *last = *first; } @@ -512,7 +512,7 @@ static void mh_update_sequences (CONTEXT * ctx) else p = ctx->hdrs[l]->path; - if (mutt_atoi (p, &i) < 0) + if (mutt_atoi (p, &i, 0) < 0) continue; if (!ctx->hdrs[l]->read) @@ -644,7 +644,7 @@ static void mh_update_maildir (struct maildir *md, struct mh_sequences *mhs) else p = md->h->path; - if (mutt_atoi (p, &i) < 0) + if (mutt_atoi (p, &i, 0) < 0) continue; f = mhs_check (mhs, i); -- cgit v1.2.3