comparison src/character.c @ 99475:98e08333a580

(Fget_byte): Fix and make it faster for unibyte target.
author Kenichi Handa <handa@m17n.org>
date Mon, 10 Nov 2008 00:45:26 +0000
parents 877b7365b646
children e228d5755549
comparison
equal deleted inserted replaced
99474:ecad25300f20 99475:98e08333a580
1056 if (XINT (position) < BEGV || XINT (position) >= ZV) 1056 if (XINT (position) < BEGV || XINT (position) >= ZV)
1057 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); 1057 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
1058 pos = XFASTINT (position); 1058 pos = XFASTINT (position);
1059 p = CHAR_POS_ADDR (pos); 1059 p = CHAR_POS_ADDR (pos);
1060 } 1060 }
1061 if (NILP (current_buffer->enable_multibyte_characters))
1062 return make_number (*p);
1061 } 1063 }
1062 else 1064 else
1063 { 1065 {
1064 CHECK_STRING (string); 1066 CHECK_STRING (string);
1065 if (NILP (position)) 1067 if (NILP (position))
1072 if (XINT (position) >= SCHARS (string)) 1074 if (XINT (position) >= SCHARS (string))
1073 args_out_of_range (string, position); 1075 args_out_of_range (string, position);
1074 pos = XFASTINT (position); 1076 pos = XFASTINT (position);
1075 p = SDATA (string) + string_char_to_byte (string, pos); 1077 p = SDATA (string) + string_char_to_byte (string, pos);
1076 } 1078 }
1079 if (! STRING_MULTIBYTE (string))
1080 return make_number (*p);
1077 } 1081 }
1078 c = STRING_CHAR (p, 0); 1082 c = STRING_CHAR (p, 0);
1079 if (CHAR_BYTE8_P (c)) 1083 if (CHAR_BYTE8_P (c))
1080 c = CHAR_TO_BYTE8 (c); 1084 c = CHAR_TO_BYTE8 (c);
1081 else if (! ASCII_CHAR_P (c)) 1085 else if (! ASCII_CHAR_P (c))