Constify some more text functions
authorRan Benita <ran234@gmail.com>
Fri, 2 Mar 2012 20:31:29 +0000 (22:31 +0200)
committerRan Benita <ran234@gmail.com>
Fri, 2 Mar 2012 23:17:57 +0000 (01:17 +0200)
Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/compat.c
src/xkbcomp/expr.c
src/xkbcomp/expr.h
src/xkbcomp/xkbpath.c
src/xkbcomp/xkbpath.h

index e535248..eb153ff 100644 (file)
@@ -80,7 +80,7 @@ typedef struct _CompatInfo
 
 /***====================================================================***/
 
-static char *
+static const char *
 siText(SymInterpInfo * si, CompatInfo * info)
 {
     static char buf[128];
index f682186..5f1a2b8 100644 (file)
@@ -41,7 +41,7 @@ typedef Bool(*IdentLookupFunc) (const void * /* priv */ ,
 
 /***====================================================================***/
 
-char *
+const char *
 exprOpText(unsigned type)
 {
     static char buf[32];
@@ -103,7 +103,7 @@ exprOpText(unsigned type)
     return buf;
 }
 
-static char *
+static const char *
 exprTypeText(unsigned type)
 {
     static char buf[20];
index 00eaf02..921516b 100644 (file)
@@ -48,7 +48,7 @@ typedef struct _LookupEntry
 } LookupEntry;
 
 
-extern char *exprOpText(unsigned        /* type */
+extern const char *exprOpText(unsigned        /* type */
     );
 
 extern int LookupModMask(const void * /* priv */ ,
index c8e7578..1b04a7c 100644 (file)
@@ -262,48 +262,34 @@ XkbAddDefaultDirectoriesToPath(void)
 
 /**
  * Return the xkb directory based on the type.
- * Do not free the memory returned by this function.
  */
-char *
+const char *
 XkbDirectoryForInclude(unsigned type)
 {
-    static char buf[32];
-
     switch (type)
     {
     case XkmSemanticsFile:
-        strcpy(buf, "semantics");
-        break;
+        return "semantics";
     case XkmLayoutFile:
-        strcpy(buf, "layout");
-        break;
+        return "layout";
     case XkmKeymapFile:
-        strcpy(buf, "keymap");
-        break;
+        return "keymap";
     case XkmKeyNamesIndex:
-        strcpy(buf, "keycodes");
-        break;
+        return "keycodes";
     case XkmTypesIndex:
-        strcpy(buf, "types");
-        break;
+        return "types";
     case XkmSymbolsIndex:
-        strcpy(buf, "symbols");
-        break;
+        return "symbols";
     case XkmCompatMapIndex:
-        strcpy(buf, "compat");
-        break;
+        return "compat";
     case XkmGeometryFile:
     case XkmGeometryIndex:
-        strcpy(buf, "geometry");
-        break;
+        return "geometry";
     case XkmRulesFile:
-        strcpy(buf, "rules");
-        break;
+        return "rules";
     default:
-        strcpy(buf, "");
-        break;
+        return "";
     }
-    return buf;
 }
 
 /***====================================================================***/
@@ -403,7 +389,8 @@ XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
     int i;
     FILE *file = NULL;
     int nameLen, typeLen, pathLen;
-    char buf[PATH_MAX], *typeDir;
+    char buf[PATH_MAX];
+    const char *typeDir;
 
     if (!XkbInitIncludePath())
         return NULL;
index f527d19..eef1fb2 100644 (file)
@@ -31,7 +31,7 @@
 #include <X11/X.h>
 #include <X11/Xdefs.h>
 
-extern char *XkbDirectoryForInclude(unsigned    /* type */
+extern const char *XkbDirectoryForInclude(unsigned    /* type */
     );
 
 extern FILE *XkbFindFileInPath(const char * /* name */ ,