(exception:string-contains-nul): New exception pattern.
[bpt/guile.git] / libguile / boolean.c
CommitLineData
2b829bbb 1/* Copyright (C) 1995, 1996, 2000, 2001, 2006 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
JB
19\f
20
a0599745 21#include "libguile/_scm.h"
20e6290e 22
a0599745
MD
23#include "libguile/validate.h"
24#include "libguile/boolean.h"
c96d76b8 25#include "libguile/lang.h"
1fe56d60
MV
26#include "libguile/tags.h"
27
0f2d19dd
JB
28\f
29
30
3b3b36dd 31SCM_DEFINE (scm_not, "not", 1, 0, 0,
da4a1dba 32 (SCM x),
cdbc7418 33 "Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}.")
1bbd0b84 34#define FUNC_NAME s_scm_not
0f2d19dd 35{
1fe56d60 36 return scm_from_bool (scm_is_false (x) || SCM_NILP (x));
0f2d19dd 37}
1bbd0b84 38#undef FUNC_NAME
0f2d19dd
JB
39
40
3b3b36dd 41SCM_DEFINE (scm_boolean_p, "boolean?", 1, 0, 0,
1bbd0b84 42 (SCM obj),
cdbc7418 43 "Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}.")
1bbd0b84 44#define FUNC_NAME s_scm_boolean_p
0f2d19dd 45{
1fe56d60 46 return scm_from_bool (scm_is_bool (obj) || SCM_NILP (obj));
0f2d19dd 47}
1bbd0b84 48#undef FUNC_NAME
0f2d19dd 49
3a684cc6
MV
50int
51scm_is_bool (SCM x)
52{
1fe56d60 53 return scm_is_eq (x, SCM_BOOL_F) || scm_is_eq (x, SCM_BOOL_T);
3a684cc6 54}
0f2d19dd 55
3a684cc6
MV
56int
57scm_to_bool (SCM x)
58{
59 if (scm_is_eq (x, SCM_BOOL_F))
60 return 0;
61 else if (scm_is_eq (x, SCM_BOOL_T))
62 return 1;
63 else
64 scm_wrong_type_arg (NULL, 0, x);
65}
1cc91f1b 66
0f2d19dd
JB
67void
68scm_init_boolean ()
0f2d19dd 69{
a0599745 70#include "libguile/boolean.x"
0f2d19dd
JB
71}
72
89e00824
ML
73
74/*
75 Local Variables:
76 c-file-style: "gnu"
77 End:
78*/