summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2020-06-18 05:28:50 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2020-06-18 05:28:50 +0000
commit11b7ba943c908b291d86e537b9c5ac52999e094b (patch)
treecdb90aa21c1a8ad760f218445cf6a2ab8ac01b54
parent24f535829162c70be3822863490dcbabdd5d0289 (diff)
Allow names to start with digits or underscores
-rw-r--r--usr.bin/sndioctl/sndioctl.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/usr.bin/sndioctl/sndioctl.c b/usr.bin/sndioctl/sndioctl.c
index d04cbeb925d..44579dc423a 100644
--- a/usr.bin/sndioctl/sndioctl.c
+++ b/usr.bin/sndioctl/sndioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndioctl.c,v 1.11 2020/05/25 09:14:50 mestre Exp $ */
+/* $OpenBSD: sndioctl.c,v 1.12 2020/06/18 05:28:49 ratchov Exp $ */
/*
* Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org>
*
@@ -69,15 +69,11 @@ struct info *infolist;
int i_flag = 0, v_flag = 0, m_flag = 0, n_flag = 0, q_flag = 0;
static inline int
-isname_first(int c)
+isname(int c)
{
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
-}
-
-static inline int
-isname_next(int c)
-{
- return isname_first(c) || (c >= '0' && c <= '9') || (c == '_');
+ return (c == '_') ||
+ (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9');
}
static int
@@ -481,11 +477,11 @@ parse_name(char **line, char *name)
char *p = *line;
unsigned len = 0;
- if (!isname_first(*p)) {
- fprintf(stderr, "letter expected near '%s'\n", p);
+ if (!isname(*p)) {
+ fprintf(stderr, "letter or digit expected near '%s'\n", p);
return 0;
}
- while (isname_next(*p)) {
+ while (isname(*p)) {
if (len >= SIOCTL_NAMEMAX - 1) {
name[SIOCTL_NAMEMAX - 1] = '\0';
fprintf(stderr, "%s...: too long\n", name);