~ubuntu-branches/ubuntu/maverick/texinfo/maverick

« back to all changes in this revision

Viewing changes to info/makedoc.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2005-10-28 15:10:30 UTC
  • mto: (2.1.1 dapper) (3.1.4 hardy)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051028151030-9nsf2s2k2z3fktjt
Tags: upstream-4.8
ImportĀ upstreamĀ versionĀ 4.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* makedoc.c -- make doc.c and funs.h from input files.
2
 
   $Id: makedoc.c,v 1.10 2001/11/16 23:15:21 karl Exp $
 
2
   $Id: makedoc.c,v 1.4 2004/04/11 17:56:46 karl Exp $
3
3
 
4
 
   Copyright (C) 1993, 97, 98, 99, 2001 Free Software Foundation, Inc.
 
4
   Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003, 2004 Free Software
 
5
   Foundation, Inc.
5
6
 
6
7
   This program is free software; you can redistribute it and/or modify
7
8
   it under the terms of the GNU General Public License as published by
17
18
   along with this program; if not, write to the Free Software
18
19
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20
 
20
 
   Written by Brian Fox (bfox@ai.mit.edu). */
 
21
   Originally written by Brian Fox (bfox@ai.mit.edu). */
21
22
 
22
23
/* This program grovels the contents of the source files passed as arguments
23
24
   and writes out a file of function pointers and documentation strings, and
27
28
#include "info.h"
28
29
#include "infokey.h"
29
30
 
30
 
static void fatal_file_error ();
 
31
static void fatal_file_error (char *filename);
31
32
 
32
33
/* Name of the header file which receives the declarations of functions. */
33
34
static char *funs_filename = "funs.h";
40
41
  "/* doc.c -- Generated structure containing function names and doc strings.",
41
42
  "",
42
43
  "   This file was automatically made from various source files with the",
43
 
  "   command \"%s\".  DO NOT EDIT THIS FILE, only \"%s.c\".",
 
44
  "   command `%s'.  DO NOT EDIT THIS FILE, only `%s.c'.",
44
45
  (char *)NULL
45
46
};
46
47
 
104
105
 
105
106
#define DECLARATION_STRING "\nDECLARE_INFO_COMMAND"
106
107
 
107
 
static void process_one_file ();
108
 
static void maybe_dump_tags ();
109
 
static FILE *must_fopen ();
110
 
static void init_func_key ();
111
 
static unsigned int next_func_key ();
 
108
static void process_one_file (char *filename, FILE *doc_stream,
 
109
    FILE *key_stream, FILE *funs_stream);
 
110
static void maybe_dump_tags (FILE *stream);
 
111
static FILE *must_fopen (char *filename, char *mode);
 
112
static void init_func_key (unsigned int val);
 
113
static unsigned int next_func_key (void);
112
114
 
113
115
int
114
 
main (argc, argv)
115
 
     int argc;
116
 
     char **argv;
 
116
main (int argc, char **argv)
117
117
{
118
118
  register int i;
119
119
  int tags_only = 0;
142
142
      doc_filename = NULL_DEVICE;
143
143
      key_filename = NULL_DEVICE;
144
144
    }
145
 
  
 
145
 
146
146
  funs_stream = must_fopen (funs_filename, "w");
147
147
  doc_stream = must_fopen (doc_filename, "w");
148
148
  key_stream = must_fopen (key_filename, "w");
149
149
 
150
150
  fprintf (funs_stream,
151
 
           "/* %s -- Generated declarations for Info commands. */\n",
152
 
           funs_filename);
 
151
      "/* %s -- Generated declarations for Info commands. */\n\n\
 
152
#include \"info.h\"\n",
 
153
      funs_filename);
153
154
 
154
155
  for (i = 0; doc_header[i]; i++)
155
156
    {
220
221
 
221
222
#endif /* !INFOKEY */
222
223
 
223
 
  fprintf (key_stream, "   (char *)0\n};\n");
 
224
  fprintf (key_stream, "   { (char *)NULL, 0 }\n};\n");
224
225
  fprintf (funs_stream, "\n#define A_NCOMMANDS %u\n", next_func_key());
225
226
 
226
227
  fclose (funs_stream);
229
230
 
230
231
  if (tags_only)
231
232
    maybe_dump_tags (stdout);
232
 
  xexit (0);
 
233
  return 0;
233
234
}
234
235
 
