[augeas-devel] [PATCH] Module names are treated case-insensitively

David Lutterkort dlutter at redhat.com
Wed Aug 13 22:45:03 UTC 2008


2 files changed, 3 insertions(+), 2 deletions(-)
src/internal.h |    1 +
src/syntax.c   |    4 ++--


# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1218667497 25200
# Node ID f779b26fdb919ff6ae777eb09a364664e3fb93e4
# Parent  0318a38c20a5ee61391b75bd194e7d1b34d7da98
Module names are treated case-insensitively

Before, if you had a module 'Mod' in file 'mod.aug' and requested variable
'MoD.var' from another module, the interpreter would throw itself into a
loop where it kept loading 'mod.aug', but never found 'MoD.var' because the
comparison of module names 'MoD' and 'Mod' was case sensitive.

diff -r 0318a38c20a5 -r f779b26fdb91 src/internal.h
--- a/src/internal.h	Wed Aug 13 15:41:28 2008 -0700
+++ b/src/internal.h	Wed Aug 13 15:44:57 2008 -0700
@@ -121,6 +121,7 @@
 /* String equality tests, suggested by Jim Meyering. */
 #define STREQ(a,b) (strcmp((a),(b)) == 0)
 #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
+#define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
 #define STRNEQ(a,b) (strcmp((a),(b)) != 0)
 #define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
 #define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
diff -r 0318a38c20a5 -r f779b26fdb91 src/syntax.c
--- a/src/syntax.c	Wed Aug 13 15:41:28 2008 -0700
+++ b/src/syntax.c	Wed Aug 13 15:44:57 2008 -0700
@@ -456,7 +456,7 @@
 
 static struct module *module_find(struct module *module, const char *name) {
     list_for_each(e, module) {
-        if (STREQ(e->name, name))
+        if (STRCASEEQ(e->name, name))
             return e;
     }
     return NULL;
@@ -487,7 +487,7 @@
         if (dot != NULL) {
         qual_lookup:
             list_for_each(module, ctx->aug->modules) {
-                if (STREQLEN(module->name, name, strlen(module->name))
+                if (STRCASEEQLEN(module->name, name, strlen(module->name))
                     && dot - name == strlen(module->name))
                     return bnd_lookup(module->bindings, dot + 1);
             }




More information about the augeas-devel mailing list