diff options
author | Luo Jinghua <sunmoon1997@gmail.com> | 2010-01-09 01:06:57 +0800 |
---|---|---|
committer | Luo Jinghua <sunmoon1997@gmail.com> | 2010-01-09 01:06:57 +0800 |
commit | e2cfe1dc1c5abfa9c0846f7e2394a112003d9fc7 (patch) | |
tree | d2ca6888c307c65d05ec811b43d9799c52455726 | |
parent | 558ab0fbd5bbbe6a3bcd14a5398c2b2285a2753b (diff) |
uconv: treat - as stdin or stdout
-rw-r--r-- | uconv.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <uniconv.h> #include <assert.h> @@ -28,10 +29,15 @@ int main(int argc, char **argv) return -1; } + if (!strcmp (argv[3], "-")) + infp = stdin; infp = fopen(argv[3], "rb"); if (!infp) return -1; - outfp = fopen(argv[4], "wb"); + if (!strcmp (argv[4], "-")) + outfp = stdout; + else + outfp = fopen(argv[4], "wb"); if (!outfp) return -1; @@ -87,8 +93,10 @@ int main(int argc, char **argv) } } - fclose(outfp); - fclose(infp); + if (outfp != stdout) + fclose(outfp); + if (infp != stdin) + fclose(infp); uniconv_close(conv); |