/* GNU Emacs case conversion functions.
- Copyright (C) 1985,94,97,98,99, 2001, 2002, 2004
+ Copyright (C) 1985,94,97,98,99, 2001, 2002, 2004, 2005
Free Software Foundation, Inc.
This file is part of GNU Emacs.
You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
#include <config.h>
}
else if (ASCII_CHAR_P (c2) && ASCII_CHAR_P (c))
FETCH_BYTE (start_byte) = c;
- else if (len == CHAR_BYTES (c))
+ else
{
+ int tolen = CHAR_BYTES (c);
int j;
unsigned char str[MAX_MULTIBYTE_LENGTH];
CHAR_STRING (c, str);
- for (j = 0; j < len; ++j)
- FETCH_BYTE (start_byte + j) = str[j];
- }
- else
- {
- TEMP_SET_PT_BOTH (start, start_byte);
- del_range_2 (start, start_byte, start + 1, start_byte + len, 0);
- insert_char (c);
- len = CHAR_BYTES (c);
+ if (len == tolen)
+ {
+ /* Length is unchanged. */
+ for (j = 0; j < len; ++j)
+ FETCH_BYTE (start_byte + j) = str[j];
+ }
+ else
+ {
+ /* Replace one character with the other,
+ keeping text properties the same. */
+ replace_range_2 (start, start_byte,
+ start + 1, start_byte + len,
+ str, 1, tolen,
+ 0);
+ len = tolen;
+ }
}
}
start++;