Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make --files-from work like in gettext #74

Open
sareyko opened this issue Sep 13, 2018 · 2 comments
Open

Make --files-from work like in gettext #74

sareyko opened this issue Sep 13, 2018 · 2 comments
Labels

Comments

@sareyko
Copy link

sareyko commented Sep 13, 2018

Currently the file list supplied via --files-from is split at each line feed \n:

xgettext/index.js

Lines 195 to 201 in 2a23cf5

if (options['files-from']) {
input = fs.readFileSync(options['files-from'], options['from-code'])
.split('\n')
.filter(function (line) {
return line.trim().length > 0;
});
}

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.
@smhg
Copy link
Collaborator

smhg commented Sep 13, 2018

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 smhg added the bug label Sep 13, 2018
@sareyko
Copy link
Author

sareyko commented Sep 29, 2018

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

sareyko pushed a commit to sareyko/xgettext that referenced this issue Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants