summaryrefslogtreecommitdiffstats
path: root/stream.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Count East Asian Wide and Full Fidth chars as two columns.Kaz Kylheku2015-08-101-4/+5
| | | | | | | | | | | | | | | | | * regex.c (create_wide_cs): New static function. (wide_display_char_p): New function. * regex.h (wide_display_char_p): Declared. * stream.c (put_string, put_char): Use wide_display_char_p to determine whether an extra column need be counted. Also bugfix: iswprint evidently cannot be relied to work over the entire Unicode range, at least not in the C locale. Glibc's version and is reporting valid Japanese characters as unprintable on Ubuntu. As a hack we instead check for control characters and invert the result: control chars are unprintable. * tests/009/json.expected: Updated.
* C++ upkeep: conversions, clashes, warnings.Kaz Kylheku2015-08-071-1/+1
| | | | | | | | | * glob.c (glob_wrap): Fix signed/unsigned comparison. * stream.c (make_null_stream): Fix convert beign used where coerce is needed. * sysif.c (dup_wrap): Fix use of C++ new keyword.
* * stream.c: Include <wctype.h> header for iswprint.Kaz Kylheku2015-08-071-0/+1
| | | | Needed on Cygwin.
* * stream.c (stream_init): Register get-indent-mode, set-indent-mode,Kaz Kylheku2015-08-051-0/+11
| | | | | | | | test-set-indent-mode, get-indent, set-indent, inc-indent and width-check intrinsic functions. Register indent-off, indent-data and indent-code variables. * txr.1: Documented stream output indentation API.
* * stream.c (width_check): Just use the publicKaz Kylheku2015-08-051-11/+4
| | | | | put_char function; no need to manipulate column or call put_indent.
* * stream.c (put_string): In indent mode, put_string hasKaz Kylheku2015-08-041-6/+7
| | | | | | | | to process all the characters as if by put_char, (which we now do literally that way). (set_indent_mode): Bugfix: no longer reset the column to zero when turning off indent mode. This is wrong since streams do column counting all the time.
* * stream.c (vformat): Implement ~! format directive for indentation.Kaz Kylheku2015-08-041-7/+37
| | | | | | | Allow negative widths to be specified with a leading minus sign, so that we can indent to the left. * txr.1: Document ~! format directive.
* * stream.c (put_string, put_char): Do not put out the indentationKaz Kylheku2015-08-041-2/+13
| | | | | immediately after outputting a newline. Rather, delay the output of the indentation until some output occurs at column zero.
* * stream.c (inc_indent): If a negative indentation increment goes belowKaz Kylheku2015-08-041-0/+4
| | | | | zero, clamp it at zero. (set_indent): Clamp indentation value to zero.
* * stream.c (vormat): Bugfix: when width specified as *Kaz Kylheku2015-08-041-1/+1
| | | | | | meets a negative argument, the width should be treated as positive and the field left aligned. Instead, the width is treated as zero.
* * stream.c (string_out_put_string): Do not return nil whenKaz Kylheku2015-08-041-2/+4
| | | | buffer calculations overflow, but throw exception.
* Remove useless return values and checks.Kaz Kylheku2015-08-041-78/+41
| | | | | | | | | | | | | | | * stream.c (vformat_align_pre, vformat_align_post): Change to void return. Do not check return value of put_char. (vformat_num, vformat_str): Change to void return. Do not check return value of vformat_align_pre, vformat_aign_post or put_char. (vformat): Do not check return value of vformat_str or vformat_num. nilout exit point no longer needed. (put_string): Do not intercept return value of ops->put_string. Return t. (put_char): Do not intercept return value of ops->put_char. Do not check return value of put_indent. Return t. * txr.1: Document t return of put-char, put-byte and put-string.
* * stream.c (indent_mode_put_string): Function removed,Kaz Kylheku2015-08-041-17/+4
| | | | | | | logic hoisted into put_string. (put_string, put_char): Always count column, indent mode or not. * tests/009/json.expected: Updated.
* Pass pretty flag to cobj print operation.Kaz Kylheku2015-08-011-3/+8
| | | | | | | | | | | | | | | | | | | | | * hash.c (hash_print_op): Take third argument, and call cobj_print_impl rather than cobj_print. * lib.c (cobj_print_op): Take third argument. The object class is * printed with obj_print_impl. (obj_print_impl): Static function becomes extern. Passes its pretty flag argument to cobj print virtual function. * lib.h (cobj_ops): print takes third argument. (cobj_print_op): Declaration updated. (obj_print_impl): Declared. * regex.c (regex_print): Takes third argument, and ignores it. * stream.c (stream_print_op, stdio_stream_print, cat_stream_print): Take third argument, and ignore it. * stream.h (stream_print_op): Declaration updated.
* string_output renamed to string_outKaz Kylheku2015-07-311-8/+8
| | | | | | | * stream.c (struct string_output): Renamed to string_out. (string_out_stream_destroy, string_out_byte_callback, string_out_put_char, strnig_out_put_string, string_out_put_byte, make_string_output_stream, get_string_from_stream): Follow rename.
* Simplify type check code in stream module.Kaz Kylheku2015-07-311-191/+100
| | | | | | | | | | | | | | | * stream.c (get_string_from_stream, get_list_from_stream, stream_set_prop, stream_get_prop, close_stream, get_line, get_char, get_byte, unget_char, unget_byte, put_string, put_char, put_byte, flush_stream, seek_stream): Use cobj_handle and cobj_ops instead of type_check and type_assert. (get_indent_mode, test_set_indent_mode, set_indent_mode, get_indent, set_indent, inc_indent, width_check): Use cobj_handle and cobj_ops instead of stream->co.handle and stream->co.ops for safety. (vformat, format): Use class_check instead of type_check and type_assert.
* Multi-line, indented printing of structure.Kaz Kylheku2015-07-311-3/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (op_error): New static function. (macro_form_p, fboundp): Static to external. (special_operator_p): New function. (eval_init): Register macrolet and symacrolet to op_error. These are recognized and processed by expand, but we want them in the op table so they are reported by special_operator_p. * eval.h (fboundp, macro_form_p, special_operator_p): Declared. * hash.c (print_key_val): Break long lines on spaces between pairs with stream_width_check. (hash_print_op): Implement split and indented printing. * lib.c (obj_print_impl): New static function, resulting from a merge of obj_print and obj_pprint. Fixes some wrong-way recursion bugs: obj_pprint recursed into obj_print in some places. Adds support for multi-line printing of vectors and lists, with indentation using the new interfaces in streams. * stream.c (strm_base_init): Update initializer. (put_indent, indent_mode_put_string): New static functions. (put_string): Use indent_mode_put_string in either of the two indent modes. (put_char): Implement indent mode. (get_indent_mode, test_set_indent_mode, set_indent_mode, get_indent, set_indent, inc_indent, width_check): New functions. * stream.h (enum indent_mode): New. (struct strm_base): indent_on member becomes indent_mode. New members data_width and code_width. (get_indent_mode, test_set_indent_mode, set_indent_mode, get_indent, set_indent, inc_indent, width_check): Declared. * tests/009/json.expected: Updated. * tests/010/seq.expected: Likewise. * tests/011/macros-2.expected: Likewise.
* Deriving streams from the same base, soKaz Kylheku2015-07-291-106/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | we can give streams some common slots. * stream.c (strm_base_init, strm_base_cleanup, strm_base_mark, stream_destroy_op, stream_mark_op): New functions. (null_ops): Switch to stream_destroy_op and stream_mark_op. (make_null_stream): Associate a strm_base instance with the cobj handle rather than a null pointer. (struct stdio_handle): Inherit struct strm_base. (stdio_stream_destroy): Clean up the strm_base part. (stdio_stream_mark): Mark the strm_base part. (make_stdio_stream_common): Initialize the strm_base part. (struct dir_handle): Inherit struct strm_base. (dir_destroy): Clean up the strm_base part. (dir_mark): Mark the strm_base part. (make_dir_stream): Initialize the strm_base part. (struct string_in): New structure. Replaces ad-hoc cons cell used for string input streams. (string_in_stream_mark): Mark new structure. (string_in_get_line, string_in_get_char, string_in_unget_char, string_in_get_prop, string_in_get_error, make_string_input_stream): Convert to new structure. (string_in_ops): Switch to stream_destroy_op. (struct byte_input): Inherit struct strm_base. (byte_in_stream_destroy): No need to check handle for null. No need to set handle to null after freeing: gc does it. Clean up the strm_base part. (byte_in_ops): Switch to stream_mark_op. (make_string_byte_input_stream): Initialize the strm_base part. (struct string_output): Inherit struct strm_base. (string_out_stream_destroy): No need to check handle for null since the logic elsewhere has changed. Clean up the strm_base part. No need to set handle to null. (string_out_ops): Switch to stream_mark_op. (make_string_output_stream): Initialize the strm_base part. (get_string_from_stream): Don't free the handle. Null out the buffer so->buf whose ownership passes to the string. (struct strlist_out): New structure. Replaces ad-hoc cons cell used for string list output stream. (strlist_mark): Renamed to strlist_out_mark. Mark the strm_base part. (strlist_out_put_string, strlist_out_put_char, make_strlist_output_stream, get_list_from_stream): Convert to new structure. (strlist_out_ops): Switch to stream_destroy_op. Follow rename of strlist_mark. (struct cat_strm): New structure, replacing ad-hoc list pointer
* * stream.c (common_destroy): Function removed.Kaz Kylheku2015-07-291-7/+2
| | | | (stdio_stream_destroy, dir_destroy): Call close_stream directly.
* * stream.c: Rearranging definitions and declarations so thatKaz Kylheku2015-07-291-432/+431
| | | | | | code for each stream type is together. Moving catenated streams above utility functions, so they are together with other stream definitions.
* Centered fields in format.Kaz Kylheku2015-07-281-25/+69
| | | | | | | | | | | | * stream.c (enum align): New enum. (vformat_align_pre, vformat_align_post): New static functions. (vformat_num, vformat_str): Argument left renamed to align, and changed to enum align. vformat_align_pre and vformat_align_post are called to generate the correct padding for left, center and right alignment. (vformat): Two-valued local variable left turned into three-valued align. The ^ prefix on the width field is recognized. * txr.1: Documented ^ width prefix.
* * stream.c (byte_in_unget_byte): Wrong function name in error message.Kaz Kylheku2015-07-101-1/+1
|
* Fix unget-byte and unget-char on catenated streams.Kaz Kylheku2015-07-101-2/+2
| | | | | * stream.c (cat_unget_byte, cat_unget_char): Recursive call to unget_byte and unget_char with reversed arguments.
* Improved printing of stream objects.Kaz Kylheku2015-07-071-16/+38
| | | | | | | | | | | | | | | | | | | | | * stream.c (null_stream_print): Static function removed. (stream_print_op): New function. Prints stream's name and address. (null_get_prop): Pull stream name from strm_ops structure rather than hard-coding to "null-stream". (null_ops, stdio_ops, tail_ops, pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops, cat_stream_ops): Use stream_print_op in place of cobj_print_op. Initialize name. (stdio_stream_print): Use name from ops structure, and include object address. (string_in_get_prop): Likewise. (cat_stream_print): Likewise. * stream.h (struct strm_ops): New member, name. (strm_ops_init): Initialize name. (stream_print_op): Declared. * syslog.c (syslog_strm_ops): Use stream_print_op. Initialize name.
* Bugfix in printed rep of stdio stream.Kaz Kylheku2015-07-061-2/+3
| | | | | | * stream.c (stdio_stream_print): Wrong way test on h->pid; if it is nonzero it must be printed. Was printed wrong: argument of integer type passed to ~s which expects a val.
* Clarify clear-error and flush return value.Kaz Kylheku2015-07-061-16/+7
| | | | | | | | | | | * stream.c (stdio_clear_error): Return the prior value of h->err. Do not inspect feof(h->f) or ferror(h->f); just clear the error status of the stream. (stdio_close): Set h->err from errno if fclose failed. (dir_clear_error): Return prior value of h->err. * txr.1: Document return value convetion for clear-error, and flush-stream.
* Tightening behavior for unimplemented stream ops.Kaz Kylheku2015-07-061-25/+208
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In many cases, if a stream operation is not applicable to a stream, it is not appropriate to just do nothing and return nil. An error must be thrown. * stream.c (unimpl, unimpl_put_string, unimpl_put_char, unimpl_put_byte, unimpl_get_line, unimpl_get_char, unimpl_get_byte, unimpl_unget_char, unimpl_unget_byte, unimpl_seek, null_put_string, null_put_char, null_put_byte, null_get_line, null_get_char, null_get_byte, null_close, null_flush, null_seek, null_set_prop, null_get_error, null_get_error_str, null_clear_error): New static functions. (fill_stream_ops): New function. (null_ops): Use null_put_string, etc., instead of null pointers. (stdio_clear_error, dir_clear_error, cat_clear_error): Return value now indicating whether an error was cleared. (stream_set_prop, stream_get_prop, real_time_stream_p, close_stream, get_error, get_error_str, clear_error, get_line, get_char, get_byte, unget_char, unget_byte, put_string, put_char, put_byte, flush_stream): Do not test whether a function in the ops table is defined; just call it, and return its value. (stream_init): Call fill_stream_ops on all stream operation structures so any null pointers are defaulted to appropriate functions. * stream.h (struct strm_ops): clear_error gets return value. (fill_stream_ops): Declared. * syslog.c (syslog_init): Call fill_stream_ops on syslog_strm_ops.
* * stream.c (catenated_stream_p, catenated_stream_push): New functions.Kaz Kylheku2015-06-071-0/+24
| | | | * stream.h (catenated_stream_p, catenated_stream_push): Declared.
* Fix escaping issues in open-process on Windows.Kaz Kylheku2015-04-151-12/+47
| | | | | | | | | | | | | | | This can now execute programs with spaces in their path names. Arguments can contain embedded double quotes, and other characters that are special to cmd.exe, like &, |, (, ), ^ and others. * stream.c (string_extend_count, win_escape_cmd): New static functions. (win_escape_arg): Fix and extend escaping scheme to cover not only the argument processing scheme implemented by programs which use Microsoft's C library, but also to smuggle the command line through cmd.exe. (win_make_cmdline): Use win_escape_cmd to wrap the command. Escape the quotes which are placed around arguments, so cmd.exe doesn't interpret them, which will cause it to suppress its processing of the caret escapes.
* Functions open-fileno and fileno.Kaz Kylheku2015-04-101-1/+20
| | | | | | | | | | | | | | | | * stream.c (fd_k): New keyword variable. (stdio_get_prop): Handle the :fd property by returning the file descriptor. (open_fileno): New function. (stream_init): Initialize fd_k, and register fileno and open-fileno. * stream.h (open_fileno): Declared. * txr.1: Documented open-fileno and fileno. * utf8.c (w_fdopen): New function. * utf8.h (w_fdopen): Declared.
* * stream.c (vformat): Bugfix: ~X printing in lower case, like ~x,Kaz Kylheku2015-03-301-1/+1
| | | | when argument is a bignum integer.
* New -n option. New "i" mode letter in file opening functions.Kaz Kylheku2015-03-291-10/+137
| | | | | | | | | | | | | | | | | | | | | | | | * stream.c (struct stdio_mode): New struct type. (stdio_mode_init_trivial): New initializer macro. (parse_mode, format_mode, normalize_mode, set_mode_props): New static functions. (make_stdio_stream_common): the isatty check, and automatic marking of tty device streams as real-time is no longer done, unless backward compatibility 105 or earlier is requested. (open_file, open_tail, open_command, open_process): Use new mode parsing, which supports the "i" flag. (stream_init): If we have isatty, and standard input is a tty, then mark the *std-input* stream as real-time. * txr.1: Document -n/--noninteractive option. Fix typo where real-time-stream-p is referred to as stream-real-time-p. Document "i" flag on open-file and others. * txr.c (opt_noninteractive): New global. (help): Help text for -n/--noninteractive. (txr_main): Handle new options. * txr.h (opt_noninteractive): Declared.
* * stream.c (run): In Windows version, fix nasty corruption bug:Kaz Kylheku2015-03-111-2/+0
| | | | | we were freeing C strings that were not duplicated, but only borrowed from string objects.
* * stream.c (open_process, run, sh): Eliminate utf8name local variableKaz Kylheku2015-03-111-10/+6
| | | | | and associated memory leak. Correctly allocate only nargs + 1 elements for argv array, not nargs + 2.
* Introducing persistent error state on streams.Kaz Kylheku2015-02-251-27/+208
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (cobj_ops): New function. * lib.h (cobj_ops): Declared. * stream.c (null_ops): Initializer updated. (struct stdio_handle): New member, err. (stdio_stream_mark): Mark the err member. (errno_to_string): New static function. (stdio_maybe_read_error, stdio_maybe_error): Set persistent error state. Use errno_to_string_function. (stdio_put_string, stdio_put_char, stdio_put_byte, stdio_seek, stdio_get_line): Set errno to zero, so that if the underlying operations do not set errno on err, we don't misinterpret some pervious errno value as pertaining to the failed stream operation. (stdio_get_error, stdio_get_error_str, stdio_clear_error): New static functions. (stdio_ops, tail_ops, pipe_ops): Update initializer with new functions. (string_in_get_error, string_in_get_error_str): New static functions. (string_in_ops): Update initializer with new functions. (byte_in_get_error, byte_in_get_error_str): New static functions. (byte_in_ops): Update initializer with new functions. (string_out_ops, strlist_out_ops): Update initializer with null pointers for new functions. (struct dir_handle): New struct type. (dir_destroy, dir_mark): New functions. (dir_get_line): Refactor for struct dir_handle context rather than DIR. Persist error state. (dir_close): Refactor for struct dir_handle. (dir_get_error, dir_get_error_str, dir_clear_error): New static functions. (dir_ops): Update initializer with new functions. (make_stdio_stream_common): Initialize new err member. (make_dir_stream): Refactor for struct dir_handle. (get_error, get_error_str, clear_error): New functions. (cat_get_error, cat_get_error_str, cat_clear_error): New static functions. (cat_stream_ops): Update initializer with new functions. (stream_init): Register get-error, get-error-str, clear-error intrinsics. * stream.h (struct strm_ops): New function pointer members, get_error, get_error_str and clear_error. (strm_ops_init): Macro extended with new arguments for new function pointers. (get_error, get_error_str, clear_error): Declared. * syslog.c (syslog_strm_ops): Update initializer with null pointers for new functions. * txr.1: Documented get-error, get-error-str and clear-error.
* Update copyright notices from 2014 to 2015.Kaz Kylheku2015-02-011-1/+1
| | | | | | | | | | | * arith.c, arith.h, combi.c, combi.h, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Update. * LICENSE, METALICENSE: Likewise.
* Use macro to initialize strm_ops.Kaz Kylheku2015-01-291-202/+137
| | | | | | | | | | * stream.h (strm_ops_init): New macro. * stream.c (null_ops, stdio_ops, tail_ops, pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops, cat_stream_ops): Initialize using macro. * syslog.c (syslog_strm_ops): Likewise.
* * stream.c (get_string): New argument, close_after_p.Kaz Kylheku2015-01-211-2/+7
| | | | | | | | | | | Close the stream unless close_after_p is specified and is nil, or when it is missing, an there is no compatibility or it's newer than version 102. * stream.h (get_string): Updated declartion. * txr.1: Documented default closing behavior of get-string and the new optional argument for overriding it.
* * lib.c (simple_lazy_stream_func): Bugfix: close the streamKaz Kylheku2014-12-251-3/+9
| | | | | | | | | | if get_line returns nil. * stream.c (cat_get_line, cat_get_char, cat_get_byte): The catenated stream read operations close an exhausted stream before popping to the next one. * txr.1: Document closing behavior of catenated streams.
* * stream.c (stream_init): Register make_catenated_stream inKaz Kylheku2014-12-251-1/+1
| | | | | | | | a different form as cat-streams. * txr.1: Document cat-streams. * tl.vim, txr.vim: Regenerated.
* * lib.c (chk_grow_vec): New function.Kaz Kylheku2014-10-301-4/+7
| | | | | | | | | (string_extend): Use chk_grow_vec. (vec_set_length): Avoid subtractions for comparing numbers. * lib.h (chk_grow_vec): Declared. * stream.c (snarf_line, string_out_put_string): Use chk_grow_vec.
* * Makefile: Removing trailing spaces.Kaz Kylheku2014-10-241-15/+15
| | | | | | | | | | (GREP_CHECK): New macro. (enforce): Rewritten using GREP_CHECK, with new checks. * arith.c, combi.c, debug.c, eval.c, filter.c, gc.c, hash.c, lib.c, * lib.h, match.c, parser.l, parser.y, rand.c, regex.c, signal.c, * signal.h, stream.c, syslog.c, txr.c, unwind.c, utf8.c: Remove trailing spaces.
* Converting cast expressions to macros that are retargettedKaz Kylheku2014-10-171-116/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to C++ style casts when compiling as C++. * lib.h (strip_qual, convert, coerce): New casting macros. (TAG_MASK, tag, type, wli_noex, auto_str, static_str, litptr, num_fast, chr, lit_noex, nil, nao): Use cast macros. * arith.c (mul, isqrt_fixnum, bit): Use cast macros. * configure (INT_PTR_MAX): Define using cast macro. * debug.c (debug_init): Use cast macro. * eval.c (do_eval, expand_macro, reg_op, reg_mac, eval_init): Use cast macros. * filter.c (filter_init): Use cast macro. * gc.c (more, mark_obj, in_heap, mark, sweep_one, unmark): Use cast macros. * hash.c (hash_double, equal_hash, eql_hash, hash_equal_op, hash_hash_op, hash_print_op, hash_mark, make_hash, make_similar_hash, copy_hash, gethash_c, gethash, gethash_f, gethash_n, remhash, hash_count, get_hash_userdata, set_hash_userdata, hash_iter_destroy, hash_iter_mark, hash_begin, hash_uni, hash_diff, hash_isec): Use cast macros. * lib.c (code2type, chk_malloc, chk_malloc_gc_more, chk_calloc, chk_realloc, chk_strdup, num, c_num, string, mkstring, mkustring, upcase_str, downcase_str, string_extend, sub_str, cat_str, trim_str, c_chr, vector, vec_set_length, copy_vec, sub_vec, cat_vec, cobj_print_op, obj_init): Likewise. * match.c (do_match_line, hv_trampoline, match_files, dir_tables_init): Likewise. * parser.l (grammar): Likewise. * parser.y (parse): Likewise. * rand.c (make_state, make_random_state, random_fixnum, random): Likewise. * regex.c (CHAR_SET_L2_LO, CHAR_SET_L2_HI, CHAR_SET_L1_LO, CHAR_SET_L1_HI, CHAR_SET_L0_LO, CHAR_SET_L0_HI, L0_full, L0_fill_range, L1_full, L1_fill_range, L1_contains, L1_free, L2_full, L2_fill_range, L2_contains, L2_free, L3_fill_range, L3_contains, L3_free, char_set_create, char_set_cobj_destroy, nfa_state_accept, nfa_state_empty, nfa_state_single, nfa_state_wild, nfa_state_set,
* Purge stray occurrences of "void *" from code base.Kaz Kylheku2014-10-171-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (cobj_print_op): In the format call, cast the C pointer to val, since the ~p conversion now takes a val rather than void *. (cptr_equal_op, obj_print, obj_pprint): Remove cast to void *, since obj now already has the type that ~p expects. * lib.h (struct any): Use mem_t * instead of void *. * parser.h (yyscan_t): Repeat the definition from inside the Flex-generated lex.yy.c. (yylex_init, yylex_destroy, yyget_extra, yyset_extra): Re-declare using yyscan_t typedef in place of void *. * parser.l (yyget_column, yyerrprepf): Re-declare using yyscan_t. (grammar): Use yyg in place of yyscanner in calls to yyerrprepf. * parser.y (yylex, %lex-param): Use yyscan_t instead of void *. (parse): Use yyscan_t for local variable. * signal.c (stack): Change type from void * to mem_t *. * stream.c (vformat): Conversion specifier p extracts val instead of void *. (run): Use casts that only remove const, not all the way to void *. * txr.1: Documented p conversion specifier of format. * Makefile (OBJS-y): Initialize with := to make sure it is a simple variable, and not a macro. (SRCS): New variable, listing source files. (enforce): New rule for enforcing coding conventions. Currently checks for void * occurrences.
* Fix gc safety issue in abs_path_p function.Kaz Kylheku2014-10-091-4/+7
| | | | | | | * stream.c (ap_regex): New static variable. (abs_path_p): Remove local reg variable; replace uses of reg with ap_regex. (stream_init): gc-protect ap_regex.
* * stream.c (stream_init): No need to gc-protectKaz Kylheku2014-10-091-1/+0
| | | | | | | | | std_input, std_output, std_debug, std_error and std_null. These are not ordinary variables but macros which expand to locations in the variable binding environment that are already protected. This call was actually doing nothing, because the symbol involved in the expression std_input is not yet initialized and so &std_input yields a null pointer which causes protect to bail.
* Moving system interface functions to separate module out ofKaz Kylheku2014-10-081-298/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the eval and stream modules. * Makefile (OBJS): Add sysif.o. * dep.mk: Regenerated. * eval.c (errno_wrap, daemon_wrap, exit_wrap, usleep_wrap, getpid_wrap, getppid_wrap, env_hash): Functions moved to sysif.c and changed to static functions. (eval_init): Registrations of functions moved to sysif.c. * lib.c (init): Call sysif_init. * stream.c (w_stat, statf, mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap): Functions moved to sysif.c and become static functions. (stream_init): Registration of stat moved to sysif.c. (open_files, open_files_star): Bugfix: no longer erroneously included in #ifdef HAVE_UNISTD_H block. * stream.h (mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap, symlink_wrap, link_wrap, readlink_wrap): Declarations removed. * sysif.c: New file. * sysif.h: New file.
* GC correctness fixes: make sure we pin down objects for which we borrowKaz Kylheku2014-08-251-7/+26
| | | | | | | | | | | | | | | low level C pointers, while we execute code that can cons memory. * lib.c (list_str): Protect the str argument. (int_str): Likewise. * regex.c (search_regex): protect the haystack string, while using the h pointer to its data, since regex_run can use the derivative-based engine which conses. * stream.c (vformat_str): Protect str argument, since put_char might conceivably cons. (vformat): Protect fmtstr.
* * Makefile, arith.c, arith.h, combi.c, combi.h, configure, debug.c,Kaz Kylheku2014-07-231-16/+16
| | | | | | | | debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Synchronize license header with LICENSE.
* * stream.c (put_strings, put_lines): New functions.Kaz Kylheku2014-07-191-0/+20
| | | | | | | | (stream_init): Registered new functions as intrinsics. * stream.h (put_strings, put_lines): Declared. * txr.1: Documented.