summaryrefslogtreecommitdiff
path: root/libguile/read.c
AgeCommit message (Collapse)AuthorFilesLines
2011-11-08locking on port buffering operationsAndy Wingo1-2/+2
* libguile/ports.c (scm_fill_input_unlocked, scm_fill_input) (scm_end_input, scm_end_input_unlocked, scm_flush) (scm_flush_unlocked): Add locking and _unlocked variants. * libguile/filesys.c: * libguile/fports.c: * libguile/gdbint.c: * libguile/r6rs-ports.c: * libguile/read.c: * libguile/rw.c: Adapt callers to use _unlocked variants.
2011-11-08locking on unget_byte, ungetc, ungetsAndy Wingo1-24/+24
* libguile/ports.h: * libguile/ports.c (scm_unget_byte_unlocked, scm_unget_byte) (scm_ungetc_unlocked, scm_ungetc, scm_ungets_unlocked, scm_ungets): Add locking and _unlocked variants. * libguile/arrays.c: * libguile/rdelim.c: * libguile/read.c: * libguile/vports.c: Adapt callers to use the _unlocked variants.
2011-11-08locking on scm_c_read, scm_getcAndy Wingo1-23/+23
* libguile/ports.c (scm_c_read_unlocked, scm_c_read, scm_getc_unlocked) (scm_getc): Split getc and read operations into locked and unlocked variants. Change most uses to use the _unlocked version.
2011-11-08threadsafe get-byte-or-eof, peek-byte-or-eofAndy Wingo1-7/+7
* libguile/ports.h (scm_get_byte_or_eof_unlocked): (scm_peek_byte_or_eof_unlocked): Rename, adding _unlocked. * libguile/ports.c (scm_get_byte_or_eof, scm_peek_byte_or_eof): Add locking implementations. Adapt callers to use _unlocked variants; they will do locking. * libguile/read.c (read_token, scm_read_semicolon_comment) (scm_read_shebang): Use unlocked variants. We will add locking later.
2011-10-10Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-21/+20
Does not include psyntax regeneration. Conflicts: module/ice-9/psyntax-pp.scm module/language/tree-il/peval.scm test-suite/tests/tree-il.test
2011-10-05fix reading of #||||#Andy Wingo1-21/+20
* libguile/read.c (scm_read_r6rs_block_comment): * test-suite/tests/reader.test ("reading"): Fix reading of #||||#, originally reported in bug debbugs.gnu.org/9672, by Bruno Haible. Thanks, Bruno!
2011-08-31Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-1/+1
Conflicts: libguile/bytevectors.c libguile/bytevectors.h libguile/objcodes.c libguile/r6rs-ports.c libguile/strings.c libguile/vm.c
2011-07-29style fix in read.cAndy Wingo1-1/+1
* libguile/read.c (scm_read_sexp): No need to assign to tmp here.
2011-07-25Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-3/+8
Conflicts: GUILE-VERSION test-suite/tests/srfi-4.test
2011-07-01fix '(a #{.} b)Andy Wingo1-3/+8
* libguile/read.c (scm_read_sexp): Don't confuse `#{.}#' with `.' for the purpose of reading dotted pairs. Thanks to CRLF0710 for the report. * test-suite/tests/reader.test ("#{}#"): Add test.
2011-05-25Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-108/+11
Conflicts: libguile/procprop.c
2011-05-24read + source properties simplificationAndy Wingo1-108/+11
* libguile/srcprop.h: Remove internal scm_source_whash declaration. * libguile/srcprop.c (scm_i_set_source_properties_x) (scm_i_has_source_properties): New helpers. (scm_source_whash): Make static. * libguile/read.c (scm_read_sexp): Remove register declarations here; let's trust the compiler. Remove code to incrementally build up a copy; instead let's let scm_i_set_source_properties_x handle copying the expression if needed. (scm_read_quote, scm_read_syntax): Use scm_i_set_source_properties_x. (recsexpr): Remove this helper from 1996. (scm_read_sharp_extension): Instead of trying to recursively label sharp-read subforms with source properties, just label the outside form and rely on the macro-expander to propagate it down.
2011-05-13merge strictness branch from 2.0Andy Wingo1-4/+4
2011-05-13fix type errorsAndy Wingo1-3/+3
* libguile/numbers.c (scm_logand): Fix a type error (comparing a SCM against an int, when we really wanted to compare the unpacked fixnum). * libguile/ports.c (scm_i_set_conversion_strategy_x): Check scm_conversion_strategy_init, not scm_conversion_strategy. * libguile/read.c (recsexpr): Fix loops to avoid strange test of SCM values.
2011-05-13allow iflags to be constant expressions with typing-strictness==2Andy Wingo1-1/+1
* libguile/tags.h (SCM_MAKE_ITAG8_BITS): New helper, produces a scm_t_bits instead of a SCM, because SCM_UNPACK is not a constant expression with SCM_DEBUG_TYPING_STRICTNESS==2. (SCM_MAKIFLAG_BITS): Remove SCM_MAKIFLAG, and replace with this, which returns bits. (SCM_BOOL_F_BITS, SCM_ELISP_NIL_BITS, SCM_EOL_BITS, SCM_BOOL_T_BITS): (SCM_UNSPECIFIED_BITS, SCM_UNDEFINED_BITS, SCM_EOF_VAL_BITS): (SCM_UNBOUND_BITS): New definitions. Defined SCM_BOOL_F, etc in terms of them. (SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_0): (SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_1): (SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_2): (SCM_XXX_ANOTHER_LISP_FALSE_DONT_USE): Be bits instead of SCM values. (SCM_BITS_DIFFER_IN_EXACTLY_ONE_BIT_POSITION): (SCM_BITS_DIFFER_IN_EXACTLY_TWO_BIT_POSITIONS): Rename from SCM_VALUES_DIFFER_..., and take unpacked bits as the args. * libguile/boolean.c: Update verify block to use SCM_BITS_DIFFER_IN_EXACTLY_TWO_BIT_POSITIONS et al. * libguile/debug.c (scm_debug_opts): * libguile/print.c (scm_print_opts): * libguile/read.c (scm_read_opts): Use iflags bits for initializers. * libguile/hash.c (scm_hasher): Use _BITS for iflags as case labels. * libguile/pairs.c: Nil/null compile-time check uses SCM_ELISP_NIL_BITS.
2011-05-12remove all deprecated codeAndy Wingo1-19/+0
* libguile/async.c: * libguile/async.h: * libguile/debug.h: * libguile/deprecated.c: * libguile/deprecated.h: * libguile/evalext.h: * libguile/gc-malloc.c: * libguile/gc.h: * libguile/gen-scmconfig.c: * libguile/numbers.c: * libguile/ports.c: * libguile/ports.h: * libguile/procprop.c: * libguile/procprop.h: * libguile/read.c: * libguile/socket.c: * libguile/srfi-4.h: * libguile/strings.c: * libguile/strings.h: * libguile/tags.h: * module/ice-9/boot-9.scm: * module/ice-9/deprecated.scm: Remove all deprecated code. CPP defines that were not previously issuing warnings were changed so that their expansions would indicate the replacement forms to use, e.g. scm_sizet__GONE__REPLACE_WITH__size_t. The two exceptions were SCM_LISTN, which did not produce warnings before, and the string-filter argument order stuff. Drops the initial dirty memory usage of Guile down to 2.8 MB on my machine, from 4.4 MB.
2011-05-08Make the definition of `scm_read_shebang' match its declaration.Ludovic Courtès1-1/+1
* libguile/read.c (scm_read_shebang): Remove the `inline' keyword.
2011-05-01deprecate scm_whash APIAndy Wingo1-34/+34
* libguile/deprecated.h: * libguile/deprecated.c (scm_whash_get_handle, SCM_WHASHFOUNDP) (SCM_WHASHREF, SCM_WHASHSET, scm_whash_create_handle) (scm_whash_lookup, scm_whash_insert): Deprecate this API. * libguile/srcprop.c: * libguile/srcprop.h: * libguile/read.c (scm_read_sexp): Use the hashq API instead of the whash API.
2011-04-11read-extended-symbol handles backslash better, including r6rs hex escapesAndy Wingo1-8/+47
* libguile/read.c (scm_read_extended_symbol): Interpret '\' as an escape character. Due to some historical oddities we have to support '\' before any character, but since we never emitted '\' in front of "normal" characters like 'x' we can interpret "\x..;" to be an R6RS hex escape. * test-suite/tests/reader.test ("#{}#"): Add tests.
2011-04-05Undeprecate read syntax for uniform complex vectorsMark H Weaver1-1/+1
* libguile/read.c (scm_read_sharp): Move the "#c..." case outside of #if SCM_ENABLE_DEPRECATED, and to the same section which handles "#s...", "#u..." and "#f...". Thanks to Andreas Rottmann <a.rottmann@gmx.at> for the bug report.
2011-03-31fix problems detecting coding: in block commentsAndy Wingo1-8/+12
* libguile/read.c (scm_i_scan_for_encoding): Fix for coding on first line #! and for !# immediately following the coding. * test-suite/Makefile.am: * test-suite/tests/coding.test: Add tests.
2011-03-20Make VM string literals immutable.Ludovic Courtès1-4/+4
* libguile/strings.c (scm_i_make_string, scm_i_make_wide_string): Add `read_only_p' parameter. All callers updated. * libguile/vm-i-loader.c (load_string, load_wide_string): Push read-only strings. * test-suite/tests/strings.test ("literals"): New test prefix.
2011-03-03fix encoding scanning for non-seekable portsAndy Wingo1-7/+41
* libguile/read.c (scm_i_scan_for_encoding): If possible, just use the read buffer for the encoding scan, and avoid seeking. Fixes `(open-input-file "/dev/urandom")', because /dev/urandom can't be seeked backwards.
2011-02-28Have `read' update line/column numbers when reading SCSH block comments.Ludovic Courtès1-5/+1
* libguile/read.c (scm_read_scsh_block_comment): Use `scm_getc' instead of `scm_get_byte_or_eof'. * test-suite/tests/reader.test ("read-options")["position of SCSH block comment"]: New test.
2011-02-13read-enable 'positions by defaultAndy Wingo1-1/+1
* libguile/read.c (scm_read_opts): Default "positions" to #t. The compiler was already turning it on anyway, and this allows primitive-load without --auto-compile to also propagate source information through the expander, for better errors and to let macros know their source. * module/language/scheme/spec.scm: No need to enable positions here now.
2011-02-09fix typos in the manual bits generated from source comments.Ralf Wildenhues1-1/+1
* libguile/bitvectors.c, libguile/chars.c, libguile/deprecated.c, libguile/numbers.c, libguile/random.c, libguile/read.c, libguile/root.c, libguile/srfi-1.c, libguile/srfi-13.c, libguile/srfi-14.c, libguile/uniform.c: Fix typos, add missing newlines.
2011-01-21implement r6rs hungry escaped EOLAndy Wingo1-0/+21
* libguile/private-options.h (SCM_HUNGRY_EOL_ESCAPES_P): New private option. * libguile/read.c: Define SCM_HUNGRY_EOL_ESCAPES_P, defaulting to #f. (skip_intraline_whitespace): New helper. (scm_read_string): If SCM_HUNGRY_EOL_ESCAPES_P, skip_intraline_whitespace after an escaped EOL. * test-suite/tests/reader.test ("read-options"): Add test.
2011-01-07use scm_from_latin1_symboln for string literals and load-symbolAndy Wingo1-2/+2
* libguile/bytevectors.c: * libguile/eval.c: * libguile/goops.c: * libguile/i18n.c: * libguile/load.c: * libguile/memoize.c: * libguile/modules.c: * libguile/ports.c: * libguile/print.c: * libguile/procs.c: * libguile/programs.c: * libguile/read.c: * libguile/script.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/strings.c: * libguile/throw.c: * libguile/vm.c: Use scm_from_latin1_symboln to make symbols from string literals, because they aren't in the user's locale -- they are in ASCII, and we can optimize this case. * libguile/vm-i-loader.c: Also use scm_from_latin1_symboln when loading narrow symbols.
2010-11-19fix a number of assuptions that a long could hold an inumAndy Wingo1-2/+2
* libguile/bytevectors.c: * libguile/goops.c: * libguile/instructions.c: * libguile/numbers.c: * libguile/random.c: * libguile/read.c: * libguile/vm-i-scheme.c: Fix a number of assumptions that a long could hold an inum. This is not the case on platforms whose void* is larger than their long. * libguile/numbers.c (scm_i_inum2big): New helper, only implemented for sizeof(void*) == sizeof(long); produces a compile error on other platforms. Basically gmp doesn't have a nice interface for converting between mpz values and intmax_t.
2010-11-19fix a number of assumptions that a pointer could fit into a longAndy Wingo1-1/+1
* libguile/debug.c: * libguile/eval.c: * libguile/frames.c: * libguile/objcodes.c: * libguile/print.c: * libguile/programs.c: * libguile/read.c: * libguile/struct.c: * libguile/vm.c: Fix a number of instances in which we assumed we could fit a pointer into a long.
2010-11-12NUL vs NULL fixAndy Wingo1-1/+1
* libguile/read.c (scm_i_scan_for_encoding): Fix NUL rather than NULL.
2010-11-12Fix buffer over-read in port encoding scan.Julian Graham1-0/+1
* libguile/read.c (scm_i_scan_for_encoding): Add a NULL terminator to the end of header to prevent over-read by subsequent call to strstr.
2010-11-04need read error for extra closing square bracketsMichael Gran1-0/+4
* libguile/read.c (scm_read_expression): add test
2010-11-03Use a fluid for the list of the reader's "hash procedures"Andreas Rottmann1-10/+28
This allows customizing the reader behavior for a dynamic extent more easily. * libguile/read.c (scm_read_hash_procedures): Renamed to `scm_i_read_hash_procedures'. (scm_i_read_hash_procedures_ref, scm_i_read_hash_procedures_set_x): New (internal) accessor functions for the fluid. (scm_read_hash_extend, scm_get_hash_procedure): Use these accessor functions. (scm_init_read): Create the fluid, named `%read-hash-procedures' instead of the previous plain list `read-hash-procedures'. * test-suite/tests/reader.test: Adapt the "R6RS/SRFI-30 block comment syntax overridden" test to make use of the fluid. * module/ice-9/deprecated.scm (read-hash-procedures): New identifier macro -- backward-compatibility shim. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2010-10-18uninitialized var in scm_read_characterAndy Wingo1-2/+1
* libguile/read.c (scm_read_character): Fix error condition where charname could be uninitialized.
2010-10-01remove elisp-strings and elisp-vectors read optionsAndy Wingo1-9/+0
* libguile/private-options.h (SCM_ELISP_VECTORS_P, SCM_ESCAPED_PARENS_P): * libguile/read.c (scm_read_opts): Remove unused elisp-vectors option, and the elisp-strings option (which allowed \( and \) escapes in strings). (scm_read_string): Remove the elisp-strings case. * doc/ref/api-options.texi (Reader options): Update, and update wording of the case-insensitive bit.
2010-07-17Enable character hex escapes by defaultMichael Gran1-3/+3
R6RS character hex escapes do not conflict with legacy Guile octal character escapes, so they can be enabled by default. * libguile/read.c (scm_read_character): modified * test-suite/tests/reader.test: modify character escape tests * doc/ref/api-data.texi: modified * doc/ref/api-options.texi: modified
2010-07-16More explicit variable names in scm_i_scan_for_encodingMichael Gran1-15/+18
Note especially that the variable 'i' has two different uses in this function, and they get confused. * libguile/read.c (scm_i_scan_for_encoding): cleanup
2010-07-13fix '(] infinite loopAndy Wingo1-2/+8
* libguile/read.c (scm_read_sexp): Fix reader infinite loop. Thanks to Bill Schottstaedt for the report. * test-suite/tests/reader.test: Add test.
2010-05-27Support for the #!r6rs lexeme.Julian Graham1-2/+37
* libguile/read.c (scm_read_shebang): New function; (scm_read_sharp): Call scm_read_shebang on '!', which delegates to scm_read_scsh_block_comment as necessary. * test-suite/tests/reader.test ("R6RS lexeme comment", "partial R6RS lexeme comment"): New tests.
2010-04-09add read syntax for #nilAndy Wingo1-0/+16
* libguile/evalext.c (scm_self_evaluating_p): #nil is self-evaluating. * libguile/read.c (scm_read_nil, scm_read_sharp): Add read syntax for #nil.
2010-04-09lisp nil always enabledAndy Wingo1-4/+0
* configure.ac: Remove --disable-elisp option. Lisp nil is always enabled. * libguile/boolean.h: * libguile/gen-scmconfig.c: * libguile/gen-scmconfig.h.in: * libguile/init.c: * libguile/lang.c: * libguile/lang.h: * libguile/pairs.h: * libguile/private-options.h: * libguile/read.c: Remove conditionals for disabling elisp.
2010-02-15Faster read of semicolon commentsMichael Gran1-1/+1
There is no need to do character encoding processing within semicolon comments. * libguile/read.c (scm_read_semicolon_comment): changed
2010-02-02Optimize reader by preferring stack-allocated buffersMichael Gran1-70/+178
* libguile/read.c (read_token): now takes a C buffer instead of a SCM. string. All callers changed. (read_complete_token): now takes C buffers, not SCM strings. No longer does port position updates or encoding processing. All callers changed. (scm_read_number, scm_read_mixed_case_symbol, scm_read_number_and_radix) (scm_read_character): Do port updates and string processing no longer done by read_complete_token. Some reordering for optimization.
2010-01-15add reader option for parsing [] as ().Andy Wingo1-2/+9
* libguile/private-options.h: * libguile/read.c (scm_read_opts, SCM_SQUARE_BRACKETS_P): Add an option for treating [ and ] as parentheses, on by default. Note that this makes them delimiters also, so [ and ] cannot appear in a symbol name, with this read option on. (scm_read_sexp): If we start with [, we end with ]. (scm_read_expression): Add case for [.
2010-01-13remove unused var in read.cAndy Wingo1-2/+1
* libguile/read.c (scm_read_character): Remove unused var.
2010-01-13Disable \u and \U escapes when r6rs-hex-escapes enabledMichael Gran1-4/+10
When the reader option 'r6rs-hex-escapes is enabled, the \uNNNN and \UNNNNNN string escape sequences should be disabled. * libguile/read.c (scm_read_string): added checks for SCM_R6RS_ESCAPES_P
2010-01-12Reader option for R6RS hex escapesMichael Gran1-29/+59
This adds a reader option 'r6rs-hex-escapes that modifies the behavior of numeric escapes in characters and strings. When enabled, variable-length character hex escapes (#\xNNN) are allowed and become the default output format for numerically-escaped characters. Also, string hex escapes switch to a semicolon terminated hex escape (\xNNNN;). * libguile/print.c (PRINT_CHAR_ESCAPE): new macro (iprin1): use new macro PRINT_CHAR_ESCAPE * libguile/private-options.h (SCM_R6RS_ESCAPES_P): new #define * libguile/read.c (scm_read_opts): add new option r6rs-hex-escapes (SCM_READ_HEX_ESCAPE): modify to take a terminator parameter (scm_read_string): parse R6RS hex string escapes (scm_read_character): parse R6RS hex character escapes * test-suite/tests/chars.test (with-read-options): new procedure (R6RS hex escapes): new tests * test-suite/tests/strings.test (with-read-options): new procedure (R6RS hex escapes): new tests
2010-01-10Refactor repeated code in scm_read_stringMichael Gran1-81/+36
* libguile/read.c (SCM_READ_HEX_ESCAPE): new macro (scm_read_string): use new macro SCM_READ_HEX_ESCAPE
2010-01-10Add R6RS backspace string escapeMichael Gran1-0/+3
R6RS suggests that '\b' should be a string escape for the backspace character. * libguile/read.c (scm_read_string): parse backspace escape * test-suite/tests/strings.test (R6RS backslash escapes): new test (Guile extensions backslash escapes): remove R6RS escapes from test. * doc/ref/api-data.texi (Strings): document new string escape