summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/main.cc')
-rw-r--r--Build/source/utils/asymptote/main.cc60
1 files changed, 41 insertions, 19 deletions
diff --git a/Build/source/utils/asymptote/main.cc b/Build/source/utils/asymptote/main.cc
index 946dd4d9094..c6c80bb88f0 100644
--- a/Build/source/utils/asymptote/main.cc
+++ b/Build/source/utils/asymptote/main.cc
@@ -40,7 +40,7 @@
#include "settings.h"
#include "locate.h"
#include "interact.h"
-#include "process.h"
+#include "fileio.h"
#include "stack.h"
@@ -51,7 +51,7 @@ using interact::interactive;
namespace run {
void purge();
}
-
+
#ifdef PROFILE
namespace vm {
extern void dumpProfile();
@@ -75,11 +75,11 @@ int sigsegv_handler (void *, int emergency)
cerr << "Stack overflow or segmentation fault: rerun with -nothreads"
<< endl;
else
-#endif
+#endif
cerr << "Segmentation fault" << endl;
abort();
}
-#endif
+#endif
void setsignal(RETSIGTYPE (*handler)(int))
{
@@ -107,7 +107,13 @@ void interruptHandler(int)
em.Interrupt(true);
}
-struct Args
+bool hangup=false;
+void hangup_handler(int sig)
+{
+ hangup=true;
+}
+
+struct Args
{
int argc;
char **argv;
@@ -117,7 +123,6 @@ struct Args
void *asymain(void *A)
{
setsignal(signalHandler);
-
Args *args=(Args *) A;
fpu_trap(trap());
@@ -129,12 +134,27 @@ void *asymain(void *A)
doUnrestrictedList();
} catch(handled_error) {
em.statusError();
- }
+ }
} else {
int n=numArgs();
- if(n == 0)
- processFile("-");
- else
+ if(n == 0) {
+ int inpipe=intcast(settings::getSetting<Int>("inpipe"));
+ if(inpipe >= 0) {
+ Signal(SIGHUP,hangup_handler);
+ camp::openpipeout();
+ fprintf(camp::pipeout,"\n");
+ fflush(camp::pipeout);
+ }
+ while(true) {
+ processFile("-",true);
+ try {
+ setOptions(args->argc,args->argv);
+ } catch(handled_error) {
+ em.statusError();
+ }
+ if(inpipe < 0) break;
+ }
+ } else {
for(int ind=0; ind < n; ind++) {
processFile(string(getArg(ind)),n > 1);
try {
@@ -142,8 +162,9 @@ void *asymain(void *A)
setOptions(args->argc,args->argv);
} catch(handled_error) {
em.statusError();
- }
+ }
}
+ }
}
#ifdef PROFILE
@@ -162,7 +183,7 @@ void *asymain(void *A)
}
#endif
#endif
- exit(em.processStatus() || interact::interactive ? 0 : 1);
+ exit(em.processStatus() || interact::interactive ? 0 : 1);
}
void exitHandler(int)
@@ -170,12 +191,13 @@ void exitHandler(int)
exit(0);
}
-int main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
-#ifdef HAVE_LIBGSL
+ // cout << "hello?";
+#ifdef HAVE_LIBGSL
unsetenv("GSL_RNG_SEED");
unsetenv("GSL_RNG_TYPE");
-#endif
+#endif
setsignal(signalHandler);
try {
@@ -183,17 +205,17 @@ int main(int argc, char *argv[])
} catch(handled_error) {
em.statusError();
}
-
+
Args args(argc,argv);
#ifdef HAVE_GL
#ifdef __APPLE__
bool usethreads=true;
#else
bool usethreads=view();
-#endif
+#endif
gl::glthread=usethreads ? getSetting<bool>("threads") : false;
#if HAVE_PTHREAD
-
+
if(gl::glthread) {
pthread_t thread;
try {
@@ -215,6 +237,6 @@ int main(int argc, char *argv[])
}
#endif
gl::glthread=false;
-#endif
+#endif
asymain(&args);
}