I've just opened a Gitter chat room with the hopes, that I can learn femtolisp and contribute to the Julia parser.
> # Welcome fellow femto lispers!
> Welcome @/all you have all been invited to this chat room because I noticed your interest of FemtoLisp, either by chatting directly, forking, staring, watching the femtolisp repository or one of the repositories from FemtoEmacs! ✨
> I hope we can meet, learn and teach this programming language together, please let anyone know who might me interested about this chat room, below are some common resources that I have just recently found:
> * FemtoLisp: https://github.com/JeffBezanson/femtolisp
> * FemtoEmacs: https://github.com/FemtoEmacs/Femto-Emacs
> * FemtoDocs: https://github.com/FemtoEmacs/femtodocs
> I want to learn flisp primary in order to understand the Julia programming language parser, I hope I can contribute documenting, proof reading raising issues and pull requests.
> I wish happy new year to everyone from Mexico!
> Bless the `femtolisp` maker! - AKA @JeffBezanson :D
get_exename() for OpenBSD.
Issue
`get_exename()` gets the pathname of the current process. In
femtolisp, this is used to set the top-level `*install-dir*` which in
turn is used as the location of the system image, `flisp.boot`.
There is only a trivial implementation of `get_exename()` for OpenBSD
that simply returns `NULL`. A minor consequence is that the unit test
will fail for the default build (make) because the system image cannot
be found.
Fix
This commit provides an implementation of `get_exename()` for OpenBSD,
so that the system image can be found.
Unlike, say, Linux or FreeBSD, OpenBSD doesn't have a system call to
get the path of the current (or any, for that matter) process. The
present code contains some logic that was put together to emulate the
behavior of the Linux and FreeBSD variants of `get_exename()` as best
as possible. It works as described by the following.
(1) Call `sysctl(3)` (with `CTL_KERN` -> `KERN_PROC_ARGS` ->
`KERN_PROC_ARGV`) to get the "`argv[0]`" of the current process.
If the program (flisp) was called in "`basename` form" (i.e. as
"flisp"), then go to (2). Otherwise, return the value from
`sysctl(3)` which will be an absolute or relative pathname,
e.g. "/usr/local/bin/flisp" or "../flisp".
The code for (1) was adapted from old OpenBSD-specific `tmux` code
that has since been abandoned by the author only because he deemed
it "too expensive". For that code, see
8c259f562b/tree/osdep-openbsd.c
(2) Since we now only have "flisp", we need to find out where it is
located on the system. We assume that a program like the shell
had to crawl `PATH` to find "flisp"; hence we do the same.
The code for (2) was adapted from the `which` utility in OpenBSD.
See
http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/which/which.c?rev=1.20&content-type=text/plain
Finally, any error condition returns `NULL`, which is the same
behavior of the other `get_exename()` variants.
* Resolve relative pathnames to absolute, for OpenBSD get_exename().
It looks like FreeBSD should do what OpenBSD does in femtolisp's code.
The biggest change here (I think) is that of determining the correct
value of CC in the Makefile(s). As of version 10, FreeBSD's base
compiler is clang; so there is now some logic in the Makefile(s) to
determine if the build is occurring on a FreeBSD system >= 10.0. If
so, then the value of CC will be "clang"; otherwise, it will be "gcc",
as before.
Since OpenBSD is unable to determine the pathname of a running process,
this allows us to specify the full path to flisp.boot. This will also
come in handy for system wide installs where you want flisp to live in
bin and flisp.boot to live in share or a similar location.
- add io.ungetc and string.isutf8
- maintain input order in delete-duplicates
- error for unicode escapes greater than 0x10ffff
- make more builtins constant (use setc instead of set)
- use prog1 in begin0 macro
- array-ref was incorrectly called array-ref! in aliases.scm
- use (void) instead of () in 0-arg C functions
- don't do arithmetic with void*