# HG changeset patch # User Aidan Kehoe # Date 1234354286 0 # Node ID 33b8c874b2c86c5ae027cbf2a784ead324a73e56 # Parent 1e3cf11fa27dfd4bef80a31d356e914a3a7dc119 Correct string offset and arg handling, #'query-coding-string and related. lisp/ChangeLog addition: 2009-02-11 Aidan Kehoe * coding.el (query-coding-string): Correct the order of arguments passed to #'query-coding-region. (unencodable-char-position): Handle string offsets correctly, they're one less than buffer offsets. Handle START and END correctly if passed a string. diff -r 1e3cf11fa27d -r 33b8c874b2c8 lisp/ChangeLog --- a/lisp/ChangeLog Tue Feb 10 16:07:31 2009 +0000 +++ b/lisp/ChangeLog Wed Feb 11 12:11:26 2009 +0000 @@ -1,3 +1,11 @@ +2009-02-11 Aidan Kehoe + + * coding.el (query-coding-string): + Correct the order of arguments passed to #'query-coding-region. + (unencodable-char-position): + Handle string offsets correctly, they're one less than buffer + offsets. Handle START and END correctly if passed a string. + 2009-02-08 Aidan Kehoe * cl-macs.el (delete-duplicates): diff -r 1e3cf11fa27d -r 33b8c874b2c8 lisp/coding.el --- a/lisp/coding.el Tue Feb 10 16:07:31 2009 +0000 +++ b/lisp/coding.el Wed Feb 11 12:11:26 2009 +0000 @@ -507,8 +507,8 @@ (insert string) (multiple-value-bind (result ranges extent) (query-coding-region (point-min) (point-max) coding-system - (current-buffer) errorp - nil ignore-invalid-sequencesp) + (current-buffer) ignore-invalid-sequencesp + errorp) (unless result (map-range-table #'(lambda (begin end value) @@ -539,7 +539,7 @@ for un-encodable characters. In that case, START and END are indexes in the string." (let ((thunk - #'(lambda (start end coding-system &optional count) + #'(lambda (start end coding-system stringp count) (multiple-value-bind (result ranges) (query-coding-region start end coding-system) (if result @@ -550,14 +550,15 @@ #'(lambda (begin end value) (while (and (< begin end) (< (length result) count)) - (push begin result) + (push (if stringp (1- begin) begin) result) (incf begin)) (when (= (length result) count) (return-from worked-it-all-out result))) ranges) (map-range-table #'(lambda (begin end value) - (return-from worked-it-all-out begin)) + (return-from worked-it-all-out + (if stringp (1- begin) begin))) ranges)) (assert (not (null count)) t "We should never reach this point with null COUNT.") @@ -572,8 +573,8 @@ (if string (with-temp-buffer (insert string) - (funcall thunk start end coding-system count)) - (funcall thunk start end coding-system count)))) + (funcall thunk (1+ start) (1+ end) coding-system t count)) + (funcall thunk start end coding-system nil count)))) ;; XEmacs; this is a GPLv3 function in coding.c in GNU. This is why we have ;; both a very divergent docstring and a very divergent implementation.