235
236
/* Dumping out the contents of an Emacs tags table. */
236
237
static void
237
 
maybe_dump_tags (stream)
238
 
     FILE *stream;
 
238
maybe_dump_tags (FILE *stream)
239
239
{
240
240
  register int i;
241
241
 
283
283
/* Keeping track of names, line numbers and character offsets of functions
284
284
   found in source files. */
285
285
static EMACS_TAG_BLOCK *
286
 
make_emacs_tag_block (filename)
287
 
     char *filename;
 
286
make_emacs_tag_block (char *filename)
288
287
{
289
288
  EMACS_TAG_BLOCK *block;
290
289
 
298
297
}
299
298
 
300
299
static void
301
 
add_tag_to_block (block, name, line, char_offset)
302
 
     EMACS_TAG_BLOCK *block;
303
 
     char *name;
304
 
     int line;
305
 
     long char_offset;
 
300
add_tag_to_block (EMACS_TAG_BLOCK *block,
 
301
    char *name, int line, long int char_offset)
306
302
{
307
303
  EMACS_TAG *tag;
308
304
 
318
314
   function declarations.  Output the declarations in various forms to the
319
315
   DOC_STREAM, KEY_STREAM, and FUNS_STREAM. */
320
316
static void
321
 
process_one_file (filename, doc_stream, key_stream, funs_stream)
322
 
     char *filename;
323
 
     FILE *doc_stream;
324
 
     FILE *key_stream;
325
 
     FILE *funs_stream;
 
317
process_one_file (char *filename, FILE *doc_stream,
 
318
    FILE *key_stream, FILE *funs_stream)
326
319
{
327
320
  int descriptor, decl_len;
328
321
  char *buffer, *decl_str;
504
497
#if defined (INFOKEY)
505
498
 
506
499
#if defined (NAMED_FUNCTIONS)
507
 
      fprintf (doc_stream, "   { %s, \"%s\", (FUNCTION_KEYSEQ *)0, %s },\n", func, func_name, doc);
 
500
      fprintf (doc_stream,
 
501
          "   { (VFunction *)%s, \"%s\", (FUNCTION_KEYSEQ *)0, %s },\n",
 
502
          func, func_name, doc);
508
503
#else /* !NAMED_FUNCTIONS */
509
 
      fprintf (doc_stream, "   { %s, (FUNCTION_KEYSEQ *)0, %s },\n", func, doc);
 
504
      fprintf (doc_stream,
 
505
          "   { (VFunction *) %s, (FUNCTION_KEYSEQ *)0, %s },\n", func, doc);
510
506
#endif /* !NAMED_FUNCTIONS */
511
507
 
512
508
      fprintf (key_stream, "   { \"%s\", A_%s },\n", func_name, func);
528
524
#if defined (INFOKEY)
529
525
      fprintf (funs_stream, "#define A_%s %u\n", func, next_func_key());
530
526
#endif /* INFOKEY */
531
 
      fprintf (funs_stream, "extern void %s ();\n", func);
 
527
      fprintf (funs_stream,
 
528
          "extern void %s (WINDOW *window, int count, unsigned char key);\n",
 
529
          func);
532
530
      free (func);
533
531
      free (doc);
534
532
    }
547
545
}
548
546
 
549
547
static void
550
 
fatal_file_error (filename)
551
 
     char *filename;
 
548
fatal_file_error (char *filename)
552
549
{
553
550
  fprintf (stderr, _("Couldn't manipulate the file %s.\n"), filename);
554
551
  xexit (2);
555
552
}
556
553
 
557
554
static FILE *
558
 
must_fopen (filename, mode)
559
 
     char *filename, *mode;
 
555
must_fopen (char *filename, char *mode)
560
556
{
561
557
  FILE *stream;
562
558
 
570
566
static unsigned int func_key;
571
567
 
572
568
static void
573
 
init_func_key(val)
574
 
        unsigned int val;
 
569
init_func_key(unsigned int val)
575
570
{
576
571
        func_key = val;
577
572
}
578
573
 
579
574
static unsigned int
580
 
next_func_key()
 
575
next_func_key(void)
581
576
{
582
577
        return func_key++;
583
578
}