From owner-freebsd-bugs Wed Jan 13 13:30:38 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA04850 for freebsd-bugs-outgoing; Wed, 13 Jan 1999 13:30:38 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA04835 for ; Wed, 13 Jan 1999 13:30:36 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id NAA23772; Wed, 13 Jan 1999 13:30:01 -0800 (PST) Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA03733 for ; Wed, 13 Jan 1999 13:22:26 -0800 (PST) (envelope-from dcs@newsguy.com) Received: from daniel.sobral by peach.ocn.ne.jp (8.9.1a/OCN) id GAA02165; Thu, 14 Jan 1999 06:21:17 +0900 (JST) Received: (from root@localhost) by daniel.sobral (8.9.1/8.9.1) id GAA00394; Thu, 14 Jan 1999 06:20:52 +0900 (JST) (envelope-from root) Message-Id: <199901132120.GAA00394@daniel.sobral> Date: Thu, 14 Jan 1999 06:20:52 +0900 (JST) From: dcs@newsguy.com Reply-To: dcs@newsguy.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: kern/9473: Loader's builtin "source" collides with ficl's "source" Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 9473 >Category: kern >Synopsis: Loader's "source" is also the name of an ANS Forth word >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Jan 13 13:30:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Daniel C. Sobral >Release: FreeBSD 3.0-CURRENT i386 >Organization: >Environment: Current as of Jan 12/1999. >Description: Loader's builtin command "source" is also the name of a ANS Forth CORE word set word. >How-To-Repeat: Type "source". Compare with ANS Forth standard expected results. :-) >Fix: Apply the fix below. --- interp.c 1999/01/13 19:48:11 1.1 +++ interp.c 1999/01/13 21:01:10 @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: interp.c,v 1.1 1999/01/13 19:48:11 root Exp $ + * $Id: interp.c,v 1.3 1999/01/13 21:01:01 root Exp root $ */ /* * Simple commandline interpreter, toplevel and misc. @@ -99,7 +100,7 @@ /* * Read our default configuration */ - source("/boot/boot.conf"); + include("/boot/boot.conf"); printf("\n"); /* * Before interacting, we might want to autoboot. @@ -140,34 +141,36 @@ * Commands may be prefixed with '@' (so they aren't displayed) or '-' (so * that the script won't stop if they fail). */ -COMMAND_SET(source, "source", "read commands from a file", command_source); +COMMAND_SET(include, "include", "read commands from a file", command_include); static int -command_source(int argc, char *argv[]) +command_include(int argc, char *argv[]) { int i; for (i = 1; i < argc; i++) - source(argv[i]); + include(argv[i]); RETURN(CMD_OK); } -struct sourceline +struct includeline { char *text; int flags; int line; #define SL_QUIET (1<<0) #define SL_IGNOREERR (1<<1) - struct sourceline *next; + struct includeline *next; }; void -source(char *filename) +include(char *filename) { - struct sourceline *script, *se, *sp; + struct includeline *script, *se, *sp; char input[256]; /* big enough? */ +#ifndef BOOT_FORTH int argc; +#endif char **argv, *cp; int fd, flags, line; @@ -200,8 +203,8 @@ flags |= SL_IGNOREERR; } /* Allocate script line structure and copy line, flags */ - sp = malloc(sizeof(struct sourceline) + strlen(cp) + 1); - sp->text = (char *)sp + sizeof(struct sourceline); + sp = malloc(sizeof(struct includeline) + strlen(cp) + 1); + sp->text = (char *)sp + sizeof(struct includeline); strcpy(sp->text, cp); sp->flags = flags; sp->line = line; --- help.common 1999/01/13 19:52:19 1.1 +++ help.common 1999/01/13 19:57:16 @@ -213,15 +213,17 @@ See the set command for a list of some variables. ################################################################################ -# Tsource DRead commands from a script file +# Tinlcude DRead commands from a script file - source + include The entire contents of are read into memory before executing commands, so it is safe to source a file from removable media. A number of modifiers may be prefixed to commands within a script file to alter their behaviour: + + # Treat line as comment @ Suppresses the printing of the command when executed. --- bootstrap.h 1999/01/13 19:59:00 1.1 +++ bootstrap.h 1999/01/13 20:22:07 @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootstrap.h,v 1.1 1999/01/13 19:59:00 root Exp $ + * $Id: bootstrap.h,v 1.2 1999/01/13 20:20:43 root Exp root $ */ #include @@ -56,7 +56,7 @@ /* interp.c */ extern void interact(void); -extern void source(char *filename); +extern void include(char *filename); /* interp_parse.c */ extern int parse(int *argc, char ***argv, char *str); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message