summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
2017-07-31put-bytevector: Allow start == bytevector length.Mark H Weaver1-1/+1
* libguile/r6rs-ports.c (scm_put_bytevector): When three arguments (port bv start) are provided, allow start to be equal to the length of the bytevector, resulting in a zero-length write.
2017-03-01Fix (mkstemp! "XX" 0) errorsAndy Wingo1-0/+8
* libguile/filesys.c (scm_i_mkstemp): Validate "mode" argument as a string, and validate writability of template string early too. Thanks to Jean Louis for the bug report.
2017-03-01Fix scm_init_stime for macOSAndy Wingo1-6/+1
* libguile/stime.c (scm_init_stime): Remove needless test of clock_getcpuclockid. Fixes build on macOS; thanks to Matt Wette for the report and fix.
2017-02-28Better errors for odd-length keyword argsAndy Wingo4-42/+63
* 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-28Fix (* x -1) for GOOPS typesAndy Wingo1-15/+13
* libguile/numbers.c (scm_product): Only reduce (* x -1) to (- x) when X is a bignum. Fixes weirdness when X is not a number and instead multiplication should dispatch to GOOPS. Thanks to Alejandro Sanchez for the report.
2016-12-14build: Honor $SOURCE_DATE_EPOCH for the recorded timestamp.Ludovic Courtès1-2/+3
Reported by Jan Nieuwenhuizen <janneke@gnu.org> at <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20272#36>. * libguile/Makefile.am (libpath.h): Honor 'SOURCE_DATE_EPOCH'.
2016-10-11Treat 'SIG_IGN' as a pointer.Ludovic Courtès1-3/+7
* libguile/posix.c (scm_system_star): Cast 'SIG_IGN' to 'scm_t_uintptr_t' and use 'scm_from_uintptr_t'. This fixes an 'int-conversion' warning with GCC 6.2.
2016-10-11Add 'scm_to_uintptr_t' and 'scm_from_uintptr_t'.Ludovic Courtès1-0/+12
* libguile/numbers.h (scm_to_uintptr_t, scm_from_uintptr_t): New macros. * doc/ref/api-data.texi (Integers): Document them. * NEWS: Mention it.
2016-10-11Remove 'umask' calls from 'mkdir'.Ludovic Courtès1-15/+10
Fixes <http://bugs.gnu.org/24659>. * libguile/filesys.c (SCM_DEFINE): Remove calls to 'umask' when MODE is unbound; instead, use 0777 as the mode. Update docstring to clarify this. * doc/ref/posix.texi (File System): Adjust accordingly. * NEWS: Mention it.
2016-09-09Check for closed port in 'port-encoding' and 'set-port-encoding!'.Mark H Weaver1-2/+2
* libguile/ports.c (scm_port_encoding, scm_set_port_encoding_x): Use SCM_VALIDATE_OPPORT.
2016-08-31Move system* to posix.c, impl on open-processAndy Wingo4-129/+75
* libguile/simpos.c: Trim includes. (scm_system_star): Move to posix.c. * libguile/simpos.h (scm_system_star): Remove. * libguile/posix.h (scm_system_star): Add. * libguile/posix.c (scm_system_star): Move here and implement in terms of open-process. This lets system* work on Windows. Inspired by a patch by Eli Zaretskii. (start_child): Exit with 127 if the command isn't found.
2016-08-11build: .x and .doc files depend on generated includes.Mark H Weaver1-5/+5
Fixes <https://bugs.gentoo.org/show_bug.cgi?id=590528>. * libguile/Makefile.am (BUILT_INCLUDES): New variable. (BUILT_SOURCES): Put .i and other generated .h to BUILT_INCLUDES. (DOT_X_FILES, EXTRA_DOT_X_FILES, DOT_DOC_FILES, EXTRA_DOT_DOC_FILES): Depend on $(BUILT_INCLUDES), in place of scmconfig.h which is included in $(BUILT_INCLUDES).
2016-08-11Revert "Snarfing .x depends on built headers"Mark H Weaver1-5/+5
This reverts commit edd6d6e2805894e21afe51276d1af65d5395180d. As reported at <https://bugs.gentoo.org/show_bug.cgi?id=590528#c10>, that commit failed to fix the bug. That commit was based on the mistaken belief that the make rule syntax ".c.x: $(BUILT_INCLUDES)" means the same as ".c.x:" but with the added prerequisites "$(BUILT_INCLUDES)". However, as explained in section 10.7 (Old-Fashioned Suffix Rules) of the GNU Make manual: Suffix rules cannot have any prerequisites of their own. If they have any, they are treated as normal files with funny names, not as suffix rules. Thus, the rule: .c.o: foo.h $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< tells how to make the file '.c.o' from the prerequisite file 'foo.h', and is not at all like the pattern rule: %.o: %.c foo.h $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< which tells how to make '.o' files from '.c' files, and makes all '.o' files using this pattern rule also depend on 'foo.h'.
2016-08-07Let assv/assoc shortcircuit to assq where feasibleDavid Kastrup1-0/+21
* libguile/alist.c (scm_sloppy_assv, scm_sloppy_assoc): (scm_assv, scm_assoc): Shortcircuit to scm_assq where feasible.
2016-08-07Fix iconv encoding of long stringsAndy Wingo1-1/+5
* libguile/print.c (display_string_using_iconv): If the encoding the full utf8 buffer would overflow the output buffer, just keep trucking instead of erroring. Fixes #22667. * test-suite/tests/iconv.test ("round-trip"): Add some tests.
2016-08-07Snarfing .x depends on built headersAndy Wingo1-5/+5
* libguile/Makefile.am (BUILT_INCLUDES): New variable. (BUILT_SOURCES): Put .i and other generated .h to BUILT_INCLUDES. (.c.x, .c.doc): Depend on BUILT_INCLUDES. Fixes https://bugs.gentoo.org/show_bug.cgi?id=590528.
2016-07-24Avoid compilation warnings about alloca in read.cEli Zaretskii1-0/+1
* libguile/read.c: Include alloca.h.
2016-07-24Fix --without-threads against threaded BDW-GCAndy Wingo1-0/+6
* libguile/gc.c (scm_storage_prehistory): Prevent BDW-GC from spawning marker threads if Guile was built without threading support.
2016-07-24Reimplement null-threads as inline functionsAndy Wingo1-30/+149
* libguile/null-threads.h: Reimplement null-threads stubs for pthread data types, initializers, and functions in terms of types and inline functions instead of CPP macros. Fixes unused-value warnings, and tightens things up in general. (scm_i_pthread_cleanup_push, scm_i_pthread_cleanup_pop): Remove these, as they were unused and incorrect -- they would never run the cleanup handler even if 1 was passed to pop.
2016-07-23Use non-deprecated HAVE_STRUCT_TM_TM_ZONEAndy Wingo1-5/+5
* libguile/stime.c: Change uses of the deprecated HAVE_TM_ZONE to the new HAVE_STRUCT_TM_TM_ZONE.
2016-07-23Use gnulib for basename / dirnameAndy Wingo1-54/+32
* libguile/filesys.c (scm_dirname, scm_basename): Rewrite to use gnulib's dirname-lgpl.
2016-07-16Untabify posix-w32.cEli Zaretskii1-302/+302
2016-07-16Improve process handling on MS-WindowsEli Zaretskii1-17/+216
* libguile/posix-w32.c: Include gc.h and threads.h. (proc_record): New structure tag. <procs, proc_size>: New static variables. (find_proc, proc_handle, record_proc, delete_proc): New utility functions. (start_child): Return value is now pid_t, as it is on Posix platforms. Record the new process and returns its PID, instead of returning a handle. Fix the recursive call. (waitpid, kill, getpriority, setpriority, sched_getaffinity) (sched_setaffinity): Look up the PID in the recorded subprocesses before trying to open a process that is not our subprocess. Make sure any open handle is closed before returning, unless it's our subprocess.
2016-07-16Fix mkstemp! with 1 argumentAndy Wingo1-5/+3
* libguile/filesys.c (scm_i_mkstemp): Add SCM_OPN to flags if mode argument not given.
2016-07-16Allow mkstemp! to have optional "mode" argumentAndy Wingo3-39/+87
* 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-16Update uname implementation in posix-w32Eli Zaretskii1-8/+27
* libguile/posix-w32.c (uname): Update to modern processors (ia64 and x86_64) and OS versions (Vista to Windows 10). Delete trailing whitespace.
2016-07-16Fix unused static variables in net_db.cAndy Wingo1-55/+28
* libguile/net_db.c (SCM_DEFINE_CONSTANT): New helper. Use it to define constants and avoid the unneeded static variables that were used before, named "sym_" but actually holding variables. Thanks to Eli Zaretskii for the report.
2016-07-14Add popen featureAndy Wingo1-0/+1
* doc/ref/api-options.texi (Common Feature Symbols): Document the popen feature. * doc/ref/posix.texi (Pipes): Depend on the popen feature, not fork. * libguile/posix.c (scm_init_posix): Add popen feature if we can.
2016-07-14Refactor implementation of current-warning-portAndy Wingo2-18/+20
* 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-12Add POSIX shims for MinGWEli Zaretskii3-3/+911
* libguile/posix-w32.h: * libguile/posix-w32.c (kill, waitpid, getpriority, setpriority) (sched_getaffinity, sched_setaffinity): Add MinGW implementations. Also, provides macros that on Posix hosts are in sys/wait.h, like WIFEXITED and WTERMSIG. (start_child): Add implementation.
2016-07-12Keep trucking on weak table corruptionAndy Wingo1-2/+14
* libguile/hashtab.c (vacuum_weak_hash_table): Don't abort if we apparently remove more items than are in the table; instead print a warning. "Fixes" #19180.
2016-07-11Rename win32-uname.[ch] to posix-w32.[ch]Andy Wingo4-10/+10
* libguile/posix-w32.c: * libguile/posix-w32.h: Rename from win32-uname.c and win32-uname.h. * libguile/posix.c: * libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES) (noinst_HEADERS): Adapt.
2016-07-11Factor start_child out of open_processAndy Wingo1-84/+104
* libguile/posix.c (start_child): Factor out from open_process. Based on initial work by Eli Zaretskii.
2016-07-11More specific status:exit-val et al compilation guardsAndy Wingo1-2/+6
* libguile/posix.c (scm_status_exit_val, scm_status_term_sig) (scm_status_stop_sig): Guard on WIFEXITED et al macros instead of on MinGW.
2016-07-11getaffinity, setaffinity docstring cleanupAndy Wingo1-12/+2
* libguile/posix.c (scm_getaffinity, scm_setaffinity): Clean up docstrings. Obviously if you have the function, you don't need to be told that you have it in the docstring.
2016-07-11Provide `kill' only if supported by the hostAndy Wingo1-19/+2
* libguile/posix.c (scm_kill): Only provide if the host has `kill'. An incompatible change on MinGW, where this function would work only if the PID was the current PID, but that will be fixed by the next process.
2016-07-11More robust setuid, setgid, etc detectionAndy Wingo1-14/+16
* configure.ac: Check for getuid, getgid, setuid, and setgid. * libguile/posix.c (scm_getuid, scm_getgid, scm_setuid, scm_setgid): Only provide Scheme functions if the OS provides these facilities. (scm_geteuid, scm_getegid, scm_seteuid, scm_setegid): Provide if the host has getuid, getgid, etc, instead of being in a MinGW guard.
2016-07-11Locale is default port encodingAndy Wingo1-0/+3
* libguile/ports.c (scm_init_ports): Use the locale as the default charset. This allows GUILE_INSTALL_LOCALE=1 to work properly, harmonizing the default port encoding with the installed locale.
2016-07-11Fix invalid use of 'PTR2SCM'.Ludovic Courtès1-3/+3
Fixes a typo introduced in 04359b42b952ce1a09444e64d83dae9fb0a39da6. * libguile/load.c (try_load_thunk_from_file): Use 'SCM2PTR', not 'PTR2SCM'.
2016-07-11Add missing 'const' qualifier.Ludovic Courtès1-1/+1
* libguile/stime.c (tzvar): Add 'const'.
2016-07-11Unconditionally include <time.h> from Gnulib.Ludovic Courtès1-5/+1
* libguile/stime.c: Unconditionally include <time.h>.
2016-07-10Add meta/build-envAndy Wingo1-1/+1
* 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-06-29Skip incompatible .go filesAndy Wingo1-109/+295
* 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-26Check for strtod_l before using it.Andy Wingo1-2/+2
Based on a patch by Andy Stormont <astormont@racktopsystems.com>. * configure.ac: Check for strtod_l. * libguile/i18n.c (scm_locale_string_to_integer): Fix style. (scm_locale_string_to_inexact): Check for strtod_l.
2016-06-26Fix ,profile in pure modulesAndy Wingo1-2/+4
* libguile/scmsigs.c (close_1): Make the async closure in an environment where `lambda' has its usual meaning. Fixes #21013.
2016-06-23Register R6RS port and bytevector internals earlyAndy Wingo2-18/+18
* libguile/bytevectors.c (sym_big, sym_little): Rename from scm_sym_big and scm_sym_little, and don't use the snarf mechanism as we need to initialize this value eagerly in case the C API is used before the Scheme module is loaded. (scm_bootstrap_bytevectors): Initialize the endianness symbols here. * libguile/r6rs-ports.c (scm_register_r6rs_ports): Register the R6RS port kinds here, for the same reason.
2016-06-23Fix memory leak in scm_from_{u,}int64 on 32-bit platformsAndy Wingo2-2/+2
* libguile/conv-integer.i.c (SCM_FROM_TYPE_PROTO): * libguile/conv-uinteger.i.c (SCM_FROM_TYPE_PROTO): Fix a big in which scm_from_int64 and scm_from_uint64 on a 32-bit platform leaked memory if they needed to allocate a bignum. Fixes #20079.
2016-06-23Fix race between SMOB marking and finalizationAndy Wingo1-3/+30
* libguile/smob.c (clear_smobnum): New helper. (finalize_smob): Re-set the smobnum to the "finalized smob" type before finalizing. Fixes #19883. (scm_smob_prehistory): Pre-register a "finalized smob" type, which has no mark procedure. * test-suite/standalone/test-smob-mark-race.c: New file. * test-suite/standalone/Makefile.am: Arrange to build and run the new test.
2016-06-22Remove unused internal i18n functionsAndy Wingo1-38/+0
* libguile/i18n.c (str_upcase, str_downcase, str_upcase_l) (str_downcase_l): Remove unused inline functions. Based on a patch by Pedro Aguilar <paguilar@paguilar.org>. Fixes #19172.
2016-06-21Fix size measurement in bytevector_large_setAndy Wingo1-3/+4
* libguile/bytevectors.c (bytevector_large_set): Fix computation of value size in words. * test-suite/tests/bytevectors.test: Add test. Thanks to Ben Rocer <fleabyte@mail.com> for the bug report and fix.