mirror of
https://github.com/notwa/rc
synced 2024-04-29 02:43:23 -07:00
fix bugs in noccom
This commit is contained in:
parent
7703d77332
commit
d100b43f69
40
sh/noccom
40
sh/noccom
|
@ -4,13 +4,45 @@
|
||||||
noccom() {
|
noccom() {
|
||||||
[ -s ~/opt/local/bin/noccom ] || cat > ~/opt/local/bin/noccom <<EOF
|
[ -s ~/opt/local/bin/noccom ] || cat > ~/opt/local/bin/noccom <<EOF
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
$/ = undef;
|
|
||||||
|
\$/ = undef;
|
||||||
\$_ = <>;
|
\$_ = <>;
|
||||||
s#/\\*[^*]*\\*+([^/*][^*]*\\*+)*/|//([^\\\\]|[^\\n][\\n]?)*?\\n|("(\\\\.|[^"\\\\])*"|'(\\\\.|[^'\\\\])*'|.[^/"'\\\\]*)#defined \$3 ? \$3 : ""#gse;
|
|
||||||
s#|\\\\?\\n\\s*([{}])?\\s*(;*)\\s*(?=\\\\?\\n)|("(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|.[^/"'\\\\\\n]*)#defined \$3?\$3:defined \$1?" ".\$1.\$2:\$2#gse;
|
s{
|
||||||
s#^(\\s*\\n)+##s;
|
/\\*[^*]*\\*+([^/*][^*]*\\*+)*/
|
||||||
|
|
|
||||||
|
//([^\\\\]
|
||||||
|
|
|
||||||
|
[^\\n][\\n]?)*?\\n
|
||||||
|
|
|
||||||
|
(
|
||||||
|
"(?:\\\\.|[^"\\\\])*"
|
||||||
|
|
|
||||||
|
'(?:\\\\.|[^'\\\\])*'
|
||||||
|
|
|
||||||
|
.[^/"'\\\\]*
|
||||||
|
)
|
||||||
|
}{defined \$3 ? \$3 : ""}gxse;
|
||||||
|
|
||||||
|
s{
|
||||||
|
\\\\?\\n\\s*([{}])?\\s*(;*)\\s*(?=\\\\?\\n)
|
||||||
|
|
|
||||||
|
(
|
||||||
|
\\#[^\\n]*\\n
|
||||||
|
|
|
||||||
|
"(?:\\\\.|[^"\\\\])*"
|
||||||
|
|
|
||||||
|
'(?:\\\\.|[^'\\\\])*'
|
||||||
|
|
|
||||||
|
.[^#/"'\\\\\\n]*
|
||||||
|
)
|
||||||
|
}{defined \$3 ? \$3 : (defined \$1 ? " ".\$1.\$2 : \$2)}gxse;
|
||||||
|
|
||||||
|
s#(^|\\n)\\s+#\$1#gs;
|
||||||
|
|
||||||
print;
|
print;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
perl ~/opt/local/bin/noccom "$@"
|
perl ~/opt/local/bin/noccom "$@"
|
||||||
}
|
}
|
||||||
noccom "$@"
|
noccom "$@"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user