diff options
author | Norbert Preining <norbert@preining.info> | 2024-11-13 03:03:42 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-11-13 03:03:42 +0000 |
commit | 5037cc8f66c1c2dfc56accf0f29866977fce1f11 (patch) | |
tree | 916c5b917a84c268d98a6176a93f0a4c3e63a102 /graphics/asymptote/runhistory.cc | |
parent | d63a87aba38d505e5b1322a0fd3b93549e7cb203 (diff) |
CTAN sync 202411130303
Diffstat (limited to 'graphics/asymptote/runhistory.cc')
-rw-r--r-- | graphics/asymptote/runhistory.cc | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/graphics/asymptote/runhistory.cc b/graphics/asymptote/runhistory.cc index 089807c5a0..011ad21814 100644 --- a/graphics/asymptote/runhistory.cc +++ b/graphics/asymptote/runhistory.cc @@ -1,6 +1,6 @@ /***** Autogenerated from runhistory.in; changes will be overwritten *****/ -#line 1 "runtimebase.in" +#line 1 "./runtimebase.in" /***** * runtimebase.in * Andy Hammerlindl 2009/07/28 @@ -10,7 +10,7 @@ *****/ -#line 1 "runhistory.in" +#line 1 "./runhistory.in" /***** * runhistory.in * @@ -18,7 +18,7 @@ * *****/ -#line 1 "runtimebase.in" +#line 1 "./runtimebase.in" #include "stack.h" #include "types.h" #include "builtin.h" @@ -67,6 +67,13 @@ function *realRealFunction(); #include "mathop.h" #include "builtin.h" +#if defined(_WIN32) +#include <io.h> +#define isatty _isatty +#else +#include <unistd.h> +#endif + using namespace camp; using namespace settings; using namespace vm; @@ -166,13 +173,13 @@ void cleanup() #endif namespace run { // Return the last n lines of the history named name. -#line 110 "runhistory.in" +#line 117 "./runhistory.in" // stringarray* history(string name, Int n=1); void gen_runhistory0(stack *Stack) { Int n=vm::pop<Int>(Stack,1); string name=vm::pop<string>(Stack); -#line 111 "runhistory.in" +#line 118 "./runhistory.in" #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) bool newhistory=historyMap.find(name) == historyMap.end(); @@ -204,12 +211,12 @@ void gen_runhistory0(stack *Stack) } // Return the last n lines of the interactive history. -#line 143 "runhistory.in" +#line 150 "./runhistory.in" // stringarray* history(Int n=0); void gen_runhistory1(stack *Stack) { Int n=vm::pop<Int>(Stack,0); -#line 144 "runhistory.in" +#line 151 "./runhistory.in" #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) {Stack->push<stringarray*>(get_history(n)); return;} #else @@ -220,16 +227,20 @@ void gen_runhistory1(stack *Stack) // Prompt for a string using prompt, the GNU readline library, and a // local history named name. -#line 155 "runhistory.in" +#line 162 "./runhistory.in" // string readline(string prompt=emptystring, string name=emptystring, bool tabcompletion=false); void gen_runhistory2(stack *Stack) { bool tabcompletion=vm::pop<bool>(Stack,false); string name=vm::pop<string>(Stack,emptystring); string prompt=vm::pop<string>(Stack,emptystring); -#line 157 "runhistory.in" - if(!(isatty(STDIN_FILENO) || getSetting<Int>("inpipe") >= 0)) +#line 164 "./runhistory.in" + bool stdinIsTty=isatty(STDIN_FILENO); + bool hasInpipe=getSetting<Int>("inpipe") >= 0; + if(!(stdinIsTty || hasInpipe)) + { {Stack->push<string>(emptystring); return;} + } #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) interact::init_readline(tabcompletion); @@ -271,14 +282,14 @@ void gen_runhistory2(stack *Stack) // Save a string in a local history named name. // If store=true, store the local history in the file historyfilename(name). -#line 201 "runhistory.in" +#line 212 "./runhistory.in" // void saveline(string name, string value, bool store=true); void gen_runhistory3(stack *Stack) { bool store=vm::pop<bool>(Stack,true); string value=vm::pop<string>(Stack); string name=vm::pop<string>(Stack); -#line 202 "runhistory.in" +#line 213 "./runhistory.in" #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) store_history(&history_save); bool newhistory=historyMap.find(name) == historyMap.end(); @@ -311,13 +322,13 @@ namespace trans { void gen_runhistory_venv(venv &ve) { -#line 109 "runhistory.in" +#line 116 "./runhistory.in" addFunc(ve, run::gen_runhistory0, stringArray(), SYM(history), formal(primString(), SYM(name), false, false), formal(primInt(), SYM(n), true, false)); -#line 142 "runhistory.in" +#line 149 "./runhistory.in" addFunc(ve, run::gen_runhistory1, stringArray(), SYM(history), formal(primInt(), SYM(n), true, false)); -#line 153 "runhistory.in" +#line 160 "./runhistory.in" addFunc(ve, run::gen_runhistory2, primString(), SYM(readline), formal(primString(), SYM(prompt), true, false), formal(primString(), SYM(name), true, false), formal(primBoolean(), SYM(tabcompletion), true, false)); -#line 199 "runhistory.in" +#line 210 "./runhistory.in" addFunc(ve, run::gen_runhistory3, primVoid(), SYM(saveline), formal(primString(), SYM(name), false, false), formal(primString(), SYM(value), false, false), formal(primBoolean(), SYM(store), true, false)); } |