comparison src/fns.c @ 23773:f11f551fee99

(Fstring_as_unibyte, Fstring_as_multibyte): Clear text properties in the new string.
author Richard M. Stallman <rms@gnu.org>
date Fri, 27 Nov 1998 22:15:38 +0000
parents e963fc8ca03f
children efa2dd070256
comparison
equal deleted inserted replaced
23772:afe440aabd55 23773:f11f551fee99
1000 } 1000 }
1001 1001
1002 DEFUN ("string-as-unibyte", Fstring_as_unibyte, Sstring_as_unibyte, 1002 DEFUN ("string-as-unibyte", Fstring_as_unibyte, Sstring_as_unibyte,
1003 1, 1, 0, 1003 1, 1, 0,
1004 "Return a unibyte string with the same individual bytes as STRING.\n\ 1004 "Return a unibyte string with the same individual bytes as STRING.\n\
1005 If STRING is unibyte, the result is STRING itself.") 1005 If STRING is unibyte, the result is STRING itself.\n\
1006 If STRING is multibyte, the result is STRING itself.\n\
1007 Otherwise it is a newly created string, with no text properties.")
1006 (string) 1008 (string)
1007 Lisp_Object string; 1009 Lisp_Object string;
1008 { 1010 {
1009 CHECK_STRING (string, 0); 1011 CHECK_STRING (string, 0);
1010 1012
1011 if (STRING_MULTIBYTE (string)) 1013 if (STRING_MULTIBYTE (string))
1012 { 1014 {
1013 string = Fcopy_sequence (string); 1015 string = Fcopy_sequence (string);
1014 XSTRING (string)->size = STRING_BYTES (XSTRING (string)); 1016 XSTRING (string)->size = STRING_BYTES (XSTRING (string));
1017 XSTRING (string)->intervals = NULL_INTERVAL;
1015 SET_STRING_BYTES (XSTRING (string), -1); 1018 SET_STRING_BYTES (XSTRING (string), -1);
1016 } 1019 }
1017 return string; 1020 return string;
1018 } 1021 }
1019 1022
1020 DEFUN ("string-as-multibyte", Fstring_as_multibyte, Sstring_as_multibyte, 1023 DEFUN ("string-as-multibyte", Fstring_as_multibyte, Sstring_as_multibyte,
1021 1, 1, 0, 1024 1, 1, 0,
1022 "Return a multibyte string with the same individual bytes as STRING.\n\ 1025 "Return a multibyte string with the same individual bytes as STRING.\n\
1023 If STRING is multibyte, the result is STRING itself.") 1026 If STRING is multibyte, the result is STRING itself.\n\
1027 Otherwise it is a newly created string, with no text properties.")
1024 (string) 1028 (string)
1025 Lisp_Object string; 1029 Lisp_Object string;
1026 { 1030 {
1027 CHECK_STRING (string, 0); 1031 CHECK_STRING (string, 0);
1028 1032
1032 int newlen = multibyte_chars_in_text (XSTRING (string)->data, nbytes); 1036 int newlen = multibyte_chars_in_text (XSTRING (string)->data, nbytes);
1033 1037
1034 string = Fcopy_sequence (string); 1038 string = Fcopy_sequence (string);
1035 XSTRING (string)->size = newlen; 1039 XSTRING (string)->size = newlen;
1036 XSTRING (string)->size_byte = nbytes; 1040 XSTRING (string)->size_byte = nbytes;
1041 XSTRING (string)->intervals = NULL_INTERVAL;
1037 } 1042 }
1038 return string; 1043 return string;
1039 } 1044 }
1040 1045
1041 DEFUN ("copy-alist", Fcopy_alist, Scopy_alist, 1, 1, 0, 1046 DEFUN ("copy-alist", Fcopy_alist, Scopy_alist, 1, 1, 0,