]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/name_match.c
ncurses 5.7 - patch 20090321
[ncurses.git] / ncurses / tinfo / name_match.c
index c8d728faa7c4bf1c650f1f4d4c371efee94a2de6..a9ac642788883011bbc12f252cfa90cc41a26324 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1999-2005,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2007,2008 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            *
  *                                                                          *
  * 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 <dickey@clark.net> 1999                        *
+ *  Author: Thomas E. Dickey                    1999-on                     *
  ****************************************************************************/
 
 #include <curses.priv.h>
  ****************************************************************************/
 
 #include <curses.priv.h>
-#include <term.h>
 #include <tic.h>
 
 #include <tic.h>
 
-MODULE_ID("$Id: name_match.c,v 1.16 2007/04/21 21:28:13 tom Exp $")
+MODULE_ID("$Id: name_match.c,v 1.18 2008/11/16 00:19:59 juergen Exp $")
 
 /*
  *     _nc_first_name(char *names)
 
 /*
  *     _nc_first_name(char *names)
@@ -53,18 +52,21 @@ _nc_first_name(const char *const sp)
     if (sp == 0) {
        if (FirstName != 0)
            FreeAndNull(FirstName);
     if (sp == 0) {
        if (FirstName != 0)
            FreeAndNull(FirstName);
-       return 0;
-    }
+    } else
 #endif
 #endif
+    {
+       if (FirstName == 0)
+           FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
 
 
-    if (FirstName == 0)
-       FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
-    for (n = 0; n < MAX_NAME_SIZE; n++) {
-       if ((FirstName[n] = sp[n]) == '\0'
-           || (FirstName[n] == '|'))
-           break;
+       if (FirstName != 0) {
+           for (n = 0; n < MAX_NAME_SIZE; n++) {
+               if ((FirstName[n] = sp[n]) == '\0'
+                   || (FirstName[n] == '|'))
+                   break;
+           }
+           FirstName[n] = '\0';
+       }
     }
     }
-    FirstName[n] = '\0';
     return (FirstName);
 }
 
     return (FirstName);
 }