-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbool.c
54 lines (51 loc) · 1.51 KB
/
bool.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* $Id: bool.c,v 1.6 2008/07/15 07:40:54 bnv Exp $
* $Log: bool.c,v $
* Revision 1.6 2008/07/15 07:40:54 bnv
* #include changed from <> to ""
*
* Revision 1.5 2008/07/14 13:08:16 bnv
* Initialize variable
*
* Revision 1.4 2002/06/11 12:37:15 bnv
* Added: CDECL
*
* Revision 1.3 2001/06/25 18:49:48 bnv
* Header changed to Id
*
* Revision 1.2 1999/11/26 09:52:45 bnv
* Changed: To make use of the LastScannedNumber
*
* Revision 1.1 1998/07/02 17:16:35 bnv
* Initial revision
*
*/
#include "lerror.h"
#include "lstring.h"
#include <cmssys.h>
/* ------------------- Lbool ------------------ */
int __CDECL
Lbool(const PLstr num) {
long i = 0;
Context *context = (Context *) CMSGetPG();
switch (LTYPE(*num)) {
case LSTRING_TY:
if (_Lisnum(num) == LSTRING_TY)
(context->lstring_Lerror)(ERR_UNLOGICAL_VALUE, 0);
i = (long) (context->lstring_lLastScannedNumber);
if ((double) i != (context->lstring_lLastScannedNumber))
(context->lstring_Lerror)(ERR_UNLOGICAL_VALUE, 0);
break;
case LREAL_TY:
i = (long) LREAL(*num);
if ((double) i != LREAL(*num))
(context->lstring_Lerror)(ERR_UNLOGICAL_VALUE, 0);
break;
case LINTEGER_TY:
i = LINT(*num);
break;
}
if (i == 0 || i == 1) return i;
(context->lstring_Lerror)(ERR_UNLOGICAL_VALUE, 0);
return -1; /* Never gets here but keep compiler happy :-) */
} /* Lbool */