comparison src/alloc.c @ 867:804517e16990

[xemacs-hg @ 2002-06-05 09:54:39 by ben] Textual renaming: text/char names abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization. [a] distinguish between "charptr" when it refers to operations on the pointer itself and when it refers to operations on text; and [b] use consistent naming for everything referring to internal format, i.e. Itext == text in internal format Ibyte == a byte in such text Ichar == a char as represented in internal character format thus e.g. set_charptr_emchar -> set_itext_ichar The pre and post tags on either side of this change are: pre-internal-format-textual-renaming post-internal-format-textual-renaming See the Internals Manual for details of exactly how this was done, how to handle the change in your workspace, etc.
author ben
date Wed, 05 Jun 2002 09:58:45 +0000
parents 2c12fe2da451
children 79c6ff3eef26
comparison
equal deleted inserted replaced
866:613552a02607 867:804517e16990
1933 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); 1933 ALLOCATE_FIXED_TYPE (string, Lisp_String, s);
1934 xzero (*s); 1934 xzero (*s);
1935 set_lheader_implementation (&s->u.lheader, &lrecord_string); 1935 set_lheader_implementation (&s->u.lheader, &lrecord_string);
1936 1936
1937 set_lispstringp_data (s, BIG_STRING_FULLSIZE_P (fullsize) 1937 set_lispstringp_data (s, BIG_STRING_FULLSIZE_P (fullsize)
1938 ? xnew_array (Intbyte, length + 1) 1938 ? xnew_array (Ibyte, length + 1)
1939 : allocate_string_chars_struct (wrap_string (s), 1939 : allocate_string_chars_struct (wrap_string (s),
1940 fullsize)->chars); 1940 fullsize)->chars);
1941 1941
1942 set_lispstringp_length (s, length); 1942 set_lispstringp_length (s, length);
1943 s->plist = Qnil; 1943 s->plist = Qnil;
2004 2004
2005 if (delta < 0 && pos >= 0) 2005 if (delta < 0 && pos >= 0)
2006 memmove (XSTRING_DATA (s) + pos + delta, 2006 memmove (XSTRING_DATA (s) + pos + delta,
2007 XSTRING_DATA (s) + pos, len); 2007 XSTRING_DATA (s) + pos, len);
2008 XSET_STRING_DATA 2008 XSET_STRING_DATA
2009 (s, (Intbyte *) xrealloc (XSTRING_DATA (s), 2009 (s, (Ibyte *) xrealloc (XSTRING_DATA (s),
2010 XSTRING_LENGTH (s) + delta + 1)); 2010 XSTRING_LENGTH (s) + delta + 1));
2011 if (delta > 0 && pos >= 0) 2011 if (delta > 0 && pos >= 0)
2012 memmove (XSTRING_DATA (s) + pos + delta, XSTRING_DATA (s) + pos, 2012 memmove (XSTRING_DATA (s) + pos + delta, XSTRING_DATA (s) + pos,
2013 len); 2013 len);
2014 } 2014 }
2015 else /* String has been demoted from BIG_STRING. */ 2015 else /* String has been demoted from BIG_STRING. */
2016 { 2016 {
2017 Intbyte *new_data = 2017 Ibyte *new_data =
2018 allocate_string_chars_struct (s, newfullsize)->chars; 2018 allocate_string_chars_struct (s, newfullsize)->chars;
2019 Intbyte *old_data = XSTRING_DATA (s); 2019 Ibyte *old_data = XSTRING_DATA (s);
2020 2020
2021 if (pos >= 0) 2021 if (pos >= 0)
2022 { 2022 {
2023 memcpy (new_data, old_data, pos); 2023 memcpy (new_data, old_data, pos);
2024 memcpy (new_data + pos + delta, old_data + pos, 2024 memcpy (new_data + pos + delta, old_data + pos,
2037 somewhere depends on there not being any unused 2037 somewhere depends on there not being any unused
2038 allocation space, modulo any alignment 2038 allocation space, modulo any alignment
2039 constraints). */ 2039 constraints). */
2040 if (pos >= 0) 2040 if (pos >= 0)
2041 { 2041 {
2042 Intbyte *addroff = pos + XSTRING_DATA (s); 2042 Ibyte *addroff = pos + XSTRING_DATA (s);
2043 2043
2044 memmove (addroff + delta, addroff, 2044 memmove (addroff + delta, addroff,
2045 /* +1 due to zero-termination. */ 2045 /* +1 due to zero-termination. */
2046 XSTRING_LENGTH (s) + 1 - pos); 2046 XSTRING_LENGTH (s) + 1 - pos);
2047 } 2047 }
2048 } 2048 }
2049 else 2049 else
2050 { 2050 {
2051 Intbyte *old_data = XSTRING_DATA (s); 2051 Ibyte *old_data = XSTRING_DATA (s);
2052 Intbyte *new_data = 2052 Ibyte *new_data =
2053 BIG_STRING_FULLSIZE_P (newfullsize) 2053 BIG_STRING_FULLSIZE_P (newfullsize)
2054 ? xnew_array (Intbyte, XSTRING_LENGTH (s) + delta + 1) 2054 ? xnew_array (Ibyte, XSTRING_LENGTH (s) + delta + 1)
2055 : allocate_string_chars_struct (s, newfullsize)->chars; 2055 : allocate_string_chars_struct (s, newfullsize)->chars;
2056 2056
2057 if (pos >= 0) 2057 if (pos >= 0)
2058 { 2058 {
2059 memcpy (new_data, old_data, pos); 2059 memcpy (new_data, old_data, pos);
2098 #ifdef MULE 2098 #ifdef MULE
2099 2099
2100 /* WARNING: If you modify an existing string, you must call 2100 /* WARNING: If you modify an existing string, you must call
2101 CHECK_LISP_WRITEABLE() before and bump_string_modiff() afterwards. */ 2101 CHECK_LISP_WRITEABLE() before and bump_string_modiff() afterwards. */
2102 void 2102 void
2103 set_string_char (Lisp_Object s, Charcount i, Emchar c) 2103 set_string_char (Lisp_Object s, Charcount i, Ichar c)
2104 { 2104 {
2105 Intbyte newstr[MAX_EMCHAR_LEN]; 2105 Ibyte newstr[MAX_ICHAR_LEN];
2106 Bytecount bytoff = string_index_char_to_byte (s, i); 2106 Bytecount bytoff = string_index_char_to_byte (s, i);
2107 Bytecount oldlen = charptr_emchar_len (XSTRING_DATA (s) + bytoff); 2107 Bytecount oldlen = itext_ichar_len (XSTRING_DATA (s) + bytoff);
2108 Bytecount newlen = set_charptr_emchar (newstr, c); 2108 Bytecount newlen = set_itext_ichar (newstr, c);
2109 2109
2110 sledgehammer_check_ascii_begin (s); 2110 sledgehammer_check_ascii_begin (s);
2111 if (oldlen != newlen) 2111 if (oldlen != newlen)
2112 resize_string (s, bytoff, newlen - oldlen); 2112 resize_string (s, bytoff, newlen - oldlen);
2113 /* Remember, XSTRING_DATA (s) might have changed so we can't cache it. */ 2113 /* Remember, XSTRING_DATA (s) might have changed so we can't cache it. */
2142 (length, character)) 2142 (length, character))
2143 { 2143 {
2144 CHECK_NATNUM (length); 2144 CHECK_NATNUM (length);
2145 CHECK_CHAR_COERCE_INT (character); 2145 CHECK_CHAR_COERCE_INT (character);
2146 { 2146 {
2147 Intbyte init_str[MAX_EMCHAR_LEN]; 2147 Ibyte init_str[MAX_ICHAR_LEN];
2148 int len = set_charptr_emchar (init_str, XCHAR (character)); 2148 int len = set_itext_ichar (init_str, XCHAR (character));
2149 Lisp_Object val = make_uninit_string (len * XINT (length)); 2149 Lisp_Object val = make_uninit_string (len * XINT (length));
2150 2150
2151 if (len == 1) 2151 if (len == 1)
2152 { 2152 {
2153 /* Optimize the single-byte case */ 2153 /* Optimize the single-byte case */
2156 len * XINT (length))); 2156 len * XINT (length)));
2157 } 2157 }
2158 else 2158 else
2159 { 2159 {
2160 EMACS_INT i; 2160 EMACS_INT i;
2161 Intbyte *ptr = XSTRING_DATA (val); 2161 Ibyte *ptr = XSTRING_DATA (val);
2162 2162
2163 for (i = XINT (length); i; i--) 2163 for (i = XINT (length); i; i--)
2164 { 2164 {
2165 Intbyte *init_ptr = init_str; 2165 Ibyte *init_ptr = init_str;
2166 switch (len) 2166 switch (len)
2167 { 2167 {
2168 case 4: *ptr++ = *init_ptr++; 2168 case 4: *ptr++ = *init_ptr++;
2169 case 3: *ptr++ = *init_ptr++; 2169 case 3: *ptr++ = *init_ptr++;
2170 case 2: *ptr++ = *init_ptr++; 2170 case 2: *ptr++ = *init_ptr++;
2180 DEFUN ("string", Fstring, 0, MANY, 0, /* 2180 DEFUN ("string", Fstring, 0, MANY, 0, /*
2181 Concatenate all the argument characters and make the result a string. 2181 Concatenate all the argument characters and make the result a string.
2182 */ 2182 */
2183 (int nargs, Lisp_Object *args)) 2183 (int nargs, Lisp_Object *args))
2184 { 2184 {
2185 Intbyte *storage = alloca_array (Intbyte, nargs * MAX_EMCHAR_LEN); 2185 Ibyte *storage = alloca_array (Ibyte, nargs * MAX_ICHAR_LEN);
2186 Intbyte *p = storage; 2186 Ibyte *p = storage;
2187 2187
2188 for (; nargs; nargs--, args++) 2188 for (; nargs; nargs--, args++)
2189 { 2189 {
2190 Lisp_Object lisp_char = *args; 2190 Lisp_Object lisp_char = *args;
2191 CHECK_CHAR_COERCE_INT (lisp_char); 2191 CHECK_CHAR_COERCE_INT (lisp_char);
2192 p += set_charptr_emchar (p, XCHAR (lisp_char)); 2192 p += set_itext_ichar (p, XCHAR (lisp_char));
2193 } 2193 }
2194 return make_string (storage, p - storage); 2194 return make_string (storage, p - storage);
2195 } 2195 }
2196 2196
2197 /* Initialize the ascii_begin member of a string to the correct value. */ 2197 /* Initialize the ascii_begin member of a string to the correct value. */
2200 init_string_ascii_begin (Lisp_Object string) 2200 init_string_ascii_begin (Lisp_Object string)
2201 { 2201 {
2202 #ifdef MULE 2202 #ifdef MULE
2203 int i; 2203 int i;
2204 Bytecount length = XSTRING_LENGTH (string); 2204 Bytecount length = XSTRING_LENGTH (string);
2205 Intbyte *contents = XSTRING_DATA (string); 2205 Ibyte *contents = XSTRING_DATA (string);
2206 2206
2207 for (i = 0; i < length; i++) 2207 for (i = 0; i < length; i++)
2208 { 2208 {
2209 if (!byte_ascii_p (contents[i])) 2209 if (!byte_ascii_p (contents[i]))
2210 break; 2210 break;
2218 } 2218 }
2219 2219
2220 /* Take some raw memory, which MUST already be in internal format, 2220 /* Take some raw memory, which MUST already be in internal format,
2221 and package it up into a Lisp string. */ 2221 and package it up into a Lisp string. */
2222 Lisp_Object 2222 Lisp_Object
2223 make_string (const Intbyte *contents, Bytecount length) 2223 make_string (const Ibyte *contents, Bytecount length)
2224 { 2224 {
2225 Lisp_Object val; 2225 Lisp_Object val;
2226 2226
2227 /* Make sure we find out about bad make_string's when they happen */ 2227 /* Make sure we find out about bad make_string's when they happen */
2228 #if defined (ERROR_CHECK_TEXT) && defined (MULE) 2228 #if defined (ERROR_CHECK_TEXT) && defined (MULE)
2248 coding_system); 2248 coding_system);
2249 return string; 2249 return string;
2250 } 2250 }
2251 2251
2252 Lisp_Object 2252 Lisp_Object
2253 build_intstring (const Intbyte *str) 2253 build_intstring (const Ibyte *str)
2254 { 2254 {
2255 /* Some strlen's crash and burn if passed null. */ 2255 /* Some strlen's crash and burn if passed null. */
2256 return make_string (str, (str ? qxestrlen (str) : (Bytecount) 0)); 2256 return make_string (str, (str ? qxestrlen (str) : (Bytecount) 0));
2257 } 2257 }
2258 2258
2259 Lisp_Object 2259 Lisp_Object
2260 build_string (const CIntbyte *str) 2260 build_string (const CIbyte *str)
2261 { 2261 {
2262 /* Some strlen's crash and burn if passed null. */ 2262 /* Some strlen's crash and burn if passed null. */
2263 return make_string ((const Intbyte *) str, (str ? strlen (str) : 0)); 2263 return make_string ((const Ibyte *) str, (str ? strlen (str) : 0));
2264 } 2264 }
2265 2265
2266 Lisp_Object 2266 Lisp_Object
2267 build_ext_string (const Extbyte *str, Lisp_Object coding_system) 2267 build_ext_string (const Extbyte *str, Lisp_Object coding_system)
2268 { 2268 {
2270 return make_ext_string ((const Extbyte *) str, (str ? strlen(str) : 0), 2270 return make_ext_string ((const Extbyte *) str, (str ? strlen(str) : 0),
2271 coding_system); 2271 coding_system);
2272 } 2272 }
2273 2273
2274 Lisp_Object 2274 Lisp_Object
2275 build_msg_intstring (const Intbyte *str) 2275 build_msg_intstring (const Ibyte *str)
2276 { 2276 {
2277 return build_intstring (GETTEXT (str)); 2277 return build_intstring (GETTEXT (str));
2278 } 2278 }
2279 2279
2280 Lisp_Object 2280 Lisp_Object
2281 build_msg_string (const CIntbyte *str) 2281 build_msg_string (const CIbyte *str)
2282 { 2282 {
2283 return build_string (CGETTEXT (str)); 2283 return build_string (CGETTEXT (str));
2284 } 2284 }
2285 2285
2286 Lisp_Object 2286 Lisp_Object
2287 make_string_nocopy (const Intbyte *contents, Bytecount length) 2287 make_string_nocopy (const Ibyte *contents, Bytecount length)
2288 { 2288 {
2289 Lisp_String *s; 2289 Lisp_String *s;
2290 Lisp_Object val; 2290 Lisp_Object val;
2291 2291
2292 /* Make sure we find out about bad make_string_nocopy's when they happen */ 2292 /* Make sure we find out about bad make_string_nocopy's when they happen */
2297 /* Allocate the string header */ 2297 /* Allocate the string header */
2298 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); 2298 ALLOCATE_FIXED_TYPE (string, Lisp_String, s);
2299 set_lheader_implementation (&s->u.lheader, &lrecord_string); 2299 set_lheader_implementation (&s->u.lheader, &lrecord_string);
2300 SET_C_READONLY_RECORD_HEADER (&s->u.lheader); 2300 SET_C_READONLY_RECORD_HEADER (&s->u.lheader);
2301 s->plist = Qnil; 2301 s->plist = Qnil;
2302 set_lispstringp_data (s, (Intbyte *) contents); 2302 set_lispstringp_data (s, (Ibyte *) contents);
2303 set_lispstringp_length (s, length); 2303 set_lispstringp_length (s, length);
2304 val = wrap_string (s); 2304 val = wrap_string (s);
2305 init_string_ascii_begin (val); 2305 init_string_ascii_begin (val);
2306 sledgehammer_check_ascii_begin (val); 2306 sledgehammer_check_ascii_begin (val);
2307 2307
3313 Charcount i; 3313 Charcount i;
3314 Charcount s = string_char_length (p); 3314 Charcount s = string_char_length (p);
3315 stderr_out ("\""); 3315 stderr_out ("\"");
3316 for (i = 0; i < s; i++) 3316 for (i = 0; i < s; i++)
3317 { 3317 {
3318 Emchar ch = string_emchar (p, i); 3318 Ichar ch = string_ichar (p, i);
3319 if (ch < 32 || ch >= 126) 3319 if (ch < 32 || ch >= 126)
3320 stderr_out ("\\%03o", ch); 3320 stderr_out ("\\%03o", ch);
3321 else if (ch == '\\' || ch == '\"') 3321 else if (ch == '\\' || ch == '\"')
3322 stderr_out ("\\%c", ch); 3322 stderr_out ("\\%c", ch);
3323 else 3323 else
3654 Lisp_Object args[2], whole_msg; 3654 Lisp_Object args[2], whole_msg;
3655 args[0] = (STRINGP (Vgc_message) ? Vgc_message : 3655 args[0] = (STRINGP (Vgc_message) ? Vgc_message :
3656 build_msg_string (gc_default_message)); 3656 build_msg_string (gc_default_message));
3657 args[1] = build_string ("..."); 3657 args[1] = build_string ("...");
3658 whole_msg = Fconcat (2, args); 3658 whole_msg = Fconcat (2, args);
3659 echo_area_message (f, (Intbyte *) 0, whole_msg, 0, -1, 3659 echo_area_message (f, (Ibyte *) 0, whole_msg, 0, -1,
3660 Qgarbage_collecting); 3660 Qgarbage_collecting);
3661 } 3661 }
3662 } 3662 }
3663 3663
3664 /***** Now we actually start the garbage collection. */ 3664 /***** Now we actually start the garbage collection. */
3817 Lisp_Object args[2], whole_msg; 3817 Lisp_Object args[2], whole_msg;
3818 args[0] = (STRINGP (Vgc_message) ? Vgc_message : 3818 args[0] = (STRINGP (Vgc_message) ? Vgc_message :
3819 build_msg_string (gc_default_message)); 3819 build_msg_string (gc_default_message));
3820 args[1] = build_msg_string ("... done"); 3820 args[1] = build_msg_string ("... done");
3821 whole_msg = Fconcat (2, args); 3821 whole_msg = Fconcat (2, args);
3822 echo_area_message (selected_frame (), (Intbyte *) 0, 3822 echo_area_message (selected_frame (), (Ibyte *) 0,
3823 whole_msg, 0, -1, 3823 whole_msg, 0, -1,
3824 Qgarbage_collecting); 3824 Qgarbage_collecting);
3825 } 3825 }
3826 } 3826 }
3827 } 3827 }