shithub: neatroff

Download patch

ref: 8626cedf2864bf52786f0df30aad70e10a24ef91
parent: dc79dfc70a21b64059e3aec08e218f83010320c8
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Apr 25 17:04:34 EDT 2013

tr: .if should accept any non-digit string delimiter

--- a/tr.c
+++ b/tr.c
@@ -1,3 +1,4 @@
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -171,11 +172,12 @@
 static int if_strcmp(void)
 {
 	struct sbuf s1, s2;
-	int ret;
+	int ret, delim;
+	delim = cp_next();
 	sbuf_init(&s1);
 	sbuf_init(&s2);
-	read_until(&s1, '\'');
-	read_until(&s2, '\'');
+	read_until(&s1, delim);
+	read_until(&s2, delim);
 	ret = !strcmp(sbuf_buf(&s1), sbuf_buf(&s2));
 	sbuf_done(&s1);
 	sbuf_done(&s2);
@@ -220,7 +222,8 @@
 		neg = 1;
 		c = cp_next();
 	}
-	if (c == '\'') {
+	if (!isdigit(c) && !strchr("-+*/%<=>&:.|()", c)) {
+		cp_back(c);
 		ret = if_strcmp();
 	} else {
 		cp_back(c);