Mercurial > hg > xemacs-beta
comparison src/doc.c @ 14:9ee227acff29 r19-15b90
Import from CVS: tag r19-15b90
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:48:42 +0200 |
parents | ac2d302a0011 |
children | 859a2309aef8 |
comparison
equal
deleted
inserted
replaced
13:13c6d0aaafe5 | 14:9ee227acff29 |
---|---|
153 case 1: *to++ = c; break; | 153 case 1: *to++ = c; break; |
154 case '0': *to++ = '\0'; break; | 154 case '0': *to++ = '\0'; break; |
155 case '_': *to++ = '\037'; break; | 155 case '_': *to++ = '\037'; break; |
156 default: | 156 default: |
157 return_me = list2 (build_string | 157 return_me = list2 (build_string |
158 ("Invalid data in documentation file -- ^A followed by weird code"), | 158 ("Invalid data in documentation file -- ^A followed by weird code"), |
159 make_int (c)); | 159 make_int (c)); |
160 goto done; | 160 goto done; |
161 } | 161 } |
162 } | 162 } |
163 } | 163 } |
170 xfree (buffer); | 170 xfree (buffer); |
171 return return_me; | 171 return return_me; |
172 } | 172 } |
173 | 173 |
174 #define string_join(dest, s1, s2) \ | 174 #define string_join(dest, s1, s2) \ |
175 memcpy ((void *) dest, (void *) XSTRING_data (s1), XSTRING_length (s1)); \ | 175 memcpy ((void *) dest, (void *) XSTRING_DATA (s1), XSTRING_LENGTH (s1)); \ |
176 memcpy ((void *) ((Bufbyte *) dest + XSTRING_length (s1)), \ | 176 memcpy ((void *) ((Bufbyte *) dest + XSTRING_LENGTH (s1)), \ |
177 (void *) XSTRING_data (s2), XSTRING_length (s2)); \ | 177 (void *) XSTRING_DATA (s2), XSTRING_LENGTH (s2)); \ |
178 dest[XSTRING_length (s1) + XSTRING_length (s2)] = '\0' | 178 dest[XSTRING_LENGTH (s1) + XSTRING_LENGTH (s2)] = '\0' |
179 | 179 |
180 /* Extract a doc string from a file. FILEPOS says where to get it. | 180 /* Extract a doc string from a file. FILEPOS says where to get it. |
181 (This could actually be byte code instructions/constants instead | 181 (This could actually be byte code instructions/constants instead |
182 of a doc string.) | 182 of a doc string.) |
183 If it is an integer, use that position in the standard DOC-... file. | 183 If it is an integer, use that position in the standard DOC file. |
184 If it is (FILE . INTEGER), use FILE as the file name | 184 If it is (FILE . INTEGER), use FILE as the file name |
185 and INTEGER as the position in that file. | 185 and INTEGER as the position in that file. |
186 But if INTEGER is negative, make it positive. | 186 But if INTEGER is negative, make it positive. |
187 (A negative integer is used for user variables, so we can distinguish | 187 (A negative integer is used for user variables, so we can distinguish |
188 them without actually fetching the doc string.) */ | 188 them without actually fetching the doc string.) */ |
225 /* XEmacs: Move this check here. OK if called during loadup to | 225 /* XEmacs: Move this check here. OK if called during loadup to |
226 load byte code instructions. */ | 226 load byte code instructions. */ |
227 if (!STRINGP (Vdoc_directory)) | 227 if (!STRINGP (Vdoc_directory)) |
228 return Qnil; | 228 return Qnil; |
229 | 229 |
230 minsize = string_length (XSTRING (Vdoc_directory)); | 230 minsize = XSTRING_LENGTH (Vdoc_directory); |
231 /* sizeof ("../lib-src/") == 12 */ | 231 /* sizeof ("../lib-src/") == 12 */ |
232 if (minsize < 12) | 232 if (minsize < 12) |
233 minsize = 12; | 233 minsize = 12; |
234 name_nonreloc | 234 name_nonreloc = (char *) alloca (minsize + XSTRING_LENGTH (file) + 8); |
235 = (char *) alloca (minsize + string_length (XSTRING (file)) + 8); | |
236 /* | |
237 strcpy (name_nonreloc, (char *) string_data (XSTRING (Vdoc_directory))); | |
238 strcat (name_nonreloc, (char *) string_data (XSTRING (file))); | |
239 */ | |
240 string_join (name_nonreloc, Vdoc_directory, file); | 235 string_join (name_nonreloc, Vdoc_directory, file); |
241 munge_doc_file_name (name_nonreloc); | 236 munge_doc_file_name (name_nonreloc); |
242 } | 237 } |
243 else | 238 else |
244 name_reloc = file; | 239 name_reloc = file; |
245 | 240 |
246 fd = open (name_nonreloc ? name_nonreloc : | 241 fd = open (name_nonreloc ? name_nonreloc : |
247 (char *) string_data (XSTRING (name_reloc)), O_RDONLY, 0); | 242 (char *) XSTRING_DATA (name_reloc), O_RDONLY, 0); |
248 if (fd < 0) | 243 if (fd < 0) |
249 { | 244 { |
250 #ifndef CANNOT_DUMP | 245 #ifndef CANNOT_DUMP |
251 if (purify_flag) | 246 if (purify_flag) |
252 { | 247 { |
253 name_nonreloc | |
254 /* sizeof ("../lib-src/") == 12 */ | 248 /* sizeof ("../lib-src/") == 12 */ |
255 = (char *) alloca (12 + string_length (XSTRING (file)) + 8); | 249 name_nonreloc = (char *) alloca (12 + XSTRING_LENGTH (file) + 8); |
256 /* Preparing to dump; DOC file is probably not installed. | 250 /* Preparing to dump; DOC file is probably not installed. |
257 So check in ../lib-src. */ | 251 So check in ../lib-src. */ |
258 strcpy (name_nonreloc, "../lib-src/"); | 252 strcpy (name_nonreloc, "../lib-src/"); |
259 strcat (name_nonreloc, (char *) string_data (XSTRING (file))); | 253 strcat (name_nonreloc, (char *) XSTRING_DATA (file)); |
260 munge_doc_file_name (name_nonreloc); | 254 munge_doc_file_name (name_nonreloc); |
261 | 255 |
262 fd = open (name_nonreloc, O_RDONLY, 0); | 256 fd = open (name_nonreloc, O_RDONLY, 0); |
263 } | 257 } |
264 #endif | 258 #endif /* CANNOT_DUMP */ |
265 | 259 |
266 if (fd < 0) | 260 if (fd < 0) |
267 error ("Cannot open doc string file \"%s\"", | 261 error ("Cannot open doc string file \"%s\"", |
268 name_nonreloc ? name_nonreloc : | 262 name_nonreloc ? name_nonreloc : |
269 (char *) string_data (XSTRING (name_reloc))); | 263 (char *) XSTRING_DATA (name_reloc)); |
270 } | 264 } |
271 | 265 |
272 tem = unparesseuxify_doc_string (fd, position, name_nonreloc, name_reloc); | 266 tem = unparesseuxify_doc_string (fd, position, name_nonreloc, name_reloc); |
273 close (fd); | 267 close (fd); |
274 | 268 |
428 } | 422 } |
429 | 423 |
430 static void | 424 static void |
431 weird_doc (Lisp_Object sym, CONST char *weirdness, CONST char *type, int pos) | 425 weird_doc (Lisp_Object sym, CONST char *weirdness, CONST char *type, int pos) |
432 { | 426 { |
433 #ifdef ENERGIZE /* hide kludgery... */ | 427 #if defined(ENERGIZE) || defined(SUNPRO) /* hide kludgery... */ |
434 if (!strcmp (weirdness, GETTEXT ("duplicate"))) return; | 428 if (!strcmp (weirdness, GETTEXT ("duplicate"))) return; |
435 #endif | 429 #endif |
436 message ("Note: Strange doc (%s) for %s %s @ %d", | 430 message ("Note: Strange doc (%s) for %s %s @ %d", |
437 weirdness, type, string_data (XSYMBOL (sym)->name), pos); | 431 weirdness, type, string_data (XSYMBOL (sym)->name), pos); |
438 } | 432 } |
465 #endif | 459 #endif |
466 | 460 |
467 CHECK_STRING (filename); | 461 CHECK_STRING (filename); |
468 | 462 |
469 #ifndef CANNOT_DUMP | 463 #ifndef CANNOT_DUMP |
470 name = (char *) alloca (string_length (XSTRING (filename)) + 14); | 464 name = (char *) alloca (XSTRING_LENGTH (filename) + 14); |
471 strcpy (name, "../lib-src/"); | 465 strcpy (name, "../lib-src/"); |
472 #else /* CANNOT_DUMP */ | 466 #else /* CANNOT_DUMP */ |
473 CHECK_STRING (Vdoc_directory); | 467 CHECK_STRING (Vdoc_directory); |
474 name = (char *) alloca (string_length (XSTRING (filename)) | 468 name = (char *) alloca (XSTRING_LENGTH (filename) |
475 + string_length (XSTRING (Vdoc_directory)) | 469 + XSTRING_LENGTH (Vdoc_directory) |
476 + 1); | 470 + 1); |
477 strcpy (name, (char *) string_data (XSTRING (Vdoc_directory))); | 471 strcpy (name, (char *) XSTRING_DATA (Vdoc_directory)); |
478 #endif /* CANNOT_DUMP */ | 472 #endif /* CANNOT_DUMP */ |
479 strcat (name, (char *) string_data (XSTRING (filename))); | 473 strcat (name, (char *) XSTRING_DATA (filename)); |
480 #ifdef VMS | 474 #ifdef VMS |
481 #ifndef VMS4_4 | 475 #ifndef VMS4_4 |
482 /* For VMS versions with limited file name syntax, | 476 /* For VMS versions with limited file name syntax, |
483 convert the name to something VMS will allow. */ | 477 convert the name to something VMS will allow. */ |
484 p = name; | 478 p = name; |
822 keymap = current_kboard->Voverriding_terminal_local_map; | 816 keymap = current_kboard->Voverriding_terminal_local_map; |
823 if (NILP (keymap)) | 817 if (NILP (keymap)) |
824 keymap = Voverriding_local_map; | 818 keymap = Voverriding_local_map; |
825 #endif | 819 #endif |
826 | 820 |
827 strlength = string_length (XSTRING (str)); | 821 strlength = XSTRING_LENGTH (str); |
828 bsize = strlength; | 822 bsize = strlength; |
829 buf = (Bufbyte *) xmalloc (bsize); | 823 buf = (Bufbyte *) xmalloc (bsize); |
830 bufp = buf; | 824 bufp = buf; |
831 | 825 |
832 /* Have to reset strdata every time GC might be called */ | 826 /* Have to reset strdata every time GC might be called */ |
833 strdata = string_data (XSTRING (str)); | 827 strdata = XSTRING_DATA (str); |
834 for (idx = 0; idx < strlength; ) | 828 for (idx = 0; idx < strlength; ) |
835 { | 829 { |
836 Bufbyte *strp = strdata + idx; | 830 Bufbyte *strp = strdata + idx; |
837 | 831 |
838 if (strp[0] != '\\') | 832 if (strp[0] != '\\') |
952 { | 946 { |
953 char boof[255], *b = boof; | 947 char boof[255], *b = boof; |
954 *b++ = '\n'; | 948 *b++ = '\n'; |
955 sprintf (b, GETTEXT ( | 949 sprintf (b, GETTEXT ( |
956 "Uses keymap \"%s\", which is not currently defined."), | 950 "Uses keymap \"%s\", which is not currently defined."), |
957 (char *) string_data (XSTRING (Fsymbol_name (name)))); | 951 (char *) XSTRING_DATA (Fsymbol_name (name))); |
958 b += strlen (b); | 952 b += strlen (b); |
959 *b++ = '\n'; | 953 *b++ = '\n'; |
960 *b++ = 0; | 954 *b++ = 0; |
961 buffer_insert_c_string (current_buffer, boof); | 955 buffer_insert_c_string (current_buffer, boof); |
962 | 956 |
970 Ferase_buffer (Fcurrent_buffer ()); | 964 Ferase_buffer (Fcurrent_buffer ()); |
971 set_buffer_internal (oldbuf); | 965 set_buffer_internal (oldbuf); |
972 goto subst_string; | 966 goto subst_string; |
973 | 967 |
974 subst_string: | 968 subst_string: |
975 start = string_data (XSTRING (tem)); | 969 start = XSTRING_DATA (tem); |
976 length = string_length (XSTRING (tem)); | 970 length = XSTRING_LENGTH (tem); |
977 subst: | 971 subst: |
978 bsize += length; | 972 bsize += length; |
979 new = (Bufbyte *) xrealloc (buf, bsize); | 973 new = (Bufbyte *) xrealloc (buf, bsize); |
980 bufp += new - buf; | 974 bufp += new - buf; |
981 buf = new; | 975 buf = new; |
982 memcpy (bufp, start, length); | 976 memcpy (bufp, start, length); |
983 bufp += length; | 977 bufp += length; |
984 | 978 |
985 /* Reset STRDATA in case gc relocated it. */ | 979 /* Reset STRDATA in case gc relocated it. */ |
986 strdata = string_data (XSTRING (str)); | 980 strdata = XSTRING_DATA (str); |
987 | 981 |
988 break; | 982 break; |
989 } | 983 } |
990 } | 984 } |
991 } | 985 } |