summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* doc: improve awk fconv documenation.Kaz Kylheku2020-12-311-0/+16
| | | | | | * txr.1: List the no-conversion - operator among the shortcuts, so it is easier to discover. Add a note that that fconv is potentially applicable to non-string fields.
* gc: bug: finalization logic causing gc assertKaz Kylheku2020-12-311-7/+17
| | | | | | | | | | | | | | | | | | | | | This problem was introduced on Feb 18, 2019 in commit 3931df5cba3d826511503ad1c0a5b84c1363765e. Explicit finalization of objects outside of GC can trigger an assertion in a later GC pass. * gc.c (call_finalizers_impl): We simply must not have duplicate entries in fresh_obj; this causes problems for sweep_one. Under Valgrind debugging, sweep_one protects the memory of processed entries, so a duplicate visit triggers bad accesses. A more serious issue is that this function can be called outside of gc, explicitly, since it is available as an API function. So that is to say, non-garbage objects can have their finalizers called ouside of GC. If this function is called explicitly, outside of GC, it can end up doing something stupid, like adding a generation 1 object into the freshobj array, triggering an assert. We address this by not doing any of that processing if GC is not taking place.
* doc: note for awk macro fconv.Kaz Kylheku2020-12-291-0/+11
| | | | * txr.1: Add usage note to the fconv macro.
* awk: bugfix: load compiled verison of conv.tl.Kaz Kylheku2020-12-291-1/+1
| | | | | * share/txr/stdlib/awk.tl: Load "conv", not "conv.tl", so that if there is a .tlo present, it is loaded instead.
* awk: bugfix: fconv symbols not in usr package.Kaz Kylheku2020-12-292-13/+16
| | | | | | | * share/txr/stdlib/conv.tl (sys:conv-let): Use usr: package prefix on the conversion symbols i, o, x, b. They are being interned in the system package, which breaks the awk fconv macro.
* quips: use random-state argument in shuffle call.Kaz Kylheku2020-12-291-2/+1
| | | | | * share/txr/stdlib/quips.tl (quip): Don't bind *random-state*; pass an argument to shuffle.
* shuffle/nshuffle: take optional random state argument.Kaz Kylheku2020-12-294-11/+13
| | | | | | | | | | | | | * eval.c (eval_init): Register shuffle and nshuffle as two-argument functions with optional argument. * lib.c (nshuffle): Take random-state argument, defaulting to value of random_state special variable. (shuffle): Take random-state argument, pass down to nshuffle. * lib.h (shuffle, nshuffle): Declarations updated. * txr.1: Updated.
* shuffle/nshuffle: eliminate wasteful vector copy.Kaz Kylheku2020-12-291-1/+1
| | | | | | * lib.c (nshuffle): When shuffling the vector that was converted from the list, use nshuffle rather shuffle, because it's a temporary, non-shared object we can mutate.
* quips: new one.Kaz Kylheku2020-12-281-0/+1
| | | | * share/txr/stdlib/quips.tl (sys:%quips%); New entry.
* quip: function cycles through all quips.Kaz Kylheku2020-12-281-1/+6
| | | | | | * share/txr/stdlib/quips.tl (sys:%shuffled-quips%): New variable. (quip): Pop quips from the new variable. When the list is empty, populate it by shuffling the quips.
* doc: correction in dialect notes for symbol-macroKaz Kylheku2020-12-271-3/+5
| | | | | * doc: Common Lisp has a function like symbol-macro function; it is called macro-function.
* Version 245txr-245Kaz Kylheku2020-10-104-9/+36
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. Fixed repeated word in documentation under env-hash. * share/txr/stdlib/ver.tl: Bumped from incorrect 243 value to 245.
* chmod: disable some chmod tests on Cygwin.Kaz Kylheku2020-12-241-21/+26
| | | | | | | * tests/018/chmod.tl: Certain chmod test cases no longer work on Cygwin. The issue is the chmod system call. It produces completely nonsensical results in some cases. We disable these test cases on Cygwin.
* linenoise: fix: int used instead of wchar_t.Kaz Kylheku2020-12-241-2/+2
| | | | | * linenoise.c (scan_match_rev, scan_match_fwd): The value of s[i] must be captured in a wchar_t, not int.
* android: fix socket module, failing tests.Kaz Kylheku2020-12-235-15/+18
| | | | | | | | | | | | | * socket.c: Add missing #include <netinet/in.h>. * tests/017/glob-carray.tl, tests/017/glob-zarray.tl: Use same definition for struct glob as Cygwin. Both are of BSD origin. * tests/017/realpath.tl: Do not test on Android. * tests/common.tl (os-symbol): Detect Android and return :android. (libc): Handle :android.
* configure: don't disable PIE on Android.Kaz Kylheku2020-12-231-25/+29
| | | | | | | * configure: Move how-to-disable-PIE check below plaform detections, where we know whether we have Android or not. On Android, we can't disable PIE; non-PIE executables are not supported. Let's cross our fingers things work.
* build: Android support.Kaz Kylheku2020-12-232-0/+22
| | | | | | | | | | * Makefile (conftest.android): New helper target for testing for Android toolchain, via presence of __ANDROID__ preprocessor symbol, similarly to how we detect Darwin. * configure: New test for Android. This is mutually exclusive agains Darwin. On Android, we add some necessary feature selection macros to the compiler command line.
* configure: rename darwin variable.Kaz Kylheku2020-12-231-3/+3
| | | | * configure (need_darwin_c_source): Renamed to darwin_target.
* configure: get rid of -Wold-style-declarationKaz Kylheku2020-12-231-1/+1
| | | | | | | | * configure (diag_flags): Remove the -Wold-style-declaration option. It is not useful, unlike -Wold-style-definition; it warns agains some unspecified old style usages, like storage class specifiers not being first. Moreover, clang 10 does not recognize this option and complains.
* configure: relax to C99 for regular users.Kaz Kylheku2020-12-221-2/+9
| | | | | | | | | | | The code will continue to stick to C90, but requesting C90 compatibility from GCC may break for downstream users in some environments that don't support C90 in their header files. * configure (lang_flags): Remove -ansi option from here. (usage): Help text for maintainer mode updated. (mainline): Add -std=c++98 to the front of lang_flags if compiling as C++, -std=c90 in maintainer mode, else -std=c99.
* configure: C++ fix for recently added C flags.Kaz Kylheku2020-12-221-0/+1
| | | | | | | * configure: When we detect we are using C++, we filter out certain C-only compiler options. TO that list, we must add a pattern that gets rid of the recently added -Wold-style-definitions and -Wold-style-declarations.
* configure: C++ fix for type size detection case.Kaz Kylheku2020-12-221-4/+4
| | | | | | | | | | * configure: The new logic for detecting type sizes introduced in October, replacing the old nm-based trick, doesn't work with C++. An anonymous structure is being used to define an object with linkage: we fix that by giving the structure a tag name which be. C++ also doesn't like a one-character string literal like "\n" being used to initialize a char [1] array, so we make it [2].
* shipped lexer: fix misleading indentation.Kaz Kylheku2020-12-221-5/+5
| | | | | * lex.yy.c.shippped (YY_DECL): Fix some bad indentation, most likely caused by using a mixture of tabs and spaces.
* int-flo: bugfix on 64 bitKaz Kylheku2020-12-221-2/+9
| | | | | | | | | | | | | | | * arith.c (int_flo): On 64 bit, we incorrectly handle the positive floating-point values which correspond to (expt 2 63) and (expt 2 64). This is because in the range check which detects whether a double value lands into the cnum or ucnum range, the 64 bit INT_PTR_MAX and UINT_PTR_MAX have no exact equivalent in the double type and are being converted to double values which are greater. That then causes the range check to incorrectly include double values that are actually out of range for the conversion to the cnum or ucnum type, causing bogus values. The quickest fix would be to use < comparison for a half-open range, but that sacrifices two double values on 32 bit, unnecessarily sending them to the text-based conversion code. So instead, let's subtract margins from the range constants on 64 bit.
* build: add more warnings against ancient C.Kaz Kylheku2020-12-131-1/+3
| | | | | | * configure (diag_flags): Add warning options agains defining an old style C function, and against obsolecent features in declarations.
* txr, eval: eliminate some func_n1 calls.Kaz Kylheku2020-12-102-5/+5
| | | | | | | | | * match.c (do_output_line, do_repeat, v_deffiler): Replace func_n1(cdr) and func_n1(rest) with cdr_f. * eval.c (eval_init): Replace func_n1(car) and func_n1(cdr) with car_f and cdr_f. Should have been done in 2011 when this was done for the registrations of car and cdr.
* New quip: inspired by dumb phone messages.Kaz Kylheku2020-12-101-0/+1
| | | | * share/txr/stdlib/quips.tl (sys:%quips%): New entry.
* mpi: small rearrangement in is-power-of-two function.Kaz Kylheku2020-11-221-4/+2
| | | | | | * mpi.c (s_mp_ispow2): Delay call to s_highest_bit until that value is actually needed. Perhaps the compiler does the code motion, but let's write the code that way.
* printer: no leading zeros in hex chars.Kaz Kylheku2020-11-171-9/+6
| | | | | | | | * lib.c (obj_print_impl): Drop the complicated logic for printing a character as 2, 4 or 6 hex digits. All characters that must print using the #\x notation are jus printed using the ~X format specifier with no precision or leading zeros, which will use just as many digits as are required.
* quips: three new entries.Kaz Kylheku2020-11-161-0/+3
| | | | * share/txr/stdlib/quips.tl (sys:%quips%): Add new quips.
* time: indentation fix.Kaz Kylheku2020-10-161-12/+12
| | | | * time.c (timegm_hack): Use two space indentation, not four.
* time: don't emulate setenv with putenvKaz Kylheku2020-10-161-20/+13
| | | | | | | | * time.c (setenv, unsetenv): Removed. (timegm_hack): Now defined earnestly only if HAVE_SETENV is true, otherwise a stub is defined that throws an error. (time_init): Don't register make-time-utc intrinsic if we don't have a timegm function.
* sysif: respect HAVE_SETENV.Kaz Kylheku2020-10-161-0/+6
| | | | | | | | * sysif.c (setenv_wrap, unsetenv_wrap): Now surrounded with #if HAVE_SETENV ... #endif, an existing feature detection macro. (sysif_init): Only register setenv and unsetenv functions if HAVE_SETENV is true.
* env-hash: now persistent and synced with setenv.Kaz Kylheku2020-10-162-19/+108
| | | | | | | | | | | | | | * sysif.c (env_hash): Function renamed to get_env_hash and a static variable named env_hash introduced. Function returns a previously allocated hash table, if it exists, except in compat mode. (getenv_wrap): Stash the result into the hash also. (setenv_wrap): Keep the hash up-to-date with the action of setenv. (unsetenv_wrap): Also delete from the hash. (sysif_init): Protect the env_hash variable from gc. * txr.1: Documented, with compat notes.
* doc: add missing detail to env function.Kaz Kylheku2020-10-161-0/+8
| | | | | | * txr.1: The env function actually returns a cached list. Spell out that the function is not required to construct a new list.
* env: move function to sysif.cKaz Kylheku2020-10-165-38/+39
| | | | | | | | | | | | | | | | | * lib.c (env_list): Static variable removed; now appears in sysif.c (env): Function removed; now in sysif.c. (obj_init): Don't gc-protect env_list here any more. * lib.h (env): Declaration removed. * match.c: Must include "sysif.h" now for env. * sysif.c (env_list): Static variable moved here. (env): Function moved here. (sysif_init): env_list gc-protected here. * sysif.h (env): Declared.
* struct: bad object in two diagnostics.Kaz Kylheku2020-10-161-2/+2
| | | | | | | * struct.c (umethod_fun, umethod_args_fun): The env function is being used as an object, passed to the ~a conversion specifier of the formatter. The correct argument is the sym variable.
* Version 244txr-244Kaz Kylheku2020-10-105-438/+489
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* time: Solaris fix: don't assign to env_list.Kaz Kylheku2020-10-101-1/+0
| | | | | | | | | | * time.c (env_list): The env_list variable is static in lib.c. The idea here was that since we modified the environment with setenv, we should invalidate the env hash which stores a cached copy of it. However, the setenv library function that is exposed to programs neglects to do this, which is a much larger issue. Let's delete the assignment to env_list and deal with the whole issue later.
* mapcar: regression: not not converting to left typeKaz Kylheku2020-10-101-1/+2
| | | | | | * eval.c (map_common): Save the leftmost arg in a local variable, and refer to that in the make_like call. The bug here is that the args get zapped to nil.
* configure: replace nm-based trick for sizesKaz Kylheku2020-10-092-82/+63
| | | | | | | | | | | | | | | | | | | | | | | | The trick of declaring static arrays whose size is the value of an integer is not working with newer gcc 10 on Cygwin, because that compiler is rearranging the order of the arrays and adding padding. Basically, the writing on the wall is that this is not a good approach. I'm switching to a different approach. By initializing a suitable C structure (which contains character arrays) in a particular way, we can create a .o file in which a shell script is embedded. We can pull out the shell script and evaluate it to get the sizes of types. * Makefile (conftest.syms): Rule removed. (conftest.clean): Don't remove conftest.syms. * configure (conftest_syms, read_syms): Functions removed. (LANG, LC_ALL): New environment variables. This is needed because we are using tr to process a binary file; we can't have it trying to decode multi-byte characters. (mainline): Use new trick for obtaining variables like SIZEOF_INT.
* compiler: bump up compiled file version to 5.1.Kaz Kylheku2020-10-091-1/+1
| | | | | | | | | | | | | * share/txr/stdlib/compiler.tl (%tlo-ver%): Bump minor version from 0 to 1. Because the major version doesn't change, these files will be loaded by TXR 216 through 243, because those versions only look at the major number. The upcoming 244 will continue to do that. What the minor number increase indicates is that the compiled files do not use the deprecated movi instruction group. If a future version of TXR removes the instructions from the VM, it will then insist on only loading version 5 files if the minor number is at least 1. Version 5.0 files will be rejected, as will version 4 or lower.
* doc: missing info about compiled file version 5.Kaz Kylheku2020-10-091-1/+3
| | | | | * txr.1: TXR 216 bumped the compiled file version from 4 to 5, but this was not documented.
* random: use nanoseconds for seeding.Kaz Kylheku2020-10-071-1/+1
| | | | | * rand.c (make_random_state): Use time_sec_nsec to obtain a time with nanoseconds, instead of time_sec_usec.
* New function: time-nsec.Kaz Kylheku2020-10-074-1/+54
| | | | | | | | | | | | * configure: Test for clock_gettime, generating HAVE_CLOCK_GETTIME symbol in config.h. * time.c (time_sec_nsec): New function. (time_init): time-nsec intrinsic registered. * time.h (time_sec_nsec): Declared. * txr.1: Documented.
* time: move time functions out of lib.c into time.c.Kaz Kylheku2020-10-078-488/+567
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile (OBJS): Add new time.o. * eval.c (eval_init): Registration of time functions is removed from here; it is done in time_init now, in time.c. * hash.c: Must #include "time.h" now. * lib.c (time_s, time_local_s, time_utc_s, time_string_s, time_parse_s, year_s, month_s, day_s, hour_s, min_s, sec_s, dst_s, gmtoff_s, zone_s): Variable definitions removed. These are now in time.c. Also declared in time.h. (time_sec, time_sec_usec, gmtime_r, localtime_r, string_time, time_string_local, time_string_utc, broken_time_list, tm_to_time_struct, broken_time_struct, time_fields_local, time_fields_utc, time_struct_local, time_struct_utc, time_fields_to_tm, time_struct_to_tm, make_time_impl, make_time, epoch_tm, strptime_wrap, time_parse, setenv, unsetenv, timegm_hack, make_time_utc, time_meth, time_string_meth, time_parse_meth, time_parse_local, time_parse_utc): Functions removed. These are now in time.c. (time_init): Removed, and now in time.c as an external function. * lib.h (time_sec, time_sec_usec, time_string_local, time_string_utc, time_fields_local, time_fields_utc, time_struct_local, time_struct_utc, make_time, make_time_utc, time_parse, time_parse_local, time_parse_utc): Declarations removed. Now in time.h. * rand.c: Must #include "time.h" now. * time.c: New file. * time.h: New file.
* random: correctly refer to WELL512a everywhere.Kaz Kylheku2020-10-072-6/+6
| | | | | | * rand.c: Refer to "WELL512a" in comment, not "WELL 512". * txr.1: Replace "WELL 512" with "WELL512a" everywhere.
* random: add tests validating WELL512a.Kaz Kylheku2020-10-072-0/+24
| | | | | | * tests/013/well512a.tl: New file. * tests/013/well512a.expected: New file.
* random: bugfix: incorrect WELL512a.Kaz Kylheku2020-10-073-65/+98
| | | | | | | | | | | | | | | | | | | * rand.c (rand32_bug): New static function formed by renaming the original buggy rand32. (rand32_good): Copy of rand32 with two bugfixes. The term involving variable r2 must be only left shifted by 28 bits, and not xor-ed with the original value. The order of operations is wrong in the term that contains the & operation. (rand32): New static function pointer variable, serving as the rand32 function. Points to rand32_good by default. (rand_compat_fixup): Test for 243 or lower compatibility, under which rand32 is made point to rand32_bug. This is done before the call to make_random_state for replacing *random-state*, which has to use the old function. * txr.1: compat note added. * tests/013/maze.expected: Updated.
* doc: out of order compat entries.Kaz Kylheku2020-10-071-6/+6
| | | | * txr.1: Fix out-of-order compatibility 247 and 242 entries.