# HG changeset patch # User jwe # Date 815308371 0 # Node ID 58347671243833a6001a6d6d0dc07c5085a5fb5c # Parent 8dc3bdef46e27103475fd52cb0569f7c7fab17e6 [project @ 1995-11-02 10:30:06 by jwe] diff --git a/src/input.cc b/src/input.cc --- a/src/input.cc +++ b/src/input.cc @@ -613,7 +613,7 @@ // warning if the file doesn't exist. FILE * -get_input_from_file (char *name, int warn) +get_input_from_file (const char *name, int warn) { FILE *instream = 0; diff --git a/src/input.h b/src/input.h --- a/src/input.h +++ b/src/input.h @@ -29,7 +29,7 @@ #include extern int octave_read (char *buf, int max_size); -extern FILE *get_input_from_file (char *name, int warn = 1); +extern FILE *get_input_from_file (const char *name, int warn = 1); extern FILE *get_input_from_stdin (void); extern void initialize_readline (void); diff --git a/src/octave.cc b/src/octave.cc --- a/src/octave.cc +++ b/src/octave.cc @@ -352,7 +352,7 @@ } void -parse_and_execute (char *s, int print, int verbose) +parse_and_execute (const char *s, int print, int verbose) { begin_unwind_frame ("parse_and_execute_2"); @@ -387,6 +387,28 @@ run_unwind_frame ("parse_and_execute_2"); } +DEFUN ("source", Fsource, Ssource, 10, + "source (FILE)\n\ +\n\ +Parse and execute the contents of FILE. Like executing commands in a\n\ +script file but without requiring the file to be named `FILE.m'.") +{ + Octave_object retval; + + int nargin = args.length (); + + if (nargin == 1) + { + const char *file = args(0).string_value (); + + parse_and_execute (file, 1); + } + else + print_usage ("source"); + + return retval; +} + // Initialize by reading startup files. static void diff --git a/src/toplev.h b/src/toplev.h --- a/src/toplev.h +++ b/src/toplev.h @@ -34,7 +34,9 @@ extern void clean_up_and_exit (int) NORETURN; extern void parse_and_execute (FILE *f, int print = 0); -extern void parse_and_execute (char *s, int print = 0, int verbose = 0); + +extern void parse_and_execute (const char *s, int print = 0, + int verbose = 0); extern tree_constant eval_string (const char *string, int print, int& parse_status);