]> git.sur5r.net Git - cc65/blob - src/cc65/util.c
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / src / cc65 / util.c
1 /*
2  * util.c
3  *
4  * Ullrich von Bassewitz, 18.06.1998
5  */
6
7
8
9 #include "util.h"
10
11
12
13 /*****************************************************************************/
14 /*                                   data                                    */
15 /*****************************************************************************/
16
17
18
19
20
21
22 /*****************************************************************************/
23 /*                                   code                                    */
24 /*****************************************************************************/
25
26
27
28 int IsBlank (char c)
29 /* Return true if c is a space, tab or newline */
30 {
31     return (c == ' ' || c == '\t' || c == '\n');
32 }
33
34
35
36 int IsQuoteChar (char c)
37 /* Return true if c is a single or double quote */
38 {
39     return (c == '"' || c == '\'');
40 }
41
42
43
44 int powerof2 (unsigned long val)
45 /* Return the exponent if val is a power of two. Return -1 if val is not a
46  * power of two.
47  */
48 {
49     int i;
50     unsigned long mask;
51     mask = 0x0001;
52
53     for (i = 0; i < 32; ++i) {
54         if (val == mask) {
55             return i;
56         }
57         mask <<= 1;
58     }
59     return -1;
60 }
61
62
63