summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2006-02-09 17:03:07 +0000
committerpixel <pixel>2006-02-09 17:03:07 +0000
commit038c92026a1222d204dcf1b85e5f349eb24f34d5 (patch)
tree65e6214897f2d2115303f29a268113e5627f5346
parentffaee8f1a04b5c3616f27118b426ce727294868c (diff)
Let's stop using that deadly to_charp() that gives a static char[]! It's dangerous.
-rw-r--r--include/BString.h4
-rw-r--r--lib/String.cc10
2 files changed, 8 insertions, 6 deletions
diff --git a/include/BString.h b/include/BString.h
index e9b0270..2caebb3 100644
--- a/include/BString.h
+++ b/include/BString.h
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: BString.h,v 1.13 2006-01-31 17:02:38 pixel Exp $ */
+/* $Id: BString.h,v 1.14 2006-02-09 17:03:07 pixel Exp $ */
#ifndef __STRING_H__
#define __STRING_H__
@@ -49,7 +49,7 @@ class String : public Base {
const char * set(const ugly_string &, ...);
int scanf(const char *, ...) const;
int scanf(const ugly_string &, ...) const;
- const char * to_charp(size_t = 0, ssize_t = -1) const;
+ const char * to_charp(size_t = 0, ssize_t = -1) const throw (GeneralException);
String extract(size_t = 0, ssize_t = -1) const;
char * strdup(size_t = 0, ssize_t = -1) const;
int to_int() const;
diff --git a/lib/String.cc b/lib/String.cc
index 969d335..36e6c52 100644
--- a/lib/String.cc
+++ b/lib/String.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: String.cc,v 1.42 2006-02-02 11:01:13 pixel Exp $ */
+/* $Id: String.cc,v 1.43 2006-02-09 17:03:07 pixel Exp $ */
#include <stdio.h>
#include <string.h>
@@ -234,11 +234,12 @@ int String::scanf(const ugly_string & s, ...) const {
}
#endif
-const char * String::to_charp(size_t from, ssize_t to) const {
+const char * String::to_charp(size_t from, ssize_t to) const throw (GeneralException) {
if (to < 0) {
- if (from)
+ if (from) {
+ throw GeneralException("This usage of String is deprecated.");
strncpy(t, &(str[from]), BUFSIZ);
- else
+ } else
return str;
} else {
if (((size_t) to) >= siz) {
@@ -259,6 +260,7 @@ const char * String::to_charp(size_t from, ssize_t to) const {
t[0] = '\0';
}
}
+ throw GeneralException("This usage of String is deprecated.");
return t;
}