comparison lib-src/make-docfile.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents aabb7f5b1c81
children 501cfd01ee6d
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
38 Added 19.15/20.1: `-i site-packages' allow installer to dump extra packages 38 Added 19.15/20.1: `-i site-packages' allow installer to dump extra packages
39 without modifying Makefiles, etc. 39 without modifying Makefiles, etc.
40 */ 40 */
41 41
42 #define NO_SHORTNAMES /* Tell config not to load remap.h */ 42 #define NO_SHORTNAMES /* Tell config not to load remap.h */
43 #include <../src/config.h> 43 #include <config.h>
44 44
45 #include <stdio.h> 45 #include <stdio.h>
46 #include <errno.h> 46 #include <errno.h>
47 #if __STDC__ || defined(STDC_HEADERS) 47 #if __STDC__ || defined(STDC_HEADERS)
48 #include <stdlib.h> 48 #include <stdlib.h>
49 #include <unistd.h> 49 #include <unistd.h>
50 #include <string.h> 50 #include <string.h>
51 #include <ctype.h> 51 #include <ctype.h>
52 #endif 52 #endif
53
54 #include <sys/param.h>
55 53
56 #if defined(MSDOS) || defined(__CYGWIN32__) 54 #if defined(MSDOS) || defined(__CYGWIN32__)
57 #include <fcntl.h> 55 #include <fcntl.h>
58 #endif /* MSDOS */ 56 #endif /* MSDOS */
59 #ifdef WINDOWSNT 57 #ifdef WINDOWSNT
60 #include <direct.h> 58 #include <direct.h>
61 #include <fcntl.h> 59 #include <fcntl.h>
62 #include <io.h> 60 #include <io.h>
63 #include <stdlib.h> 61 #include <stdlib.h>
64 #endif /* WINDOWSNT */ 62 #endif /* WINDOWSNT */
63
64 #include <sys/param.h>
65 65
66 #if defined(DOS_NT) || defined(__CYGWIN32__) 66 #if defined(DOS_NT) || defined(__CYGWIN32__)
67 #define READ_TEXT "rt" 67 #define READ_TEXT "rt"
68 #define READ_BINARY "rb" 68 #define READ_BINARY "rb"
69 #define WRITE_BINARY "wb" 69 #define WRITE_BINARY "wb"
89 el_file, 89 el_file,
90 elc_file, 90 elc_file,
91 c_file 91 c_file
92 } Current_file_type; 92 } Current_file_type;
93 93
94 static int scan_file (CONST char *filename); 94 static int scan_file (const char *filename);
95 static int read_c_string (FILE *, int, int); 95 static int read_c_string (FILE *, int, int);
96 static void write_c_args (FILE *out, CONST char *func, char *buf, int minargs, 96 static void write_c_args (FILE *out, const char *func, char *buf, int minargs,
97 int maxargs); 97 int maxargs);
98 static int scan_c_file (CONST char *filename, CONST char *mode); 98 static int scan_c_file (const char *filename, const char *mode);
99 static void skip_white (FILE *); 99 static void skip_white (FILE *);
100 static void read_lisp_symbol (FILE *, char *); 100 static void read_lisp_symbol (FILE *, char *);
101 static int scan_lisp_file (CONST char *filename, CONST char *mode); 101 static int scan_lisp_file (const char *filename, const char *mode);
102 102
103 #define C_IDENTIFIER_CHAR_P(c) \ 103 #define C_IDENTIFIER_CHAR_P(c) \
104 (('A' <= c && c <= 'Z') || \ 104 (('A' <= c && c <= 'Z') || \
105 ('a' <= c && c <= 'z') || \ 105 ('a' <= c && c <= 'z') || \
106 ('0' <= c && c <= '9') || \ 106 ('0' <= c && c <= '9') || \
113 int ellcc = 0; 113 int ellcc = 0;
114 114
115 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ 115 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
116 116
117 static void 117 static void
118 error (CONST char *s1, CONST char *s2) 118 error (const char *s1, const char *s2)
119 { 119 {
120 fprintf (stderr, "%s: ", progname); 120 fprintf (stderr, "%s: ", progname);
121 fprintf (stderr, s1, s2); 121 fprintf (stderr, s1, s2);
122 fprintf (stderr, "\n"); 122 fprintf (stderr, "\n");
123 } 123 }
124 124
125 /* Print error message and exit. */ 125 /* Print error message and exit. */
126 126
127 static void 127 static void
128 fatal (CONST char *s1, CONST char *s2) 128 fatal (const char *s1, const char *s2)
129 { 129 {
130 error (s1, s2); 130 error (s1, s2);
131 exit (1); 131 exit (1);
132 } 132 }
133 133
272 272
273 /* Read file FILENAME and output its doc strings to outfile. */ 273 /* Read file FILENAME and output its doc strings to outfile. */
274 /* Return 1 if file is not found, 0 if it is found. */ 274 /* Return 1 if file is not found, 0 if it is found. */
275 275
276 static int 276 static int
277 scan_file (CONST char *filename) 277 scan_file (const char *filename)
278 { 278 {
279 int len = strlen (filename); 279 int len = strlen (filename);
280 if (ellcc == 0 && len > 4 && !strcmp (filename + len - 4, ".elc")) 280 if (ellcc == 0 && len > 4 && !strcmp (filename + len - 4, ".elc"))
281 { 281 {
282 Current_file_type = elc_file; 282 Current_file_type = elc_file;
394 394
395 /* Write to file OUT the argument names of function FUNC, whose text is in BUF. 395 /* Write to file OUT the argument names of function FUNC, whose text is in BUF.
396 MINARGS and MAXARGS are the minimum and maximum number of arguments. */ 396 MINARGS and MAXARGS are the minimum and maximum number of arguments. */
397 397
398 static void 398 static void
399 write_c_args (FILE *out, CONST char *func, char *buff, int minargs, 399 write_c_args (FILE *out, const char *func, char *buff, int minargs,
400 int maxargs) 400 int maxargs)
401 { 401 {
402 register char *p; 402 register char *p;
403 int in_ident = 0; 403 int in_ident = 0;
404 int just_spaced = 0; 404 int just_spaced = 0;
427 /* Add support for ANSI prototypes. Hop over 427 /* Add support for ANSI prototypes. Hop over
428 "Lisp_Object" string (the only C type allowed in DEFUNs) */ 428 "Lisp_Object" string (the only C type allowed in DEFUNs) */
429 static char lo[] = "Lisp_Object"; 429 static char lo[] = "Lisp_Object";
430 if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident && 430 if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident &&
431 (strncmp (p, lo, sizeof (lo) - 1) == 0) && 431 (strncmp (p, lo, sizeof (lo) - 1) == 0) &&
432 isspace(*(p + sizeof (lo) - 1))) 432 isspace((unsigned char) (* (p + sizeof (lo) - 1))))
433 { 433 {
434 p += (sizeof (lo) - 1); 434 p += (sizeof (lo) - 1);
435 while (isspace (*p)) 435 while (isspace ((unsigned char) (*p)))
436 p++; 436 p++;
437 c = *p; 437 c = *p;
438 } 438 }
439 439
440 /* Notice when we start printing a new identifier. */ 440 /* Notice when we start printing a new identifier. */
494 the corresponding .c file is read instead. 494 the corresponding .c file is read instead.
495 Looks for DEFUN constructs such as are defined in ../src/lisp.h. 495 Looks for DEFUN constructs such as are defined in ../src/lisp.h.
496 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */ 496 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */
497 497
498 static int 498 static int
499 scan_c_file (CONST char *filename, CONST char *mode) 499 scan_c_file (const char *filename, const char *mode)
500 { 500 {
501 FILE *infile; 501 FILE *infile;
502 register int c; 502 register int c;
503 register int commas; 503 register int commas;
504 register int defunflag; 504 register int defunflag;
785 785
786 skip_white (infile); 786 skip_white (infile);
787 } 787 }
788 788
789 static int 789 static int
790 scan_lisp_file (CONST char *filename, CONST char *mode) 790 scan_lisp_file (const char *filename, const char *mode)
791 { 791 {
792 FILE *infile; 792 FILE *infile;
793 register int c; 793 register int c;
794 char *saved_string = 0; 794 char *saved_string = 0;
795 795
913 { 913 {
914 914
915 /* Skip until the first newline; remember the two previous chars. */ 915 /* Skip until the first newline; remember the two previous chars. */
916 while (c != '\n' && c >= 0) 916 while (c != '\n' && c >= 0)
917 { 917 {
918 /* ### Kludge -- Ignore any ESC x x ISO2022 sequences */ 918 /* #### Kludge -- Ignore any ESC x x ISO2022 sequences */
919 if (c == 27) 919 if (c == 27)
920 { 920 {
921 getc (infile); 921 getc (infile);
922 getc (infile); 922 getc (infile);
923 goto nextchar; 923 goto nextchar;