X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fhome_terminfo.c;h=ce6576a82f822358181f5de679fb3d1e13f7185f;hp=7aa4ca112e5ad51a56ace2c7caed0f740edd5f1d;hb=0be808514502f3149b379d036ab3a83cbb4d4c02;hpb=0eb88fc5281804773e2a0c7a488a4452463535ce diff --git a/ncurses/tinfo/home_terminfo.c b/ncurses/tinfo/home_terminfo.c index 7aa4ca11..ce6576a8 100644 --- a/ncurses/tinfo/home_terminfo.c +++ b/ncurses/tinfo/home_terminfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998-2004,2005 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 * @@ -27,7 +27,7 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 1998 * + * Author: Thomas E. Dickey 1998,2000,2004,2005 * ****************************************************************************/ /* @@ -37,26 +37,32 @@ #include #include -MODULE_ID("$Id: home_terminfo.c,v 1.2 1999/02/27 19:58:46 tom Exp $") +MODULE_ID("$Id: home_terminfo.c,v 1.9 2005/07/02 19:43:38 tom Exp $") #define my_length (strlen(home) + sizeof(PRIVATE_INFO)) /* ncurses extension...fall back on user's private directory */ -char * +NCURSES_EXPORT(char *) _nc_home_terminfo(void) { - char *home; - static char *temp = 0; + char *result = 0; +#ifdef USE_HOME_TERMINFO + char *home; + static char *temp = 0; + if (use_terminfo_vars()) { if (temp == 0) { - if ((home = getenv("HOME")) != 0 - && my_length <= PATH_MAX) { - temp = typeMalloc(char, my_length); - if (temp == 0) - _nc_err_abort("Out of memory"); - (void) sprintf(temp, PRIVATE_INFO, home); - } + if ((home = getenv("HOME")) != 0 + && my_length <= PATH_MAX) { + temp = typeMalloc(char, my_length); + if (temp == 0) + _nc_err_abort(MSG_NO_MEMORY); + (void) sprintf(temp, PRIVATE_INFO, home); + } } - return temp; + result = temp; + } +#endif + return result; }