summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uriunescape.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/uriunescape.c b/uriunescape.c
index aafc6ea..0a7ef5d 100644
--- a/uriunescape.c
+++ b/uriunescape.c
@@ -2,11 +2,21 @@
#include <unistd.h>
int main(int argc,char *argv[]) {
+ int n;
int len;
- for(argv++,argc--;argc;argc--,argv++) {
- len=uriunescape(*argv,*argv);
- write(1,*argv,len);
- if(argc-1) write(1," ",1);
+ char buf[4096];
+ if(argc > 1) {
+ for(argv++,argc--;argc;argc--,argv++) {
+ len=uriunescape(*argv,*argv);
+ write(1,*argv,len);
+ if(argc-1) write(1," ",1);
+ }
+ } else {
+ while((n=read(0,buf,sizeof(buf)-1)) > 0) {
+ buf[n]=0;
+ len=uriunescape(buf,buf);
+ write(1,buf,len);
+ }
}
return 0;
}