/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_STRING_HELPERS_H
#define LABWC_STRING_HELPERS_H
+#include <stdbool.h>
+
+/**
+ * string_null_or_empty() - Check if string is NULL or empty
+ * @s: string to check
+ */
+bool string_null_or_empty(const char *s);
/**
* trim_last_field() - Trim last field of string splitting on provided delim
#include "buffer.h"
#include "button/button-png.h"
#include "button/common.h"
+#include "common/string-helpers.h"
#include "labwc.h"
/*
wlr_buffer_drop(&(*buffer)->base);
*buffer = NULL;
}
- if (!button_name || !*button_name) {
+ if (string_null_or_empty(button_name)) {
return;
}
#include "buffer.h"
#include "button/button-svg.h"
#include "button/common.h"
+#include "common/string-helpers.h"
#include "labwc.h"
void
wlr_buffer_drop(&(*buffer)->base);
*buffer = NULL;
}
- if (!button_name || !*button_name) {
+ if (string_null_or_empty(button_name)) {
return;
}
#include "button/common.h"
#include "common/grab-file.h"
#include "common/mem.h"
+#include "common/string-helpers.h"
#include "buffer.h"
enum token_type {
wlr_buffer_drop(&(*buffer)->base);
*buffer = NULL;
}
- if (!button_name || !*button_name) {
+ if (string_null_or_empty(button_name)) {
return;
}
color = argb32(rgba);
#include <wlr/util/log.h>
#include "common/font.h"
#include "common/graphic-helpers.h"
+#include "common/string-helpers.h"
#include "labwc.h"
#include "buffer.h"
max_width = 2;
}
- if (!text || !*text) {
+ if (string_null_or_empty(text)) {
return;
}
#include "common/mem.h"
#include "common/string-helpers.h"
+bool
+string_null_or_empty(const char *s)
+{
+ return !s || !*s;
+}
+
void
trim_last_field(char *buf, char delim)
{
#include "common/mem.h"
#include "common/list.h"
+#include "common/string-helpers.h"
#include "config/libinput.h"
#include "config/rcxml.h"
enum lab_libinput_device_type
get_device_type(const char *s)
{
- if (!s || !*s) {
+ if (string_null_or_empty(s)) {
return LAB_LIBINPUT_DEVICE_NONE;
}
if (!strcasecmp(s, "default")) {
#include "config/session.h"
#include "labwc.h"
-static bool
-string_empty(const char *s)
-{
- return !s || !*s;
-}
-
static void
process_line(char *line)
{
- if (string_empty(line) || line[0] == '#') {
+ if (string_null_or_empty(line) || line[0] == '#') {
return;
}
char *key = NULL;
buf_add(&value, string_strip(++p));
buf_expand_shell_variables(&value);
buf_expand_tilde(&value);
- if (string_empty(key) || !value.len) {
+ if (string_null_or_empty(key) || !value.len) {
goto error;
}
setenv(key, value.buf, 1);
#include "common/mem.h"
#include "common/scaled_font_buffer.h"
#include "common/scene-helpers.h"
+#include "common/string-helpers.h"
#include "labwc.h"
#include "node.h"
#include "ssd-internal.h"
struct view *view = ssd->view;
char *title = (char *)view_get_string_prop(view, "title");
- if (!title || !*title) {
+ if (string_null_or_empty(title)) {
return;
}