-/* $OpenBSD: cmd.c,v 1.138 2021/08/12 12:31:16 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.139 2021/08/15 13:45:42 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
do {
printf("%s [%d - %d]: [%d] ", str, low, high, dflt);
-
- if (string_from_line(lbuf, sizeof(lbuf)))
- errx(1, "eof");
+ string_from_line(lbuf, sizeof(lbuf));
if (lbuf[0] == '\0') {
num = dflt;
do {
printf("Partition id ('0' to disable) [01 - FF]: [%X] ", dflt);
printf("(? for help) ");
-
- if (string_from_line(lbuf, sizeof(lbuf)))
- errx(1, "eof");
+ string_from_line(lbuf, sizeof(lbuf));
if (lbuf[0] == '?') {
PRT_printall();
buf[0] = '\0';
printf("%s: [%s] ", prompt, oval ? oval : "");
- if (string_from_line(buf, sizeof(buf)))
- errx(1, "eof");
+ string_from_line(buf, sizeof(buf));
if (buf[0] == '\0' && oval)
strlcpy(buf, oval, sizeof(buf));
-/* $OpenBSD: misc.c,v 1.79 2021/08/07 13:33:12 krw Exp $ */
+/* $OpenBSD: misc.c,v 1.80 2021/08/15 13:45:42 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
return i;
}
-int
+void
string_from_line(char *buf, const size_t buflen)
{
static char *line;
len = getline(&line, &sz, stdin);
if (len == -1)
- return -1;
+ errx(1, "eof");
- if (line[len - 1] == '\n')
- line[len - 1] = '\0';
+ line[strcspn(line, "\n")] = '\0';
strlcpy(buf, line, buflen);
-
- return 0;
}
int
do {
printf("%s [%llu - %llu]: [%llu] ", prompt, minval, maxval,
oval);
-
- if (string_from_line(buf, sizeof(buf)))
- errx(1, "eof");
+ string_from_line(buf, sizeof(buf));
if (buf[0] == '\0') {
rslt = snprintf(buf, sizeof(buf), "%llu", oval);
-/* $OpenBSD: misc.h,v 1.40 2021/08/12 12:31:16 krw Exp $ */
+/* $OpenBSD: misc.h,v 1.41 2021/08/15 13:45:42 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
/* Prototypes */
int unit_lookup(const char *);
-int string_from_line(char *, const size_t);
+void string_from_line(char *, const size_t);
int ask_yn(const char *);
uint64_t getuint64(const char *, uint64_t, const uint64_t, const uint64_t);
char *utf16le_to_string(const uint16_t *);
-/* $OpenBSD: user.c,v 1.72 2021/08/12 17:30:52 krw Exp $ */
+/* $OpenBSD: user.c,v 1.73 2021/08/15 13:45:42 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
static char lbuf[100];
size_t cmdstart, cmdend, argstart;
- if (string_from_line(lbuf, sizeof(lbuf)))
- errx(1, "eof");
+ string_from_line(lbuf, sizeof(lbuf));
cmdstart = strspn(lbuf, " \t");
cmdend = cmdstart + strcspn(&lbuf[cmdstart], " \t");