diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2008-06-29 11:27:34 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2008-06-29 11:27:34 +0200 |
commit | 7c2a34949f56cc9bd1cf1a1295ee58041499730b (patch) | |
tree | ee0f844742687bce07cdb2ad519d4c2cacd70c49 /v4l2-apps/util | |
parent | 66e8b8c26461343c6a8d2824a7267dc8bdba97ac (diff) | |
download | mediapointer-dvb-s2-7c2a34949f56cc9bd1cf1a1295ee58041499730b.tar.gz mediapointer-dvb-s2-7c2a34949f56cc9bd1cf1a1295ee58041499730b.tar.bz2 |
v4l2-ctl: improve handling of control names with non-alnum chars
From: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'v4l2-apps/util')
-rw-r--r-- | v4l2-apps/util/v4l2-ctl.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index 8a9287418..57d98fc13 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -485,10 +485,16 @@ static void print_sliced_vbi_cap(struct v4l2_sliced_vbi_cap &cap) static std::string name2var(unsigned char *name) { std::string s; + int add_underscore = 0; while (*name) { - if (*name == ' ') s += "_"; - else s += std::string(1, tolower(*name)); + if (isalnum(*name)) { + if (add_underscore) + s += '_'; + add_underscore = 0; + s += std::string(1, tolower(*name)); + } + else if (s.length()) add_underscore = 1; name++; } return s; |