]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - form/frm_req_name.c
ncurses 6.4 - patch 20240414
[ncurses.git] / form / frm_req_name.c
index 27d4696619f4c07c07447b3646993e8f30ef99d8..8b76a8e4f542eaba5a27f866eb6e2d4bf91a8579 100644 (file)
@@ -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  *
  * 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 "form.priv.h"
 
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_req_name.c,v 1.21 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: frm_req_name.c,v 1.23 2021/06/17 21:11:08 tom Exp $")
 
 #define DATA(s) { s }
 
 
 #define DATA(s) { s }
 
@@ -112,9 +112,9 @@ static const char request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1][13] =
 #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
 
 /*---------------------------------------------------------------------------
 #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  const char * form_request_name (int request);
 |   Function      :  const char * form_request_name (int request);
-|   
+|
 |   Description   :  Get the external name of a form request.
 |
 |   Return Values :  Pointer to name      - on success
 |   Description   :  Get the external name of a form request.
 |
 |   Return Values :  Pointer to name      - on success
@@ -135,9 +135,9 @@ form_request_name(int request)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int form_request_by_name (const char *str);
 |   Function      :  int form_request_by_name (const char *str);
-|   
+|
 |   Description   :  Search for a request with this name.
 |
 |   Return Values :  Request Id       - on success
 |   Description   :  Search for a request with this name.
 |
 |   Return Values :  Request Id       - on success
@@ -150,12 +150,13 @@ form_request_by_name(const char *str)
      to run sequentially through it.
    */
   size_t i = 0;
      to run sequentially through it.
    */
   size_t i = 0;
-  char buf[16];                        /* longest name is 10 chars */
 
   T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
 
   if (str != 0 && (i = strlen(str)) != 0)
     {
 
   T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
 
   if (str != 0 && (i = strlen(str)) != 0)
     {
+      char buf[16];            /* longest name is 10 chars */
+
       if (i > sizeof(buf) - 2)
        i = sizeof(buf) - 2;
       memcpy(buf, str, i);
       if (i > sizeof(buf) - 2)
        i = sizeof(buf) - 2;
       memcpy(buf, str, i);