[pure-lang-svn] SF.net SVN: pure-lang:[725] pure/trunk
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-09-06 07:57:38
|
Revision: 725
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=725&view=rev
Author: agraef
Date: 2008-09-06 07:57:49 +0000 (Sat, 06 Sep 2008)
Log Message:
-----------
Add support for interactive startup files (.purerc).
Modified Paths:
--------------
pure/trunk/ChangeLog
pure/trunk/pure.cc
Modified: pure/trunk/ChangeLog
===================================================================
--- pure/trunk/ChangeLog 2008-09-06 07:39:02 UTC (rev 724)
+++ pure/trunk/ChangeLog 2008-09-06 07:57:49 UTC (rev 725)
@@ -1,3 +1,8 @@
+2008-09-06 Albert Graef <Dr....@t-...>
+
+ * pure.cc (main): Source interactive startup files (first
+ $HOME/.purerc, then $PWD/.purerc).
+
2008-09-05 Albert Graef <Dr....@t-...>
* pure.cc (main): In interactive mode, print a warning if -n was
Modified: pure/trunk/pure.cc
===================================================================
--- pure/trunk/pure.cc 2008-09-06 07:39:02 UTC (rev 724)
+++ pure/trunk/pure.cc 2008-09-06 07:57:49 UTC (rev 725)
@@ -233,6 +233,7 @@
int count = 0;
bool quiet = false, force_interactive = false,
want_prelude = true, have_prelude = false;
+ string rcfile;
// This is used in advisory stack checks.
interpreter::baseptr = &base;
/* Set up handlers for all standard POSIX termination signals (except
@@ -267,8 +268,10 @@
setlocale(LC_ALL, "");
// get some settings from the environment
const char *env;
- if ((env = getenv("HOME")))
+ if ((env = getenv("HOME"))) {
interp.histfile = string(env)+"/.pure_history";
+ rcfile = string(env)+"/.purerc";
+ }
if ((env = getenv("PURE_PS")))
interp.ps = string(env);
if ((env = getenv("PURE_STACK"))) {
@@ -429,7 +432,17 @@
interp.temp = 1;
if (last_modno < 0) force_interactive = false;
if (force_interactive) interp.modno = last_modno;
- interp.run("", false, force_interactive);
+ // source the initialization files, if any
+ bool sticky = force_interactive;
+ if (!rcfile.empty() && chkfile(rcfile)) {
+ interp.run(rcfile, false, sticky);
+ sticky = true;
+ }
+ if (chkfile(".purerc")) {
+ interp.run(".purerc", false, sticky);
+ sticky = true;
+ }
+ interp.run("", false, sticky);
if (interp.ttymode) cout << endl;
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|