From d2c3dd0c21a0cec43fba74c81ccbf75794b03c86 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 2 Mar 2012 22:31:29 +0200 Subject: [PATCH] Constify some more text functions Signed-off-by: Ran Benita --- src/xkbcomp/compat.c | 2 +- src/xkbcomp/expr.c | 4 ++-- src/xkbcomp/expr.h | 2 +- src/xkbcomp/xkbpath.c | 39 +++++++++++++-------------------------- src/xkbcomp/xkbpath.h | 2 +- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index e535248..eb153ff 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -80,7 +80,7 @@ typedef struct _CompatInfo /***====================================================================***/ -static char * +static const char * siText(SymInterpInfo * si, CompatInfo * info) { static char buf[128]; diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index f682186..5f1a2b8 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -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]; diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h index 00eaf02..921516b 100644 --- a/src/xkbcomp/expr.h +++ b/src/xkbcomp/expr.h @@ -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 */ , diff --git a/src/xkbcomp/xkbpath.c b/src/xkbcomp/xkbpath.c index c8e7578..1b04a7c 100644 --- a/src/xkbcomp/xkbpath.c +++ b/src/xkbcomp/xkbpath.c @@ -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; diff --git a/src/xkbcomp/xkbpath.h b/src/xkbcomp/xkbpath.h index f527d19..eef1fb2 100644 --- a/src/xkbcomp/xkbpath.h +++ b/src/xkbcomp/xkbpath.h @@ -31,7 +31,7 @@ #include #include -extern char *XkbDirectoryForInclude(unsigned /* type */ +extern const char *XkbDirectoryForInclude(unsigned /* type */ ); extern FILE *XkbFindFileInPath(const char * /* name */ , -- 2.7.4