summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Rename EXTRA_DEBUGGING to CONFIG_EXTRA_DEBUGGING.Kaz Kylheku2016-06-174-10/+10
| | | | | | | | * configure: Generate #define CONFIG_EXTRA_DEBUGGING 1 in config.h header, rather than EXTRA_DEBUGGING. * gc.c, gc.h, hash.c: Change references to EXTRA_DEBUGGING preprocessor symbol to CONFIG_EXTRA_DEBUGGING.
* Print valgrind backtraces for break_obj.Kaz Kylheku2016-06-171-2/+28
| | | | | | | | | | | | * gc.c (more): Under EXTRA_DEBUGGING, call breakpt() here also, when it is detected that break_obj is added to the free list for the firts time. Print a message and backtrace using VALGRIND_PRINTF_BACKTRACE. (make_obj): Likewise, for an object that is pulled out of the free list and returned. (mark_obj, sweep_one): Print backtrace with Valgrind for break_obj, in addition to calling breakpt().
* Useful assertion in make_obj.Kaz Kylheku2016-06-171-0/+1
| | | | | * gc.c (make_obj): Assert that the object we are pulling from the free list is marked FREE.
* Tidy up some vector object initializations.Kaz Kylheku2016-06-171-7/+7
| | | | | | | * lib.c (vector, copy_vec, sub_vec, cat_vec): Set the type field of the object sooner. Do not malloc between obtaining the object, and initializing it, because that could throw, leaving an uninitialized object in the heap space.
* gc bugfix: maintain free_tail properly.Kaz Kylheku2016-06-161-5/+6
| | | | | | | | | | | | | * gc.c (more): Only set the free_tail if the new memory is being added to an empty free_list. Otherwise free_tail is valid. (make_obj): If we empty the free_list, then reset the free_tail pointer, so it doesn't continue pointing into the object we are returning. (sweep): Remove defensive code which tries to reset the free_tail in the empty free_list case, but assumes that free_tail is correct in the non-empty case.
* Remove more vestiges of the mark_makefresh hack.Kaz Kylheku2016-06-161-16/+3
| | | | | | | | | | * gc.c (sweep_one): Don't check for gen == -1; no reachable object can have that at this stage, since mark flips -1 objects to gen 0. (sweep): Do not clear freshobj_idx here; completely revert the mark_markfresh code. (gc): Clear freshobj_idx here., as before the mark_makefresh hack.
* Bogus gc marking code in syslog module.Kaz Kylheku2016-06-151-2/+0
| | | | | | | | | | * syslog.c (syslog_mark): Remove incorrect stray code, which passes a pointer to a non-gc-object to the gc_mark function. This code was left behind in the change which introduced struct syslog_strm, git hash e44c113ee17c7cf15e8b1891f4d51ec03b16bc24 "Deriving streams from the same base", July 29, 2015.
* Replace most TXR eval with Lisp eval.Kaz Kylheku2016-06-143-45/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * match.c (tlist_k): New keyword symbol variable. (tleval_144): New static function. (h_skip): evaluate min and max arguments as Lisp. (h_coll): Evaluate all numeric keyword arguments as Lisp: :min, :max, :gap, :times, :maxtimes, :mintimes, :chars. (h_call): Evaluate function expression as Lisp. (do_output_line, do_output): Evaluate n and m parameters in @(modlast) and @(mod) as Lisp. (v_skip): Evaluate min and max as Lisp. (v_fuzz): Evaluate m and n as Lisp. (v_freeform): Evaluate arguments as Lisp. (v_next): Support new argument, :tlist, which is like :list, but with TXR style evaluation. From now on :list uses Lisp evaluation, unless compatibility is set to 143 or lower. Also, evaluate the :string argument as Lisp. (v_collect): Evaluate all numeric keyword arguments as Lisp: :min, :max, :gap, :times, :maxtimes, :mintimes, :lines. (v_output): Evaluate stream in :continue or :finish expression as Lisp. (v_load): Evaluate load target as Lisp. (v_close): Evaluate stream argument as Lisp. (v_call): Evaluate function expression as Lisp. (syms_init): Initialize tlist_k variable. * tests/007/except-1.txr: Use :tlist instead of :list, since argument is a TXR list expression. * tests/010/block.txr: Likewise.
* Rename Lisp eval wrappers and change arg order.Kaz Kylheku2016-06-131-41/+32
| | | | | | | | | | | * match.c (eval_with_bindings, eval_progn_with_bindings): Change static function names to the shorter tleval and tleval_progn. The first and second arguments swapped around to match the convention used by txeval. (dest_bind, h_coll, tx_subst_vars, do_txeval, extract_bindings, do_output_line, do_output_line, do_output, v_next, v_collect, v_output, v_do, v_require, v_if, h_do): Follow rename.
* defsymacro must remove special marking.Kaz Kylheku2016-06-112-1/+23
| | | | | | | | | | * eval.c (op_defsymacro): Remove sym from the special hash, unless compatibility 143 or lower is requested. * txr.1: Document effects of evaluating defsymacro if a global variable of the same name exists, and the behavior in lexical scopes where sym is bound. Added compatibility notes covering the code change.
* Implement :counter in collect/coll.Kaz Kylheku2016-06-092-4/+104
| | | | | | | | * match.c (h_coll, v_collect): Parse out :collect keyword specification, using code borrowed from do_output. Implement binding in collect loop. * txr.1: Documented.
* Restructure documentation of collect keywords.Kaz Kylheku2016-06-091-44/+73
| | | | | * txr.1: Use indented paragraphs to replace the ad-hoc introduction of keywords.
* Fix broken place delete semantics of symbol-value.Kaz Kylheku2016-06-081-1/+1
| | | | | * share/txr/stdlib/place.tl (defplace symbol-value): Don't splice body into deleter syntax; must use plain unquote.
* Rewriting documentation for binding accessors.Kaz Kylheku2016-06-081-14/+47
| | | | | * txr.1: Largely rewrote description of symbol-function, symbol-macro and symbol-value.
* Fixing semantics of makunbound.Kaz Kylheku2016-06-083-34/+124
| | | | | | | | | | | | | | | | | | * eval.c (unbound_s): New symbol variable. (lookup_var): If a dynamic binding has the special sys:unbound symbol as its value, then return nil, so the behavior is as if there is no binding. (makunbound): If the symbol exists in a dynamic environment, then replace its value with sys:unbound, making it look unbound. (eval_init): Initialize unbound_s. * lib.h (us_car, us_cdr): New inline functions. * txr.1: New dialect notes under boundp. Updated the makunbound documentation. Separated makunbound documentation from fmakunbound and mmakunbound. Added compatibility notes.
* Fix memory leak in dgram socket streams.Kaz Kylheku2016-06-081-0/+1
| | | | | * socket.c (dgram_destroy): Free the dgram_stream structure too, not just its buffers.
* Fix out-of-bounds memory access in bit.Kaz Kylheku2016-06-081-1/+1
| | | | | | | * mpi/mpi.c (mp_bit): If the digit index is beyond the available digits in the number, report MP_NO rather than accessing undefined digit material or beyond the array entirely.
* Do not leave COBJ-ified mp_int uninitialized.Kaz Kylheku2016-06-082-0/+6
| | | | | | | | | | | | | | | Here we ensure that the digits pointer of an uninitialized mp_int is nulled out. The garbage collector could conceivably encounter such an object, in which case mp_clear will then try to free a garbage pointer. This could happen if an exception is thrown out of numeric code due to low memory, interrupting its execution, leaving behind an unfilled object produced by make_ubignum. * arith.c (make_ubignum): Perform minimal initialization of the mp_int using new function. * mpi/mpi.h (mp_init_minimal): New inline function.
* Fix leaks in use of MPI and within MPI.Kaz Kylheku2016-06-082-17/+6
| | | | | | | | | | | | | | | | * arith.c (logand, logior, logxor): Use make_ubignum to create an uninitialized bignum, because mp_and, mp_or, and mp_xor expect argument c to be uninitialized, and clobber it by initializing. (comp_trunc): Use make_ubignum for b argument, because mp_trunk_comp initializes it. (lognot, logtrunc): Use make_ubignum for b, because mp_trunc initializes it. * mpi/mpi.c (mp_and, mp_or, mp_xor, mp_comp, mp_trunc_comp, mp_trunc, mp_shift, mp_bit): Do not initialize the tmp that is passed as argument b to mp_2comp, since that function initializes it.
* Fix syslog stream leak.Kaz Kylheku2016-06-071-1/+1
| | | | | | | | This one is minor because there is only one syslog stream. * syslog.c (syslog_strm_ops): Use cobj_destroy_free_op rather than cobj_destroy_stub_op.
* Fix memory leak in parser object.Kaz Kylheku2016-06-071-0/+1
| | | | | * parser.c (parser_destroy): Don't just clean up the parser_t structure, free it.
* New --free-all option for freeing memory on exit.Kaz Kylheku2016-06-0710-14/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although we are garbage-collected, being able to clean up on shutdown is nevertheless useful for uncovering leaks. Leaks can occur, for instance, due to neglect to free out-of-heap satellite data from objects that are reclaimed by gc. This feature is long overdue. * arith.c, arith.h (arith_free_all): New function. * gc.c, gc.h (gc_free_all): New function. * lib.c (init): Remove program name parameter and redundant initialization of progname globl variable. * lib.h (progname): Superfluous declaration removed. This is already declared in txr.h. (init): Declaration updated. * regex.c (char_set_destroy): Do not check the static allocation flag here; just destroy the object. Do check for a null pointer, though. (char_set_cobj_destroy): This cobj destructor now checks the static flag of the char set object and avoids freeing it. Thus our char set singletons are left alone by gc, but our global freeing function takes care of them. (wide_cs): New static variable moved out of wide_display_char_p to static scope. (regex_free_all): New function. * regex.h (regex_free_all): Declared. * txr.c (progname): const qualifier and initializer removed. (main): Ensure progname is always dynamically allocated, even in the argv[0] == 0 case. Do not pass progname to init; it doesn't take that argument any more. (free_all): New static function. (txr_main): Implement --free-all option. * txr.h (progname): Declaration updated.
* Handle sequence structs in length.Kaz Kylheku2016-06-061-0/+2
| | | | | * lib.c (length): In COBJ case, handle structures which have a car slot.
* Handle sequence structs in toseq.Kaz Kylheku2016-06-061-0/+4
| | | | | | * lib.c (toseq): Handle OBJP case, and implement behavior for struct objects that have a car method.
* Handle sequence better in index list case of replace.Kaz Kylheku2016-06-061-14/+9
| | | | | | | | | * lib.c (replace_list): Simplify treatment of items on entry using toseq. (replace_str, replace_vec): When a list or vector of indices is given, use the itseq result of passing items items through toseq function rather than original items, for consistency with range assignment.
* Handle structs in list collection operations.Kaz Kylheku2016-06-061-0/+10
| | | | | | | | | | | | | | | This eliminates the error which occurs when a sequence implemented as a struct is nconced or appended onto. The struct is converted to a list, and so is the object on the right hand side. As a result, more generic sequence code works on structs. * lib.c (list_collect_nconc, list_collect_append): Handle tail of type COBJ by converting to a list, storing that list back in the tail and then destructively tacking onto that the obj operand, also turned into a list.
* Use local var in list_collect_{nconc,append}.Kaz Kylheku2016-06-061-10/+12
| | | | | | | * lib.c (list_collect_nconc, list_collect_append): Capture deref(ptail) subexpression in local var and refer to that in all code where ptail isn't modified from the original value.
* Fix useless tolist over COBJ objects.Kaz Kylheku2016-06-061-1/+1
| | | | | | * lib.c (tolist): Use mapcar_listout, to avoid the conversion of the resulting list to the object's type, making this whole operation useless!
* Note that txr-path includes trailing slash.Kaz Kylheku2016-06-051-3/+4
| | | | | * txr.1: Document that txr-path includes slash. Fix two incorrect examples which have an extra slash.
* Fix error messages in internal function scat.Kaz Kylheku2016-06-051-2/+2
| | | | | * lib.c (vscat): Replace "cat-str" and "vcat" with correct name "scat".
* The stdlib variable gets a trailing slash.Kaz Kylheku2016-06-053-16/+28
| | | | | | | | | | | | | | | | | | | * txr.c (sysroot_init): Add slash to stdlib_path. (sysroot_compat_fixup): Replace user-visible stdlib variable with a path that doesn't have a slash, if compatibility is 143 or lower. (compat): Call sysroot_compat_fixup. * lisplib.c (place_set_entries, ver_set_entries, ifa_set_entries, txr_case_set_entries, with_resources_set_entries, path_test_set_entries, struct_set_entries, with_stream_set_entries, hash_set_entries, except_set_entries, type_set_entries, yield_set_entries, sock_set_entries, termios_set_entries): Remove slash from format string since the directory includes it. * txr.1: Added note under stdlib about the slash, and also an entry COMPATIBILITY.
* Allow empty @(catch) and @(finally).Kaz Kylheku2016-06-051-12/+3
| | | | | | | * parser.y (catch_clauses_opt): Don't diagnose empty catch and finally. There is no benefit in doing so; moreover, it contravenes the documentation, which explicitly says these may be empty. I.e. this fixes a regression.
* Version 143.txr-143Kaz Kylheku2016-06-046-680/+710
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Allow @(repeat) to see variables in more places.Kaz Kylheku2016-06-041-3/+30
| | | | | | | * match.c (extract_vars): With these changes, if @{a b [c..d]} appears inside a @(repeat) or @(rep), variables in the b, c and d positions will be recognized for list iteration, not only a.
* Fixes in field formatting diagnostics.Kaz Kylheku2016-06-041-5/+6
| | | | | | * eval.c (format_field): Improve error messages; streamline some code, report expression value rather than expression itself for bad modifier.
* Incorrect repeat directive example.Kaz Kylheku2016-06-031-1/+1
| | | | | * txr.1: Insufficient parenthesis nesting in :vars syntax with initializer.
* @(output) evaluates destination as Lisp.Kaz Kylheku2016-06-032-7/+23
| | | | | | | | | * match.c (v_output): Use txeval on the destination only if compatibility is 142 or lower, or it is a meta expression (so that @var and @(expr) still work without having to use the compatibility option). * txr.1: Documented and put in compatibility notes.
* Mistake in remq*, reqml* and remqual heading.Kaz Kylheku2016-06-031-1/+1
| | | | * txr.1: reqm was written instead of remq*.
* Drop between TXR and Lisp syms in HTML Doc.Kaz Kylheku2016-06-031-20/+9
| | | | | | | | | | | | | | | Dropping the document feature that hyperlinks in the TXR section resolve to TXR topics, and TXR Lisp hyperlinks go to TXR Lisp topics. All multiple uses of symbols are handled through the new mechanism of disambiguating topic navigators. * genman.txr (txrhash, txlhash, tgthash): Variables removed. (symhash): One variable, replacing those three. BODY collecting loop no longer collects LOOKUP variable, since body lines are not associated with a particular hash.
* Topic disambiguation "sub-pages" in HTML doc.Kaz Kylheku2016-06-031-3/+33
| | | | | | | | | | | | | | | | | | | | The purpose of this change is to handle situations where a symbol has multiple meanings, resulting in different topic areas of the document where we might want to navigate. For instance, there is an equal function in the TXR Lisp library, and an equal method that users can define. * genman.txr (tochash, disamb, dist-counter): New variables. (process-ambiguities): New Lisp function. When collecting symbol/jump-tag associations, collect the lists of jump tags rather than just the first jump tag. Then process the hash using process-ambiguities to handle the cases with multiple entries, which are prepared in the disamb hash. The contents of the disamb hash turn into HTML material at the end of the page. An in-line style sheet is now added; it adds vertical space between the navigation menus so they appear as if they were separate web pages.
* Adding special function from-list.Kaz Kylheku2016-06-012-1/+51
| | | | | | | | | | * lib.c (from_list_s): New symbol variable. (make_like): Handle a COBJ. If it's a structure with a from-list method, then use it, otherwise the default handling applies of returning the list. (obj_init): Initialize from_list_s. * txr.1: Documented.
* Describe special structure methods in new section.Kaz Kylheku2016-06-011-114/+158
| | | | | | | | * txr.1: Removing "Functors", "Equality Substitution", "Custom Pretty-Printing" and "Sequence Operations on Structures" paragraphs. Adding major section "Special Structure Functions" under which the special functions are described with syntax headings.
* ldiff uses equal for all non-list arguments.Kaz Kylheku2016-06-012-9/+8
| | | | | | | | | | | * lib.c (ldiff): Rather than checking specifically for strings and vectors to apply the special case behavior (comparison using equal), test specifically for lists and apply the traditional behavior. Every other object, not just strings and vectors, gets the altered behavior. * txr.1: Changed text in TXR Lisp introduction which touches on ldiff, and wording fix under ldiff.
* Methods for turning objects into sequences.Kaz Kylheku2016-06-015-2/+85
| | | | | | | | | | | | | | | | | | | | | | | | Struct objects can now define methods car, cdr and nullify. With these, they can participate in operations on sequences. * eval.h (car_s, cdr_s): Declared. * lib.c (nullify_s): New symbol variable. (car, cdr): Implement for struct objects via, respectively, their car and cdr methods. (tolist): Handle objects by mapping through identity. (nullify): Implement for objects optionally: if an object is a struct with a nullify method, use it, otherwise go through default case of just returning the object. (empty): Implement for objects that have nullify method. (obj_init): Initialize nullify_s. * struct.c (maybe_slot): New function. * struct.h (maybe_slot): Declared. * txr.1: Documented car, cdr and nullify method convention.
* Print method on objects.Kaz Kylheku2016-06-012-1/+18
| | | | | | | | | * struct.c (print_s): New symbol variable. (struct_init): Initialize print_s. (struct_inst_print): If pretty-printing, try to look up object's print method and use it. * txr.1: Documented pretty-printing via print method.
* Eliminating the ! $ and - file-opening hacks.Kaz Kylheku2016-05-313-36/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Going forward, the "!command" and "$dir" are no longer recognized, except with the backward-compatibility -C option. The "-" string denoting standard input is only recognized from the command line, not in the @(next) directive; and "-" cannot be used in @(output) to denote standard output. The main problem is that these are hacks which intrude into the namespace. (What if a file is named "-", or begins with "!" or "$"?) Secondly, they are possible security holes. These prefixes are recognized even in computed strings, like "@(next var)" where var contains "!command". * Makefile (tst/tests/002/%): Run tests in this directory with the -C 142 option in TXR_OPTS, because they use the ! mechanism. * match.c (complex_open): New argument, from_cmdline, indicating whether the file name came from the command line or is internal. Function now only treats "-" as denoting standard input, if that came from the command line. The "!" and "$" prefixes are only recognized in compatibility with 142 or earlier. (v_next): Suppress old strategy of handling string sources by pushing them to the file list to let match_files open them. This is now done only under 142 compatibility. Instead, open directly, produce the list, and recurse into match_files with ready data. This is not only simpler, but also prevents "-" from being recognized in @(next), because complex_open is invoked directly, and the from_cmdline argument is specified as nil. (v_output): Don't rely on "-" denoting standard output; rather use the stream directly, which can be passed to complex_open. Pass nil to the new from_cmdline parameter of complex_open, so "-" isn't recognized. (open_data_source): Pass t for the from_cmdline parameter of complex_open, to have "-" recognized as denoting standard input. * txr.1: Removed documentation referring to !, and use of - in the @(next) and @(output) directives. Added notes to COMPATIBILITY section.
* Version 142.txr-142Kaz Kylheku2016-05-296-98/+132
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Turn flags in struct stdio_handle into bitfields.Kaz Kylheku2016-05-291-3/+3
| | | | | * stream.c (struct stdio_handle): Members is_rotated, is_real_time and is_byte_oriented become bitfields.
* Use width of 8 for struct dgram boolean bitfields.Kaz Kylheku2016-05-291-2/+2
| | | | | | | | * socket.c (struct dgram): Members is_connected and is_byte_oriented widened from 1 to 8 bits. This allows byte-access instructions to be used on architectures like x86. All the flags still fit into a word, so the structure doesn't get bigger.
* Support byte oriented mode in dgram sockets.Kaz Kylheku2016-05-292-4/+20
| | | | | | | | | * socket.c (struct dgram_stream): New member, is_byte_oriented. (dgram_get_char): In byte oriented mode, just get one byte and convert to a character just like stdio_get_char: zero goes to U+DC00, and 0x01-0xFF go to U+0001 to U+FFFF. (dgram_get_prop, dgram_set_prop): Handle :byte-oriented property for getting and setting the is_byte_oriented flag.