mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 08:20:27 +00:00
Merge branch 'master' of github.com:janet-lang/janet
This commit is contained in:
commit
c7ca26e9c7
@ -257,7 +257,7 @@ Nope. There are no cons cells here.
|
|||||||
|
|
||||||
### Is this a Clojure port?
|
### Is this a Clojure port?
|
||||||
|
|
||||||
No. It's similar to Clojure superficially because I like Lisps and I like the asthetics.
|
No. It's similar to Clojure superficially because I like Lisps and I like the aesthetics.
|
||||||
Internally, Janet is not at all like Clojure.
|
Internally, Janet is not at all like Clojure.
|
||||||
|
|
||||||
### Are the immutable data structures (tuples and structs) implemented as hash tries?
|
### Are the immutable data structures (tuples and structs) implemented as hash tries?
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
# An example of using Janet's extensible module system
|
# An example of using Janet's extensible module system to import files from
|
||||||
# to import files from URL. To try this, run `janet -l examples/urlloader.janet`
|
# URL. To try this, run `janet -l ./examples/urlloader.janet` from the command
|
||||||
# from the repl, and then:
|
# line, and then at the REPL type:
|
||||||
#
|
#
|
||||||
# (import https://raw.githubusercontent.com/janet-lang/janet/master/examples/colors.janet :as c)
|
# (import https://raw.githubusercontent.com/janet-lang/janet/master/examples/colors.janet :as c)
|
||||||
#
|
#
|
||||||
# This will import a file using curl. You can then try
|
# This will import a file using curl. You can then try:
|
||||||
#
|
#
|
||||||
# (print (c/color :green "Hello!"))
|
# (print (c/color :green "Hello!"))
|
||||||
#
|
#
|
||||||
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
(defn- load-url
|
(defn- load-url
|
||||||
[url args]
|
[url args]
|
||||||
(def f (file/popen (string "curl " url)))
|
(def p (os/spawn ["curl" url "-s"] :p {:out :pipe}))
|
||||||
(def res (dofile f :source url ;args))
|
(def res (dofile (p :out) :source url ;args))
|
||||||
(try (file/close f) ([err] nil))
|
(:wait p)
|
||||||
res)
|
res)
|
||||||
|
|
||||||
(defn- check-http-url
|
(defn- check-http-url
|
||||||
|
@ -544,7 +544,7 @@ JANET_CORE_FN(os_proc_wait,
|
|||||||
JANET_CORE_FN(os_proc_kill,
|
JANET_CORE_FN(os_proc_kill,
|
||||||
"(os/proc-kill proc &opt wait)",
|
"(os/proc-kill proc &opt wait)",
|
||||||
"Kill a subprocess by sending SIGKILL to it on posix systems, or by closing the process "
|
"Kill a subprocess by sending SIGKILL to it on posix systems, or by closing the process "
|
||||||
"handle on windows. If wait is truthy, will wait for the process to finsih and "
|
"handle on windows. If wait is truthy, will wait for the process to finish and "
|
||||||
"returns the exit code. Otherwise, returns proc.") {
|
"returns the exit code. Otherwise, returns proc.") {
|
||||||
janet_arity(argc, 1, 2);
|
janet_arity(argc, 1, 2);
|
||||||
JanetProc *proc = janet_getabstract(argv, 0, &ProcAT);
|
JanetProc *proc = janet_getabstract(argv, 0, &ProcAT);
|
||||||
@ -689,6 +689,12 @@ static int janet_proc_get(void *p, Janet key, Janet *out) {
|
|||||||
*out = (NULL == proc->err) ? janet_wrap_nil() : janet_wrap_abstract(proc->err);
|
*out = (NULL == proc->err) ? janet_wrap_nil() : janet_wrap_abstract(proc->err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#ifndef JANET_WINDOWS
|
||||||
|
if (janet_keyeq(key, "pid")) {
|
||||||
|
*out = janet_wrap_number(proc->pid);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if ((-1 != proc->return_code) && janet_keyeq(key, "return-code")) {
|
if ((-1 != proc->return_code) && janet_keyeq(key, "return-code")) {
|
||||||
*out = janet_wrap_integer(proc->return_code);
|
*out = janet_wrap_integer(proc->return_code);
|
||||||
return 1;
|
return 1;
|
||||||
@ -1057,7 +1063,9 @@ JANET_CORE_FN(os_execute,
|
|||||||
JANET_CORE_FN(os_spawn,
|
JANET_CORE_FN(os_spawn,
|
||||||
"(os/spawn args &opt flags env)",
|
"(os/spawn args &opt flags env)",
|
||||||
"Execute a program on the system and return a handle to the process. Otherwise, the "
|
"Execute a program on the system and return a handle to the process. Otherwise, the "
|
||||||
"same arguments as os/execute. Does not wait for the process.") {
|
"same arguments as os/execute. Does not wait for the process. "
|
||||||
|
"The returned value has the fields :in, :out, :err, :return-code and "
|
||||||
|
"the additional field :pid on unix like platforms.") {
|
||||||
return os_execute_impl(argc, argv, 1);
|
return os_execute_impl(argc, argv, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,6 @@ static JANET_THREAD_LOCAL int gbl_cols = 80;
|
|||||||
static JANET_THREAD_LOCAL char *gbl_history[JANET_HISTORY_MAX];
|
static JANET_THREAD_LOCAL char *gbl_history[JANET_HISTORY_MAX];
|
||||||
static JANET_THREAD_LOCAL int gbl_history_count = 0;
|
static JANET_THREAD_LOCAL int gbl_history_count = 0;
|
||||||
static JANET_THREAD_LOCAL int gbl_historyi = 0;
|
static JANET_THREAD_LOCAL int gbl_historyi = 0;
|
||||||
static JANET_THREAD_LOCAL int gbl_sigint_flag = 0;
|
|
||||||
static JANET_THREAD_LOCAL struct termios gbl_termios_start;
|
static JANET_THREAD_LOCAL struct termios gbl_termios_start;
|
||||||
static JANET_THREAD_LOCAL JanetByteView gbl_matches[JANET_MATCH_MAX];
|
static JANET_THREAD_LOCAL JanetByteView gbl_matches[JANET_MATCH_MAX];
|
||||||
static JANET_THREAD_LOCAL int gbl_match_count = 0;
|
static JANET_THREAD_LOCAL int gbl_match_count = 0;
|
||||||
@ -758,9 +757,8 @@ static int line() {
|
|||||||
kleft();
|
kleft();
|
||||||
break;
|
break;
|
||||||
case 3: /* ctrl-c */
|
case 3: /* ctrl-c */
|
||||||
clearlines();
|
kill(getpid(), SIGINT);
|
||||||
gbl_sigint_flag = 1;
|
/* fallthrough */
|
||||||
return -1;
|
|
||||||
case 17: /* ctrl-q */
|
case 17: /* ctrl-q */
|
||||||
gbl_cancel_current_repl_form = 1;
|
gbl_cancel_current_repl_form = 1;
|
||||||
clearlines();
|
clearlines();
|
||||||
@ -962,11 +960,7 @@ void janet_line_get(const char *p, JanetBuffer *buffer) {
|
|||||||
}
|
}
|
||||||
if (line()) {
|
if (line()) {
|
||||||
norawmode();
|
norawmode();
|
||||||
if (gbl_sigint_flag) {
|
fputc('\n', out);
|
||||||
raise(SIGINT);
|
|
||||||
} else {
|
|
||||||
fputc('\n', out);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fflush(stdin);
|
fflush(stdin);
|
||||||
|
Loading…
Reference in New Issue
Block a user