aboutsummaryrefslogtreecommitdiffstats
path: root/src/insdel.c
diff options
context:
space:
mode:
authorPaul Eggert2011-05-20 21:33:23 -0700
committerPaul Eggert2011-05-20 21:33:23 -0700
commitde883a701d8f0db9595c6c459fdff9e3bb20bc83 (patch)
treeaba160bb28d92c3fbec56549e211bd1f705b273e /src/insdel.c
parent1dcf791fefa6533a06f58a5d2d074f59f06ee9ae (diff)
downloademacs-de883a701d8f0db9595c6c459fdff9e3bb20bc83.tar.gz
emacs-de883a701d8f0db9595c6c459fdff9e3bb20bc83.zip
merge count_size_as_multibyte, parse_str_to_multibyte
* character.c, character.h (count_size_as_multibyte): Renamed from parse_str_to_multibyte; all uses changed. Check for integer overflow. * insdel.c, lisp.h (count_size_as_multibyte): Remove, since it's now a duplicate of the other. This is more of a character than a buffer op, so better that it's in character.c. * fns.c, print.c: Adjust to above changes.
Diffstat (limited to 'src/insdel.c')
-rw-r--r--src/insdel.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/insdel.c b/src/insdel.c
index de9e8aa570a..c0cccc65d6a 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -570,37 +570,6 @@ copy_text (const unsigned char *from_addr, unsigned char *to_addr,
570 return to_addr - initial_to_addr; 570 return to_addr - initial_to_addr;
571 } 571 }
572} 572}
573
574/* Return the number of bytes it would take
575 to convert some single-byte text to multibyte.
576 The single-byte text consists of NBYTES bytes at PTR. */
577
578EMACS_INT
579count_size_as_multibyte (const unsigned char *ptr, EMACS_INT nbytes)
580{
581 EMACS_INT i;
582 EMACS_INT outgoing_nbytes = 0;
583
584 for (i = 0; i < nbytes; i++)
585 {
586 unsigned int c = *ptr++;
587 int n;
588
589 if (ASCII_CHAR_P (c))
590 n = 1;
591 else
592 {
593 c = BYTE8_TO_CHAR (c);
594 n = CHAR_BYTES (c);
595 }
596
597 if (INT_ADD_OVERFLOW (outgoing_nbytes, n))
598 string_overflow ();
599 outgoing_nbytes += n;
600 }
601
602 return outgoing_nbytes;
603}
604 573
605/* Insert a string of specified length before point. 574/* Insert a string of specified length before point.
606 This function judges multibyteness based on 575 This function judges multibyteness based on