From: Adam Dickmeiss Date: Wed, 22 Feb 1995 08:50:48 +0000 (+0000) Subject: Definition of CPP changed. Output function can be customized. X-Git-Url: http://git.indexdata.com/cgi-bin?a=commitdiff_plain;h=43a8f9005c81e2d16940d07482c10f653dec85dc;p=egate.git Definition of CPP changed. Output function can be customized. --- diff --git a/fml/Makefile b/fml/Makefile index cbabc9c..e3b2f93 100644 --- a/fml/Makefile +++ b/fml/Makefile @@ -1,11 +1,12 @@ # FML interpreter. Europagate, 1995 # -# $Id: Makefile,v 1.8 1995/02/21 12:11:27 adam Exp $ +# $Id: Makefile,v 1.9 1995/02/22 08:50:48 adam Exp $ SHELL=/bin/sh INCLUDE=-I../include -I. TPROG1=fmltest CFLAGS=-g -Wall -pedantic +CPP=$(CC) -E DEFS=$(INCLUDE) LIB=../lib/fml.a PO = fmltoken.o fmlmem.o fml.o fmlsym.o fmlrel.o fmlarit.o fmllist.o \ diff --git a/fml/fml.c b/fml/fml.c index 4eabb90..cf95ce7 100644 --- a/fml/fml.c +++ b/fml/fml.c @@ -2,7 +2,10 @@ * FML interpreter. Europagate, 1995 * * $Log: fml.c,v $ - * Revision 1.10 1995/02/21 17:46:08 adam + * Revision 1.11 1995/02/22 08:50:49 adam + * Definition of CPP changed. Output function can be customized. + * + * Revision 1.10 1995/02/21 17:46:08 adam * Bug fix in fml_sub0. * * Revision 1.9 1995/02/21 14:00:03 adam @@ -56,6 +59,11 @@ static int default_read_func (void) return getchar (); } +static void default_write_func (int c) +{ + putchar (c); +} + static void default_err_handle (int no) { fprintf (stderr, "Error: %d\n", no); @@ -109,6 +117,7 @@ Fml fml_open (void) fml->white_chars = " \t\f\r\n"; fml->read_func = default_read_func; fml->err_handle = default_err_handle; + fml->write_func = default_write_func; fml->list = NULL; fml->sym_tab = fml_sym_open (); @@ -308,7 +317,7 @@ static struct fml_node *fml_exec_nl (Fml fml, struct fml_node **lp, struct token *tp) { fml_cmd_lex (lp, tp); - putchar ('\n'); + (*fml->write_func) ('\n'); return NULL; } @@ -365,7 +374,7 @@ static struct fml_node *fml_exec_prefix (struct fml_sym_info *info, Fml fml, } -static void fml_emit (struct fml_node *list) +static void fml_emit (Fml fml, struct fml_node *list) { int s = 0; while (list) @@ -374,13 +383,17 @@ static void fml_emit (struct fml_node *list) { struct fml_atom *a; if (s) - printf (" "); + (*fml->write_func) (' '); s++; for (a = list->p[0]; a; a=a->next) - printf ("%.*s", FML_ATOM_BUF, a->buf); + { + int i = 0; + while (i < FML_ATOM_BUF && a->buf[i]) + (*fml->write_func) (a->buf[i++]); + } } else - fml_emit (list->p[0]); + fml_emit (fml, list->p[0]); list = list->p[1]; } } @@ -747,7 +760,7 @@ static void fml_emit_expr (Fml fml, struct fml_node **lp, struct token *tp) struct fml_node *fn; fn = fml_sub1 (fml, lp, tp); - fml_emit (fn); + fml_emit (fml, fn); fml_node_delete (fml, fn); } @@ -836,7 +849,7 @@ struct fml_node *fml_exec_group (struct fml_node *list, Fml fml) case FML_PREFIX: case FML_CPREFIX: if (token.separate && !first) - putchar (' '); + (*fml->write_func) (' '); first = 1; fml_emit_expr (fml, &list, &token); fml_node_stat (fml); @@ -890,7 +903,7 @@ struct fml_node *fml_exec_group (struct fml_node *list, Fml fml) break; case 't': if (token.separate && !first) - putchar (' '); + (*fml->write_func) (' '); first = 0; fml_emit_expr (fml, &list, &token); fml_node_stat (fml);