From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 104.59.85.219 ([104.59.85.219]) by ewsd; Wed Aug 26 14:59:30 EDT 2020 Date: Wed, 26 Aug 2020 14:47:01 -0400 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Fwd: [9front-commits] ori: hg/plan9front: libc: tmparse should ignore leading whitespace To: 9front@9front.org From: Stanley Lieber Message-ID: <701B474A-63D4-4287-9958-17FD38954E7A@stanleylieber.com> List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: object-oriented shared YAML extension standard-scale database it's still broken=2E error+ from 's1=2Eqery=2Eru!info' error+ = to '1f300=2Ecom!info' alias `local!sl' error+ failed wit= h error 'upas/fs: plan9: warning naked from [s1=2Eqery=2Eru!info Wed Aug 26= 14:34:53 EDT 2020 remote from ewsd error+ ] = error+ grep: can't open /mail/fs/mbox/1/from: '/m= ail/fs/mbox/1' does not exist = error+ grep: can't open /mail/fs/mbox/1/subject: '/mail/fs/mbox/1' does n= ot exist error+ grep: can't ope= n /mail/fs/mbox/1/replyto: '/mail/fs/mbox/1' does not exist = error+ /mail/fs/mbox/1/raw: rc (pipeto): can't= open: '/mail/fs/mbox/1' does not exist = error+ '=2E error= + -------- Original Message -------- From: The Computer Sent: August 26, 2020 1:23:14 PM EDT To: 9front-commits@9front=2Eorg Subject: [9front-commits] ori: hg/plan9front: libc: tmparse should ignore = leading whitespace details: http://code=2E9front=2Eorg/hg/plan9front/rev/63e1749d5b5b changeset: 7942:63e1749d5b5b user: Ori Bernstein date: Wed Aug 26 10:23:00 2020 -0700 description: libc: tmparse should ignore leading whitespace We almost always want to skip leading whitespace in time formats, so make tmparse just do it=2E This fixes upas mbox parsing, which leaves a leading whitespace at the start of the date=2E diffstat: sys/man/2/tmdate | 1 + sys/src/libc/port/date=2Ec | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletions(-) diffs (51 lines): diff --git a/sys/man/2/tmdate b/sys/man/2/tmdate --- a/sys/man/2/tmdate +++ b/sys/man/2/tmdate @@ -65,6 +65,7 @@ Tmstime is identical to tmtime, but acce onds=2E =2EPP Tmparse parses a time from a string according to the format argument=2E +Leading whitespace is ignored=2E The point at which the parsing stopped is returned in =2EIR ep =2E If diff --git a/sys/src/libc/port/date=2Ec b/sys/src/libc/port/date=2Ec --- a/sys/src/libc/port/date=2Ec +++ b/sys/src/libc/port/date=2Ec @@ -632,6 +632,20 @@ tmparse(Tm *tm, char *fmt, char *str, Tz sloppy =3D 1; p++; } + + /* Skip whitespace */ + for(;; p++) { + switch(*p) { + case ' ': + case '\t': + case '\n': + case '\f': + case '\r': + case '\v': + continue; + } + break; + } while(*p){ w =3D 1; c0 =3D *p++; @@ -868,7 +882,6 @@ Zoneparsed: case '_': case ',': case ' ': - if(*s !=3D ' ' && *s !=3D '\t' && *s !=3D ',' && *s !=3D '\n' && *s != =3D '\0') goto baddate; p +=3D strspn(p, " ,_\t\n"); @@ -884,6 +897,7 @@ Zoneparsed: if(!ok) goto baddate; } + if(*p !=3D '\0') goto baddate; if(ep !=3D nil)