aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/make-docfile.c
diff options
context:
space:
mode:
authorStefan Monnier2010-07-23 17:23:09 +0200
committerStefan Monnier2010-07-23 17:23:09 +0200
commit0ee81a0ce066375eac701c06cdfbdebefe594fdc (patch)
treef0dccd24163316cfe688f927681a3032a9b1fe2f /lib-src/make-docfile.c
parent894e369ddf48e191638b8e66ce732f24ff9abe2a (diff)
parent94da839793affa2a270bc26cee9c4d95d4dc4708 (diff)
downloademacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.tar.gz
emacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.zip
Merge from trunk
Diffstat (limited to 'lib-src/make-docfile.c')
-rw-r--r--lib-src/make-docfile.c143
1 files changed, 57 insertions, 86 deletions
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index eb15342ca5b..51c30f91d8f 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -67,9 +67,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
67#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) 67#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
68#endif 68#endif
69 69
70int scan_file (); 70int scan_file (char *filename);
71int scan_lisp_file (); 71int scan_lisp_file (char *filename, char *mode);
72int scan_c_file (); 72int scan_c_file (char *filename, char *mode);
73 73
74#ifdef MSDOS 74#ifdef MSDOS
75/* s/msdos.h defines this as sys_chdir, but we're not linking with the 75/* s/msdos.h defines this as sys_chdir, but we're not linking with the
@@ -91,8 +91,7 @@ char *progname;
91 91
92/* VARARGS1 */ 92/* VARARGS1 */
93void 93void
94error (s1, s2) 94error (char *s1, char *s2)
95 char *s1, *s2;
96{ 95{
97 fprintf (stderr, "%s: ", progname); 96 fprintf (stderr, "%s: ", progname);
98 fprintf (stderr, s1, s2); 97 fprintf (stderr, s1, s2);
@@ -103,8 +102,7 @@ error (s1, s2)
103 102
104/* VARARGS1 */ 103/* VARARGS1 */
105void 104void
106fatal (s1, s2) 105fatal (char *s1, char *s2)
107 char *s1, *s2;
108{ 106{
109 error (s1, s2); 107 error (s1, s2);
110 exit (EXIT_FAILURE); 108 exit (EXIT_FAILURE);
@@ -113,8 +111,7 @@ fatal (s1, s2)
113/* Like malloc but get fatal error if memory is exhausted. */ 111/* Like malloc but get fatal error if memory is exhausted. */
114 112
115void * 113void *
116xmalloc (size) 114xmalloc (unsigned int size)
117 unsigned int size;
118{ 115{
119 void *result = (void *) malloc (size); 116 void *result = (void *) malloc (size);
120 if (result == NULL) 117 if (result == NULL)
@@ -123,9 +120,7 @@ xmalloc (size)
123} 120}
124 121
125int 122int
126main (argc, argv) 123main (int argc, char **argv)
127 int argc;
128 char **argv;
129{ 124{
130 int i; 125 int i;
131 int err_count = 0; 126 int err_count = 0;
@@ -187,8 +182,7 @@ main (argc, argv)
187 182
188/* Add a source file name boundary marker in the output file. */ 183/* Add a source file name boundary marker in the output file. */
189void 184void
190put_filename (filename) 185put_filename (char *filename)
191 char *filename;
192{ 186{
193 char *tmp; 187 char *tmp;
194 188
@@ -207,8 +201,7 @@ put_filename (filename)
207/* Return 1 if file is not found, 0 if it is found. */ 201/* Return 1 if file is not found, 0 if it is found. */
208 202
209int 203int
210scan_file (filename) 204scan_file (char *filename)
211 char *filename;
212{ 205{
213 int len = strlen (filename); 206 int len = strlen (filename);
214 207
@@ -251,9 +244,7 @@ struct rcsoc_state
251 spaces are output first. */ 244 spaces are output first. */
252 245
253static INLINE void 246static INLINE void
254put_char (ch, state) 247put_char (int ch, struct rcsoc_state *state)
255 int ch;
256 struct rcsoc_state *state;
257{ 248{
258 int out_ch; 249 int out_ch;
259 do 250 do
@@ -286,9 +277,7 @@ put_char (ch, state)
286 keyword, but were in fact not. */ 277 keyword, but were in fact not. */
287 278
288static void 279static void
289scan_keyword_or_put_char (ch, state) 280scan_keyword_or_put_char (int ch, struct rcsoc_state *state)
290 int ch;
291 struct rcsoc_state *state;
292{ 281{
293 if (state->keyword 282 if (state->keyword
294 && *state->cur_keyword_ptr == ch 283 && *state->cur_keyword_ptr == ch
@@ -359,11 +348,7 @@ scan_keyword_or_put_char (ch, state)
359 true if any were encountered. */ 348 true if any were encountered. */
360 349
361int 350int
362read_c_string_or_comment (infile, printflag, comment, saw_usage) 351read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usage)
363 FILE *infile;
364 int printflag;
365 int *saw_usage;
366 int comment;
367{ 352{
368 register int c; 353 register int c;
369 struct rcsoc_state state; 354 struct rcsoc_state state;
@@ -451,15 +436,12 @@ read_c_string_or_comment (infile, printflag, comment, saw_usage)
451 MINARGS and MAXARGS are the minimum and maximum number of arguments. */ 436 MINARGS and MAXARGS are the minimum and maximum number of arguments. */
452 437
453void 438void
454write_c_args (out, func, buf, minargs, maxargs) 439write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
455 FILE *out;
456 char *func, *buf;
457 int minargs, maxargs;
458{ 440{
459 register char *p; 441 register char *p;
460 int in_ident = 0; 442 int in_ident = 0;
461 int just_spaced = 0; 443 char *ident_start;
462 int need_space = 1; 444 int ident_length;
463 445
464 fprintf (out, "(fn"); 446 fprintf (out, "(fn");
465 447
@@ -469,9 +451,8 @@ write_c_args (out, func, buf, minargs, maxargs)
469 for (p = buf; *p; p++) 451 for (p = buf; *p; p++)
470 { 452 {
471 char c = *p; 453 char c = *p;
472 int ident_start = 0;
473 454
474 /* Notice when we start printing a new identifier. */ 455 /* Notice when a new identifier starts. */
475 if ((('A' <= c && c <= 'Z') 456 if ((('A' <= c && c <= 'Z')
476 || ('a' <= c && c <= 'z') 457 || ('a' <= c && c <= 'z')
477 || ('0' <= c && c <= '9') 458 || ('0' <= c && c <= '9')
@@ -481,55 +462,50 @@ write_c_args (out, func, buf, minargs, maxargs)
481 if (!in_ident) 462 if (!in_ident)
482 { 463 {
483 in_ident = 1; 464 in_ident = 1;
484 ident_start = 1; 465 ident_start = p;
485
486 if (need_space)
487 putc (' ', out);
488
489 if (minargs == 0 && maxargs > 0)
490 fprintf (out, "&optional ");
491 just_spaced = 1;
492
493 minargs--;
494 maxargs--;
495 } 466 }
496 else 467 else
497 in_ident = 0; 468 {
469 in_ident = 0;
470 ident_length = p - ident_start;
471 }
498 } 472 }
499 473
500 /* Print the C argument list as it would appear in lisp: 474 /* Found the end of an argument, write out the last seen
501 print underscores as hyphens, and print commas and newlines 475 identifier. */
502 as spaces. Collapse adjacent spaces into one. */ 476 if (c == ',' || c == ')')
503 if (c == '_')
504 c = '-';
505 else if (c == ',' || c == '\n')
506 c = ' ';
507
508 /* In C code, `default' is a reserved word, so we spell it
509 `defalt'; unmangle that here. */
510 if (ident_start
511 && strncmp (p, "defalt", 6) == 0
512 && ! (('A' <= p[6] && p[6] <= 'Z')
513 || ('a' <= p[6] && p[6] <= 'z')
514 || ('0' <= p[6] && p[6] <= '9')
515 || p[6] == '_'))
516 {
517 fprintf (out, "DEFAULT");
518 p += 5;
519 in_ident = 0;
520 just_spaced = 0;
521 }
522 else if (c != ' ' || !just_spaced)
523 { 477 {
524 if (c >= 'a' && c <= 'z') 478 if (strncmp (ident_start, "void", ident_length) == 0)
525 /* Upcase the letter. */ 479 continue;
526 c += 'A' - 'a'; 480
527 putc (c, out); 481 putc (' ', out);
528 } 482
483 if (minargs == 0 && maxargs > 0)
484 fprintf (out, "&optional ");
485
486 minargs--;
487 maxargs--;
529 488
530 just_spaced = c == ' '; 489 /* In C code, `default' is a reserved word, so we spell it
531 need_space = 0; 490 `defalt'; unmangle that here. */
491 if (strncmp (ident_start, "defalt", ident_length) == 0)
492 fprintf (out, "DEFAULT");
493 else
494 while (ident_length-- > 0)
495 {
496 c = *ident_start++;
497 if (c >= 'a' && c <= 'z')
498 /* Upcase the letter. */
499 c += 'A' - 'a';
500 else if (c == '_')
501 /* Print underscore as hyphen. */
502 c = '-';
503 putc (c, out);
504 }
505 }
532 } 506 }
507
508 putc (')', out);
533} 509}
534 510
535/* Read through a c file. If a .o file is named, 511/* Read through a c file. If a .o file is named,
@@ -538,8 +514,7 @@ write_c_args (out, func, buf, minargs, maxargs)
538 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */ 514 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */
539 515
540int 516int
541scan_c_file (filename, mode) 517scan_c_file (char *filename, char *mode)
542 char *filename, *mode;
543{ 518{
544 FILE *infile; 519 FILE *infile;
545 register int c; 520 register int c;
@@ -815,8 +790,7 @@ scan_c_file (filename, mode)
815 */ 790 */
816 791
817void 792void
818skip_white (infile) 793skip_white (FILE *infile)
819 FILE *infile;
820{ 794{
821 char c = ' '; 795 char c = ' ';
822 while (c == ' ' || c == '\t' || c == '\n' || c == '\r') 796 while (c == ' ' || c == '\t' || c == '\n' || c == '\r')
@@ -825,9 +799,7 @@ skip_white (infile)
825} 799}
826 800
827void 801void
828read_lisp_symbol (infile, buffer) 802read_lisp_symbol (FILE *infile, char *buffer)
829 FILE *infile;
830 char *buffer;
831{ 803{
832 char c; 804 char c;
833 char *fillp = buffer; 805 char *fillp = buffer;
@@ -855,8 +827,7 @@ read_lisp_symbol (infile, buffer)
855} 827}
856 828
857int 829int
858scan_lisp_file (filename, mode) 830scan_lisp_file (char *filename, char *mode)
859 char *filename, *mode;
860{ 831{
861 FILE *infile; 832 FILE *infile;
862 register int c; 833 register int c;