| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
| |
* lib.c (epoch_time): New static function.
(time_parse): Default the struct tm to epoch.
* txr.1: Documented.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
* txr.1: Documenting circular notation and the *print-circle*
variable.
|
|
|
|
|
| |
* lib.c (obj_print): Applying a continuation guard
around the body of the function. This seems prudent.
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
* txr.1: Fixed grammar error and added clarification
that the init-val isn't filtered through key-function.
|
|
|
|
|
| |
* txr.1: describe from and to expressions of
range literals.
|
|
|
|
| |
* txr.1: describe key-value pairs of hash literals.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
* lib.c (reduce_left): init value pulled from
list itself must be passed through the key function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
* struct.c (slots): New function.
* struct.h (slots): Declared.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
* txr.1: If a symbol macro expands to itself indirectly, the
result isn't a loop but runaway recursion.
|
|
|
|
|
| |
* txr.1: Updating awkward wording, beginning with clumsy
two-clause sentence joined by a colon.
|
|
|
|
|
| |
* txr.1: typeset print function name with .code so
it turns to typewriter font and hyperlink.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
* lib.c (where): Implement faster ref-based access for vectors
and strings. Support abstract sequence structs.
|
|
|
|
|
|
| |
* txr.1: the nullify method need not return the object
itself in the non-empty case; it may also return
a sequence.
|
|
|
|
|
|
| |
* lib.c (in, sub, ref, search, rsearch, sel): These
functions now accept struct objects that have the
nullify, car and cdr methods.
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
* 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/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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
* txr.1: necessary -> necessarily
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
* filter.c (regex_from_trie): New static function.
(filter_init): Register regex-from-trie intrinsic.
* txr.1: Documented regex-from-trie.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|