add a_strcmp function
This commit is contained in:
parent
c80855836a
commit
1340d926ce
14
util.h
14
util.h
|
@ -27,6 +27,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
/** \brief replace \c NULL strings with emtpy strings */
|
||||||
|
#define NONULL(x) (x ? x : "")
|
||||||
|
|
||||||
#define ssizeof(foo) (ssize_t)sizeof(foo)
|
#define ssizeof(foo) (ssize_t)sizeof(foo)
|
||||||
#define countof(foo) (ssizeof(foo) / ssizeof(foo[0]))
|
#define countof(foo) (ssizeof(foo) / ssizeof(foo[0]))
|
||||||
|
|
||||||
|
@ -118,6 +121,17 @@ static inline char *a_strdup(const char *s)
|
||||||
return len ? p_dup(s, len + 1) : NULL;
|
return len ? p_dup(s, len + 1) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** \brief \c NULL resistant strcmp.
|
||||||
|
* \param[in] a the first string.
|
||||||
|
* \param[in] b the second string.
|
||||||
|
* \return <tt>strcmp(a, b)</tt>, and treats \c NULL strings like \c ""
|
||||||
|
* ones.
|
||||||
|
*/
|
||||||
|
static inline int a_strcmp(const char *a, const char *b)
|
||||||
|
{
|
||||||
|
return strcmp(NONULL(a), NONULL(b));
|
||||||
|
}
|
||||||
|
|
||||||
void die(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
void die(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
||||||
void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
void eprint(const char *, ...) __attribute__ ((noreturn)) __attribute__ ((format(printf, 1, 2)));
|
||||||
void uicb_spawn(Display *, DC *, awesome_config *, const char *);
|
void uicb_spawn(Display *, DC *, awesome_config *, const char *);
|
||||||
|
|
Loading…
Reference in New Issue