mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
* configure.in: add tests for figuring out whether buffered data
is available in a FILE structure, which is needed by char-ready. * acconfig.h: define FILE_CNT_FIELD, FILE_CNT_GPTR and FILE_CNT_READPTR. * simpos.c (scm_getenv): renamed from scm_sys_getenv. Throw exceptions using misc_error instead of syserror. It seems a bit odd to throw an exception if a string can't be found in the environment, but it's consistent with open-file, stat etc. (simpos.h): remove sys_ from getenv. * posix.c (scm_putenv): renamed from scm_sys_putenv. If an error occurs, throw an error instead of returning errno. Return value is now unspecified. (numerous in posix.c and posix.h): removed superfluous sys_ from names.
This commit is contained in:
parent
3afb28ce85
commit
f93ddd3985
9 changed files with 394 additions and 137 deletions
|
@ -79,19 +79,27 @@ scm_system(cmd)
|
|||
#endif
|
||||
|
||||
extern char *getenv();
|
||||
SCM_PROC (s_sys_getenv, "getenv", 1, 0, 0, scm_sys_getenv);
|
||||
SCM_PROC (s_getenv, "getenv", 1, 0, 0, scm_getenv);
|
||||
|
||||
SCM
|
||||
scm_sys_getenv(nam)
|
||||
scm_getenv(nam)
|
||||
SCM nam;
|
||||
{
|
||||
char *val;
|
||||
SCM_ASSERT(SCM_NIMP(nam) && SCM_ROSTRINGP(nam), nam, SCM_ARG1, s_sys_getenv);
|
||||
SCM_ASSERT(SCM_NIMP(nam) && SCM_ROSTRINGP(nam), nam, SCM_ARG1, s_getenv);
|
||||
if (SCM_ROSTRINGP (nam))
|
||||
nam = scm_makfromstr (SCM_ROCHARS (nam), SCM_ROLENGTH (nam), 0);
|
||||
val = getenv(SCM_CHARS(nam));
|
||||
if (!val)
|
||||
scm_syserror (s_sys_getenv);
|
||||
{
|
||||
/* This isn't a system error (errno won't be set), but is still
|
||||
treated as an exceptional condition, since getenv normally
|
||||
returns a string. Can easily do (false-if-exception (getenv ...))
|
||||
to catch the exception.
|
||||
*/
|
||||
scm_misc_error (s_getenv, "%S not found in environment",
|
||||
scm_listify (nam, SCM_UNDEFINED));
|
||||
}
|
||||
return scm_makfromstr(val, (scm_sizet)strlen(val), 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue