/* chew
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001,
+ 2002, 2003, 2005
Free Software Foundation, Inc.
Contributed by steve chamberlain @cygnus
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. */
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
/* Yet another way of extracting documentation from source.
No, I haven't finished it yet, but I hope you people like it better
Foo. */
-#include <ansidecl.h>
-#include "sysdep.h"
+#include "ansidecl.h"
#include <assert.h>
#include <stdio.h>
#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
#define DEF_SIZE 5000
#define STACK 50
typedef struct dict_struct dict_type;
-#define WORD(x) static void x()
-
static void
die (msg)
char *msg;
(*pc) ();
}
-WORD (call)
+static void
+call ()
{
stinst_type *oldpc = pc;
dict_type *e;
pc = oldpc + 2;
}
-WORD (remchar)
+static void
+remchar ()
{
if (tos->write_idx)
tos->write_idx--;
pc++;
}
-WORD (push_number)
+static void
+push_number ()
{
isp++;
icheck_range ();
pc++;
}
-WORD (push_text)
+static void
+push_text ()
{
tos++;
check_range ();
*/
static void
-paramstuff (void)
+paramstuff ()
{
unsigned int openp;
unsigned int fname;
string_type out;
init_string (&out);
+#define NO_PARAMS 1
+
/* Make sure that it's not already param'd or proto'd. */
- if (find (tos, "PARAMS") || find (tos, "PROTO") || !find (tos, "("))
+ if (NO_PARAMS
+ || find (tos, "PARAMS") || find (tos, "PROTO") || !find (tos, "("))
{
catstr (&out, tos);
}
/* turn {*
and *} into comments */
-WORD (translatecomments)
+static void
+translatecomments ()
{
unsigned int idx = 0;
string_type out;
pc++;
}
-#if 0
-
-/* This is not currently used. */
-
-/* turn everything not starting with a . into a comment */
-
-WORD (manglecomments)
-{
- unsigned int idx = 0;
- string_type out;
- init_string (&out);
-
- while (at (tos, idx))
- {
- if (at (tos, idx) == '\n' && at (tos, idx + 1) == '*')
- {
- cattext (&out, " /*");
- idx += 2;
- }
- else if (at (tos, idx) == '*' && at (tos, idx + 1) == '}')
- {
- cattext (&out, "*/");
- idx += 2;
- }
- else
- {
- catchar (&out, at (tos, idx));
- idx++;
- }
- }
-
- overwrite_string (tos, &out);
-
- pc++;
-}
-
-#endif
-
/* Mod tos so that only lines with leading dots remain */
static void
-outputdots (void)
+outputdots ()
{
unsigned int idx = 0;
string_type out;
}
/* Find lines starting with . and | and put example around them on tos */
-WORD (courierize)
+static void
+courierize ()
{
string_type out;
unsigned int idx = 0;
while (at (tos, idx) && at (tos, idx) != '\n')
{
- if (at (tos, idx) == '{' && at (tos, idx + 1) == '*')
+ if (command > 1)
+ {
+ /* We are inside {} parameters of some command;
+ Just pass through until matching brace. */
+ if (at (tos, idx) == '{')
+ ++command;
+ else if (at (tos, idx) == '}')
+ --command;
+ }
+ else if (command != 0)
+ {
+ if (at (tos, idx) == '{')
+ ++command;
+ else if (!islower ((unsigned char) at (tos, idx)))
+ --command;
+ }
+ else if (at (tos, idx) == '@'
+ && islower ((unsigned char) at (tos, idx + 1)))
+ {
+ ++command;
+ }
+ else if (at (tos, idx) == '{' && at (tos, idx + 1) == '*')
{
cattext (&out, "/*");
idx += 2;
+ continue;
}
else if (at (tos, idx) == '*' && at (tos, idx + 1) == '}')
{
cattext (&out, "*/");
idx += 2;
+ continue;
}
- else if (at (tos, idx) == '{' && !command)
+ else if (at (tos, idx) == '{'
+ || at (tos, idx) == '}')
{
- cattext (&out, "@{");
- idx++;
- }
- else if (at (tos, idx) == '}' && !command)
- {
- cattext (&out, "@}");
- idx++;
- }
- else
- {
- if (at (tos, idx) == '@')
- command = 1;
- else if (isspace ((unsigned char) at (tos, idx))
- || at (tos, idx) == '}')
- command = 0;
- catchar (&out, at (tos, idx));
- idx++;
+ catchar (&out, '@');
}
+ catchar (&out, at (tos, idx));
+ idx++;
}
catchar (&out, '\n');
}
on @itemize @bullet, and @items each of them. Then ends with @end
itemize, inplace at TOS*/
-WORD (bulletize)
+static void
+bulletize ()
{
unsigned int idx = 0;
int on = 0;
/* Turn <<foo>> into @code{foo} in place at TOS*/
-WORD (do_fancy_stuff)
+static void
+do_fancy_stuff ()
{
unsigned int idx = 0;
string_type out;
}
-WORD (icopy_past_newline)
+static void
+icopy_past_newline ()
{
tos++;
check_range ();
/* indent
Take the string at the top of the stack, do some prettying. */
-WORD (kill_bogus_lines)
+static void
+kill_bogus_lines ()
{
int sl;
}
-WORD (indent)
+static void
+indent ()
{
string_type out;
int tab = 0;
}
-WORD (get_stuff_in_command)
+static void
+get_stuff_in_command ()
{
tos++;
check_range ();
pc++;
}
-WORD (swap)
+static void
+swap ()
{
string_type t;
pc++;
}
-WORD (other_dup)
+static void
+other_dup ()
{
tos++;
check_range ();
pc++;
}
-WORD (drop)
+static void
+drop ()
{
tos--;
check_range ();
pc++;
}
-WORD (idrop)
+static void
+idrop ()
{
isp--;
icheck_range ();
pc++;
}
-WORD (icatstr)
+static void
+icatstr ()
{
tos--;
check_range ();
pc++;
}
-WORD (skip_past_newline)
+static void
+skip_past_newline ()
{
while (at (ptr, idx)
&& at (ptr, idx) != '\n')
pc++;
}
-WORD (internalmode)
+static void
+internalmode ()
{
internal_mode = *(isp);
isp--;
pc++;
}
-WORD (maybecatstr)
+static void
+maybecatstr ()
{
if (internal_wanted == internal_mode)
{
}
static void
-perform (void)
+perform ()
{
tos = stack;
}
static void
-bang (void)
+bang ()
{
*(long *) ((isp[0])) = isp[-1];
isp -= 2;
pc++;
}
-WORD (atsign)
+static void
+atsign ()
{
isp[0] = *(long *) (isp[0]);
pc++;
}
-WORD (hello)
+static void
+hello ()
{
printf ("hello\n");
pc++;
}
-WORD (stdout_)
+static void
+stdout_ ()
{
isp++;
icheck_range ();
pc++;
}
-WORD (stderr_)
+static void
+stderr_ ()
{
isp++;
icheck_range ();
pc++;
}
-WORD (print)
+static void
+print ()
{
if (*isp == 1)
write_buffer (tos, stdout);
}
static void
-usage (void)
+usage ()
{
fprintf (stderr, "usage: -[d|i|g] <file >file\n");
exit (33);