Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
44ce38dd
Commit
44ce38dd
authored
Feb 04, 2010
by
Niels Möller
Browse files
(config_tokenizer_eolp): New function.
Rev: src/tokenize_config.c:1.3 Rev: src/tokenize_config.h:1.3
parent
4af86c90
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/tokenize_config.c
View file @
44ce38dd
...
...
@@ -47,14 +47,10 @@ config_tokenizer_init(struct config_tokenizer *self,
self
->
lineno
=
1
;
}
enum
config_token_type
config_tokenizer_next
(
struct
config_tokenizer
*
self
)
{
static
const
char
char_class
[
0x100
]
=
{
/* HT, LF, VT, FF, CR */
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
4
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
/* SPACE */
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
...
...
@@ -66,8 +62,13 @@ config_tokenizer_next(struct config_tokenizer *self)
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
};
#define IS_SPACE(c) (char_class[c] & 1)
#define IS_SEPARATOR(c) (char_class[c] & 3)
#define IS_SPACE(c) (char_class[c] & 5)
#define IS_SPACE_NOT_LF(c) (char_class[c] & 1)
#define IS_SEPARATOR(c) (char_class[c] & 7)
enum
config_token_type
config_tokenizer_next
(
struct
config_tokenizer
*
self
)
{
for
(;;)
{
while
(
LEFT
&&
IS_SPACE
(
*
HERE
))
...
...
@@ -113,6 +114,30 @@ config_tokenizer_next(struct config_tokenizer *self)
}
}
/* Skips to end of line, and returns 1 if there's only space and
comments, otherwise zero.*/
int
config_tokenizer_eolp
(
struct
config_tokenizer
*
self
)
{
int
res
;
/* Skip space within the line. */
while
(
LEFT
&&
IS_SPACE_NOT_LF
(
*
HERE
))
ADVANCE
(
1
);
/* End of file counts as an end of line */
if
(
!
LEFT
)
return
1
;
res
=
(
*
HERE
==
'\n'
||
*
HERE
==
'#'
);
/* Skip rest of line */
while
(
LEFT
&&
*
HERE
!=
'\n'
)
ADVANCE
(
1
);
return
res
;
}
void
config_tokenizer_error
(
struct
config_tokenizer
*
self
,
const
char
*
msg
)
{
...
...
src/tokenize_config.h
View file @
44ce38dd
...
...
@@ -56,6 +56,9 @@ config_tokenizer_init(struct config_tokenizer *self,
enum
config_token_type
config_tokenizer_next
(
struct
config_tokenizer
*
self
);
int
config_tokenizer_eolp
(
struct
config_tokenizer
*
self
);
void
config_tokenizer_error
(
struct
config_tokenizer
*
self
,
const
char
*
msg
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment