summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Timeout parameter in sock-accept.Kaz Kylheku2016-03-152-8/+48
| | | | | | | | | | * socket.c (sock_accept): New third parameter specifying timeout. If a timeout is specified, use the select function to select socket for reading, datagram or stream. (sock_load_init): Update registration of sock-accept intrinsic to three arguments, one optional. * txr.1: Documented sock-accept's timeout parameter.
* Make connect interruptible and support timeout.Kaz Kylheku2016-03-152-4/+75
| | | | | | | | | | * socket.c (to_connect): New static function. (sock_connect): Use to_connect instead of calling connect directly. (lock_load_init): sock-connect intrinsic registration updated to three arguments, one optional. * txr.1: Documented sock-connect timeout.
* Bugfix: set errno to zero in stdio_unget_byte.Kaz Kylheku2016-03-151-0/+1
| | | | | | * stream.c (stdio_unget_byte): Set errno to zero before ungetc, because ungetc probably almost certainly doesn't set errno when it fails.
* Implement socket timeouts.Kaz Kylheku2016-03-156-2/+80
| | | | | | | | | | | | | | | | | * lib.c (timeout_error_s): New symbol variable. (obj_init): Intern timeout-error, init new variable. * lib.h (timeout_error_s): Declared. * socket.c (sock_timeout, sock_send_timeout, sock_recv_timeout): New static functions. (sock_load_init): Register sock-send-timeout and sock-recv-timeout intrinsics. * stream.c (stdio_maybe_read_error, stdio_maybe_error): Convert EAGAIN into timeout_error_s. * txr.1: Documented.
* Bad formatting under sock-shutdown.Kaz Kylheku2016-03-151-0/+1
| | | | * txr.1: Missing .desc macro.
* @(output)_destination can be a stream.Kaz Kylheku2016-03-142-27/+37
| | | | | | | | | | * match.c (complex_open): If name is a stream object, just return it. (v_output): Do not close the output stream if it came from a destination expression specifying an existing stream, and thus wasn't created inside complex_open. * txr.1: Document stream destination in output directive.
* sock-connect return value change.Kaz Kylheku2016-03-142-2/+2
| | | | | | | * socket.c (sock_connect): return a useful value rather than t, namely the socket. * txr.1: Documented.
* All stdio streams get line buffering with i mode.Kaz Kylheku2016-03-143-6/+21
| | | | | | | | | | | * socket.c (open_sockfd): We no longer need to set stream sockets to line buffered mode here; it's done in set_mode_props. * stream.c (set_mode_props): If the mode specifies interactive, streams open for writing are also switched to line buffering. * txr.1: Documented under open-file, and open-socket.
* Obsolete statement about datagram sockets in doc.Kaz Kylheku2016-03-141-2/+0
| | | | | * txr.1: Datagram sockets don't use stdio streams any more, and do not use full buffering.
* Version 135.txr-135Kaz Kylheku2016-03-106-596/+627
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Workaround for apparent putc bug in Cygwin.Kaz Kylheku2016-03-101-0/+7
| | | | | | | | | | | This fix is required for the stream socket test case to pass. Some interaction between a stdio stream in line buffering mode and the putc function causes a stream to lose data. If we use fputs instead to output a character, the issue goes away. * stream.c (se_putc): When compiling for Cygwin, construct a one-character-long string and use fputs, rather than putc.
* Run IPv6 tests only on some operating systems.Kaz Kylheku2016-03-102-4/+11
| | | | | | | | | | * tests/014/dgram-stream.tl (test): Renamed to dgram-test since now this includes common.tl which has a macro called test. Only include af-inet6 in the family list if the OS is GNU/Linux, Darwin or Cygwin. * tests/common.tl (osname): New function.
* Mac OS X: must clear sockaddr in order to bind.Kaz Kylheku2016-03-101-0/+2
| | | | | | | | | | Undocumented members in struct sockaddr_in, and possibly sockaddr_in6 also, must be cleared to all zero bits, otherwise bind fails for the loopback address, even if the relevant addressing members are correctly set. * socket.c (sockaddr_in): memset the IPv4 or IPv6 address to zero before filing it.
* Solaris: cannot sendto on connected dgram socket.Kaz Kylheku2016-03-101-2/+8
| | | | | | | | * socket.c (struct dgram_stream): New member, sock_connected. (make_dgram_sock_stream): Initialize sock_connected to zero. (dgram_flush): Use send if sock_connected is nonzero, otherwise sendto. (dgram_set_sock_peer): Set sock_connected to 1.
* Documenting datagram streams.Kaz Kylheku2016-03-091-0/+99
| | | | | * txr.1: Briefly introduce datagram streams in sockets overview and describe in more detail in special section.
* Bugfix in setenv: default argument handling.Kaz Kylheku2016-03-081-1/+1
| | | | | | | * sysif.c (setenv_wrap): We must use default_arg_strict, not default_arg, because default_arg treats a nil value as missing. We do not want to replace an explicit nil with the default t.
* Allow nil value in setenv.Kaz Kylheku2016-03-082-3/+51
| | | | | | | * sysif.c (setenv_wrap): If value is nil, and overwrite is missing or t, call unsetenv. * txr.1: Documented.
* Record adapter passes through socket ops.Kaz Kylheku2016-03-071-0/+29
| | | | | | | * stream.c (delegate_get_sock_family, delegate_get_sock_type, delegate_get_sock_peer, delegate_set_sock_peer): New static functions. (stream_init): Wire new functions in record_adapter_ops.
* Diagnose operations on closed socket.Kaz Kylheku2016-03-071-23/+42
| | | | | * socket.c (sock_bind, sock_connect, sock_listen, sock_accept): If the socket is closed, throw an error.
* Revamped naming for socket streams.Kaz Kylheku2016-03-073-10/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * socket.c (struct dgram_stream): New member, addr. (make_dgram_sock_stream): Initialize addr to nil. (dgram_print): Instead of printing the numeric fd, print the stream description, obtained from the name_k property. (dgram_mark): Mark the addr member. (dgram_get_prop): Calculate a descriptive string from the dgram stream state for the name_k property. (dgram_set_prop): New static function. (dgram_strm_ops): Name change to dgram-sock. Wire in dgram_set_prop function. (sock_bind): Set the addr_k property of the stream to the local address that was just bound. * stream.c (addr_k): New keyword symbol variable. (stdio_handle): New member, addr. (stdio_stream_print): Obtain descr by calling get_prop method rather than directly from h->descr, in case it is dynamically computed. Use ~a rather than ~s for incorporating string properties into printed form, to eliminate quotes. (stdio_stream_mark): Mark new addr member. (sock_get_prop, sock_set_prop): New static functions. (stdio_set_sock_peer): Invalidate h->descr by setting it to nil. (make_stdio_stream_common): Initialize h->addr to nil. (make_sock_stream): Specify description as nil rather than "socket". (stream_init): Intern the addr keyword, and initialize the addr_k variable. Set the name of stdio_sock_ops to "stream-sock" rather than leaving it inherited as "file-stream". Wire in the sock_get_prop and sock_set_prop functions into stdio_sock_ops. * stream.h (addr_k): Declared.
* sock_accept: uninitialized socklen_t.Kaz Kylheku2016-03-071-1/+1
| | | | | * socket.c (sock_accept): The address length passed to recvfrom was not initialized to the storage length.
* Dgram test: multiple transfers on one stream, IPv6.Kaz Kylheku2016-03-072-0/+39
| | | | | | * tests/014/dgram-stream.tl: New file. * tests/014/dgram-stream.expected: New file.
* Formatting under make-struct.Kaz Kylheku2016-03-071-1/+1
| | | | * txr.1: Syntax issue.
* Basic regression test case for sockets.Kaz Kylheku2016-03-074-0/+45
| | | | | | | | | | * Makefile: suppress --gc-debug for tst/tests/014 directory. * tests/014/socket-basic.tl: New file. * tests/014/socket-basic.expected: New file. * tests/sock-common.tl: New file.
* gc bugs: more instances of wrong mutations.Kaz Kylheku2016-03-072-2/+2
| | | | | | | | * socket.c (dgram_set_sock_peer): Assign to struct dgram_stream using using set macro. * stream.c (stdio_set_sock_peer): Assign to struct stdio_handle peer using set macro.
* gc bug: prepared_msg field of struct parser.Kaz Kylheku2016-03-071-1/+2
| | | | | | | * parser.l (yyerrprepf): Replace wrong bare assignment to parser->prepared_msg with proper set macro which handles the mutation of a mature generation object such that it points to a baby object.
* Show failing address in sock-connect error.Kaz Kylheku2016-03-071-2/+2
| | | | | * socket.c (sock_connect): If connect fails, show socket and address in error message.
* Bugfix: incorrect error string from stdio streams.Kaz Kylheku2016-03-071-1/+1
| | | | | | | * stream.c (errno_to_string): Fix wrong test; it is a nil value of err which is the "no error" case, not non-nil. Due to this bug, any non-numeric error condition will be reported as "no error", including the case t ("eof").
* Fix signed/unsigned warning from g++.Kaz Kylheku2016-03-061-1/+1
| | | | | * sysif.c (repress_called, is_setuid): Change to unsigned int, so comparison with RC_MAGIC constant doesn't elicit warning
* Special implementation of dgram socket streams.Kaz Kylheku2016-03-063-60/+494
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * socket.c (struct dgram_stream): New struct. (make_dgram_sock_stream, dgram_print, dgram_mark, dgram_destroy, dgram_overflow, dgram_put_byte_callback, dgram_put_string, dgram_put_char, dgram_put_byte, dgram_get_byte_callback, dgram_get_char, dgram_get_byte, dgram_unget_char, dgram_unget_byte, dgram_flush, dgram_close, dgram_get_prop, dgram_get_fd, dgram_get_sock_family, dgram_get_sock_type, dgram_get_sock_peer, dgram_set_sock_peer, dgram_get_error, dgram_get_error_str, dgram_clear_error): New static functions. (dgram_strm_ops): New static structure. (sock_listen): Check against datagram sockets which have a peer; otherwise a no-op for datagram sockets. (sock_accept): Special logic for dgram sockets. (open_sockfd): Function moved here from stream.c, and augmented to open dgram stream for dgram sockets. (open_socket): Function moved here from stream.c. (sock_load_init): Fill in some operations in dgram_strm_ops. * stream.c (generic_get_line, make_sock_stream, errno_to_string): Statics become external. (open_sockfd, open_socket): Functions removed from here, moved to socket.c. * stream.h (generic_get_line, make_sock_stream, errno_to_string): Declared.
* Refer to correct socket function names in errors.Kaz Kylheku2016-03-061-3/+3
| | | | | | * socket.c (sock_bind, sock_connect, sock_listen): Report function name as sock-bind, sock-connect and sock-listen, rather than bind, connect and listen.
* Bugfix: get-string closing stream when told not to.Kaz Kylheku2016-03-061-1/+1
| | | | | | * stream.c (get_string): Use default_arg_strict instead of default_arg, so that the t value is only substituted for a missing argument, not for a nil argument.
* Move error check from operation to wrapper.Kaz Kylheku2016-03-061-3/+2
| | | | | | * stream.c (stdio_unget_char): Remove not-a-character check from character argument. (unget_char): Perform check here, thus for all stream types.
* Access to file descriptor now via stream virtual.Kaz Kylheku2016-03-063-18/+49
| | | | | | | | | | | | | | | | | | | | | | | | | * stream.c (unimpl_get_fd, null_get_fd): New static functions. (fill_stream_ops): Set up get_fd function pointer in strm_ops. (null_ops): Add null_get_fd. (stdio_get_fd): New static function. (stdio_ops, tail_ops, pipe_ops): Specify stdio_get_fd as get_fd function. (stream_fd): Rewritten as call to get_fd operation. (dir_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, cat_stream_ops): Specify null as get_fd function, to be defaulted by fill_stream_ops. (delegate_get_fd): New static function. (record_adapter_ops): Specify delegate_get_fd as get_fd function. (stream_init): Change fileno intrinsic registration to point to stream_fd function. * stream.h (struct strm_ops): New member, get_fd. (strm_ops_init): New macro parameter, get_fd. * syslog.c (syslog_strm_ops): Specify null as get_fd function.