1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

315 commits

Author SHA1 Message Date
Andy Wingo
4251ae2e28 locking on port buffering operations
* 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-08 00:55:01 +01:00
Andy Wingo
c932ce0b55 locking on unget_byte, ungetc, ungets
* 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-08 00:54:58 +01:00
Andy Wingo
be632904ca locking on scm_c_read, scm_getc
* 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-08 00:54:58 +01:00
Andy Wingo
0d959103f9 threadsafe get-byte-or-eof, peek-byte-or-eof
* 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-11-08 00:54:57 +01:00
Andy Wingo
a215c15913 Merge remote-tracking branch 'origin/stable-2.0'
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-10 16:20:08 +02:00
Andy Wingo
6d5f8c324e fix reading of #||||#
* 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-10-05 20:41:15 +02:00
Andy Wingo
8b66aa8f54 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/bytevectors.c
	libguile/bytevectors.h
	libguile/objcodes.c
	libguile/r6rs-ports.c
	libguile/strings.c
	libguile/vm.c
2011-08-31 09:34:54 +02:00
Andy Wingo
89f886122a style fix in read.c
* libguile/read.c (scm_read_sexp): No need to assign to tmp here.
2011-07-29 09:14:04 +02:00
Andy Wingo
ab4bc85398 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	test-suite/tests/srfi-4.test
2011-07-25 18:26:37 +02:00
Andy Wingo
1f7945a768 fix '(a #{.} b)
* 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-07-01 12:20:52 +02:00
Andy Wingo
a099c8d971 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/procprop.c
2011-05-25 10:32:19 +02:00
Andy Wingo
26c8cc144f read + source properties simplification
* 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-24 22:41:11 +02:00
Andy Wingo
86fb1eb631 merge strictness branch from 2.0 2011-05-13 15:45:43 +02:00
Andy Wingo
2e16a342f2 fix type errors
* 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-13 13:48:07 +02:00
Andy Wingo
210c0325d3 allow iflags to be constant expressions with typing-strictness==2
* 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-13 13:48:07 +02:00
Andy Wingo
fc7bd367ab remove all deprecated code
* 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-12 14:01:26 +02:00
Ludovic Courtès
d7fcaec392 Make the definition of `scm_read_shebang' match its declaration.
* libguile/read.c (scm_read_shebang): Remove the `inline' keyword.
2011-05-08 17:24:24 +02:00
Andy Wingo
d1c4720ca3 deprecate scm_whash API
* 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-05-01 20:55:50 +02:00
Andy Wingo
d9527cfafd read-extended-symbol handles backslash better, including r6rs hex escapes
* 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-11 12:48:06 +02:00
Mark H Weaver
df941b5b62 Undeprecate read syntax for uniform complex vectors
* 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-04-05 19:42:06 -04:00
Andy Wingo
8a12aeb919 fix problems detecting coding: in block comments
* 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-31 14:46:21 +02:00
Ludovic Courtès
190d4b0d93 Make VM string literals immutable.
* 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-20 23:34:42 +01:00
Andy Wingo
d900843c72 fix encoding scanning for non-seekable ports
* 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-03-03 12:57:46 +01:00
Ludovic Courtès
58b1db5f24 Have `read' update line/column numbers when reading SCSH block comments.
* 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-28 23:33:47 +01:00
Andy Wingo
6c51a40ace read-enable 'positions by default
* 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-13 15:06:11 +01:00
Ralf Wildenhues
ffb62a43dc fix typos in the manual bits generated from source comments.
* 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-02-09 22:28:49 +00:00
Andy Wingo
684d664e39 implement r6rs hungry escaped EOL
* 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-21 09:24:32 +01:00
Andy Wingo
4a655e50a3 use scm_from_latin1_symboln for string literals and load-symbol
* 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.
2011-01-07 09:18:41 -08:00
Andy Wingo
e25f37271a fix a number of assuptions that a long could hold an inum
* 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-19 15:22:43 +01:00
Andy Wingo
3d27ef4bd3 fix a number of assumptions that a pointer could fit into a long
* 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-19 15:22:43 +01:00
Andy Wingo
190fa72a8f NUL vs NULL fix
* libguile/read.c (scm_i_scan_for_encoding): Fix NUL rather than NULL.
2010-11-12 17:18:08 +01:00
Julian Graham
f25e1b6713 Fix buffer over-read in port encoding scan.
* 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-12 08:45:09 -05:00
Michael Gran
a4e4722944 need read error for extra closing square brackets
* libguile/read.c (scm_read_expression): add test
2010-11-04 22:07:50 -07:00
Andreas Rottmann
d458073bc0 Use a fluid for the list of the reader's "hash procedures"
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-11-03 00:09:57 +01:00
Andy Wingo
c1a0ba1cef uninitialized var in scm_read_character
* libguile/read.c (scm_read_character): Fix error condition where
  charname could be uninitialized.
2010-10-18 13:29:58 +02:00
Andy Wingo
24259edb8b remove elisp-strings and elisp-vectors read options
* 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-10-01 10:20:54 +02:00
Michael Gran
0f3a70cfa8 Enable character hex escapes by default
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-17 04:16:57 -07:00
Michael Gran
daedbca7de More explicit variable names in scm_i_scan_for_encoding
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-16 05:39:52 -07:00
Andy Wingo
5b69315ed3 fix '(] infinite loop
* 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-07-13 21:53:41 +02:00
Julian Graham
911b03b20c Support for the #!r6rs lexeme.
* 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-05-27 09:21:18 -04:00
Andy Wingo
7c4aad9cc7 add read syntax for #nil
* 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-09 14:15:16 +02:00
Andy Wingo
c1b7c940ec lisp nil always enabled
* 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-04-09 14:03:02 +02:00
Michael Gran
8a8da78d97 Faster read of semicolon comments
There is no need to do character encoding processing within
semicolon comments.

* libguile/read.c (scm_read_semicolon_comment): changed
2010-02-15 20:45:58 -08:00
Michael Gran
69f90b0b05 Optimize reader by preferring stack-allocated buffers
* 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-02-02 20:33:41 -08:00
Andy Wingo
5afa815c9c add reader option for parsing [] as ().
* 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-15 22:31:23 +01:00
Andy Wingo
a8fc38526a remove unused var in read.c
* libguile/read.c (scm_read_character): Remove unused var.
2010-01-13 21:08:54 +01:00
Michael Gran
898a0b5a2e Disable \u and \U escapes when r6rs-hex-escapes enabled
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-13 07:02:07 -08:00
Michael Gran
dea901d66e Reader option for R6RS hex escapes
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-12 21:02:41 -08:00
Michael Gran
c5661d2860 Refactor repeated code in scm_read_string
* libguile/read.c (SCM_READ_HEX_ESCAPE): new macro
  (scm_read_string): use new macro SCM_READ_HEX_ESCAPE
2010-01-10 18:24:23 -08:00
Michael Gran
67a4a16d8e Add R6RS backspace string escape
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
2010-01-10 15:41:37 -08:00