diff options
author | Michael Tänzer <neo@nhng.de> | 2012-01-31 04:00:35 +0100 |
---|---|---|
committer | Michael Tänzer <neo@nhng.de> | 2012-01-31 04:00:35 +0100 |
commit | 56cff58b4856066a83c7ee1a649c0e2d26e17173 (patch) | |
tree | ae6b56f8cdbd76ebabf493c5b193c8dfa07cfcb3 /locale | |
parent | d30dd44c1a5eeac330a4281e58db9a0873b32271 (diff) | |
download | cacert-devel-56cff58b4856066a83c7ee1a649c0e2d26e17173.tar.gz cacert-devel-56cff58b4856066a83c7ee1a649c0e2d26e17173.tar.xz cacert-devel-56cff58b4856066a83c7ee1a649c0e2d26e17173.zip |
bug 1011: work around PHP 5.2
PHP 5.2 gives a warning when the first string in substr_compare() is shorter
than $length while PHP 5.3 does not care. Of course this change in
behaviour is not documented and PHP as we know and love it doesn't
report this error on STDERR but spills its crap all over STDIN which causes
msgfmt to get all confused
Signed-off-by: Michael Tänzer <neo@nhng.de>
Diffstat (limited to 'locale')
-rwxr-xr-x | locale/escape_special_chars.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/locale/escape_special_chars.php b/locale/escape_special_chars.php index 4ec0d9a..32de390 100755 --- a/locale/escape_special_chars.php +++ b/locale/escape_special_chars.php @@ -20,21 +20,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /* Convert special characters in UTF-8 encoded PO files to HTML entities */ +define('MSGSTR', 'msgstr'); +define('MSGSTR_LEN', strlen(MSGSTR)); +define('MSGID', 'msgid'); +define('MSGID_LEN', strlen(MSGID)); function is_msgstr($line) { - return substr_compare($line, 'msgstr', 0, strlen('msgstr')) === 0; + if (strlen($line) < MSGSTR_LEN) { + return false; + } + + return substr_compare($line, MSGSTR, 0, MSGSTR_LEN) === 0; } function is_msgid($line) { - return substr_compare($line, 'msgid', 0, strlen('msgid')) === 0; + if (strlen($line) < MSGID_LEN) { + return false; + } + + return substr_compare($line, MSGID, 0, MSGID_LEN) === 0; } // Skip the metadata (first msgid/msgstr pair) while (!feof(STDIN)) { $line = fgets(STDIN); - if ($line === false) { - exit(0); //EOF after newline mostly - } echo $line; @@ -48,9 +57,6 @@ $msgstr = false; while (!feof(STDIN)) { $line = fgets(STDIN); - if ($line === false) { - exit(0); //EOF after newline mostly - } if (is_msgstr($line)) { $msgstr = true; |