* Fwd: parse-time-string error with non ASCII timestamp
[not found] <1175499420.269736.200740@b75g2000hsg.googlegroups.com>
@ 2007-04-17 10:10 ` Levin Du
2007-04-17 11:20 ` Kenichi Handa
0 siblings, 1 reply; 8+ messages in thread
From: Levin Du @ 2007-04-17 10:10 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 3240 bytes --]
Hi list,
I'was dicovering this when inserting timestamp in org-mode.
My timestamp includes Chinese number, when the following executes:
(parse-time-string "<2007-04-02 一>") ; the 12nd char is the
Chinese number.
An error will occur:
Debugger entered--Lisp error: (args-out-of-range [nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil 1 nil -1 nil nil 48 48 48 48 48 48 48 48 48 48 100 nil
nil nil nil nil nil 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65
65 65 65 65 65 65 65 65 65 nil nil nil nil nil nil 97 97 97 97 97 97
97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil] 19968)
aref([nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil 1 nil -1 nil nil 48
48 ...] 19968)
parse-time-string-chars(19968)
(setq c (parse-time-string-chars (aref string index)))
(not (setq c (parse-time-string-chars ...)))
(and (< index end) (not (setq c ...)))
(while (and (< index end) (not ...)) (incf index))
(while (< index end) (while (and ... ...) (incf index)) (setq start
index all-digits (eq c 48)) (while (and ... ...) (setq all-
digits ...)) (if (<= index end) (push ... list)))
(let ((start nil) (end ...) (all-digits nil) (list nil) (index 0) (c
nil)) (while (< index end) (while ... ...) (setq start index all-
digits ...) (while ... ...) (if ... ...)) (nreverse list))
parse-time-tokenize("<2007-04-02 \x4e00>")
(let ((time ...) (temp ...)) (while temp (let ... ...)) time)
parse-time-string("<2007-04-02 \x4e00>")
eval((parse-time-string "<2007-04-02 \x4e00>"))
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp)
This is a patch I wrote to solve this problem:
*** /home/zslevin/Cook/emacs/lisp/calendar/parse-time.el.orig
2007-04-02 10:01:27.000000000 +0800
--- /home/zslevin/Cook/emacs/lisp/calendar/parse-time.el 2007-04-02
15:35:07.000000000 +0800
***************
*** 66,72 ****
(aref parse-time-digits char))
(defsubst parse-time-string-chars (char)
! (aref parse-time-syntax char))
(put 'parse-error 'error-conditions '(parse-error error))
(put 'parse-error 'error-message "Parsing error")
--- 66,73 ----
(aref parse-time-digits char))
(defsubst parse-time-string-chars (char)
! (and (< char (length parse-time-syntax))
! (aref parse-time-syntax char)))
(put 'parse-error 'error-conditions '(parse-error error))
(put 'parse-error 'error-message "Parsing error")
Hope this is useful and can be merged into emacs.
Thanks!
Levin
[-- Attachment #1.2: Type: text/html, Size: 4078 bytes --]
[-- Attachment #2: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: parse-time-string error with non ASCII timestamp
2007-04-17 10:10 ` Fwd: parse-time-string error with non ASCII timestamp Levin Du
@ 2007-04-17 11:20 ` Kenichi Handa
2007-04-17 11:33 ` Andreas Schwab
2007-04-18 2:02 ` Richard Stallman
0 siblings, 2 replies; 8+ messages in thread
From: Kenichi Handa @ 2007-04-17 11:20 UTC (permalink / raw)
To: Levin Du; +Cc: emacs-devel
In article <9649271a0704170310s5c92163bv15f8d6e8eaef37db@mail.gmail.com>, "Levin Du" <zslevin@gmail.com> writes:
[...]
> My timestamp includes Chinese number, when the following executes:
> (parse-time-string "<2007-04-02 一>") ; the 12nd char is the
> Chinese number.
> An error will occur:
> Debugger entered--Lisp error: (args-out-of-range [nil nil nil nil nil
> nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
[...]
> This is a patch I wrote to solve this problem:
> *** /home/zslevin/Cook/emacs/lisp/calendar/parse-time.el.orig
> 2007-04-02 10:01:27.000000000 +0800
> --- /home/zslevin/Cook/emacs/lisp/calendar/parse-time.el 2007-04-02
> 15:35:07.000000000 +0800
> ***************
> *** 66,72 ****
> (aref parse-time-digits char))
> (defsubst parse-time-string-chars (char)
> ! (aref parse-time-syntax char))
> (put 'parse-error 'error-conditions '(parse-error error))
> (put 'parse-error 'error-message "Parsing error")
> --- 66,73 ----
> (aref parse-time-digits char))
> (defsubst parse-time-string-chars (char)
> ! (and (< char (length parse-time-syntax))
> ! (aref parse-time-syntax char)))
It seems that this is the right fix at the moment because
parse-time.el doesn't pay attention to non-ASCII characters
at all. In the future, we may have to improve it for
non-ASCII characters if necesary.
Shall I install that change?
---
Kenichi Handa
handa@m17n.org
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: parse-time-string error with non ASCII timestamp
2007-04-17 11:20 ` Kenichi Handa
@ 2007-04-17 11:33 ` Andreas Schwab
2007-04-17 11:50 ` Kenichi Handa
2007-04-18 2:02 ` Richard Stallman
1 sibling, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2007-04-17 11:33 UTC (permalink / raw)
To: Kenichi Handa; +Cc: Levin Du, emacs-devel
Kenichi Handa <handa@m17n.org> writes:
> In article <9649271a0704170310s5c92163bv15f8d6e8eaef37db@mail.gmail.com>, "Levin Du" <zslevin@gmail.com> writes:
> [...]
>> My timestamp includes Chinese number, when the following executes:
>
>> (parse-time-string "<2007-04-02 一>") ; the 12nd char is the
>> Chinese number.
>
>> An error will occur:
>
>> Debugger entered--Lisp error: (args-out-of-range [nil nil nil nil nil
>> nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
> [...]
>> This is a patch I wrote to solve this problem:
>> *** /home/zslevin/Cook/emacs/lisp/calendar/parse-time.el.orig
>> 2007-04-02 10:01:27.000000000 +0800
>> --- /home/zslevin/Cook/emacs/lisp/calendar/parse-time.el 2007-04-02
>> 15:35:07.000000000 +0800
>> ***************
>> *** 66,72 ****
>> (aref parse-time-digits char))
>
>> (defsubst parse-time-string-chars (char)
>> ! (aref parse-time-syntax char))
>
>> (put 'parse-error 'error-conditions '(parse-error error))
>> (put 'parse-error 'error-message "Parsing error")
>> --- 66,73 ----
>> (aref parse-time-digits char))
>
>> (defsubst parse-time-string-chars (char)
>> ! (and (< char (length parse-time-syntax))
>> ! (aref parse-time-syntax char)))
>
> It seems that this is the right fix at the moment because
> parse-time.el doesn't pay attention to non-ASCII characters
> at all. In the future, we may have to improve it for
> non-ASCII characters if necesary.
I'd guess all that needs to be done is to make parse-time-digits and
parse-time-syntax char tables.
> Shall I install that change?
digit-char-p has the same problem.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: parse-time-string error with non ASCII timestamp
2007-04-17 11:33 ` Andreas Schwab
@ 2007-04-17 11:50 ` Kenichi Handa
2007-04-17 14:32 ` Andreas Schwab
0 siblings, 1 reply; 8+ messages in thread
From: Kenichi Handa @ 2007-04-17 11:50 UTC (permalink / raw)
To: Andreas Schwab; +Cc: zslevin, emacs-devel
In article <jek5wbxmkc.fsf@sykes.suse.de>, Andreas Schwab <schwab@suse.de> writes:
[...]
>>> (defsubst parse-time-string-chars (char)
>>> ! (and (< char (length parse-time-syntax))
>>> ! (aref parse-time-syntax char)))
> >
> > It seems that this is the right fix at the moment because
> > parse-time.el doesn't pay attention to non-ASCII characters
> > at all. In the future, we may have to improve it for
> > non-ASCII characters if necesary.
> I'd guess all that needs to be done is to make parse-time-digits and
> parse-time-syntax char tables.
Just making them char-tables has the same effect as above.
If we want to handle a multibyte time-string well, we must
set proper values to those char-tables which, I think, is
beyond what we should do at the moment.
> > Shall I install that change?
> digit-char-p has the same problem.
But, it seems that it is never called with a multibyte
character.
---
Kenichi Handa
handa@m17n.org
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: parse-time-string error with non ASCII timestamp
2007-04-17 11:50 ` Kenichi Handa
@ 2007-04-17 14:32 ` Andreas Schwab
2007-04-17 23:07 ` Kenichi Handa
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2007-04-17 14:32 UTC (permalink / raw)
To: Kenichi Handa; +Cc: zslevin, emacs-devel
Kenichi Handa <handa@m17n.org> writes:
> In article <jek5wbxmkc.fsf@sykes.suse.de>, Andreas Schwab <schwab@suse.de> writes:
> [...]
>>>> (defsubst parse-time-string-chars (char)
>>>> ! (and (< char (length parse-time-syntax))
>>>> ! (aref parse-time-syntax char)))
>> >
>> > It seems that this is the right fix at the moment because
>> > parse-time.el doesn't pay attention to non-ASCII characters
>> > at all. In the future, we may have to improve it for
>> > non-ASCII characters if necesary.
>
>> I'd guess all that needs to be done is to make parse-time-digits and
>> parse-time-syntax char tables.
>
> Just making them char-tables has the same effect as above.
Right, but is the more clean change, IMHO.
> If we want to handle a multibyte time-string well, we must
> set proper values to those char-tables which, I think, is
> beyond what we should do at the moment.
parse-time-string only handles English dates anyway.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: parse-time-string error with non ASCII timestamp
2007-04-17 14:32 ` Andreas Schwab
@ 2007-04-17 23:07 ` Kenichi Handa
0 siblings, 0 replies; 8+ messages in thread
From: Kenichi Handa @ 2007-04-17 23:07 UTC (permalink / raw)
To: Andreas Schwab; +Cc: zslevin, emacs-devel
In article <jed523xe9d.fsf@sykes.suse.de>, Andreas Schwab <schwab@suse.de> writes:
> > If we want to handle a multibyte time-string well, we must
> > set proper values to those char-tables which, I think, is
> > beyond what we should do at the moment.
> parse-time-string only handles English dates anyway.
If that is the original intention of that function, that
should be mentioned in the docstring clearly. In addition,
just a vector of 128 (instead of the current 256) should be
enough. Using char-table here is much less efficient.
But, is it surely called with English dates only?
---
Kenichi Handa
handa@m17n.org
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: parse-time-string error with non ASCII timestamp
2007-04-17 11:20 ` Kenichi Handa
2007-04-17 11:33 ` Andreas Schwab
@ 2007-04-18 2:02 ` Richard Stallman
2007-04-18 2:46 ` Kenichi Handa
1 sibling, 1 reply; 8+ messages in thread
From: Richard Stallman @ 2007-04-18 2:02 UTC (permalink / raw)
To: Kenichi Handa; +Cc: zslevin, emacs-devel
It seems that this is the right fix at the moment because
parse-time.el doesn't pay attention to non-ASCII characters
at all. In the future, we may have to improve it for
non-ASCII characters if necesary.
Shall I install that change?
Please do!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: parse-time-string error with non ASCII timestamp
2007-04-18 2:02 ` Richard Stallman
@ 2007-04-18 2:46 ` Kenichi Handa
0 siblings, 0 replies; 8+ messages in thread
From: Kenichi Handa @ 2007-04-18 2:46 UTC (permalink / raw)
To: rms; +Cc: zslevin, emacs-devel
In article <E1HdzVZ-0005zr-2X@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:
> It seems that this is the right fix at the moment because
> parse-time.el doesn't pay attention to non-ASCII characters
> at all. In the future, we may have to improve it for
> non-ASCII characters if necesary.
> Shall I install that change?
> Please do!
Done.
---
Kenichi Handa
handa@m17n.org
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-04-18 2:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1175499420.269736.200740@b75g2000hsg.googlegroups.com>
2007-04-17 10:10 ` Fwd: parse-time-string error with non ASCII timestamp Levin Du
2007-04-17 11:20 ` Kenichi Handa
2007-04-17 11:33 ` Andreas Schwab
2007-04-17 11:50 ` Kenichi Handa
2007-04-17 14:32 ` Andreas Schwab
2007-04-17 23:07 ` Kenichi Handa
2007-04-18 2:02 ` Richard Stallman
2007-04-18 2:46 ` Kenichi Handa
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.