Fixed stderr
This commit is contained in:
parent
f757f23d11
commit
e5cb265456
@ -233,7 +233,7 @@ static constexpr size_t strlen_pre_eq(const char* str){
|
|||||||
#define CHECK_VALID_LONG_ARG(opt, off, arg, type) \
|
#define CHECK_VALID_LONG_ARG(opt, off, arg, type) \
|
||||||
{ \
|
{ \
|
||||||
if(arg[off] != '=' || !is_##type(arg+off+1)){ \
|
if(arg[off] != '=' || !is_##type(arg+off+1)){ \
|
||||||
fprintf(stderr, L"'--%.*s' requires an argument of type " #type "\n", off, opt); \
|
fprintf(stderr, "'--%.*s' requires an argument of type " #type "\n", off, opt); \
|
||||||
ret.error = 1; \
|
ret.error = 1; \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
@ -244,7 +244,7 @@ static constexpr size_t strlen_pre_eq(const char* str){
|
|||||||
#define CHECK_VALID_SHORT_ARG(opt, arg, type) \
|
#define CHECK_VALID_SHORT_ARG(opt, arg, type) \
|
||||||
{ \
|
{ \
|
||||||
if(next_arg == argc || !is_##type(arg)){ \
|
if(next_arg == argc || !is_##type(arg)){ \
|
||||||
fprintf(stderr, L"'-%s' requires an argument of type " #type "\n", opt); \
|
fprintf(stderr, "'-%s' requires an argument of type " #type "\n", opt); \
|
||||||
ret.error = 1; \
|
ret.error = 1; \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
@ -354,7 +354,7 @@ cmd_args process_cmd_args(int argc, char** argv){
|
|||||||
default:
|
default:
|
||||||
//keep parsing after error so we can still properly output requested color style
|
//keep parsing after error so we can still properly output requested color style
|
||||||
ret.error = 1;
|
ret.error = 1;
|
||||||
fprintf(stderr, L"Unrecognized option '-%c'\n", argv[i][j]);
|
fprintf(stderr, "Unrecognized option '-%c'\n", argv[i][j]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
i = next_arg-1;
|
i = next_arg-1;
|
||||||
@ -407,7 +407,7 @@ cmd_args process_cmd_args(int argc, char** argv){
|
|||||||
;
|
;
|
||||||
}else{
|
}else{
|
||||||
ret.error = 1;
|
ret.error = 1;
|
||||||
fprintf(stderr, L"Unrecognized option '%s'\n", argv[i]);
|
fprintf(stderr, "Unrecognized option '%s'\n", argv[i]);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ret.filenames.push_back(argv[i]);
|
ret.filenames.push_back(argv[i]);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ static constexpr size_t constexpr_strlen(const char* str){
|
|||||||
static int detect_term_colors(void){
|
static int detect_term_colors(void){
|
||||||
int term_colors = 16;
|
int term_colors = 16;
|
||||||
if(setupterm(NULL, fileno(stdout), NULL) == ERR){
|
if(setupterm(NULL, fileno(stdout), NULL) == ERR){
|
||||||
fprintf(stderr, L"could not set up term\n");
|
fprintf(stderr, "could not set up term\n");
|
||||||
}else{
|
}else{
|
||||||
term_colors = tigetnum("colors");
|
term_colors = tigetnum("colors");
|
||||||
if(term_colors < 0){
|
if(term_colors < 0){
|
||||||
@ -154,7 +154,7 @@ int print_normal_files(const cmd_args& args){
|
|||||||
FILE* fp = fopen(args.filenames[i], "r");
|
FILE* fp = fopen(args.filenames[i], "r");
|
||||||
if(!fp){
|
if(!fp){
|
||||||
fflush(stdout); //force color update before error
|
fflush(stdout); //force color update before error
|
||||||
fprintf(stderr, L"Unable to open file %s\n", args.filenames[i]);
|
fprintf(stderr, "Unable to open file %s\n", args.filenames[i]);
|
||||||
ret = 2;
|
ret = 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -242,7 +242,7 @@ int main(int argc, char** argv){
|
|||||||
int avail_colors = detect_term_colors();
|
int avail_colors = detect_term_colors();
|
||||||
|
|
||||||
if(args.error){
|
if(args.error){
|
||||||
fprintf(stderr, L"Try '%s --help' for more information.\n", argv[0]);
|
fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user