[hackers] [sbase] Add trivial equivalence class support in tr(1) and update manpage || FRIGN

From: <git_AT_suckless.org>
Date: Wed, 28 Jan 2015 19:48:35 +0100 (CET)

commit 231f950a8df7f67d56911bb55ac538afe5f7ee28
Author: FRIGN <dev_AT_frign.de>
Date: Wed Jan 28 19:44:05 2015 +0100

    Add trivial equivalence class support in tr(1) and update manpage
    
    Equivalence classes are a hard matter and there's still no "standard"
    way to solve the issue.
    Previously, tr would just skip those classes, but it's much
    better when it resolves a [=c=] to a normal c instead of treating
    it as a literal.
    
    Also, reflect recent changes in the manpage (octal escapes) and fix
    the markup in some areas.

diff --git a/tr.1 b/tr.1
index 29ea1f1..75d0658 100644
--- a/tr.1
+++ b/tr.1
_AT_@ -25,22 +25,27 @@ Squeeze repeated characters matching
 .Ar set1
 or
 .Ar set2
-if -d is set.
+if
+.Fl d
+is set.
 .El
 .Sh SET
 .Bl -tag -width Ds
-.It Literal 'c'
-.It Escape sequence '\ec'
-\e\e, \ea, \eb, \ef, \en, \er, \et, \ev
-.It Range 'c-d'
-.It Repeat '[c*n]'
+.It Literal Sy c
+.It Escape sequence Sy \ec
+\e\e, \ea, \eb, \ef, \en, \er, \et, \ev, \eO[OO]
+.It Range Sy c-d
+.It Repeat Sy [c*n]
 Only in
 .Ar set2 .
 If n = 0 or left out, set n to length of
 .Ar set1 .
-.It Character class '[:class:]'
+.It Character class Sy [:class:]
 See
 .Xr wctype 3 .
+.It Equivalence class Sy [=c=]
+Resolve to
+.Sy c .
 .El
 .Sh TRANSLATION
 If no options are specified,
diff --git a/tr.c b/tr.c
index 7aa71e7..a5b9b62 100644
--- a/tr.c
+++ b/tr.c
_AT_@ -143,6 +143,12 @@ nextbrack:
 
                         /* CLASSES [=EQUIV=] (skip) */
                         if (j - i > 3 && rstr[i + 1] == '=' && rstr[m - 1] == '=') {
+ if (j - i != 4)
+ goto literal;
+ (*set)[setranges].start = rstr[i + 2];
+ (*set)[setranges].end = rstr[i + 2];
+ (*set)[setranges].quant = 1;
+ setranges++;
                                 i = j;
                                 continue;
                         }
Received on Wed Jan 28 2015 - 19:48:35 CET

This archive was generated by hypermail 2.3.0 : Wed Jan 28 2015 - 20:00:17 CET