comparison src/doc.c @ 46370:40db0673e6f0

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.
author Ken Raeburn <raeburn@raeburn.org>
date Mon, 15 Jul 2002 00:00:41 +0000
parents 65ad2c8b301b
children 23a1cea22d13
comparison
equal deleted inserted replaced
46369:dd1d3b1d0053 46370:40db0673e6f0
156 If it is relative, combine it with Vdoc_directory. */ 156 If it is relative, combine it with Vdoc_directory. */
157 157
158 tem = Ffile_name_absolute_p (file); 158 tem = Ffile_name_absolute_p (file);
159 if (NILP (tem)) 159 if (NILP (tem))
160 { 160 {
161 minsize = XSTRING (Vdoc_directory)->size; 161 minsize = SCHARS (Vdoc_directory);
162 /* sizeof ("../etc/") == 8 */ 162 /* sizeof ("../etc/") == 8 */
163 if (minsize < 8) 163 if (minsize < 8)
164 minsize = 8; 164 minsize = 8;
165 name = (char *) alloca (minsize + XSTRING (file)->size + 8); 165 name = (char *) alloca (minsize + SCHARS (file) + 8);
166 strcpy (name, XSTRING (Vdoc_directory)->data); 166 strcpy (name, SDATA (Vdoc_directory));
167 strcat (name, XSTRING (file)->data); 167 strcat (name, SDATA (file));
168 munge_doc_file_name (name); 168 munge_doc_file_name (name);
169 } 169 }
170 else 170 else
171 { 171 {
172 name = (char *) XSTRING (file)->data; 172 name = (char *) SDATA (file);
173 } 173 }
174 174
175 fd = emacs_open (name, O_RDONLY, 0); 175 fd = emacs_open (name, O_RDONLY, 0);
176 if (fd < 0) 176 if (fd < 0)
177 { 177 {
179 if (!NILP (Vpurify_flag)) 179 if (!NILP (Vpurify_flag))
180 { 180 {
181 /* Preparing to dump; DOC file is probably not installed. 181 /* Preparing to dump; DOC file is probably not installed.
182 So check in ../etc. */ 182 So check in ../etc. */
183 strcpy (name, "../etc/"); 183 strcpy (name, "../etc/");
184 strcat (name, XSTRING (file)->data); 184 strcat (name, SDATA (file));
185 munge_doc_file_name (name); 185 munge_doc_file_name (name);
186 186
187 fd = emacs_open (name, O_RDONLY, 0); 187 fd = emacs_open (name, O_RDONLY, 0);
188 } 188 }
189 #endif 189 #endif
588 (!NILP (Vpurify_flag)) 588 (!NILP (Vpurify_flag))
589 #else /* CANNOT_DUMP */ 589 #else /* CANNOT_DUMP */
590 (0) 590 (0)
591 #endif /* CANNOT_DUMP */ 591 #endif /* CANNOT_DUMP */
592 { 592 {
593 name = (char *) alloca (XSTRING (filename)->size + 14); 593 name = (char *) alloca (SCHARS (filename) + 14);
594 strcpy (name, "../etc/"); 594 strcpy (name, "../etc/");
595 } 595 }
596 else 596 else
597 { 597 {
598 CHECK_STRING (Vdoc_directory); 598 CHECK_STRING (Vdoc_directory);
599 name = (char *) alloca (XSTRING (filename)->size 599 name = (char *) alloca (SCHARS (filename)
600 + XSTRING (Vdoc_directory)->size + 1); 600 + SCHARS (Vdoc_directory) + 1);
601 strcpy (name, XSTRING (Vdoc_directory)->data); 601 strcpy (name, SDATA (Vdoc_directory));
602 } 602 }
603 strcat (name, XSTRING (filename)->data); /*** Add this line ***/ 603 strcat (name, SDATA (filename)); /*** Add this line ***/
604 #ifdef VMS 604 #ifdef VMS
605 #ifndef VMS4_4 605 #ifndef VMS4_4
606 /* For VMS versions with limited file name syntax, 606 /* For VMS versions with limited file name syntax,
607 convert the name to something VMS will allow. */ 607 convert the name to something VMS will allow. */
608 p = name; 608 p = name;
720 or from a \\<mapname> construct in STRING itself.. */ 720 or from a \\<mapname> construct in STRING itself.. */
721 keymap = current_kboard->Voverriding_terminal_local_map; 721 keymap = current_kboard->Voverriding_terminal_local_map;
722 if (NILP (keymap)) 722 if (NILP (keymap))
723 keymap = Voverriding_local_map; 723 keymap = Voverriding_local_map;
724 724
725 bsize = STRING_BYTES (XSTRING (string)); 725 bsize = SBYTES (string);
726 bufp = buf = (unsigned char *) xmalloc (bsize); 726 bufp = buf = (unsigned char *) xmalloc (bsize);
727 727
728 strp = (unsigned char *) XSTRING (string)->data; 728 strp = (unsigned char *) SDATA (string);
729 while (strp < XSTRING (string)->data + STRING_BYTES (XSTRING (string))) 729 while (strp < SDATA (string) + SBYTES (string))
730 { 730 {
731 if (strp[0] == '\\' && strp[1] == '=') 731 if (strp[0] == '\\' && strp[1] == '=')
732 { 732 {
733 /* \= quotes the next character; 733 /* \= quotes the next character;
734 thus, to put in \[ without its special meaning, use \=\[. */ 734 thus, to put in \[ without its special meaning, use \=\[. */
735 changed = 1; 735 changed = 1;
736 strp += 2; 736 strp += 2;
737 if (multibyte) 737 if (multibyte)
738 { 738 {
739 int len; 739 int len;
740 int maxlen = XSTRING (string)->data + STRING_BYTES (XSTRING (string)) - strp; 740 int maxlen = SDATA (string) + SBYTES (string) - strp;
741 741
742 STRING_CHAR_AND_LENGTH (strp, maxlen, len); 742 STRING_CHAR_AND_LENGTH (strp, maxlen, len);
743 if (len == 1) 743 if (len == 1)
744 *bufp = *strp; 744 *bufp = *strp;
745 else 745 else
757 int start_idx; 757 int start_idx;
758 758
759 changed = 1; 759 changed = 1;
760 strp += 2; /* skip \[ */ 760 strp += 2; /* skip \[ */
761 start = strp; 761 start = strp;
762 start_idx = start - XSTRING (string)->data; 762 start_idx = start - SDATA (string);
763 763
764 while ((strp - (unsigned char *) XSTRING (string)->data 764 while ((strp - (unsigned char *) SDATA (string)
765 < STRING_BYTES (XSTRING (string))) 765 < SBYTES (string))
766 && *strp != ']') 766 && *strp != ']')
767 strp++; 767 strp++;
768 length_byte = strp - start; 768 length_byte = strp - start;
769 769
770 strp++; /* skip ] */ 770 strp++; /* skip ] */
771 771
772 /* Save STRP in IDX. */ 772 /* Save STRP in IDX. */
773 idx = strp - (unsigned char *) XSTRING (string)->data; 773 idx = strp - (unsigned char *) SDATA (string);
774 tem = Fintern (make_string (start, length_byte), Qnil); 774 tem = Fintern (make_string (start, length_byte), Qnil);
775 775
776 /* Note the Fwhere_is_internal can GC, so we have to take 776 /* Note the Fwhere_is_internal can GC, so we have to take
777 relocation of string contents into account. */ 777 relocation of string contents into account. */
778 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil); 778 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil);
779 strp = XSTRING (string)->data + idx; 779 strp = SDATA (string) + idx;
780 start = XSTRING (string)->data + start_idx; 780 start = SDATA (string) + start_idx;
781 781
782 /* Disregard menu bar bindings; it is positively annoying to 782 /* Disregard menu bar bindings; it is positively annoying to
783 mention them when there's no menu bar, and it isn't terribly 783 mention them when there's no menu bar, and it isn't terribly
784 useful even when there is a menu bar. */ 784 useful even when there is a menu bar. */
785 if (!NILP (tem)) 785 if (!NILP (tem))
817 int start_idx; 817 int start_idx;
818 818
819 changed = 1; 819 changed = 1;
820 strp += 2; /* skip \{ or \< */ 820 strp += 2; /* skip \{ or \< */
821 start = strp; 821 start = strp;
822 start_idx = start - XSTRING (string)->data; 822 start_idx = start - SDATA (string);
823 823
824 while ((strp - (unsigned char *) XSTRING (string)->data 824 while ((strp - (unsigned char *) SDATA (string)
825 < XSTRING (string)->size) 825 < SCHARS (string))
826 && *strp != '}' && *strp != '>') 826 && *strp != '}' && *strp != '>')
827 strp++; 827 strp++;
828 828
829 length_byte = strp - start; 829 length_byte = strp - start;
830 strp++; /* skip } or > */ 830 strp++; /* skip } or > */
831 831
832 /* Save STRP in IDX. */ 832 /* Save STRP in IDX. */
833 idx = strp - (unsigned char *) XSTRING (string)->data; 833 idx = strp - (unsigned char *) SDATA (string);
834 834
835 /* Get the value of the keymap in TEM, or nil if undefined. 835 /* Get the value of the keymap in TEM, or nil if undefined.
836 Do this while still in the user's current buffer 836 Do this while still in the user's current buffer
837 in case it is a local variable. */ 837 in case it is a local variable. */
838 name = Fintern (make_string (start, length_byte), Qnil); 838 name = Fintern (make_string (start, length_byte), Qnil);
842 tem = Fsymbol_value (name); 842 tem = Fsymbol_value (name);
843 if (! NILP (tem)) 843 if (! NILP (tem))
844 { 844 {
845 tem = get_keymap (tem, 0, 1); 845 tem = get_keymap (tem, 0, 1);
846 /* Note that get_keymap can GC. */ 846 /* Note that get_keymap can GC. */
847 strp = XSTRING (string)->data + idx; 847 strp = SDATA (string) + idx;
848 start = XSTRING (string)->data + start_idx; 848 start = SDATA (string) + start_idx;
849 } 849 }
850 } 850 }
851 851
852 /* Now switch to a temp buffer. */ 852 /* Now switch to a temp buffer. */
853 oldbuf = current_buffer; 853 oldbuf = current_buffer;
856 if (NILP (tem)) 856 if (NILP (tem))
857 { 857 {
858 name = Fsymbol_name (name); 858 name = Fsymbol_name (name);
859 insert_string ("\nUses keymap \""); 859 insert_string ("\nUses keymap \"");
860 insert_from_string (name, 0, 0, 860 insert_from_string (name, 0, 0,
861 XSTRING (name)->size, 861 SCHARS (name),
862 STRING_BYTES (XSTRING (name)), 1); 862 SBYTES (name), 1);
863 insert_string ("\", which is not currently defined.\n"); 863 insert_string ("\", which is not currently defined.\n");
864 if (start[-1] == '<') keymap = Qnil; 864 if (start[-1] == '<') keymap = Qnil;
865 } 865 }
866 else if (start[-1] == '<') 866 else if (start[-1] == '<')
867 keymap = tem; 867 keymap = tem;
870 tem = Fbuffer_string (); 870 tem = Fbuffer_string ();
871 Ferase_buffer (); 871 Ferase_buffer ();
872 set_buffer_internal (oldbuf); 872 set_buffer_internal (oldbuf);
873 873
874 subst_string: 874 subst_string:
875 start = XSTRING (tem)->data; 875 start = SDATA (tem);
876 length = XSTRING (tem)->size; 876 length = SCHARS (tem);
877 length_byte = STRING_BYTES (XSTRING (tem)); 877 length_byte = SBYTES (tem);
878 subst: 878 subst:
879 { 879 {
880 int offset = bufp - buf; 880 int offset = bufp - buf;
881 buf = (unsigned char *) xrealloc (buf, bsize += length_byte); 881 buf = (unsigned char *) xrealloc (buf, bsize += length_byte);
882 bufp = buf + offset; 882 bufp = buf + offset;
883 bcopy (start, bufp, length_byte); 883 bcopy (start, bufp, length_byte);
884 bufp += length_byte; 884 bufp += length_byte;
885 nchars += length; 885 nchars += length;
886 /* Check STRING again in case gc relocated it. */ 886 /* Check STRING again in case gc relocated it. */
887 strp = (unsigned char *) XSTRING (string)->data + idx; 887 strp = (unsigned char *) SDATA (string) + idx;
888 } 888 }
889 } 889 }
890 else if (! multibyte) /* just copy other chars */ 890 else if (! multibyte) /* just copy other chars */
891 *bufp++ = *strp++, nchars++; 891 *bufp++ = *strp++, nchars++;
892 else 892 else
893 { 893 {
894 int len; 894 int len;
895 int maxlen = XSTRING (string)->data + STRING_BYTES (XSTRING (string)) - strp; 895 int maxlen = SDATA (string) + SBYTES (string) - strp;
896 896
897 STRING_CHAR_AND_LENGTH (strp, maxlen, len); 897 STRING_CHAR_AND_LENGTH (strp, maxlen, len);
898 if (len == 1) 898 if (len == 1)
899 *bufp = *strp; 899 *bufp = *strp;
900 else 900 else