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

273 commits

Author SHA1 Message Date
Andy Wingo
24eea1be08 "select" no longer throws exception on EINTR
* doc/ref/posix.texi (Ports and File Descriptors): Update.
* libguile/filesys.c (scm_select): Use scm_std_select so that pending
  interrupts can be delivered.  On EINTR or EAGAIN, just return directly
  so that calling Scheme code can run asyncs.
2017-03-01 17:27:56 +01:00
Andy Wingo
a86bb2e613 Fix (mkstemp! "XX" 0) errors
* 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-01 14:48:37 +01:00
Andy Wingo
69ca2bb221 Elide syscalls in fdes->port
* libguile/fports.h (scm_t_fport): Add options field.
  (SCM_FDES_RANDOM_P): Deprecate.
  (scm_i_fdes_to_port): Add options argument.
* libguile/fports.c (scm_i_fdes_to_port): Add options argument.  Only
  verify FD if SCM_FPORT_OPTION_VERIFY is there.
  (scm_fdes_to_port, scm_open_file_with_encoding): Adapt to
  scm_i_fdes_to_port changes.
  (fport_random_access_p): Don't try to seek if NOT_SEEKABLE option is
  set.
* libguile/deprecated.h:
* libguile/deprecated.c (SCM_FDES_RANDOM_P): Deprecate.
* NEWS: Add deprecation.
* libguile/filesys.c:
* libguile/ioext.c:
* libguile/posix.c:
* libguile/read.c:
* libguile/socket.c: Adapt callers.
2017-02-14 22:03:21 +01:00
Andy Wingo
09a69dd712 Prevent TOCTTOU bugs in C ports
* libguile/ports-internal.h (scm_port_buffer_can_take):
  (scm_port_buffer_can_put): Add cur/end output arguments so that when a
  caller asks the buffer room, it can be relative to a fixed point in
  the buffer and not whatever point it's at when we go to fill it.
  (scm_port_buffer_did_take, scm_port_buffer_did_put): Similarly,
  require that the caller knows where they took/put data in the buffer.
  Prevents overflow.
  (scm_port_buffer_take_pointer, scm_port_buffer_put_pointer): Likewise,
  require that the caller has already checked and knows a position in
  the buffer and therefore how much data is available.
  (scm_port_buffer_take, scm_port_buffer_put, scm_port_buffer_putback):
  Adapt.
* libguile/ports.h (scm_fill_input): Add cur/avail output arguments.
* libguile/filesys.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/r6rs-ports.c:
* libguile/read.c:
* libguile/rw.c: Adapt all callers.  Gnarly work!
2017-02-08 15:09:14 +01:00
Andy Wingo
6ff1ec9c31 Fix mkstemp on macOS
* libguile/filesys.c (scm_i_mkstemp): Limit flags to mkostemp.  Based on
  a patch by Matt Wette; thanks!
2017-01-08 23:25:56 +01:00
Andy Wingo
7ff3d3834d Use readdir instead of readdir_r
* libguile/filesys.c:
* configure.ac: Remove readdir_r / readdir64_r checks and usage.
  glibc's impls are thread-safe, the _r variants are squirrely and now
  deprecated in glibc, and it is expected that POSIX will mandate that
  readdir{,64} be thread-safe already.  See
  https://sourceware.org/ml/libc-alpha/2016-02/msg00093.html.
2016-12-06 23:02:28 +01:00
Andy Wingo
2fa2e50a0f Add file descriptor finalizers
* doc/ref/posix.texi (Ports and File Descriptors): Document new
  interfaces.
* libguile/filesys.c (scm_close, scm_close_fdes)
* libguile/fports.c (fport_close):
* libguile/ioext.c (scm_primitive_move_to_fdes): Call
  scm_run_fdes_finalizers.
