repo.or.cz
/
hband-tools.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
add unicode-aware expand command
[hband-tools.git]
/
half-baked
/
expand
blob
f190370dd77e8b7f05660b19879c8ffe5e247ec4
1
#!/usr/bin/env perl
2
3
# unicode-aware expand(1) replacement
4
5
use
Encode
;
6
binmode
STDOUT
,
":utf8"
;
7
8
$tabstop
=
4
;
9
$tabstopMinusOne
=
$tabstop
-
1
;
10
11
while
(<
STDIN
>)
12
{
13
Encode
::
_utf8_on
(
$_
);
14
s/((?<A>[^\t]{0,$tabstopMinusOne})\t|(?<A>[^\t]{$tabstop}))/sprintf "%s%s", $+{A}, " " x ($tabstop - length $+{A})/ge
;
15
print
;
16
}