Consistent stderr

This commit is contained in:
Rexy712 2019-05-19 12:41:52 -07:00
parent c9f39be9d8
commit f757f23d11
2 changed files with 7 additions and 7 deletions

View File

@ -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)){ \
fwprintf(stderr, L"'--%.*s' requires an argument of type " #type "\n", off, opt); \ fprintf(stderr, L"'--%.*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)){ \
fwprintf(stderr, L"'-%s' requires an argument of type " #type "\n", opt); \ fprintf(stderr, L"'-%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;
fwprintf(stderr, L"Unrecognized option '-%c'\n", argv[i][j]); fprintf(stderr, L"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;
fwprintf(stderr, L"Unrecognized option '%s'\n", argv[i]); fprintf(stderr, L"Unrecognized option '%s'\n", argv[i]);
} }
}else{ }else{
ret.filenames.push_back(argv[i]); ret.filenames.push_back(argv[i]);

View File

@ -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){
fwprintf(stderr, L"could not set up term\n"); fprintf(stderr, L"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
fwprintf(stderr, L"Unable to open file %s\n", args.filenames[i]); fprintf(stderr, L"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){
fwprintf(stderr, L"Try '%s --help' for more information.\n", argv[0]); fprintf(stderr, L"Try '%s --help' for more information.\n", argv[0]);
return 1; return 1;
} }