Skip to content

Commit 12238b3

Browse files
committed
Add support for bash-like comments
1 parent 854affb commit 12238b3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

bin/compile.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
error_reporting(E_ALL);
1717

18-
$VERSION = '1.2.0';
18+
$VERSION = '1.3.0-dev';
1919

2020
/**
2121
* BEWARE:

src/Phar.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ function php_strip_whitespace($file): string
2121
{
2222
$lines = file($file, FILE_IGNORE_NEW_LINES);
2323

24-
// First pass, process inline comments
25-
// We need to rely on the LF chars here
24+
// First pass, one-line comments
25+
// Processing is easier using a per-line approach
2626
$lines = array_map(function ($line) {
27-
if (preg_match('!^//.*$!', $line)) {
27+
if (preg_match('!^(//|#[^\[]).*$!', $line)) {
2828
return null;
2929
}
3030
// Prevent processing non-comment lines (eg: containing php:// or http:// uris)
3131
// to be mistakenly treated as such
32-
return preg_replace('!\s//.*$!', '', $line);
32+
return preg_replace('!\s(//|#[^\[]).*$!', '', $line);
33+
//return preg_replace('!([^:])' . '(//|#[^\[])' . '.*$!', '$1', $line);
3334
}, $lines);
3435

3536
// Second pass: multi-line comments

0 commit comments

Comments
 (0)