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
|
#if !defined(LIQUID_UTIL_H)
#define LIQUID_UTIL_H
inline static const char *read_while(const char *start, const char *end, int (func)(int))
{
while (start < end && func((unsigned char) *start)) start++;
return start;
}
inline static const char *read_while_reverse(const char *start, const char *end, int (func)(int))
{
end--;
while (start <= end && func((unsigned char) *end)) end--;
end++;
return end;
}
inline static int count_newlines(const char *start, const char *end)
{
int count = 0;
while (start < end) {
if (*start == '\n') count++;
start++;
}
return count;
}
inline static int is_non_newline_space(int c)
{
return rb_isspace(c) && c != '\n';
}
inline static int not_newline(int c)
{
return c != '\n';
}
inline static bool is_word_char(char c)
{
return ISALNUM(c) || c == '_';
}
#endif
|