Fix stdin bug
This commit is contained in:
parent
f1de0cfb8b
commit
03d4f4fddf
@ -4,7 +4,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define LAT_USAGE "usage: lat [cnVh] [files..]"
|
#define LAT_USAGE "usage: lat [-cnVh] [files..]"
|
||||||
|
|
||||||
void help(void) {
|
void help(void) {
|
||||||
printf("%s\n", LAT_USAGE);
|
printf("%s\n", LAT_USAGE);
|
||||||
@ -89,7 +89,7 @@ int parseargs(int argc, char *argv[]) {
|
|||||||
for (i = 1; i < argc; i++) { // offset for argv[0]
|
for (i = 1; i < argc; i++) { // offset for argv[0]
|
||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
|
|
||||||
if (*arg == '-') {
|
if (arg[0] == '-' && arg[1] == '\0') {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void initconf(void) {
|
|||||||
conf.has_read_stdin = false;
|
conf.has_read_stdin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearstdin() {
|
void clearstdin(void) {
|
||||||
// from
|
// from
|
||||||
// https://stackoverflow.com/questions/7898215/how-to-clear-input-buffer-in-c
|
// https://stackoverflow.com/questions/7898215/how-to-clear-input-buffer-in-c
|
||||||
fseek(stdin, 0, SEEK_END);
|
fseek(stdin, 0, SEEK_END);
|
||||||
|
Loading…
Reference in New Issue
Block a user