summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2010-01-09 01:06:57 +0800
committerLuo Jinghua <sunmoon1997@gmail.com>2010-01-09 01:06:57 +0800
commite2cfe1dc1c5abfa9c0846f7e2394a112003d9fc7 (patch)
treed2ca6888c307c65d05ec811b43d9799c52455726
parent558ab0fbd5bbbe6a3bcd14a5398c2b2285a2753b (diff)
uconv: treat - as stdin or stdout
-rw-r--r--uconv.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/uconv.c b/uconv.c
index a21829a..c496024 100644
--- a/uconv.c
+++ b/uconv.c
@@ -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);