* module/ice-9/fdes-finalizers.scm:
* test-suite/tests/fdes-finalizers.test:
* libguile/fdes-finalizers.h:
* libguile/fdes-finalizers.c: New files.
* module/Makefile.am:
* test-suite/Makefile.am:
* libguile/Makefile.am:
* libguile.h:
* libguile/init.c: Wire up new files.
2016-08-30 23:35:10 +02:00
Andy Wingo
1f14900a07 Use gnulib for basename / dirname
* libguile/filesys.c (scm_dirname, scm_basename): Rewrite to use
  gnulib's dirname-lgpl.
2016-07-25 11:49:55 +02:00
Andy Wingo
aae3561584 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-25 11:46:18 +02:00
Andy Wingo
9a95167871 Fix relative file name canonicalization on paths with "."
* libguile/filesys.c (scm_i_relativize_path): Canonicalize the file
  names elements that we will be using as prefixes.  Fixes the case
  where a load path contains a relative file name: #19540.
* test-suite/tests/ports.test ("%file-port-name-canonicalization"): Add
  tests that elements of the load path are canonicalized.
2016-06-23 10:17:57 +02:00
Taylan Ulrich Bayırlı/Kammer
704c911893 Correct docstring of 'symlink'.
* libguile/filesys.c (symlink): Correct the docstring, which had
  'oldpath' and 'newpath' confused.
2016-05-22 19:09:47 +02:00
Andy Wingo
cd51ce81d0 Use heap-allocated port types instead of ptobnums
This removes a limitation on the number of port types, simplifies the
API, and removes a central point of coordination.

