summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* doc: missing plurals in headings, missing .desc.Kaz Kylheku2016-10-232-3/+8
| | | | | | | | * checkman.txr (check-func): Check for excess elements in singular heading. Add exception for headings that have Operator and macro. * txr.1: Missing plural in chr-ixdigit and chr-xdigit heading. Same in hash-begin and hash-next, plus missing desc.
* Default to epoch time in time-parse.Kaz Kylheku2016-10-232-1/+19
| | | | | | | * lib.c (epoch_time): New static function. (time_parse): Default the struct tm to epoch. * txr.1: Documented.
* doc: spelling error new circle notation doc.Kaz Kylheku2016-10-231-1/+1
|
* Version 155.txr-155Kaz Kylheku2016-10-216-724/+757
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* struct bug: mismanagement of static slot store.Kaz Kylheku2016-10-211-1/+4
| | | | | | | | | | | | | | | | | The bug_unless statement was found to go off, indicating an internal problem. Indeed, the store of inherited static slots were being set to non-nil by incorrect copying in two places. This is harmless in and of itself; it's just a way of being tidy. If a slot's value is located elsewhere, then the local store must be nil. * struct.c (static_slot_home_fixup): After fetching a fresh copy of the home type's stslot entry, clear the store to nil. (make_struct_type): Likewise. (struct_type_mark): Use assert for this rather than bug_unless, because it happens in the middle of garbage collection. Throwing an exception out of the middle of gc is a nonstarter.
* Document circular printing.Kaz Kylheku2016-10-211-0/+144
| | | | | * txr.1: Documenting circular notation and the *print-circle* variable.
* Block continuation capture across printer.Kaz Kylheku2016-10-211-0/+5
| | | | | * lib.c (obj_print): Applying a continuation guard around the body of the function. This seems prudent.
* repl: don't send error trace to *stderr*.Kaz Kylheku2016-10-211-1/+1
| | | | | | | * parser.c (repl): Pass out_stream rather than std_error to error_trace. I don't remember the original intent here. All it does is create strange puzzling behavior when an error occurs in the middle of a line of output that isn't flushed yet.
* Another fix to print method circular printing.Kaz Kylheku2016-10-211-8/+21
| | | | | | | | | | | | | | | | | | | | | | | Continuing on the theme of the previous patch, we now properly detect the situation when the recursive call is re-introducing duplicate references to objects that have already been sent to the stream without at #<num>= label. It's too late to print those objects, so we throw an exception. * lib.c (obj_print_impl): When we print an object that doesn't have duplicates (its hash entry has a nil value), we replace that value with the : symbol to indicate that the object has already been printed. (obj_hash_merge): New function, factoring out the hash merging logic from obj_print, introduced in parent commit. Here, we detect the case that the recursive print call has submitted to us an object which was already printed without a label: because it is associated with the : symbol in the parent hash. This situation is a show-stopper so we throw. We cannot attempt to print the object in any manner because we can get into runaway recursion. (obj_print): Hash merging logic replaced with call to new static function.
* Fix circular printing across print methods.Kaz Kylheku2016-10-211-0/+10
| | | | | | | | | * lib.c (obj_print): When invoked recursively in circular printing mode, collect the nodes of the new object into a separate hash table. Then merge these entries into to the previous hash table. If the newly visited object visits objects we have already seen, suppress those entries.
* Changes to the printing framework.Kaz Kylheku2016-10-209-73/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The print function now takes an optional boolean for pretty printing. The print method is also called with a third argument; hence structures can customize both standard printing and pretty printing. * lib.c (obj_print): Take pretty argument, and pass it down to obj_print_impl. This makes obj_pprint redundant. (obj_pprint): Function removed: it was identical to obj_print except for passing t down to obj_print_impl for the pretty argument. These two wrappers had started small and got bigger with identical changes done in parallel. (pprint): New function. (tostring, dump): Pass nil for pretty argument of obj_print. (tostringp): Use pprint instead of obj_pprint. * lib.h (obj_print): Declaration updated. (obj_pprint): Declaration removed. (print, pprint): Declared. * eval.c (prinl): Pass nil for pretty_p argument of obj_print. Do the stream defaulting here; obj_print doesn't do it. (pprinl): Pass t for pretty_p argument of obj_print, and do stream argument defaulting. (eval_init): Register print to new print function rather than directly to obj_print. Register pprint to new pprint function rather than obj_pprint. * hash.c (hash_print_op): Call obj_print_impl to print the :equal-based keyword, rather than obj_print. Pass down the pretty flag. All the other keywords are treated this way; this fixes an inconsistency. * match.c (dump_var): Call pprint instead of obj_pprint. * stream.c (formatv): Call obj_print, with a calculated pretty argument instead of switching between obj_pprint and obj_print. * struct.c (struct_inst_print): Except when in backward compatibility mode, call the object's print method in both pretty and regular printing mode, passing the mode as a third argument. * tests/012/oop.tl (defstruct animal): Support third argument in print method. Make it optional because there are some explicit calls which don't pass the argument. * txr.1: Documentation updated for print method and the print function. Revised text for some of the related functions. Added compat notes.
* A few volatile fixes related to setjmp.Kaz Kylheku2016-10-202-6/+6
| | | | | | | | | | | | * socket.c (dgram_get_byte_callback): nbytes must be volatile because we assign to it after setting up the catch, and then access it in the unwind code. (sock_accept): Likewise. * stream.c (generic_get_line): buf variable must be volatile. (struct save_fds): The members of this structure must be volatile; it's used as a local variable in a number of functions in a way that requires volatile.
* obj_print: use of volatile.Kaz Kylheku2016-10-201-3/+5
| | | | | | | | * lib.c (obj_print): The ret variable doesn't have to be volatile qualified, because it is never modified after setting an exception handler, and then accessed in the cleanup. On the other hand, the ctx variable is manipulated this way and must be volatile.
* doc: reduce-left fixes.Kaz Kylheku2016-10-201-2/+8
| | | | | * txr.1: Fixed grammar error and added clarification that the init-val isn't filtered through key-function.
* doc: fix incomplete range literal desc.Kaz Kylheku2016-10-201-0/+10
| | | | | * txr.1: describe from and to expressions of range literals.
* doc: fix incomplete hash literal desc.Kaz Kylheku2016-10-201-1/+8
| | | | * txr.1: describe key-value pairs of hash literals.
* Check call graph circularity in circ_backpatch.Kaz Kylheku2016-10-201-7/+13
| | | | | | | | | | | | | | | | | The circ_backpatch function could suffer runaway recursion, so we must add a cycle check. This could happen due to hitting cyclical objects when traversing structs. Structs have static slots that could contain cyclic objects, as well as construction logic which can generate slots that contain cycles and are not overridden by anything in the literal. * parser.c (circ_backpatch): Take struct circ_stack * argument; extend the circ_stack in recursive calls. Do circular check on entry. (parser_resolve_circ): Pass null pointer as the new stack argument to circ_backpatch.
* Fix struct lit problem exposed by circular syntax.Kaz Kylheku2016-10-206-12/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The semantics of how struct literals come to life is poorly designed: namely, the slot-value pairs in the struct literal are used as the plist argument in a call to make-struct. This is wrong because the implied initializations are then clobbered by the structure type's :init and :postinit handlers, resulting in an object with slot values that don't match what is in the literal. When you add circular syntax to the mix, things get worse. Slots may be initialized with (sys:circ-ref ...) expressions corresponding to #<n># syntax. These expressions then get clobbered by the constructor actions before the circ_backpatch processes the syntax. * parser.y (struct): Use make_struct_lit rather than make_struct to instantiate struct object. * struct.tl (sys:struct-lit): Expand to a form which calls sys:make-struct-lit, rather than make-struct. * struct.c (struct_init): Register new make_struct_lit function as sys:make-struct-lit intrinsic. (make_struct_lit): New function. * struct.h (make_struct_lit): Declared. * tests/012/struct.tl: struct literal expansion test case updated. * txr.1: Updated documentation of struct literals. Added compat notes.
* Implement *print-circle* for sharing and cycles.Kaz Kylheku2016-10-201-5/+122
| | | | | | | | | | | | | | | | | | | | | | | * lib.c (obj_print_impl): On entry, ctx being non-null indicates that cycle and substructure detecting is enabled via *print-circle* for this print job. In this case, check whether this is the first request to print a multiply-referenced object, in which case we print the #<n>= label definition, or whether it is a second or additional reference, in which case we render the object as #<n>#. Special handling must also be introduced into the loop which prints list elements. At any point in a list, the rest of the list could be shared substructure or a cyclic link that must be rendered with the appropriate notation. (populate_obj_hash): New static function. Enters all objects in the substructure that are eligible for the circle notation into the hash that is stored in the print context. Any object that appears two or more times is associated with a t value. (obj_print, obj_pprint): Unless circle printing is already in effect, check *print-circle* and turn it on if necessary and prepare the context, associating it with the stream. Either way, if circle printing is enabled, call populate_obj_hash to walk the object and add its components to the hash.
* Add stream printing context.Kaz Kylheku2016-10-208-55/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is some infrastructure which will support *print-circle*. * lib.h (struct strm_ctx): Forward declared. (struct cobj_ops): Add context parameter to print function pointer. (cobj_print_op, obj_print_impl): Add context parameter to declarations. * hash.c (hash_print_op): Take context argument and pass it down in obj_print_impl calls. * lib.c (cobj_print_op, out_quasi_str): Likewise (obj_print_impl): Likewise, and also pass to COBJ print method. (obj_print, obj_pprint): Pass null pointer as context argument to obj_print_impl. * regex.c (regex_print): Take context parameter and ignore it. * socket.c (dgram_print): Likewise. * stream.h (struct strm_ctx): New struct type. (struct strm_base): New ctx member, pointer to struct strm_ctx. (stream_print_op): Add context parameter to declaration. (get_set_ctx, get_ctx): Declared. * stream.c (strm_base_init): Add null pointer to initializer. (strm_base_cleanup): Add assertion against context pointer being non-null: that indicates that some stream operation installed a context pointer and neglected to restore it to null before returning, which is bad because context will be stack allocated. (stream_print_op, stdio_stream_print, cat_stream_print): Take context parameter and ignore it. (get_set_ctx, get_ctx): New functions. * struct.c (struct_type_print): Take context parameter and ignore it. (struct_inst_print): Take context parameter and pass down to obj_print_impl.
* Add *print-circle* special variable.Kaz Kylheku2016-10-192-2/+3
| | | | | | | | * stream.c (print_circle_s): New symbol variable. (stream_init): Initialize print_circle_s as symbol named *print-circle*; register as special var. * stream.h (print_circle_s): Declared.
* Cycle detection in sys:cp-origin.Kaz Kylheku2016-10-191-9/+13
| | | | | | | | | | | | | | | Tree-walking code in the place expander runs into trouble if the expression contains cycles. Test case: (defparm a '(#1=(a . #1#))). * share/txr/stdlib/place.tl (sys:cp-origin): Take list of symbols as a single argument instead of trailing arguments. Support an optional argument that gives serves as a cycle-detecting stack. Bail if a cycle is detected. (call-udpate-expander, call-clobber-expander, call-delete-expander): Update sys:cp-origin calls to follow interface change.
* reduce-left bugfix: bad init val with key-func.Kaz Kylheku2016-10-181-1/+1
| | | | | * lib.c (reduce_left): init value pulled from list itself must be passed through the key function.
* Adding notation for cycles and shared structure.Kaz Kylheku2016-10-184-5/+213
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit implements the parse-side support for handling a notation that exists in ANSI Common Lisp for specifying objects with cycles and shared substructure. * parser.h (struct parser): New members, circ_ref_hash and circ_count. (circref_s, parser_resolve_circ, parser_circ_def, parser_circ_ref): Declared. * parser.c (circref_s): New symbol variable. (parser_mark): Visit the new circ_ref_hash member of the parser structure. (parser_common_init): Initialize new members circ_ref_hash and circ_count of parser structure. (patch_ref, circ_backpatch): New static functions. (parser_resolve_circ, parser_circ_def, parser_circ_ref): New functions. (circref): New static function. (parse_init): Initialize circref_s as sys:circref symbol. Register sys:circref function. * parser.l (grammar): Scan #<num>= and #<num># notation as tokens, extracting their numeric value. * parser.y (HASH_N_EQUALS, HASH_N_HASH): New token types. (i_expr, n_expr): Adding phrases for hash-equalsign and hash-hash syntax. (yybadtoken): Handle new token types in switch. (parse_once): Call parser_resolve_circ after parsing to rewrite any remaining #<num># references in the structure to the objects they denote. (parse): Reset new struct parse members to initial state. Call parser_resolve_circ after parsing to rewrite any remaining #<num># references.
* Detect cycles in rlcp_tree.Kaz Kylheku2016-10-183-3/+34
| | | | | | | | | | | | | This will be required when the parser becomes capable of creating object graphs with cycles. * parser.c (parser_callgraph_circ_check): New function. * parser.h (struct circ_stack): New struct. (parser_callgraph_circ_check): Declared. * parser.y (rlcp_tree_rec): New static function. (rlcp_tree): Reduced to wrapper for rlcp_tree_rec.
* New function to access slot list of struct type.Kaz Kylheku2016-10-182-0/+7
| | | | | | * struct.c (slots): New function. * struct.h (slots): Declared.
* Provide functions to alter range objects.Kaz Kylheku2016-10-172-0/+16
| | | | | | | | | | Ranges continue to be immutable; but a backdoor is needed for upcoming support for circular notation. * lib.c (set_from, set_to): New functions. * lib.h (set_from, set_to): Declared.
* Bugfix: unable to assign to x.y.z place.Kaz Kylheku2016-10-151-4/+1
| | | | | | | | | | | | | | | | | | | This regression was caused by commit 957f80f "Bugfix: issue with expansion of place macros" on Sep 7, 2016. The commit itself is sound, but exposes a hidden problem in nearby code. * share/txr/stdlib/place.tl (sys:pl-expand): The conditions for terminating the loop and returning the expansion are too weak, due to the inclusion of an incorrect test. We must not bail when the expansion of a compound form is a compound form with the same symbol. This is because some macros behave that way, such as, oh: qref! The expansion of (qref a b c) is (qref (slot a 'b) 'c): another qref form. To fully expand, we must keep iterating until the returned form is eq to the input form. The original macroexpand (which was replaced by macroexpand-1 in 957f80f) hid this problem because macroexpand doesn't use this broken termination test.
* Support nil env in env-fbind and env-vbind.Kaz Kylheku2016-10-152-10/+30
| | | | | | | | * eval.c (env_fbind, env_vbind): Allow env to be nil, indicating that the binding is to take place in the global environment. * txr.1: Documented.
* Version 154.txr-154Kaz Kylheku2016-10-156-662/+710
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Fix wrong memset in new args handling function.Kaz Kylheku2016-10-151-1/+1
| | | | | | | * args.c (args_cat_zap_from): Clear the area that was copied, starting at the index offset, rather than from argument zero. This bug could result in spurious retention due to failing to zap some arguments.
* doc: defsymacro: runaway recursion.Kaz Kylheku2016-10-141-1/+1
| | | | | * txr.1: If a symbol macro expands to itself indirectly, the result isn't a loop but runaway recursion.
* doc: defsymacro rewording.Kaz Kylheku2016-10-141-8/+12
| | | | | * txr.1: Updating awkward wording, beginning with clumsy two-clause sentence joined by a colon.
* doc: small fix under format ~s directive.Kaz Kylheku2016-10-141-1/+3
| | | | | * txr.1: typeset print function name with .code so it turns to typewriter font and hyperlink.
* Adding family slot to socket addresses.Kaz Kylheku2016-10-133-9/+37
| | | | | | | | | | | | | | | A static slot indicating the address family simplifies code which wants to map a socket address to its family. * lisplib.c (sock_instantiate): Call sock_load_init before loading socket.tl rather than after, because socket.tl now references variables defined inside sock_load_init. * share/txr/stdlib/socket.tl (sockaddr, sockaddr-in, sockaddr-in6, sockaddr-un): New static slot, family. * txr.1: Documented family slots.
* Bugfix: sub and length on abstract sequences.Kaz Kylheku2016-10-133-1/+45
| | | | | | | | | | * lib.c (length_proper_list): New static function. (length): Use length_proper_list for objects. (sub): Call nullify on COBJ object before passing to sub_list. * tests/012/aseq.tl, tests/012/aseq.expected: New files.
* Overhaul where funtion.Kaz Kylheku2016-10-131-14/+43
| | | | | * lib.c (where): Implement faster ref-based access for vectors and strings. Support abstract sequence structs.
* doc: clarification under nullify method.Kaz Kylheku2016-10-131-1/+2
| | | | | | * txr.1: the nullify method need not return the object itself in the non-empty case; it may also return a sequence.
* Let some sequence functions work on structs.Kaz Kylheku2016-10-131-28/+32
| | | | | | * lib.c (in, sub, ref, search, rsearch, sel): These functions now accept struct objects that have the nullify, car and cdr methods.
* find-max and find-min support hashes.Kaz Kylheku2016-10-122-15/+76
| | | | | | | * lib.c (find_max): Restructured to implement separately for vectors and lists. Support hash tables. * txr.1: Document find-min and find-max for hashes.
* New accessor: hash-userdata.Kaz Kylheku2016-10-123-9/+51
| | | | | | | | | | | | | | The get-hash-userdata function is now deprecated in favor of hash-userdata, which is an accessor. * hash.c (hash_init): Register hash-userdata as a synonym for the same function as get-hash-userdata. * share/txr/stdlib/place.tl (hash-userdata): New defplace. * txr.1: Document new accessor, marking get-hash-userdata as a deprecated synonym. Replace references to get-hash-userdata with references to hash-userdata.
* listener: put each result into linenoise.Kaz Kylheku2016-10-121-0/+1
| | | | | | | | * parser.c (repl): After each successful command that produces a value, not only print the value but also call lino_set_result to install its string representation into the linenoise object, so it is available for insertion via Ctrl-X Ctrl-P.
* linenoise: Ctrl-X Ctrl-P edits result of command.Kaz Kylheku2016-10-122-0/+21
| | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New member, result. (edit): Ctrl-P or p in extended mode cause result string to be inserted into the buffer. (lino_copy): Ensure result string in copy is null. (lino_cleanup): Free result string and set to null. (lino_set_result): New function. * linenoise/linenoise.h (lino_set_result): Declared.
* Include user data in hash read syntax.Kaz Kylheku2016-10-122-8/+40
| | | | | | | | | | | | | * hash.c (userdata_k): New keyword symbol variable. (hash_print_op): Print the userdata together with the hash flags as :userdata obj. (hashv): Parse out :userdata obj syntax from the argument list. This takes care of supporting it in the read notation and in the hash function. (hash_init): Initialize userdata_k. * txr.1: Documenting :userdata in hash read notation and hash function.
* Support gmtoff and zone in time struct.Kaz Kylheku2016-10-122-4/+52
| | | | | | | | | | | | | | * lib.c (gmtoff_s, zone_s): New symbol variables. (tm_to_time_struct): Copy tm_gmtoff and tm_zone into Lisp struct from struct tm, if the platform has these. (time_fields_to_tm): Zero/null-out the tm_gmtoff and tm_zone fields of the target structure, if the platform has them. (time_init): Intern the gmtoff and zone symbols, initializing the gmtoff_s and zone_s variables. Add the gmtoff and zone slots to the time struct. * txr.1: Documented new slots.
* doc: typo under html-encode*Kaz Kylheku2016-10-121-1/+1
| | | | * txr.1: necessary -> necessarily
* linenoise: bug in resubmit historic line when dupe.Kaz Kylheku2016-10-121-2/+4
| | | | | | | | | | | When Ctrl-X Enter is used to resubmit a line from the history, and it is a duplicate, it is not entered into the history. The position then doesn't advance to the next historic line. * linenoise/linenoise.c (lino_hist_add): Do add the line even if it is duplicate if the last submitted line was from the middle of the history.
* New function regex-from-trie.Kaz Kylheku2016-10-122-0/+78
| | | | | | | * filter.c (regex_from_trie): New static function. (filter_init): Register regex-from-trie intrinsic. * txr.1: Documented regex-from-trie.
* Support n-ary and and or operators in regex.Kaz Kylheku2016-10-101-1/+63
| | | | | | | | | | | Since much regex code assumes these are binary, the easiest and briefest approach is to implement a code transformation pass which rewrites n-ary forms into binary. * regex.c (reg_nary_unfold, reg_nary_to_bin): New functions. (regex_compile): Put raw sexp through reg_nary_to_bin to expand the nary syntax.
* Simplify some regex tree walking code.Kaz Kylheku2016-10-101-18/+10
| | | | | | | | | | * regex.c (reg_expand_nongreedy, reg_compile_csets): Generalize the compound_s case slightly by referring to sym rather than hard-coded compound_s. Then handle most of the regex operators under this same case. Their semantics are not relevant to the expansions being performed in these functions: all their arguments are regexes to be recursed over.