[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Bugfix: Rule command requires 1 consequence
- To: herbstluftwm _minus_ devel _at_ lists _dot_ sourceforge _dot_ net
- Subject: Re: [PATCH] Bugfix: Rule command requires 1 consequence
- From: Tyler Thomas Hart <htyler _at_ pdx _dot_ edu>
- Date: Sat, 15 Dec 2012 00:46:17 -0800
Whoops.
Totally forgot to free the empty rule (pointers and flags and maybe conditions).
This patch does this
Tylo
>From 0724e7fa4ce78cc5125f691b1b0a8415eee528a6 Mon Sep 17 00:00:00 2001
From: Tyler Thomas Hart <htyler _at_ pdx _dot_ edu>
Date: Sat, 15 Dec 2012 00:43:15 -0800
Subject: [PATCH] Rule command checks for at least 1 consequence
---
NEWS | 1 +
doc/herbstluftwm.txt | 4 ++--
src/rules.c | 8 ++++++++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 7a69e51..7e6a68e 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,7 @@ Changes:
* add error messages for herbstclient
* new command: shift_edge
* new command: shift_to_monitor
+ * bug fix: rule command requires at least 1 consequence
Release: 0.4.1 on 2012-08-30
----------------------------
diff --git a/doc/herbstluftwm.txt b/doc/herbstluftwm.txt
index 54178f6..10ba753 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -619,7 +619,7 @@ floating [['TAG'] *on*|*off*|*toggle*|*status*]::
is given, floating mode is toggled. If status is given, then *on* or *off*
is printed, depending of the floating state on 'TAG'.
-rule [\[--]'FLAG'|\[--]'CONDITION'|\[--]'CONSEQUENCE' ...]::
+rule [\[--]'FLAG'|\[--]'CONDITION'] ... \[--]'CONSEQUENCE' ...::
Defines a rule which will be applied to all new clients. Its behaviour is
described in the <<RULES,*RULES section*>>.
@@ -836,7 +836,7 @@ appear. Each rule matches against a certain subset of all clients and defines a
set of properties for them (called 'CONSEQUENCE'##s##). A rule can be defined
with this command:
-+rule+ [\[--]'FLAG'|\[--]'CONDITION'|\[--]'CONSEQUENCE' ...]
++rule+ [\[--]'FLAG'|\[--]'CONDITION'] ... \[--]'CONSEQUENCE' ...
Each rule consists of a list of 'FLAG'##s##, 'CONDITION'##s## and
'CONSEQUENCE'##s## (each of them can be optionally prefixed with two dashes
diff --git a/src/rules.c b/src/rules.c
index 95a0ac5..a89e2c6 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -362,6 +362,14 @@ int rule_add_command(int argc, char** argv, GString* output) {
}
}
+ // Check if there is at least 1 consequence
+ if (rule->consequences == NULL) {
+ g_string_append_printf(output,
+ "rule: you must specify at least one consequence\n");
+ rule_destroy(rule);
+ return HERBST_FORBIDDEN;
+ }
+
g_queue_push_tail(&g_rules, rule);
return 0;
}
--
1.8.0.2