summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* IP address to string functions.Kaz Kylheku2016-02-292-0/+39
| | | | | | | | * lisplib.c (sock_set_entries): Add str-inaddr and str-in6addr to list of autoload identifiers. * share/txr/stdlib/socket.tl (str-inaddr, str-in6addr): New functions.
* Bugfix: append-each is wrongly destructive.Kaz Kylheku2016-02-291-1/+1
| | | | | * eval.c (op_each): Use list_collect_append not list_collect_nconc. Ouch!
* expand-left and nexpand-left functions.Kaz Kylheku2016-02-292-1/+108
| | | | | | | | * eval.c (expand_left, nexpand_left): New static functions. (eval_init): Registered expand-left and nexpand-left intrinsics. * txr.1: Documented.
* Implement @(next nil).Kaz Kylheku2016-02-292-6/+22
| | | | | | | | * match.c (v_next): If argument to @(next) is nil, then evaluate remaining query in context with no list of files, and no data. * txr.1: Documented @(next nil).
* Missing return type on some inline functions.Kaz Kylheku2016-02-291-2/+2
| | | | | * sysif.h (repress_privilege, drop_privilege): Add missing void.
* Fix typo in configure script message.Kaz Kylheku2016-02-281-1/+1
| | | | * configure: it's, not its.
* Doc: syslog-related fixes.Kaz Kylheku2016-02-281-4/+5
| | | | | | * txr.1: Refer to parameter as options, not option, and use .meta consistently. Don't refer to Syslog section in all caps.
* Doc: elsif doesn't exist.Kaz Kylheku2016-02-281-1/+1
| | | | * txr.1: replace nonexistent @(elsif) in example with @(elif).
* Documenting sockets.Kaz Kylheku2016-02-281-0/+572
| | | | * txr.1: Documented.
* Socket streams know their connected peer address.Kaz Kylheku2016-02-273-0/+22
| | | | | | | | | | | | * stream.c (struct stdio_handle): New member, peer. (stdio_stream_mark): Mark the new member. (sock_peer, sock_set_peer): New functions. (stream_init): Registered sock-peer intrinsic. * stream.h (sock_peer, sock_set_peer): Declared. * socket.c (sock_connect): If the connect is successful, then store the address into the stream as the peer.
* Do the SO_REUSEADDR thing when binding socket.Kaz Kylheku2016-02-271-2/+5
| | | | | * socket.c (sock_bind): Set the SO_REUSEADDR option before binding the socket, to thwart the EADDRINUSE nuisance.
* Fix descriptor leak on exception in open-fileno.Kaz Kylheku2016-02-271-1/+3
| | | | | * stream.c (open_fileno): If w_fdopen fails, close the file descriptor before throwing exception.
* open-fileno: errno usage.Kaz Kylheku2016-02-271-1/+1
| | | | * stream.c (open_fileno): clear errno to 0 before fdopen.
* Adding socket support: unix, ipv4, ipv6.Kaz Kylheku2016-02-268-1/+682
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * socket.c, socket.h: New files. * Makefile: include new socket.o among objects if have_objects variable is defined to 'y'. * configure (have_sockets): New variable. New configure test for socket-related functionality. (HAVE_SOCKETS, HAVE_GETADDRINFO): New configuration preprocessor symbols. Also, reordering the shell probing so that /usr/xpg4/bin/sh is the last fallback. On Solaris, it chokes on some code that is needed for Solaris. * lisplib.c (sock_set_entries, sock_instantiate): New static functions. (lisplib_init): Register new functions as autoload hooks. * share/txr/stdlib/socket.tl: New file. * stream.c (socket_error_s): New symbol variable. (struct stdio_handle): New members, family and type, helping stdio streams represent sockets too. (stdio_stream_mark): Mark new members of struct stdio_handle. (make_stdio_stream_common): Initialize new members. (make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): New functions. (stream_init): Initialize socket_error_s variable. Register sock-family, sock-type and open-socket intrinsic functions. Register socket-error subtype. * stream.h (socket_error_s, make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): Declared.
* Place C standard I/O based streams into subtype.Kaz Kylheku2016-02-263-3/+10
| | | | | | | | | | | | | | | | | | | * lib.c (subtypep): Handle subtype check here between stream and stdio-stream as a special case, since streams aren't structures related by inheritance, but built-ins. (class_check): If the type of obj doesn't match the class exactly, use a subtypep check. We need this because stream functions use this check, and stdio streams are not of the stream type now. * stream.c (stdio_stream_s): New global symbol variable. (make_stdio_stream_common): Use stdio_stream_s symbol for the type of stdio streams. (stream_init): Intern the stdio-stream symbol, and store in stdio_stream_s variable. (streamp): Replace exact check with typep. * stream.h (stdio_stream_s): Declared.
* Functions for converting between buffers and integers.Kaz Kylheku2016-02-264-0/+60
| | | | | | | | | | | | | | | | | These functions convert between positive integers, and fixed-size memory buffers representing pure binary numbers in big endian byte order. This functionality will be used in some upcoming networking code. * arith.c (num_from_buffer, num_to_buffer): New functions. * arith.h (num_from_buffer, num_to_buffer): Declared. * mpi/mpi.c (mp_to_unsigned_buf): New function. * mpi/mpi.h (mp_to_unsigned_buf): Declared.
* Adding --eargs mechanism.Kaz Kylheku2016-02-022-2/+103
| | | | | | * txr.c (txr_main): Implement --eargs. * txr.1: Documented.
* Support lazy loading of stdlib struct definitions.Kaz Kylheku2016-01-311-2/+6
| | | | | | | * struct.c (make_struct_type): Use find_struct_type rather than direct lookup in struct_type_hash. (find_struct_type): Use lisplib_try_load if a type is not found to trigger autoloading on the symbol.
* Support setuid operation.Kaz Kylheku2016-01-234-1/+136
| | | | | | | | | | | | | | | | | | | | | * sysif.c (orig_euid, real_uid, repress_called, is_setuid): New static variables. (repress_privilege, drop_privilage, simulate_setuid): New functions. (RC_MAGIC): New preprocessor symbol. * sysif.c (repress_privilege, drop_privilage, simulate_setuid): Declared. * txr.c (txr_main): Call repress_privilege to check and remember whether we are in setuid mode, and temporarily drop the effective uid to the real one. (txr_main): Permanently drop privileges in all cases except script execution. In script execution cases, go through simulate_setuid to either set or preserve the effective user ID, or else drop privs. * txr.1: Documented setuid operation in new section.
* Add debug trace to @(require).Kaz Kylheku2016-01-221-1/+3
| | | | * match.c (v_require): Produce trace when require fails.
* Bugfix: @(require) eval not in proper env.Kaz Kylheku2016-01-221-2/+1
| | | | | | | | | I caught this when doing a @(require (boundp 'var)). * match.c (v_require): The correct evaluation was being done here, with the value discarded, followed by an incorrect evaluation in which the TXR bindings are not visible, whose value *is* then used.
* Semantics fix: unhandled exceptions must still unwind.Kaz Kylheku2016-01-222-36/+43
| | | | | | | | | | | | | | | | | * unwind.c (unhandled_ex): New static structure. (unwind_to_exit_point): The code to print the unhandled exception info and bail the process is moved here out of uw_throw. We do this in the situation when we have an unhandled exception, which is represented by the fact that the exception pointer points to the unhandled_ex structure. (uw_throw): If unhandled hook isn't a function, we don't abort; we go through the unwinding and unhandled processing. Also, ditto if the unhandled function returns, ditto. Unhandled processing is entered by substituting unhandled_ex for the not-found exception, and allowing unwind_to_exit point to be called. * txr.1: Document new behavior for unhandled exceptions and *unhandled-hook*.
* Header file cleanup.Kaz Kylheku2016-01-2217-44/+0
| | | | | | | * arith.c, cadr.c, debug.c, eval.c, filter.c, gencadr.txr, glob.c, hash.c, linenoise/linenoise.c, lisplib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Remove unncessary header files.
* Reduce header pollution caused by mpi.h.Kaz Kylheku2016-01-224-7/+12
| | | | | | | | | | | | | * eval.c: include <assert.h> that was previously coming via "mpi.h". * mpi/mpi.c: Includes of <stdio.h>, <ctype.h> and <assert.h> moved here. * mpi/mpi.h: Remove include of <stdio.h>, <ctype.h> and <assert.h>. Keeping <limits.h> for now; needed for CHAR_BIT. * mpi/mplogic.c: Needs <assert.h>
* Version 133.txr-133Kaz Kylheku2016-01-216-560/+586
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Support for Base 64 encoding.Kaz Kylheku2016-01-213-1/+208
| | | | | | | | | | | | | * filter.c (tobase64_k, frombase64_k): New keyword symbol variables. (col_check, get_base64_char, b64_code): New static functions. (base64_decode, base64_encode): New functions. (filter_init): Initialize new keyword symbol variables, and register base64-encode and base64-decode intrinsic functions. * filter.h (base64_encode, base64_decode): Declared. * txr.1: Documented base64-encode, base64-decode, as well as :tobase64 and :frombase64.
* bugfix: cached sigmask not populated from OS sigmask.Kaz Kylheku2016-01-191-3/+3
| | | | | | | | | | | | | | | This is responsible for behaviors like Ctrl-C being subsequently ignored after the first time a read is interrupted that way. * signal.c (sig_reload_cache): Eliminate the return statement which was making the memcpy expression unreachable! No warning from gcc. Also, since nobody checks the return value of this function and it doesn't provide one, let's make it void. There is no reason the sigprocmask would fail since the arguments are correct, but let's check its return value anyway.
* Add missing txr words to syntax highlighting.Kaz Kylheku2016-01-191-1/+2
| | | | | | * genvim.txr: Add missing single, first, last and other output repeat modifiers. Removing rep, since it's scraped from the table registration in match.c.
* Grammar fix under string quasiliterals.Kaz Kylheku2016-01-191-1/+1
| | | | * txr.1: "variables substitutions".
* Grammar fix under cadr function.Kaz Kylheku2016-01-191-1/+1
| | | | * txr.1: "They encodes" fixed.
* Fix regression: get-char on string input stream.Kaz Kylheku2016-01-191-2/+3
| | | | | | | | | | This happened on 2015-07-29, before TXR 111, "Deriving streams from the same base" commit. * stream.c (string_in_get_char): Must retrieve the character at the previous position, not the incremented one. Otherwise we lose the first character, and of course we blow up with an out of range access when we hit the end of the string.
* Relax input type constraint in vec-list.Kaz Kylheku2016-01-181-4/+1
| | | | | | | * lib.c (vec_list): Don't require input to be specifically a list, just any sequence that can be marched with cdr until nil. This commit also fixes the problem that the error message was still referring to the function as vector-list.
* New random-state-get-vec function.Kaz Kylheku2016-01-188-15/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | * arith.c (UINT_PTR_MAX_MP): New static variable. (biggnum_from_uintptr): New function. (in_uint_ptr_range): New static function. (c_uint_ptr_num): New function. (arith_init): Initialize UINT_PTR_MAX_MP. * arith.h (bignum_from_uintptr, c_uint_ptr_num): Declared. * eval.c (eval_init): Register random-state-get-vec. * mpi/mpi.c (mp_set_uintptr, mp_get_uintptr): New functions. (mp_set_intptr, mp_get_intptr): Expressed in terms of mp_set_uintptr and mp_get_uintptr. * mpi/mpi.h (mp_set_uintptr, mp_get_uintptr): Declared. * rand.c (make_random_state): Handle vector seed. (random_state_get_vec): New function. * rand.h (random_state_get_vec): Declared. * txr.1: Documented new feature in make-random-state and new random-state-get-vec function.
* random: wrong mask width for power-of-two moduli.Kaz Kylheku2016-01-184-61/+67
| | | | | | | | | | | | | | | | | | | | | | | This mistake causes wasteful behavior for power-of-two moduli in the random function, in both the bignum and fixnum cases. For instance, the modulus 16 is taken to be 17 bits wide. But we really want the width 16: the number of bits needed for values in the range [0, 16). The result isn't wrong, but the loop generates 17-bit random numbers, and then throws away those which equal or exceed the modulus, which is wasteful. * mpi/mpi.c (mp_is_pow_two): New function. * mpi/mpi.h (mp_is_pow_two): Declared. * rand.c (random): In bignum case, after counting bits in the modulus, subtract 1 if the modulus is a power of two. In the fixnum case, subtract 1 from the modulus and then count the bits in the reduced value. * tests/013/maze.expected: regenerate due to different prng behavior.
* Don't allow non-positive modulus in rand and random.Kaz Kylheku2016-01-182-20/+29
| | | | | | | | | | * rand.c (random): In fixnum case, allow only m >= 1. The code is restructured so that this check is done before we do some arithmetic with derived values, where the behavior can become undefined. * txr.1: Document the restriction on modulus range for rand and random.
* New function, split*.Kaz Kylheku2016-01-174-8/+63
| | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register split*. * lib.c (split_star_func): New static function. (partition_split_common): Take pointer-to-function argument instead of boolean. Hoist this C function into the lazy cons. (partition): Pass pointer to partition_func ito partition_split_common, intsead of a flag requesting the use of partition_func. (split): Pass apointer to split_func into partition_split_common. (split_star): New function. * lib.h (split_star): Declared. * txr.1: Documented split*.
* Fix incorrect split examples.Kaz Kylheku2016-01-171-3/+3
| | | | | | | * txr.1: examples were calling split as if it were variadic, accepting multiple indices as separate arguments. This is not the case; a sequence of indices must be passed as one argument.
* partition* bugfix: ignore negative indices consistently.Kaz Kylheku2016-01-171-9/+14
| | | | | * lib.c (partition_star): Eliminate strange behaviors when a negative index is given as an argument.
* partition* bugfix: incorrect behavior for 0.Kaz Kylheku2016-01-171-1/+1
| | | | | | | lib.c (partition_star): In the special case that the indices argument is given as the integer zero, the function wrongly returned just the remaining piece of the sequence after zero, rather than a list containing this piece.
* Apply partition/split bugfix to partition*.Kaz Kylheku2016-01-171-4/+4
| | | | | | * lib.c (partition_star): The same issues that were addressed in TXR 126 in 2015-11-29 commits and 2015-11-24 commits must also be addressed here.
* Bugfix: env-hash discarding characters after =.Kaz Kylheku2016-01-171-2/+5
| | | | | * sysif.c (make_hash): Fix incorrect treatment of env values which contain equal signs, due to careless use of split_str.
* Version 132.txr-132Kaz Kylheku2016-01-156-549/+573
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Retroactively fix recent inconsistent formatting.Kaz Kylheku2016-01-151-10/+10
|
* New :mandatory keyword in until/last clauses.Kaz Kylheku2016-01-154-24/+132
| | | | | | | | | | | | | | | | | | | * match.c (mandatory_k): New keyword variable. (h_coll, v_gather, v_collect): Implement :mandatory logic. (syms_init): Initialize mandatory_k. * parser.l (grammar): The UNTIL and LAST tokens must be matched similarly to collect, without consuming the closing parenthesis, allowing a list of items to be parsed between the symbol and the closure, in the NESTED state. * parser.y (gather_clause, collect_clause, elem, repeat_parts_opt, rep_parts_opt): Adjust to new until/last syntax. In the matching productions, the abstract syntax changes to incorporate the options. In the output productions, we throw an error if options are present. * txr.1: Documented :mandatory for collect, coll and gather.
* Gather bugfix: support empty :vars.Kaz Kylheku2016-01-151-2/+5
| | | | | | | | * match.c (v_gather): Use getplist_f to distinguish the :vars nil case just like v_collect does. A :vars nil gather could be useful; it says none of the variables are strictly required. In any case, it is not correct to treat :vars nil as if :vars weren't there.
* Bugfix: *print-flo-format* used for integer output.Kaz Kylheku2016-01-141-0/+2
| | | | | * lib.c (obj_print_impl): Handle NUM and BGNUM separately from FLNUM, thorugh a hard-coded "~s" format.
* Improve n-ary minus like newly added division.Kaz Kylheku2016-01-141-3/+13
| | | | | | * lib.c (minusv): Avoid reduce_left overhead in common two-argument case, and just call binary minus function directly.
* Optimization in n-ary numeric functions.Kaz Kylheku2016-01-141-5/+12
| | | | | * lib.c (nary_op): Avoid the overhead of reduce_left in the two-argument case and just call the binary function.
* Fix omission: the / function becomes n-ary.Kaz Kylheku2016-01-134-3/+25
| | | | | | | | | | * eval.c (eval_init): Register / function to divv instead of divi. * lib.c (divv): New function. * lib.h (divv): Declared. * txr.1: Documented.
* bugfix: no location info for unbound var in dohash.Kaz Kylheku2016-01-131-5/+5
| | | | | | | * eval.c (do_expand): Add missing rlcp in the construction of the return value of the clause which expands a dohash. Let's make it a rlcp_tree. Test case: (dohash (a b c) d e) with c unbound.