summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* METALICENSE: paragraph about Bison.Kaz Kylheku2020-10-071-0/+13
| | | | | | * METALICENSE: Include a paragraph explaining the special circumstances regarding the shipping the Bison-generated y.tab.c and y.tab.h files.
* quips: four new entries.Kaz Kylheku2020-10-061-0/+4
| | | | * share/txr/stdlib/quips.tl (sys:%quips%): Add four quips.
* New functions trim-left and trim-right.Kaz Kylheku2020-10-054-0/+140
| | | | | | | | | * regex.c (trim_left, trim_right): New static functions. (regex_init): New intrinsics registered. * tests/015/trim.tl, tests/015/trim.expected: New files. * txr.1: Documented.
* quips: two new entries.Kaz Kylheku2020-10-051-0/+2
| | | | * share/txr/stdlib/quips.tl (sys:%quips%): Add two quips.
* New: quip function for random humor.Kaz Kylheku2020-10-043-0/+122
| | | | | | | | | | | | Add this to your .txr_profile startup file. * lisplib.c (quips_instantiate, quips_set_entries): New static functions. (lisplib_init): Register autoloading of quip. * share/txr/stdlib/quips.tl: New file. * txr.1: Documented.
* configure: quote more characters in cmdlineKaz Kylheku2020-10-021-1/+1
| | | | | | | * configure: When calculating the cmdline variable from the positional parameters, there are more shell-special characters that require quoting: parentheses, braces, redirection operators, the semicolon and the hash comment.
* compiler: don't use move immediate instructions.Kaz Kylheku2020-10-012-5/+0
| | | | | | | | | | | | * share/txr/stdlib/compiler.tl (comp-atom): Remove the special case for small fixnums and characters which encodes their value in a movi instruction as an immediate operand. This means that now these operands go into D registers, like all other literals. * share/txr/stdlib/vm-param.tl (%imm-width%): Remove this constant, reprensenting the maximum bit width of an immediate operand.
* vm: deprecate move-immediate instructions.Kaz Kylheku2020-10-013-4/+10
| | | | | | | | | | | | | | | | | | | The movrsi, movrmi and movrbi (move immediate {small, medium, big} to register) instructions are becoming deprecated. The reasoning is that character and fixnum operands can just go into a VM descriptor's data vector (D registers). Then they can be referenced directly without wastefully issuing an extra instruction. * genvmop.txr: Add a deprecated comment next to the enum constants of deprecated opcodes. * share/txr/stdlib/asm.tl (oc-base): Add Boolean property which indicates that an opcode is deprecated. This is a static class variable, defaulting to nil in the base class. (op-movrsi, op-movsmi, op-movrbi): Override base class deprecated property with a true value. * vmop.h: Regenerated.
* genvmop.txr: stop using :vars.Kaz Kylheku2020-10-011-1/+1
| | | | | * genvmop.txr: :vars removed from @(repeat) syntax. It is no longer required as of the previous commit's fix.
* txr: bugfix: repeat not finding Lisp vars in brace.Kaz Kylheku2020-10-012-10/+18
| | | | | | | | | | | | | | | | | | | The following does not work and is fixed here: @(output) @(repeat) @{lisp-expr ...} @(end) When a Lisp expression occurs in a braced expansion syntax, it is not not traversed to find variables. * parser.y (extract_vars): Treat the second element of a sys:var as a Lisp expression, and find variables. Don't do this in 128 or older compatibility mode, because then that is a TXR expression. * y.tab.c.shipped: Regenerated.
* configure: only detect lex in maintainer mode.Kaz Kylheku2020-09-242-24/+32
| | | | | | | | | * Makefile (lex.yy.c): Move rule into maintainer conditional. * configure: Describe maintainer variable in help text. Move lex check into maintainer conditional. * lex.yy.c.shipped: New file.
* configure: detect yacc only in maintainer mode.Kaz Kylheku2020-09-242-47/+46
| | | | | | | | | | | * Makefile (YACC_FLAGS): Removed. We don't need these because we won't be trying to get newer Bison to behave like older Bison. (y.tab.c): Drop reference to $(YACC_FLAGS). * configure: Entire yacc-detecting section is conditional on the maintainer Boolean variable. If the yacc program is detected as Bison, check for version 2.5 and fail if not found.
* parser: commit Bison-2.5-generated code.Kaz Kylheku2020-09-244-11/+14353
| | | | | | | | | | | | | * Makefile (BS_LIC_FROM, BS_LIC_TO): Variables removed. (y.tab.c): Remove all filtering hacks. Don't remove the license from y.tab.c. Don't remove yyparse declaration from y.tab.h. Provide a pattern rule for producing any missing file X from X.shipped. That's how y.tab.c and y.tab.h get produced from y.tab.c.shipped and y.tab.h.shipped, respectively, in user mode. * y.tab.c.shipped, y.tab.h.shipped: New files, generated using Bison 2.5.
* new: maintainer mode.Kaz Kylheku2020-09-242-0/+8
| | | | | | | | | | | | | | | | | | There is now a ./configure --maintainer mode which establishes a variable called maintainer in config.make, with a y value. The initial use for maintainer mode will be that the Yacc parser (the y.tab.c and y.tab.h) files will no longer be regenerated whenever the parser.y file is newer. In the following commit, I will add a generated parser. * Makefile (y.tab.h, y.tab.c): These rules are now only enabled in maintainer mode via an ifeq. * configure (maintainer): New variable. (gen_config_make): Generate maintainer make variable definition in config.make.
* Makefile: stray tabs.Kaz Kylheku2020-09-241-1/+1
| | | | | * Makefile (lex.yy.c): Remove tabs that are being used for alignment instead of spaces.
* Version 243txr-243Kaz Kylheku2020-09-016-425/+453
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* oop: add tests for diamond problem.Kaz Kylheku2020-09-012-2/+23
| | | | | | | | * tests/012/oop-mi.tl (grand, base1, base2): Add list slot li to grand, targeted by :init and :fini handlers in all three structs. Added test case which triggers finalization. * tests/012/oop-mi.expected: Updated.
* tags: address small issue with tag lookup.Kaz Kylheku2020-09-013-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exuberant Ctags uses the full content of one line as the key to find a tag. A function declaration that is split into multiple lines can have a first line which is identical to the definition, as in: static int add(int a, int b); static int add(int a, int b) { return a + b; } Here, the search key which ctags uses for the add function is "static int add(int a,", taken from the definition. But it's exactly the same as a the first line of the declaration, and that is what Vim jumps to for that tag. A few function declarations in TXR have this issue. * eval.c (expand_params_rec, do_eval): Make the first line of the forward declaration different from the first line of the definition. * match.c (mf_all): Likewise. * struct.c (make_struct_type_compat): Likewise.
* New function: reject.Kaz Kylheku2020-09-014-0/+117
| | | | | | | | | | | * eval.c (eva_init): Register reject intrinsic. * lib.c (appendl): New static function. (reject): New function. * lib.h (reject): Declared. * txr.1: Documented.
* doc: minor flaw in select syntax markup.Kaz Kylheku2020-08-301-1/+1
| | | | * txr.1: remove space between | and "function".
* doc: rewrite multiple inheritance intro paragraph.Kaz Kylheku2020-08-281-9/+3
| | | | | | * txr.1: Simplify the paragraph, and eliminate the introduction of the unnecessary term "strict single inheritance".
* doc: :fini also affected by diamond problem.Kaz Kylheku2020-08-281-4/+25
| | | | | | * txr.1: Document that the change in behavior to initialize a duplicate base just once also affects :fini, not only initialization. Example expanded.
* OOP: use chk_calloc for objects.Kaz Kylheku2020-08-271-9/+4
| | | | | | | * struct.c (make_struct_impl, make_lazy_struct): Use chk_calloc instead of chk_malloc for allocating objects. Remove the loops that initialize slots to nil. Remove the initialization of the lazy flag to zero.
* OOP: bugfix: lazy object uninitialized dirty flag.Kaz Kylheku2020-08-271-0/+1
| | | | | | * struct.c (make_lazy_struct): Initialize dirty flag to 1, as required by the documentation, since all newly instantiated objects are dirty.
* OOP: optimization in dupe base check.Kaz Kylheku2020-08-271-7/+7
| | | | | | | | | | | | | | | | | | | | Hypothesis: the majority of struct types will not be used as inheritance bases, and most of those that are bases will not be appear as duplicate bases. If we put a flag into a type which indicates that it has been used as a duplicate base, we can check that flag to do less work when initializing an object. * struct.c (struct struct_type): New flag, dupe. (get_duplicate_supers): Each time we find a duplicate supertype, we set its dupe flag. (make_struct_type): Allocate the struct type with chk_calloc instead of chk_malloc, so the flag is initialized to zero. Remove initializations of some members to zero: those of nslots, ntslots, stslot and spslot. (call_initfun_chain, call_postinitfun_chain): Don't bother search for st in the root's array of duplicates if st is not marked with the dupe flag.
* structs: deal with initialization diamond problem.Kaz Kylheku2020-08-272-13/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now it has been documented that if a struct type inherits a supertype two or more times, then the supertype initialization occurs that many times. This change fixes the behavior: bases are initialized once. * struct.c (struct struct_type): New members, ndsupers, dsus providing a flat array for tracking duplicate supertypes. (get_all_supers, get_duplicate_supers): New static functions. (make_struct_type): Calculate the duplicate supers, and store them in the dsus array. Under 242 or lower compat mode, pretend there are duplicates, which defeats the duplicate detecting mechanism (struct_type_destroy): Free the dsus array. (call_inittfun_chain, call_postinitfun_chain): Take new arguments: the root type from which the recursion started, and a stack-allocated bit vector indicating which duplicate bases have already been initialized. If the given type appears in the duplicate bases list of the root type, and its bit is already set, then skip all initialization for it. Otherwise set its bit and proceed. (alloc_seen, clear_seen): New macros to help with allocating the bitvector of duplicate bases. (make_struct_impl, lazy_struct_init, reset_struct): Use alloc_seen and clear_seen macros to manage the bitvector of duplicate bases for calling call_initfun_chain and call_postinitfun_chain. * txr.1: Updated doc with new paragraph about duplicated supertypes, and compat note added.
* ffi/doc: bugfixes to bitfield alignment.Kaz Kylheku2020-08-242-22/+24
| | | | | | | | | | | | | | | | | | | | | | | | | Three issues issues. The documentation is wrong about the concept of a "leading bitfield" whose alignment matters. The alignment of all named bitfields matters. Secondly, the alignment of unnamed bitfields doesn't matter. Thirdly, there is a flaw in the treatment of bitfields in unions, from both alignment and sizing. * ffi.c (make_ffi_type_struct): A bitfield member contributes to alignment regardless of its offset within an allocation unit: no bits_alloc == 0 check should be applied. Secondly, a bitfield member that is unnamed has an alignment of 1, otherwise the alignment of its declared type. (make_ffi_type_union): The size and alignment of a bitfield member is not simply that of its type. The size of a bitfield is the number of bytes required to store all of the bits. The alignment is 1 if it is unnamed, otherwise that of its type. The sizing of bitfields now means that alignment can add padding to a union. For instance, a uint32_t x : 17 bitfield has size 3, but alignment 4, requiring one byte of alignment padding in the union so that its size is 4. This means that we must now do the padding alignment calculation for unions to adjust the size, just like we do for structures.
* doc: ffi: struct size with only zero-width field.Kaz Kylheku2020-08-241-1/+2
| | | | | * txr.1: Document that the size of a struct that contains nothing but a zero-width field is zero.
* ffi: bugfix: zero-width bitfield offset problem.Kaz Kylheku2020-08-241-1/+1
| | | | | | | | | | | | | | | | * ffi.c (make_ffi_type_struct): Fix incorrect condition for determining whether the zero-width bitfield allocates a unit or not. We must take into account the bit_offs, because it's possible that unit_offs and offs are the same, yet a previous bitfield has allocated some bits into the current allocation unit. For instance struct { char a : 1; uint32 : 0; char b } has size 5, but the equivalent FFI struct type ends up with size 1. After char a : 1, the byte offset is still zero, so if we don't look at the bit offset of 1, it looks like the allocation offset is aligned to the start of a uint32 cell, which then means that the zero-width bitfield is ignored. What's worse, the char b is then also allocated over top of the a : 1 bitfield.
* ffi: correct tft->nmemb under zero-bit fields.Kaz Kylheku2020-08-241-2/+4
| | | | | | | | | * ffi.c (make_ffi_type_struct, make_ffi_type_union): Assign tft->memb = memb after the loop which compiles the member types, because memb is decremented in the case of the zero-width bitfield. This hasn't cause an issue because the extra members are all zero, so their slot symbol is nil, and all the relevant operations skip a nil named member.
* doc: clarify *load-path* treatment under @(load)Kaz Kylheku2020-08-191-1/+3
| | | | | | * txr.1: Make it clear that pure-rel-path-p is applied to the target path coming from the @(load) directive, and not to the value in *load-path*.
* txr: repeat ferrets out Lisp-embedded vars.Kaz Kylheku2020-08-174-46/+87
| | | | | | | | | | | | | | | Gone is the need for :vars to inform @(repeat)/@(rep) about variable references buried in Lisp. * eval.c (expand_with_free_refs): Change to external linkage. * eval.h (expand_with_free_refs): Declared. * parser.y (extract_vars): Handle sys:expr forms, which are embedded Lisp via expand_with_free_refs to uncover their free variables. * txr.1: Redocumented this area.
* txr: identify output repeat vars at parse timeKaz Kylheku2020-08-172-52/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | Up to now the @(repeat) and @(rep) directives have scanned their interior to find output variables. We now hoist that into the parser; the variables are found up-front and integrated into the abstract syntax. This work anticipates doing a more proper job of identifying free variables in Lisp expressions. * match.c (extract_vars): Delete static this function here. It moves into parser.y. (extract_bindings): Don't call extract_vars to obtain the variables occurring in the repeat body. Get it as a new argument, occur_vars. (do_output_line, do_repeat): Extract the new occur_vars element of the abstract syntax node and pass it to extract_bindings. * parser.y (extract_vars): New static function, moved here from match.c. (repeat_rep_helper): Scan over each of the repeat subclauses with extract vars. Catenate the resulting lists together and pass through uniq to squash repeated symbols. Then add the resulting vars as a new element of the returned syntax node.
* Remove unnecessary forward declarations.Kaz Kylheku2020-08-172-3/+0
| | | | | | * lib.c (length_proper_list): Forward decl removed. * match.c (do_match_line): Likewise.
* Version 242txr-242Kaz Kylheku2020-08-144-5/+18
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* match.c: revert bad commits.Kaz Kylheku2020-08-141-158/+118
| | | | | | | | | | | | | | | | | | | This contains two reverts, folded into one. "txr: spurious retention in @(next)." commit fe1e960389a89f481d46c02aa040fdc762da735f. "txr: avoid by-value match_files_ctx passing." commit 3d7330b827d6e9cc0d9e87edd30388374cb45900. These are dependent. The second of these two (i.e. the one that was done first) is the problematic one. By-reference passing of contexts means contexts become shared objects between callers and callees. But this is incorrect, because mutations are going on, like c->spec = rest(c->spec) or c->data = rest(c->data). These mutations were done under the assumption of safety: that the caller is not affected due to by-value semantics of the entire context.
* doc: listener: undo over history clarifications.Kaz Kylheku2020-08-141-6/+12
| | | | | | * txr.1: Document that all the edits done to a history line are committed as a single undo item when navigating away from it. Clarify some text related to undo over a history line.