ifchd-parse: Simplify leftover-buffer copying.
This commit is contained in:
parent
b8bffa16c5
commit
c8eb238f31
@ -208,9 +208,8 @@ int execute_buffer(const char newbuf[static 1])
|
|||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t init_siz = strlen(buf);
|
|
||||||
const char *p = buf;
|
const char *p = buf;
|
||||||
const char *pe = p + init_siz;
|
const char *pe = p + strlen(buf);
|
||||||
const char *arg_start = p;
|
const char *arg_start = p;
|
||||||
size_t arg_len = 0;
|
size_t arg_len = 0;
|
||||||
int cs = 0;
|
int cs = 0;
|
||||||
@ -218,11 +217,8 @@ int execute_buffer(const char newbuf[static 1])
|
|||||||
%% write init;
|
%% write init;
|
||||||
%% write exec;
|
%% write exec;
|
||||||
|
|
||||||
ptrdiff_t blt = pe - p;
|
if (p != pe) {
|
||||||
size_t bytes_left = blt >= 0 ? (size_t)blt : 0;
|
ssize_t ilen = snprintf(cl.ibuf, sizeof cl.ibuf, "%s", p);
|
||||||
if (bytes_left > 0) {
|
|
||||||
size_t taken = init_siz - bytes_left;
|
|
||||||
ssize_t ilen = snprintf(cl.ibuf, sizeof cl.ibuf, "%s", buf + taken);
|
|
||||||
if (ilen < 0) {
|
if (ilen < 0) {
|
||||||
log_line("%s: (%s) snprintf2 failed; your system is broken?",
|
log_line("%s: (%s) snprintf2 failed; your system is broken?",
|
||||||
client_config.interface, __func__);
|
client_config.interface, __func__);
|
||||||
|
Loading…
Reference in New Issue
Block a user