mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
string-helpers.c: add str_starts_with()
This commit is contained in:
parent
5db953aa89
commit
2446c46069
5 changed files with 45 additions and 7 deletions
|
|
@ -1419,12 +1419,6 @@ handle_pipemenu_timeout(void *_ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
starts_with_less_than(const char *s)
|
||||
{
|
||||
return (s + strspn(s, " \t\r\n"))[0] == '<';
|
||||
}
|
||||
|
||||
static int
|
||||
handle_pipemenu_readable(int fd, uint32_t mask, void *_ctx)
|
||||
{
|
||||
|
|
@ -1468,7 +1462,7 @@ handle_pipemenu_readable(int fd, uint32_t mask, void *_ctx)
|
|||
}
|
||||
|
||||
/* Guard against badly formed data such as binary input */
|
||||
if (!starts_with_less_than(ctx->buf.data)) {
|
||||
if (!str_starts_with(ctx->buf.data, '<', " \t\r\n")) {
|
||||
wlr_log(WLR_ERROR, "expect xml data to start with '<'; abort pipemenu");
|
||||
goto clean_up;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue