projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
scanner.l: modernize code a bit
[collectd.git]
/
src
/
liboconfig
/
scanner.l
diff --git
a/src/liboconfig/scanner.l
b/src/liboconfig/scanner.l
index
4858003
..
cfd9a5c
100644
(file)
--- a/
src/liboconfig/scanner.l
+++ b/
src/liboconfig/scanner.l
@@
-40,9
+40,9
@@
/* multiline string buffer */
/* multiline string buffer */
-static char *ml_buffer
= NULL
;
-static
int ml_pos = 0
;
-static
int ml_len = 0
;
+static char *ml_buffer;
+static
size_t ml_pos
;
+static
size_t ml_len
;
#define ml_free (ml_len - ml_pos)
#define ml_free (ml_len - ml_pos)
@@
-110,12
+110,12
@@
IPV6_ADDR ({IPV6_BASE})|(\[{IPV6_BASE}\](:{PORT})?)
{UNQUOTED_STRING} {yylval.string = yytext; return (UNQUOTED_STRING);}
\"{QUOTED_STRING}\\{EOL} {
{UNQUOTED_STRING} {yylval.string = yytext; return (UNQUOTED_STRING);}
\"{QUOTED_STRING}\\{EOL} {
-
in
t len = strlen (yytext);
+
size_
t len = strlen (yytext);
ml_pos = 0;
/* remove "\\<EOL>" */
ml_pos = 0;
/* remove "\\<EOL>" */
- if (
'\r' == yytext[len - 2]
)
+ if (
yytext[len - 2] == '\r'
)
len -= 3;
else
len -= 2;
len -= 3;
else
len -= 2;
@@
-126,10
+126,10
@@
IPV6_ADDR ({IPV6_BASE})|(\[{IPV6_BASE}\](:{PORT})?)
}
<ML>^{WHITE_SPACE}+ {/* remove leading white-space */}
<ML>{NON_WHITE_SPACE}{QUOTED_STRING}\\{EOL} {
}
<ML>^{WHITE_SPACE}+ {/* remove leading white-space */}
<ML>{NON_WHITE_SPACE}{QUOTED_STRING}\\{EOL} {
-
in
t len = strlen (yytext);
+
size_
t len = strlen (yytext);
/* remove "\\<EOL>" */
/* remove "\\<EOL>" */
- if (
'\r' == yytext[len - 2]
)
+ if (
yytext[len - 2] == '\r'
)
len -= 3;
else
len -= 2;
len -= 3;
else
len -= 2;
@@
-147,18
+147,17
@@
IPV6_ADDR ({IPV6_BASE})|(\[{IPV6_BASE}\](:{PORT})?)
%%
static void ml_append (char *string)
{
%%
static void ml_append (char *string)
{
- int len = strlen (string);
- int s;
+ size_t len = strlen (string);
if (ml_free <= len) {
ml_len += len - ml_free + 1;
ml_buffer = realloc (ml_buffer, ml_len);
if (ml_free <= len) {
ml_len += len - ml_free + 1;
ml_buffer = realloc (ml_buffer, ml_len);
- if (
NULL == ml_buffer
)
+ if (
ml_buffer == NULL
)
YY_FATAL_ERROR ("out of dynamic memory in ml_append");
}
YY_FATAL_ERROR ("out of dynamic memory in ml_append");
}
-
s = snprintf
(ml_buffer + ml_pos, ml_free, "%s", string);
- if (
(0 > s) || (ml_free <= s)
)
+
int s = snprintf
(ml_buffer + ml_pos, ml_free, "%s", string);
+ if (
s < 0 || (size_t)s >= ml_free
)
YY_FATAL_ERROR ("failed to write to multiline buffer");
ml_pos += s;
YY_FATAL_ERROR ("failed to write to multiline buffer");
ml_pos += s;