summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* New frame type to block bad unwinding and cont capture.Kaz Kylheku2016-04-082-4/+32
| | | | | | | | | | | | | | | | | | If some external function is invoked which can call back into TXR Lisp, we should guard against the called-back code from capturing a continuation across the external stack frames, and also from unwinding across those frames. This patch prepares a mechanism for this. * unwind.c (uw_unwind_to_exit_point): Abort with message on standard error if attempt is made to unwind across UW_GUARD frame. (uw_push_guard): New function. (uw_capture_cont): If the frame search encounters a UW_GUARD block, an exception is thrown. * unwind.h (enum uw_frtype): New enum constant, UW_GUARD. (uw_push_guard): Declared.
* Remove patch-related function from configure.Kaz Kylheku2016-04-081-18/+0
| | | | | | * configure (apply_patches): Unused function removed. This was used for applying patches when MPI was a tarball, not expanded in the code tree.
* Allow symbol macro in function call dot position.Kaz Kylheku2016-04-072-1/+19
| | | | | | | | | | * eval.c (expand_forms): If the forms list is an atom, then don't just return it. Try to expand it as a macro. If the macro produces a compound form, diagnose with an exception, otherwise return the expansion. * txr.1: Document the treatment of symbol macros in function call dot position.
* Document improper lists as macro call forms.Kaz Kylheku2016-04-071-0/+36
| | | | | | | | * txr.1: New section: Improper Lists as Macro Calls. This is necessary because the section on Dot Position in Function Calls doesn't cover macros. Macros are simpler, because it's just destructuring of syntax.
* Example formatting under Dot Position in Function Calls.Kaz Kylheku2016-04-071-2/+2
| | | | * txr.1: Just some whitespace for alignment of comments.
* Dot position in function calls described in terms of apply.Kaz Kylheku2016-04-071-21/+29
| | | | | | | | * txr.1: Reduce and simplify the description text under the Dot Position in Function Calls section, giving the semantics via equivalence to apply. The handling of values which are atoms or improper lists is described under apply in a more effective way.
* Mistake in apply example.Kaz Kylheku2016-04-071-1/+1
| | | | * txr.1: Example produces (1 2 3 4), not (1 2 3).
* Fix throw used instead of throwf in defstruct.Kaz Kylheku2016-04-061-9/+9
| | | | | | * share/txr/stdlib/struct.tl (defstruct): Errors about duplicate :init, :postinit or :fini were incorrectly thrown using throw rather than throwf.
* Diagnose bad supertype in defstruct.Kaz Kylheku2016-04-061-1/+6
| | | | | | | * share/txr/stdlib/struct.tl (defstruct): If super isn't nil, it must name an existing struct type, or an exception is thrown. Previously, a nonexistent struct was silently treated as if nil had been specified.
* Fix inappropriate references to tree-bind.Kaz Kylheku2016-04-051-3/+3
| | | | | | * txr.1: Documentation for the tc macro falsely claims that it is based on tree-bind, in the description and example expansion.
* Cramped parenthesis under suspend.Kaz Kylheku2016-04-051-2/+2
| | | | | * txr.1: Fix strange formatting mistake, causing parenthesis to follow a meta symbol with no whitespace.
* Incorrect obtain-block heading.Kaz Kylheku2016-04-051-1/+1
| | | | * txr.1: obtain-block introduced as the obtain-from macro.
* Revamp bad character messages in lexer.Kaz Kylheku2016-04-011-4/+15
| | | | | | | | * parser.l (grammar): Drop colon from unrecognized escape message. "bad character in directive" handles various cases to avoid printing junk to the terminal. Basic message harmonizes with the one in the yybadtoken function in the parser. Non-UTF-8 byte printed as TXR hex integer literal.
* Wrap #if HAVE_SOCKETS around some functions.Kaz Kylheku2016-03-311-0/+4
| | | | | | * stream.c (delegate_get_sock_family, delegate_get_sock_type, delegate_get_sock_peer, delegate_set_sock_peer): These functions should only be defined if HAVE_SOCKETS is true.
* Bugfix: support abstract UNIX socket addresses on Linux.Kaz Kylheku2016-03-312-6/+39
| | | | | | | | | | | | | Making it work as already documented. * socket.c (MIN): New macro. (sockaddr_pack): Use utf8_dup_to_buf to convert Unix socket path to a buffer of UTF-8 bytes, possibly with one or more embedded null bytes. Copy as much of this as fits into the sun_path member of struct sockaddr_un. * txr.1: Improve documentation about the abstract names on Linux.
* UTF-8 API overhaul: security, and other concerns.Kaz Kylheku2016-03-314-42/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main aim here is to pave the way for conversion between arbitrary buffers of bytes (that may include embedded NUL characters) and a wide string. Also, a potential security hole is closed. When we convert a TXR string to UTF-8 for use with some C library API, any embedded pnul characters (U+DC00) turn into NUL bytes which effectively cut the UTF-8 string short, and silently so. The C library function receives a shortened string. This could be exploitable in some situations. * lib.c (int_str): Use utf8_dup_to_buf instead of utf8_dup_to_uc. Pass 1 to have the buffer null-terminated, since mp_read_radix depends on it. * stream.c (make_string_byte_input_stream): Use utf8_dup_to_buf. This gives us the size, soo we don't have to call strlen. The buffer is no longer null terminated, but the byte input stream implementation never relied on this. * utf8.c (utf8_from_buf): Replacement fors utf8_from_uc which doesn't assume that the buffer of bytes is null-terminated. It can produce a wide string containing U+DC00 characters corresponding to embedded nulls in the original buffer. (utf8_from): Calculate length of null-terminated string and use utf8_from_buf. (utf8_to_buf): Replacement for utf8_to_uc. Can produce a buffer which is or is not null-terminated, based on new argument. (utf8_to): Use utf8_to_buf, and ask it to null-terminate, thus preserving behavior. (utf8_dup_from_uc): This function was not used anywhere and is removed. (utf8_dup_to_buf): Replacement for utf8_dup_to_uc which takes an extra agrgument, whether to null-terminate or not. (utf8_dup_to): Apply security check here: is the resulting string as long as utf8_to says it should be? If not, it contains embedded nulls. Throw an exception. * utf.h (utf8_from_uc, utf8_to_uc, utf8_dup_from_uc, utf8_dup_to_uc): Declarations removed. (utf8_from_buf, utf8_to_buf, utf8_dup_to_buf): Declared.
* Define a sock-peer syntactic place.Kaz Kylheku2016-03-312-6/+49
| | | | | | | * share/txr/stdlib/socket.tl (sock-peer): Syntactic place defined, allowing (set (sock-peer sock) addr). * txr.1: Documented sock-peer as accessor and sock-set-peer.
* sock-set-peer shouldn't mark dgram sockets connected.Kaz Kylheku2016-03-311-1/+5
| | | | | | | | | | | | Merely setting a peer doesn't actually connect the socket, so it must not be marked connected. If it is wrongly marked connected, then dgram_flush will wrongly use send rather than sendto. * socket.c (dgram_set_sock_peer): Don't set sock_connected flag. (sock_connect): Set the sock_connected flag here, for dgram sockets.
* Expose sock-set-peer function.Kaz Kylheku2016-03-311-0/+1
| | | | * stream.c (stream_init): Register sock-set-peer intrinsic.
* Rename badly named socket-related internal funs.Kaz Kylheku2016-03-311-16/+16
| | | | | | | | | | | | | | | Also rename its related functions for consistency. * socket.c (sockaddr_in_out): Renamed to sockaddr_in_unpack. The "in" stands for internet, and is juxtaposed to "out". (sockaddr_in6_out): Renamed to sockaddr_in6_unpack. (unix_sockaddr_out): Renamed to sockaddr_un_unpack. (getaddrinfo_wrap): Calls to *_out functions renamed to *_unpack. (sockaddr_in): Renamed to sockaddr_pack. Original name is confusing against the struct tag name in struct sockaddr_in. (dgram_set_sock_peer, sock_bind, sock_connect, sock_accept): Calls updated to sockaddr_pack.
* Version 137.txr-137Kaz Kylheku2016-03-306-304/+334
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* linenoise: replace poor uses of size_t with int.Kaz Kylheku2016-03-291-76/+75
| | | | | | | | | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): Members plen, pos, sel, end, dlen, dpos, dsel, dend, cols, oldrow and maxrows change from size_t to int. (struct lino_undo): Member dpos changes likewise. (restore_undo, free_completions, complete_line, next_hist_match, history_search, sync_data_to_buf, copy_display_params, refresh_singleline, screen_rows, col_offset_in_str, refresh_multiline, scan_match_rev, scan_rev, scan_match_fwd, scan_fwd, find_nearest_paren, paren_jump, update_sel, yank_sel, delete_sel, edit_insert, edit_insert_str, edit_move_eol, edit_move_matching_paren, edit_delete_prev_all, edit_delete_to_eol, edit_delete_prev_word, edit_delete_line, edit): Replace various size_t's in function arguments, return values and local variables with int. Drop what would now be useless casts of constants to type int.
* Replace all stray C style casts with macros.Kaz Kylheku2016-03-298-76/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (gc_report_copies): C style casts found in this function. * linenoise.c (strip_qual, convert, coerce): Copy and paste the macros here. (record_undo, compare_completions, lino_add_completion, history_search, ab_append, sync_data_to_buf, refresh_singleline, screen_rows, refresh_multiline, find_nearest_paren, paren_jump, yank_sel, edit_move_matching_paren, edit, lino_make, lino_copy, lino_hist_add, lino_hist_set_max_len): C style casts replaced. * mpi/mpi-types.h (MP_DIGIT_BIT, MP_DIGIT_MAX, MP_WORD_BIT, MP_WORD_MAX, RADIX): C style casts replaced. * mpi/mpi.c (convert, coerce): Copy and paste the macros here. (mp_init_size, mp_init_copy, mp_copy, mp_set_int, mp_div_d, mp_bit, mp_to_double, mp_to_signed_bin, mp_to_unsigned_bin, mp_to_unsigned_buf, mp_toradix_case, mp_grow, s_mp_set_bit, s_mp_mod_2d, s_mp_mul_2d, s_mp_div_2d, s_mp_mul_d, s_mp_mul, s_mp_sqr, s_mp_div, s_mp_2expt, s_mp_todigit): C style casts replaced. * mpi/mplogic (convert): Macro copy and pasted here. (mpl_num_set, mpl_num_clear): C style casts replaced. * parser.c (provide_completions): Likewise. * signal.c (small_sigfillset): Likewise. * stream.c (stdio_truncate, test_set_indent_mode, set_indent_mode): Likewise.
* Rewrite intro to delimited continuations.Kaz Kylheku2016-03-291-21/+114
| | | | * txr.1: Concrete example is given, with a detailed walk-through.
* Incorrect typesetting for suspend macro syntax.Kaz Kylheku2016-03-291-1/+1
| | | | | * txr.1: Wrong troff macro used for syntax of suspend macro, rendering it invisible.
* Doc restructuring: Filesystem Access seection gone.Kaz Kylheku2016-03-281-237/+235
| | | | | | | * txr.1: open-file, open-tail and open-directory moved into Input and Output (Streams) section. remove-path and rename-path moved into System Programming. Filesystem Access section removed.
* New macro: lset.Kaz Kylheku2016-03-283-1/+45
| | | | | | | | | * lisplib.c (place_set_entries): Added "lset" to autoload list. * share/txr/stdlib/place.tl (lset): New macro. * txr.1: Documented lset.
* Adding rightmost item search functions.Kaz Kylheku2016-03-274-3/+373
| | | | | | | | | | | | | | | | | | * eval.c (eval_init): Registered intrinsics rmemq, rmemql, rmemqual, rmember, rmember-if, rposqual, rposql, rposq, rpos, rpos-if, rfind, rfind-if and rsearch. * lib.c (rmemq, rmemql, rmemqual, rmember, rmember-if, rposqual, rposql, rposq, rpos, rpos-if, rfind, rfind-if, rsearch): New functions. (rsearch_list): New static function. (search): Omit unreachable return statement. * lib.h (rmemq, rmemql, rmemqual, rmember, rmember-if, rposqual, rposql, rposq, rpos, rpos-if, rfind, rfind-if, rsearch): Declared. * txr.1: Documented.
* Doc fixes under condlet.Kaz Kylheku2016-03-261-6/+4
| | | | * txr.1: Fix inaccurate wording referring to pairs.
* Bugfix in error location reporting across macro expansions.Kaz Kylheku2016-03-261-2/+2
| | | | | | | * eval.c (do_expand, macroexpand_1): The original form must have priority in providing source location info, over the macro. Otherwise macro bodies may get reported as locations of errors that occur in substituted code.
* Methods in time struct: time-local and time-utc.Kaz Kylheku2016-03-242-5/+66
| | | | | | | | | | | * lib.c (time_local_s, time_utc_s): New symbol variables. (time_meth): New static function. (time_init): Initialize new symbol variables. Create the time struct with two static slots, and initialize those static slots to be methods. * txr.1: Introduce "the epoch" term. Document the new methods.
* Mistake in time-string-local doc.Kaz Kylheku2016-03-241-2/+2
| | | | | * txr.1: Fixed wrongly copied and pasted reference to time-string-local and time-string-utc.
* Bugfix: lazy str printing not observing limit.Kaz Kylheku2016-03-241-0/+4
| | | | | * lib.c (lazy_str_put, out_lazy_str): Decrement lim variable in loop body.
* HTML formatting issue in tree-case and tc.Kaz Kylheku2016-03-241-2/+2
| | | | * txr.1: similar stray space removed in two places.
* Stray word removed, and formatting fix.Kaz Kylheku2016-03-241-2/+2
| | | | * txr.1: Under Macro parameter lists again.
* HTML issue in doc.Kaz Kylheku2016-03-241-1/+1
| | | | | | * txr.1: One piece of syntax under the section Macro parameter lists looks fine in a man page rendering and in the PDF, but not in the HTML.
* Fix ctype.h functions misapplied to wide characters.Kaz Kylheku2016-03-231-3/+3
| | | | | | | * arith.c (tofloat): The isdigit here should be iswdigit. Use '0' to '9' range check. (toint): Replace accidental isalpha and toupper with iswalpha and towupper.
* Merge some repeated code.Kaz Kylheku2016-03-221-31/+20
| | | | | | * match.c (maybe_next): New static function. (v_block, v_if): Replace block of code with call to maybe_next.
* New semantics for @(if) directive.Kaz Kylheku2016-03-224-46/+107
| | | | | | | | | | | | | | | * eval.h (if_s): Declared. * match.c (v_if): New static function. (dir_tables_init): Register v_if in v_directive_table under if symbol. * parser.y (IF): Token assigned to <lineno> type. (if_clause, elif_clauses_opt, else_clause_opt): New syntactic representation, understood by v_if. * txr.1: Documented if semantics more precisely, dropped the text about it being syntactic sugar for a cases with require, added compatibility note.
* Version 136.txr-136Kaz Kylheku2016-03-206-132/+169
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Improve documentation of file open modes.Kaz Kylheku2016-03-201-73/+82
| | | | | | | * txr.1: Restructured mode-string under open-file to give the syntax as a grammar, and explain its elements using indented paragraphs. No longer refers user to find documentation on the C fopen function.
* Improve treatment of open mode in tail streams.Kaz Kylheku2016-03-191-2/+9
| | | | | | | | | * stream.c (tail_strategy): Apply the mode whenever a new stream is opened. (open_tail): Store the original mode string in h->mode rather than the normalized one, so in tail_strategy we can apply all the same attributes to a newly opened stream that we applied to the original stream.
* Permissive stream open mode strings.Kaz Kylheku2016-03-194-43/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is more to this patch than just more permissive mode strings. Now if a socket can be opened with mode "l2" for instance, and these options are effectively applied to the socket-specific "r+b" default, not to "r". * stream.c (parse_mode): New argument specifying a default mode. The syntax is relaxed, allowing previously required elements to be omitted. (normalize_mode): New argument specifying a default mode. Format mode is always called now, because an input string is no longer necessarily a valid fopen string even in cases when it doesn't specify any extensions. (open_file, open_fileno, open_tail, open_command, open_process): Use new normalize_mode argument for defaulting; normalize_mode no longer defaults to "r". * stream.h (stdio_mode_init_trivial): Macro removed. (stdio_mode_init_blank, stdio_mode_init_r, stdio_mode_init_rpb): New initializer macros. (parse_mode, normalize_mode): Declarations updated. * socket.c (sock_accept): In datagram socket case, use new parse_mode argument for defaulting using stdio_mode_init_rpb, rather than overriding a missing string with "r+b". (open_sockfd): Likewise, and use new normalize_mode argument similarly for defaulting the mode on a stream socket. * txr.1: Documented mode string permissiveness.
* Size mode meaningful in datagram sockets.Kaz Kylheku2016-03-194-12/+48
| | | | | | | | | | | | | | | | | | | | | | * socket.c (struct dgram_stream): new rx_max member. (make_dgram_sock_stream): New arguments: a struct stdio_mode, and pointer to prototype dgram socket. If a size is specified in the mode, then use that as rx_max. Otherwise if a prototype socket is specified, use its rx_max as the new socket's rx_max. Otherwise default on 65536. (dgram_get_byte_callback): Use d->rx_max as the capture size, rather than a hard-coded 65536. (sock_accept): Use d->rx_max as capture size for datagram. Parse the mode. Pass the parsed mode to make_dgram_sock_stream, as well as the accepting socket, so it can set up the rx_max for the new socket. (open_sockfd): Parse the mode and pass to make_dgram_sock_stream. * stream.c (parse_mode): Static function becomes extern. * stream.h (parse_mode): Declared. * txr.1: Documented.
* Nuke accidental tabs.Kaz Kylheku2016-03-191-9/+9
| | | | | * socket.c: Inadvertently introduced tabs recently while working on Solaris. Grr!
* Buffer size digit in file open mode string.Kaz Kylheku2016-03-193-3/+40
| | | | | | | | | | | | | | | | | * streamn.c (struct stdio_handle): New member, buf. (stdio_stream_destroy): Free the stdio_handle's buf. (parse_mode): Handle digit character, converting it to integer value stored in m.buforder. (set_mode_props): Allocate a buffer and install into FILE * stream if the mode specifies a buforder. (make_stdio_stream_common): Initialize buffer to null. * stream.h (struct stdio_mode): New signed bitfield member, buforder. (stdio_mode_init_trivial): Initialize buforder member to -1. * txr.1: Documented size order digit.
* Sockets are r+b by default, not r+.Kaz Kylheku2016-03-182-2/+11
| | | | | | * socket.c (open_sockfd): Default mode string is "r+b". * txr.1: Documented.
* New l and u letters in stream open mode strings.Kaz Kylheku2016-03-183-15/+64
| | | | | | | | | | | | | | * stream.c (parse_mode): Recognize "l" and "u", and set new flags. (set_mode_props): More complicated behavior to integrate the new options with the line mode defaulting behavior of "i". * stream.h (struct stdio_mode): New members unbuf and linebuf. All members become bit fields of width 1. (stdio_mode_init_trivial): Initializers for new members. * txr.1: Documented.
* Support binding in @(repeat)/@(rep) :vars.Kaz Kylheku2016-03-164-9/+99
| | | | | | | | | | | | | | | | * match.c (extract_bindings): Check for (var expr) syntax, evaluate and bind. * match.h (vars_k): Declared. * parser.y (expand_repeat_rep_args): New static function. (repeat_rep_helper): The :counter and :var arguments of repeat/rep must be macro-expanded, since there can be Lisp expressions there. This supports the new feature, but also fixes the bug of :counter (var form) not expanding form. * txr.1: Updated documentation about :vars in @(repeat).
* Bugfix and @(repeat) and @(rep).Kaz Kylheku2016-03-161-1/+1
| | | | | | | * match.c (extract_bindings): Do not destructively append to vars, because that's a piece of syntax. The return value of extract_vars is freshly allocated, though, so we can fix this by reversing the arguments.