mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
rc.xml: split out rstrip() to string-helpers.c
This commit is contained in:
parent
bc04f50d14
commit
a97428020e
3 changed files with 21 additions and 13 deletions
|
|
@ -8,4 +8,11 @@
|
||||||
*/
|
*/
|
||||||
char *string_strip(char *s);
|
char *string_strip(char *s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* string_truncate_at_pattern - remove pattern and everything after it
|
||||||
|
* @buf: pointer to buffer
|
||||||
|
* @pattern: string to remove
|
||||||
|
*/
|
||||||
|
void string_truncate_at_pattern(char *buf, const char *pattern);
|
||||||
|
|
||||||
#endif /* __LABWC_STRING_HELPERS_H */
|
#endif /* __LABWC_STRING_HELPERS_H */
|
||||||
|
|
|
||||||
|
|
@ -25,3 +25,13 @@ string_strip(char *s)
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
string_truncate_at_pattern(char *buf, const char *pattern)
|
||||||
|
{
|
||||||
|
char *p = strstr(buf, pattern);
|
||||||
|
if (!p) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "common/dir.h"
|
#include "common/dir.h"
|
||||||
#include "common/font.h"
|
#include "common/font.h"
|
||||||
#include "common/log.h"
|
#include "common/log.h"
|
||||||
|
#include "common/string-helpers.h"
|
||||||
#include "config/keybind.h"
|
#include "config/keybind.h"
|
||||||
#include "config/rcxml.h"
|
#include "config/rcxml.h"
|
||||||
|
|
||||||
|
|
@ -30,23 +31,13 @@ enum font_place {
|
||||||
/* TODO: Add all places based on Openbox's rc.xml */
|
/* TODO: Add all places based on Openbox's rc.xml */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
|
||||||
rstrip(char *buf, const char *pattern)
|
|
||||||
{
|
|
||||||
char *p = strstr(buf, pattern);
|
|
||||||
if (!p) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fill_keybind(char *nodename, char *content)
|
fill_keybind(char *nodename, char *content)
|
||||||
{
|
{
|
||||||
if (!content) {
|
if (!content) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rstrip(nodename, ".keybind.keyboard");
|
string_truncate_at_pattern(nodename, ".keybind.keyboard");
|
||||||
if (!strcmp(nodename, "key")) {
|
if (!strcmp(nodename, "key")) {
|
||||||
current_keybind = keybind_create(content);
|
current_keybind = keybind_create(content);
|
||||||
}
|
}
|
||||||
|
|
@ -82,7 +73,7 @@ fill_font(char *nodename, char *content, enum font_place place)
|
||||||
if (!content) {
|
if (!content) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rstrip(nodename, ".font.theme");
|
string_truncate_at_pattern(nodename, ".font.theme");
|
||||||
|
|
||||||
/* TODO: implement for all font places */
|
/* TODO: implement for all font places */
|
||||||
if (place != FONT_PLACE_ACTIVEWINDOW) {
|
if (place != FONT_PLACE_ACTIVEWINDOW) {
|
||||||
|
|
@ -118,7 +109,7 @@ entry(xmlNode *node, char *nodename, char *content)
|
||||||
if (!nodename) {
|
if (!nodename) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rstrip(nodename, ".openbox_config");
|
string_truncate_at_pattern(nodename, ".openbox_config");
|
||||||
|
|
||||||
/* for debugging */
|
/* for debugging */
|
||||||
if (write_to_nodename_buffer) {
|
if (write_to_nodename_buffer) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue