]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/add_tries.c
ncurses 6.1 - patch 20200118
[ncurses.git] / ncurses / tinfo / add_tries.c
index fb6dd5c53befb68d311d4ebccd01dd63e5d41424..f9a4cce680a27a5215522fa9fe3712bb91d9308f 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2010,2019 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            *
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: add_tries.c,v 1.9 2009/10/24 22:41:36 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.11 2019/07/27 22:59:11 tom Exp $")
 
 #define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
 #define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
@@ -67,7 +67,7 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
 
            if (CMP_TRY(ptr->ch, cmp)) {
                if (*(++txt) == '\0') {
-                   ptr->value = code;
+                   ptr->value = (unsigned short) code;
                    returnCode(OK);
                }
                if (ptr->child != 0)
@@ -109,6 +109,7 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
                savedptr = ptr->child;
                free(ptr);
            }
+           *tree = NULL;
            returnCode(ERR);
        }
 
@@ -116,6 +117,6 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
        ptr->value = 0;
     }
 
-    ptr->value = code;
+    ptr->value = (unsigned short) code;
     returnCode(OK);
 }