Skip to content

Commit 5ba4273

Browse files
committed
Fix internal types; use bool instead of int for flags/booleans.
1 parent ac69388 commit 5ba4273

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

XS.xs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
* CHARACTER CLASS METHODS
1515
* ****************************************************************************
1616
*/
17-
int charIsSpace(char ch) {
17+
bool charIsSpace(char ch) {
1818
if (ch == ' ') return 1;
1919
if (ch == '\t') return 1;
2020
return 0;
2121
}
22-
int charIsEndspace(char ch) {
22+
bool charIsEndspace(char ch) {
2323
if (ch == '\n') return 1;
2424
if (ch == '\r') return 1;
2525
if (ch == '\f') return 1;
2626
return 0;
2727
}
28-
int charIsWhitespace(char ch) {
28+
bool charIsWhitespace(char ch) {
2929
return charIsSpace(ch) || charIsEndspace(ch);
3030
}
31-
int charIsIdentifier(char ch) {
31+
bool charIsIdentifier(char ch) {
3232
if ((ch >= 'a') && (ch <= 'z')) return 1;
3333
if ((ch >= 'A') && (ch <= 'Z')) return 1;
3434
if ((ch >= '0') && (ch <= '9')) return 1;
@@ -38,7 +38,7 @@ int charIsIdentifier(char ch) {
3838
if (ch > 126) return 1;
3939
return 0;
4040
}
41-
int charIsInfix(char ch) {
41+
bool charIsInfix(char ch) {
4242
/* EOL characters before+after these characters can be removed */
4343
if (ch == ',') return 1;
4444
if (ch == ';') return 1;
@@ -54,15 +54,15 @@ int charIsInfix(char ch) {
5454
if (ch == '\n') return 1;
5555
return 0;
5656
}
57-
int charIsPrefix(char ch) {
57+
bool charIsPrefix(char ch) {
5858
/* EOL characters after these characters can be removed */
5959
if (ch == '{') return 1;
6060
if (ch == '(') return 1;
6161
if (ch == '[') return 1;
6262
if (ch == '!') return 1;
6363
return charIsInfix(ch);
6464
}
65-
int charIsPostfix(char ch) {
65+
bool charIsPostfix(char ch) {
6666
/* EOL characters before these characters can be removed */
6767
if (ch == '}') return 1;
6868
if (ch == ')') return 1;
@@ -124,12 +124,12 @@ typedef struct {
124124
*/
125125

126126
/* checks to see if the node is the given string, case INSENSITIVELY */
127-
int nodeEquals(Node* node, const char* string) {
127+
bool nodeEquals(Node* node, const char* string) {
128128
return (strcasecmp(node->contents, string) == 0);
129129
}
130130

131131
/* checks to see if the node contains the given string, case INSENSITIVELY */
132-
int nodeContains(Node* node, const char* string) {
132+
bool nodeContains(Node* node, const char* string) {
133133
const char* haystack = node->contents;
134134
size_t len = strlen(string);
135135
char ul_start[2] = { tolower(*string), toupper(*string) };
@@ -154,17 +154,18 @@ int nodeContains(Node* node, const char* string) {
154154
/* no match */
155155
return 0;
156156
}
157+
157158
/* checks to see if the node begins with the given string, case INSENSITIVELY
158159
*/
159-
int nodeBeginsWith(Node* node, const char* string) {
160+
bool nodeBeginsWith(Node* node, const char* string) {
160161
size_t len = strlen(string);
161162
if (len > node->length)
162163
return 0;
163164
return (strncasecmp(node->contents, string, len) == 0);
164165
}
165166

166167
/* checks to see if the node ends with the given string, case INSENSITIVELY */
167-
int nodeEndsWith(Node* node, const char* string) {
168+
bool nodeEndsWith(Node* node, const char* string) {
168169
size_t len = strlen(string);
169170
size_t off = node->length - len;
170171
if (len > node->length)
@@ -511,7 +512,7 @@ void JsCollapseNodes(Node* curr) {
511512
* of their placement in the JS document.
512513
*/
513514
if (!nodeIsIECONDITIONALBLOCKCOMMENT(curr)) {
514-
int convert_to_ws = 0;
515+
bool convert_to_ws = 0;
515516
/* find surrounding non-WS nodes */
516517
Node* nonws_prev = curr->prev;
517518
Node* nonws_next = curr->next;

0 commit comments

Comments
 (0)