comparison lib-src/make-docfile.c @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents a145efe76779
children 677f6a0ee643
comparison
equal deleted inserted replaced
172:a38aed19690b 173:8eaf7971accc
75 #undef chdir 75 #undef chdir
76 #endif 76 #endif
77 77
78 /* Stdio stream for output to the DOC file. */ 78 /* Stdio stream for output to the DOC file. */
79 static FILE *outfile; 79 static FILE *outfile;
80 static char *extra_elcs = NULL;
81 80
82 enum 81 enum
83 { 82 {
84 el_file, 83 el_file,
85 elc_file, 84 elc_file,
174 main (int argc, char **argv) 173 main (int argc, char **argv)
175 { 174 {
176 int i; 175 int i;
177 int err_count = 0; 176 int err_count = 0;
178 int first_infile; 177 int first_infile;
178 char *extra_elcs = NULL;
179 179
180 progname = argv[0]; 180 progname = argv[0];
181 181
182 outfile = stdout; 182 outfile = stdout;
183 183
376 int in_ident = 0; 376 int in_ident = 0;
377 int just_spaced = 0; 377 int just_spaced = 0;
378 #if 0 378 #if 0
379 int need_space = 1; 379 int need_space = 1;
380 380
381 fprintf (out, "(%s", func); 381 fprintf (out, "(%s", func);
382 #else 382 #else
383 /* XEmacs - "arguments:" is for parsing the docstring. FSF's help system 383 /* XEmacs - "arguments:" is for parsing the docstring. FSF's help system
384 doesn't parse the docstring for arguments like we do, so we're also 384 doesn't parse the docstring for arguments like we do, so we're also
385 going to omit the function name to preserve compatibility with elisp 385 going to omit the function name to preserve compatibility with elisp
386 that parses the docstring. Finally, not prefixing the arglist with 386 that parses the docstring. Finally, not prefixing the arglist with
387 anything is asking for trouble because it's not uncommon to have an 387 anything is asking for trouble because it's not uncommon to have an
388 unescaped parenthesis at the beginning of a line. --Stig */ 388 unescaped parenthesis at the beginning of a line. --Stig */
389 fprintf (out, "arguments: ("); 389 fprintf (out, "arguments: (");
390 #endif 390 #endif
391 391
392 if (*buff == '(') 392 if (*buff == '(')
393 ++buff; 393 ++buff;
394 394
395 for (p = buff; *p; p++) 395 for (p = buff; *p; p++)
407 p += (sizeof (lo) - 1); 407 p += (sizeof (lo) - 1);
408 while (isspace (*p)) 408 while (isspace (*p))
409 p++; 409 p++;
410 c = *p; 410 c = *p;
411 } 411 }
412 412
413 /* Notice when we start printing a new identifier. */ 413 /* Notice when we start printing a new identifier. */
414 if (C_IDENTIFIER_CHAR_P (c) != in_ident) 414 if (C_IDENTIFIER_CHAR_P (c) != in_ident)
415 { 415 {
416 if (!in_ident) 416 if (!in_ident)
417 { 417 {
433 in_ident = 0; 433 in_ident = 0;
434 } 434 }
435 435
436 /* Print the C argument list as it would appear in lisp: 436 /* Print the C argument list as it would appear in lisp:
437 print underscores as hyphens, and print commas as spaces. 437 print underscores as hyphens, and print commas as spaces.
438 Collapse adjacent spaces into one. */ 438 Collapse adjacent spaces into one. */
439 if (c == '_') c = '-'; 439 if (c == '_') c = '-';
440 if (c == ',') c = ' '; 440 if (c == ',') c = ' ';
441 441
442 /* In C code, `default' is a reserved word, so we spell it 442 /* If the C argument name ends with `_', change it to ' ',
443 `defalt'; unmangle that here. */ 443 to allow use of C reserved words or global symbols as Lisp args. */
444 if (ident_start 444 if (c == '-' && ! C_IDENTIFIER_CHAR_P (p[1]))
445 && strncmp (p, "defalt", 6) == 0 445 {
446 && ! C_IDENTIFIER_CHAR_P (p[6]))
447 {
448 fprintf (out, "DEFAULT");
449 p += 5;
450 in_ident = 0; 446 in_ident = 0;
451 just_spaced = 0; 447 just_spaced = 0;
452 } 448 }
453 else if (c != ' ' || ! just_spaced) 449 else if (c != ' ' || ! just_spaced)
454 { 450 {
698 We also look for #@LENGTH CONTENTS^_ at the beginning of the line. 694 We also look for #@LENGTH CONTENTS^_ at the beginning of the line.
699 When we find that, we save it for the following defining-form, 695 When we find that, we save it for the following defining-form,
700 and we use that instead of reading a doc string within that defining-form. 696 and we use that instead of reading a doc string within that defining-form.
701 697
702 For defun, defmacro, and autoload, we know how to skip over the arglist. 698 For defun, defmacro, and autoload, we know how to skip over the arglist.
703 For defvar, defconst, and fset we skip to the docstring with a kludgy 699 For defvar, defconst, and fset we skip to the docstring with a kludgy
704 formatting convention: all docstrings must appear on the same line as the 700 formatting convention: all docstrings must appear on the same line as the
705 initial open-paren (the one in column zero) and must contain a backslash 701 initial open-paren (the one in column zero) and must contain a backslash
706 and a double-quote immediately after the initial double-quote. No newlines 702 and a double-quote immediately after the initial double-quote. No newlines
707 must appear between the beginning of the form and the first double-quote. 703 must appear between the beginning of the form and the first double-quote.
708 The only source file that must follow this convention is loaddefs.el; aside 704 The only source file that must follow this convention is loaddefs.el; aside
709 from that, it is always the .elc file that we look at, and they are no 705 from that, it is always the .elc file that we look at, and they are no
710 problem because byte-compiler output follows this convention. 706 problem because byte-compiler output follows this convention.
745 *fillp++ = c; 741 *fillp++ = c;
746 } 742 }
747 743
748 if (! buffer[0]) 744 if (! buffer[0])
749 fprintf (stderr, "## expected a symbol, got '%c'\n", c); 745 fprintf (stderr, "## expected a symbol, got '%c'\n", c);
750 746
751 skip_white (infile); 747 skip_white (infile);
752 } 748 }
753 749
754 static int 750 static int
755 scan_lisp_file (CONST char *filename, CONST char *mode) 751 scan_lisp_file (CONST char *filename, CONST char *mode)
885 { 881 {
886 getc (infile); 882 getc (infile);
887 getc (infile); 883 getc (infile);
888 goto nextchar; 884 goto nextchar;
889 } 885 }
890 886
891 c2 = c1; 887 c2 = c1;
892 c1 = c; 888 c1 = c;
893 nextchar: 889 nextchar:
894 c = getc (infile); 890 c = getc (infile);
895 } 891 }
896 892
897 /* If two previous characters were " and \, 893 /* If two previous characters were " and \,
898 this is a doc string. Otherwise, there is none. */ 894 this is a doc string. Otherwise, there is none. */
899 if (c2 != '"' || c1 != '\\') 895 if (c2 != '"' || c1 != '\\')
900 { 896 {
901 #ifdef DEBUG 897 #ifdef DEBUG
948 { 944 {
949 c2 = c1; 945 c2 = c1;
950 c1 = c; 946 c1 = c;
951 c = getc (infile); 947 c = getc (infile);
952 } 948 }
953 949
954 /* If two previous characters were " and \, 950 /* If two previous characters were " and \,
955 this is a doc string. Otherwise, there is none. */ 951 this is a doc string. Otherwise, there is none. */
956 if (c2 != '"' || c1 != '\\') 952 if (c2 != '"' || c1 != '\\')
957 { 953 {
958 #ifdef DEBUG 954 #ifdef DEBUG