2 Commits

Author SHA1 Message Date
rexy712
4631d532e0 Fixed handling of '-' for stdin 2019-05-11 08:05:55 -07:00
rexy712
f0247ac9c5 Fix segfault caused by off by one error 2019-01-15 11:39:57 -08:00
2 changed files with 4 additions and 1 deletions

View File

@@ -201,7 +201,7 @@ static constexpr size_t strlen_pre_eq(const char* str){
#define CHECK_VALID_SHORT_ARG(opt, arg, type) \
{ \
if(next_arg == (argc-1) || !is_##type(arg)){ \
if(next_arg == argc || !is_##type(arg)){ \
fwprintf(stderr, L"'-%s' requires an argument of type " #type "\n", opt); \
ret.error = 1; \
break; \
@@ -226,6 +226,8 @@ cmd_args process_cmd_args(int argc, char** argv){
}
if(!strcmp(argv[i], "--")){
escaped = true;
}else if(!strcmp(argv[i], "-")){
ret.filenames.push_back(argv[i]);
}else if(IS_SHORT_OPTION(argv[i])){
size_t arg_len = strlen(argv[i]);
int next_arg = i+1;

View File

@@ -126,6 +126,7 @@ int print_files(cmd_args& args){
if(in == L'\n') //Only reset on newline to save print overhead
p.reset();
}
clearerr(stdin);
}else{ //everything besides stdin
FILE* fp = fopen(args.filenames[i], "r");
if(!fp){