X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fadd_tries.c;h=d41f488300ae3f799d2eab7e69f397e6073ca5df;hp=fb6dd5c53befb68d311d4ebccd01dd63e5d41424;hb=790a85dbd4a81d5f5d8dd02a44d84f01512ef443;hpb=3a0d9d27e0cf115ff9dcc6163c251bccaa62bd7d diff --git a/ncurses/tinfo/add_tries.c b/ncurses/tinfo/add_tries.c index fb6dd5c5..d41f4883 100644 --- a/ncurses/tinfo/add_tries.c +++ b/ncurses/tinfo/add_tries.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc. * + * Copyright 2019,2020 Thomas E. Dickey * + * Copyright 1998-2009,2010 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 +40,7 @@ #include -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.12 2020/02/02 23:34:34 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 +68,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 +110,7 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code) savedptr = ptr->child; free(ptr); } + *tree = NULL; returnCode(ERR); } @@ -116,6 +118,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); }