mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
internal: Introduce STRCASESKIP()
There is so far one case where STRCASEPREFIX(a, b) && a + strlen(b) combo is used (in virVMXConfigScanResultsCollector()), but there will be more. Do what we do usually: introduce a macro. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
af4b994bc4
commit
059e096435
@ -750,6 +750,15 @@ use one of the following semantically named macros
|
|||||||
* use: */
|
* use: */
|
||||||
STRSKIP(a, b)
|
STRSKIP(a, b)
|
||||||
|
|
||||||
|
- For skipping prefix case insensitively:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
/* Instead of:
|
||||||
|
* STRCASEPREFIX(a, b) ? a + strlen(b) : NULL
|
||||||
|
* use: */
|
||||||
|
STRCASESKIP(a, b)
|
||||||
|
|
||||||
- To avoid having to check if a or b are NULL:
|
- To avoid having to check if a or b are NULL:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
@ -87,6 +87,8 @@
|
|||||||
#define STRPREFIX(a, b) (strncmp(a, b, strlen(b)) == 0)
|
#define STRPREFIX(a, b) (strncmp(a, b, strlen(b)) == 0)
|
||||||
#define STRCASEPREFIX(a, b) (g_ascii_strncasecmp(a, b, strlen(b)) == 0)
|
#define STRCASEPREFIX(a, b) (g_ascii_strncasecmp(a, b, strlen(b)) == 0)
|
||||||
#define STRSKIP(a, b) (STRPREFIX(a, b) ? (a) + strlen(b) : NULL)
|
#define STRSKIP(a, b) (STRPREFIX(a, b) ? (a) + strlen(b) : NULL)
|
||||||
|
#define STRCASESKIP(a, b) (STRCASEPREFIX(a, b) ? (a) + strlen(b) : NULL)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* STRLIM
|
* STRLIM
|
||||||
* @str: pointer to a string (evaluated once)
|
* @str: pointer to a string (evaluated once)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user