forked from Dniel97/segatools
util/str.c: Add string equality wrappers
This commit is contained in:
parent
9e3c70ad6b
commit
a96e625a36
@ -25,5 +25,7 @@ util_lib = static_library(
|
||||
'setupapi.h',
|
||||
'spike.c',
|
||||
'spike.h',
|
||||
'str.c',
|
||||
'str.h',
|
||||
],
|
||||
)
|
||||
|
11
util/str.c
Normal file
11
util/str.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "util/str.h"
|
||||
|
||||
extern inline bool str_eq(const char *lhs, const char *rhs);
|
||||
extern inline bool str_ieq(const char *lhs, const char *rhs);
|
||||
extern inline bool wstr_eq(const wchar_t *lhs, const wchar_t *rhs);
|
||||
extern inline bool wstr_ieq(const wchar_t *lhs, const wchar_t *rhs);
|
41
util/str.h
Normal file
41
util/str.h
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
inline bool str_eq(const char *lhs, const char *rhs)
|
||||
{
|
||||
if (lhs == NULL || rhs == NULL) {
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
return strcmp(lhs, rhs) == 0;
|
||||
}
|
||||
|
||||
inline bool str_ieq(const char *lhs, const char *rhs)
|
||||
{
|
||||
if (lhs == NULL || rhs == NULL) {
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
return _stricmp(lhs, rhs) == 0;
|
||||
}
|
||||
|
||||
inline bool wstr_eq(const wchar_t *lhs, const wchar_t *rhs)
|
||||
{
|
||||
if (lhs == NULL || rhs == NULL) {
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
return wcscmp(lhs, rhs) == 0;
|
||||
}
|
||||
|
||||
inline bool wstr_ieq(const wchar_t *lhs, const wchar_t *rhs)
|
||||
{
|
||||
if (lhs == NULL || rhs == NULL) {
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
return _wcsicmp(lhs, rhs) == 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user