keymap: call strlen on keymap string instead of SIZE_MAX
authorRan Benita <ran234@gmail.com>
Wed, 9 Oct 2013 09:12:59 +0000 (12:12 +0300)
committerRan Benita <ran234@gmail.com>
Thu, 10 Oct 2013 19:02:30 +0000 (22:02 +0300)
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>
src/keymap.c
src/xkbcomp/scanner-utils.h

index 4cb01c6..52d66f6 100644 (file)
@@ -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 *
index 04783ac..350be66 100644 (file)
@@ -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