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

2264 commits

Author SHA1 Message Date
Shea Levy
d6e669b8cb
Recognize RISC-V compilation targets.
* module/system/base/target.scm (cpu-endianness): Add case for "riscv" variants.

Signed-off-by: Shea Levy <shea@shealevy.com>
Signed-off-by: Mark H Weaver <mhw@netris.org>
2018-03-15 23:17:23 -04:00
Andy Wingo
73d9d18488 Flush when getting string from r6rs string output port
* module/rnrs/io/ports.scm (open-string-output-port): Calling the
  get-string proc should flush the buffer and reset the file position.
* test-suite/tests/r6rs-ports.test ("8.2.10 Output ports"): Add tests.
  Thanks to Freja Nordsiek for the report.

(cherry picked from commit e13cd5c77c)
2017-03-06 20:46:21 +01:00
Andy Wingo
89ececea95 Better errors for odd-length keyword args
* libguile/vm-i-system.c (bind-kwargs):
* libguile/vm.c (vm_error_kwargs_missing_value):
* libguile/eval.c (error_missing_value)
  (prepare_boot_closure_env_for_apply): Adapt to mirror VM behavior.
* libguile/keywords.c (scm_c_bind_keyword_arguments): Likewise.
* module/ice-9/eval.scm (primitive-eval): Update to error on (foo #:kw)
  with a "Keyword argument has no value" instead of the horrible "odd
  argument list length".  Also adapts to the expected args format for
  the keyword-argument-error exception printer in all cases.  Matches
  1.8 optargs behavior also.
* test-suite/standalone/test-scm-c-bind-keyword-arguments.c (test_missing_value):
  (missing_value_error_handler): Update test.
* test-suite/tests/optargs.test: Add tests.
2017-02-28 21:01:33 +01:00
Ludovic Courtès
4b2b867c21 i18n: 'number->locale-string' guesses the minimum number of decimals.
This feature was removed by 4aead68cdb.

* module/ice-9/i18n.scm (number-decimal-string): Rewrite the case where
DIGIT-COUNT is not an integer.
(number->locale-string): Always pass FRACTION-DIGITS to
'number-decimal-string'.
* test-suite/tests/format.test ("~h localized number")["1234.5"]
["padding", "padchar"]: Remove decimal specifier.
* test-suite/tests/i18n.test ("number->locale-string")
["fraction",
* test-suite/tests/i18n.test ("format ~h")["12 345,678"]: Remove decimal
specifier.  Remove one decimal.
* doc/ref/api-i18n.texi (Number Input and Output): Update
'number->locale-string' doc to mention the number of decimals.
2017-02-13 21:34:57 +01:00
Ludovic Courtès
4aead68cdb i18n: Fix corner cases for monetary and number string conversions.
Fixes <http://bugs.gnu.org/24990>.
Reported by Martin Michel <dev@famic.de>.

* module/ice-9/i18n.scm (integer->string, number-decimal-string): New
procedures.
(monetary-amount->locale-string): Use them instead of 'number->string'
followed by 'string-split'.
(number->locale-string): Likewise.
* test-suite/tests/i18n.test ("number->locale-string")["fraction"]: Add
second argument to 'number->locale-string'.
["fraction, 1 digit"]: Round up.
["fraction, 10 digits", "trailing zeros", "negative integer"]: New
tests.
* test-suite/tests/i18n.test ("format ~h"): Pass the number of decimals
for ~h.
("monetary-amount->locale-string")["French"]: Always expect two decimals
after the comma.
["one cent", "very little money"]: New tests.
* test-suite/tests/format.test ("~h localized number")["1234.5"]:
Specify the number of decimals explicitly.
["padding"]: Expect zero decimals.
["padchar"]: Ask for one decimal.
["decimals", "locale"]: Adjust rounding.
2017-02-13 00:18:09 +01:00
Ludovic Courtès
68938bcadd i18n: Do not represent zero as "-0".
Partly fixes <http://bugs.gnu.org/24990>.
Reported by Martin Michel <dev@famic.de>.

* module/ice-9/i18n.scm (monetary-amount->locale-string): Don't negate
AMOUNT when it's zero.
(number->locale-string): Likewise.
* test-suite/tests/i18n.test ("number->locale-string")["positive inexact
zero, 1 digit"]: New test.
("monetary-amount->locale-string")["positive inexact zero"]: New test.
2017-02-12 23:01:16 +01:00
John Paul Adrian Glaubitz
e18251e3ba Recognize sh3 as compilation targets
* module/system/base/target.scm (cpu-endianness, triplet-pointer-size):
  Add case for "sh3".

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2017-02-12 22:07:45 +01:00
Mark H Weaver
458ae248ab psyntax: Generate identifiers in a deterministic fashion.
Fixes <http://bugs.gnu.org/20272>.

* module/ice-9/boot-9.scm (module-generate-unique-id!)
(module-gensym): New procedures.
(module): Add 'next-unique-id' field.
(the-root-module): Inherit 'next-unique-id' value from early stub.
(make-module, make-autoload-interface): Adjust calls to
module-constructor.
* module/ice-9/psyntax.scm (gen-label, new-mark): Generate unique
identifiers from the module name and the per-module unique-id.
(build-lexical-var, generate-temporaries): Use
'module-gensym' instead of 'gensym'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/language/tree-il/fix-letrec.scm (fix-letrec!): Use
'module-gensym' instead of 'gensym'.
* module/system/base/syntax.scm (define-record): Likewise.
(transform-record): Likewise.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2016-12-30 21:58:44 +01:00
Ludovic Courtès
272473fee4 scandir: Avoid 'stat' calls on each entry.
* module/ice-9/ftw.scm (scandir): Rewrite in terms of 'readdir'.
2016-10-28 22:17:10 +02:00
Mark H Weaver
08c021916d REPL Server: Guard against HTTP inter-protocol exploitation attacks.
Reported by Christopher Allan Webber <cwebber@dustycloud.org>
Co-authored-by: Ludovic Courtès <ludo@gnu.org>

This commit adds protection to Guile's REPL servers against HTTP
inter-protocol exploitation attacks, a scenario whereby an attacker can,
via an HTML page, cause a web browser to send data to TCP servers
listening on a loopback interface or private network.  See
<https://en.wikipedia.org/wiki/Inter-protocol_exploitation> and
<https://www.jochentopf.com/hfpa/hfpa.pdf>, The HTML Form Protocol
Attack (2001) by Tochen Topf <jochen@remote.org>.

Here we add a procedure to 'before-read-hook' that looks for a possible
HTTP request-line in the first line of input from the client socket.  If
present, the socket is drained and closed, and a loud warning is written
to stderr (POSIX file descriptor 2).

* module/system/repl/server.scm: Add 'maybe-check-for-http-request'
to 'before-read-hook' when this module is loaded.
(with-temporary-port-encoding, with-saved-port-line+column)
(drain-input-and-close, permissive-http-request-line?)
(check-for-http-request, guard-against-http-request)
(maybe-check-for-http-request): New procedures.
(serve-client): Use 'guard-against-http-request'.
* module/system/repl/coop-server.scm (start-repl-client): Use
'guard-against-http-request'.
* doc/ref/guile-invoke.texi (Command-line Options): In the description
of the --listen option, make the security warning more prominent.
Mention the new protection added here.  Recommend using UNIX domain
sockets for REPL servers.  "a path to" => "the file name of".
2016-10-11 11:29:09 +02:00
Mark H Weaver
622bd8f14b http: Do not use 'eq?' to compare characters in parse-request-uri.
* module/web/http.scm (parse-request-uri): Use 'eqv?' to compare
characters.
2016-09-09 07:32:53 -04:00
James Clarke
664586aff4 Recognize alpha as compilation target
* module/system/base/target.scm (cpu-endianness): Add case for "alpha".
(triplet-pointer-size): Likewise.
2016-08-08 22:21:09 +02:00
Marek Vasut
f9f438d471 Recognize nios2 as compilation target
Add support for the nios2 architecture.

Signed-off-by: Marek Vasut <marex@denx.de>
2016-08-07 13:32:08 +02:00
Ludovic Courtès
26cf7843c6 texinfo: Remove unnecessary (oop goops) dependency.
* module/texinfo/string-utils.scm: Remove #:use-module (oop goops).
2016-08-04 19:15:09 +02:00
Andy Wingo
0cf62c576d Allow mkstemp! to have optional "mode" argument
* m4/mkstemp.m4: Remove.
* lib/mkstemp.c: Remove.
* lib/mkostemp.c: New file.
* m4/mkostemp.m4: New file.
* lib/Makefile.am:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4: Remove mkstemp module, replace with mkostemp.

* libguile/fports.h:
* libguile/fports.c (scm_i_mode_to_open_flags): Factor out helper to
  parse mode string to open flags.
  (scm_open_file_with_encoding): Use the new helper.
* libguile/filesys.c:
  (scm_i_mkstemp): Adapt to take optional second argument, being a mode
  string.  Use mkostemp.
  (scm_mkstemp): Backwards compatible shim that calls scm_i_mkstemp.

* doc/ref/posix.texi:
* NEWS: Update.

* module/system/base/compile.scm (call-with-output-file/atomic): Pass
  "wb" as mode, to cause O_BINARY to be added on MinGW.
2016-07-16 15:37:55 +02:00
Andy Wingo
c691c0e15a Fix bug compiling fixpoint combinator
* module/language/tree-il/peval.scm (<operand>): Rename "alias-value"
  field to "alias", which is now an operand and not an expression.
  This allows the operand to capture its environment; before, the
  alias was being visited in its use environment instead of its
  definition environment.
  (peval): Adapt to operand change.
* test-suite/tests/peval.test ("partial evaluation"): New test.
2016-07-16 12:05:21 +02:00
Andy Wingo
4e02ce55a6 Fix error when boot-9.go after "skip invalid .go files" commit
* module/ice-9/boot-9.scm (map, for-each): Move definition up before
  loading r4rs.go.  Before, when r4rs.go was being loaded, there was a
  window in which "catch" defined in Scheme used with-fluids before
  "map" was defined, but if "with-fluids" in eval.scm uses "map".  That
  would lead to the inability to catch errors (stack overflow) if
  `catch' was used in that window -- which it now is, due to the "skip
  invalid .go files" patch.
2016-07-14 16:20:59 +02:00
Andy Wingo
da757c6814 Refactor implementation of current-warning-port
* module/ice-9/boot-9.scm (current-warning-port):
* libguile/init.c (scm_init_standard_ports):
* libguile/ports.c (cur_warnport_fluid, scm_current_warning_port)
  (scm_set_current_warning_port, scm_init_ports): Define the warning
  port in the same way as the error/output/input ports, with a fluid
  that doesn't require calling out to Scheme.
2016-07-14 16:18:47 +02:00
Andy Wingo
af3796b11c Don't recurse in drop-right
* module/srfi/srfi-1.scm (drop-right): Don't recurse, sadly, as we have
  a stack limit.
2016-07-12 15:53:40 +02:00
Andy Wingo
9c783616cc Reduce-right not limited by stack
* module/srfi/srfi-1.scm (reduce-right): Avoid blowing out the stack.
  Fixes #17485.
2016-07-12 09:05:51 +02:00
Andy Wingo
5b7b5749e1 Add meta/build-env
* meta/build-env.in: New file which sets up an environment that does not
  inherit GUILE_LOAD_PATH / GUILE_LOAD_COMPILED_PATH (unless
  cross-compiling).
* doc/ref/Makefile.am (autoconf-macros.texi):
* libguile/Makefile.am (snarf2checkedtexi):
* module/Makefile.am (ice-9/psyntax-pp.go):
* test-suite/standalone/Makefile.am (GUILE_INSTALL_LOCALE):
* am/guilec (.scm.go): Use build-env.
* configure.ac: Create build-env.
2016-07-10 13:21:38 +02:00
Andy Wingo
04359b42b9 Skip incompatible .go files
* libguile/load.c (load_thunk_from_path, try_load_thunk_from_file):
  New functions.
  (search_path): Simplify.
  (scm_primitive_load_path, scm_init_eval_in_scheme): Use the new
  functions to load compiled files.
* module/ice-9/boot-9.scm (load-in-vicinity): Skip invalid .go files.

Inspired by a patch from Jan Nieuwenhuizen <janneke@gnu.org>.
2016-06-29 18:10:24 +02:00
Andy Wingo
45b80a1fa8 Constant-folding eq? and eqv? uses deduplication
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
* module/language/tree-il/peval.scm (peval): Constant-fold eq? and eqv?
  using equal?, anticipating deduplication.
2016-06-26 22:37:33 +02:00
Andy Wingo
ef2943e806 Prevent (@ (ice-9 boot-9) x)
* module/ice-9/boot-9.scm: Prevent re-loading, perhaps via (@ (ice-9
  boot-9) foo).  (ice-9 boot-9) isn't a module.  Fixes #21801.
2016-06-26 22:31:21 +02:00
Andy Wingo
a0d76d9c9e Fix texinfo->html for @acronym, @itemize
* module/texinfo/html.scm (itemize, acronym, tag-replacements, rules):
  Fix HTML serialization of @itemize and @acronym.  Fixes #21772.
* test-suite/tests/texinfo.html.test: New file.
* test-suite/Makefile.am: Add new file.
2016-06-26 22:30:57 +02:00
Andy Wingo
ea352d9e54 Fix bug that exposed `list' invocations to CSE
* module/language/tree-il/effects.scm (make-effects-analyzer):
  Fix analysis for list, cons, make-prompt-tage, and vector; &allocation
  is a `cause' effect.  Fixes #21899.
* test-suite/tests/cse.test ("cse"): Add test case.
2016-06-24 19:03:36 +02:00
Andy Wingo
b8e3e2ff4f CSE visits prompt body in values context
* module/language/tree-il/cse.scm (cse): Visit prompt body in values
  context, similar to recent peval fix.
2016-06-24 18:53:58 +02:00
Andy Wingo
dde0d17f8e Use source file permissions for compiled files
* module/system/base/compile.scm (call-with-output-file/atomic): Use the
  permissions of the source file, if available, as the permissions of
  the compiled file.  Fixes #18477.
2016-06-21 18:05:16 +02:00
Taylan Ulrich Bayırlı/Kammer
57e8775915 Fix SRFI-2 (and-let*) implementation.
* module/ice-9/and-let-star.scm (%and-let*): Re-implemented this in a
  more verbose but accurate way.
2016-06-21 18:04:24 +02:00
Andy Wingo
0a3ea0586d Fix uri-decode behavior for "+"
* module/web/uri.scm (uri-decode): Add #:decode-plus-to-space? keyword
  argument.
  (split-and-decode-uri-path): Don't decode plus to space.
* doc/ref/web.texi (URIs): Update documentation.
* test-suite/tests/web-uri.test ("decode"): Add tests.
* NEWS: Add entry.

Based on a patch by Brent <brent@tomski.co.za>.
2016-06-21 18:02:03 +02:00
Andy Wingo
a192c336a2 peval: Always visit prompt bodies in values context
* module/language/tree-il/peval.scm (peval): Always evaluate the body in
  values context, as a captured continuation could continue to a
  continuation of any arity.  However the handler, if it returns, does
  return to the prompt's continuation.  Fixes #14347.  Thanks to Jussi
  Piitulainen for the report.
* test-suite/tests/control.test ("shift and reset"): Add a test.
2016-06-20 23:05:55 +02:00
Ludovic Courtès
16050431f2 http: Accept date strings with a leading space for hours.
Fixes <http://bugs.gnu.org/23421>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* module/web/http.scm (parse-rfc-822-date): Add two clauses for hours
with a leading space.
* test-suite/tests/web-http.test ("general headers"): Add two tests.
2016-05-08 21:52:33 +02:00
Ludovic Courtès
ff98cbb643 Revert foreign objects.
For a long time the API failed to reach consensus among maintainers.
See <https://lists.gnu.org/archive/html/guile-devel/2015-11/msg00005.html>
and <https://lists.gnu.org/archive/html/guile-devel/2014-04/msg00069.html>.

This revert intends to break the deadlock and help further discussion to
take place with less pressure.

* libguile/foreign-object.c, libguile/foreign-object.h: Remove.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES)
(modinclude_HEADERS): Adjust accordingly.
* libguile/init.c (scm_i_init_guile): Remove call to
'scm_register_foreign_object'.
* libguile.h: Remove inclusion of "libguile/foreign-object.h".
* module/system/foreign-object.scm: Remove.
* module/Makefile.am (SYSTEM_SOURCES): Adjust accordingly.
* test-suite/standalone/test-foreign-object-c.c,
test-suite/standalone/test-foreign-object-scm: Remove.
* test-suite/standalone/Makefile.am (check_SCRIPTS, check_PROGRAMS)
(TESTS): Adjust accordingly.
(test_foreign_object_c_SOURCES, test_foreign_object_c_CFLAGS)
(test_foreign_object_c_LDADD): Remove.
* doc/ref/libguile-foreign-objects.texi: Remove.
* doc/ref/api-foreign-objects.texi: Remove.
* doc/ref/libguile-smobs.texi: New file.
* doc/ref/Makefile.am (guile_TEXINFOS): Adjust accordingly.
* doc/ref/api-control.texi, doc/ref/api-smobs.texi,
doc/ref/api-utility.texi, doc/ref/guile.texi,
doc/ref/libguile-concepts.texi, doc/ref/libguile-program.texi:
Revert d9a4a1cd and 6e4630e0.
2016-02-01 22:29:33 +01:00
Andy Wingo
c5dac3595f web: Be less strict when parsing entity tags.
* module/web/http.scm (parse-entity-tag): Be less strict, accepting
  unquoted strings as well.

* test-suite/tests/web-http.test ("response headers"): Add a test for
  etag parsing.
2016-02-01 21:56:16 +01:00
Mark H Weaver
5c8b3be820 Bump user-visible copyright years to 2016.
* doc/ref/guile.texi: Add 2016 to user-visible copyright notice.
* module/ice-9/command-line.scm (version-etc): Bump 'copyright-year' to
  2016.
* module/system/repl/common.scm (*version*): Add 2016 to the range of
  copyright years.
2016-01-06 16:44:39 -05:00
Mark H Weaver
b97bfa8be3 SRFI-19: Update the table of leap seconds.
* module/srfi/srfi-19.scm (leap-second-table): Update to include the
  most recent leap second.
2016-01-06 16:44:39 -05:00
Ludovic Courtès
4d08e38e0a http: Use 'read-header-line' instead of 'read-line*'.
* module/web/http.scm (read-line*): Remove.
(read-continuation-line, read-header, read-request-line): Use
'read-header-line' instead of 'read-line*'.
2016-01-06 17:16:46 +01:00
Ludovic Courtès
4c7732c59e http: Accept empty reason phrases.
Fixes <http://bugs.gnu.org/22273>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* module/web/http.scm (read-header-line): New procedure.
(read-response-line): Use it instead of 'read-line*'.
* test-suite/tests/web-http.test ("read-response-line"): Add test.
2016-01-06 17:16:46 +01:00
Mark H Weaver
5c9a8ecd01 Bump user-visible copyright years to 2015.
* module/ice-9/command-line.scm (version-etc): Bump 'copyright-year' to
  2015.

* module/system/repl/common.scm (*version*): Add 2015 to the range of
  copyright years.
2015-11-28 12:38:16 -05:00
Mark H Weaver
3e0605458a Revert "Add SRFI-25 implementation"
This reverts commit aaea5b248e.
2015-11-13 11:45:00 -05:00
Andreas Rottmann
aaea5b248e Add SRFI-25 implementation
Adds an implementation of SRFI 25 on top of Guile's native arrays. The
implementation does not introduce a disjoint type; Guile arrays and
SRFI-25 arrays can be used interchangably, though with different, partly
conflicting APIs.

* NEWS: Add preliminary, incomplete section on 2.0.12, noting the
  addition of SRFI-25.
* doc/ref/srfi-modules.texi (SRFI-25): New node.
* module/srfi/srfi-25.scm: New file.
* test-suite/tests/srfi-25.test: New file.
* module/Makefile.am:
* test-suite/Makefile.am: Add new files.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2015-11-05 21:05:57 +01:00
Ludovic Courtès
53b8d5f335 web: Gracefully handle premature EOF when reading chunk header.
* module/web/http.scm (read-chunk-header): Return 0 when 'read-line'
  returns EOF.
2015-09-26 11:07:05 +02:00
Ludovic Courtès
5a10e416e3 web: Fix 'close' method of delimited input ports.
* module/web/response.scm (make-delimited-input-port)[close]: Replace
  erroneous self-recursive call with a call to 'close-port'.
* test-suite/tests/web-response.test ("example-1")["response-body-port +
  close"]: New test.
2015-09-10 22:30:52 +02:00
Mark H Weaver
3bda6eb9df psyntax: Fix bug in match-each+.
Reported by Panicz Maciej Godek <godek.maciek@gmail.com> in
<http://lists.gnu.org/archive/html/guile-user/2015-09/msg00017.html>.

* module/ice-9/psyntax.scm (match-each+): Fix the case where a non-pair
  syntax object is encountered in a dotted tail.
* module/ice-9/psyntax-pp.scm: Regenerate.
2015-09-03 02:51:00 -04:00
Mark H Weaver
2c032c2215 Handle zero-length bytevectors correctly in (system base types).
* module/system/base/types.scm (cell->object): Use 'get-bytevector-n'
  instead of 'get-bytevector-all', so that the zero-length case does not
  return EOF.
2015-03-26 23:18:39 -04:00
Mark H Weaver
4ab9f0f8b9 Work around requirement that size be non-zero in GDB 'open-memory'.
* module/system/base/types.scm (memory-port): Handle zero size case
  specially.
2015-03-26 23:18:39 -04:00
Ludovic Courtès
61e1c2130c web: Export 'server-impl' procedures and the 'http' server implementation.
* module/web/server.scm: Export the 'server-impl' procedures.
* module/web/server/http.scm: Export 'http'.
2015-03-10 09:01:54 +01:00
Mark H Weaver
372d46c887 Web: http: Location header accepts URI-reference, not just absoluteURIs.
The now obsolete RFC2616 section 14.30 required that the Location
header be an absoluteURI, but RFC7231 section 7.1.2 allows it to
contain any URI-reference.

* module/web/http.scm: Use 'declare-relative-uri-header!' to declare
  the "Location" header.
2015-03-01 22:04:07 -05:00
Ludovic Courtès
00d3ecf274 http: Do not buffer HTTP chunks.
Fixes <http://bugs.gnu.org/19939>.

* module/web/http.scm (read-chunk, read-chunk-body): Remove.
  (make-chunked-input-port)[next-chunk, buffer-, buffer-size,
  buffer-pointer]: Remove.
  [chunk-size, remaining]: New variables.
  [read!]: Rewrite to write directly to BV.
* test-suite/tests/web-http.test ("chunked encoding")["reads chunks
  without buffering", "reads across chunk boundaries"]: New tests.
2015-03-01 23:41:01 +01:00
Andy Wingo
6cd1c6c79c (system base types) knows about variables
* module/system/base/types.scm (%tc7-variable): New tc7.
  (cell->object): Handle tc7-variable.

* test-suite/tests/types.test ("opaque objects"): Add a test.
2015-02-25 21:41:23 +01:00