aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/coding.c b/src/coding.c
index 9848f983a81..0daa390bc85 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9559,10 +9559,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system,
9559 9559
9560 9560
9561/* Encode or decode STRING according to CODING_SYSTEM. 9561/* Encode or decode STRING according to CODING_SYSTEM.
9562 Do not set Vlast_coding_system_used. 9562 Do not set Vlast_coding_system_used. */
9563
9564 This function is called only from macros DECODE_FILE and
9565 ENCODE_FILE, thus we ignore character composition. */
9566 9563
9567Lisp_Object 9564Lisp_Object
9568code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, 9565code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system,
@@ -10332,6 +10329,16 @@ DEFUN ("internal-decode-string-utf-8", Finternal_decode_string_utf_8,
10332 10329
10333#endif /* ENABLE_UTF_8_CONVERTER_TEST */ 10330#endif /* ENABLE_UTF_8_CONVERTER_TEST */
10334 10331
10332/* Encode or decode STRING using CODING_SYSTEM, with the possibility of
10333 returning STRING itself if it equals the result.
10334 Do not set Vlast_coding_system_used. */
10335static Lisp_Object
10336convert_string_nocopy (Lisp_Object string, Lisp_Object coding_system,
10337 bool encodep)
10338{
10339 return code_convert_string (string, coding_system, Qt, encodep, 1, 1);
10340}
10341
10335/* Encode or decode a file name, to or from a unibyte string suitable 10342/* Encode or decode a file name, to or from a unibyte string suitable
10336 for passing to C library functions. */ 10343 for passing to C library functions. */
10337Lisp_Object 10344Lisp_Object
@@ -10342,14 +10349,13 @@ decode_file_name (Lisp_Object fname)
10342 converts the file names either to UTF-16LE or to the system ANSI 10349 converts the file names either to UTF-16LE or to the system ANSI
10343 codepage internally, depending on the underlying OS; see w32.c. */ 10350 codepage internally, depending on the underlying OS; see w32.c. */
10344 if (! NILP (Fcoding_system_p (Qutf_8))) 10351 if (! NILP (Fcoding_system_p (Qutf_8)))
10345 return code_convert_string_norecord (fname, Qutf_8, 0); 10352 return convert_string_nocopy (fname, Qutf_8, 0);
10346 return fname; 10353 return fname;
10347#else /* !WINDOWSNT */ 10354#else /* !WINDOWSNT */
10348 if (! NILP (Vfile_name_coding_system)) 10355 if (! NILP (Vfile_name_coding_system))
10349 return code_convert_string_norecord (fname, Vfile_name_coding_system, 0); 10356 return convert_string_nocopy (fname, Vfile_name_coding_system, 0);
10350 else if (! NILP (Vdefault_file_name_coding_system)) 10357 else if (! NILP (Vdefault_file_name_coding_system))
10351 return code_convert_string_norecord (fname, 10358 return convert_string_nocopy (fname, Vdefault_file_name_coding_system, 0);
10352 Vdefault_file_name_coding_system, 0);
10353 else 10359 else
10354 return fname; 10360 return fname;
10355#endif 10361#endif
@@ -10369,14 +10375,13 @@ encode_file_name (Lisp_Object fname)
10369 converts the file names either to UTF-16LE or to the system ANSI 10375 converts the file names either to UTF-16LE or to the system ANSI
10370 codepage internally, depending on the underlying OS; see w32.c. */ 10376 codepage internally, depending on the underlying OS; see w32.c. */
10371 if (! NILP (Fcoding_system_p (Qutf_8))) 10377 if (! NILP (Fcoding_system_p (Qutf_8)))
10372 return code_convert_string_norecord (fname, Qutf_8, 1); 10378 return convert_string_nocopy (fname, Qutf_8, 1);
10373 return fname; 10379 return fname;
10374#else /* !WINDOWSNT */ 10380#else /* !WINDOWSNT */
10375 if (! NILP (Vfile_name_coding_system)) 10381 if (! NILP (Vfile_name_coding_system))
10376 return code_convert_string_norecord (fname, Vfile_name_coding_system, 1); 10382 return convert_string_nocopy (fname, Vfile_name_coding_system, 1);
10377 else if (! NILP (Vdefault_file_name_coding_system)) 10383 else if (! NILP (Vdefault_file_name_coding_system))
10378 return code_convert_string_norecord (fname, 10384 return convert_string_nocopy (fname, Vdefault_file_name_coding_system, 1);
10379 Vdefault_file_name_coding_system, 1);
10380 else 10385 else
10381 return fname; 10386 return fname;
10382#endif 10387#endif