summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2011-09-19 19:48:06 +0200
committerportix <portix@gmx.net>2011-09-19 19:48:06 +0200
commit9c85f2c94ef2ec6dddd48fa3ee7f25bd1e0aac81 (patch)
treee049027fd05f5331227962f09a3c50eff5cb4f20 /src/util.c
parentb4c4cc702cdf6d461e4c4aa498a2821e467c8838 (diff)
parente5d8c756e67538c341791fcec97a21a08be13f24 (diff)
downloaddwb-9c85f2c94ef2ec6dddd48fa3ee7f25bd1e0aac81.zip
Merging develop into default
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index ec61de7b..ce977f1b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -192,6 +192,10 @@ int
util_navigation_compare_second(Navigation *a, Navigation *b) {
return (strcmp(a->second, b->second));
}/*}}}*/
+int
+util_quickmark_compare(Quickmark *a, Quickmark *b) {
+ return strcmp(a->key, b->key);
+}
/* util_keymap_sort_first(KeyMap *, KeyMap *) {{{*/
int
util_keymap_sort_first(KeyMap *a, KeyMap *b) {
@@ -325,6 +329,33 @@ util_get_data_file(const char *filename) {
}
return NULL;
}
+static inline int
+util_strcmp_skip_newline(const char *s1, const char *s2) {
+ char *nl = strstr(s2, "\n");
+ if (nl != NULL)
+ return strncmp(s1, s2, nl - s1);
+ else
+ return strcmp(s1, s2);
+}
+int
+util_file_remove_line(const char *filename, const char *line) {
+ int ret = 1;
+ char *content = util_get_file_content(filename);
+ char **lines = g_strsplit(content, "\n", -1);
+ GString *buffer = g_string_new(NULL);
+ for (int i=0; lines[i]; i++) {
+ if (strlen(lines[i]) > 0 && STRCMP_FIRST_WORD(lines[i], line)) {
+ g_string_append_printf(buffer, "%s\n", lines[i]);
+ }
+ }
+ g_file_set_contents(filename, buffer->str, -1, NULL);
+
+ g_string_free(buffer, true);
+ g_free(content);
+ g_strfreev(lines);
+
+ return ret;
+}
/* NAVIGATION {{{*/
/* dwb_navigation_new(const char *uri, const char *title) {{{*/