diff lisp/coding.el @ 4609:33b8c874b2c8

Correct string offset and arg handling, #'query-coding-string and related. lisp/ChangeLog addition: 2009-02-11 Aidan Kehoe <kehoea@parhasard.net> * 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.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 11 Feb 2009 12:11:26 +0000
parents e0a8715fdb1f
children 8cbca852bcd4
line wrap: on
line diff
--- 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.