summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxhe <xw897002528@gmail.com>2017-11-07 13:22:38 +0800
committerrofl0r <retnyg@gmx.net>2017-11-07 15:33:27 +0000
commitbe6e739097dad30436ba97c5e72082af39b423f3 (patch)
treea9ffdad0b0adf9694c5c0f4dcd2d765c0da41659
parent17e631c409465faabd8fba5719506038375b48cc (diff)
downloadgettext-tiny-be6e739097dad30436ba97c5e72082af39b423f3.tar.gz
msgfmt: make in/out arguments parse code cleaner
Prepare for the next commit. 1. Using except_out_fn flag is a little complex, we could just get the filename by 'arg++ && A'. 2. i previously check except_in_fn in the block 'if (A[0] == '-')' to prevent ignoring the input file named '-..'. Again, i add similiar codes to 'A[1] == '-'' to prevent ignoring file named '--...'.
-rw-r--r--src/msgfmt.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/msgfmt.c b/src/msgfmt.c
index 4f8c7b6..6ccb56a 100644
--- a/src/msgfmt.c
+++ b/src/msgfmt.c
@@ -504,17 +504,13 @@ int main(int argc, char**argv) {
int arg = 1;
FILE *out = NULL;
FILE *in = NULL;
- int expect_out_fn = 0;
int expect_in_fn = 1;
int statistics = 0;
char* locale = NULL;
char* dest = NULL;
#define A argv[arg]
for(; arg < argc; arg++) {
- if(expect_out_fn) {
- set_file(1, A, &out);
- expect_out_fn = 0;
- } else if(A[0] == '-') {
+ if(A[0] == '-') {
if(A[1] == '-') {
if(
streq(A+2, "java") ||
@@ -547,10 +543,14 @@ int main(int argc, char**argv) {
statistics = 1;
} else if(streq(A+2, "version")) {
version();
+ } else if (expect_in_fn) {
+ set_file(0, A, &in);
+ expect_in_fn = 0;
} else if(streq(A+2, "help")) syntax();
} else if(streq(A + 1, "o")) {
- expect_out_fn = 1;
+ arg++;
+ set_file(1, A, &out);
} else if(
streq(A+1, "j") ||
streq(A+1, "r") ||