summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/texinfo/makeinfo/makeinfo.h
blob: 78fda8c4492a250885d53374f6824361ca46dcca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/* makeinfo.h -- Declarations for Makeinfo.
   $Id: makeinfo.h,v 1.1 1996/12/15 21:39:27 downsj Exp $

   Copyright (C) 1996 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

   Written by Brian Fox (bfox@ai.mit.edu). */

/* Why, oh why, did I ever listen to rms when he said:
   "Don't make lots of small files, just make one big one!"  I've
   regretted it ever since with this program, and with readline.
   bfox@ai.mit.edu Thu Jul 11 07:54:32 1996 */

#if !defined (MAKEINFO_H)
#define MAKEINFO_H

#if defined (COMPILING_MAKEINFO)
#  define DECLARE(type, var, init) type var = init
#else
#  define DECLARE(type, var, init)  extern type var
#endif

enum insertion_type
{
  menu, detailmenu, quotation, lisp, smalllisp, example, smallexample,
  display, itemize, format, enumerate, cartouche, multitable, table,
  ftable, vtable, group, ifinfo, flushleft, flushright, ifset,
  ifclear, deffn, defun, defmac, defspec, defvr, defvar, defopt,
  deftypefn, deftypefun, deftypevr, deftypevar, defcv, defivar, defop,
  defmethod, deftypemethod, deftp, direntry, bad_type
};

DECLARE (int, insertion_level, 0);

#if defined (COMPILING_MAKEINFO)
char *insertion_type_names[] =
{
  "menu", "detailmenu", "quotation", "lisp", "smalllisp", "example",
  "smallexample", "display", "itemize", "format", "enumerate",
  "cartouche", "multitable", "table", "ftable", "vtable", "group",
  "ifinfo", "flushleft", "flushright", "ifset", "ifclear", "deffn",
  "defun", "defmac", "defspec", "defvr", "defvar", "defopt",
  "deftypefn", "deftypefun", "deftypevr", "deftypevar", "defcv",
  "defivar", "defop", "defmethod", "deftypemethod", "deftp", "direntry",
  "bad_type"
};
#endif

typedef struct istack_elt
{
  struct istack_elt *next;
  char *item_function;
  char *filename;
  int line_number;
  int filling_enabled;
  int indented_fill;
  enum insertion_type insertion;
  int inhibited;
  int in_fixed_width_font;
} INSERTION_ELT;

DECLARE (INSERTION_ELT *, insertion_stack, (INSERTION_ELT *)NULL);

/* Current output stream. */
DECLARE (FILE *, output_stream, (FILE *)NULL);

/* Output paragraph buffer. */
DECLARE (unsigned char *, output_paragraph, (unsigned char *)NULL);

/* Offset into OUTPUT_PARAGRAPH. */
DECLARE (int, output_paragraph_offset, 0);

/* The output paragraph "cursor" horizontal position. */
DECLARE (int, output_column, 0);

/* Non-zero means output_paragraph contains text. */
DECLARE (int, paragraph_is_open, 0);

/* The amount of indentation to apply at the start of each line. */
DECLARE (int, current_indent, 0);

/* nonzero if we are currently processing a multitable command */
DECLARE (int, multitable_active, 0);

/* The column at which long lines are broken. */
DECLARE (int, fill_column, 72);

/* The current input file state. */
DECLARE (char *, input_filename, (char *)NULL);
DECLARE (char *, input_text, (char *)NULL);
DECLARE (int, size_of_input_text, 0);
DECLARE (int, input_text_offset, 0);
DECLARE (int, line_number, 0);

#define curchar() input_text[input_text_offset]
/* **************************************************************** */
/*								    */
/*			      Global Defines  			    */
/*								    */
/* **************************************************************** */

/* Error levels */
#define NO_ERROR 0
#define SYNTAX	 2
#define FATAL	 4

/* C's standard macros don't check to make sure that the characters being
   changed are within range.  So I have to check explicitly. */

/* GNU Library doesn't have toupper().  Until GNU gets this fixed, I will
   have to do it. */
#ifndef toupper
#define toupper(c) ((c) - 32)
#endif

#define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c)))
#define coerce_to_lower(c) ((isupper(c) ? tolower(c) : (c)))

#define control_character_bit 0x40 /* %01000000, must be off. */
#define meta_character_bit 0x080/* %10000000, must be on.  */
#define CTL(c) ((c) & (~control_character_bit))
#define UNCTL(c) coerce_to_upper(((c)|control_character_bit))
#define META(c) ((c) | (meta_character_bit))
#define UNMETA(c) ((c) & (~meta_character_bit))

#define whitespace(c) (((c) == '\t') || ((c) == ' '))
#define sentence_ender(c) ((c) == '.' || (c) == '?' || (c) == '!')
#define cr_or_whitespace(c) (((c) == '\t') || ((c) == ' ') || ((c) == '\n'))

#ifndef isletter
#define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
#endif

#ifndef isupper
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
#endif

#ifndef isdigit
#define isdigit(c)  ((c) >= '0' && (c) <= '9')
#endif

#ifndef digit_value
#define digit_value(c) ((c) - '0')
#endif

#define member(c, s) (strchr (s, c) != NULL)

#define COMMAND_PREFIX '@'

/* Stuff for splitting large files. */
#define SPLIT_SIZE_THRESHOLD 70000  /* What's good enough for Stallman... */
#define DEFAULT_SPLIT_SIZE 50000    /* Is probably good enough for me. */

DECLARE (int, splitting, 1);	/* Defaults to true for now. */

typedef void COMMAND_FUNCTION (); /* So I can say COMMAND_FUNCTION *foo; */

#define command_char(c) ((!whitespace(c)) && \
			 ((c) != '\n') && \
			 ((c) != '{') && \
			 ((c) != '}') && \
			 ((c) != '='))

#define skip_whitespace() \
     while ((input_text_offset != size_of_input_text) && \
	     whitespace (curchar())) \
       input_text_offset++

#define skip_whitespace_and_newlines() \
  do { \
   while ((input_text_offset != size_of_input_text) && \
	  (whitespace (curchar ()) || (curchar () == '\n'))) \
      { \
	 if (curchar () == '\n') \
	   line_number++; \
	 input_text_offset++; \
      } \
   } while (0)

#endif /* !MAKEINFO_H */