2019-12-03 19:16:05 +01:00
|
|
|
#include "misc.h"
|
|
|
|
|
|
|
|
|
|
#include <wctype.h>
|
|
|
|
|
|
|
|
|
|
bool
|
2020-10-09 19:44:23 +02:00
|
|
|
isword(wchar_t wc, bool spaces_only, const wchar_t *delimiters)
|
2019-12-03 19:16:05 +01:00
|
|
|
{
|
|
|
|
|
if (spaces_only)
|
|
|
|
|
return iswgraph(wc);
|
|
|
|
|
|
2020-10-09 19:44:23 +02:00
|
|
|
if (wcschr(delimiters, wc) != NULL)
|
2019-12-03 19:16:05 +01:00
|
|
|
return false;
|
2020-10-09 19:44:23 +02:00
|
|
|
|
|
|
|
|
return iswgraph(wc);
|
2019-12-03 19:16:05 +01:00
|
|
|
}
|
2022-01-15 14:56:13 +05:30
|
|
|
|
|
|
|
|
void
|
|
|
|
|
timespec_sub(const struct timespec *a, const struct timespec *b,
|
|
|
|
|
struct timespec *res)
|
|
|
|
|
{
|
|
|
|
|
res->tv_sec = a->tv_sec - b->tv_sec;
|
|
|
|
|
res->tv_nsec = a->tv_nsec - b->tv_nsec;
|
|
|
|
|
/* tv_nsec may be negative */
|
|
|
|
|
if (res->tv_nsec < 0) {
|
|
|
|
|
res->tv_sec--;
|
|
|
|
|
res->tv_nsec += 1000 * 1000 * 1000;
|
|
|
|
|
}
|
|
|
|
|
}
|