diff --git a/sh/noccom b/sh/noccom index 39c28ac..2be2726 100644 --- a/sh/noccom +++ b/sh/noccom @@ -4,13 +4,45 @@ noccom() { [ -s ~/opt/local/bin/noccom ] || cat > ~/opt/local/bin/noccom <; -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*\\n)+##s; + +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; EOF + perl ~/opt/local/bin/noccom "$@" } noccom "$@"