diff options
Diffstat (limited to 'lib/String.cc')
-rw-r--r-- | lib/String.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/String.cc b/lib/String.cc index d131fba..0fa4278 100644 --- a/lib/String.cc +++ b/lib/String.cc @@ -74,6 +74,8 @@ String::~String() { const char * String::set(const char * s, ...) { va_list ap; +/* This causes a warning: cannot pass objects of type `const String' through `...' + but it is not really a problem. */ va_start(ap, s); vsnprintf(t, BUFSIZ, s, ap); free(str); @@ -99,17 +101,17 @@ const char * String::to_charp(size_t from, ssize_t to) const { if (to < 0) { strncpy(t, &(str[from]), BUFSIZ); } else { - if (to >= siz) { + if (((size_t) to) >= siz) { to = siz - 1; } - if ((to - from) > BUFSIZ) { + if ((((size_t) to) - from) > BUFSIZ) { from -= (to - from) - BUFSIZ; } - if (to >= from) { - int i; - for (i = 0; i <= to - from; i++) { + if (((size_t) to) >= from) { + size_t i; + for (i = 0; i <= ((size_t) to) - from; i++) { t[i] = str[i + from]; } t[i] = '\0'; |