projects
/
platform
/
upstream
/
libxkbcommon.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bc3b4c0
)
scanner-utils: add helper for hex string escape
author
Ran Benita
<ran234@gmail.com>
Sun, 27 Oct 2013 18:17:29 +0000
(20:17 +0200)
committer
Ran Benita
<ran234@gmail.com>
Thu, 2 Oct 2014 19:21:06 +0000
(22:21 +0300)
Like the already existing oct.
Signed-off-by: Ran Benita <ran234@gmail.com>
src/scanner-utils.h
patch
|
blob
|
history
diff --git
a/src/scanner-utils.h
b/src/scanner-utils.h
index
fc231ab
..
57c5ec5
100644
(file)
--- a/
src/scanner-utils.h
+++ b/
src/scanner-utils.h
@@
-156,4
+156,17
@@
oct(struct scanner *s, uint8_t *out)
return i > 0;
}
+static inline bool
+hex(struct scanner *s, uint8_t *out)
+{
+ int i;
+ for (i = 0, *out = 0; is_xdigit(peek(s)) && i < 2; i++) {
+ const char c = next(s);
+ const char offset = (c >= '0' && c <= '9' ? '0' :
+ c >= 'a' && c <= 'f' ? 'a' - 10 : 'A' - 10);
+ *out = *out * 16 + c - offset;
+ }
+ return i > 0;
+}
+
#endif