xgettext icon indicating copy to clipboard operation
xgettext copied to clipboard

Make `--files-from` work like in gettext

Open sareyko opened this issue 6 years ago • 2 comments

Currently the file list supplied via --files-from is split at each line feed \n: https://github.com/gmarty/xgettext/blob/2a23cf592728bf98acda2b53f0ad1b01eae3b735/index.js#L195-L201

This leads to problems with lists generated by programs that produce "Windows linebreaks" (CR LF, \r\n).

This is why I suggest changing the current behaviour and making line splitting work like in GNU gettext: https://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/src/file-list.c?id=b26729c67cffb2403d8a20b44606f5a08cb901b5#n68

What is done is basically this:

  1. Get next line from the file.
  2. Remove trailing new line \n
  3. Remove any of: Tab \t, space (I'm not sure this is actually a good idea) and \r from the end of the string.

sareyko avatar Sep 13 '18 10:09 sareyko

This sounds really good! Thank you for the research!

Would you be able to send a PR? In that case please also extend the current --files-from test in test/cli.js to include at least 2 lines.

smhg avatar Sep 13 '18 19:09 smhg

I'll send a PR as soon as I get a bit of free time.

sareyko avatar Sep 29 '18 14:09 sareyko