summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* * arith.c (plus): Fixed broken (+ fixnum char) case.Kaz Kylheku2012-04-242-2/+6
|
* Fixes for configuring and building in a separate directory.Kaz Kylheku2012-04-203-10/+21
| | | | | | | | | | * configure: MPI is now extracted and patched in the build directory, not in the source directory. * Makefile (CFLAGS): Refer to mpi headers relative to current directory, not $(top_srcdir). (repatch): Run MPI repatching steps in correct directory. (clean): Remove extracted MPI from build directory.
* Version 65txr-65Kaz Kylheku2012-04-205-4/+61
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated.
* * regex.c (regex_space_chars): Variable removed.Kaz Kylheku2012-04-202-22/+26
| | | | | | | | | (char_set_addr_str): New function. (char_set_compile): Use char_set_addr_str to add spaces to set. (init_special_char_sets): Use char_set_addr_str to add spaces to set. Bugfix: word_cs, cword_cs wrongly initialized. (regex_init): Removed reference to regex_space_chars.
* * parser.y (regtoken): New nonterminal symbol.Kaz Kylheku2012-04-204-37/+68
| | | | | | | | | | | | | | | | (regterm): REGTOKEN production factored out to regtoken. (regclass): Reverted prior commmit's changes. (regclassterm): Reverted prior commit, removing REGTOKEN production for character classes, and introduced a regtoken production. So now the keyword symbols are part of the character class abstract syntax. (regtoken): New production rule. * regex.c (regex_space_chars): Converted to internal linkage. (char_set_compile): Handle token keywords in character class abstract syntax. * regex.h (regex_space_chars): External declaration removed.
* * txr.1: Documented new regex tokens.Kaz Kylheku2012-04-192-1/+17
|
* First cut at implementing \s, \d, \w, \S, \D and \W regex tokens.Kaz Kylheku2012-04-196-9/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (init): Call regex_init. * parser.l: return new REGTOKEN kind. * parser.y (REGTOKEN): New token type. (REGTERM): Translate REGTERM to keyword. (regclass): Restructured to handle inherited nodes as lists. (regclassterm): Produce $$ as list. Add handling for REGTOKEN occurring inside character class by expanding it. This might not be the best approach. (yybadtoken): Handle REGTOKEN in switch. * regex.c (struct any_char_set, struct small_char_set, struct displaced_char_set, struct large_char_set, struct xlarge_char_set): New bitfield member, stat. (char_set_create): New parameter for indicating static char set. (char_set_destroy): Do not free a static char set. (char_set_compile): Pass zero to new parameter of char_set_create. (spaces): New static array. (space_cs, digit_cs, word_cs, cspace_cs, cdigit_cs, cword_cs): New static pointers to char_set_t. (init_special_char_sets, nfa_compile_given_set): New static function. (nfa_compile_regex, dv_compile_regex): Handle new character set token keywords. (space_k, digit_k, word_char_k, cspace_k, cdigit_k, cword_char_k, regex_space_chars): New variables. (regex_init): New function. * regex.h (space_k, digit_k, word_char_k, cspace_k, cdigit_k, cword_char_k, regex_space_chars, regex_init): Declared.
* * eval.c (eval_init): New intrinsic functions remq*, remql*,Kaz Kylheku2012-04-155-1/+111
| | | | | | | | | | | | | remqual*, remove-if*, keep-if*. * lib.c (rem_lazy_func, rem_lazy_rec): New static functions. (remq_lazy, remql_lazy, remqual_lazy, remove_if_lazy, keep_if_lazy): New functions. * lib.h (remq_lazy, remql_lazy, remqual_lazy, remove_if_lazy, keep_if_lazy): Declared. * txr.1: New functions documented.
* * eval.c (eval_init): find-if intrinsic registered.Kaz Kylheku2012-04-145-6/+42
| | | | | | | | | | | * lib.c (find): First and second arguments reversed. The item should be first. (find_if): New function. * lib.h (find): Declaration updated. (find_if): Declaration added. * txr.1: Stub section.
* * HACKING: Added notes on generational garbage collection.Kaz Kylheku2012-04-142-0/+114
|
* * eval.c (eval_init): New functions remove-if and keep-if.Kaz Kylheku2012-04-145-0/+99
| | | | | | | | * lib.c (remove_if, keep_if): New functions. * lib.h (remove_if, keep_if): Declared. * txr.1: Documented.
* * configure: Restructuring configure script to be able to detectKaz Kylheku2012-04-132-51/+76
| | | | | | | | | | nonexistent options. Variable default values are established first, which simplifies the syntax. The scanning loop detects attempts to create configuration variables that do not exist. The var_given convention is folded into the parsing. (If var exists, and var_given exists, and the user specifies var, then var_given is set to y to indicate that the value came from the user.)
* Bugfix: multiple uses of @(next :args) seeing junk "args" stringKaz Kylheku2012-04-132-18/+34
| | | | | | | | | | | | | | in argument list. Fix is not to rely on the hack of using the first element of the list of files to hold the name of the current file. * match.c (match_files_ctx): New member, curfile. (mf_all): Initialize curfile. (mf_args): Set curfile to "args". (mf_file_data): Initialize curfile. (v_skip, v_fuzz, v_gather, v_collect): Use c->curfile rater than first(c->files) in debug calls. (freeform_prepare, match_files): Pass c->curfile to ml_all constructor of match_line_ctx rather than rather than first(c->files).
* Improve the regex Lisp syntax by allowing strings to specifyKaz Kylheku2012-04-122-4/+24
| | | | | | | | | | | character compounds. I.e. the syntax "foo" is equivalent to the cumbersome canonical form (compound #\f #\o #\o). * regex.c (nfa_compile_regex, dv_compile_regex): Use chrp function instead of typeof. Handle stringp case by forming a compound out of the characters and recursing. Check for some bad objects in the regex that would never come out of our regex parser but could occur in a "hand crafted" syntax tree.
* * txr.1: Fixed wrong comment in example.Kaz Kylheku2012-04-111-1/+1
|
* * txr.1: Fix misleading comment example.Kaz Kylheku2012-04-112-1/+6
|
* Provide access to line number info and source path.Kaz Kylheku2012-04-116-1/+17
| | | | | | | | | | | | | | * eval.c (eval_init): New intrinsic functions source-loc and source-loc-str. New variable *self-path*. * txr.1: Stub doc sections. * txr.c (self_path): New variable. * txr.h (self_path): Declared. * txr.vim: Syntax highlighting for source-loc, source-loc-str and *self-path*.
* Adding patch to MPI to disable its Makefile so people don't tryKaz Kylheku2012-04-104-0/+66
| | | | | | | | | | | | | | to work around TXR build problems by running make inside the MPI directory, which is wrong. Also fixing an incorrect use of ctype.h functions in MPI and one case of a superfluous warning. * mpi-patches/series: new patches added. * mpi-patches/disable-make: New file. * mpi-patches/fix-ctype-warnings: New file.
* More NetBSD porting.Kaz Kylheku2012-04-104-2/+51
| | | | | | | | | | | | | | | | | | * Makefile (EXTRA_FLAGS): Handy new variable for additional ad-hoc CFLAGS. Needed by a new test in configure. * configure: Check for annoying warnings about char being used as an array subscript when calling the macros from <ctype.h>. If this occurs, suppress it by #undef-ing the macros. (lang_flags): Switching fromm _XOPEN_SOURCE to _XOPEN_SOURCE=2 because this is needed on NetBSD to obtain declarations of popen and pclose. * stream.c (pipe_close): If we don't have the WIFCONTINUED macro, then define it to expand to zero. It's absent on NetBSD and they already seem to have a hack for this because there is a warning about the function not being defined, but then the program links anyway. Let's do it properly and not rely on their hack.
* * arith.c (INT_PTR_MAX_MP): New static variable.Kaz Kylheku2012-04-105-6/+38
| | | | | | | | | | | | | | | (in_int_ptr_range): New function. (arith_init): Initialize INT_PTR_MAX_MP. * arith.h (in_int_ptr_range): Declared. * lib.c (c_num): Allow bignums to be converted to a cnum, if they are in range, rather than allowing only fixnums. * rand.c (make_random_state): Now that we have such a function, initialize random seed using time value from time_sec_usec rather than from time and clock. clock is bad for random seeding because it measures virtual time since the start of the process.
* * configure: Switch from _POSIX_C_SOURCE=2 to _XOPEN_SOURCE.Kaz Kylheku2012-04-103-5/+14
| | | | | | | | We will be relying on the gettimeofday function which only came into POSIX in 2001, but was in Unix long before then. * HACKING: Replace notes about -D_POSIX_C_SOURCE which are not true any more.
* * Makefile (conftest.ccver): New phony target.Kaz Kylheku2012-04-103-20/+44
| | | | | | | * configure: The test for non-working 128 bit integers in the gcc used by NetBSD 5.1 is not good enough to catch the bug. Adding a test which will assume that gcc 4.3.x and lesser does not have working 128 bit types.
* * eval.c (eval_init): Expose regex-compile and regexp as intrinsics.Kaz Kylheku2012-04-106-2/+65
| | | | | | | | | | | | | * lib.c (obj_init): Change spelling of nongreedy operator and put it into the user package so that it is available for use with regex-compile. * regex.c (match_regex, search_regex): Bugfix: optional start position argument argument not defaulting to zero. * txr.1: Documented regex-compile and regexp. * txr.vim: Highlighting regex-compile and regexp.
* Clarify which NetBSD.Kaz Kylheku2012-04-091-1/+1
|
* NetBSD port.Kaz Kylheku2012-04-093-69/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | * arith.c (bignum_dbl_ipt): Added missing #if HAVE_DOUBLE_INTPTR_T around function * configure: NetBSD's shell is too pathetic to expand "$@" properly when there are no positional arguments, so I applied the ${@+"$@"} trick. (make): New variable. GNU make might be known only as gmake, so we now detect the command for our own use within the configure script and also for giving the user advice on what command to use for building. Put in a fix so that the attempt to run $make --version does not bail the script under "set -e" if that command terminates unsuccessfully. The check for clashing names has been moved earlier, so that the renaming #define's appear early in config.h (so config.h itself can rely on the renames). The identifier longlong_t has been added to the potential clash list. NetBSD exposes this identifier in spite of -D_POSIX_SOURCE=2, and it clashes with our longlong_t. The tests for integers wider than long long has been modified to actually compile a multiplication of two long-long-s into the wider precision. On the NetBSD system, with gcc 4.1.3, I found that the __int128 type is there, but doesn't actually work; compilation of arith.c bails with an internal compiler error. We now get this internal error at configure time and avoid using the type.
* * mpi-patches/add-mp-hash (mp_hash): Fix incorrectKaz Kylheku2012-04-092-6/+15
| | | | | | | | code on platforms where mp_digit is smaller than long. This was left shifting a mp_digit by MP_DIGIT_BIT. It was found by compiling on NetBSD with a gcc 4.1.3 which has a broken__int128_t, forcing us to use 32 bit mp_digit with a 64 bit mp_word.
* * arith.c (bignum): Previously static function now exposed as external.Kaz Kylheku2012-04-089-4/+90
| | | | | | | | | | | | | | | | | | | | * arith.h (bignum): Declared. * configure: Added check for tm_gmtoff and tm_tmzone fields being present in struct tm. * eval.c (eval_init): New intrinsic functions: time, time-usec. * lib.c (num): If the cnum is outside of the fixnum range, then construct a bignum. (time_sec, time_sec_usec): New functions. * lib.h (mut): Slight change to macro to eliminate compiler warning. (time_sec, time_sec_usec): Declared. * txr.1: Stub section for time and time-usec. * txr.vim: Highlighting for time and time-usec.
* * txr.vim: Remove duplicate lines.Kaz Kylheku2012-04-081-4/+0
|
* * txr.vim: Fixed accidental breakage.Kaz Kylheku2012-04-082-1/+5
|
* * lib.c: Revert earlier change: config.h must be included before theKaz Kylheku2012-04-072-1/+7
| | | | | <windows.h> section because that header is conditionally included based on one of the config constants.
* Fixes to get configure ccname=g++ working on OSX Lion.Kaz Kylheku2012-04-073-37/+76
| | | | | | | | | | | | | | | | * Makefile (conftest.syms): Use -n flag in nm so that the output is not alphabetically sorted, but numerically. We need this to get the symbols ordered by increasing offset. * configure (read_syms): New function. Factors out logic used in two places for reading the output of nm. On OSX Lion, it looks like we do not get symbol sizes but offsets only, when compiling with g++. The symbols are in an S section. When compiling with gcc, we get a common C section with symbol sizes. So the hack is to use the deltas between offsets to get the sizes. The objects had to be re-ordered in decreasing rank so alignment doesn't create padding that will get counted as the size. Interleaved dummy objects of type char should also work.
* * configure: Print done and terminate line after checking forKaz Kylheku2012-04-072-0/+7
| | | | clashing symbols.
* * configure: Added new check for some clashing external names,Kaz Kylheku2012-04-073-1/+48
| | | | | | which we can redefine out of the way in config.h. * lib.c: config.h was being included before <windows.h>.
* * txr.1: Documented int-flo, flo-int, search-regex,Kaz Kylheku2012-04-072-0/+77
| | | | match-regex and regsub.
* Rounding out hash table functionality with lazy lists thatKaz Kylheku2012-04-079-11/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | can walk table content in different ways. * eval.c (op_dohash): Follow interface change of hash_next. (eval_init): hash-keys, hash-values, hash-pairs and hash-alist intrinsics introduced. * filter.c (trie_compress): Follow interface change of hash_next. * hash.c (hash_next): Silly interface which takes a pointer to the iterator has changed to just take the iterator. The function unambiguously returns nil when the iteration ends, so there is no need to set the iterator variable to nil. (maphash): Follows interface change of hash_next. (hash_keys_lazy, hash_values_lazy, hash_pairs_lazy, hash_alist_lazy): New static functions. (hash_keys, hash_values, hash_pairs, hash_alist): New functions. * hash.h (hash_next): Declaration updated. (hash_keys, hash_values, hash_pairs, hash_alist): Declared. * lib.c (make_half_lazy_cons): New way of constructing lazy cons, with the car field specified. It simplifies situations when the previous cons computes the car of the next one. Why hadn't I thought of this before? * lib.h (make_half_lazy_cons): Declared. * txr.1: Doc stubs for new hash functions. * txr.vim: Highlighting for new hash functions.
* Version 64txr-64Kaz Kylheku2012-04-065-4/+43
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated.
* ChangeLog: fix stray whitespace.Kaz Kylheku2012-04-051-4/+4
|
* Merge branch 'ephemeral-gc'Kaz Kylheku2012-04-0512-159/+654
|\ | | | | | | | | Conflicts: ChangeLog
| * * gc.c (FRESHQ_SIZE): Preprocessor symbol renamed to FRESHOBJ_VEC_SIZE.Kaz Kylheku2012-04-052-4/+9
| | | | | | | | (freshobj, make_obj): Object and function definitions follow rename.
| * * gc.c (mark_obj, sweep_one, gc_is_reachable): Check for gen > 0 ratherKaz Kylheku2012-04-052-3/+15
| | | | | | | | | | | | | | | | | | than gen == 0. This allows gen == -1 objects to be considered the same as gen == 0, and traversed. (gc_set, gc_mutated): When a gen 0 object is added to the checkobj array, set its generation to -1. This prevents duplicates in the checkobj array. Also, it fixes a bug: an vector marked as mutated was not being traversed due to being in generation 1.
| * Code cleanup and tweaking.Kaz Kylheku2012-04-054-24/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (BACKPTR_VEC_SIZE): Preprocessor symbol renamed to CHECKOBJ_VEC_SIZE. (FULL_GC_INTERVAL): Increased to 40 since the modified algorithm now leaves less work for the full gc to do. (backptr, backptr_idx): Static variables renamed to checkobj and checkobj_idx. (mark): Follows rename of backptr and backptr_idx. (gc): Commented out handy printf added. (gc_set): Use in_malloc_range check to avoid adding to the check array pointers which are being stored in non-heap locations, since non-heap locations are already GC roots. (gc_mutated): Follows variable renaming. (gc_push): Just do the push using gc_set. * lib.c (malloc_low_bound, malloc_high_bound): New variables. (chk_malloc, chk_calloc, chk_realloc): Updated malloc_low_bound and malloc_high_bound. (in_malloc_range): New function. * lib.h (in_malloc_range): Declared.
| * The mut macro should only be used for vectors or vector-like objectsKaz Kylheku2012-04-053-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | which hold direct references to other objects and must be used each time a mutation takes place. * eval.c (op_dohash): invocations of mut macro removed. Comment rewritten. * lib.c (sort_list): Use set macro for mutating assignment. Do not invoke mut on sorted list; it won't work anyway, because it doesn't mean what the code wants it to mean: that the list will be fully traversed during gc marking.
| * Bunch of fixes.Kaz Kylheku2012-04-057-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (gc_mutated): Return the value. * gc.h (gc_mutated): Declaration updated. * hash.c (remhash): Fix unsafe assignment to use set macro. * lib.c (sort): Fix wrong use of mut macro on the list before it is sorted rather than after. * lib.h (mut): Trivial version of macro updated to return argument. * unwind.c (uw_init): The toplevel environment's match_context should be gc_protected. Though this is probably not used, which is why it has not been a problem.
| * * hash.c (hash_grow, gethash_l, gethash, gethash_f): ReplaceKaz Kylheku2012-04-042-4/+9
| | | | | | | | useless use of *vecref_l() with vecref().
| * * configure (gen_gc): Default to off.Kaz Kylheku2012-04-043-1/+23
| | | | | | | | | | | | Help section added for gen_gc variable. * gc.c (gc): Some missing CONFIG_GEN_GC added.
| * Code cleanup.Kaz Kylheku2012-04-042-67/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (backptr_oflow): Static variable removed. (freshq_head, freshq_tail, partial_gc_count): Static variables removed. (freshq): Array renamed to freshobj. (full): Variable renamed to full_gc. (freshobj_idx): New varaible. (make_obj): Add newly born objects to freshobj array rather than freshq. If freshobj array is full on entry to this function, trigger gc to empty it. make_obj no longer updates the free_tail; the gc routine takes care of restoring this invariant. (mark_obj): Follows rename of full_gc. Some code was not wrapped in #if CONFIG_GEN_GC. (mark, sweep_one): Follow rename of full_gc. (sweep): On entry, restore free_tail invariant in the empty free_list case. Code which processes freshq from tail to head replaced by simple array walk of freshobj. Code wrapped properly in #if CONFIG_GEN_GC. (gc): Logic for triggering full gc simplified. Check added for situations when a partial gc is called when the free list empties, and it doesn't liberate enough memory. This prevents the situation of partial gc being called over and over again by make_obj, squeezing less and less memory each time until finally it returns 0 objects, and more() is called. (gc_is_reachable): Follows rename of full_gc, and #if CONFIG_GEN_GC added. (gc_set, gc_mutated): Simplified. Check if the backptr array is full and trigger gc if so to flush it, then just add to the array.
| * Performance tweaking and fixes.Kaz Kylheku2012-04-032-4/+20
| | | | | | | | | | | | | | | | | | | | | | * gc.c (BACKPTR_VEC_SIZE): Increase greatly, so that we don't trigger gc due to overflow of the backptr array. This is not likely to yield a lot of free objects except in a full GC. (FULL_GC_INTERVAL): From 10 to 20. (gc): Take a not of whether or not gc was entered with free_list being exhausted or not. Call more() only if the free_list was empty, and a full sweep was done. Reset partial_gc_count only when a full gc is triggered.
| * Fix failing test case tests/006/freeform-1.txr.Kaz Kylheku2012-04-032-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (lazy_str_force, lazy_str_force_upto): Use set macro when assigning lim. This won't cause a problem unless lim is in the bignum range, however. (acons_new, aconsq_new): When overwriting the cdr value of the existing entry, use set. This is the smoking gun; these functions are used for manipulating bindings. (sort): After sorting a list, we must mark it as having been mutated. If a list contains only mature conses or only fresh conses, there is no problem. But if it contains a mixture, then sorting could reverse their relationship, causing mature conses to backpoint to the fresh ones. (obj_init): Use set when installing the t symbol into the user package.
| * Generational GC showing signs of working. One test case inKaz Kylheku2012-04-034-82/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test suite fails. * gc.c (FRESHQ_SIZE): New preprocessor symbol. (backptr_oflow, freshq, freshq_head, freshq_tail): New static variables. (make_obj): Place newly allocated generation 0 object into freshq. If freshq becomes full, transfer oldest item into generation 1. (mark_obj): If doing only a partial gc, then do not mark objects which are not generation 0. (mark_mem_region): Valgrind support: cannot mark t.type field undefined because it is a bitfield. Just mark the first SIZEOF_PTR bytes of the object defined. (mark): Under partial gc, mark the table of back pointers. (sweep_one): New static function from the prior guts of sweep. Reachable objects now get promoted to generation 1. (sweep): Under partial gc, sweep just the freshq which identifies the generation 0 objects, rather than the entire linked list of all the heaps. (gc): Trigger full gc also if the backptr list has overflowed due to gc having been disabled. Under generational gc, reset the static variables afterward: clear the list of backpointers, and the freshq. (gc_is_reachable): Under partial gc, report any mature object as reachable. (gc_set, gc_mutated): Handle backptr array overflow situation when gc is disabled. (gc_push): Bugfix: it is the newly pushed cons cell that has to be marked as a root, not the value being pushed. * hash.c (sethash): Use set macro for storing value. * lib.h (set, mut, mpush): Fix wrong-way #if test for these macros. The trivial versions were being defined uner CONFIG_GEN_GC and vice versa!
| * * eval.c (op_modplace): push replaced with mpush (mutating push).Kaz Kylheku2012-04-037-7/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (gc_push): New function. * gc.h (gc_push): Declared. * hash.c (pushhash): Use mpush. * lib.c (push): Reverted to unsafe operation. TODO comment replaced with warning. (lazy_flatten_scan): push occurence commented as safe. (lazy_stream_func): Unsafe push replaced with mpush. * lib.h (mpush): New macro.