summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* time: respect gmtoff in calculating numeric time.Kaz Kylheku2023-02-132-3/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have the following problem. On some platforms, the broken-down C time structure "struct tm" has a GMT offset field which gives the time zone of the specified time. In the Lisp structure, we call the corresponding slot gmtoff. This value should be taken into account when converting the broken-down time to a numeric time value. The underlying platform functions like mktime don't do this; they not only ignore the gmtoff, but in some cases clobber the field. The GNU C library version of the POSIX strptime function supports "%z" and "%Z" specifiers which populate the GMT offset. But then it gets wrongly ignored. Old/wrong behavior: 1> (time-parse-utc "%H:%M:%z" "00:00:+0900") 0 New behavior (on platforms with the GMT offset): 1> (time-parse-utc "%H:%M:%z" "00:00:+0900") 32400 * time.c (time_meth): If the Lisp time structure we are given specifies a non-nil gmtoff, then add its value to the returned result. (time_parse_local, time_parse_utc): If struct tm has a GMT offset, then we add its value to the time_t returned by mktime, timegm or timegm_hack. * txr.1: Updated.
* quips: new one about floating-point.Kaz Kylheku2023-02-081-0/+1
| | | | * stdlib/quips.tl (%quips%): New entry.
* bugfix: gc issue in parser interface.Kaz Kylheku2023-01-221-0/+2
| | | | | | | | | | | | | | * parser.c (lisp_parse_impl): Add a call to gc_hint, to protect the parser object from garbage collection. We allocate this object, and then use a raw pointer to the parser, which leaves it exposed. This resulted in a crash of the tests/010/json.tl test case (which runs with the --gc-debug mode). The crash doesn't occur in a regular build; it reproduced in build configured with --no-gen-gc. Possibly, why it doesn't repro under generational GC is that the hash table which associates streams and parsers may be moving the objects into the mature generation.
* fix --no-gen-gc configuration.Kaz Kylheku2023-01-203-4/+6
| | | | | | | | | | | | | | | | | | | This fixes only the build. I'm getting a crash in one test case, namely tests/010/json.tl. * lib.h (mut): Remove stray semicolon from definition. This semicolon compensates for the lack of a semicolon in txr.c, which becomes a syntax errror under no-gen-gc, when the other definition of mut is active. (mkloc, setcheck): Let's add casts of the object argument to void. This gets rid of a number of unused parameter errors in various functions that take an object parameter that is only used in the case of generational GC. * txr.c (txr_main): Add missing semicolon after mut call. * gc.c (gc_wrap): In the no CONFIG_GEN_GC case, cast argument full to void, since it is unused.
* fix --no-debug-support configuration.Kaz Kylheku2023-01-204-1/+10
| | | | | | | | | | | | | | | | * debug.h (debug_init): Define as ((void) 0) macro in the no debug support case. * unwind.h (uw_last_form_expanded): No-debug-support version must yield a value, not void. * unwind.c (ffcal_frame_type, eval_frame_type, expand_frame_type): Define only if CONFIG_DEBUG_SUPPORT is enabled, to suppress unused warnings. * eval.c (do_eval): Conditionally define debug-related code. The uw_push_eval function doesn't exist if CONFIG_DEBUG_SUPPORT isn't enabled.
* doc: * function not mentioned in heading.Kaz Kylheku2023-01-022-75/+75
| | | | | | | | | | | | * txr.1: The functions -, + and * are documented together, but the section heading only mentions + and -. This was introduced when these functions were documented for the first time in March 2012, in commit 6363875356bc050ef81d40553e573fc47aca2e28, and then went unnoticed for almost eleven years in spite of the heading undergoing relocation and reformatting. * stdlib/doc-syms.tl: Updated.
* doc: awk: mention res in clause descriptions.Kaz Kylheku2023-01-021-6/+14
| | | | | | * txr.1: In the description of the condition-action clause processing, mention the new res variable. Some additional improvements in neighboring text.
* Copyright year bump 2023.Kaz Kylheku2023-01-01136-138/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, autoload.c, autoload.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, gzio.c, gzio.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, 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 2023.
* doc: fix date for 284 release.Kaz Kylheku2022-12-301-1/+1
| | | | * txr.1: Bump date to 2022-12-30.
* Version 284.txr-284Kaz Kylheku2022-12-307-1096/+1153
| | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* android, cygwin: do not try to test crypt.Kaz Kylheku2022-12-301-0/+3
| | | | | * tests/018/crypt.tl: Exit with successful termination status on Android or Cygwin.
* crypt: fix for platforms that lack crypt_r.Kaz Kylheku2022-12-302-1/+5
| | | | | | | | | | | | * sysif.c (crypt_wrap): Don't call free(cd) on platforms where we don't have crypt_r and have not defined the cd variable. * test/018/crypt.tl: Move the (crypt "a" "b") test case to be GNU/Linux-only. On Solaris, it yields a valid-looking hash instead of failing. That hash will not validate the password though; i.e. (crypt "a" (crypt "a" "b")) is not equal to (crypt "a" "b").
* doc: spurious plural in JSON section.Kaz Kylheku2022-12-301-1/+1
| | | | * txr.1: "in supports of" -> "in support of".
* doc: grammar under awk.Kaz Kylheku2022-12-301-1/+1
| | | | | * txr.1: Description of rng column in table is missing the verb "shows".
* doc: trim-left: don't document string case as fixed regexKaz Kylheku2022-12-301-2/+2
| | | | | * txr.1: Though it's not wrong, let's describe the string case as a fixed match without mentioning regex.
* doc: clarify @(repeat) is @(collect :vars nil)Kaz Kylheku2022-12-301-1/+11
| | | | | | * txr.1: When @(repeat) is first mentioned near the top of the @(collect) documentation, say right away what exactly it means.
* awk: new feature, res variable.Kaz Kylheku2022-12-305-2/+58
| | | | | | | | | | | | | | | | The res variable captures the specific value of the condition expression, making it available to the action. * autoload.c (awk_set_entries): Intern the res symbol * stdlib/awk.tl (awk): Instead of generating the condition-action into a simple when, we use whenlet to also bind the res variable. * tests/015/awk-res.tl: New file. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* doc: consistency of condition-pattern term for awk.Kaz Kylheku2022-12-301-2/+2
| | | | | * txr.1: Fix instances of condition-pattern and condition-clauses to condition-action.
* doc: fix nonexistent macro name.Kaz Kylheku2022-12-302-2/+2
| | | | | | | * txr.1: *define-struct-prelude* should of course be define-struct-prelude. * stdlib/doc-syms.tl: Updated.
* doc: improve span-str, compl-span-str, break-strKaz Kylheku2022-12-101-0/+32
| | | | | * txr.1: document return value better for span-str and compl-span-str. Add examples for all three functions.
* doc: abc_function typo.Kaz Kylheku2022-12-101-1/+1
| | | | | * txr.1: In FFI-related example, a call to abc_function should just refer to function.
* quips: new one.Kaz Kylheku2022-12-101-0/+1
| | | | * stdlib/quips.tl (%quips%): New one about personality.
* compiler: runaway recursion in constant folding call.Kaz Kylheku2022-11-261-1/+4
| | | | | | | | | | | | | | | | | When an invalid call expression is constant folded, such as (call 'abs 1 2), runaway recursion occurs. This is because due to the wrong number of arguments being passed to abs, the safe-const-reduce function returns the expression unmodified. The comp-apply-call method then passes it to compile, wrongly assuming a reduction had taken place, and so everything repeats. * stdlib/compiler.tl (comp-apply-call): Detect when safe-const-reduce has hit a fixed point by returning the input form. In that case, we don't call the compiler top-level entry point, but the comp-fun-form method directly; the wrong function call will be compiled without constant folding and throw an error at run-time.
* compiler: bug: some functions mustn't be constant-foldedKaz Kylheku2022-11-251-5/+5
| | | | | | | | * stdlib/constfun.tl (%const-foldable-syms%): Removing the following functions, which cannot be constant folded because maybe are relied upon to produce fresh objects: cons, sub-list, conses, ldiff, uniq, tostring, tostringp, join, join-with.
* streams: fixes in few type error diagnostics.Kaz Kylheku2022-11-211-5/+7
| | | | | | | | | | | * stream.c (make_string_byte_input_stream, get_string_from_stream): Use self in diagnostic, and print bad object using ~s rather than ~a. (get_list_from_stream): Likewise, and add missing nao as well. (catenated_stream_push): Add self string, use in diagnostics, print bad object using ~s.
* expt: zero exponent yields 1.0.Kaz Kylheku2022-11-202-0/+9
| | | | | | | | * arith.c (expt): NUM-FLNUM, FLNUM-NUM and FLNUM-FLNUM cases ensure that if the expontent is zero, the return value is 1.0. Implementations of pow do this, but ISO C doesn't require it. * txr.1: Now documented.
* hash: floating: handle negative zero.Kaz Kylheku2022-11-201-3/+5
| | | | | | * hash.c (hash_double): If the input is equal to 0.0, return 0, so that both negative and positive zero have the same hash value.
* crypt: reduce ridiculous stack usage.Kaz Kylheku2022-11-171-4/+9
| | | | | | * sysif.c (crypt_wrap): Dynamically allocate struct crypt_data instead, because it's over 128K wide, resulting in a huge stack frame size.
* structs: use type-error rather than error.Kaz Kylheku2022-11-111-5/+5
| | | | | | | * struct.c (struct_handle, stype_handle_impl, struct_handle_for_slot, umethod_fun, umethod_args_fun): Throw type-error rather than error for the situation that an argument isn't a struct.
* read-once: support globals properly.Kaz Kylheku2022-11-103-15/+42
| | | | | | | | | | | | | | | | | | | | | | | | When a global variable v is wrapped with (read-once v), multiple accesses to the place still generate multiple accesses of the global through getv or getlx instructions. The reason is that the alet and slet macros optimize away a temporary bound to the value of a variable regardless of whether the variable is lexical. Let's fix that. * stdlib/place.tl (slet, alet): Replace the bindable test with lexical-var-p, in the given environment. A binding to a variable is only alias-like if the variable is lexical, otherwise we need a real temporary. * tests/012/struct.tl (get-current-menv): New macro. (menv): New global variable. Fix a number of tests which use expand, whose expansion has changed because the expressions refer to free variables. We introduce an environment parameter which binds all the variables, so that the optimized expansion is produced, as before. * txr.1: Updated documentation. slet gets examples.
* ftw: default flags to ftw-physKaz Kylheku2022-11-102-4/+24
| | | | | | | | | | | | | | | More often than not, you want the FTW_PHYS flag when calling the nftw function. Let's make that the default in TXR's wrapper. * ftw.c (ftw_wrap): Default to FTW_PHYS when flags argument not given, rather than zero, subject to compatibility option. (ftw_init): Don't check for FTW_PHYS with ifdef, since we relied on it being present. And anyway, any nftw implementation must have that. * txr.1: Documented.
* New feature: struct preludes.Kaz Kylheku2022-11-036-4/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | A struct prelude definition associates one or more future defstruct (by struct name) with clauses which are implicitly inserted into the defstruct. It is purely a macro-time construct, customizing the expansion behavior of defstruct. * stdlib/struct.tl (*struct-prelude, *struct-prelude-alists*): New special variables holding hash tables. (defstruct): Before processing slot-specs, augment it with the contents of the prelude definitions associated with this struct name. (define-struct-prelude): New macro. * autoload.c (struct_set_entries): define-struct-prelude is interned and triggers autoload of struct module. * tests/012/oop-prelude.tl: New file. * tests/012/oop-prelude.expected: Likewise. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* crypt: remove dubious validator.Kaz Kylheku2022-10-313-71/+37
| | | | | | | | | | | | | | | | | | | | | | | | The validate_salt function was introduced in commit c3a0ceb2cea1a9d43f2baf5a2e63d0d712c8df19, February 2020. I cannot reproduce the internal crash in crypt which it alleges, and I neglected to mention the bad inputs in the commit or add tests. I'm not able to reproduce the alleged behavior in spite of trying all sorts of bad inputs; and looking at the crypt source in glibc, I don't see any obvious problem. And so, on this Halowe'en, we exorcise the ghost that has been haunting the crypt. * sysif.c (salt_char_p, validate_salt): Static functions removed. (crypt_wrap): Don't call validate_salt, and so cwsalt need not be tested for null. * tests/018/crypt.tl: New file. * txr.1: Mention that crypt_r is used if available, which avoids static storage.
* listener: drop security checks on windows.Kaz Kylheku2022-10-271-1/+14
| | | | | | | | | | | | | | These checks go off on Windows and are likely not easily fixable. They have to do with how Cygwin maps permissions. Our security checks depend on a detailed, bona fide Unix implementation. * parser.c (report_file_perm_problem, report_path_perm_problem): Empty bodies when compiled for Cygwin. (repl): Initialize the ppriv_s and psafe_s variables to the tf symbol, the function which takes any number of arguments, ignoring them, and returning t.
* command line: set self-path for --compile.Kaz Kylheku2022-10-272-3/+33
| | | | | | | | | | | | | | | I noticed that when compiling a TXR Lisp program which refers to self-path using the --compile option, the compiler complained about self-path being unbound. * txr.c (self_path_s): New global variable. (do_compile_opt): Prior to running compile-update-file, bind self-path to the source path. (txr_main): Don't define local self_path_s, but initialize the global one. Replace redundant re-intering of self-path with a reference to self_path_s. * txr.1: self-path documentation updated.
* txrtags: maintain due to new defstruct syntax.Kaz Kylheku2022-10-271-2/+3
| | | | | | * txrtags.tl (process-form): Handle :postfini in the same way as :fini. In fallback case, reject clauses headed by a keyword symbol.
* compiler: optimizations in catch.Kaz Kylheku2022-10-271-46/+63
| | | | | | | | | | | | | | | * stdlib/compiler.tl (comp-catch): Under an optimization level of at least 1, if no symbols are being caught, or if the try expression is a safe constant expression, then just compile the try expression. Furthermore, if there is only one exception symbol being caught, and a catch clause is for a subtype of that symbol, we eliminate the run-time exception-subtype-p test. This will always be true if the catch macros are being used, because the list of symbols is derived from the clauses. Lastly, if there is only one exception symbol being caught, any clause which doesn't match that symbol is now eliminated as dead code. That shouldn't happen unless the sys:catch operator is used directly.
* lib: or2: define in GCC-specific way.Kaz Kylheku2022-10-261-1/+5
| | | | | | | | | * lib.h (or2): Define simply using the ?: operator from GNU C, eliminating the explicit temporary variable. (uses_or2): For GNU C, we make this a dummy, harmless declaration. If memory serves me, one of the few good ways to do that it without eliciting unused warnings is to declare an enum.
* cat-str/join/join-with: allow nested sequencesKaz Kylheku2022-10-253-96/+111
| | | | | | | | | | | | | | | | | | | | | | | The measure/allocate/catenate functions which underlie the cat-str implementation are streamlined, simplifying the code. At the same time, they handle nested sequences of string/character items. * lib.c (struct cat_str): New member, seen_one. This flips from 0 to 1 after the first item has been seen in the cat_str_measure pass or cat_str_append pass. Each item other than the first is preceded by a separator. (cat_str_measure, cat_str_append): The more_p argument is dropped. We account for the separator with the help of the new seen_one flag, which allows us to easily recurse over items that are sequences. (cat_str_alloc): Reset the seen_one flag in preparation for the cat_str_append pass. (cat_str, vscat, scat2, scat3, join_with): Simplified. * tests/015/split.tl: New tests. * txr.1: Redocumented.
* defstruct: new :inherit clause.Kaz Kylheku2022-10-173-5/+53
| | | | | | | | | | | | | | | The :inherit clause allows custom struct clauses to inject inherited bases. * stdlib/struct.tl (defstruct): Recognize :inherit clause, adding symbol arguments to extra list of supers that get appended to the list coming from defstruct's seconda rgument. (define-struct-clause): Disallow :inherit clause name. * tests/012/oop-dsc.tl: New tests. * txr.1: Documented.
* doc: opip, flow: note about no-argument case.Kaz Kylheku2022-10-171-0/+20
| | | | | | | * txr.1: It's a developer surprise that (flow x) returns nil rather than x; which is due to the documented behavior of chain, when it has no arguments. Let's add cautionary notes.
* Version 283.txr-283Kaz Kylheku2022-10-167-799/+885
| | | | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. Also mention that separator commas in integer tokens are new in 283 and have a different interpretation in older versions. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* args: don't use C99 flexible array member.Kaz Kylheku2022-10-151-6/+2
| | | | | | | | | | | | | | | The reason is that args_decl_list places struct args inside a larger struct, where it is followed by another member. A struct with a flexible array being other than the last member of another struct is a GNU extension, which generates warnings on newer GCC versions. * args.h (struct args): Define arg as array of [1] rather than [FLEX_ARRAY]. (ARGS_ABS_MIN): Unconditionally define as 1. (args_decl_list): Subtract 1 from N because we get one element from struct args. This macro should have subtracted the FLEX_ARRAY value.
* args: don't use alloca for const size cases.Kaz Kylheku2022-10-1511-38/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * args.h (args_decl_list): This macro now handles only constant values of N. It declares an anonyous container struct type which juxtaposes the struc args header with exactly N values. This is simply defined as a local variable without alloca. (args_decl_constsize): Like args_decl, but requiring a constant N; implemented via args_decl_list. (args_decl_list_dyn): New name for the old args_decl_list which calls alloca. No places in the code depend on this at all, except the definition of args_decl. (args_decl): Retargeted to args_decl_list_dyn. There is some inconsistency in the macro naming in that args_decl_constsize depends on args_decl_list, and args_decl depends on arg_decl_list_dyn. This was done to minimize diffs. Most direct uses of args_decl_list have a constant size, but a large number of args_decl uses do not have a constant size. * eval.c (op_catch): Use args_decl_constsize. * ffi.c (ffi_struct_in, ffi_struct_get, union_out): Likewise. * ftw.c (ftw_callback): Likewise. * lib.c (funcall, funcall1, funcall2, funcall3, funcall4, uniq, relate): Likewise. * socket.c (sockaddr_in_unpack, sockaddr_in6_unpack, sockaddr_un_unpack): Likewise. * stream.c (formatv): Likewise. * struct.c (struct_from_plist, struct_from_args, make_struct_lit): Likewise. * sysif.c (termios_unpack): Likewise. * time.c (broken_time_struct): Likewise.
* funcall: consolidate VM fun handling.Kaz Kylheku2022-10-141-34/+80
| | | | | | | * lib.c (funcall, funcall1, funcall2, funcall3, funcall4): Handle FVM case separately, regardless of the f.variadic flag. If the VM function is variadic, the call can still use the special cases.
* funcall: handle optargs in funcall helpers.Kaz Kylheku2022-10-141-8/+85
| | | | | | * lib.c (funcall, funcall1, funcall2, funcall3, funcall4): Handle some situations when the function is a built-in with optional args.
* funcall: don't route to generic_fun on optargs.Kaz Kylheku2022-10-141-5/+15
| | | | | | | | | | | | | | * lib.c (funcall, funcall1, funcall2, funcall3, funcall4): Do not go through the generic_funcall slow path just because the target function has optional arguments. It's possible that the call is supplying all of the required arguments. Let's try it like that and then if it doesn't work and there are optionals, check again and go the generic_funcall route. This might not be an overall improvement by itself, if we end up going to generic_funcall in more cases than not. However, this change paves the way for more changes: handling some cases of optargs in these helpers.
* New function: macroexpand-struct-clause.Kaz Kylheku2022-10-134-1/+57
| | | | | | | | | | | * stdlib/struct.tl (macroexpand-struct-clause): New function. * autoload.c (struct_set_entries): Autoload struct module on macroexpand-struct-clause. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New function: macroexpand-match.Kaz Kylheku2022-10-134-0/+57
| | | | | | | | | | | * stdlib/match.tl (macroexpand-match): New function. * autoload.c (match_set_entries): Autoload match module on macroexpand-match. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New function: macroexpand-place.Kaz Kylheku2022-10-134-8/+87
| | | | | | | | | | | | | | | * stdlib/place.tl (sys:pl-expand): Function renamed to macroexpand-place; env parameter becomes optional. (macroexpand-1-place): New function. (place-form-p, call-update-expander, call-clobber-expander, call-delete-expander): Follow rename. * autoload.c (place_set_entries): Register symbols macroexpand-place and macroexpand-1-place for autoload. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.