summaryrefslogtreecommitdiff
path: root/graphics/clanlib/patches/patch-ac
diff options
context:
space:
mode:
authordmcmahill <dmcmahill@pkgsrc.org>2001-05-11 14:12:10 +0000
committerdmcmahill <dmcmahill@pkgsrc.org>2001-05-11 14:12:10 +0000
commitf4c83acaa95772b651c9baa3447f77b499ec80a8 (patch)
treee4ccb4e8a5c50dfa013fb2d5d88abc80013f79ea /graphics/clanlib/patches/patch-ac
parent68a57288f74ffa37abf613b4de2461496297f13c (diff)
downloadpkgsrc-f4c83acaa95772b651c9baa3447f77b499ec80a8.tar.gz
add a missing CL_String << long operator overload needed on systems for
which sizeof(long) != sizeof(int).
Diffstat (limited to 'graphics/clanlib/patches/patch-ac')
-rw-r--r--graphics/clanlib/patches/patch-ac110
1 files changed, 98 insertions, 12 deletions
diff --git a/graphics/clanlib/patches/patch-ac b/graphics/clanlib/patches/patch-ac
index 7caca2322b8..2144fbb6a21 100644
--- a/graphics/clanlib/patches/patch-ac
+++ b/graphics/clanlib/patches/patch-ac
@@ -1,17 +1,83 @@
-$NetBSD: patch-ac,v 1.3 2000/12/15 03:20:50 garbled Exp $
---- Sources/API/Core/System/clanstring.h.orig Tue May 9 14:09:32 2000
-+++ Sources/API/Core/System/clanstring.h Thu Dec 14 18:08:39 2000
-@@ -25,6 +25,8 @@
-
+$NetBSD: patch-ac,v 1.4 2001/05/11 14:12:10 dmcmahill Exp $
+
+
+add an operator overload for CL_String << long so this can build
+on 64-bit systems.
+
+--- Sources/API/Core/System/clanstring.h.orig Tue May 9 17:09:32 2000
++++ Sources/API/Core/System/clanstring.h Thu May 10 17:57:14 2001
+@@ -26,4 +26,6 @@
#ifndef WIN32
#include <cctype>
+#include <stdio.h>
+#include <sys/param.h>
#endif
- #ifdef __BEOS__
-@@ -101,9 +103,12 @@
- {
+@@ -69,4 +71,36 @@
+ }
+ }
++
++void ltoa(long num, char *str, const int number_format)
++{
++ long num1 = num;
++ int num_chars = 0;
++
++ while (num1>0)
++ {
++ num_chars++;
++ num1 /= number_format;
++ }
++
++ if (num_chars == 0) num_chars = 1;
++
++ str[num_chars] = 0; // Null-terminate the str
++
++ for (int pos = num_chars-1; pos>=0; pos--)
++ {
++ int cur_char = num % number_format;
++
++ if (cur_char < 10) // Insert number
++ {
++ str[pos] = cur_char + '0';
++ }
++ else // Insert letter
++ {
++ str[pos] = cur_char-10 + 'A';
++ }
++
++ num /= number_format;
++ }
++}
+ #else
+ #pragma warning( disable : 4244 )
+@@ -97,4 +131,26 @@
+ return text;
+ }
++
++ char *long_to_string(const char *prefix, const long number)
++ {
++ char buf[20];
++ ltoa(number, buf, 10);
++
++ int len=0;
++ if (prefix!=NULL) len=strlen(prefix);
++
++ char *text=new char[len+strlen(buf)+1];
++ if (prefix!=NULL)
++ {
++ strcpy(text, prefix);
++ strcat(text, buf);
++ }
++ else
++ {
++ strcpy(text, buf);
++ }
++
++ return text;
++ }
+
+ char *float_to_string(const char *prefix, const float _float_number)
+@@ -102,7 +158,10 @@
char buf[25];
buf[0]=0;
+ int precision=4;
@@ -23,12 +89,32 @@ $NetBSD: patch-ac,v 1.3 2000/12/15 03:20:50 garbled Exp $
- int precision=4;
char temp;
- float float_number = _float_number;
-@@ -134,6 +139,7 @@
- strcat(buf, &float_buffer[decimal]);
+@@ -135,4 +194,5 @@
copy_strings:
+#endif
int len=0;
if (prefix!=NULL) len=strlen(prefix);
-
+@@ -434,4 +494,22 @@
+ {
+ char *new_string=int_to_string(str, number);
++ if (str!=NULL) delete str;
++ str=new_string;
++
++ return *this;
++ }
++
++ CL_String &operator<< (const unsigned long number)
++ {
++ char *new_string=long_to_string(str, number);
++ if (str!=NULL) delete str;
++ str=new_string;
++
++ return *this;
++ }
++
++ CL_String &operator<< (const long number)
++ {
++ char *new_string=long_to_string(str, number);
+ if (str!=NULL) delete str;
+ str=new_string;