X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fhome_terminfo.c;h=92c26705a016fb2b7ebaf12a7fbc4f9fac82f3c1;hp=69b8a96ffcff745a0ce855cf1a54b7869b63312d;hb=7a27c7d49c2e8b4a1ecbe85b4423d647cbc75ea5;hpb=c633e5103a29a38532cf1925257b91cea33fd090;ds=sidebyside diff --git a/ncurses/tinfo/home_terminfo.c b/ncurses/tinfo/home_terminfo.c index 69b8a96f..92c26705 100644 --- a/ncurses/tinfo/home_terminfo.c +++ b/ncurses/tinfo/home_terminfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2007 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,2000 * + * Author: Thomas E. Dickey * ****************************************************************************/ /* @@ -37,29 +37,33 @@ #include #include -MODULE_ID("$Id: home_terminfo.c,v 1.3 2000/10/04 02:31:53 tom Exp $"); +MODULE_ID("$Id: home_terminfo.c,v 1.10 2007/04/21 23:11:53 tom Exp $") #define my_length (strlen(home) + sizeof(PRIVATE_INFO)) /* ncurses extension...fall back on user's private directory */ -char * +#define MyBuffer _nc_globals.home_terminfo + +NCURSES_EXPORT(char *) _nc_home_terminfo(void) { + char *result = 0; +#if USE_HOME_TERMINFO char *home; - static char *temp = 0; if (use_terminfo_vars()) { - if (temp == 0) { + if (MyBuffer == 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); + MyBuffer = typeMalloc(char, my_length); + if (MyBuffer == 0) + _nc_err_abort(MSG_NO_MEMORY); + (void) sprintf(MyBuffer, PRIVATE_INFO, home); } } - return temp; + result = MyBuffer; } - return 0; +#endif + return result; }