Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4631d532e0 | ||
|
|
f0247ac9c5 | ||
|
|
adea8f719e | ||
|
|
c25594ccda | ||
|
|
138c20ba28 | ||
|
|
8c561778ee |
@@ -8,12 +8,16 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
find_package(Curses REQUIRED)
|
||||
find_library(TINFO_LIBRARY tinfo)
|
||||
if(NOT TINFO_LIBRARY)
|
||||
set(TINFO_LIBRARY "")
|
||||
endif()
|
||||
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
add_executable (roflcat src/roflcat.cpp src/cmd.cpp)
|
||||
target_include_directories(roflcat PUBLIC ${INCLUDE_PATH})
|
||||
target_include_directories(roflcat PUBLIC ${CURSES_INCLUDE_DIRS})
|
||||
target_link_libraries(roflcat PRIVATE ${CURSES_LIBRARIES})
|
||||
target_include_directories(roflcat PUBLIC ${CURSES_INCLUDE_DIRS} ${TINFO_INCLUDE_DIRS})
|
||||
target_link_libraries(roflcat PRIVATE ${CURSES_LIBRARIES} ${TINFO_LIBRARY})
|
||||
install(TARGETS roflcat RUNTIME DESTINATION bin)
|
||||
|
||||
#uninstall target
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user