Commit a45f531aa75676052f05e4cf2a2a1fae527a8416

Ran Benita 2013-10-09T12:12:59

keymap: call strlen on keymap string instead of SIZE_MAX I wanted to avoid the strlen, but we'd better keep the scanner a bit less surprising and encourage people to use xkb_keymap_new_from_buffer() instead of they do in fact have access to the size. Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/keymap.c b/src/keymap.c
index 4cb01c6..52d66f6 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -218,7 +218,8 @@ xkb_keymap_new_from_string(struct xkb_context *ctx,
                            enum xkb_keymap_format format,
                            enum xkb_keymap_compile_flags flags)
 {
-    return xkb_keymap_new_from_buffer(ctx, string, SIZE_MAX, format, flags);
+    return xkb_keymap_new_from_buffer(ctx, string, strlen(string),
+                                      format, flags);
 }
 
 XKB_EXPORT struct xkb_keymap *
diff --git a/src/xkbcomp/scanner-utils.h b/src/xkbcomp/scanner-utils.h
index 04783ac..350be66 100644
--- a/src/xkbcomp/scanner-utils.h
+++ b/src/xkbcomp/scanner-utils.h
@@ -80,7 +80,7 @@ peek(struct scanner *s)
 static inline bool
 eof(struct scanner *s)
 {
-    return peek(s) == '\0';
+    return s->pos >= s->len;
 }
 
 static inline bool