comparison src/doc.c @ 21244:50929073a0ba

Use STRING_BYTES and SET_STRING_BYTES.
author Richard M. Stallman <rms@gnu.org>
date Sat, 21 Mar 1998 07:06:14 +0000
parents 8cd0a6343a84
children fce0c8c246d1
comparison
equal deleted inserted replaced
21243:e82a4a4fa12a 21244:50929073a0ba
560 or from a \\<mapname> construct in STRING itself.. */ 560 or from a \\<mapname> construct in STRING itself.. */
561 keymap = current_kboard->Voverriding_terminal_local_map; 561 keymap = current_kboard->Voverriding_terminal_local_map;
562 if (NILP (keymap)) 562 if (NILP (keymap))
563 keymap = Voverriding_local_map; 563 keymap = Voverriding_local_map;
564 564
565 bsize = XSTRING (string)->size_byte; 565 bsize = STRING_BYTES (XSTRING (string));
566 bufp = buf = (unsigned char *) xmalloc (bsize); 566 bufp = buf = (unsigned char *) xmalloc (bsize);
567 567
568 strp = (unsigned char *) XSTRING (string)->data; 568 strp = (unsigned char *) XSTRING (string)->data;
569 while (strp < XSTRING (string)->data + XSTRING (string)->size_byte) 569 while (strp < XSTRING (string)->data + STRING_BYTES (XSTRING (string)))
570 { 570 {
571 if (strp[0] == '\\' && strp[1] == '=') 571 if (strp[0] == '\\' && strp[1] == '=')
572 { 572 {
573 /* \= quotes the next character; 573 /* \= quotes the next character;
574 thus, to put in \[ without its special meaning, use \=\[. */ 574 thus, to put in \[ without its special meaning, use \=\[. */
575 changed = 1; 575 changed = 1;
576 strp += 2; 576 strp += 2;
577 if (multibyte) 577 if (multibyte)
578 { 578 {
579 int len; 579 int len;
580 int maxlen = XSTRING (string)->data + XSTRING (string)->size_byte - strp; 580 int maxlen = XSTRING (string)->data + STRING_BYTES (XSTRING (string)) - strp;
581 581
582 STRING_CHAR_AND_LENGTH (strp, maxlen, len); 582 STRING_CHAR_AND_LENGTH (strp, maxlen, len);
583 if (len == 1) 583 if (len == 1)
584 *bufp = *strp; 584 *bufp = *strp;
585 else 585 else
598 changed = 1; 598 changed = 1;
599 strp += 2; /* skip \[ */ 599 strp += 2; /* skip \[ */
600 start = strp; 600 start = strp;
601 601
602 while ((strp - (unsigned char *) XSTRING (string)->data 602 while ((strp - (unsigned char *) XSTRING (string)->data
603 < XSTRING (string)->size_byte) 603 < STRING_BYTES (XSTRING (string)))
604 && *strp != ']') 604 && *strp != ']')
605 strp++; 605 strp++;
606 length_byte = strp - start; 606 length_byte = strp - start;
607 607
608 strp++; /* skip ] */ 608 strp++; /* skip ] */
683 { 683 {
684 name = Fsymbol_name (name); 684 name = Fsymbol_name (name);
685 insert_string ("\nUses keymap \""); 685 insert_string ("\nUses keymap \"");
686 insert_from_string (name, 0, 0, 686 insert_from_string (name, 0, 0,
687 XSTRING (name)->size, 687 XSTRING (name)->size,
688 XSTRING (name)->size_byte, 1); 688 STRING_BYTES (XSTRING (name)), 1);
689 insert_string ("\", which is not currently defined.\n"); 689 insert_string ("\", which is not currently defined.\n");
690 if (start[-1] == '<') keymap = Qnil; 690 if (start[-1] == '<') keymap = Qnil;
691 } 691 }
692 else if (start[-1] == '<') 692 else if (start[-1] == '<')
693 keymap = tem; 693 keymap = tem;
698 set_buffer_internal (oldbuf); 698 set_buffer_internal (oldbuf);
699 699
700 subst_string: 700 subst_string:
701 start = XSTRING (tem)->data; 701 start = XSTRING (tem)->data;
702 length = XSTRING (tem)->size; 702 length = XSTRING (tem)->size;
703 length_byte = XSTRING (tem)->size_byte; 703 length_byte = STRING_BYTES (XSTRING (tem));
704 subst: 704 subst:
705 new = (unsigned char *) xrealloc (buf, bsize += length_byte); 705 new = (unsigned char *) xrealloc (buf, bsize += length_byte);
706 bufp += new - buf; 706 bufp += new - buf;
707 buf = new; 707 buf = new;
708 bcopy (start, bufp, length_byte); 708 bcopy (start, bufp, length_byte);
714 else if (! multibyte) /* just copy other chars */ 714 else if (! multibyte) /* just copy other chars */
715 *bufp++ = *strp++, nchars++; 715 *bufp++ = *strp++, nchars++;
716 else 716 else
717 { 717 {
718 int len; 718 int len;
719 int maxlen = XSTRING (string)->data + XSTRING (string)->size_byte - strp; 719 int maxlen = XSTRING (string)->data + STRING_BYTES (XSTRING (string)) - strp;
720 720
721 STRING_CHAR_AND_LENGTH (strp, maxlen, len); 721 STRING_CHAR_AND_LENGTH (strp, maxlen, len);
722 if (len == 1) 722 if (len == 1)
723 *bufp = *strp; 723 *bufp = *strp;
724 else 724 else