trset: ignore '(' inside brackets when counting groups - neatvi - [fork] simple vi-type editor with UTF-8 support
(HTM) git clone git://src.adamsgaard.dk/neatvi
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit e3d2ac66bd83987579f970043be6e6c31b29dd19
(DIR) parent dd8c8d2fd76f346bd04e372076310a59554ba5e3
(HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Sun, 7 Jun 2015 11:32:17 +0430
rset: ignore '(' inside brackets when counting groups
Diffstat:
M rset.c | 11 +++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/rset.c b/rset.c
t@@ -19,6 +19,17 @@ static int re_groupcount(char *s)
while (*s) {
if (s[0] == '(')
n++;
+ if (s[0] == '[') {
+ int dep = 0;
+ s += s[1] == '^' ? 3 : 2;
+ while (s[0] && (s[0] != ']' || dep)) {
+ if (s[0] == '[')
+ dep++;
+ if (s[0] == ']')
+ dep--;
+ s++;
+ }
+ }
if (s[0] == '\\' && s[1])
s++;
s++;