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

211 commits

Author SHA1 Message Date
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
Mark H Weaver
c12da2be81 Fix search_path to fill stat_buf when given an absolute pathname
* libguile/load.c (search_path): When the provided 'filename' is an
  absolute pathname, perform a 'stat' on that pathname to fill the
  'stat_buf'.  Previously, 'stat_buf' was left uninitialized in this
  case, even though 'scm_primitive_load_path' assumes that 'stat_buf'
  will be filled.  Update the header comment to explicitly specify that
  'stat_buf' will be filled.  Also 'goto end' in a few failure cases
  instead of replicating its code.
2012-02-01 20:58:55 -05:00
Andy Wingo
91ee7515da Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/__scm.h
	libguile/array-map.c
	libguile/procprop.c
	libguile/tags.h
	module/ice-9/deprecated.scm
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
	test-suite/standalone/test-num2integral.c
	test-suite/tests/regexp.test
2012-01-10 00:41:42 +01:00
Andy Wingo
017eb4a6be primitive-load returns the value(s) of the last expression
* libguile/load.c (scm_primitive_load): Return the values yielded from
  evaluating the last expression in the file.

* test-suite/tests/load.test ("return value of `load'"): Add tests.
2012-01-09 16:15:00 +01:00
Andy Wingo
04ec290f8b Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/deprecation.c
	libguile/load.c
	libguile/print.c
2011-12-06 19:14:50 +01:00
Andy Wingo
2c27dd57c7 warnings written to warning port
* libguile/deprecation.c (scm_c_issue_deprecation_warning):
* libguile/load.c (auto_compile_catch_handler):
  (scm_sys_warn_auto_compilation_enabled, scm_primitive_load_path):
* module/ice-9/boot-9.scm (warn, %load-announce, duplicate-handlers)
  (load-in-vicinity):
* module/system/base/message.scm (warning): Write to the warning port.
  (*current-warning-port*): Alias the warning port.
2011-12-05 18:11:24 +01:00
Andy Wingo
b2208d2e98 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	configure.ac
	libguile/fluids.c
	libguile/gc.c
	libguile/gc.h
	libguile/objcodes.c
	libguile/procprop.c
	libguile/vm.c
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
2011-12-01 23:31:50 +01:00
Andy Wingo
c81c2ad3a5 use new scm_make_fluid_with_default
* libguile/load.c (scm_init_load):
* libguile/ports.c (scm_init_ports):
* libguile/read.c (scm_init_read): Use scm_make_fluid_with_default.
2011-11-23 12:54:09 +01:00
Andy Wingo
0607ebbfcf locking for putc, puts
* libguile/ports.c (scm_putc, scm_puts):
* libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into
  _unlocked and locked variants.  Change all callers to use the
  _unlocked versions.
2011-11-08 00:55:05 +01:00
Andy Wingo
25d50a051d most uses of scm_from_locale_symbol become scm_from_utf8_symbol
* libguile/array-handle.c:
* libguile/chars.c:
* libguile/expand.c:
* libguile/feature.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/instructions.c:
* libguile/load.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/options.c:
* libguile/print.c:
* libguile/smob.c:
* libguile/snarf.h: Change most uses of scm_from_locale_symbol to
  scm_from_utf8_symbol, as the symbols really are not locale-dependent.
2011-10-25 17:45:29 +02:00
Andy Wingo
21041372ed add SCM_{PACK,UNPACK}_POINTER
* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros.
  The old SCM2PTR and PTR2SCM were defined in such a way that
  round-tripping through a pointer could lose precision, even in the
  case in which you weren't interested in actually dereferencing the
  pointer, it was simply that you needed to plumb a SCM through APIs
  that take pointers.  These new macros are more like SCM_PACK and
  SCM_UNPACK, but for pointer types.  The bit representation of the
  pointer should be the same as the scm_t_bits representation.

* libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS
  pointers.  We are going to try tagging the SCM object itself in the
  future, and I don't think that keeping this support is worth its
  cost.  It probably doesn't work anyway.

