]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_longname.c
ncurses 5.7 - patch 20100130
[ncurses.git] / ncurses / tinfo / lib_longname.c
index 746f83f4eabf6cc3edbf93783815d370e1ec8d44..2164a126ca8b95a3395db56f2e2e6cfb81595205 100644 (file)
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_longname.c,v 1.10 2009/02/15 00:48:15 tom Exp $")
+MODULE_ID("$Id: lib_longname.c,v 1.11 2009/02/21 17:18:02 tom Exp $")
 
+#if USE_REENTRANT
 NCURSES_EXPORT(char *)
 NCURSES_SP_NAME(longname) (NCURSES_SP_DCL0)
 {
+    static char empty[] =
+    {'\0'};
     char *ptr;
 
-    T((T_CALLED("longname()")));
+    T((T_CALLED("longname(%p)"), SP_PARM));
 
-    for (ptr = ttytype + strlen(ttytype); ptr > ttytype; ptr--)
-       if (*ptr == '|')
-           returnPtr(ptr + 1);
-
-    returnPtr(ttytype);
+    if (SP_PARM) {
+       for (ptr = SP_PARM->_ttytype + strlen(SP_PARM->_ttytype);
+            ptr > SP_PARM->_ttytype;
+            ptr--)
+           if (*ptr == '|')
+               returnPtr(ptr + 1);
+       returnPtr(SP_PARM->_ttytype);
+    }
+    return empty;
 }
 
 #if NCURSES_SP_FUNCS
@@ -65,3 +72,20 @@ longname(void)
     return NCURSES_SP_NAME(longname) (CURRENT_SCREEN);
 }
 #endif
+
+#else
+NCURSES_EXPORT(char *)
+longname(void)
+{
+    char *ptr;
+
+    T((T_CALLED("longname()")));
+
+    for (ptr = ttytype + strlen(ttytype);
+        ptr > ttytype;
+        ptr--)
+       if (*ptr == '|')
+           returnPtr(ptr + 1);
+    returnPtr(ttytype);
+}
+#endif