]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/home_terminfo.c
ncurses 5.5
[ncurses.git] / ncurses / tinfo / home_terminfo.c
index 7aa4ca112e5ad51a56ace2c7caed0f740edd5f1d..ce6576a82f822358181f5de679fb3d1e13f7185f 100644 (file)
@@ -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 <dickey@clark.net> 1998                        *
+ *  Author: Thomas E. Dickey 1998,2000,2004,2005                            *
  ****************************************************************************/
 
 /*
 #include <curses.priv.h>
 #include <tic.h>
 
-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;
 }