aboutsummaryrefslogtreecommitdiff
path: root/bfd/doc/chew.c
diff options
context:
space:
mode:
authorKazu Hirata <kazu@codesourcery.com>2000-09-08 23:46:41 +0000
committerKazu Hirata <kazu@codesourcery.com>2000-09-08 23:46:41 +0000
commitd70910e85dd5d9649eb50ab12f066ada9efe976b (patch)
treed91db291bc60bcc39bb958c7964d1251d7de94c8 /bfd/doc/chew.c
parent99f9523ca6165bc3b1d876a2eeb82bae78483fc4 (diff)
downloadgdb-d70910e85dd5d9649eb50ab12f066ada9efe976b.zip
gdb-d70910e85dd5d9649eb50ab12f066ada9efe976b.tar.gz
gdb-d70910e85dd5d9649eb50ab12f066ada9efe976b.tar.bz2
2000-09-08 Kazu Hirata <kazu@hxi.com>
* archive.c: Fix formatting. * coff-arm.c: Likewise. * doc/chew.c: Likewise.
Diffstat (limited to 'bfd/doc/chew.c')
-rw-r--r--bfd/doc/chew.c1619
1 files changed, 790 insertions, 829 deletions
diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c
index 6e0fc20..52de92e 100644
--- a/bfd/doc/chew.c
+++ b/bfd/doc/chew.c
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Yet another way of extracting documentation from source.
No, I haven't finished it yet, but I hope you people like it better
than the old way
-
+
sac
Basically, this is a sort of string forth, maybe we should call it
@@ -81,7 +81,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
Foo. */
-
#include <ansidecl.h>
#include "sysdep.h"
#include <assert.h>
@@ -96,16 +95,15 @@ int internal_mode;
int warning;
-/* Here is a string type ... */
+/* Here is a string type ... */
-typedef struct buffer
+typedef struct buffer
{
char *ptr;
unsigned long write_idx;
unsigned long size;
} string_type;
-
#ifdef __STDC__
static void init_string_with_size (string_type *, unsigned int);
static void init_string (string_type *);
@@ -121,23 +119,21 @@ static void cattext (string_type *, char *);
static void catstr (string_type *, string_type *);
#endif
-
static void
init_string_with_size (buffer, size)
string_type *buffer;
unsigned int size;
{
- buffer->write_idx = 0;
- buffer->size = size;
- buffer->ptr = malloc(size);
+ buffer->write_idx = 0;
+ buffer->size = size;
+ buffer->ptr = malloc (size);
}
static void
init_string (buffer)
string_type *buffer;
{
- init_string_with_size(buffer, DEF_SIZE);
-
+ init_string_with_size (buffer, DEF_SIZE);
}
static int
@@ -145,18 +141,17 @@ find (str, what)
string_type *str;
char *what;
{
- unsigned int i;
- char *p;
- p = what;
- for (i = 0; i < str->write_idx && *p; i++)
+ unsigned int i;
+ char *p;
+ p = what;
+ for (i = 0; i < str->write_idx && *p; i++)
{
- if (*p == str->ptr[i])
- p++;
- else
- p = what;
+ if (*p == str->ptr[i])
+ p++;
+ else
+ p = what;
}
- return (*p == 0);
-
+ return (*p == 0);
}
static void
@@ -164,24 +159,22 @@ write_buffer (buffer, f)
string_type *buffer;
FILE *f;
{
- fwrite(buffer->ptr, buffer->write_idx, 1, f);
+ fwrite (buffer->ptr, buffer->write_idx, 1, f);
}
-
static void
delete_string (buffer)
string_type *buffer;
{
- free(buffer->ptr);
+ free (buffer->ptr);
}
-
static char *
addr (buffer, idx)
string_type *buffer;
unsigned int idx;
{
- return buffer->ptr + idx;
+ return buffer->ptr + idx;
}
static char
@@ -189,7 +182,7 @@ at (buffer, pos)
string_type *buffer;
unsigned int pos;
{
- if (pos >= buffer->write_idx)
+ if (pos >= buffer->write_idx)
return 0;
return buffer->ptr[pos];
}
@@ -199,25 +192,24 @@ catchar (buffer, ch)
string_type *buffer;
int ch;
{
- if (buffer->write_idx == buffer->size)
+ if (buffer->write_idx == buffer->size)
{
- buffer->size *=2;
- buffer->ptr = realloc(buffer->ptr, buffer->size);
+ buffer->size *= 2;
+ buffer->ptr = realloc (buffer->ptr, buffer->size);
}
- buffer->ptr[buffer->write_idx ++ ] = ch;
+ buffer->ptr[buffer->write_idx++] = ch;
}
-
static void
overwrite_string (dst, src)
string_type *dst;
string_type *src;
{
- free(dst->ptr);
- dst->size = src->size;
- dst->write_idx = src->write_idx;
- dst->ptr = src->ptr;
+ free (dst->ptr);
+ dst->size = src->size;
+ dst->write_idx = src->write_idx;
+ dst->ptr = src->ptr;
}
static void
@@ -252,27 +244,25 @@ catstr (dst, src)
catbuf (dst, src->ptr, src->write_idx);
}
-
-static unsigned int
+static unsigned int
skip_white_and_stars (src, idx)
string_type *src;
unsigned int idx;
{
char c;
- while ((c = at(src,idx)),
+ while ((c = at (src, idx)),
isspace ((unsigned char) c)
|| (c == '*'
/* Don't skip past end-of-comment or star as first
character on its line. */
- && at(src,idx +1) != '/'
- && at(src,idx -1) != '\n'))
+ && at (src, idx +1) != '/'
+ && at (src, idx -1) != '\n'))
idx++;
return idx;
}
/***********************************************************************/
-
string_type stack[STACK];
string_type *tos;
@@ -287,19 +277,18 @@ long *isp = &istack[0];
typedef int *word_type;
-
-
struct dict_struct
{
- char *word;
- struct dict_struct *next;
- stinst_type *code;
- int code_length;
- int code_end;
- int var;
-
+ char *word;
+ struct dict_struct *next;
+ stinst_type *code;
+ int code_length;
+ int code_end;
+ int var;
};
+
typedef struct dict_struct dict_type;
+
#define WORD(x) static void x()
static void
@@ -369,23 +358,23 @@ exec (word)
dict_type *word;
{
pc = word->code;
- while (*pc)
- (*pc)();
+ while (*pc)
+ (*pc) ();
}
-WORD(call)
-{
- stinst_type *oldpc = pc;
- dict_type *e;
- e = (dict_type *)(pc [1]);
- exec(e);
- pc = oldpc + 2;
-
+
+WORD (call)
+{
+ stinst_type *oldpc = pc;
+ dict_type *e;
+ e = (dict_type *) (pc[1]);
+ exec (e);
+ pc = oldpc + 2;
}
-WORD(remchar)
+WORD (remchar)
{
if (tos->write_idx)
- tos->write_idx--;
+ tos->write_idx--;
pc++;
}
@@ -399,81 +388,80 @@ strip_trailing_newlines ()
pc++;
}
-WORD(push_number)
+WORD (push_number)
{
- isp++;
- icheck_range ();
- pc++;
- *isp = (long)(*pc);
- pc++;
+ isp++;
+ icheck_range ();
+ pc++;
+ *isp = (long) (*pc);
+ pc++;
}
-WORD(push_text)
+WORD (push_text)
{
- tos++;
- check_range ();
- init_string(tos);
- pc++;
- cattext(tos,*((char **)pc));
- pc++;
-
+ tos++;
+ check_range ();
+ init_string (tos);
+ pc++;
+ cattext (tos, *((char **) pc));
+ pc++;
}
-
/* This function removes everything not inside comments starting on
the first char of the line from the string, also when copying
comments, removes blank space and leading *'s.
Blank lines are turned into one blank line. */
-static void
-remove_noncomments (src,dst)
+static void
+remove_noncomments (src, dst)
string_type *src;
string_type *dst;
{
- unsigned int idx = 0;
-
- while (at(src,idx))
+ unsigned int idx = 0;
+
+ while (at (src, idx))
{
- /* Now see if we have a comment at the start of the line */
- if (at(src,idx) == '\n'
- && at(src,idx+1) == '/'
- && at(src,idx+2) == '*')
+ /* Now see if we have a comment at the start of the line. */
+ if (at (src, idx) == '\n'
+ && at (src, idx + 1) == '/'
+ && at (src, idx + 2) == '*')
{
- idx+=3;
-
- idx = skip_white_and_stars(src,idx);
-
- /* Remove leading dot */
- if (at(src, idx) == '.')
- idx++;
-
- /* Copy to the end of the line, or till the end of the
- comment */
- while (at(src, idx))
+ idx += 3;
+
+ idx = skip_white_and_stars (src, idx);
+
+ /* Remove leading dot */
+ if (at (src, idx) == '.')
+ idx++;
+
+ /* Copy to the end of the line, or till the end of the
+ comment. */
+ while (at (src, idx))
{
- if (at(src, idx) == '\n')
+ if (at (src, idx) == '\n')
{
- /* end of line, echo and scrape of leading blanks */
- if (at(src,idx +1) == '\n')
- catchar(dst,'\n');
- catchar(dst,'\n');
- idx++;
- idx = skip_white_and_stars(src, idx);
+ /* end of line, echo and scrape of leading blanks */
+ if (at (src, idx + 1) == '\n')
+ catchar (dst, '\n');
+ catchar (dst, '\n');
+ idx++;
+ idx = skip_white_and_stars (src, idx);
}
- else if (at(src, idx) == '*' && at(src,idx+1) == '/')
+ else if (at (src, idx) == '*' && at (src, idx + 1) == '/')
{
- idx +=2 ;
- cattext(dst,"\nENDDD\n");
- break;
+ idx += 2;
+ cattext (dst, "\nENDDD\n");
+ break;
}
- else
+ else
{
- catchar(dst, at(src, idx));
- idx++;
+ catchar (dst, at (src, idx));
+ idx++;
}
}
}
- else idx++;
+ else
+ idx++;
}
}
@@ -496,96 +484,92 @@ print_stack_level ()
static void
paramstuff (void)
{
- unsigned int openp;
- unsigned int fname;
- unsigned int idx;
- string_type out;
- init_string(&out);
-
+ unsigned int openp;
+ unsigned int fname;
+ unsigned int idx;
+ string_type out;
+ init_string (&out);
- /* make sure that it's not already param'd or proto'd */
- if(find(tos,"PARAMS") || find(tos,"PROTO") || !find(tos,"(")) {
- catstr(&out,tos);
- }
- else
+ /* Make sure that it's not already param'd or proto'd. */
+ if (find (tos, "PARAMS") || find (tos, "PROTO") || !find (tos, "("))
{
- /* Find the open paren */
- for (openp = 0; at(tos, openp) != '(' && at(tos,openp); openp++)
- ;
-
- fname = openp;
- /* Step back to the fname */
+ catstr (&out, tos);
+ }
+ else
+ {
+ /* Find the open paren. */
+ for (openp = 0; at (tos, openp) != '(' && at (tos, openp); openp++)
+ ;
+
+ fname = openp;
+ /* Step back to the fname. */
+ fname--;
+ while (fname && isspace ((unsigned char) at (tos, fname)))
+ fname--;
+ while (fname
+ && !isspace ((unsigned char) at (tos,fname))
+ && at (tos,fname) != '*')
fname--;
- while (fname && isspace((unsigned char) at(tos, fname)))
- fname --;
- while (fname
- && !isspace((unsigned char) at(tos,fname))
- && at(tos,fname) != '*')
- fname--;
-
- fname++;
-
- for (idx = 0; idx < fname; idx++) /* Output type */
+
+ fname++;
+
+ for (idx = 0; idx < fname; idx++) /* Output type */
{
- catchar(&out, at(tos,idx));
+ catchar (&out, at (tos, idx));
}
-
- cattext(&out, "\n"); /* Insert a newline between type and fnname */
- for (idx = fname; idx < openp; idx++) /* Output fnname */
+ cattext (&out, "\n"); /* Insert a newline between type and fnname */
+
+ for (idx = fname; idx < openp; idx++) /* Output fnname */
{
- catchar(&out, at(tos,idx));
+ catchar (&out, at (tos, idx));
}
- cattext(&out," PARAMS (");
+ cattext (&out, " PARAMS (");
- while (at(tos,idx) && at(tos,idx) !=';')
+ while (at (tos, idx) && at (tos, idx) != ';')
{
- catchar(&out, at(tos, idx));
- idx++;
+ catchar (&out, at (tos, idx));
+ idx++;
}
- cattext(&out,");\n\n");
+ cattext (&out, ");\n\n");
}
- overwrite_string(tos, &out);
- pc++;
-
-}
-
+ overwrite_string (tos, &out);
+ pc++;
+}
/* turn {*
and *} into comments */
-WORD(translatecomments)
+WORD (translatecomments)
{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
+ unsigned int idx = 0;
+ string_type out;
+ init_string (&out);
+
+ while (at (tos, idx))
{
- if (at(tos,idx) == '{' && at(tos,idx+1) =='*')
+ if (at (tos, idx) == '{' && at (tos, idx + 1) == '*')
{
- cattext(&out,"/*");
- idx+=2;
+ cattext (&out, "/*");
+ idx += 2;
}
- else if (at(tos,idx) == '*' && at(tos,idx+1) =='}')
+ else if (at (tos, idx) == '*' && at (tos, idx + 1) == '}')
{
- cattext(&out,"*/");
- idx+=2;
+ cattext (&out, "*/");
+ idx += 2;
}
- else
+ else
{
- catchar(&out, at(tos, idx));
- idx++;
+ catchar (&out, at (tos, idx));
+ idx++;
}
}
+ overwrite_string (tos, &out);
- overwrite_string(tos, &out);
-
- pc++;
-
+ pc++;
}
#if 0
@@ -594,36 +578,34 @@ WORD(translatecomments)
/* turn everything not starting with a . into a comment */
-WORD(manglecomments)
+WORD (manglecomments)
{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
+ unsigned int idx = 0;
+ string_type out;
+ init_string (&out);
+
+ while (at (tos, idx))
{
- if (at(tos,idx) == '\n' && at(tos,idx+1) =='*')
+ if (at (tos, idx) == '\n' && at (tos, idx + 1) == '*')
{
- cattext(&out," /*");
- idx+=2;
+ cattext (&out, " /*");
+ idx += 2;
}
- else if (at(tos,idx) == '*' && at(tos,idx+1) =='}')
+ else if (at (tos, idx) == '*' && at (tos, idx + 1) == '}')
{
- cattext(&out,"*/");
- idx+=2;
+ cattext (&out, "*/");
+ idx += 2;
}
- else
+ else
{
- catchar(&out, at(tos, idx));
- idx++;
+ catchar (&out, at (tos, idx));
+ idx++;
}
}
+ overwrite_string (tos, &out);
- overwrite_string(tos, &out);
-
- pc++;
-
+ pc++;
}
#endif
@@ -632,509 +614,506 @@ WORD(manglecomments)
static void
outputdots (void)
{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
+ unsigned int idx = 0;
+ string_type out;
+ init_string (&out);
+
+ while (at (tos, idx))
{
- if (at(tos, idx) == '\n' && at(tos, idx+1) == '.')
+ if (at (tos, idx) == '\n' && at (tos, idx + 1) == '.')
{
char c;
idx += 2;
-
- while ((c = at(tos, idx)) && c != '\n')
+
+ while ((c = at (tos, idx)) && c != '\n')
{
- if (c == '{' && at(tos,idx+1) =='*')
+ if (c == '{' && at (tos, idx + 1) == '*')
{
- cattext(&out,"/*");
- idx+=2;
+ cattext (&out, "/*");
+ idx += 2;
}
- else if (c == '*' && at(tos,idx+1) =='}')
+ else if (c == '*' && at (tos, idx + 1) == '}')
{
- cattext(&out,"*/");
- idx+=2;
+ cattext (&out, "*/");
+ idx += 2;
}
else
{
- catchar(&out, c);
- idx++;
+ catchar (&out, c);
+ idx++;
}
}
- catchar(&out,'\n');
+ catchar (&out, '\n');
}
- else
+ else
{
- idx++;
+ idx++;
}
- }
+ }
- overwrite_string(tos, &out);
- pc++;
-
+ overwrite_string (tos, &out);
+ pc++;
}
/* Find lines starting with . and | and put example around them on tos */
-WORD(courierize)
-{
- string_type out;
- unsigned int idx = 0;
- int command = 0;
-
- init_string(&out);
-
- while (at(tos, idx))
+WORD (courierize)
+{
+ string_type out;
+ unsigned int idx = 0;
+ int command = 0;
+
+ init_string (&out);
+
+ while (at (tos, idx))
{
- if (at(tos, idx) == '\n'
- && (at(tos, idx +1 ) == '.'
- || at(tos,idx+1) == '|'))
+ if (at (tos, idx) == '\n'
+ && (at (tos, idx +1 ) == '.'
+ || at (tos, idx + 1) == '|'))
{
- cattext(&out,"\n@example\n");
- do
+ cattext (&out, "\n@example\n");
+ do
{
- idx += 2;
-
- while (at(tos, idx) && at(tos, idx)!='\n')
+ idx += 2;
+
+ while (at (tos, idx) && at (tos, idx) != '\n')
{
- if (at(tos,idx)=='{' && at(tos,idx+1) =='*')
+ if (at (tos, idx) == '{' && at (tos, idx + 1) == '*')
{
- cattext(&out,"/*");
- idx+=2;
+ cattext (&out, "/*");
+ idx += 2;
}
- else if (at(tos,idx)=='*' && at(tos,idx+1) =='}')
+ else if (at (tos, idx) == '*' && at (tos, idx + 1) == '}')
{
- cattext(&out,"*/");
- idx+=2;
+ cattext (&out, "*/");
+ idx += 2;
}
- else if (at(tos,idx) == '{' && !command)
+ else if (at (tos, idx) == '{' && !command)
{
- cattext(&out,"@{");
- idx++;
+ cattext (&out, "@{");
+ idx++;
}
- else if (at(tos,idx) == '}' && !command)
+ else if (at (tos, idx) == '}' && !command)
{
- cattext(&out,"@}");
- idx++;
+ cattext (&out, "@}");
+ idx++;
}
- else
+ 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++;
+ 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,'\n');
- }
- while (at(tos, idx) == '\n'
- && ((at(tos, idx+1) == '.')
- || (at(tos,idx+1) == '|')))
- ;
- cattext(&out,"@end example");
+ catchar (&out, '\n');
+ }
+ while (at (tos, idx) == '\n'
+ && ((at (tos, idx + 1) == '.')
+ || (at (tos, idx + 1) == '|')))
+ ;
+ cattext (&out, "@end example");
}
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
+ else
+ {
+ catchar (&out, at (tos, idx));
+ idx++;
}
- }
-
- overwrite_string(tos, &out);
- pc++;
+ }
-
+ overwrite_string (tos, &out);
+ pc++;
}
/* Finds any lines starting with "o ", if there are any, then turns
on @itemize @bullet, and @items each of them. Then ends with @end
itemize, inplace at TOS*/
-
-WORD(bulletize)
+WORD (bulletize)
{
- unsigned int idx = 0;
- int on = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx)) {
- if (at(tos, idx) == '@' &&
- at(tos, idx+1) == '*')
+ unsigned int idx = 0;
+ int on = 0;
+ string_type out;
+ init_string (&out);
+
+ while (at (tos, idx))
+ {
+ if (at (tos, idx) == '@'
+ && at (tos, idx + 1) == '*')
{
- cattext(&out,"*");
- idx+=2;
+ cattext (&out, "*");
+ idx += 2;
}
-
- else
- if (at(tos, idx) == '\n' &&
- at(tos, idx+1) == 'o' &&
- isspace((unsigned char) at(tos, idx +2)))
+ else if (at (tos, idx) == '\n'
+ && at (tos, idx + 1) == 'o'
+ && isspace ((unsigned char) at (tos, idx + 2)))
+ {
+ if (!on)
{
- if (!on)
- {
- cattext(&out,"\n@itemize @bullet\n");
- on = 1;
-
- }
- cattext(&out,"\n@item\n");
- idx+=3;
+ cattext (&out, "\n@itemize @bullet\n");
+ on = 1;
+
}
- else
+ cattext (&out, "\n@item\n");
+ idx += 3;
+ }
+ else
+ {
+ catchar (&out, at (tos, idx));
+ if (on && at (tos, idx) == '\n'
+ && at (tos, idx + 1) == '\n'
+ && at (tos, idx + 2) != 'o')
{
- catchar(&out, at(tos, idx));
- if (on && at(tos, idx) == '\n' &&
- at(tos, idx+1) == '\n' &&
- at(tos, idx+2) != 'o')
- {
- cattext(&out, "@end itemize");
- on = 0;
- }
- idx++;
-
+ cattext (&out, "@end itemize");
+ on = 0;
}
+ idx++;
+
}
- if (on)
+ }
+ if (on)
{
- cattext(&out,"@end itemize\n");
- }
+ cattext (&out, "@end itemize\n");
+ }
- delete_string(tos);
- *tos = out;
- pc++;
-
+ delete_string (tos);
+ *tos = out;
+ pc++;
}
/* Turn <<foo>> into @code{foo} in place at TOS*/
-
-WORD(do_fancy_stuff)
+WORD (do_fancy_stuff)
{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
- while (at(tos, idx))
+ unsigned int idx = 0;
+ string_type out;
+ init_string (&out);
+ while (at (tos, idx))
{
- if (at(tos, idx) == '<'
- && at(tos, idx+1) == '<'
- && !isspace((unsigned char) at(tos,idx + 2)))
+ if (at (tos, idx) == '<'
+ && at (tos, idx + 1) == '<'
+ && !isspace ((unsigned char) at (tos, idx + 2)))
{
- /* This qualifies as a << startup */
- idx +=2;
- cattext(&out,"@code{");
- while(at(tos,idx) &&
- at(tos,idx) != '>' )
+ /* This qualifies as a << startup. */
+ idx += 2;
+ cattext (&out, "@code{");
+ while (at (tos, idx)
+ && at (tos, idx) != '>' )
{
- catchar(&out, at(tos, idx));
- idx++;
-
+ catchar (&out, at (tos, idx));
+ idx++;
+
}
- cattext(&out,"}");
- idx+=2;
+ cattext (&out, "}");
+ idx += 2;
}
- else
+ else
{
- catchar(&out, at(tos, idx));
- idx++;
+ catchar (&out, at (tos, idx));
+ idx++;
}
}
- delete_string(tos);
- *tos = out;
- pc++;
-
+ delete_string (tos);
+ *tos = out;
+ pc++;
+
}
-/* A command is all upper case,and alone on a line */
-static int
+
+/* A command is all upper case,and alone on a line. */
+
+static int
iscommand (ptr, idx)
string_type *ptr;
unsigned int idx;
{
- unsigned int len = 0;
- while (at(ptr,idx)) {
- if (isupper((unsigned char) at(ptr,idx)) || at(ptr,idx) == ' ' ||
- at(ptr,idx) == '_')
- {
- len++;
- idx++;
- }
- else if(at(ptr,idx) == '\n')
- {
- if (len > 3) return 1;
- return 0;
- }
- else return 0;
+ unsigned int len = 0;
+ while (at (ptr, idx))
+ {
+ if (isupper ((unsigned char) at (ptr, idx))
+ || at (ptr, idx) == ' ' || at (ptr, idx) == '_')
+ {
+ len++;
+ idx++;
}
- return 0;
-
+ else if (at (ptr, idx) == '\n')
+ {
+ if (len > 3)
+ return 1;
+ return 0;
+ }
+ else
+ return 0;
+ }
+ return 0;
}
-
static int
copy_past_newline (ptr, idx, dst)
string_type *ptr;
unsigned int idx;
string_type *dst;
{
- int column = 0;
+ int column = 0;
- while (at(ptr, idx) && at(ptr, idx) != '\n')
+ while (at (ptr, idx) && at (ptr, idx) != '\n')
{
- if (at (ptr, idx) == '\t')
- {
- /* Expand tabs. Neither makeinfo nor TeX can cope well with
- them. */
- do
- catchar (dst, ' ');
- while (++column & 7);
- }
- else
- {
- catchar(dst, at(ptr, idx));
- column++;
- }
- idx++;
-
- }
- catchar(dst, at(ptr, idx));
- idx++;
- return idx;
+ if (at (ptr, idx) == '\t')
+ {
+ /* Expand tabs. Neither makeinfo nor TeX can cope well with
+ them. */
+ do
+ catchar (dst, ' ');
+ while (++column & 7);
+ }
+ else
+ {
+ catchar (dst, at (ptr, idx));
+ column++;
+ }
+ idx++;
+
+ }
+ catchar (dst, at (ptr, idx));
+ idx++;
+ return idx;
}
-WORD(icopy_past_newline)
+WORD (icopy_past_newline)
{
- tos++;
- check_range ();
- init_string(tos);
- idx = copy_past_newline(ptr, idx, tos);
- pc++;
+ tos++;
+ check_range ();
+ init_string (tos);
+ idx = copy_past_newline (ptr, idx, tos);
+ pc++;
}
/* indent
- Take the string at the top of the stack, do some prettying */
+ Take the string at the top of the stack, do some prettying. */
-
-WORD(kill_bogus_lines)
+WORD (kill_bogus_lines)
{
- int sl ;
-
- int idx = 0;
- int c;
- int dot = 0 ;
-
- string_type out;
- init_string(&out);
- /* Drop leading nl */
- while (at(tos,idx) == '\n')
+ int sl;
+
+ int idx = 0;
+ int c;
+ int dot = 0;
+
+ string_type out;
+ init_string (&out);
+ /* Drop leading nl. */
+ while (at (tos, idx) == '\n')
{
- idx++;
+ idx++;
}
- c = idx;
-
- /* If the first char is a '.' prepend a newline so that it is
- recognized properly later. */
- if (at (tos, idx) == '.')
- catchar (&out, '\n');
-
- /* Find the last char */
- while (at(tos,idx))
+ c = idx;
+
+ /* If the first char is a '.' prepend a newline so that it is
+ recognized properly later. */
+ if (at (tos, idx) == '.')
+ catchar (&out, '\n');
+
+ /* Find the last char. */
+ while (at (tos, idx))
{
- idx++;
+ idx++;
}
-
- /* find the last non white before the nl */
+
+ /* Find the last non white before the nl. */
+ idx--;
+
+ while (idx && isspace ((unsigned char) at (tos, idx)))
idx--;
-
- while (idx && isspace((unsigned char) at(tos,idx)))
- idx--;
- idx++;
-
- /* Copy buffer upto last char, but blank lines before and after
- dots don't count */
- sl = 1;
+ idx++;
- while (c < idx)
+ /* Copy buffer upto last char, but blank lines before and after
+ dots don't count. */
+ sl = 1;
+
+ while (c < idx)
{
- if (at(tos,c) == '\n'
- && at(tos,c+1) == '\n'
- && at(tos,c+2) == '.')
+ if (at (tos, c) == '\n'
+ && at (tos, c + 1) == '\n'
+ && at (tos, c + 2) == '.')
{
- /* Ignore two newlines before a dot*/
- c++;
+ /* Ignore two newlines before a dot. */
+ c++;
}
- else if (at(tos,c) == '.' && sl)
+ else if (at (tos, c) == '.' && sl)
{
- /* remember that this line started with a dot */
- dot=2;
+ /* remember that this line started with a dot. */
+ dot = 2;
}
- else if (at(tos,c) == '\n'
- && at(tos,c+1) == '\n'
- && dot)
+ else if (at (tos, c) == '\n'
+ && at (tos, c + 1) == '\n'
+ && dot)
{
- c++;
- /* Ignore two newlines when last line was dot */
+ c++;
+ /* Ignore two newlines when last line was dot. */
}
- catchar(&out, at(tos,c));
- if (at(tos,c) == '\n')
+ catchar (&out, at (tos, c));
+ if (at (tos, c) == '\n')
{
- sl = 1;
-
- if (dot == 2)dot=1;else dot = 0;
+ sl = 1;
+
+ if (dot == 2)
+ dot = 1;
+ else
+ dot = 0;
}
- else
- sl = 0;
-
- c++;
+ else
+ sl = 0;
+
+ c++;
}
-
- /* Append nl*/
- catchar(&out, '\n');
- pc++;
- delete_string(tos);
- *tos = out;
-
-
+
+ /* Append nl. */
+ catchar (&out, '\n');
+ pc++;
+ delete_string (tos);
+ *tos = out;
+
}
-WORD(indent)
+WORD (indent)
{
- string_type out;
- int tab = 0;
- int idx = 0;
- int ol =0;
- init_string(&out);
- while (at(tos,idx)) {
- switch (at(tos,idx))
+ string_type out;
+ int tab = 0;
+ int idx = 0;
+ int ol = 0;
+ init_string (&out);
+ while (at (tos, idx))
+ {
+ switch (at (tos, idx))
+ {
+ case '\n':
+ cattext (&out, "\n");
+ idx++;
+ if (tab && at (tos, idx))
{
- case '\n':
- cattext(&out,"\n");
- idx++;
- if (tab && at(tos,idx))
- {
- cattext(&out," ");
- }
- ol = 0;
- break;
- case '(':
- tab++;
- if (ol == 0)
- cattext(&out," ");
- idx++;
- cattext(&out,"(");
- ol = 1;
- break;
- case ')':
- tab--;
- cattext(&out,")");
- idx++;
- ol=1;
-
- break;
- default:
- catchar(&out,at(tos,idx));
- ol=1;
-
- idx++;
- break;
+ cattext (&out, " ");
}
- }
+ ol = 0;
+ break;
+ case '(':
+ tab++;
+ if (ol == 0)
+ cattext (&out, " ");
+ idx++;
+ cattext (&out, "(");
+ ol = 1;
+ break;
+ case ')':
+ tab--;
+ cattext (&out, ")");
+ idx++;
+ ol = 1;
+
+ break;
+ default:
+ catchar (&out, at (tos, idx));
+ ol = 1;
+
+ idx++;
+ break;
+ }
+ }
- pc++;
- delete_string(tos);
- *tos = out;
+ pc++;
+ delete_string (tos);
+ *tos = out;
}
-
-WORD(get_stuff_in_command)
+WORD (get_stuff_in_command)
{
- tos++;
- check_range ();
- init_string(tos);
+ tos++;
+ check_range ();
+ init_string (tos);
- while (at(ptr, idx)) {
- if (iscommand(ptr, idx)) break;
- idx = copy_past_newline(ptr, idx, tos);
- }
- pc++;
+ while (at (ptr, idx))
+ {
+ if (iscommand (ptr, idx))
+ break;
+ idx = copy_past_newline (ptr, idx, tos);
+ }
+ pc++;
}
-WORD(swap)
+WORD (swap)
{
- string_type t;
-
- t = tos[0];
- tos[0] = tos[-1];
- tos[-1] =t;
- pc++;
-
+ string_type t;
+
+ t = tos[0];
+ tos[0] = tos[-1];
+ tos[-1] = t;
+ pc++;
}
-WORD(other_dup)
+WORD (other_dup)
{
- tos++;
- check_range ();
- init_string(tos);
- catstr(tos, tos-1);
- pc++;
+ tos++;
+ check_range ();
+ init_string (tos);
+ catstr (tos, tos - 1);
+ pc++;
}
-WORD(drop)
+WORD (drop)
{
tos--;
check_range ();
pc++;
}
-WORD(idrop)
+WORD (idrop)
{
isp--;
icheck_range ();
pc++;
}
-WORD(icatstr)
+WORD (icatstr)
{
- tos--;
- check_range ();
- catstr(tos, tos+1);
- delete_string(tos+1);
- pc++;
+ tos--;
+ check_range ();
+ catstr (tos, tos + 1);
+ delete_string (tos + 1);
+ pc++;
}
-WORD(skip_past_newline)
+WORD (skip_past_newline)
{
- while (at(ptr,idx)
- && at(ptr,idx) != '\n')
- idx++;
+ while (at (ptr, idx)
+ && at (ptr, idx) != '\n')
idx++;
- pc++;
+ idx++;
+ pc++;
}
-
-WORD(internalmode)
+WORD (internalmode)
{
- internal_mode = *(isp);
- isp--;
- icheck_range ();
- pc++;
+ internal_mode = *(isp);
+ isp--;
+ icheck_range ();
+ pc++;
}
-WORD(maybecatstr)
+WORD (maybecatstr)
{
- if (internal_wanted == internal_mode)
+ if (internal_wanted == internal_mode)
{
- catstr(tos-1, tos);
+ catstr (tos - 1, tos);
}
- delete_string(tos);
- tos--;
- check_range ();
- pc++;
+ delete_string (tos);
+ tos--;
+ check_range ();
+ pc++;
}
char *
@@ -1142,142 +1121,137 @@ nextword (string, word)
char *string;
char **word;
{
- char *word_start;
- int idx;
- char *dst;
- char *src;
-
- int length = 0;
-
- while (isspace((unsigned char) *string) || *string == '-') {
- if (*string == '-')
- {
- while (*string && *string != '\n')
- string++;
-
- }
- else {
- string++;
- }
- }
- if (!*string) return 0;
-
- word_start = string;
- if (*string == '"')
- {
- do
- {
- string++;
- length++;
- if (*string == '\\')
- {
- string += 2;
- length += 2;
- }
- }
- while (*string != '"');
- }
- else
- {
- while (!isspace((unsigned char) *string))
+ char *word_start;
+ int idx;
+ char *dst;
+ char *src;
+
+ int length = 0;
+
+ while (isspace ((unsigned char) *string) || *string == '-')
+ {
+ if (*string == '-')
{
+ while (*string && *string != '\n')
string++;
- length++;
-
+
+ }
+ else
+ {
+ string++;
}
}
-
- *word = malloc(length + 1);
-
- dst = *word;
- src = word_start;
-
+ if (!*string)
+ return 0;
- for (idx= 0; idx < length; idx++)
- {
- if (src[idx] == '\\')
- switch (src[idx+1])
+ word_start = string;
+ if (*string == '"')
+ {
+ do
+ {
+ string++;
+ length++;
+ if (*string == '\\')
{
- case 'n':
- *dst++ = '\n';
- idx++;
- break;
- case '"':
- case '\\':
- *dst++ = src[idx+1];
- idx++;
- break;
- default:
- *dst++ = '\\';
- break;
+ string += 2;
+ length += 2;
}
- else
- *dst++ = src[idx];
+ }
+ while (*string != '"');
}
- *dst++ = 0;
+ else
+ {
+ while (!isspace ((unsigned char) *string))
+ {
+ string++;
+ length++;
+ }
+ }
+ *word = malloc (length + 1);
+ dst = *word;
+ src = word_start;
+ for (idx = 0; idx < length; idx++)
+ {
+ if (src[idx] == '\\')
+ switch (src[idx + 1])
+ {
+ case 'n':
+ *dst++ = '\n';
+ idx++;
+ break;
+ case '"':
+ case '\\':
+ *dst++ = src[idx + 1];
+ idx++;
+ break;
+ default:
+ *dst++ = '\\';
+ break;
+ }
+ else
+ *dst++ = src[idx];
+ }
+ *dst++ = 0;
- if(*string)
- return string + 1;
- else
- return 0;
-
+ if (*string)
+ return string + 1;
+ else
+ return 0;
}
+
dict_type *root;
+
dict_type *
lookup_word (word)
char *word;
{
dict_type *ptr = root;
- while (ptr) {
- if (strcmp(ptr->word, word) == 0) return ptr;
+ while (ptr)
+ {
+ if (strcmp (ptr->word, word) == 0)
+ return ptr;
ptr = ptr->next;
-
}
if (warning)
- fprintf(stderr,"Can't find %s\n",word);
+ fprintf (stderr, "Can't find %s\n", word);
return 0;
-
-
}
static void
perform (void)
{
tos = stack;
-
- while (at(ptr, idx)) {
- /* It's worth looking through the command list */
- if (iscommand(ptr, idx))
- {
- char *next;
- dict_type *word ;
-
- (void) nextword(addr(ptr, idx), &next);
+ while (at (ptr, idx))
+ {
+ /* It's worth looking through the command list. */
+ if (iscommand (ptr, idx))
+ {
+ char *next;
+ dict_type *word;
- word = lookup_word(next);
+ (void) nextword (addr (ptr, idx), &next);
+ word = lookup_word (next);
-
+ if (word)
+ {
+ exec (word);
+ }
+ else
+ {
+ if (warning)
+ fprintf (stderr, "warning, %s is not recognised\n", next);
+ skip_past_newline ();
+ }
- if (word)
- {
- exec(word);
}
- else
- {
- if (warning)
- fprintf(stderr,"warning, %s is not recognised\n", next);
- skip_past_newline();
- }
-
- }
- else skip_past_newline();
-
+ else
+ skip_past_newline ();
}
}
@@ -1285,154 +1259,141 @@ dict_type *
newentry (word)
char *word;
{
- dict_type *new = (dict_type *)malloc(sizeof(dict_type));
- new->word = word;
- new->next = root;
- root = new;
- new->code = (stinst_type *)malloc(sizeof(stinst_type ));
- new->code_length = 1;
- new->code_end = 0;
- return new;
-
+ dict_type *new = (dict_type *) malloc (sizeof (dict_type));
+ new->word = word;
+ new->next = root;
+ root = new;
+ new->code = (stinst_type *) malloc (sizeof (stinst_type));
+ new->code_length = 1;
+ new->code_end = 0;
+ return new;
}
-
unsigned int
add_to_definition (entry, word)
dict_type *entry;
stinst_type word;
{
- if (entry->code_end == entry->code_length)
+ if (entry->code_end == entry->code_length)
{
- entry->code_length += 2;
- entry->code =
- (stinst_type *) realloc((char *)(entry->code),
- entry->code_length *sizeof(word_type));
+ entry->code_length += 2;
+ entry->code =
+ (stinst_type *) realloc ((char *) (entry->code),
+ entry->code_length * sizeof (word_type));
}
- entry->code[entry->code_end] = word;
-
-return entry->code_end++;
-}
-
-
-
-
-
+ entry->code[entry->code_end] = word;
+ return entry->code_end++;
+}
void
add_intrinsic (name, func)
char *name;
- void (*func)();
+ void (*func) ();
{
- dict_type *new = newentry(name);
- add_to_definition(new, func);
- add_to_definition(new, 0);
+ dict_type *new = newentry (name);
+ add_to_definition (new, func);
+ add_to_definition (new, 0);
}
void
add_var (name)
char *name;
{
- dict_type *new = newentry(name);
- add_to_definition(new, push_number);
- add_to_definition(new, (stinst_type)(&(new->var)));
- add_to_definition(new,0);
+ dict_type *new = newentry (name);
+ add_to_definition (new, push_number);
+ add_to_definition (new, (stinst_type) (&(new->var)));
+ add_to_definition (new, 0);
}
-
-void
+void
compile (string)
char *string;
{
- /* add words to the dictionary */
- char *word;
- string = nextword(string, &word);
- while (string && *string && word[0])
+ /* Add words to the dictionary. */
+ char *word;
+ string = nextword (string, &word);
+ while (string && *string && word[0])
{
- if (strcmp(word,"var")==0)
+ if (strcmp (word, "var") == 0)
{
- string=nextword(string, &word);
-
- add_var(word);
- string=nextword(string, &word);
+ string = nextword (string, &word);
+
+ add_var (word);
+ string = nextword (string, &word);
}
-else
-
- if (word[0] == ':')
+ else if (word[0] == ':')
{
- dict_type *ptr;
- /* Compile a word and add to dictionary */
- string = nextword(string, &word);
-
- ptr = newentry(word);
- string = nextword(string, &word);
- while (word[0] != ';' )
+ dict_type *ptr;
+ /* Compile a word and add to dictionary. */
+ string = nextword (string, &word);
+
+ ptr = newentry (word);
+ string = nextword (string, &word);
+ while (word[0] != ';')
{
- switch (word[0])
- {
- case '"':
- /* got a string, embed magic push string
- function */
- add_to_definition(ptr, push_text);
- add_to_definition(ptr, (stinst_type)(word+1));
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- /* Got a number, embedd the magic push number
- function */
- add_to_definition(ptr, push_number);
- add_to_definition(ptr, (stinst_type)atol(word));
- break;
- default:
- add_to_definition(ptr, call);
- add_to_definition(ptr, (stinst_type)lookup_word(word));
- }
-
- string = nextword(string, &word);
+ switch (word[0])
+ {
+ case '"':
+ /* got a string, embed magic push string
+ function */
+ add_to_definition (ptr, push_text);
+ add_to_definition (ptr, (stinst_type) (word + 1));
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ /* Got a number, embedd the magic push number
+ function */
+ add_to_definition (ptr, push_number);
+ add_to_definition (ptr, (stinst_type) atol (word));
+ break;
+ default:
+ add_to_definition (ptr, call);
+ add_to_definition (ptr, (stinst_type) lookup_word (word));
+ }
+
+ string = nextword (string, &word);
}
- add_to_definition(ptr,0);
- string = nextword(string, &word);
+ add_to_definition (ptr, 0);
+ string = nextword (string, &word);
}
- else
+ else
{
- fprintf(stderr,"syntax error at %s\n",string-1);
- }
+ fprintf (stderr, "syntax error at %s\n", string - 1);
+ }
}
-
}
-
static void
bang (void)
{
- *(long *)((isp[0])) = isp[-1];
- isp-=2;
+ *(long *) ((isp[0])) = isp[-1];
+ isp -= 2;
icheck_range ();
pc++;
}
-WORD(atsign)
+WORD (atsign)
{
- isp[0] = *(long *)(isp[0]);
- pc++;
+ isp[0] = *(long *) (isp[0]);
+ pc++;
}
-WORD(hello)
+WORD (hello)
{
- printf("hello\n");
- pc++;
+ printf ("hello\n");
+ pc++;
}
-WORD(stdout_)
+WORD (stdout_)
{
isp++;
icheck_range ();
@@ -1440,7 +1401,7 @@ WORD(stdout_)
pc++;
}
-WORD(stderr_)
+WORD (stderr_)
{
isp++;
icheck_range ();
@@ -1448,7 +1409,7 @@ WORD(stderr_)
pc++;
}
-WORD(print)
+WORD (print)
{
if (*isp == 1)
write_buffer (tos, stdout);
@@ -1463,31 +1424,29 @@ WORD(print)
pc++;
}
-
static void
read_in (str, file)
- string_type *str;
- FILE *file;
+ string_type *str;
+ FILE *file;
{
- char buff[10000];
- unsigned int r;
- do
+ char buff[10000];
+ unsigned int r;
+ do
{
- r = fread(buff, 1, sizeof(buff), file);
- catbuf(str, buff, r);
+ r = fread (buff, 1, sizeof (buff), file);
+ catbuf (str, buff, r);
}
- while (r);
- buff[0] = 0;
-
- catbuf(str, buff,1);
-}
+ while (r);
+ buff[0] = 0;
+ catbuf (str, buff, 1);
+}
static void
usage (void)
{
- fprintf(stderr,"usage: -[d|i|g] <file >file\n");
- exit(33);
+ fprintf (stderr, "usage: -[d|i|g] <file >file\n");
+ exit (33);
}
/* There is no reliable way to declare exit. Sometimes it returns
@@ -1502,7 +1461,7 @@ chew_exit ()
}
int
-main (ac,av)
+main (ac, av)
int ac;
char *av[];
{
@@ -1510,87 +1469,89 @@ main (ac,av)
string_type buffer;
string_type pptr;
- init_string(&buffer);
- init_string(&pptr);
- init_string(stack+0);
- tos=stack+1;
+ init_string (&buffer);
+ init_string (&pptr);
+ init_string (stack + 0);
+ tos = stack + 1;
ptr = &pptr;
-
- add_intrinsic("push_text", push_text);
- add_intrinsic("!", bang);
- add_intrinsic("@", atsign);
- add_intrinsic("hello",hello);
- add_intrinsic("stdout",stdout_);
- add_intrinsic("stderr",stderr_);
- add_intrinsic("print",print);
- add_intrinsic("skip_past_newline", skip_past_newline );
- add_intrinsic("catstr", icatstr );
- add_intrinsic("copy_past_newline", icopy_past_newline );
- add_intrinsic("dup", other_dup );
- add_intrinsic("drop", drop);
- add_intrinsic("idrop", idrop);
- add_intrinsic("remchar", remchar );
- add_intrinsic("get_stuff_in_command", get_stuff_in_command );
- add_intrinsic("do_fancy_stuff", do_fancy_stuff );
- add_intrinsic("bulletize", bulletize );
- add_intrinsic("courierize", courierize );
+
+ add_intrinsic ("push_text", push_text);
+ add_intrinsic ("!", bang);
+ add_intrinsic ("@", atsign);
+ add_intrinsic ("hello", hello);
+ add_intrinsic ("stdout", stdout_);
+ add_intrinsic ("stderr", stderr_);
+ add_intrinsic ("print", print);
+ add_intrinsic ("skip_past_newline", skip_past_newline);
+ add_intrinsic ("catstr", icatstr);
+ add_intrinsic ("copy_past_newline", icopy_past_newline);
+ add_intrinsic ("dup", other_dup);
+ add_intrinsic ("drop", drop);
+ add_intrinsic ("idrop", idrop);
+ add_intrinsic ("remchar", remchar);
+ add_intrinsic ("get_stuff_in_command", get_stuff_in_command);
+ add_intrinsic ("do_fancy_stuff", do_fancy_stuff);
+ add_intrinsic ("bulletize", bulletize);
+ add_intrinsic ("courierize", courierize);
/* If the following line gives an error, exit() is not declared in the
../hosts/foo.h file for this host. Fix it there, not here! */
/* No, don't fix it anywhere; see comment on chew_exit--Ian Taylor. */
- add_intrinsic("exit", chew_exit );
- add_intrinsic("swap", swap );
- add_intrinsic("outputdots", outputdots );
- add_intrinsic("paramstuff", paramstuff );
- add_intrinsic("maybecatstr", maybecatstr );
- add_intrinsic("translatecomments", translatecomments );
- add_intrinsic("kill_bogus_lines", kill_bogus_lines);
- add_intrinsic("indent", indent);
- add_intrinsic("internalmode", internalmode);
- add_intrinsic("print_stack_level", print_stack_level);
- add_intrinsic("strip_trailing_newlines", strip_trailing_newlines);
-
- /* Put a nl at the start */
- catchar(&buffer,'\n');
-
- read_in(&buffer, stdin);
- remove_noncomments(&buffer, ptr);
- for (i= 1; i < (unsigned int) ac; i++)
- {
- if (av[i][0] == '-')
+ add_intrinsic ("exit", chew_exit);
+ add_intrinsic ("swap", swap);
+ add_intrinsic ("outputdots", outputdots);
+ add_intrinsic ("paramstuff", paramstuff);
+ add_intrinsic ("maybecatstr", maybecatstr);
+ add_intrinsic ("translatecomments", translatecomments);
+ add_intrinsic ("kill_bogus_lines", kill_bogus_lines);
+ add_intrinsic ("indent", indent);
+ add_intrinsic ("internalmode", internalmode);
+ add_intrinsic ("print_stack_level", print_stack_level);
+ add_intrinsic ("strip_trailing_newlines", strip_trailing_newlines);
+
+ /* Put a nl at the start. */
+ catchar (&buffer, '\n');
+
+ read_in (&buffer, stdin);
+ remove_noncomments (&buffer, ptr);
+ for (i = 1; i < (unsigned int) ac; i++)
{
- if (av[i][1] == 'f')
- {
- string_type b;
- FILE *f;
- init_string(&b);
-
- f = fopen(av[i+1],"r");
- if (!f)
+ if (av[i][0] == '-')
{
- fprintf(stderr,"Can't open the input file %s\n",av[i+1]);
- return 33;
- }
+ if (av[i][1] == 'f')
+ {
+ string_type b;
+ FILE *f;
+ init_string (&b);
- read_in(&b, f);
- compile(b.ptr);
- perform();
- }
- else if (av[i][1] == 'i')
- {
- internal_wanted = 1;
- }
- else if (av[i][1] == 'w')
- {
- warning = 1;
- }
- else
- usage ();
+ f = fopen (av[i + 1], "r");
+ if (!f)
+ {
+ fprintf (stderr, "Can't open the input file %s\n",
+ av[i + 1]);
+ return 33;
+ }
+
+ read_in (&b, f);
+ compile (b.ptr);
+ perform ();
+ }
+ else if (av[i][1] == 'i')
+ {
+ internal_wanted = 1;
+ }
+ else if (av[i][1] == 'w')
+ {
+ warning = 1;
+ }
+ else
+ usage ();
+ }
}
- }
- write_buffer(stack+0, stdout);
+ write_buffer (stack + 0, stdout);
if (tos != stack)
{
- fprintf (stderr, "finishing with current stack level %d\n", tos - stack);
+ fprintf (stderr, "finishing with current stack level %d\n",
+ tos - stack);
return 1;
}
return 0;