See <https://savannah.gnu.org/bugs/?35109>.
The Python language reference states that the line endings should be treated equally, regardless of platform. However, xgettext assumes LF and is causing failure on multiline string handling. This patch tries to convert other line endings (CR and CRLF) to LF. >From 346699bfec77187eea1734d338855015a94824b6 Mon Sep 17 00:00:00 2001 From: Daiki Ueno <[email protected]> Date: Tue, 16 Apr 2013 15:17:14 +0900 Subject: [PATCH] Convert line endings when scanning Python source code --- gettext-tools/src/x-python.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index aa6a7d6..b973211 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -156,7 +156,11 @@ static FILE *fp; static unsigned char phase1_pushback[MAX_PHASE1_PUSHBACK]; static int phase1_pushback_length; -/* Read the next single byte from the input file. */ +/* Read the next single byte from the input file. + + Terminate line by \n, regardless whether the external + representation of a line terminator is CR (Mac), and CR/LF + (DOS/Windows), as Python treat them equally. */ static int phase1_getc () { @@ -177,6 +181,16 @@ phase1_getc () } } + if (c == '\r') + { + int c1 = getc (fp); + + if (c1 != EOF && c1 != '\n') + ungetc (c1, fp); + + /* Seen line terminator CR or CR/LF. */ + return '\n'; + } if (c == '\n') ++line_number; -- 1.8.1.4
