diff options
author | Andy Wingo <wingo@pobox.com> | 2013-11-28 11:53:57 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-11-28 11:53:57 +0100 |
commit | 87fc4596e54d69559ce27868dd1a604ea322a6b1 (patch) | |
tree | 60b9f821b54c492ebd746ae5d99a6363f99c5e1e /libguile/simpos.c | |
parent | 35164d84e093ddf9e463fb72cc355c68a4ee92c9 (diff) |
Remove private-gc.h
* libguile/simpos.c (scm_getenv_int): Move here, from gc.c.
* libguile/private-gc.h: Remove, unused.
* libguile/simpos.h: Move scm_getenv_int declaration here.
* libguile/vm.c:
* libguile/gc.c: Adapt scm_getenv_int users.
* libguile/gc-malloc.c:
* libguile/load.c:
* libguile/script.c: Remove private-gc includes from non-users of
scm_getenv_int.
* libguile/Makefile.am: Adapt.
Diffstat (limited to 'libguile/simpos.c')
-rw-r--r-- | libguile/simpos.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libguile/simpos.c b/libguile/simpos.c index 8859d4f15..7865da647 100644 --- a/libguile/simpos.c +++ b/libguile/simpos.c @@ -1,5 +1,5 @@ /* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2003, 2004, 2009, - * 2010, 2012 Free Software Foundation, Inc. + * 2010, 2012, 2013 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -190,6 +190,21 @@ SCM_DEFINE (scm_getenv, "getenv", 1, 0, 0, } #undef FUNC_NAME +/* Get an integer from an environment variable. */ +int +scm_getenv_int (const char *var, int def) +{ + char *end = 0; + char *val = getenv (var); + long res = def; + if (!val) + return def; + res = strtol (val, &end, 10); + if (end == val) + return def; + return res; +} + /* simple exit, without unwinding the scheme stack or flushing ports. */ SCM_DEFINE (scm_primitive_exit, "primitive-exit", 0, 1, 0, (SCM status), |