fprintf(stderr,
"replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ",
*path);
- if (fgets(buf, sizeof(buf), stdin) == NULL) {
- clearerr(stdin);
- printf("NULL\n(EOF or read error, "
- "treating as \"[N]one\"...)\n");
- n_opt = 1;
- return -1;
- }
+ if (fgets(buf, sizeof(buf), stdin) == NULL)
+ goto stdin_err;
switch (*buf) {
case 'A':
o_opt = 1;
*path = NULL;
alen = 0;
len = getline(path, &alen, stdin);
+ if (len < 1)
+ goto stdin_err;
if ((*path)[len - 1] == '\n')
(*path)[len - 1] = '\0';
return 0;
break;
}
}
+stdin_err:
+ clearerr(stdin);
+ printf("NULL\n(EOF or read error, "
+ "treating as \"[N]one\"...)\n");
+ n_opt = 1;
+ return -1;
}
/*