diff options
| author | Ken Raeburn | 2002-07-15 00:01:34 +0000 |
|---|---|---|
| committer | Ken Raeburn | 2002-07-15 00:01:34 +0000 |
| commit | d5db40779d7505244d37476b4f046641f07eea2b (patch) | |
| tree | 5c8bf4dad41639287e722cb7cbdc0709e47a9e53 /src/editfns.c | |
| parent | 491c2516d32fa8b9ba9422ec142c8925dd82af00 (diff) | |
| download | emacs-d5db40779d7505244d37476b4f046641f07eea2b.tar.gz emacs-d5db40779d7505244d37476b4f046641f07eea2b.zip | |
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
SCHARS, SBYTES, STRING_INTERVALS, SREF, SDATA; explicit size_byte references
left unchanged for now.
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/src/editfns.c b/src/editfns.c index 72da635a9b4..9c88d963eb3 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1202,7 +1202,7 @@ name, or nil if there is no such user. */) | |||
| 1202 | else if (NUMBERP (uid)) | 1202 | else if (NUMBERP (uid)) |
| 1203 | pw = (struct passwd *) getpwuid ((uid_t) XFLOATINT (uid)); | 1203 | pw = (struct passwd *) getpwuid ((uid_t) XFLOATINT (uid)); |
| 1204 | else if (STRINGP (uid)) | 1204 | else if (STRINGP (uid)) |
| 1205 | pw = (struct passwd *) getpwnam (XSTRING (uid)->data); | 1205 | pw = (struct passwd *) getpwnam (SDATA (uid)); |
| 1206 | else | 1206 | else |
| 1207 | error ("Invalid UID specification"); | 1207 | error ("Invalid UID specification"); |
| 1208 | 1208 | ||
| @@ -1215,7 +1215,7 @@ name, or nil if there is no such user. */) | |||
| 1215 | full = make_string (p, q ? q - p : strlen (p)); | 1215 | full = make_string (p, q ? q - p : strlen (p)); |
| 1216 | 1216 | ||
| 1217 | #ifdef AMPERSAND_FULL_NAME | 1217 | #ifdef AMPERSAND_FULL_NAME |
| 1218 | p = XSTRING (full)->data; | 1218 | p = SDATA (full); |
| 1219 | q = (unsigned char *) index (p, '&'); | 1219 | q = (unsigned char *) index (p, '&'); |
| 1220 | /* Substitute the login name for the &, upcasing the first character. */ | 1220 | /* Substitute the login name for the &, upcasing the first character. */ |
| 1221 | if (q) | 1221 | if (q) |
| @@ -1224,10 +1224,10 @@ name, or nil if there is no such user. */) | |||
| 1224 | Lisp_Object login; | 1224 | Lisp_Object login; |
| 1225 | 1225 | ||
| 1226 | login = Fuser_login_name (make_number (pw->pw_uid)); | 1226 | login = Fuser_login_name (make_number (pw->pw_uid)); |
| 1227 | r = (unsigned char *) alloca (strlen (p) + XSTRING (login)->size + 1); | 1227 | r = (unsigned char *) alloca (strlen (p) + SCHARS (login) + 1); |
| 1228 | bcopy (p, r, q - p); | 1228 | bcopy (p, r, q - p); |
| 1229 | r[q - p] = 0; | 1229 | r[q - p] = 0; |
| 1230 | strcat (r, XSTRING (login)->data); | 1230 | strcat (r, SDATA (login)); |
| 1231 | r[q - p] = UPCASE (r[q - p]); | 1231 | r[q - p] = UPCASE (r[q - p]); |
| 1232 | strcat (r, q + 1); | 1232 | strcat (r, q + 1); |
| 1233 | full = build_string (r); | 1233 | full = build_string (r); |
| @@ -1250,7 +1250,7 @@ char * | |||
| 1250 | get_system_name () | 1250 | get_system_name () |
| 1251 | { | 1251 | { |
| 1252 | if (STRINGP (Vsystem_name)) | 1252 | if (STRINGP (Vsystem_name)) |
| 1253 | return (char *) XSTRING (Vsystem_name)->data; | 1253 | return (char *) SDATA (Vsystem_name); |
| 1254 | else | 1254 | else |
| 1255 | return ""; | 1255 | return ""; |
| 1256 | } | 1256 | } |
| @@ -1479,7 +1479,7 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1479 | Vlocale_coding_system, 1); | 1479 | Vlocale_coding_system, 1); |
| 1480 | 1480 | ||
| 1481 | /* This is probably enough. */ | 1481 | /* This is probably enough. */ |
| 1482 | size = STRING_BYTES (XSTRING (format_string)) * 6 + 50; | 1482 | size = SBYTES (format_string) * 6 + 50; |
| 1483 | 1483 | ||
| 1484 | tm = ut ? gmtime (&value) : localtime (&value); | 1484 | tm = ut ? gmtime (&value) : localtime (&value); |
| 1485 | if (! tm) | 1485 | if (! tm) |
| @@ -1493,8 +1493,8 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1493 | int result; | 1493 | int result; |
| 1494 | 1494 | ||
| 1495 | buf[0] = '\1'; | 1495 | buf[0] = '\1'; |
| 1496 | result = emacs_memftimeu (buf, size, XSTRING (format_string)->data, | 1496 | result = emacs_memftimeu (buf, size, SDATA (format_string), |
| 1497 | STRING_BYTES (XSTRING (format_string)), | 1497 | SBYTES (format_string), |
| 1498 | tm, ut); | 1498 | tm, ut); |
| 1499 | if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) | 1499 | if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) |
| 1500 | return code_convert_string_norecord (make_string (buf, result), | 1500 | return code_convert_string_norecord (make_string (buf, result), |
| @@ -1502,8 +1502,8 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1502 | 1502 | ||
| 1503 | /* If buffer was too small, make it bigger and try again. */ | 1503 | /* If buffer was too small, make it bigger and try again. */ |
| 1504 | result = emacs_memftimeu (NULL, (size_t) -1, | 1504 | result = emacs_memftimeu (NULL, (size_t) -1, |
| 1505 | XSTRING (format_string)->data, | 1505 | SDATA (format_string), |
| 1506 | STRING_BYTES (XSTRING (format_string)), | 1506 | SBYTES (format_string), |
| 1507 | tm, ut); | 1507 | tm, ut); |
| 1508 | size = result + 1; | 1508 | size = result + 1; |
| 1509 | } | 1509 | } |
| @@ -1610,7 +1610,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1610 | if (EQ (zone, Qt)) | 1610 | if (EQ (zone, Qt)) |
| 1611 | tzstring = "UTC0"; | 1611 | tzstring = "UTC0"; |
| 1612 | else if (STRINGP (zone)) | 1612 | else if (STRINGP (zone)) |
| 1613 | tzstring = (char *) XSTRING (zone)->data; | 1613 | tzstring = (char *) SDATA (zone); |
| 1614 | else if (INTEGERP (zone)) | 1614 | else if (INTEGERP (zone)) |
| 1615 | { | 1615 | { |
| 1616 | int abszone = abs (XINT (zone)); | 1616 | int abszone = abs (XINT (zone)); |
| @@ -1788,7 +1788,7 @@ If TZ is t, use Universal Time. */) | |||
| 1788 | else | 1788 | else |
| 1789 | { | 1789 | { |
| 1790 | CHECK_STRING (tz); | 1790 | CHECK_STRING (tz); |
| 1791 | tzstring = (char *) XSTRING (tz)->data; | 1791 | tzstring = (char *) SDATA (tz); |
| 1792 | } | 1792 | } |
| 1793 | 1793 | ||
| 1794 | set_time_zone_rule (tzstring); | 1794 | set_time_zone_rule (tzstring); |
| @@ -1934,8 +1934,8 @@ general_insert_function (insert_func, insert_from_string_func, | |||
| 1934 | else if (STRINGP (val)) | 1934 | else if (STRINGP (val)) |
| 1935 | { | 1935 | { |
| 1936 | (*insert_from_string_func) (val, 0, 0, | 1936 | (*insert_from_string_func) (val, 0, 0, |
| 1937 | XSTRING (val)->size, | 1937 | SCHARS (val), |
| 1938 | STRING_BYTES (XSTRING (val)), | 1938 | SBYTES (val), |
| 1939 | inherit); | 1939 | inherit); |
| 1940 | } | 1940 | } |
| 1941 | else | 1941 | else |
| @@ -2146,7 +2146,7 @@ make_buffer_string_both (start, start_byte, end, end_byte, props) | |||
| 2146 | result = make_uninit_multibyte_string (end - start, end_byte - start_byte); | 2146 | result = make_uninit_multibyte_string (end - start, end_byte - start_byte); |
| 2147 | else | 2147 | else |
| 2148 | result = make_uninit_string (end - start); | 2148 | result = make_uninit_string (end - start); |
| 2149 | bcopy (BYTE_POS_ADDR (start_byte), XSTRING (result)->data, | 2149 | bcopy (BYTE_POS_ADDR (start_byte), SDATA (result), |
| 2150 | end_byte - start_byte); | 2150 | end_byte - start_byte); |
| 2151 | 2151 | ||
| 2152 | /* If desired, update and copy the text properties. */ | 2152 | /* If desired, update and copy the text properties. */ |
| @@ -2659,8 +2659,8 @@ It returns the number of characters changed. */) | |||
| 2659 | validate_region (&start, &end); | 2659 | validate_region (&start, &end); |
| 2660 | CHECK_STRING (table); | 2660 | CHECK_STRING (table); |
| 2661 | 2661 | ||
| 2662 | size = STRING_BYTES (XSTRING (table)); | 2662 | size = SBYTES (table); |
| 2663 | tt = XSTRING (table)->data; | 2663 | tt = SDATA (table); |
| 2664 | 2664 | ||
| 2665 | pos_byte = CHAR_TO_BYTE (XINT (start)); | 2665 | pos_byte = CHAR_TO_BYTE (XINT (start)); |
| 2666 | stop = CHAR_TO_BYTE (XINT (end)); | 2666 | stop = CHAR_TO_BYTE (XINT (end)); |
| @@ -2929,7 +2929,7 @@ usage: (message STRING &rest ARGS) */) | |||
| 2929 | { | 2929 | { |
| 2930 | register Lisp_Object val; | 2930 | register Lisp_Object val; |
| 2931 | val = Fformat (nargs, args); | 2931 | val = Fformat (nargs, args); |
| 2932 | message3 (val, STRING_BYTES (XSTRING (val)), STRING_MULTIBYTE (val)); | 2932 | message3 (val, SBYTES (val), STRING_MULTIBYTE (val)); |
| 2933 | return val; | 2933 | return val; |
| 2934 | } | 2934 | } |
| 2935 | } | 2935 | } |
| @@ -2979,13 +2979,13 @@ usage: (message-box STRING &rest ARGS) */) | |||
| 2979 | message_text = (char *)xmalloc (80); | 2979 | message_text = (char *)xmalloc (80); |
| 2980 | message_length = 80; | 2980 | message_length = 80; |
| 2981 | } | 2981 | } |
| 2982 | if (STRING_BYTES (XSTRING (val)) > message_length) | 2982 | if (SBYTES (val) > message_length) |
| 2983 | { | 2983 | { |
| 2984 | message_length = STRING_BYTES (XSTRING (val)); | 2984 | message_length = SBYTES (val); |
| 2985 | message_text = (char *)xrealloc (message_text, message_length); | 2985 | message_text = (char *)xrealloc (message_text, message_length); |
| 2986 | } | 2986 | } |
| 2987 | bcopy (XSTRING (val)->data, message_text, STRING_BYTES (XSTRING (val))); | 2987 | bcopy (SDATA (val), message_text, SBYTES (val)); |
| 2988 | message2 (message_text, STRING_BYTES (XSTRING (val)), | 2988 | message2 (message_text, SBYTES (val), |
| 2989 | STRING_MULTIBYTE (val)); | 2989 | STRING_MULTIBYTE (val)); |
| 2990 | return val; | 2990 | return val; |
| 2991 | } | 2991 | } |
| @@ -3058,7 +3058,7 @@ usage: (propertize STRING &rest PROPERTIES) */) | |||
| 3058 | } | 3058 | } |
| 3059 | 3059 | ||
| 3060 | Fadd_text_properties (make_number (0), | 3060 | Fadd_text_properties (make_number (0), |
| 3061 | make_number (XSTRING (string)->size), | 3061 | make_number (SCHARS (string)), |
| 3062 | properties, string); | 3062 | properties, string); |
| 3063 | RETURN_UNGCPRO (string); | 3063 | RETURN_UNGCPRO (string); |
| 3064 | } | 3064 | } |
| @@ -3069,9 +3069,8 @@ usage: (propertize STRING &rest PROPERTIES) */) | |||
| 3069 | 3069 | ||
| 3070 | #define CONVERTED_BYTE_SIZE(MULTIBYTE, STRING) \ | 3070 | #define CONVERTED_BYTE_SIZE(MULTIBYTE, STRING) \ |
| 3071 | (((MULTIBYTE) && ! STRING_MULTIBYTE (STRING)) \ | 3071 | (((MULTIBYTE) && ! STRING_MULTIBYTE (STRING)) \ |
| 3072 | ? count_size_as_multibyte (XSTRING (STRING)->data, \ | 3072 | ? count_size_as_multibyte (SDATA (STRING), SBYTES (STRING)) \ |
| 3073 | STRING_BYTES (XSTRING (STRING))) \ | 3073 | : SBYTES (STRING)) |
| 3074 | : STRING_BYTES (XSTRING (STRING))) | ||
| 3075 | 3074 | ||
| 3076 | DEFUN ("format", Fformat, Sformat, 1, MANY, 0, | 3075 | DEFUN ("format", Fformat, Sformat, 1, MANY, 0, |
| 3077 | doc: /* Format a string out of a control-string and arguments. | 3076 | doc: /* Format a string out of a control-string and arguments. |
| @@ -3133,8 +3132,8 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3133 | and later find it has to be multibyte, we jump back to retry. */ | 3132 | and later find it has to be multibyte, we jump back to retry. */ |
| 3134 | retry: | 3133 | retry: |
| 3135 | 3134 | ||
| 3136 | format = XSTRING (args[0])->data; | 3135 | format = SDATA (args[0]); |
| 3137 | end = format + STRING_BYTES (XSTRING (args[0])); | 3136 | end = format + SBYTES (args[0]); |
| 3138 | longest_format = 0; | 3137 | longest_format = 0; |
| 3139 | 3138 | ||
| 3140 | /* Make room in result for all the non-%-codes in the control string. */ | 3139 | /* Make room in result for all the non-%-codes in the control string. */ |
| @@ -3255,7 +3254,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3255 | goto retry; | 3254 | goto retry; |
| 3256 | } | 3255 | } |
| 3257 | args[n] = Fchar_to_string (args[n]); | 3256 | args[n] = Fchar_to_string (args[n]); |
| 3258 | thissize = STRING_BYTES (XSTRING (args[n])); | 3257 | thissize = SBYTES (args[n]); |
| 3259 | } | 3258 | } |
| 3260 | } | 3259 | } |
| 3261 | else if (FLOATP (args[n]) && *format != 's') | 3260 | else if (FLOATP (args[n]) && *format != 's') |
| @@ -3303,7 +3302,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3303 | n = 0; | 3302 | n = 0; |
| 3304 | 3303 | ||
| 3305 | /* Scan the format and store result in BUF. */ | 3304 | /* Scan the format and store result in BUF. */ |
| 3306 | format = XSTRING (args[0])->data; | 3305 | format = SDATA (args[0]); |
| 3307 | maybe_combine_byte = 0; | 3306 | maybe_combine_byte = 0; |
| 3308 | while (format != end) | 3307 | while (format != end) |
| 3309 | { | 3308 | { |
| @@ -3353,13 +3352,13 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3353 | && multibyte | 3352 | && multibyte |
| 3354 | && !ASCII_BYTE_P (*((unsigned char *) p - 1)) | 3353 | && !ASCII_BYTE_P (*((unsigned char *) p - 1)) |
| 3355 | && STRING_MULTIBYTE (args[n]) | 3354 | && STRING_MULTIBYTE (args[n]) |
| 3356 | && !CHAR_HEAD_P (XSTRING (args[n])->data[0])) | 3355 | && !CHAR_HEAD_P (SREF (args[n], 0))) |
| 3357 | maybe_combine_byte = 1; | 3356 | maybe_combine_byte = 1; |
| 3358 | nbytes = copy_text (XSTRING (args[n])->data, p, | 3357 | nbytes = copy_text (SDATA (args[n]), p, |
| 3359 | STRING_BYTES (XSTRING (args[n])), | 3358 | SBYTES (args[n]), |
| 3360 | STRING_MULTIBYTE (args[n]), multibyte); | 3359 | STRING_MULTIBYTE (args[n]), multibyte); |
| 3361 | p += nbytes; | 3360 | p += nbytes; |
| 3362 | nchars += XSTRING (args[n])->size; | 3361 | nchars += SCHARS (args[n]); |
| 3363 | end = nchars; | 3362 | end = nchars; |
| 3364 | 3363 | ||
| 3365 | if (negative) | 3364 | if (negative) |
| @@ -3371,7 +3370,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3371 | 3370 | ||
| 3372 | /* If this argument has text properties, record where | 3371 | /* If this argument has text properties, record where |
| 3373 | in the result string it appears. */ | 3372 | in the result string it appears. */ |
| 3374 | if (XSTRING (args[n])->intervals) | 3373 | if (STRING_INTERVALS (args[n])) |
| 3375 | { | 3374 | { |
| 3376 | if (!info) | 3375 | if (!info) |
| 3377 | { | 3376 | { |
| @@ -3450,19 +3449,19 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3450 | arguments has text properties, set up text properties of the | 3449 | arguments has text properties, set up text properties of the |
| 3451 | result string. */ | 3450 | result string. */ |
| 3452 | 3451 | ||
| 3453 | if (XSTRING (args[0])->intervals || info) | 3452 | if (STRING_INTERVALS (args[0]) || info) |
| 3454 | { | 3453 | { |
| 3455 | Lisp_Object len, new_len, props; | 3454 | Lisp_Object len, new_len, props; |
| 3456 | struct gcpro gcpro1; | 3455 | struct gcpro gcpro1; |
| 3457 | 3456 | ||
| 3458 | /* Add text properties from the format string. */ | 3457 | /* Add text properties from the format string. */ |
| 3459 | len = make_number (XSTRING (args[0])->size); | 3458 | len = make_number (SCHARS (args[0])); |
| 3460 | props = text_property_list (args[0], make_number (0), len, Qnil); | 3459 | props = text_property_list (args[0], make_number (0), len, Qnil); |
| 3461 | GCPRO1 (props); | 3460 | GCPRO1 (props); |
| 3462 | 3461 | ||
| 3463 | if (CONSP (props)) | 3462 | if (CONSP (props)) |
| 3464 | { | 3463 | { |
| 3465 | new_len = make_number (XSTRING (val)->size); | 3464 | new_len = make_number (SCHARS (val)); |
| 3466 | extend_property_ranges (props, len, new_len); | 3465 | extend_property_ranges (props, len, new_len); |
| 3467 | add_text_properties_from_list (val, props, make_number (0)); | 3466 | add_text_properties_from_list (val, props, make_number (0)); |
| 3468 | } | 3467 | } |
| @@ -3472,7 +3471,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3472 | for (n = 1; n < nargs; ++n) | 3471 | for (n = 1; n < nargs; ++n) |
| 3473 | if (info[n].end) | 3472 | if (info[n].end) |
| 3474 | { | 3473 | { |
| 3475 | len = make_number (XSTRING (args[n])->size); | 3474 | len = make_number (SCHARS (args[n])); |
| 3476 | new_len = make_number (info[n].end - info[n].start); | 3475 | new_len = make_number (info[n].end - info[n].start); |
| 3477 | props = text_property_list (args[n], make_number (0), len, Qnil); | 3476 | props = text_property_list (args[n], make_number (0), len, Qnil); |
| 3478 | extend_property_ranges (props, len, new_len); | 3477 | extend_property_ranges (props, len, new_len); |