#36: file-position broken for utf16 and utf32
--------------------+-------------------------------------------------------
Reporter: rtoy | Owner: somebody
Type: defect | Status: new
Priority: minor | Milestone:
Component: Core | Version: 19f
Keywords: |
--------------------+-------------------------------------------------------
Consider this code:
{{{
(defun bug (&optional (format :utf16))
(with-open-file (s "/…
[View More]tmp/bom.txt"
:direction :output
:if-exists :supersede
:external-format format)
(format s "Hello~%"))
(with-open-file (s "/tmp/bom.txt"
:direction :input
:external-format format)
(print (read-char s))
(print (file-position s)))
(values))
}}}
Running {{{(bug :utf16)}}} produces
{{{
#\H
2
}}}
{{{(bug :utf32)}}} produces
{{{
#\H
4
}}}
In both cases, the actual position is wrong. For utf16, the position
should 4; utf32, 8. The BOM has been ignored.
This is caused by {{{STRING-ENCODE}}} outputting the BOM for these
formats. {{{STRING-ENCODE)}}} is used to figure out how many octets have
not yet been processed but have been read from the file. If the BOM was
not output, the position would be correct.
This bug (will) occur in the 2010-02 snapshot and later.
--
Ticket URL: <http://trac.common-lisp.net/cmucl/ticket/36>
cmucl <http://common-lisp.net/project/cmucl>
cmucl
[View Less]
#38: Inlining loses declarations
--------------------+-------------------------------------------------------
Reporter: heller | Owner: somebody
Type: defect | Status: new
Priority: minor | Milestone:
Component: Core | Version: 20a
Keywords: |
--------------------+-------------------------------------------------------
I'd like to write a function fx+ which is like + but only
accepts fixnums as arguments and never conses, i.…
[View More]e. it's
considered an error if the sum is not a fixnum. Arguments
and return value should be checked. Essentially this
{{{
(declaim (inline fx+))
(defun fx+ (x y)
(declare (fixnum x y)
(values fixnum))
(+ x y))
}}}
is what I want. If called as (fx+ 1 most-positive-fixnum)
the error is detected as it should be. But after inlining
{{{
(defun foo (x y)
(fx+ x y))
}}}
and using it like (foo 1 most-positive-fixnum) it returns
-536870912.
--
Ticket URL: <http://trac.common-lisp.net/cmucl/ticket/38>
cmucl <http://common-lisp.net/project/cmucl>
cmucl
[View Less]