]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - c++/cursslk.cc
ncurses 6.3 - patch 20220716
[ncurses.git] / c++ / cursslk.cc
index cfbc9da42da7a1e9290e2eb00e76ec90b0a9bccd..b0dd4ab0dc987294279a97c5f530938327339700 100644 (file)
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 Thomas E. Dickey                                *
+ * Copyright 1998-2005,2012 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            *
 #include "cursslk.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursslk.cc,v 1.15 2005/08/06 22:12:36 tom Exp $")
+MODULE_ID("$Id: cursslk.cc,v 1.20 2022/02/26 17:57:23 tom Exp $")
 
 Soft_Label_Key_Set::Soft_Label_Key&
   Soft_Label_Key_Set::Soft_Label_Key::operator=(char *text)
 {
   delete[] label;
-  label = new char[1 + ::strlen(text)];
-  (::strcpy)(label,text);
+  size_t need = 1 + ::strlen(text);
+  label = new char[need];
+  ::_nc_STRCPY(label,text,need);
   return *this;
 }
 
@@ -54,6 +56,8 @@ Soft_Label_Key_Set::Label_Layout
 
 void Soft_Label_Key_Set::init()
 {
+  if (num_labels > 12)
+      num_labels = 12;
   slk_array = new Soft_Label_Key[num_labels];
   for(int i=0; i < num_labels; i++) {
     slk_array[i].num = i+1;
@@ -87,7 +91,7 @@ Soft_Label_Key_Set::Soft_Label_Key_Set(Soft_Label_Key_Set::Label_Layout fmt)
   init();
 }
 
-Soft_Label_Key_Set::~Soft_Label_Key_Set() {
+Soft_Label_Key_Set::~Soft_Label_Key_Set() THROWS(NCursesException) {
   if (!::isendwin())
     clear();
   delete[] slk_array;
@@ -100,6 +104,10 @@ Soft_Label_Key_Set::Soft_Label_Key& Soft_Label_Key_Set::operator[](int i) {
   return slk_array[i-1];
 }
 
+int Soft_Label_Key_Set::labels() const {
+  return num_labels;
+}
+
 void Soft_Label_Key_Set::activate_label(int i, bool bf) {
   if (!b_attrInit) {
     NCursesApplication* A = NCursesApplication::getApplication();