* libguile/backtrace.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/gc.h:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/smob.c:
* libguile/strings.c:
* libguile/symbols.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Update many sites to use the new macros.
2011-10-24 18:54:04 +02:00
Andy Wingo
a6e1e05094 avoid duplicate stats when searching for files in a path
* libguile/load.c (search_path): Extract from scm_search_path, to
  give the caller the stat buffer of the found path.
  (scm_search_path, scm_sys_search_load_path): Adapt accordingly.
  (compiled_is_fresh): Take the stat buffers directly.
  (scm_primitive_load_path, scm_init_eval_in_scheme): Adapt to
  search_path / compiled_is_fresh changes to avoid duplicate states in
  search-path.
2011-08-03 12:43:29 +02:00
Andy Wingo
e4f6e855b6 fix unnecessary call to canonicalize_path in load-path fast case
* libguile/load.c (scm_primitive_load_path): Don't canonicalize the
  filename unless we need to look in the fallback path.  Fixes a stat
  explosion; see http://savannah.gnu.org/bugs/?33815.
2011-08-03 11:46:56 +02:00
Andy Wingo
9957641b60 add a site dir to %load-compiled-path
* libguile/Makefile.am (libpath.h): Define SCM_SITE_CCACHE_DIR.  Defined
  as site-ccache/ instead of site/ccache/ to indicate that we don't expect
  further subdirectories, and also to avoid confusion about whether
  extensions/ is a site-specific or not.

* libguile/load.c (scm_init_load_path): Add SCM_SITE_CCACHE_DIR to the
  default load-compiled path.
2011-07-21 10:36:13 +02:00
Andy Wingo
6934d9e75f fix generation of auto-compiled file names on mingw systems
* libguile/load.c (canonical_to_suffix, scm_primitive_load_path):
* module/ice-9/boot-9.scm (load-in-vicinity):
* module/system/base/compile.scm (compiled-file-name): If the canonical
  path of a file is a DOS-style path with a drive letter, turn it into a
  path suffix it by removing the colon and prefixing a "/".

Inspired by a patch from Jan Nieuwenhuizen.
2011-06-30 16:07:17 +02:00
Andy Wingo
dcada7d8e7 %load-hook not just for primitive-load
* libguile/load.c (scm_primitive_load_path):
* module/ice-9/boot-9.scm (load-in-vicinity): Call %load-hook as needed.
2011-06-30 12:56:12 +02:00
Andy Wingo
669ea4ebff better messages on failed autocompilation
* libguile/load.c (auto_compile_catch_handler):
* module/ice-9/boot-9.scm (load-in-vicinity): Nicer messages when
  autocompilation fails.
2011-06-17 18:08:06 +02:00
Jan Nieuwenhuizen
284019a2a5 mingw: use $APPDATA as a possible root for cachedir.
* libguile/load.c (scm_init_load_path) [MINGW32]: Fall back to using
$LOCALAPPDATA or $APPDATA if $XDG_CACHE_HOME and $HOME aren't set.
2011-06-17 00:01:39 +02:00
Andy Wingo
393baa8a44 scm_is_false instead of == SCM_BOOL_F; also is_null, is_true, etc
* libguile/deprecation.c (scm_issue_deprecation_warning)
* libguile/eval.c (CAPTURE_ENV):
* libguile/goops.c (make_dispatch_procedure, make_class_from_symbol):
  (create_smob_classes):
* libguile/guardians.c (finalize_guarded, scm_i_get_one_zombie):
* libguile/hashtab.c (scm_fixup_weak_alist, scm_internal_hash_fold):
* libguile/i18n.c (scm_nl_langinfo)
* libguile/load.c (scm_primitive_load)
* libguile/posix.c (scm_setrlimit)
* libguile/socket.c (scm_to_sockaddr):
* libguile/srcprop.c (scm_make_srcprops): Use scm_is_false / scm_is_true
  / scm_is_null instead of comparing against SCM_BOOL_F et al.
2011-05-13 15:28:41 +02:00
Andy Wingo
1e56cff233 add --fresh-auto-compile
* doc/ref/api-evaluation.texi (Compilation): Add discussion of
  --fresh-auto-compile.
* doc/ref/scheme-scripts.texi (Invoking Guile): Add --fresh-auto-compile
  option.

* NEWS: Add entry.

* libguile/load.c: Define %fresh-auto-compile.
  (scm_primitive_load_path): Use it here.
  (scm_init_load_should_auto_compile): Init from GUILE_AUTO_COMPILE env
  var, with a value of "fresh".

