summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* New function: copy-cptr.Kaz Kylheku2022-01-286-1/+35
| | | | | | | | | | | | | | | * eval.c (eval_init): copy-cptr intrinsic registered. * lib.c (copy_cptr): New function. (copy): Use copy_cptr for CPTR objects. * lib.h (copy_cptr): Declared. * tests/017/ffi-misc.tl: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* filter: actually throw from filter-string-tree.Paul A. Patience2022-01-271-2/+4
| | | | | | | | | * filter.c (filter_string_tree): The function tries to call uw_throwf when an invalid filter is provided, but an overzealous return statement renders the effort futile. Remove the return statement, change the exception type from error_s to type_error_s, and conform the message to the usual type-error style.
* quips: new entry.Kaz Kylheku2022-01-251-0/+1
| | | | % stdlib/quips.tl (%quips%): New one.
* Remove numerous unused global functions.Kaz Kylheku2022-01-239-140/+23
| | | | | | | | | | | | | | | | | | | | | | | * eval.[ch] (lookup_global_var_l): Remove. * itypes.[ch] (c_schar): Likewise. * lib.[ch] (null_list, rcyc_list, gequal, func_n6v, func_n7v, func_n8v, do_pa_123_23, pa_123_23, orf, aconsql_new_c): Likewise. (obj_init): Remove references to null_list. * mpi/mpi-config.h (MP_FOR_TXR): New preprocessor symbol, defined as 1. * mpi/mpi.c (mp_get_prec, mp_set_prec, mp_init_array, mp_clear_array, mp_set_word, mp_exptmod_d, mp_cmp_d, mp_cmp_mag, mp_cmp_int, mp_lcm, mp_xgcd, mp_invmod, mp_char2value): Exclude using #if !MPI_FOR_TXR, rather than remove. We don't bother excluding the declarations in the header. * utf8.[ch] (w_freopen): Remove.
* signal: make stack_refcount static.Kaz Kylheku2022-01-231-1/+1
| | | | | * signal.c (stack_refcount): This variable is referenced only from two static functions here; it should be static.
* lib: new functions nand, nor, nandf and norf.Paul A. Patience2022-01-225-32/+171
| | | | | | | | | | | | | | * eval.c (me_nand, me_nor, nor_fun, nand_fun): New functions. (eval_init): Register new intrinsics. * lib.c (nandv, norv): New functions. * lib.h (nandv, norv): Declared. * txr.1: Documented, along with trivial fixes to the descriptions of and, or, andf, orf and notf. * stdlib/doc-syms.tl: Updated.
* compiler: optimize some typep expressions.Kaz Kylheku2022-01-211-0/+12
| | | | | | | | * stdlib/compiler.tl (compiler compile): Handle typep symbol via comp-typep method. (compiler comp-typep): New method. This recognizes some absolute truths: every object is of type t, and no object is of type nil.
* typecase: merge with etypecase, handle t differnetly.Kaz Kylheku2022-01-213-20/+40
| | | | | | | | | | | | | | | | | * stdlib/type.tl (sys:typecase-expander): New function, formed from body of typecase. Bad clause syntax now handled with compile-error rather than (throwf 'eval-error). The t symbol is handled specially: it turns into a t conditon in the resulting cond rather than a typep test. The compiler will nicely eliminate dead code after that. Now etypecase is handled here also: if we are expanding etypecase, we just emit the extra clause. (typecase, etypecase): Reduced to sys:typecase-expander calls. * tests/012/typecase.tl: New file. * tests/012/compile.tl: Add type.tl to list of compile-tested files.
* type: new macro etypecase.Paul A. Patience2022-01-214-1/+51
| | | | | | | | | | * lisplib.c (type_set_entries): Add etypecase to autoload list. * stdlib/type.tl (etypecase): New macro. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* compiler: few more cases of ifq/ifql removal.Kaz Kylheku2022-01-181-1/+10
| | | | | | | | | | * optimize.tl (basic-blocks peephole-block): Check for the reversed arguments case of (ifq (d x) (t 0)), and also match ifq. Add a case for two different d registers being compared by ifq or ifql which are not both implicated as load-time regs; that also converts to an unconditional jmp to the else label. Add a case for a register being compared with itself with ifq or ifql, which disappears.
* doc: mention each-match and while-match in overview.Kaz Kylheku2022-01-181-0/+6
| | | | | * txr.1: In the Pattern-Matching macros overview section, mention while-match and each-match.
* quasiquote: make new @,expr work in dot position.Kaz Kylheku2022-01-182-7/+26
| | | | | | | | | | | | | | | Bugfix: the newly introduced @.expr fails in the dotted position because ^(a . @,expr) turns into (list 'a 'let ...). * eval.c (is_meta_unquote): New static function. (expand_qquote_rec): Replace existing shape test with is_meta_unquote. We must also use this test in one more place: whenever the cdr of a list has the meta unquote shape, we must treat the result similarly to a dotted atom, by converting to append format. * tests/010/qquote.tl: Test cases to cover this.
* quasiquote: support @,expr hack.Kaz Kylheku2022-01-183-0/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For better or worse, TXR Lisp has a dichotomy of representation that @<atom> produces sys:var syntax, whereas @<compound> produces sys:expr. This can cause an issue in backquoting. Suppose you want to use backquote to generate sytax like (a @b) where the b comes from a variable. The problem is that (let ((x 'b)) ^(a @,x)) doesn't do what you might expect: it produces (sys:expr b) rather than (sys:var b). This patch adds a hack into the quasiquote expander which causes it to generate code to do what you expect. Old behavior: 1> (expand '^(a @,x)) (list 'a (list 'sys:expr x)) New behavior: 1> (expand '^(a @,x)) (list 'a (let ((#:g0012 x)) (if (atom #:g0012) (list 'sys:var #:g0012) (list 'sys:expr #:g0012)))) In other words, x will be evaluted, and the based on the type of the object which emerges, either sys:var or sys:expr syntax is generated. * eval.c (expand_qquote_rec): Implement the above hack. We are careful to only do this when this exact shape occurs in the syntax: (sys:expr (sys:unquote item)). * tests/010/qquote.tl: New file. * txr.1: Documented.
* doc: introduce meta-atom terminology.Kaz Kylheku2022-01-181-23/+31
| | | | | | * txr.1: the @expr syntax is not just for numbers, symbols and compound expressions. Most atom syntax can follow @, and produces sys:var.
* New function: match-fboundp.Kaz Kylheku2022-01-176-1/+29
| | | | | | | | | | | | | | | | | | User vapnik spaknik was asking in the mailing list whether there is an existence test for TXR pattern functions. Now there is. * eval.c (eval_init): Register match-fboundp intrinsic. * match.c (match_fbound): New function. * match.h (match_fbound): Declared. * tests/011/txr-case.txr: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* keyparams: fix broken.Kaz Kylheku2022-01-172-34/+59
| | | | | | | | | | | | | | | | | | | Issues reported by user vapnik spaknik. The evaluation of init forms is incorrect. Init forms like '(x) evaluate to '(x) rather than (x), Also, init forms are evaluated even when the argument is present, so the entire current approach is wrong. * stdlib/keyparams.tl (extract-keys, extract-keys-p, build-key-list-expr): Functions removed. (stuff-key-params): New function. (:key): Rework using simplified approach, with just the stuff-key-params helper. All variables from the keyword parameter list are bound with let. Generated code searches the keyword parameters for values and assigns the variables as needed, evaluating default init forms in the not-found cases. * tests/011/keyparams.tl: New file.
* quips: a turn toward the slightly macabre.Kaz Kylheku2022-01-171-0/+1
| | | | * stdlib/quips.tl (%quips%): New entry.
* testing: cover compiled, non-inlined lambda.Kaz Kylheku2022-01-141-13/+28
| | | | | | | | | | | | | | | | | | | The lambda.tl test, when compiled, is only testing the compiler's implementation of the inlined lambda: code generated from a lambda expression to which arguments are statically applied. We augment this to also compile real lambda functions which are called. Everything passes. * tests/012/lambda.tl (call-lambda): New function. (ltest): New macro, specifically geared for testing lambda expressions. When *compile-test* is true, this generates code which performs two tests: applying the arguments directly to the lambda, and evaluating the lambda to a function which is passed to call-lambda, which will then apply the arguments. We cannot use apply, because the compiler sees through that and will inline the lambda anyway. (mltest): Multi-expression version of ltest. This is a drop-in replacement for mtest in the rest of the file.
* compiler: two optimizations, motivated by optional params.Kaz Kylheku2022-01-141-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The motivating situation is this: (lambda (: (opt :)) opt) When the default value of an optional parameter is : then the net effect is that there is no optional substituion. The optional argument is signaled by the : symbol, and that same symbol then replaces the value. This is not optimized well: data: 0: : 1: t syms: code: 0: 8C000009 close t2 0 3 9 1 0 nil t2 1: 00000002 2: 00000001 3: 00000003 4: 00000002 5: 3C000008 ifq t2 d0 8 6: 00020400 7: 2C020400 movsr t2 d0 8: 10000002 end t2 9: 10000002 end t2 instruction count: 5 entry point: 4 The instruction sequence 5: 3C000008 ifq t2 d0 8 6: 00020400 7: 2C020400 movsr t2 d0 8: serves no purpose; it's like: (if (eq x y) (set x y)) With this commit it looks like: data: 0: : 1: t syms: code: 0: 8C000006 close t2 0 3 6 1 0 nil t2 1: 00000002 2: 00000001 3: 00000003 4: 00000002 5: 10000002 end t2 6: 10000002 end t2 instruction count: 3 entry point: 4 * stdlib/optimize.tl (basic-blocks peephole-block): Here, we add an optimization for the useless assignment pattern. If an "ifq tx dy label" instruction falls through to a "mov tx dy", then we remove that move instruction from the next block. But only if that next block has nothing else jumping to it! If there are other jumps there, they could be relying on that "mov tx dy", so it cannot be removed. (basic-blocks elim-next-jump): The above optimization may leave us with a useless ifq instruction, which jumps to the same destination whether the comparison is true or not. In elim-next-jmp, we took care only of jmp instructions which uselessly jump to the next block in instruction order. We fix this to also eliminate if and ifq instructions whose destination label is the next block; they are equivalent to an unconditional jump.
* cptr-int: allow full unsigned range.Kaz Kylheku2022-01-132-2/+18
| | | | | | | | | | | | | | The cptr-int function requries an address to be expressed as a signed integer, which is incovenient. E.g. -2147483648 to 2147483647 in a 32 bit address space. Let's fix it to accept an extended range. * lib.c (cptr_int): Convert the argument value to a ucnum if it is positive according to plusp, otherwise to cnum. Then either one to the mem_t * pointer. Thus we can accept either signed or unsigned values. * txr.1: Document the extended range of cptr-int.
* carray-replace: two overrun bugs.Kaz Kylheku2022-01-132-2/+18
| | | | | | | | | | | | | * ffi.c (carray_replace): In the case when we replace a larger range by a smaller one, when the upper part of the aray shifts down, we are not correctly clearing to zeros the vacated part of the array. The variable whole is a displacement from the base of the array, not from ptr. Secondly, the copying loop must go rom fr to below sn, not below vn; sn is derived from vn but truncated not to go past the array. * tests/017/carray.tl: New file. Several cases here fail before this fix.
* carray: allow t and floating 0 in sub and replace.Paul A. Patience2022-01-121-10/+15
| | | | | * ffi.c (carray_sub, carray_replace): Allow t as from or to value, and also implement the zero's end-of-range floating behavior.
* typecase: return nil from formless clauses.Paul A. Patience2022-01-121-1/+1
| | | | | * stdlib/type.tl (typecase): Return nil (as documented) instead of t when a matching clause has no clause forms.
* doc: clarify example in copy-struct description.Paul A. Patience2022-01-121-1/+6
| | | | | | * txr.1: The sample copy method given in the description of copy-struct looks like it could be a special structure function that would be taken into account by the copy function. It is not.
* New macros: each-true, some-true, each-false, some-false.Kaz Kylheku2022-01-126-52/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisplib.c (arith_each_set_entries): Trigger autoload on new symbols. * stdilb/arith-each.tl (sys:arith-each): Generalize macro to handle short-circuiting logical operations. The op-iv parameter, which is a cons, is spread into two op and iv parameter. One new argument appears, short-circ. This specifies a code for short-circuiting behavior: t means iteration continues while the result is true; nil means it continues while it is nil, and + means iteration continues while the accumulator is nonzero. A new convention is in effect: the operator has to be specified as a list in order to request accumulating behavior, e.g (+) or (*). Otherwise the operator specifies a predicate that is applied to the forms, without taking into account the prior value. (sum-each, sum-each*, mul-each, mul-each*): Spread the op-iv arguments. Wrap the op argument in a list to request accumulation. In the case of mul-each and mul-each*, specify + for the short-circ argument, which means that iteration stops when the accumulator becomes zerop. sum-each and sum-each* specify : for the short-circ argument which is unrecognized, and so ther is no short-circuiting behavior. (each-true, some-true, each-false, some-false): New macros. * tests/016/arith.tl: New tests. * txr.1: Documented new macros and added note about possible short-circuiting in mul-each and mul-each*. * stdlib/doc-syms.tl: Updated.
* sum-each, mul-each: handle no vars case.Kaz Kylheku2022-01-114-10/+111
| | | | | | | | | | | | | | | * stdlib/arith-each.tl (sys:arith-each): If there are no vars, then just reduce to the identity element value. This is alreading happening fine for the each-prod family of operators. * tests/016/arith.tl: Test cases covering the no vars and empty iteration identity element cases for sum-each and mul-each, as well as the *-prod variants. * txr.1: Document empty iteration and empty vars behavior for arithmetic each operators as well as the each-prod family.
* Copyright year bump 2022.Kaz Kylheku2022-01-11134-136/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lex.yy.c.shipped, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, psquare.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, socket.c, socket.h, stdlib/arith-each.tl, stdlib/asm.tl, stdlib/awk.tl, stdlib/build.tl, stdlib/cadr.tl, stdlib/compiler.tl, stdlib/constfun.tl, stdlib/conv.tl, stdlib/copy-file.tl, stdlib/debugger.tl, stdlib/defset.tl, stdlib/doloop.tl, stdlib/each-prod.tl, stdlib/error.tl, stdlib/except.tl, stdlib/ffi.tl, stdlib/getopts.tl, stdlib/getput.tl, stdlib/hash.tl, stdlib/ifa.tl, stdlib/keyparams.tl, stdlib/match.tl, stdlib/op.tl, stdlib/optimize.tl, stdlib/package.tl, stdlib/param.tl, stdlib/path-test.tl, stdlib/pic.tl, stdlib/place.tl, stdlib/pmac.tl, stdlib/quips.tl, stdlib/save-exe.tl, stdlib/socket.tl, stdlib/stream-wrap.tl, stdlib/struct.tl, stdlib/tagbody.tl, stdlib/termios.tl, stdlib/trace.tl, stdlib/txr-case.tl, stdlib/type.tl, stdlib/vm-param.tl, stdlib/with-resources.tl, stdlib/with-stream.tl, stdlib/yield.tl, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, time.c, time.h, tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr, y.tab.c.shipped: Copyright year bumped to 2022.
* unwind: fix malformed #define.Kaz Kylheku2022-01-111-1/+1
| | | | | * unwind.h (uw_last_form_expanded): Add missing # token. Because of this, code won't compile without CONFIG_DEBUG_SUPPORT.
* parser: bug: carriage returns in JSON causing errors.Kaz Kylheku2022-01-102-356/+347
| | | | | | | | | | | * parser.l (NJPUNC): This inverted class lexical category must exclude the carriage return character \r, otherwise it matches it. The JSON keywords true, false and null are recognized as sequences of NJPUNC. If we don't exclude \r from NJPUNC, it looks like a symbol constituent, comprising an unrecognized JSON keyword. * lex.yy.c.shipped: Updated.
* parser: remove unreachable scanner rule.Kaz Kylheku2022-01-101-5/+0
| | | | | | | * parser.l: Remove rule matching double quote in JSON state. This follows a rule which matches . so is unreachable. The rule is necessary, but an identical copy of it already appears earlier.
* json: add tests with multi-line literals.Kaz Kylheku2022-01-101-0/+10
| | | | | | * tests/010/json.tl: New tests. These work. Odd; I'm seeing an issue whereby typing multi-line #J expressions into the listener does not work.
* Casts have crept into the code not wrapped by macros.Kaz Kylheku2022-01-0612-47/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is against TXR coding conventions to use the C cast notation. The usage creeps into the code. To find instances of this, we must compile using GNU g++, and add -Wold-style-cast via EXTRA_FLAGS. * eval.c (prof_call): Use macro instead of cast. * ffi.c (pad_retval, ffi_varray_alloc, make_ffi_type_union, carray_dup, carray_replace, uint_carray, int_carray, put_carray, fill_carray): Likewise. * itypes.c (c_i64, c_u64): Likewise. * lib.c (cyr, chk_xalloc, spilt_str_keep, vector, cobj_register): Likewise. * linenoise.c (record_undo): Likewise. Also, drop one superfluous cast: wstrdup_fn returns wchar_t *. (flash, edit_insert, edit_insert_str): Use macro instead of cast. * mpi/mpi.c (s_mp_ispow2d): Likewise. * parser.c (lino_getch): Likewise. * rand.c (make_random_state, random_buf): Likewise. * stream.c (generic_get_line, do_parse_mode): Likewise. * struct.c (get_duplicate_supers, call_initfun_chain, call_postinitfun_chain): Likewise. * sysif.c (c_time): Likewise. * tree.c (tr_insert): Likewise.
* num_ex: eliminate ill-considered cast.Kaz Kylheku2022-01-061-1/+1
| | | | | | | * lib.h (num_ex): Remove the cast to ucnum, which will cause this macro to misbehave for negative arguments. For instance, -1 > (ucnum) INT_PTR_MAX will compare as true! The -1 gets converted to the unsigned type and becomes UINT_PTR_MAX.
* quips: new one about C++ protected members.Kaz Kylheku2022-01-051-0/+1
| | | | * stdlib/quips.tl (%quips%): New entry.
* build: support CPPFLAGS.Kaz Kylheku2022-01-051-2/+2
| | | | | | | | | | | | | * Makefile (TXR_CFLAGS): Pull in $(CPPFLAGS) also. It seems some distros like Gentoo are relying on programs to interpolate CPPFLAGS, and use this variable for passing preprocessor-level options like -Dfoo=bar. This is an incredibly bad, unnecessary idea, but let's play along. Now because we are merging this into TXR_CFLAGS, it means that these preprocessor-only flags are used for linking, when nothing is being preprocessed, which makes no sense. However, GNU Make's built-in recipe for linking C code seems to do the same thing.
* configure: more nuanced time_t treatment.Kaz Kylheku2022-01-041-1/+47
| | | | | | | | | | | | | | | | | | | | I'm taking the position that on systems where time_t is 32 bits by default, but can be switched to 64 with some option that we positively detect, configure will refuse to run unless the user explicitly chooses what to do using either --big-time or --no-big-time. We neither want to ignore this situation (because Y2038 is a problem, and we don't want to contribute to it) nor do we want to force 64 bit time_t, which could be problematic in distributions where other applications and components are not being configured that way for whatever reason (like it being a system with a projected life span that is not expected to go past Y2038). * configure (big_time, big_time_given): New variables. (help): Document big-time. New logic in the test to validate the detected situation versus whether or not the big-time variable has been specified, and which way. Error out in several cases.
* lazy-str-get-trailing-list: spurious empty string issue.Kaz Kylheku2022-01-044-28/+242
| | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (lazy_str_get_trailing_list): Remove the spurious empty string caused by splitting on the terminator. Whenever the materialized prefix is not-empty, and there is a non-empty terminator, the prefix necessarily ends in the termintator. If we split on the terminator, the list of pieces ends in in an empty string, which is undesirable. This has to be subject to compat, unfortunately; it's a very visible behavior that affects the continuation of line-based matching after the @(freeform) directive. * tests/006/freeform-5.txr: With this fix, we no longer have to match the spurious blank line coming from @(freeform). * tests/015/lazy-str.tl: New file. * txr.1: Updated documentation with compat notes. There was some outright incorrect text describing lazy-str-get-trailing-list. Also, the lazy-str-force-upto and lazy-str-force were under-documented. The return value of the former was not completely described: that it returns t in the other case when not returning nil. It wasn't mentioned that the functions observe the limit-count. Moreover, the exact algorithm for forcing is now documented.
* freeform: bug: account for consumed prefix.Kaz Kylheku2022-01-043-1/+13
| | | | | | | | | | | | | | | | | | | | This was reported by user vapnik spaknik. The @(freeform), when reconstituting the unmatched trailing portion of the virtual line back into a list of lines, uses the abstract match position, neglecting to account for the fact that a prefix of the line may have been physically consumed to save memory. * match.c (v_freeform): When calling lazy_str_get_trailing_list, indicate the correct amount of prefix material, by subtracting, from the matching length, the base variable, which indicates how much of the prefix had been consumed. This consumption takes place above 4000 bytes, which is why the freeform test cases are not catching this. * tests/006/freeform-5.txr: New file. * tests/006/freeform-5.expected: New file.
* sysif: rlim constants: use signed/unsigned-agnostic macro.Kaz Kylheku2022-01-022-3/+5
| | | | | | | | | | | | * lib.h (num_ex): New macro. Uses unum if the argument is out of range for the signed type. Thus we can use this with unsigned constants that would wrap negative if passed to num. This is useful if some type in a system header file might be signed or unsigned. * sysif.c (sysif_init): Use num_ex for the RLIM_* constants. I'm observing values of -1 which should really be large, positive values in the rlim_t type, that being unsigned.
* ffi: allow enumed bitfield.Kaz Kylheku2022-01-023-22/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ffi.c (ffi_type_copy): Function moved earlier in file without change. (ffi_type_copy_new_ops): New stati function. (make_ffi_type_enum): Do not create a new type object using cobj; copy the existing base_type, and then tweak its properties, just like what is done with bool. Thus if base_type is a bitfield, the enum will be a bitfield. Add check against doign this to anything but an FFI_KIND_NUM, with the awareness that this does include floating-point types. Since tft is now a copy, we no longer have to copy a number of things from btft. We do set he kind field to FFI_KIND_ENUM. (ffi_type_compile): In the two bitfield cases, we now calculate the mask field for the bitfield type (leaving the shift at zero). The struct or union type into which the bitfield is embedded will still re-calculate this. The reason is that when an (enumed (bit ...) ...) type is defined, it constructs hash tables for converting between the symbolic and numeric values. It calls the put function of the underlying type to test whether each enumeration value can be converted (i.e. is in range). So the bitfield type must have a valid mask at that time, or else it will reject every nonzero value as being out of range for the bitfield. I'm also replacing the max_int variable with bits_int. Since bitfields are restricted to no wider than int, why pretend? * tests/017/ffi-misc.tl: New test cases. * txr.1: Documented.
* rlimit: var init problem due to large file offset.Kaz Kylheku2022-01-022-0/+17
| | | | | | | | | | | | | | | | Now that we fixed the regression in detecting whether to use -D_FILE_OFFSET_BITS=64, this has unmasked an issue in newer code. In sysif.c, the RLIM_INFINITY, and related constants, are being passed to num_fast: but they are 64 bit unsigned constants under the large file offset, which don't fit into a cnum or unum on a 32 bit system. * configure: When we detect large file offset, we deposit the tell-tale configuration constant CONFIG_LARGE_FILE_OFFSET into config.h. * sysif.c (sysif_init): Under CONFIG_LARGE_FILE_OFFSET, treat the RLIM_ constants using bignum_dbl_uipt.
* configure: support 64 bit time_t on glibc.Kaz Kylheku2021-12-301-11/+36
| | | | | | | | | | | | | | | | | There is a new feature in glibc: -D_TIME_BITS=64 makes time_t 64 bits wide, as part of a solution to Y2038. Let's detect this together with _FILE_OFFSET_BITS in the same test. I've not tested this because I need a system with a bleeding edge glibc that supports _TIME_BITS. * configure (time_bits_define): New variable. Test which searches some known command line options for 64 bit off_t expanded to also check for 64 bit time_t. This complicates the loop only slightly; it is much better than copy and pasting the code
* configure: broken file offset bits detection.Kaz Kylheku2021-12-301-1/+1
| | | | | | | | | | | | | We are not detecting the need to do -D_FILE_OFFSET_BITS=64 correct, resulting in no large file support on 32 bit platforms based on Glibc. This is a regression since TXR 244. * configure: We must pass EXTRA_FLAGS=-D$try to actually try the options we are looping over. This argument was accidentally removed in commit 3d80caccafc27ac812bbf8226eba6d8e529c63ff on October 9, 2020, when the conftest_symns command was changed to conftest_o.
* configure: file offset test: don't change config.hKaz Kylheku2021-12-301-2/+0
| | | | | | | | * configure: The file offset test has no reason to be writing anything into config.h. The SIZEOF_OFF_T symbol isn't used anywhere, and SIZEOF_BYTE already exists in the header. Because this command is in a loop, it ends up writing multiple definitions of SIZEOF_BYTE, and SIZEOF_OFF_T into config.h.
* doc: "sme" typo under :delegate.Kaz Kylheku2021-12-301-1/+1
| | | | | | * txr.1: Fix sme -> same. This creeps in because "sme" is whitelisted due to the @(sme ...) pattern notation (start/middle/end).
* configure: detect warning opts missing in older compilers.Kaz Kylheku2021-12-301-2/+16
| | | | | | | | | | | | * configure (diag_flags): Remove -Wvla and -Werror=declaration-after-statement. (diag_flags_given): New variable. New test: if diag_flags_given indicates that diag_flags were not specified by the user, then we try to add additional flags, subject to them being available, which we test by compiling the hello-world program with those flags. We rely on the hello-world program being left over by the previous compiler sanity check.
* Eliminate declaration-after-statement everywhere.Kaz Kylheku2021-12-2920-151/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The use of -ansi doesn't by itself diagnose instances of some constructs we don't want in the project, like mixed declarations and statements. * configure (diag_flags): Add -Werror=declaration-after-statement. This is C only, so filter it out for C++. Also add -Werror=vla. * HACKING: Update inaccurate statements about what dialect we are using. TXR isn't pure C90: some GCC extensions are used. We even use long long if the configure script detects it as working, and some C99 library features. * buf.c (replace_buf, buf_list): Fix by reordering. * eval.c (op_dohash, op_load_time_lit): Fix by reordering. * ffi.c (ffi_simple_release): Fix by reordering. (align_sw_get): Fix empty macro to expand to dummy declaration so a semicolon after it isn't interpreted as a statement. On platforms with alignment, remove a semicolon from the macro so that it requires one. (ffi_i8_put, ffi_u8_put): Fix by reordering. * gc.c (gc_init): Fix with extra braces. * hash.c (hash_init): Fix by reordering. * lib.c (list_collect_revappend, sub_iter, replace_str, replace_vec, mapcar_listout, mappend, mapdo, window_map_list, subst): Fix by reordering. (gensym, find, rfind, pos, rpos, in, search_common): Fix by renaming optional argument and using declaration instead of assignment. * linenoise/linenoise.c (edit_in_editor): Fix by reordering. * parser.c (is_balanced_line): Fix by reordering. * regex.c (nfa_count_one, print_rec): Fix by reordering. * signal.c (sig_mask): Fix by reordering. * stream.c (get_string): Fix by renaming optional argument and using declaration instead of assignment. * struct.c (lookup_static_slot_desc): Fix by turning mutated variable into block local. (umethod_args_fun): Fix by reordering. (get_special_slot): Fix by new scope via braces. * sysif.c (usleep_wrap): Fix by new scope via braces. (setrlimit_wrap): Fix by new scope via braces. * time.c (time_string_meth, time_parse_meth): Fix by reordering. * tree.c (tr_do_delete_spec): Fix by new scope via braces. * unwind.h (uw_block_beg): New macro which doesn't define RESULTVAR but expects it to refers to an existing one. (uw_block_begin): Replace do while (0) with enum trick so that we have a declaration that requires a semicolon, rather than a statement, allowing declarations to follow. (uw_match_env_begin): Now opens a scope and features the same enum trick as in uw_block_begin. This fixes a declaration-follows-statement issue in the v_output function in match.c. (uw_match_env_end): Closes scope opened by uw_match_env_begin. * unwind.c (revive_cont): Fix by introducing variable, and using new uw_block_beg macro. * vm.c (vm_execute_closure): Fix using combination of local variable and reordering.
* Makefile: way to clean only C sources.Kaz Kylheku2021-12-291-1/+3
| | | | | | | * Makefile (clean-c): New target, complementary to clean-tlo, to only clean the C object files, executables and related materials, without touching the .tlo files. (clean): Depend on clean-c; body entirely moved into clean-c.
* help: fix preprocessor directive in macro call.Kaz Kylheku2021-12-291-3/+10
| | | | | | | * txr.c (IF_HAVE_FORK_STUFF): New macro, conditionally defined. (help): Remove #if in the middle of a lit() macro call in favor of IF_HAVE_FORK_STUFF.
* doc: spurious reference to car in search tree section.Kaz Kylheku2021-12-281-1/+0
| | | | | * txr.1: Remove spurious car place syntax from syntax section of key, left and right functions.