Raymond Toy pushed to branch issue-367-count-octets-for-encoding at cmucl / cmucl
Commits:
-
afc9afb0
by Raymond Toy at 2025-01-15T09:04:00-08:00
1 changed file:
Changes:
... | ... | @@ -1165,9 +1165,21 @@ character and illegal outputs are replaced by a question mark.") |
1165 | 1165 | "Compute the number of octets needed to convert String using the
|
1166 | 1166 | specified External-format. The string is bound by Start (defaulting
|
1167 | 1167 | to 0) and End (defaulting to the end of the string)."
|
1168 | - (lisp::with-array-data ((string string) (start start) (end end))
|
|
1169 | - (funcall (ef-string-octet-count external-format)
|
|
1170 | - string start end error)))
|
|
1168 | + (let ((composing-format-p
|
|
1169 | + ;; Determine is the external format is a composing format
|
|
1170 | + ;; which we determine by seeing that the name of the format
|
|
1171 | + ;; is a cons. Probably not the best way.
|
|
1172 | + (consp (ef-name (find-external-format external-format)))))
|
|
1173 | + ;; We currently don't know how to get just the number of octets
|
|
1174 | + ;; when a composing external format is used. As a workaround, use
|
|
1175 | + ;; STRING-TO-OCTETS to find the number of octets.
|
|
1176 | + (if composing-format-p
|
|
1177 | + (nth-value 1
|
|
1178 | + (string-to-octets string :start start :end end
|
|
1179 | + :external-format external-format))
|
|
1180 | + (lisp::with-array-data ((string string) (start start) (end end))
|
|
1181 | + (funcall (ef-string-octet-count external-format)
|
|
1182 | + string start end error)))))
|
|
1171 | 1183 | |
1172 | 1184 | (def-ef-macro ef-encode (extfmt lisp::lisp +ef-max+ +ef-en+)
|
1173 | 1185 | `(lambda (string start end result error &aux (ptr 0) (state nil))
|