In {encode,decode}-coding-string, the NOCOPY parameter had the
opposite effect to what was intended and documented. This 18 year old
bug (introduced in
4031e2bf0a) only affected calls with CODING-SYSTEM
being nil.
* src/coding.c (code_convert_string): Correct use of NOCOPY.
* test/src/coding-tests.el (coding-nocopy-trivial): New test.
if (! norecord)
Vlast_coding_system_used = Qno_conversion;
if (NILP (dst_object))
- return (nocopy ? Fcopy_sequence (string) : string);
+ return nocopy ? string : Fcopy_sequence (string);
}
if (NILP (coding_system))
(with-temp-buffer (insert-file-contents (car file))))))
(insert (format "%s: %s\n" (car file) result)))))))
+(ert-deftest coding-nocopy-trivial ()
+ "Check that the NOCOPY parameter works for the trivial coding system."
+ (let ((s "abc"))
+ (should-not (eq (decode-coding-string s nil nil) s))
+ (should (eq (decode-coding-string s nil t) s))
+ (should-not (eq (encode-coding-string s nil nil) s))
+ (should (eq (encode-coding-string s nil t) s))))
+
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; End: