changeset 1604:583476712438

[project @ 1995-11-02 10:30:06 by jwe]
author jwe
date Thu, 02 Nov 1995 10:32:51 +0000
parents 8dc3bdef46e2
children a77f2df21864
files src/input.cc src/input.h src/octave.cc src/toplev.h
diffstat 4 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/input.cc	Thu Nov 02 04:24:14 1995 +0000
+++ b/src/input.cc	Thu Nov 02 10:32:51 1995 +0000
@@ -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;
 
--- a/src/input.h	Thu Nov 02 04:24:14 1995 +0000
+++ b/src/input.h	Thu Nov 02 10:32:51 1995 +0000
@@ -29,7 +29,7 @@
 #include <cstdio>
 
 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);
 
--- a/src/octave.cc	Thu Nov 02 04:24:14 1995 +0000
+++ b/src/octave.cc	Thu Nov 02 10:32:51 1995 +0000
@@ -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
--- a/src/toplev.h	Thu Nov 02 04:24:14 1995 +0000
+++ b/src/toplev.h	Thu Nov 02 10:32:51 1995 +0000
@@ -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);