summaryrefslogtreecommitdiff
path: root/ext/mysql/libmysql/longlong2str.c
diff options
context:
space:
mode:
authorMySQL Team <mysql@php.net>2000-08-22 09:02:46 +0000
committerMySQL Team <mysql@php.net>2000-08-22 09:02:46 +0000
commit4b1380e31c0f6e76c629611c7ba8c4e2e961a2fd (patch)
tree853d1881366287956bbfa7edf2f4edc0ae62637e /ext/mysql/libmysql/longlong2str.c
parentbac08af4cb97ea7e9db18a4267fb070264792f2f (diff)
downloadphp-git-4b1380e31c0f6e76c629611c7ba8c4e2e961a2fd.tar.gz
New files for MySQL 3.23.23 client library. New files are for qouting
using different character sets.
Diffstat (limited to 'ext/mysql/libmysql/longlong2str.c')
-rw-r--r--ext/mysql/libmysql/longlong2str.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/ext/mysql/libmysql/longlong2str.c b/ext/mysql/libmysql/longlong2str.c
index 9759208266..5c4eaf98c8 100644
--- a/ext/mysql/libmysql/longlong2str.c
+++ b/ext/mysql/libmysql/longlong2str.c
@@ -1,3 +1,20 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
/*
Defines: longlong2str();
@@ -66,16 +83,61 @@ char *longlong2str(longlong val,char *dst,int radix)
ulonglong quo=(ulonglong) val/(uint) radix;
uint rem= (uint) (val- quo* (uint) radix);
*--p = _dig_vec[rem];
- val= quo;
+ val= quo;
}
long_val= (long) val;
while (long_val != 0)
{
- *--p = _dig_vec[long_val%radix];
- long_val /= radix;
+ long quo= long_val/radix;
+ *--p = _dig_vec[(uchar) (long_val - quo*radix)];
+ long_val= quo;
}
while ((*dst++ = *p++) != 0) ;
return dst-1;
}
#endif
+
+#ifndef longlong10_to_str
+char *longlong10_to_str(longlong val,char *dst,int radix)
+{
+ char buffer[65];
+ register char *p;
+ long long_val;
+
+ if (radix < 0)
+ {
+ if (val < 0)
+ {
+ *dst++ = '-';
+ val = -val;
+ }
+ }
+
+ if (val == 0)
+ {
+ *dst++='0';
+ *dst='\0';
+ return dst;
+ }
+ p = &buffer[sizeof(buffer)-1];
+ *p = '\0';
+
+ while ((ulonglong) val > (ulonglong) LONG_MAX)
+ {
+ ulonglong quo=(ulonglong) val/(uint) 10;
+ uint rem= (uint) (val- quo* (uint) 10);
+ *--p = _dig_vec[rem];
+ val= quo;
+ }
+ long_val= (long) val;
+ while (long_val != 0)
+ {
+ long quo= long_val/10;
+ *--p = _dig_vec[(uchar) (long_val - quo*10)];
+ long_val= quo;
+ }
+ while ((*dst++ = *p++) != 0) ;
+ return dst-1;
+}
+#endif