diff options
author | 2010-01-12 23:21:58 +0000 | |
---|---|---|
committer | 2010-01-12 23:21:58 +0000 | |
commit | 81d8c4e1e65ef590376b5b08744af794c42bd575 (patch) | |
tree | 7699ed6e10b41563ce3a6734235390cce070489c /lib/libmenu/m_pattern.c | |
parent | save errno wrapping in a signal handler (diff) | |
download | wireguard-openbsd-81d8c4e1e65ef590376b5b08744af794c42bd575.tar.xz wireguard-openbsd-81d8c4e1e65ef590376b5b08744af794c42bd575.zip |
Update to ncurses 5.7, with local changes reapplied.
This is around eight years worth of changes (previously we were around ncurses
5.2), too many to list - many bug fixes and also a few new functions.
A major bump for libcurses, libpanel, libform and libmenu.
ok deraadt
Diffstat (limited to 'lib/libmenu/m_pattern.c')
-rw-r--r-- | lib/libmenu/m_pattern.c | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/lib/libmenu/m_pattern.c b/lib/libmenu/m_pattern.c index f750c02aae3..88ae225339b 100644 --- a/lib/libmenu/m_pattern.c +++ b/lib/libmenu/m_pattern.c @@ -1,7 +1,7 @@ -/* $OpenBSD: m_pattern.c,v 1.4 2001/01/22 18:02:05 millert Exp $ */ +/* $OpenBSD: m_pattern.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2006 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 * @@ -29,7 +29,7 @@ ****************************************************************************/ /**************************************************************************** - * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 * + * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ /*************************************************************************** @@ -39,7 +39,7 @@ #include "menu.priv.h" -MODULE_ID("$From: m_pattern.c,v 1.6 2000/12/10 02:16:48 tom Exp $") +MODULE_ID("$Id: m_pattern.c,v 1.5 2010/01/12 23:22:08 nicm Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -53,9 +53,12 @@ MODULE_ID("$From: m_pattern.c,v 1.6 2000/12/10 02:16:48 tom Exp $") | PatternString - as expected +--------------------------------------------------------------------------*/ NCURSES_EXPORT(char *) -menu_pattern (const MENU * menu) +menu_pattern(const MENU * menu) { - return (menu ? (menu->pattern ? menu->pattern : "") : (char *)0); + static char empty[] = ""; + + T((T_CALLED("menu_pattern(%p)"), menu)); + returnPtr(menu ? (menu->pattern ? menu->pattern : empty) : 0); } /*--------------------------------------------------------------------------- @@ -67,54 +70,56 @@ menu_pattern (const MENU * menu) | | Return Values : E_OK - success | E_BAD_ARGUMENT - invalid menu or pattern pointer -| E_NOT_CONNECTED - no items connected to menu | E_BAD_STATE - menu in user hook routine +| E_NOT_CONNECTED - no items connected to menu | E_NO_MATCH - no item matches pattern +--------------------------------------------------------------------------*/ NCURSES_EXPORT(int) -set_menu_pattern (MENU *menu, const char *p) +set_menu_pattern(MENU * menu, const char *p) { ITEM *matchitem; - int matchpos; - - if (!menu || !p) + int matchpos; + + T((T_CALLED("set_menu_pattern(%p,%s)"), menu, _nc_visbuf(p))); + + if (!menu || !p) RETURN(E_BAD_ARGUMENT); - + if (!(menu->items)) RETURN(E_NOT_CONNECTED); - - if ( menu->status & _IN_DRIVER ) + + if (menu->status & _IN_DRIVER) RETURN(E_BAD_STATE); - + Reset_Pattern(menu); - + if (!(*p)) { pos_menu_cursor(menu); RETURN(E_OK); } - - if (menu->status & _LINK_NEEDED) + + if (menu->status & _LINK_NEEDED) _nc_Link_Items(menu); - - matchpos = menu->toprow; + + matchpos = menu->toprow; matchitem = menu->curitem; assert(matchitem); - - while(*p) + + while (*p) { - if ( !isprint((unsigned char)(*p)) || - (_nc_Match_Next_Character_In_Item_Name(menu,*p,&matchitem) != E_OK) ) + if (!isprint(UChar(*p)) || + (_nc_Match_Next_Character_In_Item_Name(menu, *p, &matchitem) != E_OK)) { Reset_Pattern(menu); pos_menu_cursor(menu); RETURN(E_NO_MATCH); } p++; - } - + } + /* This is reached if there was a match. So we position to the new item */ - Adjust_Current_Item(menu,matchpos,matchitem); + Adjust_Current_Item(menu, matchpos, matchitem); RETURN(E_OK); } |