Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.
[bpt/guile.git] / libguile / boolean.c
CommitLineData
dbb605f5 1/* Copyright (C) 1995, 1996, 2000, 2001, 2006, 2008 Free Software Foundation, Inc.
0f2d19dd 2 *
73be1d9e
MV
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
0f2d19dd 7 *
73be1d9e
MV
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
0f2d19dd 12 *
73be1d9e
MV
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
92205699 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
73be1d9e 16 */
1bbd0b84 17
1bbd0b84 18
0f2d19dd 19\f
dbb605f5
LC
20#ifdef HAVE_CONFIG_H
21# include <config.h>
22#endif
0f2d19dd 23
a0599745 24#include "libguile/_scm.h"
20e6290e 25
a0599745
MD
26#include "libguile/validate.h"
27#include "libguile/boolean.h"
c96d76b8 28#include "libguile/lang.h"
1fe56d60
MV
29#include "libguile/tags.h"
30
0f2d19dd
JB
31\f
32
33
3b3b36dd 34SCM_DEFINE (scm_not, "not", 1, 0, 0,
da4a1dba 35 (SCM x),
cdbc7418 36 "Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}.")
1bbd0b84 37#define FUNC_NAME s_scm_not
0f2d19dd 38{
1fe56d60 39 return scm_from_bool (scm_is_false (x) || SCM_NILP (x));
0f2d19dd 40}
1bbd0b84 41#undef FUNC_NAME
0f2d19dd
JB
42
43
3b3b36dd 44SCM_DEFINE (scm_boolean_p, "boolean?", 1, 0, 0,
1bbd0b84 45 (SCM obj),
cdbc7418 46 "Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}.")
1bbd0b84 47#define FUNC_NAME s_scm_boolean_p
0f2d19dd 48{
1fe56d60 49 return scm_from_bool (scm_is_bool (obj) || SCM_NILP (obj));
0f2d19dd 50}
1bbd0b84 51#undef FUNC_NAME
0f2d19dd 52
3a684cc6
MV
53int
54scm_is_bool (SCM x)
55{
1fe56d60 56 return scm_is_eq (x, SCM_BOOL_F) || scm_is_eq (x, SCM_BOOL_T);
3a684cc6 57}
0f2d19dd 58
3a684cc6
MV
59int
60scm_to_bool (SCM x)
61{
62 if (scm_is_eq (x, SCM_BOOL_F))
63 return 0;
64 else if (scm_is_eq (x, SCM_BOOL_T))
65 return 1;
66 else
67 scm_wrong_type_arg (NULL, 0, x);
68}
1cc91f1b 69
0f2d19dd
JB
70void
71scm_init_boolean ()
0f2d19dd 72{
a0599745 73#include "libguile/boolean.x"
0f2d19dd
JB
74}
75
89e00824
ML
76
77/*
78 Local Variables:
79 c-file-style: "gnu"
80 End:
81*/