Mercurial > hg > xemacs-beta
comparison src/insdel.c @ 14:9ee227acff29 r19-15b90
Import from CVS: tag r19-15b90
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:48:42 +0200 |
parents | 376386a54a3c |
children | 7e54bd776075 |
comparison
equal
deleted
inserted
replaced
13:13c6d0aaafe5 | 14:9ee227acff29 |
---|---|
498 get_string_pos_byte (Lisp_Object string, Lisp_Object pos, unsigned int flags) | 498 get_string_pos_byte (Lisp_Object string, Lisp_Object pos, unsigned int flags) |
499 { | 499 { |
500 Charcount ccpos = get_string_pos_char (string, pos, flags); | 500 Charcount ccpos = get_string_pos_char (string, pos, flags); |
501 if (ccpos < 0) /* could happen with GB_NO_ERROR_IF_BAD */ | 501 if (ccpos < 0) /* could happen with GB_NO_ERROR_IF_BAD */ |
502 return -1; | 502 return -1; |
503 return charcount_to_bytecount (string_data (XSTRING (string)), ccpos); | 503 return charcount_to_bytecount (XSTRING_DATA (string), ccpos); |
504 } | 504 } |
505 | 505 |
506 void | 506 void |
507 get_string_range_char (Lisp_Object string, Lisp_Object from, Lisp_Object to, | 507 get_string_range_char (Lisp_Object string, Lisp_Object from, Lisp_Object to, |
508 Charcount *from_out, Charcount *to_out, | 508 Charcount *from_out, Charcount *to_out, |
550 { | 550 { |
551 Charcount s, e; | 551 Charcount s, e; |
552 | 552 |
553 get_string_range_char (string, from, to, &s, &e, flags); | 553 get_string_range_char (string, from, to, &s, &e, flags); |
554 if (s >= 0) | 554 if (s >= 0) |
555 *from_out = charcount_to_bytecount (string_data (XSTRING (string)), s); | 555 *from_out = charcount_to_bytecount (XSTRING_DATA (string), s); |
556 else /* could happen with GB_NO_ERROR_IF_BAD */ | 556 else /* could happen with GB_NO_ERROR_IF_BAD */ |
557 *from_out = -1; | 557 *from_out = -1; |
558 if (e >= 0) | 558 if (e >= 0) |
559 *to_out = charcount_to_bytecount (string_data (XSTRING (string)), e); | 559 *to_out = charcount_to_bytecount (XSTRING_DATA (string), e); |
560 else | 560 else |
561 *to_out = -1; | 561 *to_out = -1; |
562 | 562 |
563 } | 563 } |
564 | 564 |
632 | 632 |
633 Bytind | 633 Bytind |
634 buffer_or_string_accessible_end_byte (Lisp_Object object) | 634 buffer_or_string_accessible_end_byte (Lisp_Object object) |
635 { | 635 { |
636 if (STRINGP (object)) | 636 if (STRINGP (object)) |
637 return string_length (XSTRING (object)); | 637 return XSTRING_LENGTH (object); |
638 return BI_BUF_ZV (XBUFFER (object)); | 638 return BI_BUF_ZV (XBUFFER (object)); |
639 } | 639 } |
640 | 640 |
641 Bufpos | 641 Bufpos |
642 buffer_or_string_absolute_begin_char (Lisp_Object object) | 642 buffer_or_string_absolute_begin_char (Lisp_Object object) |
664 | 664 |
665 Bytind | 665 Bytind |
666 buffer_or_string_absolute_end_byte (Lisp_Object object) | 666 buffer_or_string_absolute_end_byte (Lisp_Object object) |
667 { | 667 { |
668 if (STRINGP (object)) | 668 if (STRINGP (object)) |
669 return string_length (XSTRING (object)); | 669 return XSTRING_LENGTH (object); |
670 return BI_BUF_Z (XBUFFER (object)); | 670 return BI_BUF_Z (XBUFFER (object)); |
671 } | 671 } |
672 | 672 |
673 | 673 |
674 /************************************************************************/ | 674 /************************************************************************/ |
1433 if (*len < 0) | 1433 if (*len < 0) |
1434 { | 1434 { |
1435 if (nonreloc) | 1435 if (nonreloc) |
1436 *len = strlen ((CONST char *) nonreloc) - offset; | 1436 *len = strlen ((CONST char *) nonreloc) - offset; |
1437 else | 1437 else |
1438 *len = string_length (XSTRING (reloc)) - offset; | 1438 *len = XSTRING_LENGTH (reloc) - offset; |
1439 } | 1439 } |
1440 assert (*len >= 0); | 1440 assert (*len >= 0); |
1441 if (STRINGP (reloc)) | 1441 if (STRINGP (reloc)) |
1442 { | 1442 { |
1443 assert (offset >= 0 && offset <= string_length (XSTRING (reloc))); | 1443 assert (offset >= 0 && offset <= XSTRING_LENGTH (reloc)); |
1444 assert (offset + *len <= string_length (XSTRING (reloc))); | 1444 assert (offset + *len <= XSTRING_LENGTH (reloc)); |
1445 } | 1445 } |
1446 } | 1446 } |
1447 | 1447 |
1448 /* Insert a string into BUF at Bufpos POS. The string data comes | 1448 /* Insert a string into BUF at Bufpos POS. The string data comes |
1449 from one of two sources: constant, non-relocatable data (specified | 1449 from one of two sources: constant, non-relocatable data (specified |
1523 if (pos > BUF_ZV (buf)) | 1523 if (pos > BUF_ZV (buf)) |
1524 pos = BUF_ZV (buf); | 1524 pos = BUF_ZV (buf); |
1525 | 1525 |
1526 /* string may have been relocated up to this point */ | 1526 /* string may have been relocated up to this point */ |
1527 if (STRINGP (reloc)) | 1527 if (STRINGP (reloc)) |
1528 nonreloc = string_data (XSTRING (reloc)); | 1528 nonreloc = XSTRING_DATA (reloc); |
1529 | 1529 |
1530 ind = bufpos_to_bytind (buf, pos); | 1530 ind = bufpos_to_bytind (buf, pos); |
1531 cclen = bytecount_to_charcount (nonreloc + offset, length); | 1531 cclen = bytecount_to_charcount (nonreloc + offset, length); |
1532 | 1532 |
1533 if (ind != BI_BUF_GPT (buf)) | 1533 if (ind != BI_BUF_GPT (buf)) |
1542 BUF_MODIFF (buf)++; | 1542 BUF_MODIFF (buf)++; |
1543 MARK_BUFFERS_CHANGED; | 1543 MARK_BUFFERS_CHANGED; |
1544 | 1544 |
1545 /* string may have been relocated up to this point */ | 1545 /* string may have been relocated up to this point */ |
1546 if (STRINGP (reloc)) | 1546 if (STRINGP (reloc)) |
1547 nonreloc = string_data (XSTRING (reloc)); | 1547 nonreloc = XSTRING_DATA (reloc); |
1548 | 1548 |
1549 memcpy (BUF_GPT_ADDR (buf), nonreloc + offset, length); | 1549 memcpy (BUF_GPT_ADDR (buf), nonreloc + offset, length); |
1550 | 1550 |
1551 SET_BUF_GAP_SIZE (buf, BUF_GAP_SIZE (buf) - length); | 1551 SET_BUF_GAP_SIZE (buf, BUF_GAP_SIZE (buf) - length); |
1552 SET_BI_BUF_GPT (buf, BI_BUF_GPT (buf) + length); | 1552 SET_BI_BUF_GPT (buf, BI_BUF_GPT (buf) + length); |
1608 int flags) | 1608 int flags) |
1609 { | 1609 { |
1610 /* This function can GC */ | 1610 /* This function can GC */ |
1611 assert (STRINGP (str)); | 1611 assert (STRINGP (str)); |
1612 return buffer_insert_string_1 (buf, pos, 0, str, 0, | 1612 return buffer_insert_string_1 (buf, pos, 0, str, 0, |
1613 string_length (XSTRING (str)), | 1613 XSTRING_LENGTH (str), |
1614 flags); | 1614 flags); |
1615 } | 1615 } |
1616 | 1616 |
1617 /* Insert the null-terminated string S (in external format). */ | 1617 /* Insert the null-terminated string S (in external format). */ |
1618 | 1618 |
1654 Charcount length, int flags) | 1654 Charcount length, int flags) |
1655 { | 1655 { |
1656 /* This function can GC */ | 1656 /* This function can GC */ |
1657 Lisp_Object str = make_string_from_buffer (buf2, pos2, length); | 1657 Lisp_Object str = make_string_from_buffer (buf2, pos2, length); |
1658 return buffer_insert_string_1 (buf, pos, 0, str, 0, | 1658 return buffer_insert_string_1 (buf, pos, 0, str, 0, |
1659 string_length (XSTRING (str)), flags); | 1659 XSTRING_LENGTH (str), flags); |
1660 } | 1660 } |
1661 | 1661 |
1662 | 1662 |
1663 /************************************************************************/ | 1663 /************************************************************************/ |
1664 /* Deletion of ranges */ | 1664 /* Deletion of ranges */ |
1876 add_string_extents (val, buf, bi_ind, bi_len); | 1876 add_string_extents (val, buf, bi_ind, bi_len); |
1877 | 1877 |
1878 { | 1878 { |
1879 Bytecount len1 = BI_BUF_GPT (buf) - bi_ind; | 1879 Bytecount len1 = BI_BUF_GPT (buf) - bi_ind; |
1880 Bufbyte *start1 = BI_BUF_BYTE_ADDRESS (buf, bi_ind); | 1880 Bufbyte *start1 = BI_BUF_BYTE_ADDRESS (buf, bi_ind); |
1881 Bufbyte *dest = string_data (XSTRING (val)); | 1881 Bufbyte *dest = XSTRING_DATA (val); |
1882 | 1882 |
1883 if (len1 < 0) | 1883 if (len1 < 0) |
1884 { | 1884 { |
1885 /* Completely after gap */ | 1885 /* Completely after gap */ |
1886 memcpy (dest, start1, bi_len); | 1886 memcpy (dest, start1, bi_len); |