mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
util: fix virSkipSpaces
Most clients of virSkipSpaces don't want to omit backslashes. Also, open-coding the list of spaces is not as nice as using c_isspace. * src/util/util.c (virSkipSpaces): Use c_isspace. (virSkipSpacesAndBackslash): New function. * src/util/util.h (virSkipSpacesAndBackslash): New prototype. * src/xen/xend_internal.c (sexpr_to_xend_topology): Update caller. * src/libvirt_private.syms (util.h): Export new function.
This commit is contained in:
parent
864e9457ca
commit
82162316b6
@ -1031,6 +1031,7 @@ virSetInherit;
|
|||||||
virSetNonBlock;
|
virSetNonBlock;
|
||||||
virSetUIDGID;
|
virSetUIDGID;
|
||||||
virSkipSpaces;
|
virSkipSpaces;
|
||||||
|
virSkipSpacesAndBackslash;
|
||||||
virStrToDouble;
|
virStrToDouble;
|
||||||
virStrToLong_i;
|
virStrToLong_i;
|
||||||
virStrToLong_l;
|
virStrToLong_l;
|
||||||
|
@ -1532,16 +1532,31 @@ virHexToBin(unsigned char c)
|
|||||||
* @str: pointer to the char pointer used
|
* @str: pointer to the char pointer used
|
||||||
*
|
*
|
||||||
* Skip potential blanks, this includes space tabs, line feed,
|
* Skip potential blanks, this includes space tabs, line feed,
|
||||||
* carriage returns and also '\\' which can be erronously emitted
|
* carriage returns.
|
||||||
* by xend
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
virSkipSpaces(const char **str)
|
virSkipSpaces(const char **str)
|
||||||
{
|
{
|
||||||
const char *cur = *str;
|
const char *cur = *str;
|
||||||
|
|
||||||
while ((*cur == ' ') || (*cur == '\t') || (*cur == '\n') ||
|
while (c_isspace(*cur))
|
||||||
(*cur == '\r') || (*cur == '\\'))
|
cur++;
|
||||||
|
*str = cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virSkipSpacesAndBackslash:
|
||||||
|
* @str: pointer to the char pointer used
|
||||||
|
*
|
||||||
|
* Like virSkipSpaces, but also skip backslashes erroneously emitted
|
||||||
|
* by xend
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
virSkipSpacesAndBackslash(const char **str)
|
||||||
|
{
|
||||||
|
const char *cur = *str;
|
||||||
|
|
||||||
|
while (c_isspace(*cur) || *cur == '\\')
|
||||||
cur++;
|
cur++;
|
||||||
*str = cur;
|
*str = cur;
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,7 @@ int virHexToBin(unsigned char c);
|
|||||||
int virMacAddrCompare (const char *mac1, const char *mac2);
|
int virMacAddrCompare (const char *mac1, const char *mac2);
|
||||||
|
|
||||||
void virSkipSpaces(const char **str);
|
void virSkipSpaces(const char **str);
|
||||||
|
void virSkipSpacesAndBackslash(const char **str);
|
||||||
int virParseNumber(const char **str);
|
int virParseNumber(const char **str);
|
||||||
int virParseVersionString(const char *str, unsigned long *version,
|
int virParseVersionString(const char *str, unsigned long *version,
|
||||||
bool allowMissing);
|
bool allowMissing);
|
||||||
|
@ -1199,11 +1199,11 @@ sexpr_to_xend_topology(const struct sexpr *root,
|
|||||||
cell = virParseNumber(&cur);
|
cell = virParseNumber(&cur);
|
||||||
if (cell < 0)
|
if (cell < 0)
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
virSkipSpaces(&cur);
|
virSkipSpacesAndBackslash(&cur);
|
||||||
if (*cur != ':')
|
if (*cur != ':')
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
cur++;
|
cur++;
|
||||||
virSkipSpaces(&cur);
|
virSkipSpacesAndBackslash(&cur);
|
||||||
if (STRPREFIX(cur, "no cpus")) {
|
if (STRPREFIX(cur, "no cpus")) {
|
||||||
nb_cpus = 0;
|
nb_cpus = 0;
|
||||||
for (cpu = 0; cpu < numCpus; cpu++)
|
for (cpu = 0; cpu < numCpus; cpu++)
|
||||||
|
Loading…
Reference in New Issue
Block a user