CVS commit: src/usr.bin/fgen
Module Name:src Committed By: mrg Date: Sun Sep 6 08:18:21 UTC 2020 Modified Files: src/usr.bin/fgen: fgen.l Log Message: remove unused NULL pointer that was passed to printf %s. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/usr.bin/fgen/fgen.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/fgen/fgen.l diff -u src/usr.bin/fgen/fgen.l:1.37 src/usr.bin/fgen/fgen.l:1.38 --- src/usr.bin/fgen/fgen.l:1.37 Tue Mar 8 20:13:44 2016 +++ src/usr.bin/fgen/fgen.l Sun Sep 6 08:18:21 2020 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: fgen.l,v 1.37 2016/03/08 20:13:44 christos Exp $ */ +/* $NetBSD: fgen.l,v 1.38 2020/09/06 08:18:21 mrg Exp $ */ /* FLEX input for FORTH input file scanner */ /* * Copyright (c) 1998 Eduardo Horvath. @@ -42,7 +42,7 @@ #endif #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: fgen.l,v 1.37 2016/03/08 20:13:44 christos Exp $"); +__RCSID("$NetBSD: fgen.l,v 1.38 2020/09/06 08:18:21 mrg Exp $"); #endif %} @@ -86,7 +86,6 @@ static char *outbuf = NULL; static char *outfile, *infile; #define BUFCLICK (1024*1024) static size_t outbufsiz = 0; -static char *myname = NULL; static int offsetsize = 8; static int defining = 0; static int tokenizer = 0; @@ -2043,7 +2042,7 @@ tokenize(YY_BUFFER_STATE yinput) #else token_err(yylineno, infile, yytext, "%s: undefined token `%s'\n", - myname, token->text); + __func__, token->text); #endif } break;
CVS commit: src/usr.bin/fgen
Module Name:src Committed By: wiz Date: Tue Jul 4 07:07:23 UTC 2017 Modified Files: src/usr.bin/fgen: fgen.1 Log Message: Use more macros. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/fgen/fgen.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/fgen/fgen.1 diff -u src/usr.bin/fgen/fgen.1:1.10 src/usr.bin/fgen/fgen.1:1.11 --- src/usr.bin/fgen/fgen.1:1.10 Mon Jul 3 21:34:57 2017 +++ src/usr.bin/fgen/fgen.1 Tue Jul 4 07:07:23 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: fgen.1,v 1.10 2017/07/03 21:34:57 wiz Exp $ +.\" $NetBSD: fgen.1,v 1.11 2017/07/04 07:07:23 wiz Exp $ .\" .\" Copyright (c) 1998 Eduardo Horvath, All Rights Reserved. .\" @@ -50,7 +50,8 @@ Reads Forth source and generates tokeniz .\" .Sh STANDARDS .\" .Sh HISTORY .Sh AUTHORS -Written by Eduardo E. Horvath+Written by +.An Eduardo E. Horvath Aq Mt e...@one-o.com .Sh BUGS String escape sequences are not recognized so things such as .Pp
CVS commit: src/usr.bin/fgen
Module Name:src Committed By: joerg Date: Thu Mar 10 11:32:10 UTC 2016 Modified Files: src/usr.bin/fgen: Makefile Log Message: Unbreak tools build. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.bin/fgen/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/fgen/Makefile diff -u src/usr.bin/fgen/Makefile:1.9 src/usr.bin/fgen/Makefile:1.10 --- src/usr.bin/fgen/Makefile:1.9 Tue Mar 8 20:13:44 2016 +++ src/usr.bin/fgen/Makefile Thu Mar 10 11:32:10 2016 @@ -1,11 +1,13 @@ -# $NetBSD: Makefile,v 1.9 2016/03/08 20:13:44 christos Exp $ +# $NetBSD: Makefile,v 1.10 2016/03/10 11:32:10 joerg Exp $ CPPFLAGS+= -I${.CURDIR} PROG= fgen SRCS= fgen.l MAN= fgen.1 +.if !defined(HOSTPROG) LDADD+= -lutil DPADD+= ${LIBUTIL} +.endif .include
CVS commit: src/usr.bin/fgen
Module Name:src Committed By: christos Date: Tue Mar 8 20:13:45 UTC 2016 Modified Files: src/usr.bin/fgen: Makefile fgen.l Log Message: PR/50914: David Binderman: Fix memory leaks. While here, fix error handling too. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/fgen/Makefile cvs rdiff -u -r1.36 -r1.37 src/usr.bin/fgen/fgen.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/fgen/Makefile diff -u src/usr.bin/fgen/Makefile:1.8 src/usr.bin/fgen/Makefile:1.9 --- src/usr.bin/fgen/Makefile:1.8 Thu Oct 29 10:35:25 2009 +++ src/usr.bin/fgen/Makefile Tue Mar 8 15:13:44 2016 @@ -1,8 +1,11 @@ -# $NetBSD: Makefile,v 1.8 2009/10/29 14:35:25 christos Exp $ +# $NetBSD: Makefile,v 1.9 2016/03/08 20:13:44 christos Exp $ CPPFLAGS+= -I${.CURDIR} PROG= fgen SRCS= fgen.l MAN= fgen.1 +LDADD+= -lutil +DPADD+= ${LIBUTIL} + .include Index: src/usr.bin/fgen/fgen.l diff -u src/usr.bin/fgen/fgen.l:1.36 src/usr.bin/fgen/fgen.l:1.37 --- src/usr.bin/fgen/fgen.l:1.36 Fri Oct 18 16:47:06 2013 +++ src/usr.bin/fgen/fgen.l Tue Mar 8 15:13:44 2016 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: fgen.l,v 1.36 2013/10/18 20:47:06 christos Exp $ */ +/* $NetBSD: fgen.l,v 1.37 2016/03/08 20:13:44 christos Exp $ */ /* FLEX input for FORTH input file scanner */ /* * Copyright (c) 1998 Eduardo Horvath. @@ -42,7 +42,7 @@ #endif #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: fgen.l,v 1.36 2013/10/18 20:47:06 christos Exp $"); +__RCSID("$NetBSD: fgen.l,v 1.37 2016/03/08 20:13:44 christos Exp $"); #endif %} @@ -66,6 +66,7 @@ tail {white} #include #include #include +#include #include "fgen.h" static TOKEN ltoken; @@ -101,7 +102,7 @@ static YY_DECL; static int debug = 0; #define ASSERT if (debug) assert -#define STATE(y, x) do { if (debug) printf( "%lx State %s: token `%s'\n", outpos, x, y); } while (0) +#define STATE(y, x) do { if (debug) printf("%lx State %s: token `%s'\n", outpos, x, y); } while (0) static int mark_fload = 0; %} @@ -310,7 +311,7 @@ static struct fcode *flookup(struct fcod static int aadd(struct macro *, struct macro *); static struct macro *alookup(struct macro *, const char *); static void initdic(void); -__dead static void usage(const char *); +__dead static void usage(void); static void tokenize(YY_BUFFER_STATE); static int emit(const char *); static int spit(long); @@ -787,10 +788,8 @@ push(Cell val) if (debug > 1) printf("push %lx\n", (long)val); parse_stack[parse_stack_ptr++] = val; - if (parse_stack_ptr >= PSTKSIZ) { - (void)printf( "Parse stack overflow\n"); - exit(1); - } + if (parse_stack_ptr >= PSTKSIZ) + errx(EXIT_FAILURE, "Parse stack overflow"); } static Cell @@ -831,7 +830,7 @@ fadd(struct fcode *dict, struct fcode *n return fadd(dict->l, new); else { if (debug > 5) -(void)printf( "fadd: new FCode `%s' is %lx\n", +printf("fadd: new FCode `%s' is %lx\n", new->name, new->num); new->l = new->r = NULL; dict->l = new; @@ -841,7 +840,7 @@ fadd(struct fcode *dict, struct fcode *n return fadd(dict->r, new); else { if (debug > 5) -(void)printf( "fadd: new FCode `%s' is %lx\n", +printf("fadd: new FCode `%s' is %lx\n", new->name, new->num); new->l = new->r = NULL; dict->r = new; @@ -862,7 +861,7 @@ flookup(struct fcode *dict, const char * res = strcmp(dict->name, str); ASSERT(dict->type == FCODE); if (debug > 5) - (void)printf( "flookup: `%s' and `%s' %s match\n", + printf("flookup: `%s' and `%s' %s match\n", str, dict->name, res?"don't":"do"); if (!res) return (dict); if (res < 0) @@ -895,7 +894,7 @@ aadd(struct macro *dict, struct macro *n new->l = new->r = NULL; dict->l = new; if (debug > 5) -(void)printf( "aadd: new alias `%s' to `%s'\n", +printf("aadd: new alias `%s' to `%s'\n", new->name, new->equiv); } } else { @@ -905,7 +904,7 @@ aadd(struct macro *dict, struct macro *n new->l = new->r = NULL; dict->r = new; if (debug > 5) -(void)printf( "aadd: new alias `%s' to `%s'\n", +printf("aadd: new alias `%s' to `%s'\n", new->name, new->equiv); } } @@ -948,8 +947,8 @@ initdic(void) while ((++code)->name) { if(!fadd(dictionary, code)) { - printf("init: duplicate dictionary entry %s\n", - code->name); + warnx("%s: duplicate dictionary entry `%s'", __func__, + code->name); } } @@ -959,8 +958,8 @@ initdic(void) alias->type = MACRO; while ((++alias)->name) { if(!aadd(aliases, alias)) { - printf("init: duplicate macro entry %s\n", - alias->name); + warnx("%s: duplicate macro entry `%s'", __func__, + alias->name); } } @@ -987,10 +986,11 @@ apply_macros(YY_BUFFER_STATE yinput, con } static void -usage(const char *me) +usage(void) { - (void)fprintf(stderr, "%s: [-d level] [-o
CVS commit: src/usr.bin/fgen
Module Name:src Committed By: joerg Date: Thu Sep 1 13:44:25 UTC 2011 Modified Files: src/usr.bin/fgen: fgen.l Log Message: static + __dead To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/usr.bin/fgen/fgen.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/fgen/fgen.l diff -u src/usr.bin/fgen/fgen.l:1.34 src/usr.bin/fgen/fgen.l:1.35 --- src/usr.bin/fgen/fgen.l:1.34 Mon Feb 8 20:14:55 2010 +++ src/usr.bin/fgen/fgen.l Thu Sep 1 13:44:25 2011 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: fgen.l,v 1.34 2010/02/08 20:14:55 eeh Exp $ */ +/* $NetBSD: fgen.l,v 1.35 2011/09/01 13:44:25 joerg Exp $ */ /* FLEX input for FORTH input file scanner */ /* * Copyright (c) 1998 Eduardo Horvath. @@ -42,7 +42,7 @@ #endif #if defined(__RCSID) !defined(lint) -__RCSID($NetBSD: fgen.l,v 1.34 2010/02/08 20:14:55 eeh Exp $); +__RCSID($NetBSD: fgen.l,v 1.35 2011/09/01 13:44:25 joerg Exp $); #endif %} @@ -68,41 +68,41 @@ #include unistd.h #include fgen.h -TOKEN ltoken; +static TOKEN ltoken; /* * Global variables that control the parse state. */ -struct fcode *dictionary = NULL; -struct macro *aliases = NULL; -int outf = 1; /* stdout */ -int state = 0; -int nextfcode = 0x800; -int numbase = TOK_HEX; -long outpos; -char *outbuf = NULL; -char *outfile, *infile; +static struct fcode *dictionary = NULL; +static struct macro *aliases = NULL; +static int outf = 1; /* stdout */ +static int state = 0; +static int nextfcode = 0x800; +static int numbase = TOK_HEX; +static long outpos; +static char *outbuf = NULL; +static char *outfile, *infile; #define BUFCLICK (1024*1024) -size_t outbufsiz = 0; -char *myname = NULL; -int offsetsize = 8; -int defining = 0; -int tokenizer = 0; -int need_end0 = 1; +static size_t outbufsiz = 0; +static char *myname = NULL; +static int offsetsize = 8; +static int defining = 0; +static int tokenizer = 0; +static int need_end0 = 1; #define PSTKSIZ 1024 -Cell parse_stack[PSTKSIZ]; -int parse_stack_ptr = 0; +static Cell parse_stack[PSTKSIZ]; +static int parse_stack_ptr = 0; -void token_err(int, const char *, const char *, const char *, ...) - __attribute__((__format__(__printf__, 4, 5))); -YY_DECL; +static void token_err(int, const char *, const char *, const char *, ...) +__printflike(4, 5) __dead; +static YY_DECL; -int debug = 0; +static int debug = 0; #define ASSERT if (debug) assert #define STATE(y, x) do { if (debug) printf( %lx State %s: token `%s'\n, outpos, x, y); } while (0) -int mark_fload = 0; +static int mark_fload = 0; %} @@ -302,29 +302,28 @@ %% /* Function definitions */ -void push(Cell); -Cell pop(void); -int depth(void); -int fadd(struct fcode *, struct fcode *); -struct fcode *flookup(struct fcode *, const char *); -int aadd(struct macro *, struct macro *); -struct macro *alookup(struct macro *, const char *); -void initdic(void); -void usage(const char *); -void tokenize(YY_BUFFER_STATE); -int emit(const char *); -int spit(long); -int offspit(long); -void sspit(const char *); -int apply_macros(YY_BUFFER_STATE, const char *); -int main(int argc, char *argv[]); -Cell cvt(const char *, char **, int base); +static void push(Cell); +static Cell pop(void); +static int depth(void); +static int fadd(struct fcode *, struct fcode *); +static struct fcode *flookup(struct fcode *, const char *); +static int aadd(struct macro *, struct macro *); +static struct macro *alookup(struct macro *, const char *); +static void initdic(void); +__dead static void usage(const char *); +static void tokenize(YY_BUFFER_STATE); +static int emit(const char *); +static int spit(long); +static int offspit(long); +static void sspit(const char *); +static int apply_macros(YY_BUFFER_STATE, const char *); +static Cell cvt(const char *, char **, int base); /* * Standard FCode names and numbers. Includes standard * tokenizer aliases. */ -struct fcode fcodes[] = { +static struct fcode fcodes[] = { { end0, 0x, 0, NULL, NULL }, { b(lit), 0x0010, 0, NULL, NULL }, { b('), 0x0011, 0, NULL, NULL }, @@ -701,7 +700,7 @@ /* * Default macros -- can be overridden by colon definitions. */ -struct macro macros[] = { +static struct macro macros[] = { { eval, evaluate, 0, NULL, NULL }, /* Build a more balanced tree */ { (.), dup abs # u#s swap sign u#, 0, NULL, NULL }, { , lshift, 0, NULL, NULL }, @@ -746,7 +745,7 @@ * ASCII - long int converter, eats `.'s */ #define strtol(x, y, z) cvt(x, y, z) -Cell +static Cell cvt(const char *s, char **e, int base) { Cell v = 0; @@ -782,7 +781,7 @@ * Parser stack control functions. */ -void +static void push(Cell val) { if (debug 1) @@ -794,7 +793,7 @@ } } -Cell +static Cell pop(void) { ASSERT(parse_stack_ptr); @@ -803,7 +802,7 @@ return parse_stack[--parse_stack_ptr]; } -int +static int depth(void) { return (parse_stack_ptr); @@ -812,7 +811,7 @@ /*
CVS commit: src/usr.bin/fgen
Module Name:src Committed By: eeh Date: Mon Feb 8 20:14:55 UTC 2010 Modified Files: src/usr.bin/fgen: fgen.h fgen.l Log Message: Some bugfixes and enhancements. Support for case .. of and fix calculation of branch offsets. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/fgen/fgen.h cvs rdiff -u -r1.33 -r1.34 src/usr.bin/fgen/fgen.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/fgen/fgen.h diff -u src/usr.bin/fgen/fgen.h:1.8 src/usr.bin/fgen/fgen.h:1.9 --- src/usr.bin/fgen/fgen.h:1.8 Mon Oct 19 18:12:37 2009 +++ src/usr.bin/fgen/fgen.h Mon Feb 8 20:14:55 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fgen.h,v 1.8 2009/10/19 18:12:37 snj Exp $ */ +/* $NetBSD: fgen.h,v 1.9 2010/02/08 20:14:55 eeh Exp $ */ /* * fgen.h -- stuff for the fcode tokenizer. * @@ -38,8 +38,8 @@ #define TOKEN struct tok #define YY_DECL TOKEN* yylex(void) -#define FCODE 0xF00DBABE -#define MACRO 0xFEEDBABE +#define FCODE 0x000FC0DE +#define MACRO 0xF00D /* Defined fcode and string. */ struct fcode { @@ -82,12 +82,12 @@ TOK_PSTRING, TOK_TOKENIZE, TOK_COMMENT, - TOK_ENDCOMMENT, TOK_COLON, TOK_SEMICOLON, TOK_TOSTRING, /* These are special */ + TOK_ABORT_S, TOK_AGAIN, TOK_ALIAS, TOK_GETTOKEN, @@ -101,9 +101,12 @@ TOK_DEFER, TOK_DO, TOK_ELSE, + TOK_END0, TOK_ENDCASE, TOK_ENDOF, TOK_EXTERNAL, + TOK_FCODE_VERSION2, + TOK_FCODE_END, TOK_FIELD, TOK_HEADERLESS, TOK_HEADERS, @@ -111,14 +114,16 @@ TOK_LEAVE, TOK_LOOP, TOK_OF, + TOK_OFFSET16, TOK_REPEAT, + TOK_STARTX, TOK_THEN, TOK_TO, TOK_UNTIL, TOK_VALUE, TOK_VARIABLE, + TOK_VERSION1, TOK_WHILE, - TOK_OFFSET16, /* Tokenizer directives */ TOK_BEGTOK, Index: src/usr.bin/fgen/fgen.l diff -u src/usr.bin/fgen/fgen.l:1.33 src/usr.bin/fgen/fgen.l:1.34 --- src/usr.bin/fgen/fgen.l:1.33 Thu Oct 29 14:49:03 2009 +++ src/usr.bin/fgen/fgen.l Mon Feb 8 20:14:55 2010 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: fgen.l,v 1.33 2009/10/29 14:49:03 christos Exp $ */ +/* $NetBSD: fgen.l,v 1.34 2010/02/08 20:14:55 eeh Exp $ */ /* FLEX input for FORTH input file scanner */ /* * Copyright (c) 1998 Eduardo Horvath. @@ -42,16 +42,15 @@ #endif #if defined(__RCSID) !defined(lint) -__RCSID($NetBSD: fgen.l,v 1.33 2009/10/29 14:49:03 christos Exp $); +__RCSID($NetBSD: fgen.l,v 1.34 2010/02/08 20:14:55 eeh Exp $); #endif %} -%option yylineno noinput +%option yylineno -decimal [0-9.] -hex [0-9A-Fa-f.] -octal [0-7.] +hex [0-9A-Fa-f] +hexdot [0-9A-Fa-f.] white [ \t\n\r\f] tail {white} @@ -90,6 +89,7 @@ int offsetsize = 8; int defining = 0; int tokenizer = 0; +int need_end0 = 1; #define PSTKSIZ 1024 Cell parse_stack[PSTKSIZ]; @@ -101,7 +101,8 @@ int debug = 0; #define ASSERT if (debug) assert -#define STATE(y, x) do { if (debug) printf( %ld State %s: token `%s'\n, outpos, x, y); } while (0) +#define STATE(y, x) do { if (debug) printf( %lx State %s: token `%s'\n, outpos, x, y); } while (0) +int mark_fload = 0; %} @@ -125,7 +126,7 @@ \\[^\n]*\n /* end of line comment -- keep looping */ { STATE(yytext, EOL comment); } --?{hex}+ { ltoken.type = TOK_NUMBER; ltoken.text = yytext; +-?{hex}{hexdot}* { ltoken.type = TOK_NUMBER; ltoken.text = yytext; return ltoken; } \'.\' { ltoken.type = TOK_C_LIT; ltoken.text = yytext; return ltoken; } @@ -139,10 +140,10 @@ \.\{white}*(\\\|[^])*\ { ltoken.type = TOK_PSTRING; ltoken.text = yytext; return ltoken; } -( { ltoken.type = TOK_COMMENT; ltoken.text = yytext; -return ltoken; } +[aA][bB][oO][rR][tT]\{white}*(\\\|[^])*\ { ltoken.type = TOK_ABORT_S; +ltoken.text = yytext; return ltoken; } -) { ltoken.type = TOK_ENDCOMMENT; ltoken.text = yytext; +( { ltoken.type = TOK_COMMENT; ltoken.text = yytext; return ltoken; } : { ltoken.type = TOK_COLON; ltoken.text = yytext; @@ -199,6 +200,9 @@ [eE][lL][sS][eE] { ltoken.type = TOK_ELSE; ltoken.text = yytext; return ltoken; } +[eE][nN][dD]0 { ltoken.type = TOK_END0; ltoken.text = yytext; +return ltoken; } + [eE][nN][dD][cC][aA][sS][eE] { ltoken.type = TOK_ENDCASE; ltoken.text = yytext; return ltoken; } @@ -208,6 +212,13 @@ [eE][xX][tT][eE][rR][nN][aA][lL] { ltoken.type = TOK_EXTERNAL; ltoken.text = yytext; return ltoken; } +[fF][cC][oO][dD][eE]-[vV][eE][rR][sS][iI][oO][nN]2 { + ltoken.type = TOK_FCODE_VERSION2; ltoken.text = yytext; +return ltoken; } + +[fF][cC][oO][dD][eE]-[eE][nN][dD] { ltoken.type = TOK_FCODE_END; ltoken.text = yytext; +return ltoken; } + [fF][iI][eE][lL][dD] { ltoken.type = TOK_FIELD; ltoken.text = yytext; return ltoken; } @@ -241,9 +252,15 @@ [oO][fF] { ltoken.type = TOK_OF; ltoken.text = yytext; return ltoken; } +[oO][fF][fF][sS][eE][tT]16 { ltoken.type = TOK_OFFSET16; ltoken.text = yytext; +return ltoken; } + [rR][eE][pP][eE][aA][tT] { ltoken.type = TOK_REPEAT;