Ticket #1116 (new enhancement)

Opened 16 months ago

parse-integer :junk-allowed NIL accepts control codes as spaces.

Reported by: pjb@… Owned by:
Priority: normal Milestone:
Component: other Version: trunk
Keywords: whitespace character space parse-integer junk-allowed Cc:


(parse-integer "123" :junk-allowed nil)
--> 123

(loop for i from 0 to 33 unless (ignore-errors  (parse-integer (format nil "123~C" (code-char i)) :junk-allowed nil)) collect i)
--> (8 33)

(princ (nth-value 1 (ignore-errors (parse-integer (format nil "123~C"(code-char #x2000)) :junk-allowed nil))))
PARSE-INTEGER: substring "123 " does not have integer syntax at position 3

<rethorical>Why is #\Backspace considered junk while not the others?</rethorical>

It seems to me that most control code should not be considered whitespace characters; only #\Tab #\Newline #\Linefeed #\Page #\Return.

On the other hand, unicode white space are considered junk.  http://www.cs.tut.fi/~jkorpela/chars/spaces.html I'd propose to consider them as whitespace characters, instead of the control codes.

(There may be some security issues concerning zero-width unicode white spaces, but that wouldn't be worse than the current situation with control codes).

Note: See TracTickets for help on using tickets.