* module/ice-9/boot-9.scm (load-in-vicinity): Auto-compilation cache is
  stale if %fresh-auto-compile is true.

* module/ice-9/command-line.scm (compile-shell-switches): Parse out
  --fresh-auto-compile.
2011-04-15 11:27:27 +02:00
Andy Wingo
26ac1e3f42 add packager info to %build-info
* libguile/load.c (init_build_info): Add packager, packager-version, and
  packager-bug-reports to %build-info, if they are available.
2011-04-14 16:06:40 +02:00
Ludovic Courtès
5a79300f85 Add %auto-compilation-options', used by compile-file' when auto-compiling.
* module/ice-9/boot-9.scm (%auto-compilation-options): New variable.
  (load-in-vicinity): Honor it.

* libguile/load.c (kw_opts, sym_compile_file,
  sym_auto_compilation_options): New variables.
  (do_try_auto_compile): Honor %AUTO-COMPILATION-OPTIONS.

* module/system/repl/common.scm (repl-default-options): Have
  `compile-options' default to %AUTO-COMPILATION-OPTIONS.
2011-02-13 19:18:02 +01:00
Andy Wingo
eb7a16a9f8 primitive-load defaults to utf-8, not latin-1
* libguile/load.c (scm_primitive_load): Default to utf-8.
2011-02-13 18:19:00 +01:00
Andy Wingo
6f06e8d35f autocompile -> auto-compile
* NEWS:
* check-guile.in:
* doc/guile.1:
* doc/ref/scheme-scripts.texi:
* libguile/init.c:
* libguile/load.c:
* libguile/load.h:
* libguile/script.c:
* module/Makefile.am:
* module/ice-9/boot-9.scm:
* module/scripts/compile.scm:
* module/system/base/compile.scm:
* test-suite/Makefile.am:
* test-suite/tests/popen.test: Change "autocompile" to "auto-compile" or
  "auto_compile", as appropriate, in variable names, function names,
  command line arguments, and the documentation.
2011-02-13 15:06:11 +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
Ludovic Courtès
722a4fb99e Don't say "source file is newer" when either file is inaccessible.
* libguile/load.c (compiled_is_fresh): Don't emit "source file is newer"
  warning when either FULL_FILENAME or COMPILED_FILENAME could not be
  stat'd.  This is consistent with what load/compiled-file-name do.
2010-09-04 16:13:42 +02:00
Ludovic Courtès
abca59fea4 Compare source/compiled file timestamps with nano-second resolution.
* libguile/load.c (compiled_is_fresh): Rename `res' to
  `compiled_is_newer'.  Use `get_stat_mtime' to compare with nano-second
  resolution when available.

* module/ice-9/boot-9.scm (load)[fresh-compiled-file-name]: Likewise,
  using `stat:mtimensec'.
2010-09-04 16:07:58 +02:00
Andy Wingo
bc325e763f %site-dir is specific to the effective version
* libguile/load.h:
* libguile/load.c (scm_sys_global_site_dir): New API, is what %site-dir
  used to be.
  (scm_sys_site_dir): Changed to be a version-specific dir.
  (scm_init_load_path): Search the version-specific sitedir before the
  global one.

* libguile/Makefile.am (libpath.h): Update SCM_SITE_DIR and
  SCM_GLOBAL_SITE_DIR, as appropriate.
2010-08-06 13:15:29 +02:00
Ludovic Courtès
fefd60ba4b Check for go/scm mtime ordering rather than equality.
* am/guilec (install-data-hook): Remove.
  (guile_install_go_files): New variable.
  ($(guile_install_go_files)): New dependency.

* libguile/load.c (compiled_is_fresh): Check for ordering of STAT_SOURCE
  and STAT_COMPILED, not equality.

* module/ice-9/boot-9.scm (load): Ditto.

* module/system/base/compile.scm (call-with-output-file/atomic): Don't
  set the timestamp of TEMPLATE.
2010-07-26 19:38:52 +02:00
Ludovic Courtès
eba5ea7a4f Canonicalize source file names in `primitive-load-path' (fix bug #30170).
* libguile/load.c (scm_primitive_load_path): Canonicalize
  FULL_FILENAME.  Fixes bug #30170 ("Auto-compilation erroneously
  recompiles dependencies").
