comparison recpt1/recpt1.c @ 63:ca419e61f7f2

fix for a bug that recpt1 crashes if dirname(3) returns '.'
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 10 Oct 2009 01:11:34 +0900
parents c6a5c844c7fd
children 18108d097707
comparison
equal deleted inserted replaced
62:c6a5c844c7fd 63:ca419e61f7f2
784 wfd = 1; /* stdout */ 784 wfd = 1; /* stdout */
785 } 785 }
786 else { 786 else {
787 if(!fileless) { 787 if(!fileless) {
788 int status; 788 int status;
789 char *dir = dirname(strdup(argv[optind + 2])); 789 char *path = strdup(argv[optind + 2]);
790 char *dir = dirname(path);
790 status = mkpath(dir, 0777); 791 status = mkpath(dir, 0777);
791 if(status == -1) 792 if(status == -1)
792 perror("mkpath"); 793 perror("mkpath");
793 free(dir); 794 free(path);
794 795
795 wfd = open(argv[optind + 2], (O_RDWR | O_CREAT | O_TRUNC), 0666); 796 wfd = open(argv[optind + 2], (O_RDWR | O_CREAT | O_TRUNC), 0666);
796 if(wfd < 0) { 797 if(wfd < 0) {
797 fprintf(stderr, "Cannot open output file: %s\n", 798 fprintf(stderr, "Cannot open output file: %s\n",
798 argv[optind + 2]); 799 argv[optind + 2]);