* libguile/ports-internal.h (struct scm_t_port_type): Rename from
  scm_t_ptob_descriptor, now that it's private.  Add GOOPS class
  fields.
  (struct scm_t_port): Rename from struct scm_port, especially
  considering that deprecated.h redefines scm_port using the
  preprocessor :(.
* libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE,
  though the scm_t_port and scm_t_port_type types are incomplete.
  (SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no
  more typecodes for port types.
  (scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x):
  Remove.
  (scm_make_port_type): Return a scm_t_port_type*.  All methods adapted
  to take a scm_t_port_type* instead of a ptobnum.
  (scm_c_make_port_with_encoding, scm_c_make_port): Take a port type
  pointer instead of a tag.
  (scm_new_port_table_entry): Remove; not useful.
* libguile/ports.c: Remove things related to the port kind table.  Adapt
  uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use
  SCM_PORT_TYPE and scm_t_port_type.
* libguile/deprecated.c:
* libguile/deprecated.h:
* libguile/filesys.c:
* libguile/fports.c:
* libguile/fports.h:
* libguile/print.c:
* libguile/r6rs-ports.c:
* libguile/strports.c:
* libguile/strports.h:
* libguile/tags.h:
* libguile/vports.c:
* test-suite/standalone/test-scm-c-read.c: Adapt to change.
* libguile/goops.c (scm_class_of, make_port_classes)
  (scm_make_port_classes, create_port_classes): Adapt to store the
  classes in the ptob.
2016-05-13 18:31:29 +02:00
Andy Wingo
08574987d9 Remove scm_t_port_internal
* libguile/ports-internal.h (SCM_PORT): Rename from SCM_PTAB_ENTRY.
  (scm_t_port_internal, SCM_PORT_GET_INTERNAL): Remove.
  (SCM_FILENAME, SCM_SET_FILENAME, SCM_LINUM, SCM_COL): Adapt.
* libguile/ports.c:
* libguile/poll.c:
* libguile/ioext.c:
* libguile/fports.c:
* libguile/filesys.c:
* libguile/print.c:
* libguile/read.c:
* libguile/rw.c:
* libguile/strings.c: Adapt.
2016-05-13 11:34:52 +02:00
Andy Wingo
9a9e0cceae Make port buffering fields private
* libguile/ports-internal.h (enum scm_port_buffer_field)
  (scm_t_port_internal): Make port buffering fields private.
* libguile/ports.h (scm_t_port): Adapt.
* libguile/filesys.c (set_element):
* libguile/ioext.c (scm_redirect_port):
* libguile/poll.c (scm_primitive_poll):
* libguile/ports.c:
* libguile/read.c (scm_i_scan_for_encoding):
* libguile/rw.c (scm_write_string_partial): Adapt users.
2016-05-13 10:58:19 +02:00
Andy Wingo
105e36543f Remove scm_puts_unlocked.
* libguile/ports.h (scm_puts_unlocked): Remove.
* libguile/ports.c (scm_puts): Replace implementation with
  scm_puts_unlocked's implementation.
* libguile/arbiters.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/continuations.c:
* libguile/deprecation.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/load.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/smob.c:
* libguile/srcprop.c:
* libguile/srfi-14.c:
* libguile/stackchk.c:
* libguile/struct.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/values.c:
* libguile/variable.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c: Use scm_puts instead of scm_puts_unlocked.
2016-04-26 23:07:28 +02:00
Andy Wingo
206b3f6e03 Remove scm_putc_unlocked.
* libguile/ports.h (scm_putc_unlocked): Remove.
* libguile/ports.c (scm_putc): Replace implementation with
  scm_putc_unlocked's implementation.
  (scm_port_print): Use scm_putc.
* libguile/arbiters.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/smob.c:
* libguile/srcprop.c:
* libguile/struct.c:
* libguile/variable.c:
* libguile/weak-set.c:
* libguile/weak-table.c: Use scm_putc instead of scm_putc_unlocked.
2016-04-26 23:01:14 +02:00
Andy Wingo
99899b7c9c Remove scm_flush_unlocked / scm_end_input_unlocked
* libguile/ports.h (scm_flush_unlocked, scm_end_input_unlocked):
  Remove.
* libguile/ports.c (scm_c_read_bytes_unlocked):
  (scm_i_unget_bytes_unlocked, scm_setvbuf, scm_force_output)
  (scm_fill_input_unlocked, scm_c_write_bytes_unlocked)
  (scm_c_write_unlocked, scm_lfwrite_unlocked, scm_seek)
  (scm_truncate_file, flush_output_port): Call scm_flush / scm_end_input
  instead of the _unlocked variants.
  (scm_end_input): Lock while discarding the input buffer but not while
  calling out to the seek function.
* libguile/filesys.c (scm_fsync):
* libguile/ioext.c (scm_redirect_port):
* libguile/read.c (scm_i_scan_for_encoding):
* libguile/rw.c (scm_write_string_partial): Use scm_flush, not
  scm_flush_unlocked.
2016-04-23 15:21:43 +02:00
Andy Wingo
b869344a4f Remove size field from port buffers
* libguile/ports.h (scm_t_port_buffer): Remove size field.  Instead use
  bytevector size.
* libguile/ports-internal.h (scm_port_buffer_size)
  (scm_port_buffer_reset)
  (scm_port_buffer_can_take, scm_port_buffer_can_put)
  (scm_port_buffer_did_take, scm_port_buffer_did_put)
  (scm_port_buffer_take_pointer, scm_port_buffer_put_pointer)
  (scm_port_buffer_take, scm_port_buffer_put): New helpers.
* libguile/filesys.c (set_element): Use new helpers.
* libguile/poll.c (scm_primitive_poll): Use new helpers.
* libguile/ports.c (scm_c_make_port_buffer): No more "size" field.
  (scm_i_read_unlocked, scm_c_read_bytes_unlocked)
  (scm_c_read_unlocked, scm_i_unget_bytes_unlocked)
  (scm_unget_bytes, scm_setvbuf, scm_take_from_input_buffers)
  (scm_drain_input, scm_end_input_unlocked, scm_flush_unlocked)
  (scm_fill_input_unlocked, scm_i_write_unlocked)
  (scm_c_write_bytes_unlocked, scm_c_write_unlocked)
  (scm_char_ready_p): Use new helpers.
* libguile/r6rs-ports.c (scm_get_bytevector_some): Use new helpers.
* libguile/rw.c (scm_write_string_partial): Use new helpers.
2016-04-17 19:38:44 +02:00
Andy Wingo
8399e7af51 Generic port facility provides buffering uniformly
* libguile/ports.h (struct scm_t_port_buffer): New data type.
  (struct scm_t_port): Refactor to use port buffers instead of
  implementation-managed read and write pointers.  Add "read_buffering"
  member.
  (SCM_INITIAL_PUTBACK_BUF_SIZE, SCM_READ_BUFFER_EMPTY_P): Remove.
  (scm_t_ptob_descriptor): Rename "fill_input" function to "read", and
  take a port buffer, returning void.  Likewise "write" takes a port
  buffer and returns void.  Remove "end_input"; instead if there is
  buffered input and rw_random is true, then there must be a seek
  function, so just seek back if needed.  Remove "flush"; instead all
  calls to the "write" function implicitly include a "flush", since the
  buffering happens in the generic port code now.  Remove "setvbuf", but
  add "get_natural_buffer_sizes"; instead the generic port code can
  buffer any port.
  (scm_make_port_type): Adapt to read and write prototype changes.
  (scm_set_port_flush, scm_set_port_end_input, scm_set_port_setvbuf):
  Remove.
  (scm_slow_get_byte_or_eof_unlocked)
  (scm_slow_get_peek_or_eof_unlocked): Remove; the slow path is to call
  scm_fill_input.
  (scm_set_port_get_natural_buffer_sizes): New function.
  (scm_c_make_port_buffer): New internal function.
  (scm_port_non_buffer): Remove.  This was a function for
  implementations that is no longer needed.  Instead open with BUF0 or
  use (setvbuf port 'none).
  (scm_fill_input, scm_fill_input_unlocked): Return the filled port
  buffer.
  (scm_get_byte_or_eof_unlocked, scm_peek_byte_or_eof_unlocked): Adapt
  to changes in buffering and EOF management.
* libguile/ports.c: Adapt to port interface changes.
  (initialize_port_buffers): New function, using the port mode flags to
  set up appropriate initial buffering for all ports.
  (scm_c_make_port_with_encoding): Create port buffers here instead of
  delegating to implementations.
  (scm_close_port): Flush the port if needed instead of delegating to
  the implementation.
* libguile/filesys.c (set_element): Adapt to buffering changes.
* libguile/fports.c (fport_get_natural_buffer_sizes): New function,
  replacing scm_fport_buffer_add.
  (fport_write, fport_read): Update to let the generic ports code do the
  buffering.
  (fport_flush, fport_end_input): Remove.
  (fport_close): Don't flush in a dynwind; that's the core ports' job.
  (scm_make_fptob): Adapt.
* libguile/ioext.c (scm_redirect_port): Adapt to buffering changes.
* libguile/poll.c (scm_primitive_poll): Adapt to buffering changes.
* libguile/ports-internal.h (struct scm_port_internal): Remove
  pending_eof flag; this is now set on the read buffer.
* libguile/r6rs-ports.c (struct bytevector_input_port): New type.  The
  new buffering arrangement means that there's now an intermediate
  buffer between the bytevector and the user of the port; this could
  lead to a perf degradation, but on the other hand there are some other
  speedups enabled by the buffering refactor, so probably the memcpy
  cost is dwarfed by the cost of the other parts of the ports
  machinery.
  (make_bytevector_input_port, bytevector_input_port_read):
  (bytevector_input_port_seek, initialize_bytevector_input_ports): Adapt
  to new buffering arrangement.
  (struct custom_binary_port): Remove read buffer, as Guile handles that
  now.
  (custom_binary_input_port_setvbuf): Remove; now handled by Guile.
  (make_custom_binary_input_port, custom_binary_input_port_read)
  (initialize_custom_binary_input_ports): Adapt.
  (scm_get_bytevector_some): Adapt to new EOF management.
  (scm_t_bytevector_output_port_buffer): Hold on to the underlying port,
  so we can flush it if it's open.
  (make_bytevector_output_port, bytevector_output_port_write):
  (bytevector_output_port_seek): Adapt.
  (bytevector_output_port_procedure): Flush the port as appropriate, so
  that we get all the bytes.
  (make_custom_binary_output_port, custom_binary_output_port_write):
  Adapt.
  (make_transcoded_port): Don't muck with buffering.
  (transcoded_port_write): Simply forward the write to the underlying
  port.
  (transcoded_port_read): Likewise.
  (transcoded_port_close): No need to flush.
  (initialize_transcoded_ports): Adapt.
* libguile/read.c (scm_i_scan_for_encoding): Adapt to buffering
  changes.
* libguile/rw.c (scm_write_string_partial): Adapt to buffering changes.
* libguile/strports.c: Adapt to the fact that we don't manage the
  buffer.  Probably room for speed improvements here...
* libguile/vports.c (soft_port_get_natural_buffer_sizes): New function.
  Adapt the rest of the file for the new buffering regime.
* test-suite/tests/r6rs-ports.test ("8.2.10 Output ports"): Custom
  binary output ports need to be flushed before you can rely on the
  write! procedure having been called.  Add necessary flush-port
  invocations.
  ("8.2.6  Input and output ports"): Transcoded ports now have an
  internal buffer by default.  This test checks that the characters are
  transcoded one at a time, so to do that, call setvbuf on the
  transcoded port to remove the buffer.
* test-suite/tests/web-client.test (run-with-http-transcript): Fix for
  different flushing regime on soft ports.  (The vestigial flush
  procedure is now called after each write, which is not what the test
  was expecting.)
* test-suite/standalone/test-scm-c-read.c: Update for changes to the C
  interface for defining port types.
* doc/ref/api-io.texi (Ports): Update to discuss buffering in a generic
  way, and to remove a hand-wavey paragraph describing string ports as
  "interesting and powerful".
  (Reading, Writing): Remove placeholder comments.  Document
  `scm_lfwrite'.
  (Buffering): New section.
  (File Ports): Link to buffering.
  (I/O Extensions): Join subnodes into parent and describe new API,
  including buffering API.
* doc/ref/posix.texi (Ports and File Descriptors): Link to buffering.
  Remove unread-char etc, as they are documented elsewhere.
  (Pipes, Network Sockets and Communication): Link to buffering.
2016-04-06 19:21:44 +02:00
Andy Wingo
a5b5cb422e Merge commit '8cf2a7ba74' 2015-01-22 13:24:30 +01:00
Ludovic Courtès
d1447c717b doc: Clarify behavior of 'select' in the presence of signal interruptions.
Fixes <http://bugs.gnu.org/18988>.
Reported by Chris Vine <chris@cvine.freeserve.co.uk>.

* libguile/filesys.c (scm_select): Clarify handling of signal
  interruptions.
* doc/ref/posix.texi (Ports and File Descriptors): Adjust accordingly.
2014-11-20 21:32:44 +01:00
Mark H Weaver
856d318a9f Merge branch 'stable-2.0'
Conflicts:
	benchmark-suite/benchmarks/ports.bm
	libguile/async.h
	libguile/bytevectors.c
	libguile/foreign.c
	libguile/gsubr.c
	libguile/srfi-1.c
	libguile/vm-engine.h
	libguile/vm-i-scheme.c
	module/Makefile.am
	module/language/tree-il/analyze.scm
	module/language/tree-il/peval.scm
	module/scripts/compile.scm
	module/scripts/disassemble.scm
	test-suite/tests/asm-to-bytecode.test
	test-suite/tests/peval.test
	test-suite/tests/rdelim.test
2014-09-30 03:50:47 -04:00
Eli Zaretskii
9235f805fa Fix problems with Windows file names that use backslashes.
* libguile/load.c (scm_i_mirror_backslashes): New function.
  (scm_init_load_path): Call it to produce MS-Windows file names
  with forward slashes.
  (FILE_NAME_SEPARATOR_STRING): Define as "/" on all platforms.

* libguile/load.h (scm_i_mirror_backslashes): Add prototype.

* libguile/init.c (scm_boot_guile): Call scm_i_mirror_backslashes
  on argv[0].

* libguile/filesys.c (scm_getcwd): Call scm_i_mirror_backslashes
  on the directory name returned by getcwd.

* test-suite/tests/ports.test ("file name separators"): New test.
2014-07-03 20:58:19 +03:00
Mark H Weaver
475772ea57 Merge branch 'stable-2.0'
Conflicts:
	GUILE-VERSION
	NEWS
	guile-readline/ice-9/readline.scm
	libguile/async.c
	libguile/backtrace.c
	libguile/deprecated.h
	libguile/gc-malloc.c
	libguile/gdbint.c
	libguile/init.c
	libguile/ioext.c
	libguile/mallocs.c
	libguile/print.c
	libguile/rw.c
	libguile/scmsigs.c
	libguile/script.c
	libguile/simpos.c
	libguile/snarf.h
	libguile/strports.c
	libguile/threads.c
	libguile/vm-i-scheme.c
	libguile/vm-i-system.c
	module/srfi/srfi-18.scm
	test-suite/Makefile.am
	test-suite/standalone/test-num2integral.c
2014-04-25 02:06:01 -04:00
Mark H Weaver
bc8e6d7d8c Rely on Gnulib for <unistd.h>.
* libguile/async.c:
* libguile/backtrace.c:
* libguile/error.c:
* libguile/filesys.c:
* libguile/fports.c:
* libguile/gc-malloc.c:
* libguile/gc.c:
* libguile/gdbint.c:
* libguile/init.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/mallocs.c:
* libguile/mkstemp.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/simpos.c:
* libguile/socket.c:
* libguile/stime.c:
* libguile/strports.c:
* libguile/threads.c: Unconditionally include <unistd.h>.
2014-02-27 22:38:48 -05:00
Mark H Weaver
ca6adcc6df Rely on Gnulib for fsync, link, readlink, mkdir, rmdir, and rename.
* libguile/filesys.c: Remove 'fsync' wrapper for MinGW.
  (scm_link, scm_readlink, scm_mkdir, scm_rmdir): Define these
  unconditionally.
  (my_rename): Remove.
  (scm_rename): Use 'rename' instead of 'my_rename'.
2014-02-27 22:38:09 -05:00
Mark H Weaver
e1d7a93bb2 Rely on Gnulib for 'select', 'lstat', and 'mkstemp'.
* libguile/iselect.h:
* libguile/threads.c:
* libguile/deprecated.h: Rely on Gnulib for sys/select.h.

* libguile/filesys.c: Rely on Gnulib for 'lstat' and 'mkstemp'.
2014-02-12 20:53:29 -05:00
Daniel Llorens
d747313100 Change uses of scm_is_simple_vector to scm_is_vector
* libguile/filesys.c, libguile/random.c, libguile/stime.c, libguile/trees.c,
  libguile/validate.h: use scm_is_vector instead of scm_is_simple_vector.
* libguile/sort.c (scm_sort_x, scm_sort, scm_stable_sort_x)
  (scm_stable_sort): Remove scm_is_vector check; scm_is_array is
  sufficient.
* test-suite/tests/arrays.test: Fix header.
* test-suite/tests/random.test: New coverage test covering
  random:normal-vector!.
* test-suite/Makefile.am: Include random.test in make check.
2014-02-08 18:26:49 +01:00
Andy Wingo
5a706f0342 More private-gc excisions
* libguile/private-gc.h (SCM_DOUBLECELL_ALIGNED_P): Remove; unused.
* libguile/filesys.c (MAX, MIN): Move definitions here, from
  private-gc.h.
  (scm_sendfile, scm_readdir): Adapt uses of SCM_MAX and SCM_MIN to use
  MAX or MIN.
2013-11-28 11:43:51 +01:00
Mark H Weaver
f6f4feb0a2 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/array-map.c
	libguile/fports.h
	libguile/gc.h
	libguile/inline.h
	libguile/ports.c
	libguile/ports.h
	libguile/print.c
	libguile/r6rs-ports.c
	libguile/read.c
	test-suite/tests/00-socket.test
2013-04-14 02:48:33 -04:00
Mark H Weaver
7f3be1db99 Miscellaneous 'sendfile' fixes and improved tests.
* libguile/filesys.c (scm_sendfile): In Linux-style sendfile(2) code, if
  EINTR or EAGAIN occurs, set result to 1 (not 0) so that we actually
  keep going.  In non-sendfile(2) code, deal gracefully with short reads
  due to EOF.

* test-suite/tests/filesys.test ("sendfile"): Use 'let*' to guarantee
  the needed order of operations: write (test-file) and then read it.
  Add code to check the written data (not just the returned length) in
  all tests, including the cases that hit EOF prematurely.
2013-04-08 00:36:00 -04:00
Ludovic Courtès
e0886e0780 Change `sendfile' to loop until everything has been sent.
* libguile/filesys.c (scm_sendfile)[HAVE_SYS_SENDFILE_H &&
  HAVE_SENDFILE]: Compare RESULT with C_COUNT.  Loop until C_COUNT bytes
  have been sent.
* doc/ref/posix.texi (File System): Update the description.  Explain the
  new semantics.
* test-suite/tests/filesys.test ("sendfile"): Rewrite using
  `pass-if-equal'.  Check the return value for all the tests.
  ["file with offset past the end", "file with offset near the end"]:
  New tests.
2013-04-07 23:47:38 +02:00
Mark H Weaver
26d148066f Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	configure.ac
	libguile/deprecated.c
	libguile/deprecated.h
	libguile/filesys.h
	libguile/fluids.c
	libguile/fports.c
	libguile/gc.c
	libguile/guile.c
	libguile/numbers.c
	libguile/objcodes.c
	libguile/r6rs-ports.c
	libguile/smob.c
	libguile/socket.c
	libguile/threads.h
	module/language/scheme/decompile-tree-il.scm
	module/language/tree-il/peval.scm
	test-suite/tests/syncase.test
2013-03-28 05:09:53 -04:00
Ludovic Courtès
11ed42771d sendfile: Make sure we have a Linux-style `sendfile'.
* libguile/filesys.c (scm_sendfile): Change conditional to
  HAVE_SYS_SENDFILE_H && HAVE_SENDFILE.
2013-03-25 13:51:57 +01:00
Ludovic Courtès
f28885f495 sendfile: Check return value of `lseek'.
* libguile/filesys.c (scm_sendfile): Check return value of
  `lseek_or_lseek64', and use `SCM_SYSERROR' upon error.
2013-03-25 13:28:42 +01:00
Ludovic Courtès
fbac7c6113 Add bindings for `sendfile'.
* configure.ac: Check for <sys/sendfile.h> and `sendfile'.
* libguile/filesys.c (scm_sendfile): New function.
* libguile/filesys.h (scm_sendfile): New declaration.
* test-suite/tests/filesys.test ("sendfile"): New test prefix.
* doc/ref/posix.texi (File System): Document `sendfile'.
2013-03-22 22:21:13 +01:00
Andy Wingo
ba59471eee simplify filesys.c via gnulib's select and fstat modules
* libguile/filesys.c: Instead of using scm_std_select, just use select,
  relying on gnulib to provide it to us.  Likewise, rely on fstat.
2013-03-09 22:30:26 +01:00
Ludovic Courtès
69b6da07c3 Use `scm_is_eq' in filesys.c.
* libguile/filesys.c (is_file_name_separator): Use `scm_is_eq' instead
  of `=='.  Fixes <http://hydra.nixos.org/build/4261579>.
2013-03-04 08:57:08 +01:00
Andy Wingo
7a17979ea4 cleanup to filesys.c's handling of file name separators
* libguile/filesys.c (is_file_name_separator): New helper, as in
  load.c.
  (scm_dirname, scm_basename, scm_i_relativize_path): Use
  is_file_name_separator.
2013-02-24 14:20:18 +01:00
Andy Wingo
c21939bc24 simplify scm_stat on mingw
* libguile/filesys.c (scm_stat): Don't munge the filename on MinGW;
  gnulib does that for us.
2013-02-24 14:18:29 +01:00
Andy Wingo
5a4a4454c5 copy-file and load-objcode use O_BINARY
* libguile/filesys.c (scm_copy_file):
* libguile/objcodes.c (scm_load_objcode): Use O_BINARY.  Thanks to Eli
  Zaretskii for the patch.
2013-02-19 22:36:22 +01:00
Andy Wingo
9b6316eabc better handling of windows file name conventions
* libguile/filesys.c (scm_system_file_name_convention): New function.
  Exported to Scheme only.

* module/ice-9/boot-9.scm (file-name-separator?, absolute-file-name?):
  New predicates.
  (file-name-separator-string): New global variable.
  (in-vicinity): Use the new procedures.
  (load-user-init, try-module-autoload): Use file-name-separator-string.
  (load-in-vicinity): Update canonical->suffix.  Consistently use the
  term "file name" throughout.

* module/ice-9/psyntax.scm (include): Use global `absolute-file-name?'.

* module/ice-9/psyntax-pp.scm: Regenerate.
2013-02-19 15:00:11 +01:00
Andy Wingo
2aed2667fc Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/expand.c
	libguile/hashtab.c
	libguile/ports.c
	libguile/vectors.c
	libguile/weaks.c
	module/language/ecmascript/compile-tree-il.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/peval.test
2012-07-06 16:52:54 +02:00
Andy Wingo
5558cdaa30 add check for fchmod
* configure.ac: Add a check for fchmod.

* libguile/filesys.c (scm_chmod): Guard the fchmod case with
  HAVE_FCHMOD.
2012-07-06 11:01:51 +02:00
Andy Wingo
fc30e14ffe remove mkdir alias in filesys.c for mingw
* libguile/filesys.c (mkdir): Remove alias, as gnulib handles this for
  us.
2012-07-06 10:56:02 +02:00
Andy Wingo
74bbb99457 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	module/language/tree-il/analyze.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/cse.test
	test-suite/tests/peval.test
2012-05-21 19:20:27 +02:00
Ludovic Courtès
2ae7b7b6c3 Fix relative file name canonicalization with empty %LOAD-PATH entries.
* libguile/filesys.c (scm_i_relativize_path): Don't attempt to
  canonicalize when encountering an entry of IN_PATH that is the empty
  string.

* test-suite/tests/ports.test (with-load-path): New macro.
  ("%file-port-name-canonicalization"): New test prefix.
2012-05-15 19:05:37 +02:00
Andy Wingo
0858753e82 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/gc-malloc.c
	libguile/ports.c
2012-02-08 11:48:08 +01:00
Bake Timmons
b7e64f8b26 Improve the usage of variable names in C docstrings.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/generalized-arrays.c:
* libguile/hashtab.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/promises.c:
* libguile/simpos.c:
* libguile/socket.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Make the variable names in the C docstrings more
  consistent.  Replace a few instances of @var with @code when appropriate.
2012-02-02 12:22:10 +01:00
Andy Wingo
855db1905d Merge commit '9b0975f1dc'
Conflicts:
	libguile/foreign.c
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
2012-01-30 18:25:07 +01:00