On Tue, 10 Dec 2002, Andi Gutmans wrote:

> I think this is one of those exceptions where we should probably not go by 
> our standard and call the function bcpowmod(). It looks a bit funny that 
> all of the BC functions don't have underscores but only one does. It'll 
> probably confuse people more than it helps.
> What do you guys think?

Yeah, I have to agree with that, but I also think it might be better to 
change all functions then and mark the old function names as deprecated 
(and make the old names aliasses). If we want to have consistent 
function names we better start it right away.

Derick

> At 07:04 PM 12/10/2002 +0000, Sara Golemon wrote:
> >pollita         Tue Dec 10 14:04:29 2002 EDT
> >
> >   Modified files:
> >     /php4/ext/bcmath    bcmath.c php_bcmath.h
> >   Log:
> >   Added support for libbcmath's bc_raisemod function as bc_powmod()
> >
> >
> >Index: php4/ext/bcmath/bcmath.c
> >diff -u php4/ext/bcmath/bcmath.c:1.43 php4/ext/bcmath/bcmath.c:1.44
> >--- php4/ext/bcmath/bcmath.c:1.43       Thu Dec  5 16:51:45 2002
> >+++ php4/ext/bcmath/bcmath.c    Tue Dec 10 14:04:27 2002
> >@@ -16,7 +16,7 @@
> >     +----------------------------------------------------------------------+
> >  */
> >
> >-/* $Id: bcmath.c,v 1.43 2002/12/05 21:51:45 helly Exp $ */
> >+/* $Id: bcmath.c,v 1.44 2002/12/10 19:04:27 pollita Exp $ */
> >
> >  #ifdef HAVE_CONFIG_H
> >  #include "config.h"
> >@@ -42,6 +42,7 @@
> >         PHP_FE(bcsqrt, 
> >                NULL)
> >         PHP_FE(bcscale, 
> >                NULL)
> >         PHP_FE(bccomp, 
> >                NULL)
> >+       PHP_FE(bc_powmod, 
> >              NULL)
> >         {NULL, NULL, NULL}
> >  };
> >
> >@@ -324,6 +325,38 @@
> >         }
> >         bc_free_num(&first);
> >         bc_free_num(&second);
> >+       bc_free_num(&result);
> >+       return;
> >+}
> >+/* }}} */
> >+
> >+/* {{{ proto string bc_powmod(string x, string y, string mod [, int scale])
> >+   Returns the value of an arbitrary precision number raised to the power 
> >of another reduced by a modulous */
> >+PHP_FUNCTION(bc_powmod)
> >+{
> >+       char *left, *right, *modulous;
> >+       int left_len, right_len, modulous_len;
> >+       bc_num first, second, mod, result;
> >+       int scale=bc_precision;
> >+
> >+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_C, "sss|l", 
> >&left, &left_len, &right, &right_len, &modulous, &modulous_len, &scale) == 
> >FAILURE) {
> >+               WRONG_PARAM_COUNT;
> >+       }
> >+
> >+       bc_init_num(&first TSRMLS_CC);
> >+       bc_init_num(&second TSRMLS_CC);
> >+       bc_init_num(&mod TSRMLS_CC);
> >+       bc_init_num(&result TSRMLS_CC);
> >+       bc_str2num(&first, left, scale TSRMLS_CC);
> >+       bc_str2num(&second, right, scale TSRMLS_CC);
> >+       bc_str2num(&mod, modulous, scale TSRMLS_CC);
> >+       bc_raisemod(first, second, mod, &result, scale TSRMLS_CC);
> >+       Z_STRVAL_P(return_value) = bc_num2str(result);
> >+       Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
> >+       Z_TYPE_P(return_value) = IS_STRING;
> >+       bc_free_num(&first);
> >+       bc_free_num(&second);
> >+       bc_free_num(&mod);
> >         bc_free_num(&result);
> >         return;
> >  }
> >Index: php4/ext/bcmath/php_bcmath.h
> >diff -u php4/ext/bcmath/php_bcmath.h:1.12 php4/ext/bcmath/php_bcmath.h:1.13
> >--- php4/ext/bcmath/php_bcmath.h:1.12   Fri Nov 22 04:25:28 2002
> >+++ php4/ext/bcmath/php_bcmath.h        Tue Dec 10 14:04:27 2002
> >@@ -16,7 +16,7 @@
> >     +----------------------------------------------------------------------+
> >  */
> >
> >-/* $Id: php_bcmath.h,v 1.12 2002/11/22 09:25:28 sander Exp $ */
> >+/* $Id: php_bcmath.h,v 1.13 2002/12/10 19:04:27 pollita Exp $ */
> >
> >  #ifndef PHP_BCMATH_H
> >  #define PHP_BCMATH_H
> >@@ -60,6 +60,7 @@
> >  PHP_FUNCTION(bcsqrt);
> >  PHP_FUNCTION(bccomp);
> >  PHP_FUNCTION(bcscale);
> >+PHP_FUNCTION(bc_powmod);
> >
> >  #else
> >
> >
> >
> >
> >--
> >PHP CVS Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 

-------------------------------------------------------------------------
 Derick Rethans                                 http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals       http://php-mag.net/
-------------------------------------------------------------------------


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to