2010-06-20 16:57:06 +02:00
Andy Wingo
cd038da546 remove libguile/lang.h, deprecate %nil (in favor of #nil)
* libguile/Makefile.am:
* libguile/init.c:
* libguile/lang.c:
* libguile/lang.h: Remove lang.c and lang.h.

* libguile/pairs.h (SCM_NIL_P, SCM_NULL_OR_NIL_P): Moved here.

* module/ice-9/deprecated.scm (%nil): %nil definition moved here.

* libguile/alist.c:
* libguile/async.c:
* libguile/backtrace.c:
* libguile/boolean.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/list.c:
* libguile/load.c:
* libguile/options.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/promises.c:
* libguile/sort.c:
* libguile/throw.c:
* libguile/trees.c:
* libguile/vectors.c:
* libguile/vm.c:
* libguile/weaks.c:
* srfi/srfi-1.c: <libguile/lang.h> references removed.
2010-04-09 14:26:31 +02:00
Andy Wingo
6128f34c4b correctly handle --no-autocompile (fixed broken previous patch)
* libguile/load.c (scm_init_load): Initialize %load-should-autocompile
  to false.

* libguile/init.c (scm_i_init_guile):
* libguile/load.h:
* libguile/load.c (scm_init_load_should_autocompile): At the end of
  init, check GUILE_AUTO_COMPILE.

* libguile/script.c (scm_compile_shell_switches): Instead of making
  --autocompile / --no-autocompile render into the s-expression, just
  handle them immediately, so that --no-autocompile takes effect for the
  expander.
2010-03-30 10:53:05 +02:00
Andy Wingo
655aadf4b0 going through scm_shell not necessary to get autocompilation
* libguile/load.c (scm_init_load): Initialize %load-should-autocompile
  from the environment variable here, so that apps that don't go through
  scm_shell get autocompilation.

* libguile/script.c (scm_compile_shell_switches): Explicitly enable or
  disable autocompilation here, if told to do so.
2010-03-30 10:28:51 +02:00
Andy Wingo
a6029b97ea properly integrate vm bootstrapping into init.c
* libguile/Makefile.am (modinclude_HEADERS):
* libguile/vm-bootstrap.h: Remove vm-bootstrap.h.

* libguile/frames.c: No more vm-bootstrap.h.

* libguile/instructions.c (scm_init_instructions):
* libguile/objcodes.c (scm_init_objcodes):
* libguile/programs.c (scm_init_programs): No need to call
  scm_bootstrap_vm, init.c does that for us.

* libguile/vm.c (scm_bootstrap_vm): No need call e.g.
  scm_bootstrap_frames, init.c does that. Remove a twice-calling guard,
  should be unnecessary. Don't define the load-compiled subr here.

* libguile/load.c (scm_init_load): Define the load-compiled subr here.

* libguile/vm.h: Declare scm_bootstrap_vm here.

* libguile/init.c (scm_i_init_guile): Properly integrate VM
  bootstrapping into this file.
2010-01-07 23:42:41 +01:00
Ludovic Courtès
e29dcaf3b7 Fix 1.8-compatibility of `scm_search_path ()'.
* libguile/load.c (scm_search_path): Handle the 1.8-compatibility case
  where REST is `SCM_UNDEFINED'.  Reported by Dale P. Smith.
2010-01-07 11:10:36 +01:00
Andy Wingo
3c98a49cbd in the load path, look in library-dir before site-dir
* libguile/load.c (scm_init_load_path): Search first in Guile's
  version-specific path (the library path), *then* in the site dir. This
  should allow us to import some of Guile-lib's modules into Guile,
  perhaps customizing them with Guile-version-specific foo, without
  accidentally falling back to system-installed guile-lib in the
  sitedir. Also should reduce the number of stats by half, in the common
  case.
2009-12-20 15:34:19 +01:00
Andy Wingo
ed1bf2c85c if we have no eval.go, load no .go
* libguile/load.c (scm_init_eval_in_scheme): If we have no eval.go, null
  out the load-compiled path so that we load no compiled code. Prevents
  partially compiled Guile from turning tail-calls into stack-munching
  calls.
2009-12-10 20:26:13 +01:00
Andy Wingo
f39448c5a3 remove a bunch of needless scm_permanent_object calls
* libguile/array-handle.c:
* libguile/bytevectors.c:
* libguile/deprecated.c:
* libguile/eval.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/gc.c:
* libguile/gdbint.c:
* libguile/goops.c:
* libguile/instructions.c:
* libguile/load.c:
* libguile/modules.c:
* libguile/numbers.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/scmsigs.c:
* libguile/srcprop.c:
* libguile/srfi-4.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/vm.c: Remove calls to scm_permanent_object, as they are no
  longer needed with the BDW GC.
2009-12-05 11:32:50 +01:00
Andy Wingo
5f1611640a really boot primitive-eval from scheme.
* libguile/eval.c (scm_primitive_eval, scm_c_primitive_eval):
  (scm_init_eval): Rework so that scm_primitive_eval always calls out to
  the primitive-eval variable. The previous definition is the default
  value, which is probably overridden by scm_init_eval_in_scheme.

* libguile/init.c (scm_i_init_guile): Move ports and load-path up, so we
  can debug when initing eval. Call scm_init_eval_in_scheme. Awesome.

* libguile/load.h:
* libguile/load.c (scm_init_eval_in_scheme): New procedure, loads up
  ice-9/eval.scm to replace the primitive-eval definition, if everything
  is there and up-to-date.

* libguile/modules.c (scm_module_transformer): Export to Scheme, so it's
  there for eval.go.

* module/ice-9/boot-9.scm: No need to define module-transformer.

* module/ice-9/eval.scm (capture-env): Only reference the-root-module if
  modules are booted.
  (primitive-eval): Inline a definition for identity. Throw a more
  standard error for "wrong number of arguments".

* module/ice-9/psyntax.scm (chi-install-global): The macro binding for a
  syncase macro is now a pair: the transformer, and the module that was
  current when the transformer was installed. The latter is used for
  hygiene purposes, replacing the use of procedure-module, which didn't
  work with the interpreter's shared-code closures.
  (chi-macro): Adapt for the binding being a pair, and get the hygiene
  from the cdr.
  (eval-local-transformer): Adapt to new form of macro bindings.

* module/ice-9/psyntax-pp.scm: Regenerated.

* .gitignore: Ignore eval.go.stamp.

* module/Makefile.am: Reorder for fastest serial compilation, now that
  there are no ordering constraints. I did a number of experiments here
  and this seems to be the best; but the bulk of the time is compiling
  psyntax-pp.scm with eval.scm. Not so great.

* libguile/vm-engine.c (vm-engine): Throw a more standard error for
  "wrong type to apply".

* test-suite/tests/gc.test ("gc"): Remove a hack that shouldn't affect
  the new evaluator, and throw in another (gc) for good measure.

* test-suite/tests/goops.test ("defining classes"):
* test-suite/tests/hooks.test (proc1): We can't currently check what the
  arity is of a closure made by eval.scm -- or more accurately all
  closures have 0 required args and no rest args. So punt for now.

* test-suite/tests/syntax.test ("letrec"): The scheme evaluator can't
  check that a variable is unbound, currently; perhaps the full "fixing
  letrec" expansion could fix this. But barring that, punt.
2009-12-03 00:00:38 +01:00
Ludovic Courtès
f8a1c9a859 Have `scm_scan_for_encoding ()' use GC-managed memory.
* libguile/read.c (scm_scan_for_encoding): Rename to ...
  (scm_i_scan_for_encoding): ... this; update callers.  Use
  `scm_gc_strndup ()' instead of `scm_malloc ()'.

* libguile/read.h: Update accordingly.

* libguile/load.c (scm_primitive_load): Don't call free(3) on the value
  returned by `scm_i_scan_for_encoding ()'.
2009-11-14 16:59:25 +01:00
Ludovic Courtès
88cbb42189 Restore signature of `scm_search_path ()' as found in 1.8.
The incompatibly was introduced by
22f4ee4882 ("make primitive-load-path load
compiled files if available").

* doc/ref/api-options.texi (Build Config): Update `search-path'
  documentation.

* libguile/load.c (scm_search_path): Change C prototype to expect only 3
  arguments.  Parse the rest argument accordingly.  Update callers.

* libguile/load.h (scm_search_path): Update accordingly.
2009-11-01 23:29:36 +01:00
Ludovic Courtès
31ab99de56 Restore signature of `scm_primitive_load_path ()' as found in 1.8.
The incompatibility was introduced by
0fb81f95b0 ("add exception_on_error
optional arg to primitive-load-path").

* libguile/load.c (scm_primitive_load_path): Change to take 1 rest
  argument.  Interpret the argument as either a file name (C-level
  backward compatibility with 1.8) or an actual argument list.
  (scm_c_primitive_load_path): Update caller.

* libguile/load.h (scm_primitive_load_path): Update accordingly.

* doc/ref/api-evaluation.texi (Loading): Update documentation of
  `primitive-load-path' and `scm_primitive_load_path ()'.
2009-10-15 01:05:32 +02:00
Ludovic Courtès
87c595c757 Compile in a fresh module by default.
* module/system/base/compile.scm (make-compilation-module,
  language-default-environment): New procedures.
  (read-and-compile, compile): Have ENV default to
  `(language-default-environment from)'.
  (compile-and-load): Compile in `(current-module)'.

* module/system/repl/common.scm (repl-compile): Explicitly compile in
  the current module so that macro definitions are visible.

* libguile/load.c (kw_env): New variable.
  (do_try_autocompile): Call `compile-file' with `#:env (current-module)'.

* test-suite/tests/compiler.test ("psyntax")["compile uses a fresh module by
  default", "compile-time definitions are isolated"]: New tests.
  ["compile in current module"]: Specify `#:env (current-module)'.
  ["redefinition"]: Adjust.

* test-suite/tests/bytevectors.test (c&e): Explicitly compile in the
  current module so that its imports are visible.
2009-09-20 21:54:41 +02:00
Ludovic Courtès
d7a2207326 Add the `%host-type' global variable.
* configure.ac: Define `HOST_TYPE'.

* libguile/load.c (sys_host_type): New variable.

* doc/ref/api-options.texi (Build Config): Document `%host-type'.
2009-09-18 11:40:03 +02:00
Ludovic Courtès
6dc797eee9 Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/gc_os_dep.c
2009-09-09 22:39:49 +02:00
Ludovic Courtès
7af531508c Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/Makefile.am
	libguile/bytevectors.c
	libguile/gc-card.c
	libguile/gc-mark.c
	libguile/programs.c
	libguile/srcprop.c
	libguile/srfi-14.c
	libguile/symbols.c
	libguile/threads.c
	libguile/unif.c
	libguile/vm.c
2009-08-28 19:16:46 +02:00
Andy Wingo
5950cc3fcc fix case in which compiled path had stale .go, but fallback had fresh .go
* libguile/load.c (scm_primitive_load_path): If the compiled path was
  out of date, but the fallback path was current, we correctly detected
  that case, but loaded the wrong file. So here fix the typo.
2009-08-28 17:13:09 +02:00
Ludovic Courtès
1505848425 Add missing `FUNC_NAME' definition.
* libguile/load.c (scm_sys_warn_autocompilation_enabled): Define
  `FUNC_NAME'.
2009-08-28 01:16:49 +02:00
Michael Gran
889975e51a Add full Unicode capability to ports and the default reader
Ports are given two additional properties: a character encoding and
a conversion failure strategy.  These properties have getters and setters.
The new properties are used to convert any locale text to/from the
internal representation of strings.

If unspecified, ports use a default value. The default value of these
properties is held in a fluid.  The default character encoding can be
modified by calling setlocale.

ISO-8859-1 is treated specially.  Since it is a native encoding of
strings, it can be processed more quickly.  Source code is assumed to be
ISO-8859-1 unless otherwise specified.  The encoding of a source code
file can be given as 'coding: XXXXX' in a magic comment at the top of a
file.

The C functions that deal with encoding often use a null pointer
as shorthand for the native Latin-1 encoding, for efficiency's sake.

* test-suite/tests/encoding-iso88591.test: new tests
* test-suite/tests/encoding-iso88597.test: new tests
* test-suite/tests/encoding-utf8.test: new tests
* test-suite/tests/encoding-escapes.test: new tests
* test-suite/tests/numbers.test: declare 'binary' encoding
* test-suite/tests/ports.test: declare 'binary' encoding
* test-suite/tests/r6rs-ports.test: declare 'binary' encoding

* module/system/base/compile.scm (compile-file): use source-code
  file's self-declared encoding when compiling files

* libguile/strports.c: store string ports in locale encoding
  (scm_strport_to_locale_u8vector, scm_call_with_output_locale_u8vector)
  (scm_open_input_locale_u8vector, scm_get_output_locale_u8vector):
  new functions

* libguile/strings.h: new declaration for scm_i_string_contains_char

* libguile/strings.c (scm_i_string_contains_char): new function
  (scm_from_stringn, scm_to_stringn):  use NULL for Latin-1
  (scm_from_locale_stringn, scm_to_locale_stringn): respect character
  encoding of input and output ports

* libguile/read.h: declaration for scm_scan_for_encoding

* libguile/read.c:
  (read_token): now takes scheme string instead of C string/length
  (read_complete_token): new function
  (scm_read_sexp, scm_read_number, scm_read_mixed_case_symbol)
  (scm_read_number_and_radix, scm_read_quote, scm_read_semicolon_comment)
  (scm_read_srfi4_vector, scm_read_bytevector, scm_read_guile_bit_vector)
  (scm_read_scsh_block_comment, scm_read_commented_expression)
  (scm_read_extended_symbol, scm_read_sharp_extension, scm_read_shart)
  (scm_read_expression): use scm_t_wchar for char type, use read_complete_token
  (scm_scan_for_encoding): new function to find a file's character encoding
  (scm_file_encoding): new function to find a port's character encoding

* libguile/rdelim.c: don't unpack strings

* libguile/print.h: declaration for modified function
  scm_i_charprint

* libguile/print.c: use locale when printing characters and
  strings
  (scm_i_charprint): input parameter is now scm_t_wchar
  (scm_simple_format): don't unpack strings

* libguile/posix.h: new declaration for scm_setbinary.

* libguile/posix.c (scm_setlocale): set default and stdio port
  encodings based on the locale's character encoding
  (scm_setbinary): new function

* libguile/ports.h (scm_t_port): add encoding and failed
  conversion handler to port type.  Declarations for new or modified
  functions scm_getc, scm_unget_byte, scm_ungetc,
  scm_i_get_port_encoding, scm_i_set_port_encoding_x,
  scm_port_encoding, scm_set_port_encoding_x,
  scm_i_get_conversion_strategy, scm_i_set_conversion_strategy_x,
  scm_port_conversion_strategy, scm_set_port_conversion_strategy_x.

* libguile/ports.c: assign the current ports to zero on startup so
  we can see if they've been set.
  (scm_current_input_port, scm_current_output_port,
  scm_current_error_port): return #f if the port is not yet
  initialized
  (scm_new_port_table_entry): set up a new port's encoding and
  illegal sequence handler based on the thread's current defaults
  (scm_i_remove_port): free port encoding name when port is removed
  (scm_i_mode_bits_n): now takes a scheme string instead of a c
  string and length.  All callers changed.
  (SCM_MBCHAR_BUF_SIZE): new const
  (scm_getc): new function, since the scm_getc in inline.h is now
  scm_get_byte_or_eof.  This pulls one codepoint from a port.
  (scm_lfwrite_substr, scm_lfwrite_str): now uses port's encoding
  (scm_unget_byte): new function, incorportaing the low-level functionality
  of scm_ungetc
  (scm_ungetc): uses scm_unget_byte

* libguile/numbers.h (scm_t_wchar): compilation order problem with
  scm_t_wchar being use in functions in multiple headers.  Forward
  declare scm_t_wchar.

* libguile/load.c (scm_primitive_load): scan for file encoding at
  top of file and use it to set the load port's encoding

* libguile/inline.h (scm_get_byte_or_eof): new function
  incorporating most of the functionality of scm_getc.

* libguile/fports.c (fport_fill_input): now returns scm_t_wchar

* libguile/chars.h (scm_t_wchar): avoid compilation order problem
  with declaration of scm_t_wchar
2009-08-25 07:54:37 -07:00
Andy Wingo
48a0fe4d6b autocompiled files before installation go to a cache dir in the builddir
* libguile/load.c (scm_init_load_path): Append a slash after
  XDG_CACHE_HOME.

* meta/gdb-uninstalled-guile.in:
* meta/guile.in (XDG_CACHE_HOME): Export this var so we write to a cache
  within the build directory. Probably we should have a GUILE_CACHE_DIR
  to be more specific, though.

* Makefile.am (clean-local): Clear the cache when making clean.
2009-08-20 18:52:38 +02:00