which included commits to RCS files with non-trunk default branches. git-svn-id: svn://svn.cc65.org/cc65/trunk@3 b7a2c559-68d2-44c3-8de9-860c34a00d81
64 lines
1017 B
C
64 lines
1017 B
C
/*
|
|
* util.c
|
|
*
|
|
* Ullrich von Bassewitz, 18.06.1998
|
|
*/
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
/* data */
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
/* code */
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
int IsBlank (char c)
|
|
/* Return true if c is a space, tab or newline */
|
|
{
|
|
return (c == ' ' || c == '\t' || c == '\n');
|
|
}
|
|
|
|
|
|
|
|
int IsQuoteChar (char c)
|
|
/* Return true if c is a single or double quote */
|
|
{
|
|
return (c == '"' || c == '\'');
|
|
}
|
|
|
|
|
|
|
|
int powerof2 (unsigned long val)
|
|
/* Return the exponent if val is a power of two. Return -1 if val is not a
|
|
* power of two.
|
|
*/
|
|
{
|
|
int i;
|
|
unsigned long mask;
|
|
mask = 0x0001;
|
|
|
|
for (i = 0; i < 32; ++i) {
|
|
if (val == mask) {
|
|
return i;
|
|
}
|
|
mask <<= 1;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
|
|
|