char oldFile[1024] = {0};
int oldLine = lineNum;
- rtrn = XkbFindFileInCache(stmt->file, file_type, &stmt->path);
- if (rtrn == NULL)
+ file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
+ if (file == NULL)
{
- /* file not in cache, open it, parse it and store it in cache for next
- time. */
- file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
- if (file == NULL)
- {
- ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
- XkbDirectoryForInclude(file_type));
- return False;
- }
- if (scanFile)
- strcpy(oldFile, scanFile);
- else
- memset(oldFile, 0, sizeof(oldFile));
- oldLine = lineNum;
- setScanState(stmt->file, 1);
- if (debugFlags & 2)
- INFO("About to parse include file %s\n", stmt->file);
- /* parse the file */
- if ((XKBParseFile(file, &rtrn) == 0) || (rtrn == NULL))
- {
- setScanState(oldFile, oldLine);
- ERROR("Error interpreting include file \"%s\"\n", stmt->file);
- fclose(file);
- return False;
- }
+ ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
+ XkbDirectoryForInclude(file_type));
+ return False;
+ }
+ if (scanFile)
+ strcpy(oldFile, scanFile);
+ else
+ memset(oldFile, 0, sizeof(oldFile));
+ oldLine = lineNum;
+ setScanState(stmt->file, 1);
+ if (debugFlags & 2)
+ INFO("About to parse include file %s\n", stmt->file);
+ /* parse the file */
+ if ((XKBParseFile(file, &rtrn) == 0) || (rtrn == NULL))
+ {
+ setScanState(oldFile, oldLine);
+ ERROR("Error interpreting include file \"%s\"\n", stmt->file);
fclose(file);
- XkbAddFileToCache(stmt->file, file_type, stmt->path, rtrn);
+ return False;
}
+ fclose(file);
+
mapToUse = rtrn;
if (stmt->map != NULL)
{
/***====================================================================***/
-typedef struct _FileCacheEntry
-{
- char *name;
- unsigned type;
- char *path;
- void *data;
- struct _FileCacheEntry *next;
-} FileCacheEntry;
-static FileCacheEntry *fileCache;
-
-/**
- * Add the file with the given name to the internal cache to avoid opening and
- * parsing the file multiple times. If a cache entry for the same name + type
- * is already present, the entry is overwritten and the data belonging to the
- * previous entry is returned.
- *
- * @parameter name The name of the file (e.g. evdev).
- * @parameter type Type of the file (XkbTypesIdx, ... or XkbSemanticsFile, ...)
- * @parameter path The full path to the file.
- * @parameter data Already parsed data.
- *
- * @return The data from the overwritten file or NULL.
- */
-void *
-XkbAddFileToCache(char *name, unsigned type, char *path, void *data)
-{
- FileCacheEntry *entry;
-
- for (entry = fileCache; entry != NULL; entry = entry->next)
- {
- if ((type == entry->type) && (uStringEqual(name, entry->name)))
- {
- void *old = entry->data;
- WSGO("Replacing file cache entry (%s/%d)\n", name, type);
- entry->path = path;
- entry->data = data;
- return old;
- }
- }
- entry = uTypedAlloc(FileCacheEntry);
- if (entry != NULL)
- {
- entry->name = name;
- entry->type = type;
- entry->path = path;
- entry->data = data;
- entry->next = fileCache;
- fileCache = entry;
- }
- return NULL;
-}
-
-/**
- * Search for the given name + type in the cache.
- *
- * @parameter name The name of the file (e.g. evdev).
- * @parameter type Type of the file (XkbTypesIdx, ... or XkbSemanticsFile, ...)
- * @parameter pathRtrn Set to the full path of the given entry.
- *
- * @return the data from the cache entry or NULL if no matching entry was found.
- */
-void *
-XkbFindFileInCache(char *name, unsigned type, char **pathRtrn)
-{
- FileCacheEntry *entry;
-
- for (entry = fileCache; entry != NULL; entry = entry->next)
- {
- if ((type == entry->type) && (uStringEqual(name, entry->name)))
- {
- *pathRtrn = entry->path;
- return entry->data;
- }
- }
- return NULL;
-}
-
-/***====================================================================***/
-
/**
* Search for the given file name in the include directories.
*
char ** /* pathRtrn */
);
-extern void *XkbAddFileToCache(char * /* name */ ,
- unsigned /* type */ ,
- char * /* path */ ,
- void * /* data */
- );
-
-extern void *XkbFindFileInCache(char * /* name */ ,
- unsigned /* type */ ,
- char ** /* pathRtrn */
- );
-
extern Bool XkbParseIncludeMap(char ** /* str_inout */ ,
char ** /* file_rtrn */ ,
char ** /* map_rtrn */ ,