/****************************************************************************
- * Copyright (c) 2006 Free Software Foundation, Inc. *
+ * Copyright (c) 2006-2007,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 2006 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
/*
#include <tic.h>
-MODULE_ID("$Id: db_iterator.c,v 1.5 2006/12/16 19:06:42 tom Exp $")
+MODULE_ID("$Id: db_iterator.c,v 1.8 2010/06/05 22:20:04 tom Exp $")
-static bool have_tic_directory = FALSE;
-static bool keep_tic_directory = FALSE;
+#define HaveTicDirectory _nc_globals.have_tic_directory
+#define KeepTicDirectory _nc_globals.keep_tic_directory
+#define TicDirectory _nc_globals.tic_directory
/*
* Record the "official" location of the terminfo directory, according to
NCURSES_EXPORT(const char *)
_nc_tic_dir(const char *path)
{
- static const char *result = TERMINFO;
-
- if (!keep_tic_directory) {
+ if (!KeepTicDirectory) {
if (path != 0) {
- result = path;
- have_tic_directory = TRUE;
- } else if (!have_tic_directory && use_terminfo_vars()) {
+ TicDirectory = path;
+ HaveTicDirectory = TRUE;
+ } else if (!HaveTicDirectory && use_terminfo_vars()) {
char *envp;
if ((envp = getenv("TERMINFO")) != 0)
return _nc_tic_dir(envp);
}
}
- return result;
+ return TicDirectory;
}
/*
_nc_keep_tic_dir(const char *path)
{
_nc_tic_dir(path);
- keep_tic_directory = TRUE;
+ KeepTicDirectory = TRUE;
}
/*
* Process the list of :-separated directories, looking for the terminal type.
* We don't use strtok because it does not show us empty tokens.
*/
-
-static char *this_db_list = 0;
-static int size_db_list;
+#define ThisDbList _nc_globals.dbi_list
+#define ThisDbSize _nc_globals.dbi_size
/*
* Cleanup.
NCURSES_EXPORT(void)
_nc_last_db(void)
{
- if (this_db_list != 0) {
- FreeAndNull(this_db_list);
+ if (ThisDbList != 0) {
+ FreeAndNull(ThisDbList);
}
- size_db_list = 0;
+ ThisDbSize = 0;
}
/* The TERMINFO_DIRS value, if defined by the configure script, begins with a
next_list_item(const char *source, int *offset)
{
if (source != 0) {
- FreeIfNeeded(this_db_list);
- this_db_list = strdup(source);
- size_db_list = strlen(source);
+ FreeIfNeeded(ThisDbList);
+ ThisDbList = strdup(source);
+ ThisDbSize = (int) strlen(source);
}
- if (this_db_list != 0 && size_db_list && *offset < size_db_list) {
+ if (ThisDbList != 0 && ThisDbSize && *offset < ThisDbSize) {
static char system_db[] = TERMINFO;
- char *result = this_db_list + *offset;
+ char *result = ThisDbList + *offset;
char *marker = strchr(result, NCURSES_PATHSEP);
/*
* again, using the data at the offset.
*/
if (marker == 0) {
- *offset += strlen(result) + 1;
- marker = result + *offset;
+ *offset += (int) strlen(result);
} else {
*marker++ = 0;
- *offset = marker - this_db_list;
+ *offset = marker - ThisDbList;
}
- if (*result == 0 && result != (this_db_list + size_db_list))
+ if (*result == 0 && result != (ThisDbList + ThisDbSize))
result = system_db;
return result;
}
switch (*state) {
case dbdTIC:
- if (have_tic_directory)
+ if (HaveTicDirectory)
result = _nc_tic_dir(0);
break;
#if USE_DATABASE