aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c108
1 files changed, 53 insertions, 55 deletions
diff --git a/src/editfns.c b/src/editfns.c
index fa57edead28..a14e043c1bf 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -65,7 +65,7 @@ extern Lisp_Object w32_get_internal_run_time (void);
65#endif 65#endif
66 66
67static Lisp_Object format_time_string (char const *, ptrdiff_t, EMACS_TIME, 67static Lisp_Object format_time_string (char const *, ptrdiff_t, EMACS_TIME,
68 int, struct tm *); 68 bool, struct tm *);
69static int tm_diff (struct tm *, struct tm *); 69static int tm_diff (struct tm *, struct tm *);
70static void update_buffer_properties (ptrdiff_t, ptrdiff_t); 70static void update_buffer_properties (ptrdiff_t, ptrdiff_t);
71 71
@@ -246,11 +246,11 @@ The return value is POSITION. */)
246 246
247 247
248/* Return the start or end position of the region. 248/* Return the start or end position of the region.
249 BEGINNINGP non-zero means return the start. 249 BEGINNINGP means return the start.
250 If there is no region active, signal an error. */ 250 If there is no region active, signal an error. */
251 251
252static Lisp_Object 252static Lisp_Object
253region_limit (int beginningp) 253region_limit (bool beginningp)
254{ 254{
255 Lisp_Object m; 255 Lisp_Object m;
256 256
@@ -264,7 +264,7 @@ region_limit (int beginningp)
264 error ("The mark is not set now, so there is no region"); 264 error ("The mark is not set now, so there is no region");
265 265
266 /* Clip to the current narrowing (bug#11770). */ 266 /* Clip to the current narrowing (bug#11770). */
267 return make_number ((PT < XFASTINT (m)) == (beginningp != 0) 267 return make_number ((PT < XFASTINT (m)) == beginningp
268 ? PT 268 ? PT
269 : clip_to_bounds (BEGV, XFASTINT (m), ZV)); 269 : clip_to_bounds (BEGV, XFASTINT (m), ZV));
270} 270}
@@ -435,12 +435,12 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
435 BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned 435 BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned
436 results; they do not effect boundary behavior. 436 results; they do not effect boundary behavior.
437 437
438 If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very first 438 If MERGE_AT_BOUNDARY is non-nil, then if POS is at the very first
439 position of a field, then the beginning of the previous field is 439 position of a field, then the beginning of the previous field is
440 returned instead of the beginning of POS's field (since the end of a 440 returned instead of the beginning of POS's field (since the end of a
441 field is actually also the beginning of the next input field, this 441 field is actually also the beginning of the next input field, this
442 behavior is sometimes useful). Additionally in the MERGE_AT_BOUNDARY 442 behavior is sometimes useful). Additionally in the MERGE_AT_BOUNDARY
443 true case, if two fields are separated by a field with the special 443 non-nil case, if two fields are separated by a field with the special
444 value `boundary', and POS lies within it, then the two separated 444 value `boundary', and POS lies within it, then the two separated
445 fields are considered to be adjacent, and POS between them, when 445 fields are considered to be adjacent, and POS between them, when
446 finding the beginning and ending of the "merged" field. 446 finding the beginning and ending of the "merged" field.
@@ -455,10 +455,10 @@ find_field (Lisp_Object pos, Lisp_Object merge_at_boundary,
455{ 455{
456 /* Fields right before and after the point. */ 456 /* Fields right before and after the point. */
457 Lisp_Object before_field, after_field; 457 Lisp_Object before_field, after_field;
458 /* 1 if POS counts as the start of a field. */ 458 /* True if POS counts as the start of a field. */
459 int at_field_start = 0; 459 bool at_field_start = 0;
460 /* 1 if POS counts as the end of a field. */ 460 /* True if POS counts as the end of a field. */
461 int at_field_end = 0; 461 bool at_field_end = 0;
462 462
463 if (NILP (pos)) 463 if (NILP (pos))
464 XSETFASTINT (pos, PT); 464 XSETFASTINT (pos, PT);
@@ -502,19 +502,19 @@ find_field (Lisp_Object pos, Lisp_Object merge_at_boundary,
502 502
503 xxxx.yyyy 503 xxxx.yyyy
504 504
505 In this situation, if merge_at_boundary is true, we consider the 505 In this situation, if merge_at_boundary is non-nil, consider the
506 `x' and `y' fields as forming one big merged field, and so the end 506 `x' and `y' fields as forming one big merged field, and so the end
507 of the field is the end of `y'. 507 of the field is the end of `y'.
508 508
509 However, if `x' and `y' are separated by a special `boundary' field 509 However, if `x' and `y' are separated by a special `boundary' field
510 (a field with a `field' char-property of 'boundary), then we ignore 510 (a field with a `field' char-property of 'boundary), then ignore
511 this special field when merging adjacent fields. Here's the same 511 this special field when merging adjacent fields. Here's the same
512 situation, but with a `boundary' field between the `x' and `y' fields: 512 situation, but with a `boundary' field between the `x' and `y' fields:
513 513
514 xxx.BBBByyyy 514 xxx.BBBByyyy
515 515
516 Here, if point is at the end of `x', the beginning of `y', or 516 Here, if point is at the end of `x', the beginning of `y', or
517 anywhere in-between (within the `boundary' field), we merge all 517 anywhere in-between (within the `boundary' field), merge all
518 three fields and consider the beginning as being the beginning of 518 three fields and consider the beginning as being the beginning of
519 the `x' field, and the end as being the end of the `y' field. */ 519 the `x' field, and the end as being the end of the `y' field. */
520 520
@@ -658,7 +658,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
658{ 658{
659 /* If non-zero, then the original point, before re-positioning. */ 659 /* If non-zero, then the original point, before re-positioning. */
660 ptrdiff_t orig_point = 0; 660 ptrdiff_t orig_point = 0;
661 int fwd; 661 bool fwd;
662 Lisp_Object prev_old, prev_new; 662 Lisp_Object prev_old, prev_new;
663 663
664 if (NILP (new_pos)) 664 if (NILP (new_pos))
@@ -816,8 +816,8 @@ This function does not move point. */)
816Lisp_Object 816Lisp_Object
817save_excursion_save (void) 817save_excursion_save (void)
818{ 818{
819 int visible = (XBUFFER (XWINDOW (selected_window)->buffer) 819 bool visible = (XBUFFER (XWINDOW (selected_window)->buffer)
820 == current_buffer); 820 == current_buffer);
821 821
822 return Fcons (Fpoint_marker (), 822 return Fcons (Fpoint_marker (),
823 Fcons (Fcopy_marker (BVAR (current_buffer, mark), Qnil), 823 Fcons (Fcopy_marker (BVAR (current_buffer, mark), Qnil),
@@ -831,7 +831,7 @@ save_excursion_restore (Lisp_Object info)
831{ 831{
832 Lisp_Object tem, tem1, omark, nmark; 832 Lisp_Object tem, tem1, omark, nmark;
833 struct gcpro gcpro1, gcpro2, gcpro3; 833 struct gcpro gcpro1, gcpro2, gcpro3;
834 int visible_p; 834 bool visible_p;
835 835
836 tem = Fmarker_buffer (XCAR (info)); 836 tem = Fmarker_buffer (XCAR (info));
837 /* If buffer being returned to is now deleted, avoid error */ 837 /* If buffer being returned to is now deleted, avoid error */
@@ -946,13 +946,10 @@ BODY is executed just like `progn'.
946usage: (save-current-buffer &rest BODY) */) 946usage: (save-current-buffer &rest BODY) */)
947 (Lisp_Object args) 947 (Lisp_Object args)
948{ 948{
949 Lisp_Object val;
950 ptrdiff_t count = SPECPDL_INDEX (); 949 ptrdiff_t count = SPECPDL_INDEX ();
951 950
952 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 951 record_unwind_current_buffer ();
953 952 return unbind_to (count, Fprogn (args));
954 val = Fprogn (args);
955 return unbind_to (count, val);
956} 953}
957 954
958DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0, 955DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0,
@@ -1470,8 +1467,8 @@ make_lisp_time (EMACS_TIME t)
1470 1467
1471/* Decode a Lisp list SPECIFIED_TIME that represents a time. 1468/* Decode a Lisp list SPECIFIED_TIME that represents a time.
1472 Set *PHIGH, *PLOW, *PUSEC, *PPSEC to its parts; do not check their values. 1469 Set *PHIGH, *PLOW, *PUSEC, *PPSEC to its parts; do not check their values.
1473 Return nonzero if successful. */ 1470 Return true if successful. */
1474static int 1471static bool
1475disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh, 1472disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh,
1476 Lisp_Object *plow, Lisp_Object *pusec, 1473 Lisp_Object *plow, Lisp_Object *pusec,
1477 Lisp_Object *ppsec) 1474 Lisp_Object *ppsec)
@@ -1514,8 +1511,8 @@ disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh,
1514 If *DRESULT is not null, store into *DRESULT the number of 1511 If *DRESULT is not null, store into *DRESULT the number of
1515 seconds since the start of the POSIX Epoch. 1512 seconds since the start of the POSIX Epoch.
1516 1513
1517 Return nonzero if successful. */ 1514 Return true if successful. */
1518int 1515bool
1519decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec, 1516decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec,
1520 Lisp_Object psec, 1517 Lisp_Object psec,
1521 EMACS_TIME *result, double *dresult) 1518 EMACS_TIME *result, double *dresult)
@@ -1635,7 +1632,7 @@ or (if you need time as a string) `format-time-string'. */)
1635 1632
1636/* Write information into buffer S of size MAXSIZE, according to the 1633/* Write information into buffer S of size MAXSIZE, according to the
1637 FORMAT of length FORMAT_LEN, using time information taken from *TP. 1634 FORMAT of length FORMAT_LEN, using time information taken from *TP.
1638 Default to Universal Time if UT is nonzero, local time otherwise. 1635 Default to Universal Time if UT, local time otherwise.
1639 Use NS as the number of nanoseconds in the %N directive. 1636 Use NS as the number of nanoseconds in the %N directive.
1640 Return the number of bytes written, not including the terminating 1637 Return the number of bytes written, not including the terminating
1641 '\0'. If S is NULL, nothing will be written anywhere; so to 1638 '\0'. If S is NULL, nothing will be written anywhere; so to
@@ -1646,7 +1643,7 @@ or (if you need time as a string) `format-time-string'. */)
1646 bytes in FORMAT and it does not support nanoseconds. */ 1643 bytes in FORMAT and it does not support nanoseconds. */
1647static size_t 1644static size_t
1648emacs_nmemftime (char *s, size_t maxsize, const char *format, 1645emacs_nmemftime (char *s, size_t maxsize, const char *format,
1649 size_t format_len, const struct tm *tp, int ut, int ns) 1646 size_t format_len, const struct tm *tp, bool ut, int ns)
1650{ 1647{
1651 size_t total = 0; 1648 size_t total = 0;
1652 1649
@@ -1751,7 +1748,7 @@ usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */)
1751 1748
1752static Lisp_Object 1749static Lisp_Object
1753format_time_string (char const *format, ptrdiff_t formatlen, 1750format_time_string (char const *format, ptrdiff_t formatlen,
1754 EMACS_TIME t, int ut, struct tm *tmp) 1751 EMACS_TIME t, bool ut, struct tm *tmp)
1755{ 1752{
1756 char buffer[4000]; 1753 char buffer[4000];
1757 char *buf = buffer; 1754 char *buf = buffer;
@@ -2231,11 +2228,11 @@ general_insert_function (void (*insert_func)
2231 (const char *, ptrdiff_t), 2228 (const char *, ptrdiff_t),
2232 void (*insert_from_string_func) 2229 void (*insert_from_string_func)
2233 (Lisp_Object, ptrdiff_t, ptrdiff_t, 2230 (Lisp_Object, ptrdiff_t, ptrdiff_t,
2234 ptrdiff_t, ptrdiff_t, int), 2231 ptrdiff_t, ptrdiff_t, bool),
2235 int inherit, ptrdiff_t nargs, Lisp_Object *args) 2232 bool inherit, ptrdiff_t nargs, Lisp_Object *args)
2236{ 2233{
2237 ptrdiff_t argnum; 2234 ptrdiff_t argnum;
2238 register Lisp_Object val; 2235 Lisp_Object val;
2239 2236
2240 for (argnum = 0; argnum < nargs; argnum++) 2237 for (argnum = 0; argnum < nargs; argnum++)
2241 { 2238 {
@@ -2458,7 +2455,7 @@ from adjoining text, if those properties are sticky. */)
2458/* Return a Lisp_String containing the text of the current buffer from 2455/* Return a Lisp_String containing the text of the current buffer from
2459 START to END. If text properties are in use and the current buffer 2456 START to END. If text properties are in use and the current buffer
2460 has properties in the range specified, the resulting string will also 2457 has properties in the range specified, the resulting string will also
2461 have them, if PROPS is nonzero. 2458 have them, if PROPS is true.
2462 2459
2463 We don't want to use plain old make_string here, because it calls 2460 We don't want to use plain old make_string here, because it calls
2464 make_uninit_string, which can cause the buffer arena to be 2461 make_uninit_string, which can cause the buffer arena to be
@@ -2469,7 +2466,7 @@ from adjoining text, if those properties are sticky. */)
2469 buffer substrings. */ 2466 buffer substrings. */
2470 2467
2471Lisp_Object 2468Lisp_Object
2472make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props) 2469make_buffer_string (ptrdiff_t start, ptrdiff_t end, bool props)
2473{ 2470{
2474 ptrdiff_t start_byte = CHAR_TO_BYTE (start); 2471 ptrdiff_t start_byte = CHAR_TO_BYTE (start);
2475 ptrdiff_t end_byte = CHAR_TO_BYTE (end); 2472 ptrdiff_t end_byte = CHAR_TO_BYTE (end);
@@ -2482,7 +2479,7 @@ make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props)
2482 2479
2483 If text properties are in use and the current buffer 2480 If text properties are in use and the current buffer
2484 has properties in the range specified, the resulting string will also 2481 has properties in the range specified, the resulting string will also
2485 have them, if PROPS is nonzero. 2482 have them, if PROPS is true.
2486 2483
2487 We don't want to use plain old make_string here, because it calls 2484 We don't want to use plain old make_string here, because it calls
2488 make_uninit_string, which can cause the buffer arena to be 2485 make_uninit_string, which can cause the buffer arena to be
@@ -2494,7 +2491,7 @@ make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props)
2494 2491
2495Lisp_Object 2492Lisp_Object
2496make_buffer_string_both (ptrdiff_t start, ptrdiff_t start_byte, 2493make_buffer_string_both (ptrdiff_t start, ptrdiff_t start_byte,
2497 ptrdiff_t end, ptrdiff_t end_byte, int props) 2494 ptrdiff_t end, ptrdiff_t end_byte, bool props)
2498{ 2495{
2499 Lisp_Object result, tem, tem1; 2496 Lisp_Object result, tem, tem1;
2500 2497
@@ -2845,7 +2842,8 @@ Both characters must have the same length of multi-byte form. */)
2845#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER) 2842#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER)
2846 int maybe_byte_combining = COMBINING_NO; 2843 int maybe_byte_combining = COMBINING_NO;
2847 ptrdiff_t last_changed = 0; 2844 ptrdiff_t last_changed = 0;
2848 int multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 2845 bool multibyte_p
2846 = !NILP (BVAR (current_buffer, enable_multibyte_characters));
2849 int fromc, toc; 2847 int fromc, toc;
2850 2848
2851 restart: 2849 restart:
@@ -3081,8 +3079,8 @@ It returns the number of characters changed. */)
3081 int cnt; /* Number of changes made. */ 3079 int cnt; /* Number of changes made. */
3082 ptrdiff_t size; /* Size of translate table. */ 3080 ptrdiff_t size; /* Size of translate table. */
3083 ptrdiff_t pos, pos_byte, end_pos; 3081 ptrdiff_t pos, pos_byte, end_pos;
3084 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 3082 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
3085 int string_multibyte IF_LINT (= 0); 3083 bool string_multibyte IF_LINT (= 0);
3086 3084
3087 validate_region (&start, &end); 3085 validate_region (&start, &end);
3088 if (CHAR_TABLE_P (table)) 3086 if (CHAR_TABLE_P (table))
@@ -3642,20 +3640,20 @@ usage: (format STRING &rest OBJECTS) */)
3642 ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1; 3640 ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1;
3643 char *p; 3641 char *p;
3644 Lisp_Object buf_save_value IF_LINT (= {0}); 3642 Lisp_Object buf_save_value IF_LINT (= {0});
3645 register char *format, *end, *format_start; 3643 char *format, *end, *format_start;
3646 ptrdiff_t formatlen, nchars; 3644 ptrdiff_t formatlen, nchars;
3647 /* Nonzero if the format is multibyte. */ 3645 /* True if the format is multibyte. */
3648 int multibyte_format = 0; 3646 bool multibyte_format = 0;
3649 /* Nonzero if the output should be a multibyte string, 3647 /* True if the output should be a multibyte string,
3650 which is true if any of the inputs is one. */ 3648 which is true if any of the inputs is one. */
3651 int multibyte = 0; 3649 bool multibyte = 0;
3652 /* When we make a multibyte string, we must pay attention to the 3650 /* When we make a multibyte string, we must pay attention to the
3653 byte combining problem, i.e., a byte may be combined with a 3651 byte combining problem, i.e., a byte may be combined with a
3654 multibyte character of the previous string. This flag tells if we 3652 multibyte character of the previous string. This flag tells if we
3655 must consider such a situation or not. */ 3653 must consider such a situation or not. */
3656 int maybe_combine_byte; 3654 bool maybe_combine_byte;
3657 Lisp_Object val; 3655 Lisp_Object val;
3658 int arg_intervals = 0; 3656 bool arg_intervals = 0;
3659 USE_SAFE_ALLOCA; 3657 USE_SAFE_ALLOCA;
3660 3658
3661 /* discarded[I] is 1 if byte I of the format 3659 /* discarded[I] is 1 if byte I of the format
@@ -3671,8 +3669,8 @@ usage: (format STRING &rest OBJECTS) */)
3671 struct info 3669 struct info
3672 { 3670 {
3673 ptrdiff_t start, end; 3671 ptrdiff_t start, end;
3674 int converted_to_string; 3672 unsigned converted_to_string : 1;
3675 int intervals; 3673 unsigned intervals : 1;
3676 } *info = 0; 3674 } *info = 0;
3677 3675
3678 /* It should not be necessary to GCPRO ARGS, because 3676 /* It should not be necessary to GCPRO ARGS, because
@@ -3749,13 +3747,13 @@ usage: (format STRING &rest OBJECTS) */)
3749 digits to print after the '.' for floats, or the max. 3747 digits to print after the '.' for floats, or the max.
3750 number of chars to print from a string. */ 3748 number of chars to print from a string. */
3751 3749
3752 int minus_flag = 0; 3750 bool minus_flag = 0;
3753 int plus_flag = 0; 3751 bool plus_flag = 0;
3754 int space_flag = 0; 3752 bool space_flag = 0;
3755 int sharp_flag = 0; 3753 bool sharp_flag = 0;
3756 int zero_flag = 0; 3754 bool zero_flag = 0;
3757 ptrdiff_t field_width; 3755 ptrdiff_t field_width;
3758 int precision_given; 3756 bool precision_given;
3759 uintmax_t precision = UINTMAX_MAX; 3757 uintmax_t precision = UINTMAX_MAX;
3760 char *num_end; 3758 char *num_end;
3761 char conversion; 3759 char conversion;
@@ -4135,7 +4133,7 @@ usage: (format STRING &rest OBJECTS) */)
4135 char *src = sprintf_buf; 4133 char *src = sprintf_buf;
4136 char src0 = src[0]; 4134 char src0 = src[0];
4137 int exponent_bytes = 0; 4135 int exponent_bytes = 0;
4138 int signedp = src0 == '-' || src0 == '+' || src0 == ' '; 4136 bool signedp = src0 == '-' || src0 == '+' || src0 == ' ';
4139 int significand_bytes; 4137 int significand_bytes;
4140 if (zero_flag 4138 if (zero_flag
4141 && ((src[signedp] >= '0' && src[signedp] <= '9') 4139 && ((src[signedp] >= '0' && src[signedp] <= '9')