9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Stanley Lieber <sl@stanleylieber.com>
To: 9front@9front.org
Subject: Fwd: [9front-commits] ori: hg/plan9front: libc: tmparse should ignore leading whitespace
Date: Wed, 26 Aug 2020 14:47:01 -0400	[thread overview]
Message-ID: <701B474A-63D4-4287-9958-17FD38954E7A@stanleylieber.com> (raw)
In-Reply-To: <hg.63e1749d5b5b.1598462594.4892889753185008284@code.9front.org>

it's still broken.

error+  from 's1.qery.ru!info'                                 error+ to '1f300.com!info' alias `local!sl'                    error+ failed with error 'upas/fs: plan9: warning naked from [s1.qery.ru!info Wed Aug 26 14:34:53 EDT 2020 remote from ewsd   error+ ]                                                       error+ grep: can't open /mail/fs/mbox/1/from: '/mail/fs/mbox/1' does not exist                                                error+ grep: can't open /mail/fs/mbox/1/subject: '/mail/fs/mbox/1' does not exist                                             error+ grep: can't open /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+ '.                                                      error+



-------- Original Message --------
From: The Computer <commits@code.9front.org>
Sent: August 26, 2020 1:23:14 PM EDT
To: 9front-commits@9front.org
Subject: [9front-commits] ori: hg/plan9front: libc: tmparse should ignore leading whitespace

details:     http://code.9front.org/hg/plan9front/rev/63e1749d5b5b
changeset:   7942:63e1749d5b5b
user:        Ori Bernstein <ori@eigenstate.org>
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. This fixes upas mbox
parsing, which leaves a leading whitespace at the start of
the date.


diffstat:

 sys/man/2/tmdate         |   1 +
 sys/src/libc/port/date.c |  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.
 .PP
 Tmparse parses a time from a string according to the format argument.
+Leading whitespace is ignored.
 The point at which the parsing stopped is returned in
 .IR ep .
 If
diff --git a/sys/src/libc/port/date.c b/sys/src/libc/port/date.c
--- a/sys/src/libc/port/date.c
+++ b/sys/src/libc/port/date.c
@@ -632,6 +632,20 @@ tmparse(Tm *tm, char *fmt, char *str, Tz
 		sloppy = 1;
 		p++;
 	}
+
+	/* Skip whitespace */
+	for(;; p++) {
+		switch(*p) {
+		case ' ':
+		case '\t':
+		case '\n':
+		case '\f':
+		case '\r':
+		case '\v':
+			continue;
+		}
+		break;
+	}
 	while(*p){
 		w = 1;
 		c0 = *p++;
@@ -868,7 +882,6 @@ Zoneparsed:
 		case '_':
 		case ',':
 		case ' ':
-
 			if(*s != ' ' && *s != '\t' && *s != ',' && *s != '\n' && *s != '\0')
 				goto baddate;
 			p += strspn(p, " ,_\t\n");
@@ -884,6 +897,7 @@ Zoneparsed:
 		if(!ok)
 			goto baddate;
 	}
+
 	if(*p != '\0')
 		goto baddate;
 	if(ep != nil)


       reply	other threads:[~2020-08-26 18:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <hg.63e1749d5b5b.1598462594.4892889753185008284@code.9front.org>
2020-08-26 18:47 ` Stanley Lieber [this message]
2020-08-26 19:41   ` [9front] " ori
2020-08-26 22:19     ` Stanley Lieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=701B474A-63D4-4287-9958-17FD38954E7A@stanleylieber.com \
    --to=sl@stanleylieber.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).