mirror of https://github.com/ericonr/sndio.git
Allow digits in control names
This commit is contained in:
parent
1bfe9a4f39
commit
92cc5b7bba
|
@ -22,10 +22,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sndio.h>
|
#include <sndio.h>
|
||||||
|
|
||||||
#define IS_IDENT(c) (((c) >= 'a' && (c) <= 'z') || \
|
|
||||||
((c) >= 'A' && (c) <= 'Z') || \
|
|
||||||
((c) == '_'))
|
|
||||||
|
|
||||||
struct info {
|
struct info {
|
||||||
struct info *next;
|
struct info *next;
|
||||||
struct sioctl_desc desc;
|
struct sioctl_desc desc;
|
||||||
|
@ -69,6 +65,18 @@ struct sioctl_hdl *hdl;
|
||||||
struct info *infolist;
|
struct info *infolist;
|
||||||
int i_flag = 0, v_flag = 0, m_flag = 0;
|
int i_flag = 0, v_flag = 0, m_flag = 0;
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
isname_first(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 == '_');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* compare two sioctl_desc structures, used to sort infolist
|
* compare two sioctl_desc structures, used to sort infolist
|
||||||
*/
|
*/
|
||||||
|
@ -410,11 +418,11 @@ parse_name(char **line, char *name)
|
||||||
char *p = *line;
|
char *p = *line;
|
||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
|
|
||||||
if (!IS_IDENT(*p)) {
|
if (!isname_first(*p)) {
|
||||||
fprintf(stderr, "letter expected near '%s'\n", p);
|
fprintf(stderr, "letter expected near '%s'\n", p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
while (IS_IDENT(*p)) {
|
while (isname_next(*p)) {
|
||||||
if (len >= SIOCTL_NAMEMAX - 1) {
|
if (len >= SIOCTL_NAMEMAX - 1) {
|
||||||
name[SIOCTL_NAMEMAX - 1] = '\0';
|
name[SIOCTL_NAMEMAX - 1] = '\0';
|
||||||
fprintf(stderr, "%s...: too long\n", name);
|
fprintf(stderr, "%s...: too long\n", name);
|
||||||
|
|
Loading…
Reference in New Issue