summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharalampos Kardaris <ckardaris@outlook.com>2019-12-04 17:42:23 +0200
committerCharalampos Kardaris <ckardaris@outlook.com>2019-12-04 17:42:23 +0200
commit35add2fc077dcc1436d36dc9f1e4df71651cd6a6 (patch)
tree4c18d2c9aff70c45684b2646cc1b9d7c3c84c769
parentMinor fix (diff)
downloadmktrayicon-35add2fc077dcc1436d36dc9f1e4df71651cd6a6.tar.gz
mktrayicon-35add2fc077dcc1436d36dc9f1e4df71651cd6a6.tar.bz2
mktrayicon-35add2fc077dcc1436d36dc9f1e4df71651cd6a6.zip
Accept empty entries everywhere
-rw-r--r--mktrayicon.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/mktrayicon.c b/mktrayicon.c
index 78e6053..b414af3 100644
--- a/mktrayicon.c
+++ b/mktrayicon.c
@@ -335,23 +335,7 @@ gpointer watch_fifo(gpointer argv)
}
// This block makes sure that the parameter after 'm' is ready to be processed
-
- char* initial = param;
- //we save so that we can free later even if we increase the pointer
-
- while (param[0] == ',' || param[0] == '|'){
- // ignore delimiter characters in first spot
- param++;
- len--;
- }
- while ((param[len-1] == ',' || param[len-1] == '|') && param[len-2] != '\\'){
- // ignore delimiters at the end too
- // it also helps dividing the string in entries -> bars+1
- param[len-1] = '\0';
- len--;
- }
-
- // we can't accept 2 straight commas, as it becomes ambiguous
+ // We can't accept 2 straight commas, as it becomes ambiguous
int straight = 0;
int bars = 0;
for (int i = 0; i < len; i++){
@@ -367,7 +351,7 @@ gpointer watch_fifo(gpointer argv)
}
if (straight == 2){
printf("Two straight ',' found. Use '\\' to escape\n");
- free(initial);
+ free(param);
break;
}
// End of block that checks the parameter
@@ -379,7 +363,7 @@ gpointer watch_fifo(gpointer argv)
int last = -1;
int item = 0;
char lastFound = '|'; // what was the last delimiter processed
- for(int i = 1; i < len; i++){
+ for(int i = 0; i < len; i++){
if (param[i] == ',' && param[i-1] != '\\'){
onmenu[item].name = save_word(param, i, last);
last = i;
@@ -417,7 +401,7 @@ gpointer watch_fifo(gpointer argv)
g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(click_menu_item), NULL);
}
gtk_widget_show_all(menu);
- free(initial);
+ free(param);
break;
default:
fprintf(stderr, "Unknown command: '%c'\n", *buf);
bgstack15