summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxhe <xw897002528@gmail.com>2017-11-07 13:22:38 +0800
committerxhe <xw897002528@gmail.com>2017-11-07 13:26:45 +0800
commite790353d1629d8623c55ebb49d590009710e19b4 (patch)
tree72dc702b902e3c29d1a0a7b10fcccf1187f6e048
parent7fdbdd2b387e8c0c127c5fbd746eea96b08cf4a4 (diff)
downloadgettext-tiny-e790353d1629d8623c55ebb49d590009710e19b4.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") ||