mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
moved bcmath
This commit is contained in:
parent
a297b95c9d
commit
f9f82960d9
15 changed files with 2316 additions and 33 deletions
|
@ -72,7 +72,7 @@ FUNCTIONS_SOURCE = functions/fhttpd.c \
|
|||
functions/crypt.c functions/db.c functions/dl.c \
|
||||
functions/head.c functions/imap.c functions/mime.c \
|
||||
functions/pgsql.c functions/post.c functions/sybase.c \
|
||||
functions/sybase-ct.c @BCMATH_SRC@ functions/xml.c \
|
||||
functions/sybase-ct.c functions/xml.c \
|
||||
functions/ldap.c functions/zlib.c functions/ifx.c \
|
||||
functions/pdf.c \
|
||||
functions/fdf.c functions/snmp.c functions/interbase.c \
|
||||
|
@ -80,7 +80,7 @@ FUNCTIONS_SOURCE = functions/fhttpd.c \
|
|||
|
||||
FUNCTIONS = $(FUNCTIONS_SOURCE:.c=.o)
|
||||
PHPLIBS = -L@top_srcdir@/libzend -lzend -L@top_srcdir@/ext -lphpext
|
||||
LIBS = $(PHPLIBS) $(EXTRA_LIBS) @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@ @FHTTPD_LIB@ @REGEX_LIB@ @DBM_LIB@ @SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@ @MYSQL_LFLAGS@ @MYSQL_LIBS@ @PGSQL_LFLAGS@ @PGSQL_LIBS@ @LDAP_LFLAGS@ @LDAP_LIBS@ @IMAP_LIBS@ @ZLIB_LIBS@ @PDFLIB_LIBS@ @FDFLIB_LIBS@ @IFX_LFLAGS@ @IFX_LIBS@ @SNMP_LFLAGS@ @SNMP_LIBS@ @IBASE_LFLAGS@ @IBASE_LIBS@ @XML_LIBS@ @LIBS@
|
||||
LIBS = $(PHPLIBS) $(EXTRA_LIBS) @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@ @FHTTPD_LIB@ @REGEX_LIB@ @DBM_LIB@ @SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@ @PGSQL_LFLAGS@ @PGSQL_LIBS@ @LDAP_LFLAGS@ @LDAP_LIBS@ @IMAP_LIBS@ @ZLIB_LIBS@ @PDFLIB_LIBS@ @FDFLIB_LIBS@ @IFX_LFLAGS@ @IFX_LIBS@ @SNMP_LFLAGS@ @SNMP_LIBS@ @IBASE_LFLAGS@ @IBASE_LIBS@ @XML_LIBS@ @LIBS@
|
||||
|
||||
all: $(BINNAME)
|
||||
|
||||
|
|
|
@ -150,9 +150,6 @@
|
|||
/* Define if you want to enable PHP RPC (experimental) */
|
||||
#define PHP_RPC 0
|
||||
|
||||
/* Define if you want to enable bc style precision math support */
|
||||
#define WITH_BCMATH 0
|
||||
|
||||
/* Define if you want to prevent the CGI from working unless REDIRECT_STATUS is defined in the environment */
|
||||
#define FORCE_CGI_REDIRECT 0
|
||||
|
||||
|
|
|
@ -710,26 +710,6 @@ dnl AC_DEFINE(PHP_RPC, 0)
|
|||
dnl AC_MSG_RESULT(no)
|
||||
dnl ])
|
||||
|
||||
AC_MSG_CHECKING(whether to enable bc style precision math functions)
|
||||
AC_ARG_ENABLE(bcmath,
|
||||
[ --disable-bcmath Compile without bc style precision math functions. ],
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
AC_DEFINE(WITH_BCMATH, 1)
|
||||
AC_MSG_RESULT(yes)
|
||||
BCMATH_SRC="functions/bcmath.c functions/number.c"
|
||||
else
|
||||
AC_DEFINE(WITH_BCMATH, 0)
|
||||
AC_MSG_RESULT(no)
|
||||
BCMATH_SRC=""
|
||||
fi
|
||||
],[
|
||||
AC_DEFINE(WITH_BCMATH, 1)
|
||||
AC_MSG_RESULT(yes)
|
||||
BCMATH_SRC="functions/bcmath.c functions/number.c"
|
||||
])
|
||||
AC_SUBST(BCMATH_SRC)
|
||||
|
||||
if test "$BINNAME" = "php"; then
|
||||
AC_MSG_CHECKING(whether to force Apache CGI redirect)
|
||||
AC_ARG_ENABLE(force-cgi-redirect,
|
||||
|
|
5
ext/bcmath/Makefile.am
Normal file
5
ext/bcmath/Makefile.am
Normal file
|
@ -0,0 +1,5 @@
|
|||
# $Id$
|
||||
|
||||
INCLUDES=@INCLUDES@ -I@top_srcdir@ -I@top_srcdir@/libzend
|
||||
noinst_LIBRARIES=libphpext_bcmath.a
|
||||
libphpext_bcmath_a_SOURCES=bcmath.c number.c
|
453
ext/bcmath/bcmath.c
Normal file
453
ext/bcmath/bcmath.c
Normal file
|
@ -0,0 +1,453 @@
|
|||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP HTML Embedded Scripting Language Version 3.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This program is free software; you can redistribute it and/or modify |
|
||||
| it under the terms of one of the following licenses: |
|
||||
| |
|
||||
| A) the GNU General Public License as published by the Free Software |
|
||||
| Foundation; either version 2 of the License, or (at your option) |
|
||||
| any later version. |
|
||||
| |
|
||||
| B) the PHP License as published by the PHP Development Team and |
|
||||
| included in the distribution in the file: LICENSE |
|
||||
| |
|
||||
| This program 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 General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of both licenses referred to here. |
|
||||
| If you did not, or have any questions about PHP licensing, please |
|
||||
| contact core@php.net. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef MSVC5
|
||||
#include "config.h"
|
||||
#include "build-defs.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
|
||||
|
||||
#if WITH_BCMATH
|
||||
|
||||
#include "number.h"
|
||||
#include "php3_bcmath.h"
|
||||
|
||||
function_entry bcmath_functions[] = {
|
||||
{"bcadd", php3_bcmath_add, NULL},
|
||||
{"bcsub", php3_bcmath_sub, NULL},
|
||||
{"bcmul", php3_bcmath_mul, NULL},
|
||||
{"bcdiv", php3_bcmath_div, NULL},
|
||||
{"bcmod", php3_bcmath_mod, NULL},
|
||||
{"bcpow", php3_bcmath_pow, NULL},
|
||||
{"bcsqrt", php3_bcmath_sqrt, NULL},
|
||||
{"bcscale", php3_bcmath_set_scale, NULL},
|
||||
{"bccomp", php3_bcmath_comp, NULL},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
php3_module_entry bcmath_module_entry = {
|
||||
"bcmath", bcmath_functions, NULL, NULL, php3_rinit_bcmath, php3_rend_bcmath, NULL, STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
#if COMPILE_DL
|
||||
php3_module_entry *get_module() { return &bcmath_module_entry; };
|
||||
#endif
|
||||
|
||||
#ifndef THREAD_SAFE
|
||||
static long bc_precision;
|
||||
#endif
|
||||
|
||||
int php3_rinit_bcmath(INIT_FUNC_ARGS)
|
||||
{
|
||||
TLS_VARS;
|
||||
|
||||
init_numbers();
|
||||
if (cfg_get_long("bcmath.scale",&GLOBAL(bc_precision))==FAILURE) {
|
||||
GLOBAL(bc_precision)=0;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int php3_rend_bcmath(SHUTDOWN_FUNC_ARGS)
|
||||
{
|
||||
destruct_numbers();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale])
|
||||
Returns the sum of two arbitrary precision numbers */
|
||||
void php3_bcmath_add(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *left, *right,*scale_param;
|
||||
bc_num first, second, result;
|
||||
int scale=GLOBAL(bc_precision);
|
||||
|
||||
switch (ARG_COUNT(ht)) {
|
||||
case 2:
|
||||
if (getParameters(ht, 2, &left, &right) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long(scale_param);
|
||||
scale = (int) scale_param->value.lval;
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
convert_to_string(left);
|
||||
convert_to_string(right);
|
||||
init_num(&first);
|
||||
init_num(&second);
|
||||
init_num(&result);
|
||||
str2num(&first,left->value.str.val,scale);
|
||||
str2num(&second,right->value.str.val,scale);
|
||||
bc_add (first,second,&result, scale);
|
||||
return_value->value.str.val = num2str(result);
|
||||
return_value->value.str.len = strlen(return_value->value.str.val);
|
||||
return_value->type = IS_STRING;
|
||||
free_num(&first);
|
||||
free_num(&second);
|
||||
free_num(&result);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcsub(string left_operand, string right_operand [, int scale])
|
||||
Returns the difference between two arbitrary precision numbers (subtration) */
|
||||
void php3_bcmath_sub(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *left, *right,*scale_param;
|
||||
bc_num first, second, result;
|
||||
int scale=GLOBAL(bc_precision);
|
||||
|
||||
switch (ARG_COUNT(ht)) {
|
||||
case 2:
|
||||
if (getParameters(ht, 2, &left, &right) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long(scale_param);
|
||||
scale = (int) scale_param->value.lval;
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
convert_to_string(left);
|
||||
convert_to_string(right);
|
||||
init_num(&first);
|
||||
init_num(&second);
|
||||
init_num(&result);
|
||||
str2num(&first,left->value.str.val,scale);
|
||||
str2num(&second,right->value.str.val,scale);
|
||||
bc_sub (first,second,&result, scale);
|
||||
return_value->value.str.val = num2str(result);
|
||||
return_value->value.str.len = strlen(return_value->value.str.val);
|
||||
return_value->type = IS_STRING;
|
||||
free_num(&first);
|
||||
free_num(&second);
|
||||
free_num(&result);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcmul(string left_operand, string right_operand [, int scale])
|
||||
Returns the multiplication of two arbitrary precision numbers */
|
||||
void php3_bcmath_mul(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *left, *right,*scale_param;
|
||||
bc_num first, second, result;
|
||||
int scale=GLOBAL(bc_precision);
|
||||
|
||||
switch (ARG_COUNT(ht)) {
|
||||
case 2:
|
||||
if (getParameters(ht, 2, &left, &right) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long(scale_param);
|
||||
scale = (int) scale_param->value.lval;
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
convert_to_string(left);
|
||||
convert_to_string(right);
|
||||
init_num(&first);
|
||||
init_num(&second);
|
||||
init_num(&result);
|
||||
str2num(&first,left->value.str.val,scale);
|
||||
str2num(&second,right->value.str.val,scale);
|
||||
bc_multiply (first,second,&result, scale);
|
||||
return_value->value.str.val = num2str(result);
|
||||
return_value->value.str.len = strlen(return_value->value.str.val);
|
||||
return_value->type = IS_STRING;
|
||||
free_num(&first);
|
||||
free_num(&second);
|
||||
free_num(&result);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcdiv(string left_operand, string right_operand [, int scale])
|
||||
Returns the quotient of two arbitrary precision numbers (division) */
|
||||
void php3_bcmath_div(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *left, *right,*scale_param;
|
||||
bc_num first, second, result;
|
||||
int scale=GLOBAL(bc_precision);
|
||||
|
||||
switch (ARG_COUNT(ht)) {
|
||||
case 2:
|
||||
if (getParameters(ht, 2, &left, &right) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long(scale_param);
|
||||
scale = (int) scale_param->value.lval;
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
convert_to_string(left);
|
||||
convert_to_string(right);
|
||||
init_num(&first);
|
||||
init_num(&second);
|
||||
init_num(&result);
|
||||
str2num(&first,left->value.str.val,scale);
|
||||
str2num(&second,right->value.str.val,scale);
|
||||
switch (bc_divide (first,second,&result, scale)) {
|
||||
case 0: /* OK */
|
||||
return_value->value.str.val = num2str(result);
|
||||
return_value->value.str.len = strlen(return_value->value.str.val);
|
||||
return_value->type = IS_STRING;
|
||||
break;
|
||||
case -1: /* division by zero */
|
||||
php3_error(E_WARNING,"Division by zero");
|
||||
break;
|
||||
}
|
||||
free_num(&first);
|
||||
free_num(&second);
|
||||
free_num(&result);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcmod(string left_operand, string right_operand)
|
||||
Returns the modulus of the two arbitrary precision operands */
|
||||
void php3_bcmath_mod(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *left, *right;
|
||||
bc_num first, second, result;
|
||||
|
||||
switch (ARG_COUNT(ht)) {
|
||||
case 2:
|
||||
if (getParameters(ht, 2, &left, &right) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
convert_to_string(left);
|
||||
convert_to_string(right);
|
||||
init_num(&first);
|
||||
init_num(&second);
|
||||
init_num(&result);
|
||||
str2num(&first,left->value.str.val,0);
|
||||
str2num(&second,right->value.str.val,0);
|
||||
switch (bc_modulo(first,second,&result, 0)) {
|
||||
case 0:
|
||||
return_value->value.str.val = num2str(result);
|
||||
return_value->value.str.len = strlen(return_value->value.str.val);
|
||||
return_value->type = IS_STRING;
|
||||
break;
|
||||
case -1:
|
||||
php3_error(E_WARNING,"Division by zero");
|
||||
break;
|
||||
}
|
||||
free_num(&first);
|
||||
free_num(&second);
|
||||
free_num(&result);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcpow(string x, string y [, int scale])
|
||||
Returns the value of an arbitrary precision number raised to the power of another */
|
||||
void php3_bcmath_pow(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *left, *right,*scale_param;
|
||||
bc_num first, second, result;
|
||||
int scale=GLOBAL(bc_precision);
|
||||
|
||||
switch (ARG_COUNT(ht)) {
|
||||
case 2:
|
||||
if (getParameters(ht, 2, &left, &right) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long(scale_param);
|
||||
scale = (int) scale_param->value.lval;
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
convert_to_string(left);
|
||||
convert_to_string(right);
|
||||
init_num(&first);
|
||||
init_num(&second);
|
||||
init_num(&result);
|
||||
str2num(&first,left->value.str.val,scale);
|
||||
str2num(&second,right->value.str.val,scale);
|
||||
bc_raise (first,second,&result, scale);
|
||||
return_value->value.str.val = num2str(result);
|
||||
return_value->value.str.len = strlen(return_value->value.str.val);
|
||||
return_value->type = IS_STRING;
|
||||
free_num(&first);
|
||||
free_num(&second);
|
||||
free_num(&result);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcsqrt(string operand [, int scale])
|
||||
Returns the square root of an arbitray precision number */
|
||||
void php3_bcmath_sqrt(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *left,*scale_param;
|
||||
bc_num result;
|
||||
int scale=GLOBAL(bc_precision);
|
||||
|
||||
switch (ARG_COUNT(ht)) {
|
||||
case 1:
|
||||
if (getParameters(ht, 1, &left) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (getParameters(ht, 2, &left, &scale_param) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long(scale_param);
|
||||
scale = (int) scale_param->value.lval;
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
convert_to_string(left);
|
||||
init_num(&result);
|
||||
str2num(&result,left->value.str.val,scale);
|
||||
if (bc_sqrt (&result, scale) != 0) {
|
||||
return_value->value.str.val = num2str(result);
|
||||
return_value->value.str.len = strlen(return_value->value.str.val);
|
||||
return_value->type = IS_STRING;
|
||||
} else {
|
||||
php3_error(E_WARNING,"Square root of negative number");
|
||||
}
|
||||
free_num(&result);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bccomp(string left_operand, string right_operand [, int scale])
|
||||
Compares two arbitrary precision numbers */
|
||||
void php3_bcmath_comp(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *left, *right, *scale_param;
|
||||
bc_num first, second;
|
||||
int scale=GLOBAL(bc_precision);
|
||||
|
||||
switch (ARG_COUNT(ht)) {
|
||||
case 2:
|
||||
if (getParameters(ht, 2, &left, &right) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (getParameters(ht, 3, &left, &right, &scale_param) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_long(scale_param);
|
||||
scale = (int) scale_param->value.lval;
|
||||
break;
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
|
||||
convert_to_string(left);
|
||||
convert_to_string(right);
|
||||
init_num(&first);
|
||||
init_num(&second);
|
||||
|
||||
str2num(&first,left->value.str.val,scale);
|
||||
str2num(&second,right->value.str.val,scale);
|
||||
return_value->value.lval = bc_compare(first,second);
|
||||
return_value->type = IS_LONG;
|
||||
|
||||
free_num(&first);
|
||||
free_num(&second);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string bcscale(int scale)
|
||||
Sets default scale parameter for all bc math functions */
|
||||
void php3_bcmath_set_scale(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *new_scale;
|
||||
|
||||
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &new_scale)==FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
convert_to_long(new_scale);
|
||||
GLOBAL(bc_precision) = new_scale->value.lval;
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
2
ext/bcmath/config.h.stub
Normal file
2
ext/bcmath/config.h.stub
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* Define if you want to enable bc style precision math support */
|
||||
#define WITH_BCMATH 0
|
19
ext/bcmath/config.m4
Normal file
19
ext/bcmath/config.m4
Normal file
|
@ -0,0 +1,19 @@
|
|||
dnl $Id$
|
||||
|
||||
AC_MSG_CHECKING(whether to enable bc style precision math functions)
|
||||
AC_ARG_ENABLE(bcmath,
|
||||
[ --disable-bcmath Compile without bc style precision math functions. ],
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
AC_DEFINE(WITH_BCMATH, 1)
|
||||
AC_MSG_RESULT(yes)
|
||||
PHP_EXTENSION(bcmath)
|
||||
else
|
||||
AC_DEFINE(WITH_BCMATH, 0)
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
],[
|
||||
AC_DEFINE(WITH_BCMATH, 1)
|
||||
AC_MSG_RESULT(yes)
|
||||
PHP_EXTENSION(bcmath)
|
||||
])
|
1640
ext/bcmath/number.c
Normal file
1640
ext/bcmath/number.c
Normal file
File diff suppressed because it is too large
Load diff
118
ext/bcmath/number.h
Normal file
118
ext/bcmath/number.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP HTML Embedded Scripting Language Version 3.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This program is free software; you can redistribute it and/or modify |
|
||||
| it under the terms of one of the following licenses: |
|
||||
| |
|
||||
| A) the GNU General Public License as published by the Free Software |
|
||||
| Foundation; either version 2 of the License, or (at your option) |
|
||||
| any later version. |
|
||||
| |
|
||||
| B) the PHP License as published by the PHP Development Team and |
|
||||
| included in the distribution in the file: LICENSE |
|
||||
| |
|
||||
| This program 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 General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of both licenses referred to here. |
|
||||
| If you did not, or have any questions about PHP licensing, please |
|
||||
| contact core@php.net. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Modified for PHP by Andi Gutmans <andi@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* number.h: Arbitrary precision numbers header file. */
|
||||
|
||||
/* This file is part of GNU bc.
|
||||
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License , or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
You may contact the author by:
|
||||
e-mail: phil@cs.wwu.edu
|
||||
us-mail: Philip A. Nelson
|
||||
Computer Science Department, 9062
|
||||
Western Washington University
|
||||
Bellingham, WA 98226-9062
|
||||
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _NUMBER_H
|
||||
#define _NUMBER_H
|
||||
|
||||
typedef enum {PLUS, MINUS} sign;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
sign n_sign;
|
||||
int n_len; /* The number of digits before the decimal point. */
|
||||
int n_scale; /* The number of digits after the decimal point. */
|
||||
int n_refs; /* The number of pointers to this number. */
|
||||
char n_value[1]; /* The storage. Not zero char terminated. It is
|
||||
allocated with all other fields. */
|
||||
} bc_struct;
|
||||
|
||||
typedef bc_struct *bc_num;
|
||||
|
||||
/* The base used in storing the numbers in n_value above.
|
||||
Currently this MUST be 10. */
|
||||
|
||||
#define BASE 10
|
||||
|
||||
/* Some useful macros and constants. */
|
||||
|
||||
#define CH_VAL(c) (c - '0')
|
||||
#define BCD_CHAR(d) (d + '0')
|
||||
|
||||
#if 0
|
||||
#ifdef MIN
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#endif
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#define MIN(a,b) ((a)>(b)?(b):(a))
|
||||
|
||||
#endif
|
||||
|
||||
#define ODD(a) ((a)&1)
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
extern void init_numbers (void);
|
||||
extern void destruct_numbers (void);
|
||||
extern void str2num (bc_num *num, char *str, int scale);
|
||||
extern char *num2str (bc_num num);
|
||||
extern void bc_add ( bc_num n1, bc_num n2, bc_num *result, int scale_min);
|
||||
extern void bc_sub (bc_num n1, bc_num n2, bc_num *result, int scale_min);
|
||||
extern void bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale);
|
||||
extern int bc_divide (bc_num n1, bc_num n2, bc_num *quot, int scale);
|
||||
extern int bc_modulo (bc_num num1, bc_num num2, bc_num *result, int scale);
|
||||
extern void bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale);
|
||||
extern int bc_sqrt (bc_num *num, int scale);
|
||||
extern int bc_compare (bc_num n1, bc_num n2);
|
||||
|
||||
extern void free_num (bc_num *num);
|
||||
extern void init_num (bc_num *num);
|
||||
|
||||
#endif
|
64
ext/bcmath/php3_bcmath.h
Normal file
64
ext/bcmath/php3_bcmath.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP HTML Embedded Scripting Language Version 3.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This program is free software; you can redistribute it and/or modify |
|
||||
| it under the terms of one of the following licenses: |
|
||||
| |
|
||||
| A) the GNU General Public License as published by the Free Software |
|
||||
| Foundation; either version 2 of the License, or (at your option) |
|
||||
| any later version. |
|
||||
| |
|
||||
| B) the PHP License as published by the PHP Development Team and |
|
||||
| included in the distribution in the file: LICENSE |
|
||||
| |
|
||||
| This program 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 General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of both licenses referred to here. |
|
||||
| If you did not, or have any questions about PHP licensing, please |
|
||||
| contact core@php.net. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _PHP3_BCMATH_H
|
||||
#define _PHP3_BCMATH_H
|
||||
|
||||
#if COMPILE_DL
|
||||
#undef WITH_BCMATH
|
||||
#define WITH_BCMATH 1
|
||||
#endif
|
||||
|
||||
#if WITH_BCMATH
|
||||
|
||||
extern php3_module_entry bcmath_module_entry;
|
||||
#define bcmath_module_ptr &bcmath_module_entry
|
||||
|
||||
extern int php3_rinit_bcmath(INIT_FUNC_ARGS);
|
||||
extern int php3_rend_bcmath(SHUTDOWN_FUNC_ARGS);
|
||||
extern void php3_bcmath_add(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_bcmath_sub(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_bcmath_mul(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_bcmath_div(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_bcmath_mod(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_bcmath_pow(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_bcmath_sqrt(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_bcmath_comp(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_bcmath_set_scale(INTERNAL_FUNCTION_PARAMETERS);
|
||||
|
||||
#else
|
||||
|
||||
#define bcmath_module_ptr NULL
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _PHP3_BCMATH_H */
|
6
ext/bcmath/setup.stub
Normal file
6
ext/bcmath/setup.stub
Normal file
|
@ -0,0 +1,6 @@
|
|||
# $Source$
|
||||
# $Id$
|
||||
|
||||
define_option enable-bcmath 'Enable bc style precision math functions' yesno \
|
||||
yes \
|
||||
' Enables bc style arbitrary precision math functions.'
|
|
@ -50,7 +50,7 @@
|
|||
#include "functions/php3_crypt.h"
|
||||
#include "functions/php3_ldap.h"
|
||||
#include "ext/mysql/php3_mysql.h"
|
||||
#include "functions/php3_bcmath.h"
|
||||
#include "ext/bcmath/php3_bcmath.h"
|
||||
#include "ext/msql/php3_msql.h"
|
||||
#include "ext/oracle/php3_oci8.h"
|
||||
#include "ext/oracle/oracle.h"
|
||||
|
@ -61,12 +61,12 @@
|
|||
#include "functions/dl.h"
|
||||
#include "functions/head.h"
|
||||
#include "functions/post.h"
|
||||
#include "functions/hw.h"
|
||||
#include "ext/hyperwave/hw.h"
|
||||
#include "ext/filepro/filepro.h"
|
||||
#include "functions/db.h"
|
||||
#include "dl/snmp/php3_snmp.h"
|
||||
#include "functions/php3_zlib.h"
|
||||
#include "functions/php3_COM.h"
|
||||
#include "ext/com/php3_COM.h"
|
||||
#include "functions/php3_interbase.h"
|
||||
#include "functions/php3_xml.h"
|
||||
#include "functions/php3_pdf.h"
|
||||
|
|
|
@ -41,12 +41,15 @@
|
|||
|
||||
#include "php_version.h"
|
||||
#include "zend.h"
|
||||
|
||||
/* automake defines PACKAGE and VERSION for Zend too */
|
||||
#ifdef PACKAGE
|
||||
# undef PACKAGE
|
||||
#endif
|
||||
#ifdef VERSION
|
||||
# undef VERSION
|
||||
#endif
|
||||
|
||||
#include "zend_API.h"
|
||||
|
||||
|
||||
|
|
4
setup
4
setup
|
@ -351,10 +351,6 @@ define_option enable-debugger 'Enable PHP remote debugger?' yesno no \
|
|||
" Whether to enable PHP remote debugging support. This feature\n
|
||||
is still under development."
|
||||
|
||||
define_option enable-bcmath 'Enable bc style precision math functions' yesno \
|
||||
no \
|
||||
' Enables bc style arbitrary precision math functions.'
|
||||
|
||||
# configure.in only checks these if it's a cgi so setup does the same
|
||||
if test "$option_value_with_apache" = "no"; then
|
||||
# outputing the bank line isn't really possible, but it would be nice
|
||||
|
|
2
tls.h
2
tls.h
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "alloc.h"
|
||||
#include "functions/head.h"
|
||||
#include "functions/number.h"
|
||||
#include "ext/bcmath/number.h"
|
||||
#include "constants.h"
|
||||
#include <sys/stat.h>
|
||||
#if USE_SAPI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue