diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2024-11-01 20:26:48 +0100 | 
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2024-11-01 20:26:48 +0100 | 
| commit | ec5976bbd5a930e040a34b9e93bf9cc41d7230c1 (patch) | |
| tree | ec46751b70c254118de4df8527e3741cf08a59d2 | |
| parent | 8199336423014729c92bac5c463e550810a28bdc (diff) | |
Simplify check for empty regex
| -rw-r--r-- | src/main.c | 10 | 
1 files changed, 3 insertions, 7 deletions
@@ -277,19 +277,15 @@ pattern_comp(u8view_t pat)  		/* Find the right delimeter, which is optional for the last  		   operator */ -		u8view_t re = {pat.p, -1}; +		u8view_t re = {pat.p, 0};  		while ((w = ucsnext(&ch, &pat)) != 0) {  			if (ch == '\\') {  				if (ucsnext(nullptr, &pat) == 0)  					cerr(EXIT_FATAL, "Premature end of pattern"); -			} else if (ch == rdelim) { -				re.len = pat.p - re.p - w; +			} else if (ch == rdelim)  				break; -			}  		} -		if (re.len == -1) -			re.len = pat.p - re.p; -		if (re.len == 0) { +		if ((re.len = pat.p - re.p - w) == 0) {  			if (op.c != 'h') {  				cerr(EXIT_FATAL, "%s%c%s operator given empty regex",  				     lquot, op.c, rquot);  |