Mercurial > emacs
comparison src/data.c @ 111572:b3f9490f0b7f
merge trunk
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 08 Nov 2010 14:19:24 +0900 |
parents | 66f6be9b4d43 |
children | 317ffffec7f3 |
comparison
equal
deleted
inserted
replaced
111571:91de9477a77a | 111572:b3f9490f0b7f |
---|---|
2080 doc: /* Return the element of ARRAY at index IDX. | 2080 doc: /* Return the element of ARRAY at index IDX. |
2081 ARRAY may be a vector, a string, a char-table, a bool-vector, | 2081 ARRAY may be a vector, a string, a char-table, a bool-vector, |
2082 or a byte-code object. IDX starts at 0. */) | 2082 or a byte-code object. IDX starts at 0. */) |
2083 (register Lisp_Object array, Lisp_Object idx) | 2083 (register Lisp_Object array, Lisp_Object idx) |
2084 { | 2084 { |
2085 register int idxval; | 2085 register EMACS_INT idxval; |
2086 | 2086 |
2087 CHECK_NUMBER (idx); | 2087 CHECK_NUMBER (idx); |
2088 idxval = XINT (idx); | 2088 idxval = XINT (idx); |
2089 if (STRINGP (array)) | 2089 if (STRINGP (array)) |
2090 { | 2090 { |
2091 int c, idxval_byte; | 2091 int c; |
2092 EMACS_INT idxval_byte; | |
2092 | 2093 |
2093 if (idxval < 0 || idxval >= SCHARS (array)) | 2094 if (idxval < 0 || idxval >= SCHARS (array)) |
2094 args_out_of_range (array, idx); | 2095 args_out_of_range (array, idx); |
2095 if (! STRING_MULTIBYTE (array)) | 2096 if (! STRING_MULTIBYTE (array)) |
2096 return make_number ((unsigned char) SREF (array, idxval)); | 2097 return make_number ((unsigned char) SREF (array, idxval)); |
2134 doc: /* Store into the element of ARRAY at index IDX the value NEWELT. | 2135 doc: /* Store into the element of ARRAY at index IDX the value NEWELT. |
2135 Return NEWELT. ARRAY may be a vector, a string, a char-table or a | 2136 Return NEWELT. ARRAY may be a vector, a string, a char-table or a |
2136 bool-vector. IDX starts at 0. */) | 2137 bool-vector. IDX starts at 0. */) |
2137 (register Lisp_Object array, Lisp_Object idx, Lisp_Object newelt) | 2138 (register Lisp_Object array, Lisp_Object idx, Lisp_Object newelt) |
2138 { | 2139 { |
2139 register int idxval; | 2140 register EMACS_INT idxval; |
2140 | 2141 |
2141 CHECK_NUMBER (idx); | 2142 CHECK_NUMBER (idx); |
2142 idxval = XINT (idx); | 2143 idxval = XINT (idx); |
2143 CHECK_ARRAY (array, Qarrayp); | 2144 CHECK_ARRAY (array, Qarrayp); |
2144 CHECK_IMPURE (array); | 2145 CHECK_IMPURE (array); |
2169 CHECK_CHARACTER (idx); | 2170 CHECK_CHARACTER (idx); |
2170 CHAR_TABLE_SET (array, idxval, newelt); | 2171 CHAR_TABLE_SET (array, idxval, newelt); |
2171 } | 2172 } |
2172 else if (STRING_MULTIBYTE (array)) | 2173 else if (STRING_MULTIBYTE (array)) |
2173 { | 2174 { |
2174 int idxval_byte, prev_bytes, new_bytes, nbytes; | 2175 EMACS_INT idxval_byte, prev_bytes, new_bytes, nbytes; |
2175 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; | 2176 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; |
2176 | 2177 |
2177 if (idxval < 0 || idxval >= SCHARS (array)) | 2178 if (idxval < 0 || idxval >= SCHARS (array)) |
2178 args_out_of_range (array, idx); | 2179 args_out_of_range (array, idx); |
2179 CHECK_CHARACTER (newelt); | 2180 CHECK_CHARACTER (newelt); |
2185 prev_bytes = BYTES_BY_CHAR_HEAD (*p1); | 2186 prev_bytes = BYTES_BY_CHAR_HEAD (*p1); |
2186 new_bytes = CHAR_STRING (XINT (newelt), p0); | 2187 new_bytes = CHAR_STRING (XINT (newelt), p0); |
2187 if (prev_bytes != new_bytes) | 2188 if (prev_bytes != new_bytes) |
2188 { | 2189 { |
2189 /* We must relocate the string data. */ | 2190 /* We must relocate the string data. */ |
2190 int nchars = SCHARS (array); | 2191 EMACS_INT nchars = SCHARS (array); |
2191 unsigned char *str; | 2192 unsigned char *str; |
2192 USE_SAFE_ALLOCA; | 2193 USE_SAFE_ALLOCA; |
2193 | 2194 |
2194 SAFE_ALLOCA (str, unsigned char *, nbytes); | 2195 SAFE_ALLOCA (str, unsigned char *, nbytes); |
2195 memcpy (str, SDATA (array), nbytes); | 2196 memcpy (str, SDATA (array), nbytes); |