[GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add regex patterns for CSS. The word regex maches selectors, properties,
and values. On the other hand, the funcname regex matches lines contains
the curly brace character.

Signed-off-by: Hiroyuki Sano <sh19910711@xxxxxxxxx>
---
 t/t4018-diff-funcname.sh |  1 +
 t/t4034-diff-words.sh    |  1 +
 t/t4034/css/expect       | 35 +++++++++++++++++++++++++++++++++++
 t/t4034/css/post         | 32 ++++++++++++++++++++++++++++++++
 t/t4034/css/pre          | 32 ++++++++++++++++++++++++++++++++
 userdiff.c               |  3 +++
 6 files changed, 104 insertions(+)
 create mode 100644 t/t4034/css/expect
 create mode 100644 t/t4034/css/post
 create mode 100644 t/t4034/css/pre

diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 1dbaa38..29fe220 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -30,6 +30,7 @@ diffpatterns="
 	bibtex
 	cpp
 	csharp
+	css
 	fortran
 	html
 	java
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index f2f55fc..912df91 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -302,6 +302,7 @@ test_language_driver ada
 test_language_driver bibtex
 test_language_driver cpp
 test_language_driver csharp
+test_language_driver css
 test_language_driver fortran
 test_language_driver html
 test_language_driver java
diff --git a/t/t4034/css/expect b/t/t4034/css/expect
new file mode 100644
index 0000000..8bc6dfd
--- /dev/null
+++ b/t/t4034/css/expect
@@ -0,0 +1,35 @@
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index c53f20b..7e64463 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
+<CYAN>@@ -2,7 +2,7 @@<RESET> <RESET><MAGENTA>elm1, elm2 {<RESET>
+prop: first-value;<RESET>
+prop: value;<RESET>
+prop: value;<RESET>
+prop: <RED>value<RESET><GREEN>NEW-VALUE<RESET>;
+prop: last-value;<RESET>
+}<RESET>
+
+<CYAN>@@ -10,7 +10,7 @@<RESET> <RESET><MAGENTA>elm3, elm4 {<RESET>
+prop: first-value;<RESET>
+prop: value;<RESET>
+prop: value;<RESET>
+<RED>prop<RESET><GREEN>NEW-PROP<RESET>: value;
+prop: last-value;<RESET>
+}<RESET>
+
+<CYAN>@@ -19,7 +19,7 @@<RESET> <RESET><MAGENTA>elm6 {<RESET>
+prop: first-value;<RESET>
+prop: value;<RESET>
+prop: value;<RESET>
+<RED>prop<RESET><GREEN>NEW-PROP<RESET>: <RED>value<RESET><GREEN>NEW-VALUE<RESET>;
+prop: last-value;<RESET>
+}<RESET>
+
+<CYAN>@@ -27,6 +27,6 @@<RESET> <RESET><MAGENTA>.class, elm:hover, elm:first-child, elm:lang(en), #id, elm#id, .num123{<RESET>
+prop: first-value;<RESET>
+prop: value;<RESET>
+prop: value;<RESET>
+<RED>prop<RESET><GREEN>NUM-PROP<RESET>: <RED>value<RESET><GREEN>999<RESET>;
+prop: last-value;<RESET>
+}<RESET>
diff --git a/t/t4034/css/post b/t/t4034/css/post
new file mode 100644
index 0000000..7e64463
--- /dev/null
+++ b/t/t4034/css/post
@@ -0,0 +1,32 @@
+elm1, elm2 {
+prop: first-value;
+prop: value;
+prop: value;
+prop: NEW-VALUE;
+prop: last-value;
+}
+
+elm3, elm4 {
+prop: first-value;
+prop: value;
+prop: value;
+NEW-PROP: value;
+prop: last-value;
+}
+
+elm5,
+elm6 {
+prop: first-value;
+prop: value;
+prop: value;
+NEW-PROP: NEW-VALUE;
+prop: last-value;
+}
+
+.class, elm:hover, elm:first-child, elm:lang(en), #id, elm#id, .num123{
+prop: first-value;
+prop: value;
+prop: value;
+NUM-PROP: 999;
+prop: last-value;
+}
diff --git a/t/t4034/css/pre b/t/t4034/css/pre
new file mode 100644
index 0000000..c53f20b
--- /dev/null
+++ b/t/t4034/css/pre
@@ -0,0 +1,32 @@
+elm1, elm2 {
+prop: first-value;
+prop: value;
+prop: value;
+prop: value;
+prop: last-value;
+}
+
+elm3, elm4 {
+prop: first-value;
+prop: value;
+prop: value;
+prop: value;
+prop: last-value;
+}
+
+elm5,
+elm6 {
+prop: first-value;
+prop: value;
+prop: value;
+prop: value;
+prop: last-value;
+}
+
+.class, elm:hover, elm:first-child, elm:lang(en), #id, elm#id, .num123{
+prop: first-value;
+prop: value;
+prop: value;
+prop: value;
+prop: last-value;
+}
diff --git a/userdiff.c b/userdiff.c
index 2ccbee5..8374a2a 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -37,6 +37,9 @@ IPATTERN("fortran",
 	 "|//|\\*\\*|::|[/<>=]="),
 PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
 	 "[^<>= \t]+"),
+PATTERNS("css",
+	 "^.*[{].*$",
+	 "[-_\\.,#a-zA-Z0-9]+"),
 PATTERNS("java",
 	 "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
 	 "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",
-- 
2.3.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]