diff options
Diffstat (limited to 'menu/m_req_name.c')
-rw-r--r-- | menu/m_req_name.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/menu/m_req_name.c b/menu/m_req_name.c index d3f04c1..c72116f 100644 --- a/menu/m_req_name.c +++ b/menu/m_req_name.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2015 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_req_name.c,v 1.24 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_req_name.c,v 1.27 2021/06/17 21:11:08 tom Exp $") #define DATA(s) { s } @@ -66,15 +66,15 @@ static const char request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1][14] = #define A_SIZE (sizeof(request_names)/sizeof(request_names[0])) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : const char * menu_request_name (int request); -| +| | Description : Get the external name of a menu request. | | Return Values : Pointer to name - on success | NULL - on invalid request code +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(const char *) +MENU_EXPORT(const char *) menu_request_name(int request) { T((T_CALLED("menu_request_name(%d)"), request)); @@ -88,27 +88,28 @@ menu_request_name(int request) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int menu_request_by_name (const char *str); -| +| | Description : Search for a request with this name. | | Return Values : Request Id - on success | E_NO_MATCH - request not found +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) +MENU_EXPORT(int) menu_request_by_name(const char *str) { /* because the table is so small, it doesn't really hurt to run sequentially through it. */ size_t i = 0; - char buf[16]; T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str))); if (str != 0 && (i = strlen(str)) != 0) { + char buf[16]; + if (i > sizeof(buf) - 2) i = sizeof(buf) - 2; memcpy(buf, str, i); |