Compare commits

..
605 changed files with 9551 additions and 34498 deletions

No files matched your search

+8 -46
View File
@@ -5,9 +5,8 @@ PHP Coding Standards
This file lists several standards that any programmer, adding or changing
code in PHP, should follow. Since this file was added at a very late
stage of the development of PHP v3.0, the code base does not (yet) fully
follow it, but it's going in that general direction. Since we are now
well into the version 4 releases, many sections have been recoded to use
these rules.
follow it, but it's going in that general direction.
This is an initial version - it'll most probably grow as time passes.
Code Implementation
@@ -65,24 +64,7 @@ Naming Conventions
------------------
[1] Function names for user functions should be enclosed with in
the PHP_FUNCTION() macro. They should be in lowercase, with words
underscore delimited, with care taken to minimize the letter count.
If they are part of a "parent set" of functions, that parent should
be included in the user function name.
Good:
'mcrypt_enc_self_test'
'mysql_list_fields'
Ok:
'mcrypt_module_get_algo_supported_key_sizes'
(could be 'mcrypt_mod_get_algo_sup_key_sizes'?)
'get_html_translation_table'
(could be 'html_get_trans_table'?)
Bad:
'hw_GetObjectByQueryCollObj'
'pg_setclientencoding'
the PHP_FUNCTION() macro.
[2] Function names used by user functions should be prefixed
with "_php_", and followed by a word or an underscore-delimited list of
@@ -110,32 +92,25 @@ Syntax and indentation
is known to accept C++-style comments in C code.
[2] Use K&R-style. Of course, we can't and don't want to
force anybody to use a style he or she is not used to, but,
force anybody to use a style she's not used to, but
at the very least, when you write code that goes into the core
of PHP or one of its standard modules, please maintain the K&R
style. This applies to just about everything, starting with
indentation and comment styles and up to function decleration
syntax.
[3] Be generous with whitespace and braces. Always prefer:
if (foo) {
[3] Be generous with whitespace and braces. Always prefer
if (foo) {
bar;
}
to:
to
if(foo)bar;
Keep one empty line between the variable decleration section and
the statements in a block, as well as between logical statement
groups in a block. Maintain at least one empty line between
two functions, preferably two.
[4] When indenting, use the tab character. A tab is expected to represent
four spaces. It is important to maintain consistency in indenture so
that definitions, comments, and control structures line up correctly.
Documentation and Folding Hooks
-------------------------------
@@ -170,17 +145,4 @@ Optional arguments are written like this:
And yes, please keep everything on a single line, even if that line is massive.
Aliases & Legacy Documentation
-----------------------------------
You may also have some deprecated aliases with close to duplicate
names, for example, somedb_select_result and somedb_selectresult. For
documentation puposes, these will only be documented by the most
current name, with the aliases listed in the documentation for
the parent function. For ease of reference, user-functions with
completely different names, that alias to the same function (such as
highlight_file and show_source), will be separately documented. The
proto should still be included, describing which function is aliased.
Backwards compatible functions and names should be maintained as long
as the code can be reasonably be kept as part of the codebase. See
/phpdoc/README for me information on documentation.
-3213
View File
File diff suppressed because it is too large. Load diff
+3 -14
View File
@@ -141,7 +141,7 @@ MAINTENANCE: Unknown
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: oci8
PRIMARY MAINTAINER: Thies C. Arntzen <thies@thieso.net>
PRIMARY MAINTAINER: Thies C. Arntzen <thies@digicol.de>
MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
@@ -152,7 +152,7 @@ STATUS: Working
COMMENT: Working except for persistent connections
-------------------------------------------------------------------------------
EXTENSION: oracle
PRIMARY MAINTAINER: Thies C. Arntzen <thies@thieso.net>
PRIMARY MAINTAINER: Thies C. Arntzen <thies@digicol.de>
MAINTENANCE: Maintained
STATUS: Working
COMMENT: Using the new OCI8 driver is encouraged where possible.
@@ -262,11 +262,6 @@ PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>
MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: openssl
PRIMARY MAINTAINER: Stig Venaas <venaas@php.net>
MAINTENANCE: Maintained
STATUS: Experimental
-------------------------------------------------------------------------------
EXTENSION: pcre
PRIMARY MAINTAINER: Andrei Zmievski <andrei@ispi.net>
MAINTENANCE: Maintained
@@ -303,12 +298,6 @@ PRIMARY MAINTAINER: Kristian K
MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: satellite
PRIMARY MAINTAINER: David Eriksson <eriksson@php.net>
MAINTENANCE: Odd Fixes
STATUS: Experimental
SINCE: 4.0.3
-------------------------------------------------------------------------------
EXTENSION: session
PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>
MAINTENANCE: Maintained
@@ -344,7 +333,7 @@ MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: xml
PRIMARY MAINTAINER: Thies C. Arntzen <thies@thieso.net>
PRIMARY MAINTAINER: Thies C. Arntzen <thies@digicol.de>
MAINTENANCE: Maintained
STATUS: Unknown
-------------------------------------------------------------------------------
+1 -128
View File
@@ -1,133 +1,6 @@
PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2000, Version 4.0.4
- Added the is_null() function that will return true if a variable is of
type null. (Sterling)
- Fixed a bug which made readdir() unusable in some systems. (Jani)
- Added the get_defined_functions() function which returns a list of all
currently defined functions. (Sterling)
- Added the get_defined_vars() function which returns an associative array
of all variables defined in the current scope and their subsequent values.
(Sterling)
- Added the call_user_func_array() function which gives you the ability to
call a user function by passing an array of parameters as the second
argument. (Sterling)
- Added the constant() function which returns the value of a constant given
the constant's name. (Sterling)
- Implemented support for Perl-style matching regexp delimiters in PCRE.
You can use <{[( and )]}> to delimit your expressions now. (Andrei)
- Introduced new 'F' modifier in PCRE that lets you specify a function
name in the replacement argument to preg_replace() that will be called
at run-time to provide the replacement string. It is passed an array of
matched pattern and subpatterns. (Andrei)
- Put an end to BUG#4615 (kalowsky & Eric Veldhuyzen)
- Fixed realpath() in Virtual Directory mode (Daniel)
- Integrated the Phil Nelson's bc math library routines into PHP, now that
the license allows it (Phil Nelson <phil@cs.wwu.edu>)
- Added the xslt_set_error_handler() function to the Sablotron extension.
(Sterling)
- Improved Sablotron's error handling system allowing you to catch all
errors before they are outputted to the screen. (Sterling)
- Added OpenSSL extension (Stig Venaas)
- Fixed/created support for Solid 3.0 databases (kalowsky)
- Fixed support for Solid 2.3 databases (kalowsky)
- quoted_printable_decode() function is made RFC-2045 compliant. (Kir)
- Modified preg_grep() to always return the results with keys from the original
array. (Andrei)
- Modified preg_replace() to accept Perl-style $n backreferences in addition
to \\n ones. (Andrei)
- Modified preg_replace() to ignore backreferences that refer to
non-existing subpatterns. (Andrei)
- Fixed column-title buffer-overflow in OCIFetchStatement(). (Thies)
- Added 'output_handler' INI directive (Zeev)
- Fixed some buglets in the output buffering mechanism (Zeev)
- Added transparent gzip compression support (Jade Nicoletti, Zeev)
- Major overhaul of domxml. Added basic XPath support as well (Uwe)
- Added 'r' flag to date() which generates an RFC822 formatted date, e.g.
"Thu, 9 Nov 2000 16:33:01 -0500" (Colin)
- In CGI mode, $HTTP_SERVER_VARS now includes all of the environment variables
as well (Zeev)
- Allow user to use mysql_use_result in mysql queries (Stas)
- Fixed a memory leak that would occur when restarting Apache often
(mookid@sigent.ru)
- Fixed a bug that prevented $argv and $argc from being defined in the command
line version of PHP (Stas)
- Fixed a bug that prevented a changed compile-time extension_dir from
affecting modules that were loaded via php.ini (Zeev)
- Fixed a bug in ftp_mkdir() when used on ftp server which doesn't return
the full path (Jani)
- Added ImageCreateFromString() which creates an image stream out of
e.g. a MySQL blob. (Mathieu)
- Changed the sablot configuration file so that if you use any version of
Sablotron below 0.44 you must use Sablotron's built-in Expat libraries.
(Sterling)
- Added basic authentication support to thttpd (Sascha)
- Added support for the Caudium webserver (http://caudium.net/). It's based
on the Roxen SAPI module. Many bugs have been identified and fixed. (David)
- Fixed mysql_close(), pg_close(), msql_close() and sybase_close() - they
weren't properly closing the SQL connections (Zeev)
- Fixed crypt() to supply random seed if none is given (Andi)
- Made print_r() support recursive data structures, e.g. $GLOBALS. (Zeev)
- Fixed a bug that caused PHP not to properly flush its output buffer, if more
than one output buffer was used. (Zeev)
- Fixed a bug that could draw the shutdown sequence of the PHP Apache module
into an endless loop, under certain circumstances. It could cause Apache
processes under Solaris to get stuck, especially when using output
buffering. (Zeev)
- Added support for serializing references (Stas)
- Fixed conflict with OpenLDAP and Oracle 8.1.x (Jani)
- parse_ini_file() supports a new optional 2nd argument that instructs it
to divide the directives to arrays according to the sections in which they
reside (Zeev)
- parse_ini_file() is now thread-safe, and supported under Windows (Zeev)
- Unified aborted-connection semantics of all SAPI modules (Sascha)
- URL-opened files now store the HTTP response header in $http_response_header
(Zeev)
- Fixed array_rand() to shuffle results when the number of requested
elements is the same as the number of elements in the array. (Andrei)
- Added replace parameter to header() (Sascha)
- Fixed handling of single quotes in transparent session-id mode (Sascha)
- Fixed "php://*" fopen handler (Sascha)
- Made rename work in threadsafe enviroments (Daniel)
- Made session_destroy() close files before unlinking (Daniel)
- Added array_sum() function. (Andrei)
- Fixed a bug in session.c. The php_session_save_current_state did not check
if mod_data is NULL and such situation is possible if the user calls
session_module_name with a parameter. (alex@zend.com)
- Added IIS Admin extension. (Frank)
- OCIBindByName() now does better parameter-checking. (Thies)
- Made read() binary-safe in sockets.c (Chris Vandomelen)
- Made array_intersect() and array_diff() not alter order (Stig Venaas)
- Made ldap_connect() accept URL in host parameter when using OpenLDAP
2.x. To use SSL, use ldaps://host/ as URL. (Stig Venaas)
- Made resource type names visible, e.g. var_dump() and
get_resource_type() display "file" for file resources. (Andrei)
- Added the curl_getinfo() function to find out information about a CURL
transfer. This function requires cURL 7.4.0 or above. (Sterling)
- Added the CURLOPT_KRB4, CURLOPT_INTERFACE, CURLOPT_QUOTE, CURLOPT_POSTQUOTE,
CURLOPT_QUOTE and CURLOPT_HTTPPROXYTUNNELL options. (Sterling)
- Renamed the shm_* functions to shmop_* (Derick)
- Updated ext/mysql/libmysql to version 3.23 (tim@mysql.com)
- Added ldap_get_option() and ldap_set_option() functions (Stig Venaas)
- Fixed a crash in CGI mode, in case no file was provided
(Daniel Beulshausen& Zeev)
- Fixed possible crash bug in imap_fetchstructure() (Jani)
- Fixed possible crash bug in imap_open() (Jani & Mark Musone)
- Added url_rewriter.tags configuration directive (Sascha)
- Added CORBA client extension, ready for use (eriksson@php.net)
- Fixed memory leak in x-httpd-source mode (Jason Greene)
- Changed ext/gd not to be enabled by default (Jani)
- Make increment of empty string ("") behave like in PHP 3 and result in "1"
(Andi, Zend Engine)
- Added POST handler for Adobe FDF format (Hartmut)
- Added transparent read and write .gz-files on glibc based systems
using the 'zlib:' fopen wrapper (Hartmut)
- Fixed a problem in the configuration parser (two null bytes were added
to each ENCAPSULATED TC_STRING) (alex@zend.com)
- Added HMAC support in the mhash module (nmav@altera.gr)
- Added module for Ovrimos sql server (nmav@altera.gr)
11 Oct 2000, Version 4.0.3
- Fixed a possible crash in -a interactive mode (Zeev, Zend Engine)
- Added mysql_escape_string() (Peter A. Savitch and & Brian Wang)
@@ -145,7 +18,7 @@ PHP 4.0 NEWS
(Rasmus)
- Fixed possible crash bug in parse_url() (Andi)
- Added support for trans sid under Win32 (Daniel)
- Added IPv6 support in fopen (Stig Venaas)
- IPv6 support in fopen (Stig Venaas)
- Added the shmop extension. It allows more general ways of shared memory
access. (thanks to Ilia Alshanestky <iliaa@home.com> and Slava Poliakov
<slavapl@mailandnews.com> (Derick)
+1 -5
View File
@@ -51,13 +51,9 @@ FORMAT OF FUNCTION DEFINITIONS FILE
']'s as there where '['s. Currently, it does not harm if you forget to do it
or there is a wrong amount of ']'s, but this may change in the future.
An additional short description may be added after the parameters.
If present it will be filled into the 'proto' header comments in the stubs
code and the <refpurpose> tag in the XML documentation.
An example:
my_function(int arg1, int arg2 [, int arg3 [, int arg4]]) this is my 1st
my_function(int arg1, int arg2 [, int arg3 [, int arg4]])
Arguments arg3 and arg4 are optional.
+2 -53
View File
@@ -86,28 +86,6 @@ the 'configure' program to set up PHP; LDFLAGS and EXTRA_LIBS. Make
sure that you also export these variables to the build process.
(Type 'export LDFLAGS EXTRA_LIBS' in the shell to do this.)
If you are using 3rd party tools and libraries which are installed
in non-standard locations, you may need to set the environment
variable LD_LIBRARY_PATH to point to the library's location, prior
to running the Zeus Web Server. For example, if you have compiled
external MySQL support, and mysql is installed in /usr/local/mysql,
you should set LD_LIBRARY_PATH to '/usr/local/mysql/lib/mysql'
and then 'export LD_LIBRARY_PATH'. For convenience, you should add
this to the 'start-zeus' script provided.
Yet another method of ensuring the linked libraries are found is to
set the environment variable LD_RUN_PATH before compiling PHP. This
works in a similar way to LD_LIBRARY_PATH, but at compile-time.
Libraries produced with this envrionment variable set will have its
value 'burned' into the resultant binary, specifying a runtime
search pth to locate other required libraries such as MySQL.
On Linux, you can also tell the dynamic linker where to find the
libraries, by adding '/usr/local/mysql/lib/mysql' to the file
/etc/ld.so.conf - after editting this file, run 'ldconfig' as root,
to use the changes.
Specific examples:
Solaris + gcc:
@@ -115,39 +93,10 @@ Ensure you run ./configure with the `--enable-libgcc' parameter. You
may need to set LDFLAGS to '-L/usr/local/egcs/lib' (path depends on
your gcc installation)
FreeBSD 4:
FreeBSD 4.0:
Some people may find they need to run ./configure with the
'--enable-libgcc' compile option too.
Performance issues
==================
To make PHP run fast under Zeus, check the following points:
1) Run PHP as an ISAPI module, not a CGI - compile it with the --with-zeus=...
flag!
2) Tune the ISAPI runner to your required workload. There are several
tuneables that can be given. These are set by adding the appropriate
lines to the $ZEUSHOME/web/global.cfg file. Changes to this file will only
be picked up after the web server is restarted (run stop-zeus ; start-zeus)
tuning!modules!isapi!external!maxthreads xxx
- Sets the maximum number of threads that the ISAPI runner will spawn. If
further PHP page requests arrive, they will be queued until a current
page is finished. For busy websites, we suggest increasing this value
(defaults to 16). Replace the 'xxx' in the above line with the required
number of threads. Note that the threads are equally shared between
ISAPI extensions and filters, so if you want to handle 100 concurrent
PHP page requests, set this tuneable to 200.
tuning!modules!isapi!external!minthreads xxx
- Sets the minimum number of threads. Idle threads will be kept in a pool,
which avoids costly thread creation/deletion.
For more information and help with Zeus, please visit our website:
http://support.zeus.com
http://www.zeus.com
+7 -8
View File
@@ -7,10 +7,6 @@ Zend
traverse an array without copying each element.
* look at replacing c-lib call tolower().
* make hash API functions work with HASH_OF() to save time.
* native large number support (probably with GNU GMP)
* Const'ify APIs. Right now, many functions leave parameters untouched,
but don't declare those as const. This makes interaction with other
interfaces difficult which pass const parameters to us.
global
------
@@ -20,6 +16,7 @@ global
* make sure all source files have the "right" copyright.
* the following modules still use PHP3_TLS_*() macros (and thereby don't
work in ZTS mode): ext/dav/dav.c, ext/db/db.c, ext/gd/gd.c, ext/ldap/ldap.c
* INI system causes segfaults in ZTS mode (operates on static HashTable)
* make sure that all ZTS globals get destructed. Most ts_allocate_id()
calls should have a dtor entry.
* activate all extensions by default that don't rely on external
@@ -27,7 +24,7 @@ global
* --enable-all in configure. (--enable-shared=max ...)
* make configure print out a summary when it's done (like XEmacs)
* replace standard functions which work on static data with
reentrancy-safe functions (DONE?).
reentrancy-safe functions.
* on some platforms unimplemented function will just do nothing (e.g. symlink)
they should print a warning or not even be defined!
* implement javadoc based function docs template system.
@@ -53,6 +50,10 @@ ext/dav
--------
* rewrite.
ext/mcrypt
----------
* port to mcrypt-2.6 or later
ext/oci8
--------
* all OCIFetch*() functions should return 0 for no more data and false on error.
@@ -61,6 +62,7 @@ ext/oci8
ext/pcre
--------
* have an option for preg_grep() to return keys as well.
* update the online docs from version 3.1 man page
ext/session
@@ -74,7 +76,6 @@ ext/session
ext/standard
------------
* array_mean()
* add a version number to data serialized via serialize().
* array_add(). (Andrei)
* possibly modify parsing of GPC data to automatically create arrays if
@@ -90,8 +91,6 @@ ext/standard
strrpos()
strrchr()
strip_tags()
* rewrite win32 SMTP code to be useable for *ix to, maybe as a (default)
module of its own (Hartmut)
ext/wddx
--------
+33 -76
View File
@@ -38,16 +38,13 @@ typedef struct {
} tsrm_resource_type;
#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
#define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1)
/* The memory manager table */
static tsrm_tls_entry **tsrm_tls_table=NULL;
static tsrm_tls_entry **tsrm_tls_table;
static int tsrm_tls_table_size;
static ts_rsrc_id id_count;
/* The resource sizes table */
static tsrm_resource_type *resource_types_table=NULL;
static tsrm_resource_type *resource_types_table;
static int resource_types_table_size;
@@ -58,31 +55,20 @@ static void (*tsrm_new_thread_begin_handler)();
static void (*tsrm_new_thread_end_handler)();
/* Debug support */
int tsrm_error(int level, const char *format, ...);
static int tsrm_error_level;
static FILE *tsrm_error_file;
#if TSRM_DEBUG
#define TSRM_ERROR tsrm_error
#define TSRM_SAFE_ARRAY_OFFSET(array, offset, range) (((offset)>=0 && (offset)<(range)) ? array[offset] : NULL)
#else
#define TSRM_ERROR
#define TSRM_SAFE_ARRAY_OFFSET(array, offset, range) array[offset]
#endif
static int tsrm_debug(const char *format, ...);
static int tsrm_debug_status;
/* Startup TSRM (call once for the entire process) */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename)
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_status)
{
#if defined(GNUPTH)
pth_init();
#endif
tsrm_error_file = stderr;
tsrm_error_set(debug_level, debug_filename);
tsrm_tls_table_size = expected_threads;
tsrm_tls_table = (tsrm_tls_entry **) calloc(tsrm_tls_table_size, sizeof(tsrm_tls_entry *));
if (!tsrm_tls_table) {
TSRM_ERROR(TSRM_ERROR_LEVEL_ERROR, "Unable to allocate TLS table");
return 0;
}
id_count=0;
@@ -90,9 +76,7 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
resource_types_table_size = expected_resources;
resource_types_table = (tsrm_resource_type *) calloc(resource_types_table_size, sizeof(tsrm_resource_type));
if (!resource_types_table) {
TSRM_ERROR(TSRM_ERROR_LEVEL_ERROR, "Unable to allocate resource types table");
free(tsrm_tls_table);
tsrm_tls_table = NULL;
return 0;
}
@@ -100,7 +84,9 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
tsrm_new_thread_begin_handler = tsrm_new_thread_end_handler = NULL;
TSRM_ERROR(TSRM_ERROR_LEVEL_CORE, "Started up TSRM, %d expected threads, %d expected resources", expected_threads, expected_resources);
tsrm_debug_status = debug_status;
tsrm_debug("Started up TSRM, %d expected threads, %d expected resources\n", expected_threads, expected_resources);
return 1;
}
@@ -127,18 +113,12 @@ TSRM_API void tsrm_shutdown(void)
}
}
free(tsrm_tls_table);
tsrm_tls_table = NULL;
}
if (resource_types_table) {
free(resource_types_table);
resource_types_table=NULL;
}
tsrm_mutex_free(tsmm_mutex);
tsmm_mutex = NULL;
TSRM_ERROR(TSRM_ERROR_LEVEL_CORE, "Shutdown TSRM");
if (tsrm_error_file!=stderr) {
fclose(tsrm_error_file);
}
tsrm_debug("Shutdown TSRM\n");
#if defined(GNUPTH)
pth_kill();
#endif
@@ -151,21 +131,19 @@ TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_alloca
ts_rsrc_id new_id;
int i;
TSRM_ERROR(TSRM_ERROR_LEVEL_CORE, "Obtaining a new resource id, %d bytes", size);
tsrm_debug("Obtaining a new resource id, %d bytes\n", size);
tsrm_mutex_lock(tsmm_mutex);
/* obtain a resource id */
new_id = id_count++;
TSRM_ERROR(TSRM_ERROR_LEVEL_CORE, "Obtained resource id %d", TSRM_SHUFFLE_RSRC_ID(new_id));
tsrm_debug("Obtained resource id %d\n", new_id);
/* store the new resource type in the resource sizes table */
if (resource_types_table_size < id_count) {
resource_types_table = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count);
if (!resource_types_table) {
tsrm_mutex_unlock(tsmm_mutex);
TSRM_ERROR(TSRM_ERROR_LEVEL_ERROR, "Unable to allocate storage for resource");
return 0;
return -1;
}
resource_types_table_size = id_count;
}
@@ -195,8 +173,8 @@ TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_alloca
}
tsrm_mutex_unlock(tsmm_mutex);
TSRM_ERROR(TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d", TSRM_SHUFFLE_RSRC_ID(new_id));
return TSRM_SHUFFLE_RSRC_ID(new_id);
tsrm_debug("Successfully allocated new resource id %d\n", new_id);
return new_id;
}
@@ -204,7 +182,6 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
{
int i;
TSRM_ERROR(TSRM_ERROR_LEVEL_CORE, "Creating data structures for thread %x", thread_id);
(*thread_resources_ptr) = (tsrm_tls_entry *) malloc(sizeof(tsrm_tls_entry));
(*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count);
(*thread_resources_ptr)->count = id_count;
@@ -241,7 +218,7 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
} else {
thread_id = tsrm_thread_id();
}
TSRM_ERROR(TSRM_ERROR_LEVEL_INFO, "Fetching resource id %d for thread %ld", id, (long) thread_id);
tsrm_debug("Fetching resource id %d for thread %ld\n", id, (long) thread_id);
tsrm_mutex_lock(tsmm_mutex);
hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
@@ -269,15 +246,11 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
} while (thread_resources);
}
resource = TSRM_SAFE_ARRAY_OFFSET(thread_resources->storage, TSRM_UNSHUFFLE_RSRC_ID(id), thread_resources->count);
resource = thread_resources->storage[id];
tsrm_mutex_unlock(tsmm_mutex);
if (resource) {
TSRM_ERROR(TSRM_ERROR_LEVEL_INFO, "Successfully fetched resource id %d for thread id %ld - %x", id, (long) thread_id, (long) resource);
} else {
TSRM_ERROR(TSRM_ERROR_LEVEL_ERROR, "Resource id %d is out of range (%d..%d)", id, TSRM_SHUFFLE_RSRC_ID(0), TSRM_SHUFFLE_RSRC_ID(thread_resources->count-1));
}
tsrm_debug("Successfully fetched resource id %d for thread id %ld - %x\n", id, (long) thread_id, (long) resource);
return resource;
}
@@ -352,7 +325,7 @@ TSRM_API THREAD_T tsrm_thread_id(void)
/* Allocate a mutex */
TSRM_API MUTEX_T tsrm_mutex_alloc(void)
TSRM_API MUTEX_T tsrm_mutex_alloc( void )
{
MUTEX_T mutexp;
@@ -378,7 +351,7 @@ TSRM_API MUTEX_T tsrm_mutex_alloc(void)
/* Free a mutex */
TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
TSRM_API void tsrm_mutex_free( MUTEX_T mutexp )
{
if (mutexp) {
#ifdef TSRM_WIN32
@@ -401,9 +374,11 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
/* Lock a mutex */
TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
TSRM_API int tsrm_mutex_lock( MUTEX_T mutexp )
{
TSRM_ERROR(TSRM_ERROR_LEVEL_INFO, "Mutex locked thread: %ld", tsrm_thread_id());
#if 0
tsrm_debug("Mutex locked thread: %ld\n",tsrm_thread_id());
#endif
#ifdef TSRM_WIN32
EnterCriticalSection(mutexp);
return 1;
@@ -420,9 +395,11 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
/* Unlock a mutex */
TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
TSRM_API int tsrm_mutex_unlock( MUTEX_T mutexp )
{
TSRM_ERROR(TSRM_ERROR_LEVEL_INFO, "Mutex unlocked thread: %ld", tsrm_thread_id());
#if 0
tsrm_debug("Mutex unlocked thread: %ld\n",tsrm_thread_id());
#endif
#ifdef TSRM_WIN32
LeaveCriticalSection(mutexp);
return 1;
@@ -461,45 +438,25 @@ TSRM_API void *tsrm_set_new_thread_end_handler(void (*new_thread_end_handler)(TH
* Debug support
*/
#if TSRM_DEBUG
int tsrm_error(int level, const char *format, ...)
static int tsrm_debug(const char *format, ...)
{
if (level<=tsrm_error_level) {
if (tsrm_debug_status) {
va_list args;
int size;
fprintf(tsrm_error_file, "TSRM: ");
va_start(args, format);
size = vfprintf(tsrm_error_file, format, args);
size = vprintf(format, args);
va_end(args);
fprintf(tsrm_error_file, "\n");
fflush(tsrm_error_file);
return size;
} else {
return 0;
}
}
#endif
void tsrm_error_set(int level, char *debug_filename)
void tsrm_debug_set(int status)
{
tsrm_error_level = level;
#if TSRM_DEBUG
if (tsrm_error_file!=stderr) { /* close files opened earlier */
fclose(tsrm_error_file);
}
if (debug_filename) {
tsrm_error_file = fopen(debug_filename, "w");
if (!tsrm_error_file) {
tsrm_error_file = stderr;
}
} else {
tsrm_error_file = stderr;
}
#endif
tsrm_debug_status = status;
}
#endif /* ZTS */
+3 -3
View File
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Debug_TS"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "C:\Projects\TSRM" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_DEBUG" /D "ZTS" /D "_LIB" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /D TSRM_DEBUG=1 /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_DEBUG" /D "ZTS" /D "_LIB" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x40d /d "_DEBUG"
# ADD RSC /l 0x40d /d "_DEBUG"
BSC32=bscmake.exe
@@ -65,7 +65,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Release_TS"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "ZTS" /D "_LIB" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /D TSRM_DEBUG=0 /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "ZTS" /D "_LIB" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x40d /d "NDEBUG"
# ADD RSC /l 0x40d /d "NDEBUG"
BSC32=bscmake.exe
@@ -88,7 +88,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Release_TS_inline"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "TSRM_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "ZTS" /D "_LIB" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /D TSRM_DEBUG=0 /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "ZTS" /D "_LIB" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x40d /d "NDEBUG"
# ADD RSC /l 0x40d /d "NDEBUG"
BSC32=bscmake.exe
+2 -6
View File
@@ -77,7 +77,7 @@ extern "C" {
#endif
/* startup/shutdown */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename);
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_status);
TSRM_API void tsrm_shutdown(void);
/* allocates a new thread-safe-resource id */
@@ -95,11 +95,7 @@ TSRM_API void ts_free_id(ts_rsrc_id id);
/* Debug support */
#define TSRM_ERROR_LEVEL_ERROR 1
#define TSRM_ERROR_LEVEL_CORE 2
#define TSRM_ERROR_LEVEL_INFO 3
TSRM_API int tsrm_error(int level, const char *format, ...);
TSRM_API void tsrm_error_set(int level, char *debug_filename);
TSRM_API void tsrm_debug_set(int status);
/* utility functions */
TSRM_API THREAD_T tsrm_thread_id(void);
+4 -32
View File
@@ -199,7 +199,7 @@ CWD_API void virtual_cwd_shutdown(void)
free(main_cwd_state.cwd); /* Don't use CWD_STATE_FREE because the non global states will probably use emalloc()/efree() */
}
CWD_API char *virtual_getcwd_ex(size_t *length)
CWD_API char *virtual_getcwd_ex(int *length)
{
cwd_state *state;
CWDLS_FETCH();
@@ -442,7 +442,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path)
CWD_STATE_COPY(&new_state, &CWDG(cwd));
retval = virtual_file_ex(&new_state, path, NULL);
if (!retval) {
if(retval) {
int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length;
memcpy(real_path, new_state.cwd, len);
real_path[len] = '\0';
@@ -452,24 +452,18 @@ CWD_API char *virtual_realpath(const char *path, char *real_path)
return NULL;
}
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path)
CWD_API int virtual_filepath(const char *path, char **filepath)
{
cwd_state new_state;
int retval;
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
retval = virtual_file_ex(&new_state, path, verify_path);
retval = virtual_file_ex(&new_state, path, php_is_file_ok);
*filepath = new_state.cwd;
return retval;
}
CWD_API int virtual_filepath(const char *path, char **filepath)
{
return virtual_filepath_ex(path, filepath, php_is_file_ok);
}
CWD_API FILE *virtual_fopen(const char *path, const char *mode)
@@ -580,28 +574,6 @@ CWD_API int virtual_creat(const char *path, mode_t mode)
return f;
}
CWD_API int virtual_rename(char *oldname, char *newname)
{
cwd_state old_state;
cwd_state new_state;
int retval;
CWDLS_FETCH();
CWD_STATE_COPY(&old_state, &CWDG(cwd));
virtual_file_ex(&old_state, oldname, NULL);
oldname = old_state.cwd;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, newname, NULL);
newname = new_state.cwd;
retval = rename(oldname, newname);
CWD_STATE_FREE(&old_state);
CWD_STATE_FREE(&new_state);
return retval;
}
CWD_API int virtual_stat(const char *path, struct stat *buf)
{
+2 -6
View File
@@ -44,7 +44,7 @@
#include "readdir.h"
#include <sys/utime.h>
/* mode_t isn't defined on Windows */
typedef unsigned short mode_t;
typedef int mode_t;
#define DEFAULT_SLASH '\\'
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
@@ -95,17 +95,15 @@ typedef int (*verify_path_func)(const cwd_state *);
CWD_API void virtual_cwd_startup(void);
CWD_API void virtual_cwd_shutdown(void);
CWD_API char *virtual_getcwd_ex(size_t *length);
CWD_API char *virtual_getcwd_ex(int *length);
CWD_API char *virtual_getcwd(char *buf, size_t size);
CWD_API int virtual_chdir(const char *path);
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path));
CWD_API int virtual_filepath(const char *path, char **filepath);
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path);
CWD_API char *virtual_realpath(const char *path, char *real_path);
CWD_API FILE *virtual_fopen(const char *path, const char *mode);
CWD_API int virtual_open(const char *path, int flags, ...);
CWD_API int virtual_creat(const char *path, mode_t mode);
CWD_API int virtual_rename(char *oldname, char *newname);
CWD_API int virtual_stat(const char *path, struct stat *buf);
#ifndef TSRM_WIN32
CWD_API int virtual_lstat(const char *path, struct stat *buf);
@@ -161,7 +159,6 @@ typedef struct _virtual_cwd_globals {
#define V_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir)
#define V_GETWD(buf)
#define V_REALPATH(path,real_path) virtual_realpath(path,real_path)
#define V_RENAME(oldname,newname) virtual_rename(oldname,newname)
#define V_STAT(path, buff) virtual_stat(path, buff)
#ifdef TSRM_WIN32
#define V_LSTAT(path, buff) virtual_stat(path, buff)
@@ -187,7 +184,6 @@ typedef struct _virtual_cwd_globals {
#define V_FOPEN(path, mode) fopen(path, mode)
#define V_OPEN(open_args) open open_args
#define V_CREAT(path, mode) creat(path, mode)
#define V_RENAME(oldname,newname) rename(oldname,newname)
#define V_CHDIR(path) chdir(path)
#define V_CHDIR_FILE(path) virtual_chdir_file(path, chdir)
#define V_GETWD(buf) getwd(buf)
+13 -32
View File
@@ -1,23 +1,21 @@
## Process this file with automake to produce Makefile.in -*- makefile -*-
#CLEANFILES = zend_language_parser.c zend_language_parser.h zend_language_scanner.c zend_language_parser.output zend_ini_parser.c zend_ini_parser.h zend_ini_scanner.c zend_ini_parser.output
#CLEANFILES = zend-parser.c zend-parser.h zend-scanner.c zend-parser.output
AUTOMAKE_OPTIONS=foreign
EXTRA_LTLIBRARIES=libZend_cc.la libZend_c.la
noinst_LTLIBRARIES=$(ZEND_SCANNER) libZend.la
libZend_cc_la_SOURCES=zend_language_scanner_cc.cc zend_ini_scanner_cc.cc
libZend_c_la_SOURCES=zend_language_scanner.c zend_ini_scanner.c
libZend_cc_la_SOURCES=zend-scanner-cc.cc
libZend_c_la_SOURCES=zend-scanner.c
libZend_la_SOURCES=\
zend_language_parser.y \
zend_ini_parser.y \
zend-parser.y \
zend_alloc.c zend_compile.c zend_constants.c zend_dynamic_array.c \
zend_execute.c zend_execute_API.c zend_highlight.c zend_llist.c \
zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \
zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
zend_ini.c
zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c
libZend_la_LIBADD = $(ZEND_SCANNER)
libZend_la_LDFLAGS = @EXTRA_LIBS@
@@ -25,36 +23,19 @@ libZend_la_DEPENDENCIES = $(ZEND_SCANNER)
# automake isn't too clever about "non-standard" use of lex and yacc
$(libZend_la_OBJECTS) zend_language_scanner.lo zend_language_scanner_cc.lo: zend_language_parser.h
$(libZend_la_OBJECTS) zend-scanner.lo zend-scanner-cc.lo: zend-parser.h
zend_ini_scanner.lo zend_ini_scanner_cc.lo: zend_ini_parser.h
zend-scanner.c: $(srcdir)/zend-scanner.l
$(LEX) -Pzend -o$@ -i $(srcdir)/zend-scanner.l
# Language parser/scanner rules
zend-scanner-cc.cc: $(srcdir)/zend-scanner.l
$(LEX) -+ -B -i -S$(srcdir)/flex.skl -Pzend -o$@ $(srcdir)/zend-scanner.l
zend_language_scanner.c: $(srcdir)/zend_language_scanner.l
$(LEX) -Pzend -o$@ -i $(srcdir)/zend_language_scanner.l
zend_language_scanner_cc.cc: $(srcdir)/zend_language_scanner.l
$(LEX) -+ -B -i -S$(srcdir)/flex.skl -Pzend -o$@ $(srcdir)/zend_language_scanner.l
zend_language_parser.h: zend_language_parser.c
zend_language_parser.c: $(srcdir)/zend_language_parser.y
$(YACC) -p zend -v -d $(srcdir)/zend_language_parser.y -o zend_language_parser.c
# INI parser/scanner rules
zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
$(YACC) -p ini_ -v -d $(srcdir)/zend_ini_parser.y -o zend_ini_parser.c
zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
$(LEX) -Pini_ -o$@ -i $(srcdir)/zend_ini_scanner.l
zend_ini_scanner_cc.cc: $(srcdir)/zend_ini_scanner.l
$(LEX) -+ -B -i -S$(srcdir)/flex.skl -Pini_ -o$@ $(srcdir)/zend_ini_scanner.l
zend_ini_parser.h: zend_ini_parser.c
zend-parser.h: zend-parser.c
zend-parser.c: $(srcdir)/zend-parser.y
$(YACC) -p zend -v -d $(srcdir)/zend-parser.y -o zend-parser.c
depend:
zend_execute.lo: $(srcdir)/zend_execute.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(INLINE_CFLAGS) -c $(srcdir)/zend_execute.c
-1
View File
@@ -109,4 +109,3 @@ shamelessly lying about it. Here's why:
This incompatability is due to the full variable reference
within quoted strings feature added in Zend.
+46 -108
View File
@@ -107,6 +107,14 @@ LIB32=link.exe -lib
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=".\zend-parser.c"
# End Source File
# Begin Source File
SOURCE=".\zend-scanner.c"
# End Source File
# Begin Source File
SOURCE=.\zend.c
# End Source File
# Begin Source File
@@ -143,6 +151,10 @@ SOURCE=.\zend_extensions.c
# End Source File
# Begin Source File
SOURCE=.\zend_gcc_inline.c
# End Source File
# Begin Source File
SOURCE=.\zend_hash.c
# End Source File
# Begin Source File
@@ -155,26 +167,6 @@ SOURCE=.\zend_indent.c
# End Source File
# Begin Source File
SOURCE=.\zend_ini.c
# End Source File
# Begin Source File
SOURCE=.\zend_ini_parser.c
# End Source File
# Begin Source File
SOURCE=.\zend_ini_scanner.c
# End Source File
# Begin Source File
SOURCE=".\zend_language_parser.c"
# End Source File
# Begin Source File
SOURCE=".\zend_language_scanner.c"
# End Source File
# Begin Source File
SOURCE=.\zend_list.c
# End Source File
# Begin Source File
@@ -219,6 +211,14 @@ SOURCE=.\modules.h
# End Source File
# Begin Source File
SOURCE=".\zend-parser.h"
# End Source File
# Begin Source File
SOURCE=".\zend-scanner.h"
# End Source File
# Begin Source File
SOURCE=.\zend.h
# End Source File
# Begin Source File
@@ -279,18 +279,6 @@ SOURCE=.\zend_indent.h
# End Source File
# Begin Source File
SOURCE=.\zend_ini.h
# End Source File
# Begin Source File
SOURCE=".\zend_language_parser.h"
# End Source File
# Begin Source File
SOURCE=".\zend_language_scanner.h"
# End Source File
# Begin Source File
SOURCE=.\zend_list.h
# End Source File
# Begin Source File
@@ -319,52 +307,23 @@ SOURCE=.\zend_variables.h
# PROP Default_Filter "y"
# Begin Source File
SOURCE=.\zend_ini_parser.y
!IF "$(CFG)" == "Zend - Win32 Release"
!ELSEIF "$(CFG)" == "Zend - Win32 Debug"
# Begin Custom Build
InputDir=.
InputPath=.\zend_ini_parser.y
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p ini_ zend_ini_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p ini_ zend_ini_parser.y \
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "Zend - Win32 Release_inline"
!ENDIF
# End Source File
# Begin Source File
SOURCE=".\zend_language_parser.y"
SOURCE=".\zend-parser.y"
!IF "$(CFG)" == "Zend - Win32 Release"
# Begin Custom Build
InputDir=.
InputPath=".\zend_language_parser.y"
InputPath=".\zend-parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend_language_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend_language_parser.y \
if not "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend-parser.y \
if "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend-parser.y \
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
@@ -372,17 +331,17 @@ BuildCmds= \
# Begin Custom Build
InputDir=.
InputPath=".\zend_language_parser.y"
InputPath=".\zend-parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend_language_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend_language_parser.y \
if not "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend-parser.y \
if "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend-parser.y \
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
@@ -390,17 +349,17 @@ BuildCmds= \
# Begin Custom Build
InputDir=.
InputPath=".\zend_language_parser.y"
InputPath=".\zend-parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend_language_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend_language_parser.y \
if not "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend-parser.y \
if "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend-parser.y \
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
@@ -413,56 +372,35 @@ BuildCmds= \
# PROP Default_Filter "l"
# Begin Source File
SOURCE=.\zend_ini_scanner.l
!IF "$(CFG)" == "Zend - Win32 Release"
!ELSEIF "$(CFG)" == "Zend - Win32 Debug"
# Begin Custom Build
InputPath=.\zend_ini_scanner.l
"zend_ini_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.c zend_ini_scanner.l
# End Custom Build
!ELSEIF "$(CFG)" == "Zend - Win32 Release_inline"
!ENDIF
# End Source File
# Begin Source File
SOURCE=".\zend_language_scanner.l"
SOURCE=".\zend-scanner.l"
!IF "$(CFG)" == "Zend - Win32 Release"
# Begin Custom Build
InputPath=".\zend_language_scanner.l"
InputPath=".\zend-scanner.l"
"zend_language_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -i -Pzend -ozend_language_scanner.c zend_language_scanner.l
"zend-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -i -Pzend -ozend-scanner.c zend-scanner.l
# End Custom Build
!ELSEIF "$(CFG)" == "Zend - Win32 Debug"
# Begin Custom Build
InputPath=".\zend_language_scanner.l"
InputPath=".\zend-scanner.l"
"zend_language_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -i -Pzend -ozend_language_scanner.c zend_language_scanner.l
"zend-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -i -Pzend -ozend-scanner.c zend-scanner.l
# End Custom Build
!ELSEIF "$(CFG)" == "Zend - Win32 Release_inline"
# Begin Custom Build
InputPath=".\zend_language_scanner.l"
InputPath=".\zend-scanner.l"
"zend_language_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -i -Pzend -ozend_language_scanner.c zend_language_scanner.l
"zend-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -i -Pzend -ozend-scanner.c zend-scanner.l
# End Custom Build
+2 -2
View File
@@ -6,8 +6,8 @@ if test "$YACC" != "bison -y"; then
else
AC_MSG_CHECKING(bison version)
set `bison --version| sed -e 's/^GNU Bison version //' -e 's/\./ /'`
if test "${1}" = "1" -a "${2}" -lt "28"; then
AC_MSG_WARN(You will need bison 1.28 if you want to regenerate the Zend parser (found ${1}.${2}).)
if test "${1}" = "1" -a "${2}" -lt "25"; then
AC_MSG_WARN(You will need bison 1.25 if you want to regenerate the Zend parser (found ${1}.${2}).)
fi
AC_MSG_RESULT(${1}.${2} (ok))
fi
+1 -1
View File
@@ -86,7 +86,7 @@
".\zend_llist.h"\
".\zend_ptr_stack.h"\
".\zend_stack.h"\
".\zend_language_parser.tab.h"\
".\zend-parser.tab.h"\
".\zend.h"\
".\zend_errors.h"\
".\zend_globals.h"\
+42 -164
View File
@@ -107,6 +107,14 @@ LIB32=link.exe -lib
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=".\zend-parser.c"
# End Source File
# Begin Source File
SOURCE=".\zend-scanner.cpp"
# End Source File
# Begin Source File
SOURCE=.\zend.c
# End Source File
# Begin Source File
@@ -159,26 +167,6 @@ SOURCE=.\zend_indent.c
# End Source File
# Begin Source File
SOURCE=.\zend_ini.c
# End Source File
# Begin Source File
SOURCE=.\zend_ini_parser.c
# End Source File
# Begin Source File
SOURCE=.\zend_ini_scanner.cpp
# End Source File
# Begin Source File
SOURCE=".\zend_language_parser.c"
# End Source File
# Begin Source File
SOURCE=".\zend_language_scanner.cpp"
# End Source File
# Begin Source File
SOURCE=.\zend_list.c
# End Source File
# Begin Source File
@@ -223,6 +211,14 @@ SOURCE=.\modules.h
# End Source File
# Begin Source File
SOURCE=".\zend-parser.h"
# End Source File
# Begin Source File
SOURCE=".\zend-scanner.h"
# End Source File
# Begin Source File
SOURCE=.\zend.h
# End Source File
# Begin Source File
@@ -295,26 +291,6 @@ SOURCE=.\zend_indent.h
# End Source File
# Begin Source File
SOURCE=.\zend_ini.h
# End Source File
# Begin Source File
SOURCE=.\zend_ini_parser.h
# End Source File
# Begin Source File
SOURCE=.\zend_ini_scanner.h
# End Source File
# Begin Source File
SOURCE=".\zend_language_parser.h"
# End Source File
# Begin Source File
SOURCE=".\zend_language_scanner.h"
# End Source File
# Begin Source File
SOURCE=.\zend_list.h
# End Source File
# Begin Source File
@@ -343,23 +319,23 @@ SOURCE=.\zend_variables.h
# PROP Default_Filter "y"
# Begin Source File
SOURCE=.\zend_ini_parser.y
SOURCE=".\zend-parser.y"
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
# Begin Custom Build
InputDir=.
InputPath=.\zend_ini_parser.y
InputPath=".\zend-parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p ini_ zend_ini_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p ini_ zend_ini_parser.y \
if not "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend-parser.y \
if "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend-parser.y \
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
@@ -367,17 +343,17 @@ BuildCmds= \
# Begin Custom Build
InputDir=.
InputPath=.\zend_ini_parser.y
InputPath=".\zend-parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p ini_ zend_ini_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p ini_ zend_ini_parser.y \
if not "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend-parser.y \
if "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend-parser.y \
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
@@ -385,78 +361,17 @@ BuildCmds= \
# Begin Custom Build
InputDir=.
InputPath=.\zend_ini_parser.y
InputPath=".\zend-parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p ini_ zend_ini_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_ini_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p ini_ zend_ini_parser.y \
if not "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend-parser.y \
if "X%CYGWIN%"=="X" bison --output=zend-parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend-parser.y \
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ENDIF
# End Source File
# Begin Source File
SOURCE=".\zend_language_parser.y"
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
# Begin Custom Build
InputDir=.
InputPath=".\zend_language_parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend_language_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend_language_parser.y \
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "ZendTS - Win32 Debug_TS"
# Begin Custom Build
InputDir=.
InputPath=".\zend_language_parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend_language_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend_language_parser.y \
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TS_inline"
# Begin Custom Build
InputDir=.
InputPath=".\zend_language_parser.y"
BuildCmds= \
if not "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "%CYGWIN%\share\bison.simple" -p zend zend_language_parser.y \
if "X%CYGWIN%"=="X" bison --output=zend_language_parser.c -v -d -S "C:\Program Files\Cygnus\share\bison.simple" -p zend zend_language_parser.y \
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
"$(InputDir)\zend-parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
@@ -469,72 +384,35 @@ BuildCmds= \
# PROP Default_Filter "l"
# Begin Source File
SOURCE=.\zend_ini_scanner.l
SOURCE=".\zend-scanner.l"
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
# Begin Custom Build
InputPath=.\zend_ini_scanner.l
InputPath=".\zend-scanner.l"
"zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l
"zend-scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pzend -ozend-scanner.cpp zend-scanner.l
# End Custom Build
!ELSEIF "$(CFG)" == "ZendTS - Win32 Debug_TS"
# Begin Custom Build
InputPath=.\zend_ini_scanner.l
InputPath=".\zend-scanner.l"
"zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l
"zend-scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pzend -ozend-scanner.cpp zend-scanner.l
# End Custom Build
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TS_inline"
# Begin Custom Build
InputPath=.\zend_ini_scanner.l
InputPath=".\zend-scanner.l"
"zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l
# End Custom Build
!ENDIF
# End Source File
# Begin Source File
SOURCE=".\zend_language_scanner.l"
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
# Begin Custom Build
InputPath=".\zend_language_scanner.l"
"zend_language_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pzend -ozend_language_scanner.cpp zend_language_scanner.l
# End Custom Build
!ELSEIF "$(CFG)" == "ZendTS - Win32 Debug_TS"
# Begin Custom Build
InputPath=".\zend_language_scanner.l"
"zend_language_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pzend -ozend_language_scanner.cpp zend_language_scanner.l
# End Custom Build
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TS_inline"
# Begin Custom Build
InputPath=".\zend_language_scanner.l"
"zend_language_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pzend -ozend_language_scanner.cpp zend_language_scanner.l
"zend-scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
flex -+ -B -i -Sflex.skl -Pzend -ozend-scanner.cpp zend-scanner.l
# End Custom Build
+725
View File
@@ -0,0 +1,725 @@
%{
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 0.92 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.zend.com/license/0_92.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/*
* LALR shift/reduce conflicts and how they are resolved:
*
* - 2 shift/reduce conflicts due to the dangeling elseif/else ambiguity. Solved by shift.
* - 1 shift/reduce conflict due to arrays within encapsulated strings. Solved by shift.
* - 1 shift/reduce conflict due to objects within encapsulated strings. Solved by shift.
*
*/
#include "zend_compile.h"
#include "zend.h"
#include "zend_list.h"
#include "zend_globals.h"
#include "zend_API.h"
#define YYERROR_VERBOSE
#define YYSTYPE znode
#ifdef ZTS
# define YYPARSE_PARAM compiler_globals
# define YYLEX_PARAM compiler_globals
#endif
%}
%pure_parser
%expect 4
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
%left ','
%left T_LOGICAL_OR
%left T_LOGICAL_XOR
%left T_LOGICAL_AND
%right T_PRINT
%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL
%left '?' ':'
%left T_BOOLEAN_OR
%left T_BOOLEAN_AND
%left '|'
%left '^'
%left '&'
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
%left T_SL T_SR
%left '+' '-' '.'
%left '*' '/' '%'
%right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@'
%right '['
%nonassoc T_NEW
%token T_EXIT
%token T_IF
%left T_ELSEIF
%left T_ELSE
%left T_ENDIF
%token T_LNUMBER
%token T_DNUMBER
%token T_STRING
%token T_STRING_VARNAME
%token T_VARIABLE
%token T_NUM_STRING
%token T_INLINE_HTML
%token T_CHARACTER
%token T_BAD_CHARACTER
%token T_ENCAPSED_AND_WHITESPACE
%token T_CONSTANT_ENCAPSED_STRING
%token T_ECHO
%token T_DO
%token T_WHILE
%token T_ENDWHILE
%token T_FOR
%token T_ENDFOR
%token T_FOREACH
%token T_ENDFOREACH
%token T_DECLARE
%token T_ENDDECLARE
%token T_AS
%token T_SWITCH
%token T_ENDSWITCH
%token T_CASE
%token T_DEFAULT
%token T_BREAK
%token T_CONTINUE
%token T_OLD_FUNCTION
%token T_FUNCTION
%token T_CONST
%token T_RETURN
%token T_USE
%token T_GLOBAL
%token T_STATIC
%token T_VAR
%token T_UNSET
%token T_ISSET
%token T_EMPTY
%token T_CLASS
%token T_EXTENDS
%token T_OBJECT_OPERATOR
%token T_DOUBLE_ARROW
%token T_LIST
%token T_ARRAY
%token T_LINE
%token T_FILE
%token T_COMMENT
%token T_ML_COMMENT
%token T_OPEN_TAG
%token T_OPEN_TAG_WITH_ECHO
%token T_CLOSE_TAG
%token T_WHITESPACE
%token T_START_HEREDOC
%token T_END_HEREDOC
%token T_DOLLAR_OPEN_CURLY_BRACES
%token T_CURLY_OPEN
%token T_PAAMAYIM_NEKUDOTAYIM
%% /* Rules */
start:
top_statement_list
;
top_statement_list:
top_statement_list { do_extended_info(CLS_C); } top_statement { HANDLE_INTERACTIVE(); }
| /* empty */
;
top_statement:
statement
| declaration_statement { do_early_binding(CLS_C); }
;
inner_statement_list:
inner_statement_list { do_extended_info(CLS_C); } inner_statement { HANDLE_INTERACTIVE(); }
| /* empty */
;
inner_statement:
statement
| declaration_statement
;
statement:
unticked_statement { do_ticks(CLS_C); }
;
unticked_statement:
'{' inner_statement_list '}'
| T_IF '(' expr ')' { do_if_cond(&$3, &$4 CLS_CC); } statement { do_if_after_statement(&$4, 1 CLS_CC); } elseif_list else_single { do_if_end(CLS_C); }
| T_IF '(' expr ')' ':' { do_if_cond(&$3, &$4 CLS_CC); } inner_statement_list { do_if_after_statement(&$4, 1 CLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { do_if_end(CLS_C); }
| T_WHILE '(' { $1.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' { do_while_cond(&$4, &$5 CLS_CC); } while_statement { do_while_end(&$1, &$5 CLS_CC); }
| T_DO { $1.u.opline_num = get_next_op_number(CG(active_op_array)); do_do_while_begin(CLS_C); } statement T_WHILE '(' { $5.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' ';' { do_do_while_end(&$1, &$5, &$7 CLS_CC); }
| T_FOR
'('
for_expr
';' { do_free(&$3 CLS_CC); $4.u.opline_num = get_next_op_number(CG(active_op_array)); }
for_expr
';' { do_extended_info(CLS_C); do_for_cond(&$6, &$7 CLS_CC); }
for_expr
')' { do_free(&$9 CLS_CC); do_for_before_statement(&$4, &$7 CLS_CC); }
for_statement { do_for_end(&$7 CLS_CC); }
| T_SWITCH '(' expr ')' { do_switch_cond(&$3 CLS_CC); } switch_case_list { do_switch_end(&$6 CLS_CC); }
| T_BREAK ';' { do_brk_cont(ZEND_BRK, NULL CLS_CC); }
| T_BREAK expr ';' { do_brk_cont(ZEND_BRK, &$2 CLS_CC); }
| T_CONTINUE ';' { do_brk_cont(ZEND_CONT, NULL CLS_CC); }
| T_CONTINUE expr ';' { do_brk_cont(ZEND_CONT, &$2 CLS_CC); }
| T_RETURN ';' { do_return(NULL, 0 CLS_CC); }
| T_RETURN expr_without_variable ';' { do_return(&$2, 0 CLS_CC); }
| T_RETURN cvar ';' { do_return(&$2, 1 CLS_CC); }
| T_GLOBAL global_var_list ';'
| T_STATIC static_var_list ';'
| T_ECHO echo_expr_list ';'
| T_INLINE_HTML { do_echo(&$1 CLS_CC); }
| expr ';' { do_free(&$1 CLS_CC); }
| T_USE use_filename ';' { zend_error(E_COMPILE_ERROR,"use: Not yet supported. Please use include_once() or require_once()"); zval_dtor(&$2.u.constant); }
| T_UNSET '(' unset_variables ')' ';'
| T_FOREACH '(' w_cvar T_AS { do_foreach_begin(&$1, &$3, &$2, &$4, 1 CLS_CC); } w_cvar foreach_optional_arg ')' { do_foreach_cont(&$6, &$7, &$4 CLS_CC); } foreach_statement { do_foreach_end(&$1, &$2 CLS_CC); }
| T_FOREACH '(' expr_without_variable T_AS { do_foreach_begin(&$1, &$3, &$2, &$4, 0 CLS_CC); } w_cvar foreach_optional_arg ')' { do_foreach_cont(&$6, &$7, &$4 CLS_CC); } foreach_statement { do_foreach_end(&$1, &$2 CLS_CC); }
| T_DECLARE { do_declare_begin(CLS_C); } '(' declare_list ')' declare_statement { do_declare_end(CLS_C); }
| ';' /* empty statement */
;
unset_variables:
unset_variable
| unset_variables ',' unset_variable
;
unset_variable:
cvar { do_end_variable_parse(BP_VAR_UNSET, 0 CLS_CC); do_unset(&$1 CLS_CC); }
;
use_filename:
T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
| '(' T_CONSTANT_ENCAPSED_STRING ')' { $$ = $2; }
;
declaration_statement:
unticked_declaration_statement { do_ticks(CLS_C); }
;
unticked_declaration_statement:
T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { do_begin_function_declaration(&$1, &$4, 0, $3.op_type CLS_CC); }
'(' parameter_list ')' '{' inner_statement_list '}' { do_end_function_declaration(&$1 CLS_CC); }
| T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { do_begin_function_declaration(&$1, &$4, 0, $3.op_type CLS_CC); }
parameter_list '(' inner_statement_list ')' ';' { do_end_function_declaration(&$1 CLS_CC); }
| T_CLASS T_STRING { do_begin_class_declaration(&$2, NULL CLS_CC); } '{' class_statement_list '}' { do_end_class_declaration(CLS_C); }
| T_CLASS T_STRING T_EXTENDS T_STRING { do_begin_class_declaration(&$2, &$4 CLS_CC); } '{' class_statement_list '}' { do_end_class_declaration(CLS_C); }
;
foreach_optional_arg:
/* empty */ { $$.op_type = IS_UNUSED; }
| T_DOUBLE_ARROW w_cvar { $$ = $2; }
;
for_statement:
statement
| ':' inner_statement_list T_ENDFOR ';'
;
foreach_statement:
statement
| ':' inner_statement_list T_ENDFOREACH ';'
;
declare_statement:
statement
| ':' inner_statement_list T_ENDDECLARE ';'
;
declare_list:
T_STRING '=' static_scalar { do_declare_stmt(&$1, &$3 CLS_CC); }
| declare_list ',' T_STRING '=' static_scalar { do_declare_stmt(&$3, &$5 CLS_CC); }
;
switch_case_list:
'{' case_list '}' { $$ = $2; }
| '{' ';' case_list '}' { $$ = $3; }
| ':' case_list T_ENDSWITCH ';' { $$ = $2; }
| ':' ';' case_list T_ENDSWITCH ';' { $$ = $3; }
;
case_list:
/* empty */ { $$.op_type = IS_UNUSED; }
| case_list T_CASE expr case_separator { do_extended_info(CLS_C); do_case_before_statement(&$1, &$2, &$3 CLS_CC); } inner_statement_list { do_case_after_statement(&$$, &$2 CLS_CC); $$.op_type = IS_CONST }
| case_list T_DEFAULT case_separator { do_extended_info(CLS_C); do_default_before_statement(&$1, &$2 CLS_CC); } inner_statement_list { do_case_after_statement(&$$, &$2 CLS_CC); $$.op_type = IS_CONST; }
;
case_separator:
':'
| ';'
;
while_statement:
statement
| ':' inner_statement_list T_ENDWHILE ';'
;
elseif_list:
/* empty */
| elseif_list T_ELSEIF '(' expr ')' { do_if_cond(&$4, &$5 CLS_CC); } statement { do_if_after_statement(&$5, 0 CLS_CC); }
;
new_elseif_list:
/* empty */
| new_elseif_list T_ELSEIF '(' expr ')' ':' { do_if_cond(&$4, &$5 CLS_CC); } inner_statement_list { do_if_after_statement(&$5, 0 CLS_CC); }
;
else_single:
/* empty */
| T_ELSE statement
;
new_else_single:
/* empty */
| T_ELSE ':' inner_statement_list
;
parameter_list:
non_empty_parameter_list
| /* empty */
;
non_empty_parameter_list:
T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$1, 0 CLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE CLS_CC); }
| '&' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$2, 0 CLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_FORCE CLS_CC); }
| T_CONST T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$2, 0 CLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE CLS_CC); }
| T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$1, 0 CLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$3, BYREF_NONE CLS_CC); }
| non_empty_parameter_list ',' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$3, 0 CLS_CC); $$=$1; $$.u.constant.value.lval++; do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE CLS_CC); }
| non_empty_parameter_list ',' '&' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$4, 0 CLS_CC); $$=$1; $$.u.constant.value.lval++; do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_FORCE CLS_CC); }
| non_empty_parameter_list ',' T_CONST T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$4, 0 CLS_CC); $$=$1; $$.u.constant.value.lval++; do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE CLS_CC); }
| non_empty_parameter_list ',' T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$3, 0 CLS_CC); $$=$1; $$.u.constant.value.lval++; do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$5, BYREF_NONE CLS_CC); }
;
function_call_parameter_list:
non_empty_function_call_parameter_list { $$ = $1; }
| /* empty */ { $$.u.constant.value.lval = 0; }
;
non_empty_function_call_parameter_list:
expr_without_variable { $$.u.constant.value.lval = 1; do_pass_param(&$1, ZEND_SEND_VAL, $$.u.constant.value.lval CLS_CC); }
| cvar { $$.u.constant.value.lval = 1; do_pass_param(&$1, ZEND_SEND_VAR, $$.u.constant.value.lval CLS_CC); }
| '&' w_cvar { $$.u.constant.value.lval = 1; do_pass_param(&$2, ZEND_SEND_REF, $$.u.constant.value.lval CLS_CC); }
| non_empty_function_call_parameter_list ',' expr_without_variable { $$.u.constant.value.lval=$1.u.constant.value.lval+1; do_pass_param(&$3, ZEND_SEND_VAL, $$.u.constant.value.lval CLS_CC); }
| non_empty_function_call_parameter_list ',' cvar { $$.u.constant.value.lval=$1.u.constant.value.lval+1; do_pass_param(&$3, ZEND_SEND_VAR, $$.u.constant.value.lval CLS_CC); }
| non_empty_function_call_parameter_list ',' '&' w_cvar { $$.u.constant.value.lval=$1.u.constant.value.lval+1; do_pass_param(&$4, ZEND_SEND_REF, $$.u.constant.value.lval CLS_CC); }
;
global_var_list:
global_var_list ',' global_var { do_fetch_global_or_static_variable(&$3, NULL, ZEND_FETCH_GLOBAL CLS_CC); }
| global_var { do_fetch_global_or_static_variable(&$1, NULL, ZEND_FETCH_GLOBAL CLS_CC); }
;
global_var:
T_VARIABLE { $$ = $1; }
| '$' r_cvar { $$ = $2; }
| '$' '{' expr '}' { $$ = $3; }
;
static_var_list:
static_var_list ',' T_VARIABLE { do_fetch_global_or_static_variable(&$3, NULL, ZEND_FETCH_STATIC CLS_CC); }
| static_var_list ',' T_VARIABLE '=' static_scalar { do_fetch_global_or_static_variable(&$3, &$5, ZEND_FETCH_STATIC CLS_CC); }
| T_VARIABLE { do_fetch_global_or_static_variable(&$1, NULL, ZEND_FETCH_STATIC CLS_CC); }
| T_VARIABLE '=' static_scalar { do_fetch_global_or_static_variable(&$1, &$3, ZEND_FETCH_STATIC CLS_CC); }
;
class_statement_list:
class_statement_list class_statement
| /* empty */
;
class_statement:
T_VAR class_variable_decleration ';'
| T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { do_begin_function_declaration(&$1, &$4, 1, $3.op_type CLS_CC); } '('
parameter_list ')' '{' inner_statement_list '}' { do_end_function_declaration(&$1 CLS_CC); }
| T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { do_begin_function_declaration(&$1, &$4, 1, $3.op_type CLS_CC); }
parameter_list '(' inner_statement_list ')' ';' { do_end_function_declaration(&$1 CLS_CC); }
;
is_reference:
/* empty */ { $$.op_type = ZEND_RETURN_VAL; }
| '&' { $$.op_type = ZEND_RETURN_REF; }
class_variable_decleration:
class_variable_decleration ',' T_VARIABLE { do_declare_property(&$3, NULL CLS_CC); }
| class_variable_decleration ',' T_VARIABLE '=' static_scalar { do_declare_property(&$3, &$5 CLS_CC); }
| T_VARIABLE { do_declare_property(&$1, NULL CLS_CC); }
| T_VARIABLE '=' static_scalar { do_declare_property(&$1, &$3 CLS_CC); }
;
echo_expr_list:
| echo_expr_list ',' expr { do_echo(&$3 CLS_CC); }
| expr { do_echo(&$1 CLS_CC); }
;
for_expr:
/* empty */ { $$.op_type = IS_CONST; $$.u.constant.type = IS_BOOL; $$.u.constant.value.lval = 1; }
| non_empty_for_expr { $$ = $1; }
;
non_empty_for_expr:
non_empty_for_expr ',' { do_free(&$1 CLS_CC); } expr { $$ = $4; }
| expr { $$ = $1; }
;
expr_without_variable:
T_LIST '(' { do_list_init(CLS_C); } assignment_list ')' '=' expr { do_list_end(&$$, &$7 CLS_CC); }
| cvar '=' expr { do_end_variable_parse(BP_VAR_W, 0 CLS_CC); do_assign(&$$, &$1, &$3 CLS_CC); }
| cvar '=' '&' w_cvar { do_end_variable_parse(BP_VAR_W, 0 CLS_CC); do_assign_ref(&$$, &$1, &$4 CLS_CC); }
| cvar '=' '&' function_call { do_end_variable_parse(BP_VAR_W, 0 CLS_CC); do_assign_ref(&$$, &$1, &$4 CLS_CC); }
| T_NEW class_name { do_extended_fcall_begin(CLS_C); do_begin_new_object(&$1, &$2 CLS_CC); } ctor_arguments { do_end_new_object(&$$, &$2, &$1, &$4 CLS_CC); do_extended_fcall_end(CLS_C);}
| cvar T_PLUS_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_ADD, &$$, &$1, &$3 CLS_CC); }
| cvar T_MINUS_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_SUB, &$$, &$1, &$3 CLS_CC); }
| cvar T_MUL_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_MUL, &$$, &$1, &$3 CLS_CC); }
| cvar T_DIV_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_DIV, &$$, &$1, &$3 CLS_CC); }
| cvar T_CONCAT_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_CONCAT, &$$, &$1, &$3 CLS_CC); }
| cvar T_MOD_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_MOD, &$$, &$1, &$3 CLS_CC); }
| cvar T_AND_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_BW_AND, &$$, &$1, &$3 CLS_CC); }
| cvar T_OR_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_BW_OR, &$$, &$1, &$3 CLS_CC); }
| cvar T_XOR_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_BW_XOR, &$$, &$1, &$3 CLS_CC); }
| cvar T_SL_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_SL, &$$, &$1, &$3 CLS_CC); }
| cvar T_SR_EQUAL expr { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); do_binary_assign_op(ZEND_ASSIGN_SR, &$$, &$1, &$3 CLS_CC); }
| rw_cvar T_INC { do_post_incdec(&$$, &$1, ZEND_POST_INC CLS_CC); }
| T_INC rw_cvar { do_pre_incdec(&$$, &$2, ZEND_PRE_INC CLS_CC); }
| rw_cvar T_DEC { do_post_incdec(&$$, &$1, ZEND_POST_DEC CLS_CC); }
| T_DEC rw_cvar { do_pre_incdec(&$$, &$2, ZEND_PRE_DEC CLS_CC); }
| expr T_BOOLEAN_OR { do_boolean_or_begin(&$1, &$2 CLS_CC); } expr { do_boolean_or_end(&$$, &$1, &$4, &$2 CLS_CC); }
| expr T_BOOLEAN_AND { do_boolean_and_begin(&$1, &$2 CLS_CC); } expr { do_boolean_and_end(&$$, &$1, &$4, &$2 CLS_CC); }
| expr T_LOGICAL_OR { do_boolean_or_begin(&$1, &$2 CLS_CC); } expr { do_boolean_or_end(&$$, &$1, &$4, &$2 CLS_CC); }
| expr T_LOGICAL_AND { do_boolean_and_begin(&$1, &$2 CLS_CC); } expr { do_boolean_and_end(&$$, &$1, &$4, &$2 CLS_CC); }
| expr T_LOGICAL_XOR expr { do_binary_op(ZEND_BOOL_XOR, &$$, &$1, &$3 CLS_CC); }
| expr '|' expr { do_binary_op(ZEND_BW_OR, &$$, &$1, &$3 CLS_CC); }
| expr '&' expr { do_binary_op(ZEND_BW_AND, &$$, &$1, &$3 CLS_CC); }
| expr '^' expr { do_binary_op(ZEND_BW_XOR, &$$, &$1, &$3 CLS_CC); }
| expr '.' expr { do_binary_op(ZEND_CONCAT,&$$,&$1,&$3 CLS_CC); }
| expr '+' expr { do_binary_op(ZEND_ADD,&$$,&$1,&$3 CLS_CC); }
| expr '-' expr { do_binary_op(ZEND_SUB,&$$,&$1,&$3 CLS_CC); }
| expr '*' expr { do_binary_op(ZEND_MUL,&$$,&$1,&$3 CLS_CC); }
| expr '/' expr { do_binary_op(ZEND_DIV,&$$,&$1,&$3 CLS_CC); }
| expr '%' expr { do_binary_op(ZEND_MOD,&$$,&$1,&$3 CLS_CC); }
| expr T_SL expr { do_binary_op(ZEND_SL, &$$, &$1, &$3 CLS_CC); }
| expr T_SR expr { do_binary_op(ZEND_SR, &$$, &$1, &$3 CLS_CC); }
| '+' expr { $1.u.constant.value.lval=0; $1.u.constant.type=IS_LONG; $1.op_type = IS_CONST; INIT_PZVAL(&$1.u.constant); do_binary_op(ZEND_ADD, &$$, &$1, &$2 CLS_CC); }
| '-' expr { $1.u.constant.value.lval=0; $1.u.constant.type=IS_LONG; $1.op_type = IS_CONST; INIT_PZVAL(&$1.u.constant); do_binary_op(ZEND_SUB, &$$, &$1, &$2 CLS_CC); }
| '!' expr { do_unary_op(ZEND_BOOL_NOT, &$$, &$2 CLS_CC); }
| '~' expr { do_unary_op(ZEND_BW_NOT, &$$, &$2 CLS_CC); }
| expr T_IS_IDENTICAL expr { do_binary_op(ZEND_IS_IDENTICAL, &$$, &$1, &$3 CLS_CC); }
| expr T_IS_NOT_IDENTICAL expr { do_binary_op(ZEND_IS_NOT_IDENTICAL, &$$, &$1, &$3 CLS_CC); }
| expr T_IS_EQUAL expr { do_binary_op(ZEND_IS_EQUAL, &$$, &$1, &$3 CLS_CC); }
| expr T_IS_NOT_EQUAL expr { do_binary_op(ZEND_IS_NOT_EQUAL, &$$, &$1, &$3 CLS_CC); }
| expr '<' expr { do_binary_op(ZEND_IS_SMALLER, &$$, &$1, &$3 CLS_CC); }
| expr T_IS_SMALLER_OR_EQUAL expr { do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$1, &$3 CLS_CC); }
| expr '>' expr { do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 CLS_CC); }
| expr T_IS_GREATER_OR_EQUAL expr { do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 CLS_CC); }
| '(' expr ')' { $$ = $2; }
| expr '?' { do_begin_qm_op(&$1, &$2 CLS_CC); }
expr ':' { do_qm_true(&$4, &$2, &$5 CLS_CC); }
expr { do_qm_false(&$$, &$7, &$2, &$5 CLS_CC); }
| function_call { $$ = $1; }
| internal_functions_in_yacc { $$ = $1; }
| T_INT_CAST expr { do_cast(&$$, &$2, IS_LONG CLS_CC); }
| T_DOUBLE_CAST expr { do_cast(&$$, &$2, IS_DOUBLE CLS_CC); }
| T_STRING_CAST expr { do_cast(&$$, &$2, IS_STRING CLS_CC); }
| T_ARRAY_CAST expr { do_cast(&$$, &$2, IS_ARRAY CLS_CC); }
| T_OBJECT_CAST expr { do_cast(&$$, &$2, IS_OBJECT CLS_CC); }
| T_BOOL_CAST expr { do_cast(&$$, &$2, IS_BOOL CLS_CC); }
| T_UNSET_CAST expr { do_cast(&$$, &$2, IS_NULL CLS_CC); }
| T_EXIT exit_expr { do_exit(&$$, &$2 CLS_CC); }
| '@' { do_begin_silence(&$1 CLS_CC); } expr { do_end_silence(&$1 CLS_CC); $$ = $3; }
| scalar { $$ = $1; }
| T_ARRAY '(' array_pair_list ')' { $$ = $3; }
| '`' encaps_list '`' { do_shell_exec(&$$, &$2 CLS_CC); }
| T_PRINT expr { do_print(&$$, &$2 CLS_CC); }
;
function_call:
T_STRING '(' { $2.u.opline_num = do_begin_function_call(&$1 CLS_CC); }
function_call_parameter_list
')' { do_end_function_call(&$1, &$$, &$4, 0, $2.u.opline_num CLS_CC); do_extended_fcall_end(CLS_C); }
| cvar '(' { do_begin_dynamic_function_call(&$1 CLS_CC); }
function_call_parameter_list
')' { do_end_function_call(&$1, &$$, &$4, 0, 1 CLS_CC); do_extended_fcall_end(CLS_C);}
| T_STRING T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { do_extended_fcall_begin(CLS_C); do_begin_class_member_function_call(&$1, &$3 CLS_CC); }
function_call_parameter_list
')' { do_end_function_call(&$3, &$$, &$6, 1, 1 CLS_CC); do_extended_fcall_end(CLS_C);}
;
exit_expr:
/* empty */ { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
| '(' ')' { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
| '(' expr ')' { $$ = $2; }
;
ctor_arguments:
/* empty */ { $$.u.constant.value.lval=0; }
| '(' function_call_parameter_list ')' { $$ = $2; }
;
class_name:
T_STRING { $$ = $1; }
| r_cvar { $$ = $1; }
;
common_scalar:
T_LNUMBER { $$ = $1; }
| T_DNUMBER { $$ = $1; }
| T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
| T_LINE { $$ = $1; }
| T_FILE { $$ = $1; }
;
static_scalar: /* compile-time evaluated scalars */
common_scalar { $$ = $1; }
| T_STRING { do_fetch_constant(&$$, &$1, ZEND_CT CLS_CC); }
| '+' static_scalar { $$ = $1; }
| '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval = -1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one); $$ = $2; }
| T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = IS_CONSTANT_ARRAY; }
;
scalar:
T_STRING { do_fetch_constant(&$$, &$1, ZEND_RT CLS_CC); }
| T_STRING_VARNAME { $$ = $1; }
| common_scalar { $$ = $1; }
| '"' encaps_list '"' { $$ = $2; }
| '\'' encaps_list '\'' { $$ = $2; }
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; do_end_heredoc(CLS_C); }
;
static_array_pair_list:
/* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); }
| non_empty_static_array_pair_list possible_comma { $$ = $1; }
;
possible_comma:
/* empty */
| ','
;
non_empty_static_array_pair_list:
non_empty_static_array_pair_list ',' static_scalar T_DOUBLE_ARROW static_scalar { do_add_static_array_element(&$$, &$3, &$5); }
| non_empty_static_array_pair_list ',' static_scalar { do_add_static_array_element(&$$, NULL, &$3); }
| static_scalar T_DOUBLE_ARROW static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); do_add_static_array_element(&$$, &$1, &$3); }
| static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); do_add_static_array_element(&$$, NULL, &$1); }
;
expr:
r_cvar { $$ = $1; }
| expr_without_variable { $$ = $1; }
;
/*
w_expr:
w_cvar { $$ = $1; }
| expr_without_variable { $$ = $1; }
;
*/
r_cvar:
cvar { do_end_variable_parse(BP_VAR_R, 0 CLS_CC); $$ = $1; }
;
w_cvar:
cvar { do_end_variable_parse(BP_VAR_W, 0 CLS_CC); $$ = $1; }
;
rw_cvar:
cvar { do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); $$ = $1; }
;
cvar:
cvar_without_objects { $$ = $1; }
| cvar_without_objects T_OBJECT_OPERATOR { do_push_object(&$1 CLS_CC); } ref_list { $$ = $4; }
;
cvar_without_objects:
reference_variable { $$ = $1; }
| simple_indirect_reference reference_variable { do_indirect_references(&$$, &$1, &$2 CLS_CC); }
;
reference_variable:
reference_variable '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 CLS_CC); }
| reference_variable '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 CLS_CC); }
| compound_variable { do_fetch_globals(&$1 CLS_CC); do_begin_variable_parse(CLS_C); fetch_simple_variable(&$$, &$1, 1 CLS_CC); }
;
compound_variable:
T_VARIABLE { $$ = $1; }
| '$' '{' expr '}' { $$ = $3; }
;
dim_offset:
/* empty */ { $$.op_type = IS_UNUSED; }
| expr { $$ = $1; }
;
ref_list:
object_property { $$ = $1; }
| ref_list T_OBJECT_OPERATOR { do_push_object(&$1 CLS_CC); } object_property { $$ = $4; }
;
object_property:
object_dim_list { $$ = $1; }
| cvar_without_objects { do_end_variable_parse(BP_VAR_R, 0 CLS_CC); } { znode tmp_znode; do_pop_object(&tmp_znode CLS_CC); do_fetch_property(&$$, &tmp_znode, &$1 CLS_CC);}
;
object_dim_list:
object_dim_list '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 CLS_CC); }
| object_dim_list '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 CLS_CC); }
| variable_name { znode tmp_znode; do_pop_object(&tmp_znode CLS_CC); do_fetch_property(&$$, &tmp_znode, &$1 CLS_CC);}
;
variable_name:
T_STRING { $$ = $1; }
| '{' expr '}' { $$ = $2; }
;
simple_indirect_reference:
'$' { $$.u.constant.value.lval = 1; }
| simple_indirect_reference '$' { $$.u.constant.value.lval++; }
;
assignment_list:
assignment_list ',' assignment_list_element
| assignment_list_element
;
assignment_list_element:
cvar { do_add_list_element(&$1 CLS_CC); }
| T_LIST '(' { do_new_list_begin(CLS_C); } assignment_list ')' { do_new_list_end(CLS_C); }
| /* empty */ { do_add_list_element(NULL CLS_CC); }
;
array_pair_list:
/* empty */ { do_init_array(&$$, NULL, NULL, 0 CLS_CC); }
| non_empty_array_pair_list possible_comma { $$ = $1; }
;
non_empty_array_pair_list:
non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr { do_add_array_element(&$$, &$5, &$3, 0 CLS_CC); }
| non_empty_array_pair_list ',' expr { do_add_array_element(&$$, &$3, NULL, 0 CLS_CC); }
| expr T_DOUBLE_ARROW expr { do_init_array(&$$, &$3, &$1, 0 CLS_CC); }
| expr { do_init_array(&$$, &$1, NULL, 0 CLS_CC); }
| non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_cvar { do_add_array_element(&$$, &$6, &$3, 1 CLS_CC); }
| non_empty_array_pair_list ',' '&' w_cvar { do_add_array_element(&$$, &$4, NULL, 1 CLS_CC); }
| expr T_DOUBLE_ARROW '&' w_cvar { do_init_array(&$$, &$4, &$1, 1 CLS_CC); }
| '&' w_cvar { do_init_array(&$$, &$2, NULL, 1 CLS_CC); }
;
encaps_list:
encaps_list encaps_var { do_end_variable_parse(BP_VAR_R, 0 CLS_CC); do_add_variable(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_STRING { do_add_string(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_NUM_STRING { do_add_string(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_ENCAPSED_AND_WHITESPACE { do_add_string(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_CHARACTER { do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_BAD_CHARACTER { do_add_string(&$$, &$1, &$2 CLS_CC); }
| encaps_list '[' { $2.u.constant.value.lval = (long) '['; do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list ']' { $2.u.constant.value.lval = (long) ']'; do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list '{' { $2.u.constant.value.lval = (long) '{'; do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list '}' { $2.u.constant.value.lval = (long) '}'; do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_OBJECT_OPERATOR { znode tmp; $2.u.constant.value.lval = (long) '-'; do_add_char(&tmp, &$1, &$2 CLS_CC); $2.u.constant.value.lval = (long) '>'; do_add_char(&$$, &tmp, &$2 CLS_CC); }
| /* empty */ { do_init_string(&$$ CLS_CC); }
;
encaps_var:
T_VARIABLE { do_fetch_globals(&$1 CLS_CC); do_begin_variable_parse(CLS_C); fetch_simple_variable(&$$, &$1, 1 CLS_CC); }
| T_VARIABLE '[' { do_begin_variable_parse(CLS_C); } encaps_var_offset ']' { do_fetch_globals(&$1 CLS_CC); fetch_array_begin(&$$, &$1, &$4 CLS_CC); }
| T_VARIABLE T_OBJECT_OPERATOR T_STRING { do_begin_variable_parse(CLS_C); fetch_simple_variable(&$2, &$1, 1 CLS_CC); do_fetch_property(&$$, &$2, &$3 CLS_CC); }
| T_DOLLAR_OPEN_CURLY_BRACES expr '}' { do_begin_variable_parse(CLS_C); fetch_simple_variable(&$$, &$2, 1 CLS_CC); }
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' { do_begin_variable_parse(CLS_C); fetch_array_begin(&$$, &$2, &$4 CLS_CC); }
| T_CURLY_OPEN cvar '}' { $$ = $2; }
;
encaps_var_offset:
T_STRING { $$ = $1; }
| T_NUM_STRING { $$ = $1; }
| T_VARIABLE { fetch_simple_variable(&$$, &$1, 1 CLS_CC); }
;
internal_functions_in_yacc:
T_ISSET '(' cvar ')' { do_isset_or_isempty(ZEND_ISSET, &$$, &$3 CLS_CC); }
| T_EMPTY '(' cvar ')' { do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 CLS_CC); }
| T_INCLUDE expr { do_include_or_eval(ZEND_INCLUDE, &$$, &$2 CLS_CC); }
| T_INCLUDE_ONCE expr { do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 CLS_CC); }
| T_EVAL '(' expr ')' { do_include_or_eval(ZEND_EVAL, &$$, &$3 CLS_CC); }
| T_REQUIRE expr { do_include_or_eval(ZEND_REQUIRE, &$$, &$2 CLS_CC); }
| T_REQUIRE_ONCE expr { do_include_or_eval(ZEND_REQUIRE_ONCE, &$$, &$2 CLS_CC); }
;
%%
File renamed without changes.
@@ -38,12 +38,11 @@
#endif
#include <errno.h>
#include <limits.h>
#include "zend.h"
#include "zend_alloc.h"
#include "zend_language_parser.h"
#include "zend-parser.h"
#include "zend_compile.h"
#include "zend_language_scanner.h"
#include "zend-scanner.h"
#include "zend_highlight.h"
#include "zend_constants.h"
#include "zend_variables.h"
@@ -77,7 +76,6 @@
#else
#define YY_DECL int lex_scan(zval *zendlval CLS_DC)
#endif
#define ECHO { ZEND_WRITE( yytext, yyleng ); }
#ifdef ZTS
@@ -90,10 +88,10 @@
class istdiostream : public istream
{
private:
stdiobuf _file;
stdiobuf _file;
public:
istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); }
stdiobuf* rdbuf()/* const */ { return &_file; }
istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); }
stdiobuf* rdbuf()/* const */ { return &_file; }
};
#endif
@@ -361,7 +359,7 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type CLS
CG(in_compilation) = 1;
CG(active_op_array) = op_array;
compiler_result = zendparse(CLS_C);
zend_do_return(&retval_znode, 0 CLS_CC);
do_return(&retval_znode, 0 CLS_CC);
restore_lexical_state(&original_lex_state CLS_CC);
CG(in_compilation) = original_in_compilation;
if (compiler_result==1) { /* parser error */
@@ -490,7 +488,7 @@ zend_op_array *compile_string(zval *source_string, char *filename CLS_DC)
CG(unclean_shutdown)=1;
retval = NULL;
} else {
zend_do_return(NULL, 0 CLS_CC);
do_return(NULL, 0 CLS_CC);
CG(active_op_array) = original_active_op_array;
pass_two(op_array);
retval = op_array;
@@ -1001,7 +999,7 @@ ANY_CHAR (.|[\n])
}
<ST_IN_SCRIPTING>{LNUM} {
<ST_IN_SCRIPTING>{LNUM}|{HNUM} {
errno = 0;
zendlval->value.lval = strtol(yytext, NULL, 0);
if (errno == ERANGE) { /* overflow */
@@ -1014,26 +1012,6 @@ ANY_CHAR (.|[\n])
}
}
<ST_IN_SCRIPTING>{HNUM} {
errno = 0;
zendlval->value.lval = strtoul(yytext, NULL, 16);
if (errno == ERANGE) { /* overflow */
/* not trying strtod - it returns trash on 0x-es */
zendlval->value.lval = LONG_MAX; /* maximal long */
zend_error(E_NOTICE,"Hex number is too big: %s",yytext);
} else {
if(zendlval->value.lval < 0) {
/* maintain consistency with the old way */
zendlval->value.dval = (unsigned long) zendlval->value.lval;
zendlval->type = IS_DOUBLE;
return T_DNUMBER;
}
zendlval->type = IS_LONG;
}
zendlval->type = IS_LONG;
return T_LNUMBER;
}
<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>{LNUM}|{HNUM} { /* treat numbers (almost) as strings inside encapsulated strings */
zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;
-12
View File
@@ -198,23 +198,11 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
switch(expr->type) {
case IS_ARRAY:
ZEND_PUTS("Array\n");
if (++expr->value.ht->nApplyCount>1) {
ZEND_PUTS(" *RECURSION*");
expr->value.ht->nApplyCount=0;
return;
}
print_hash(expr->value.ht,indent);
expr->value.ht->nApplyCount--;
break;
case IS_OBJECT:
if (++expr->value.obj.properties->nApplyCount>1) {
ZEND_PUTS(" *RECURSION*");
expr->value.obj.properties->nApplyCount=0;
return;
}
zend_printf("%s Object\n", expr->value.obj.ce->name);
print_hash(expr->value.obj.properties, indent);
expr->value.obj.properties->nApplyCount--;
break;
default:
zend_print_variable(expr);
-15
View File
@@ -421,21 +421,6 @@ ZEND_API int zend_get_ini_entry(char *name, uint name_length, zval *contents);
} \
INIT_PZVAL(&(zv));
#define REPLACE_ZVAL_VALUE(ppzv_dest,pzv_src,copy) { \
int is_ref,refcount; \
\
SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest); \
is_ref = (*ppzv_dest)->is_ref; \
refcount = (*ppzv_dest)->refcount; \
zval_dtor(*ppzv_dest); \
**ppzv_dest = *pzv_src; \
if(copy) { \
zval_copy_ctor(*ppzv_dest); \
} \
(*ppzv_dest)->is_ref = is_ref; \
(*ppzv_dest)->refcount = refcount; \
}
#define ZEND_MAX_RESERVED_RESOURCES 2
#ifdef ZEND_WIN32
+2 -2
View File
@@ -30,7 +30,7 @@
/* these variables are true statics/globals, and have to be mutex'ed on every access */
static int module_count=0;
ZEND_API HashTable module_registry;
HashTable module_registry;
/* this function doesn't check for too many parameters */
ZEND_API int zend_get_parameters(int ht, int param_count, ...)
@@ -892,7 +892,7 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla
register_class = zend_register_internal_class(class_entry);
if (parent_ce) {
zend_do_inheritance(register_class, parent_ce);
do_inheritance(register_class, parent_ce);
}
return register_class;
}
-28
View File
@@ -137,9 +137,6 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
p->orig_lineno = __zend_orig_lineno;
p->magic = MEM_BLOCK_START_MAGIC;
p->reported = 0;
/* Setting the thread id should not be necessary, because we fetched this block
* from this thread's cache
*/
AG(cache_stats)[CACHE_INDEX][1]++;
#endif
p->persistent = 0;
@@ -180,9 +177,6 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
p->orig_lineno = __zend_orig_lineno;
p->magic = MEM_BLOCK_START_MAGIC;
p->reported = 0;
# ifdef ZTS
p->thread_id = tsrm_thread_id();
# endif
*((long *)(((char *) p) + sizeof(zend_mem_header)+SIZE+PLATFORM_PADDING+END_ALIGNMENT(SIZE))) = MEM_BLOCK_END_MAGIC;
#endif
#if MEMORY_LIMIT
@@ -199,15 +193,6 @@ ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
DECLARE_CACHE_VARS
ALS_FETCH();
#if defined(ZTS) && ZEND_DEBUG
if (p->thread_id != tsrm_thread_id()) {
tsrm_error(TSRM_ERROR_LEVEL_ERROR, "Memory block allocated at %s:(%d) on thread %x freed at %s:(%d) on thread %x, ignoring",
p->filename, p->lineno, p->thread_id,
__zend_filename, __zend_lineno, tsrm_thread_id());
return;
}
#endif
CALCULATE_REAL_SIZE_AND_CACHE_INDEX(p->size);
#if ZEND_DEBUG
if (!_mem_block_check(ptr, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC)) {
@@ -268,19 +253,6 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
return _emalloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
}
#if defined(ZTS) && ZEND_DEBUG
if (p->thread_id != tsrm_thread_id()) {
void *new_p;
tsrm_error(TSRM_ERROR_LEVEL_ERROR, "Memory block allocated at %s:(%d) on thread %x reallocated at %s:(%d) on thread %x, duplicating",
p->filename, p->lineno, p->thread_id,
__zend_filename, __zend_lineno, tsrm_thread_id());
new_p = _emalloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
memcpy(new_p, ptr, p->size);
return new_p;
}
#endif
CALCULATE_REAL_SIZE_AND_CACHE_INDEX(size);
HANDLE_BLOCK_INTERRUPTIONS();
+1 -9
View File
@@ -23,10 +23,6 @@
#include <stdio.h>
#ifdef ZTS
#include "../TSRM/TSRM.h"
#endif
#include "zend_globals_macros.h"
#define MEM_BLOCK_START_MAGIC 0x7312F8DCL
@@ -42,9 +38,6 @@ typedef struct _zend_mem_header {
int reported;
char *orig_filename;
uint orig_lineno;
# ifdef ZTS
THREAD_T thread_id;
# endif
#endif
struct _zend_mem_header *pNext;
struct _zend_mem_header *pLast;
@@ -71,11 +64,10 @@ typedef union _align_test {
#define PLATFORM_PADDING (((PLATFORM_ALIGNMENT-sizeof(zend_mem_header))%PLATFORM_ALIGNMENT+PLATFORM_ALIGNMENT)%PLATFORM_ALIGNMENT)
ZEND_API char *zend_strndup(const char *s, unsigned int length);
BEGIN_EXTERN_C()
ZEND_API char *zend_strndup(const char *s, unsigned int length);
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
-70
View File
@@ -56,8 +56,6 @@ static ZEND_FUNCTION(trigger_error);
static ZEND_FUNCTION(set_error_handler);
static ZEND_FUNCTION(restore_error_handler);
static ZEND_FUNCTION(get_declared_classes);
static ZEND_FUNCTION(get_defined_functions);
static ZEND_FUNCTION(get_defined_vars);
static ZEND_FUNCTION(create_function);
static ZEND_FUNCTION(get_resource_type);
#if ZEND_DEBUG
@@ -103,8 +101,6 @@ static zend_function_entry builtin_functions[] = {
ZEND_FE(set_error_handler, NULL)
ZEND_FE(restore_error_handler, NULL)
ZEND_FE(get_declared_classes, NULL)
ZEND_FE(get_defined_functions, NULL)
ZEND_FE(get_defined_vars, NULL)
ZEND_FE(create_function, NULL)
ZEND_FE(get_resource_type, NULL)
#if ZEND_DEBUG
@@ -531,10 +527,6 @@ ZEND_FUNCTION(get_class_vars)
} else {
efree(lcname);
array_init(return_value);
if (!ce->constants_updated) {
zend_hash_apply_with_argument(&ce->default_properties, (int (*)(void *,void *)) zval_update_constant, (void *) 1);
ce->constants_updated = 1;
}
zend_hash_copy(return_value->value.ht, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
}
}
@@ -859,68 +851,6 @@ ZEND_FUNCTION(get_declared_classes)
}
/* }}} */
static int copy_function_name(zend_function *func, int num_args, va_list args, zend_hash_key *hash_key)
{
zval *internal_ar = va_arg(args, zval *),
*user_ar = va_arg(args, zval *);
if (hash_key->nKeyLength == 0 || hash_key->arKey[0] == 0) {
return 0;
}
if (func->type == ZEND_INTERNAL_FUNCTION) {
add_next_index_stringl(internal_ar, hash_key->arKey, hash_key->nKeyLength, 1);
} else if (func->type == ZEND_USER_FUNCTION) {
add_next_index_stringl(user_ar, hash_key->arKey, hash_key->nKeyLength, 1);
}
return 0;
}
/* {{{ proto array get_defined_functions(void)
Returns an array of all defined functions */
ZEND_FUNCTION(get_defined_functions)
{
zval *internal;
zval *user;
if (ZEND_NUM_ARGS() != 0) {
ZEND_WRONG_PARAM_COUNT();
}
MAKE_STD_ZVAL(internal);
MAKE_STD_ZVAL(user);
array_init(internal);
array_init(user);
array_init(return_value);
zend_hash_apply_with_arguments(EG(function_table), (apply_func_args_t)copy_function_name, 2, internal, user);
if (zend_hash_add(return_value->value.ht, "internal", sizeof("internal"), (void **)&internal, sizeof(zval *), NULL) == FAILURE) {
zend_error(E_WARNING, "Cannot add internal functions to return value from get_defined_functions()");
RETURN_FALSE;
}
if (zend_hash_add(return_value->value.ht, "user", sizeof("user"), (void **)&user, sizeof(zval *), NULL) == FAILURE) {
zend_error(E_WARNING, "Cannot add user functions to return value from get_defined_functions()");
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto array get_defined_vars(void)
Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */
ZEND_FUNCTION(get_defined_vars)
{
zval *tmp;
array_init(return_value);
zend_hash_copy(return_value->value.ht, EG(active_symbol_table),
(copy_ctor_func_t)zval_add_ref, &tmp, sizeof(zval *));
}
/* }}} */
#define LAMBDA_TEMP_FUNCNAME "__lambda_func"
+140 -142
View File
@@ -18,7 +18,7 @@
*/
#include "zend_language_parser.h"
#include "zend-parser.h"
#include "zend.h"
#include "zend_compile.h"
#include "zend_llist.h"
@@ -34,6 +34,9 @@ ZEND_API zend_compiler_globals compiler_globals;
ZEND_API zend_executor_globals executor_globals;
#endif
#define SET_UNUSED(op) (op).op_type = IS_UNUSED
static void free_filename(void *p)
{
efree(*((char **) p));
@@ -154,7 +157,7 @@ static zend_uint get_temporary_variable(zend_op_array *op_array)
}
void zend_do_binary_op(int op, znode *result, znode *op1, znode *op2 CLS_DC)
void do_binary_op(int op, znode *result, znode *op1, znode *op2 CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -167,7 +170,7 @@ void zend_do_binary_op(int op, znode *result, znode *op1, znode *op2 CLS_DC)
}
void zend_do_unary_op(int op, znode *result, znode *op1 CLS_DC)
void do_unary_op(int op, znode *result, znode *op1 CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -180,7 +183,7 @@ void zend_do_unary_op(int op, znode *result, znode *op1 CLS_DC)
}
void zend_do_binary_assign_op(int op, znode *result, znode *op1, znode *op2 CLS_DC)
void do_binary_assign_op(int op, znode *result, znode *op1, znode *op2 CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -195,7 +198,7 @@ void zend_do_binary_assign_op(int op, znode *result, znode *op1, znode *op2 CLS_
void zend_do_fetch_globals(znode *varname CLS_DC)
void do_fetch_globals(znode *varname CLS_DC)
{
if (!CG(active_op_array)->uses_globals
&& varname->op_type == IS_CONST
@@ -275,7 +278,7 @@ void fetch_string_offset(znode *result, znode *parent, znode *offset CLS_DC)
}
void zend_do_print(znode *result, znode *arg CLS_DC)
void do_print(znode *result, znode *arg CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -288,7 +291,7 @@ void zend_do_print(znode *result, znode *arg CLS_DC)
}
void zend_do_echo(znode *arg CLS_DC)
void do_echo(znode *arg CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -298,7 +301,7 @@ void zend_do_echo(znode *arg CLS_DC)
}
void zend_do_assign(znode *result, znode *variable, znode *value CLS_DC)
void do_assign(znode *result, znode *variable, znode *value CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -312,7 +315,7 @@ void zend_do_assign(znode *result, znode *variable, znode *value CLS_DC)
}
void zend_do_assign_ref(znode *result, znode *lvar, znode *rvar CLS_DC)
void do_assign_ref(znode *result, znode *lvar, znode *rvar CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -351,7 +354,7 @@ static inline void do_end_loop(int cont_addr CLS_DC)
}
void zend_do_while_cond(znode *expr, znode *close_bracket_token CLS_DC)
void do_while_cond(znode *expr, znode *close_bracket_token CLS_DC)
{
int while_cond_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -366,7 +369,7 @@ void zend_do_while_cond(znode *expr, znode *close_bracket_token CLS_DC)
}
void zend_do_while_end(znode *while_token, znode *close_bracket_token CLS_DC)
void do_while_end(znode *while_token, znode *close_bracket_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -385,7 +388,7 @@ void zend_do_while_end(znode *while_token, znode *close_bracket_token CLS_DC)
}
void zend_do_for_cond(znode *expr, znode *second_semicolon_token CLS_DC)
void do_for_cond(znode *expr, znode *second_semicolon_token CLS_DC)
{
int for_cond_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -397,7 +400,7 @@ void zend_do_for_cond(znode *expr, znode *second_semicolon_token CLS_DC)
}
void zend_do_for_before_statement(znode *cond_start, znode *second_semicolon_token CLS_DC)
void do_for_before_statement(znode *cond_start, znode *second_semicolon_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -413,7 +416,7 @@ void zend_do_for_before_statement(znode *cond_start, znode *second_semicolon_tok
}
void zend_do_for_end(znode *second_semicolon_token CLS_DC)
void do_for_end(znode *second_semicolon_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -429,7 +432,7 @@ void zend_do_for_end(znode *second_semicolon_token CLS_DC)
}
void zend_do_pre_incdec(znode *result, znode *op1, int op CLS_DC)
void do_pre_incdec(znode *result, znode *op1, int op CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -443,7 +446,7 @@ void zend_do_pre_incdec(znode *result, znode *op1, int op CLS_DC)
}
void zend_do_post_incdec(znode *result, znode *op1, int op CLS_DC)
void do_post_incdec(znode *result, znode *op1, int op CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -456,7 +459,7 @@ void zend_do_post_incdec(znode *result, znode *op1, int op CLS_DC)
}
void zend_do_if_cond(znode *cond, znode *closing_bracket_token CLS_DC)
void do_if_cond(znode *cond, znode *closing_bracket_token CLS_DC)
{
int if_cond_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -469,7 +472,7 @@ void zend_do_if_cond(znode *cond, znode *closing_bracket_token CLS_DC)
}
void zend_do_if_after_statement(znode *closing_bracket_token, unsigned char initialize CLS_DC)
void do_if_after_statement(znode *closing_bracket_token, unsigned char initialize CLS_DC)
{
int if_end_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -492,7 +495,7 @@ void zend_do_if_after_statement(znode *closing_bracket_token, unsigned char init
}
void zend_do_if_end(CLS_D)
void do_if_end(CLS_D)
{
int next_op_number = get_next_op_number(CG(active_op_array));
zend_llist *jmp_list_ptr;
@@ -508,7 +511,7 @@ void zend_do_if_end(CLS_D)
}
void zend_do_begin_variable_parse(CLS_D)
void do_begin_variable_parse(CLS_D)
{
zend_llist fetch_list;
@@ -517,7 +520,7 @@ void zend_do_begin_variable_parse(CLS_D)
}
void zend_do_end_variable_parse(int type, int arg_offset CLS_DC)
void do_end_variable_parse(int type, int arg_offset CLS_DC)
{
zend_llist *fetch_list_ptr;
zend_llist_element *le;
@@ -582,7 +585,7 @@ static zend_bool is_method_call(CLS_D)
}
void zend_do_init_string(znode *result CLS_DC)
void do_init_string(znode *result CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -595,7 +598,7 @@ void zend_do_init_string(znode *result CLS_DC)
}
void zend_do_add_char(znode *result, znode *op1, znode *op2 CLS_DC)
void do_add_char(znode *result, znode *op1, znode *op2 CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -608,7 +611,7 @@ void zend_do_add_char(znode *result, znode *op1, znode *op2 CLS_DC)
}
void zend_do_add_string(znode *result, znode *op1, znode *op2 CLS_DC)
void do_add_string(znode *result, znode *op1, znode *op2 CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -621,7 +624,7 @@ void zend_do_add_string(znode *result, znode *op1, znode *op2 CLS_DC)
}
void zend_do_add_variable(znode *result, znode *op1, znode *op2 CLS_DC)
void do_add_variable(znode *result, znode *op1, znode *op2 CLS_DC)
{
zend_op *opline;
@@ -657,7 +660,7 @@ void zend_do_add_variable(znode *result, znode *op1, znode *op2 CLS_DC)
}
void zend_do_free(znode *op1 CLS_DC)
void do_free(znode *op1 CLS_DC)
{
if (op1->op_type==IS_TMP_VAR) {
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -703,7 +706,7 @@ void zend_do_free(znode *op1 CLS_DC)
}
void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference CLS_DC)
void do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference CLS_DC)
{
zend_op_array op_array;
char *name = function_name->u.constant.value.str.val;
@@ -760,10 +763,10 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
}
void zend_do_end_function_declaration(znode *function_token CLS_DC)
void do_end_function_declaration(znode *function_token CLS_DC)
{
zend_do_extended_info(CLS_C);
zend_do_return(NULL, 0 CLS_CC);
do_extended_info(CLS_C);
do_return(NULL, 0 CLS_CC);
pass_two(CG(active_op_array));
CG(active_op_array) = function_token->u.op_array;
@@ -773,7 +776,7 @@ void zend_do_end_function_declaration(znode *function_token CLS_DC)
}
void zend_do_receive_arg(int op, znode *var, znode *offset, znode *initialization, unsigned char pass_type CLS_DC)
void do_receive_arg(int op, znode *var, znode *offset, znode *initialization, unsigned char pass_type CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -804,7 +807,7 @@ void zend_do_receive_arg(int op, znode *var, znode *offset, znode *initializatio
}
int zend_do_begin_function_call(znode *function_name CLS_DC)
int do_begin_function_call(znode *function_name CLS_DC)
{
zend_function *function;
@@ -813,7 +816,7 @@ int zend_do_begin_function_call(znode *function_name CLS_DC)
znode tmp = *function_name;
zval_copy_ctor(&tmp.u.constant);
zend_do_begin_dynamic_function_call(&tmp CLS_CC);
do_begin_dynamic_function_call(&tmp CLS_CC);
return 1; /* Dynamic */
}
@@ -831,19 +834,19 @@ int zend_do_begin_function_call(znode *function_name CLS_DC)
}
break;
}
zend_do_extended_fcall_begin(CLS_C);
do_extended_fcall_begin(CLS_C);
return 0;
}
void zend_do_begin_dynamic_function_call(znode *function_name CLS_DC)
void do_begin_dynamic_function_call(znode *function_name CLS_DC)
{
unsigned char *ptr = NULL;
int last_op_number;
zend_op *last_op;
if (function_name->op_type != IS_CONST && is_method_call(CLS_C)) {
zend_do_end_variable_parse(BP_VAR_W, 0 CLS_CC);
do_end_variable_parse(BP_VAR_W, 0 CLS_CC);
last_op_number = get_next_op_number(CG(active_op_array))-1;
last_op = &CG(active_op_array)->opcodes[last_op_number];
last_op->opcode = ZEND_INIT_FCALL_BY_NAME;
@@ -852,7 +855,7 @@ void zend_do_begin_dynamic_function_call(znode *function_name CLS_DC)
zend_op *opline;
if (function_name->op_type != IS_CONST) {
zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
}
opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -862,11 +865,11 @@ void zend_do_begin_dynamic_function_call(znode *function_name CLS_DC)
SET_UNUSED(opline->op1);
}
zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *));
zend_do_extended_fcall_begin(CLS_C);
do_extended_fcall_begin(CLS_C);
}
void zend_do_begin_class_member_function_call(znode *class_name, znode *function_name CLS_DC)
void do_begin_class_member_function_call(znode *class_name, znode *function_name CLS_DC)
{
unsigned char *ptr = NULL;
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -890,7 +893,7 @@ void zend_do_begin_class_member_function_call(znode *class_name, znode *function
}
void zend_do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall CLS_DC)
void do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -910,13 +913,12 @@ void zend_do_end_function_call(znode *function_name, znode *result, znode *argum
}
void zend_do_pass_param(znode *param, int op, int offset CLS_DC)
void do_pass_param(znode *param, int op, int offset CLS_DC)
{
zend_op *opline;
unsigned char *arg_types;
int original_op=op;
zend_function **function_ptr_ptr, *function_ptr;
int send_by_reference;
zend_stack_top(&CG(function_call_stack), (void **) &function_ptr_ptr);
@@ -940,13 +942,20 @@ void zend_do_pass_param(znode *param, int op, int offset CLS_DC)
arg_types = NULL;
}
send_by_reference = ARG_SHOULD_BE_SENT_BY_REF(offset, 1, arg_types)?ZEND_ARG_SEND_BY_REF:0;
if (op == ZEND_SEND_VAL && param->op_type == IS_VAR) {
op = ZEND_SEND_VAR_NO_REF;
if (op == ZEND_SEND_VAL) {
switch (param->op_type) {
case IS_CONST: /* constants behave like variables when passed to functions,
* as far as reference counting is concerned. Treat them
* as if they were variables here.
*/
case IS_VAR:
op = ZEND_SEND_VAR;
break;
}
}
if (op!=ZEND_SEND_VAR_NO_REF && send_by_reference == ZEND_ARG_SEND_BY_REF) {
if (ARG_SHOULD_BE_SENT_BY_REF(offset, 1, arg_types)) {
/* change to passing by reference */
switch (param->op_type) {
case IS_VAR:
@@ -958,38 +967,26 @@ void zend_do_pass_param(znode *param, int op, int offset CLS_DC)
}
}
if (original_op == ZEND_SEND_VAR) {
if (original_op==ZEND_SEND_VAR) {
switch(op) {
case ZEND_SEND_VAR_NO_REF:
zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
break;
case ZEND_SEND_VAR:
if (function_ptr) {
zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
} else {
zend_do_end_variable_parse(BP_VAR_FUNC_ARG, offset CLS_CC);
do_end_variable_parse(BP_VAR_FUNC_ARG, offset CLS_CC);
}
break;
case ZEND_SEND_REF:
zend_do_end_variable_parse(BP_VAR_W, 0 CLS_CC);
do_end_variable_parse(BP_VAR_W, 0 CLS_CC);
break;
}
}
opline = get_next_op(CG(active_op_array) CLS_CC);
if (op == ZEND_SEND_VAR_NO_REF) {
if (function_ptr) {
opline->extended_value = ZEND_ARG_COMPILE_TIME_BOUND | send_by_reference;
} else {
opline->extended_value = 0;
}
if (function_ptr) {
opline->extended_value = ZEND_DO_FCALL;
} else {
if (function_ptr) {
opline->extended_value = ZEND_DO_FCALL;
} else {
opline->extended_value = ZEND_DO_FCALL_BY_NAME;
}
opline->extended_value = ZEND_DO_FCALL_BY_NAME;
}
opline->opcode = op;
opline->op1 = *param;
@@ -1032,15 +1029,15 @@ static int generate_free_foreach_copy(znode *foreach_copy CLS_DC)
return 0;
}
void zend_do_return(znode *expr, int do_end_vparse CLS_DC)
void do_return(znode *expr, int do_end_vparse CLS_DC)
{
zend_op *opline;
if (do_end_vparse) {
if (CG(active_op_array)->return_reference) {
zend_do_end_variable_parse(BP_VAR_W, 0 CLS_CC);
do_end_variable_parse(BP_VAR_W, 0 CLS_CC);
} else {
zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
}
}
#ifdef ZTS
@@ -1097,7 +1094,7 @@ static void do_inherit_parent_constructor(zend_class_entry *ce)
}
}
void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
void do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
{
zend_function tmp_zend_function;
zval *tmp;
@@ -1184,7 +1181,7 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
}
efree(parent_name);
zend_do_inheritance(ce, parent_ce);
do_inheritance(ce, parent_ce);
/* Register the derived class */
if (zend_hash_add(class_table, class_name, strlen(class_name)+1, ce, sizeof(zend_class_entry), NULL)==FAILURE) {
@@ -1204,7 +1201,7 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
}
void zend_do_early_binding(CLS_D)
void do_early_binding(CLS_D)
{
zend_op *opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1];
HashTable *table;
@@ -1234,7 +1231,7 @@ void zend_do_early_binding(CLS_D)
}
void zend_do_boolean_or_begin(znode *expr1, znode *op_token CLS_DC)
void do_boolean_or_begin(znode *expr1, znode *op_token CLS_DC)
{
int next_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1255,7 +1252,7 @@ void zend_do_boolean_or_begin(znode *expr1, znode *op_token CLS_DC)
}
void zend_do_boolean_or_end(znode *result, znode *expr1, znode *expr2, znode *op_token CLS_DC)
void do_boolean_or_end(znode *result, znode *expr1, znode *expr2, znode *op_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1269,7 +1266,7 @@ void zend_do_boolean_or_end(znode *result, znode *expr1, znode *expr2, znode *op
}
void zend_do_boolean_and_begin(znode *expr1, znode *op_token CLS_DC)
void do_boolean_and_begin(znode *expr1, znode *op_token CLS_DC)
{
int next_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1290,7 +1287,7 @@ void zend_do_boolean_and_begin(znode *expr1, znode *op_token CLS_DC)
}
void zend_do_boolean_and_end(znode *result, znode *expr1, znode *expr2, znode *op_token CLS_DC)
void do_boolean_and_end(znode *result, znode *expr1, znode *expr2, znode *op_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1304,14 +1301,14 @@ void zend_do_boolean_and_end(znode *result, znode *expr1, znode *expr2, znode *o
}
void zend_do_do_while_begin(CLS_D)
void do_do_while_begin(CLS_D)
{
do_begin_loop(CLS_C);
INC_BPC(CG(active_op_array));
}
void zend_do_do_while_end(znode *do_token, znode *expr_open_bracket, znode *expr CLS_DC)
void do_do_while_end(znode *do_token, znode *expr_open_bracket, znode *expr CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1326,7 +1323,7 @@ void zend_do_do_while_end(znode *do_token, znode *expr_open_bracket, znode *expr
}
void zend_do_brk_cont(int op, znode *expr CLS_DC)
void do_brk_cont(int op, znode *expr CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1344,7 +1341,7 @@ void zend_do_brk_cont(int op, znode *expr CLS_DC)
}
void zend_do_switch_cond(znode *cond CLS_DC)
void do_switch_cond(znode *cond CLS_DC)
{
zend_switch_entry switch_entry;
zend_op *opline;
@@ -1372,7 +1369,7 @@ void zend_do_switch_cond(znode *cond CLS_DC)
void zend_do_switch_end(znode *case_list CLS_DC)
void do_switch_end(znode *case_list CLS_DC)
{
zend_op *opline;
zend_switch_entry *switch_entry_ptr;
@@ -1417,7 +1414,7 @@ void zend_do_switch_end(znode *case_list CLS_DC)
}
void zend_do_case_before_statement(znode *case_list, znode *case_token, znode *case_expr CLS_DC)
void do_case_before_statement(znode *case_list, znode *case_token, znode *case_expr CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
int next_op_number;
@@ -1451,7 +1448,7 @@ void zend_do_case_before_statement(znode *case_list, znode *case_token, znode *c
}
void zend_do_case_after_statement(znode *result, znode *case_token CLS_DC)
void do_case_after_statement(znode *result, znode *case_token CLS_DC)
{
int next_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1473,7 +1470,7 @@ void zend_do_case_after_statement(znode *result, znode *case_token CLS_DC)
void zend_do_default_before_statement(znode *case_list, znode *default_token CLS_DC)
void do_default_before_statement(znode *case_list, znode *default_token CLS_DC)
{
int next_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1506,7 +1503,7 @@ void zend_do_default_before_statement(znode *case_list, znode *default_token CLS
}
void zend_do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_DC)
void do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
int runtime_inheritance = 0;
@@ -1588,14 +1585,14 @@ void zend_do_begin_class_declaration(znode *class_name, znode *parent_class_name
}
void zend_do_end_class_declaration(CLS_D)
void do_end_class_declaration(CLS_D)
{
do_inherit_parent_constructor(CG(active_class_entry));
CG(active_class_entry) = NULL;
}
void zend_do_declare_property(znode *var_name, znode *value CLS_DC)
void do_declare_property(znode *var_name, znode *value CLS_DC)
{
if (value) {
zval *property;
@@ -1609,7 +1606,7 @@ void zend_do_declare_property(znode *var_name, znode *value CLS_DC)
}
void zend_do_fetch_property(znode *result, znode *object, znode *property CLS_DC)
void do_fetch_property(znode *result, znode *object, znode *property CLS_DC)
{
zend_op opline;
zend_llist *fetch_list_ptr;
@@ -1628,13 +1625,13 @@ void zend_do_fetch_property(znode *result, znode *object, znode *property CLS_DC
}
void zend_do_push_object(znode *object CLS_DC)
void do_push_object(znode *object CLS_DC)
{
zend_stack_push(&CG(object_stack), object, sizeof(znode));
}
void zend_do_pop_object(znode *object CLS_DC)
void do_pop_object(znode *object CLS_DC)
{
znode *tmp;
@@ -1644,7 +1641,7 @@ void zend_do_pop_object(znode *object CLS_DC)
}
void zend_do_begin_new_object(znode *new_token, znode *class_name CLS_DC)
void do_begin_new_object(znode *new_token, znode *class_name CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
unsigned char *ptr = NULL;
@@ -1655,6 +1652,10 @@ void zend_do_begin_new_object(znode *new_token, znode *class_name CLS_DC)
opline->op1 = *class_name;
SET_UNUSED(opline->op2);
/* *result = opline->result;
do_assign(result, variable, &opline->result CLS_CC); */
new_token->u.opline_num = get_next_op_number(CG(active_op_array));
opline = get_next_op(CG(active_op_array) CLS_CC);
opline->opcode = ZEND_JMP_NO_CTOR;
@@ -1673,22 +1674,22 @@ void zend_do_begin_new_object(znode *new_token, znode *class_name CLS_DC)
}
void zend_do_end_new_object(znode *result, znode *class_name, znode *new_token, znode *argument_list CLS_DC)
void do_end_new_object(znode *result, znode *class_name, znode *new_token, znode *argument_list CLS_DC)
{
znode ctor_result;
if (class_name->op_type == IS_CONST) {
zval_copy_ctor(&class_name->u.constant);
}
zend_do_end_function_call(class_name, &ctor_result, argument_list, 1, 0 CLS_CC);
zend_do_free(&ctor_result CLS_CC);
do_end_function_call(class_name, &ctor_result, argument_list, 1, 0 CLS_CC);
do_free(&ctor_result CLS_CC);
CG(active_op_array)->opcodes[new_token->u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array));
*result = CG(active_op_array)->opcodes[new_token->u.opline_num].op1;
}
void zend_do_fetch_constant(znode *result, znode *constant_name, int mode CLS_DC)
void do_fetch_constant(znode *result, znode *constant_name, int mode CLS_DC)
{
switch (mode) {
case ZEND_CT:
@@ -1710,7 +1711,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_name, int mode CLS_DC
}
void zend_do_shell_exec(znode *result, znode *cmd CLS_DC)
void do_shell_exec(znode *result, znode *cmd CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1743,7 +1744,7 @@ void zend_do_shell_exec(znode *result, znode *cmd CLS_DC)
void zend_do_init_array(znode *result, znode *expr, znode *offset, int is_ref CLS_DC)
void do_init_array(znode *result, znode *expr, znode *offset, int is_ref CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1766,7 +1767,7 @@ void zend_do_init_array(znode *result, znode *expr, znode *offset, int is_ref CL
}
void zend_do_add_array_element(znode *result, znode *expr, znode *offset, int is_ref CLS_DC)
void do_add_array_element(znode *result, znode *expr, znode *offset, int is_ref CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1783,7 +1784,7 @@ void zend_do_add_array_element(znode *result, znode *expr, znode *offset, int is
void zend_do_add_static_array_element(znode *result, znode *offset, znode *expr)
void do_add_static_array_element(znode *result, znode *offset, znode *expr)
{
zval *element;
@@ -1805,7 +1806,7 @@ void zend_do_add_static_array_element(znode *result, znode *offset, znode *expr)
}
void zend_do_add_list_element(znode *element CLS_DC)
void do_add_list_element(znode *element CLS_DC)
{
list_llist_element lle;
@@ -1818,29 +1819,29 @@ void zend_do_add_list_element(znode *element CLS_DC)
}
void zend_do_new_list_begin(CLS_D)
void do_new_list_begin(CLS_D)
{
int current_dimension = 0;
zend_llist_add_element(&CG(dimension_llist), &current_dimension);
}
void zend_do_new_list_end(CLS_D)
void do_new_list_end(CLS_D)
{
zend_llist_remove_tail(&CG(dimension_llist));
(*((int *)CG(dimension_llist).tail->data))++;
}
void zend_do_list_init(CLS_D)
void do_list_init(CLS_D)
{
zend_llist_init(&CG(list_llist), sizeof(list_llist_element), NULL, 0);
zend_llist_init(&CG(dimension_llist), sizeof(int), NULL, 0);
zend_do_new_list_begin(CLS_C);
do_new_list_begin(CLS_C);
}
void zend_do_list_end(znode *result, znode *expr CLS_DC)
void do_list_end(znode *result, znode *expr CLS_DC)
{
zend_llist_element *le;
zend_llist_element *dimension;
@@ -1860,10 +1861,7 @@ void zend_do_list_end(znode *result, znode *expr CLS_DC)
opline->opcode = ZEND_FETCH_DIM_R;
break;
case IS_TMP_VAR:
opline->opcode = ZEND_FETCH_DIM_TMP_VAR;
break;
case IS_CONST: /* fetch_dim_tmp_var will handle this bogus fetch */
zval_copy_ctor(&expr->u.constant);
opline->opcode = ZEND_FETCH_DIM_TMP_VAR;
break;
}
@@ -1884,8 +1882,8 @@ void zend_do_list_end(znode *result, znode *expr CLS_DC)
}
((list_llist_element *) le->data)->value = last_container;
zend_llist_destroy(&((list_llist_element *) le->data)->dimensions);
zend_do_end_variable_parse(BP_VAR_W, 0 CLS_CC);
zend_do_assign(result, &((list_llist_element *) le->data)->var, &((list_llist_element *) le->data)->value CLS_CC);
do_end_variable_parse(BP_VAR_W, 0 CLS_CC);
do_assign(result, &((list_llist_element *) le->data)->var, &((list_llist_element *) le->data)->value CLS_CC);
CG(active_op_array)->opcodes[CG(active_op_array)->last-1].result.u.EA.type |= EXT_TYPE_UNUSED;
le = le->next;
}
@@ -1895,7 +1893,7 @@ void zend_do_list_end(znode *result, znode *expr CLS_DC)
}
void zend_do_fetch_global_or_static_variable(znode *varname, znode *static_assignment, int fetch_type CLS_DC)
void do_fetch_global_or_static_variable(znode *varname, znode *static_assignment, int fetch_type CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
znode lval;
@@ -1929,12 +1927,12 @@ void zend_do_fetch_global_or_static_variable(znode *varname, znode *static_assig
}
fetch_simple_variable(&lval, varname, 0 CLS_CC); /* Relies on the fact that the default fetch is BP_VAR_W */
zend_do_assign_ref(NULL, &lval, &result CLS_CC);
do_assign_ref(NULL, &lval, &result CLS_CC);
CG(active_op_array)->opcodes[CG(active_op_array)->last-1].result.u.EA.type |= EXT_TYPE_UNUSED;
}
void zend_do_cast(znode *result, znode *expr, int type CLS_DC)
void do_cast(znode *result, znode *expr, int type CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1948,9 +1946,9 @@ void zend_do_cast(znode *result, znode *expr, int type CLS_DC)
}
void zend_do_include_or_eval(int type, znode *result, znode *op1 CLS_DC)
void do_include_or_eval(int type, znode *result, znode *op1 CLS_DC)
{
zend_do_extended_fcall_begin(CLS_C);
do_extended_fcall_begin(CLS_C);
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -1965,25 +1963,25 @@ void zend_do_include_or_eval(int type, znode *result, znode *op1 CLS_DC)
opline->result.u.EA.type |= EXT_TYPE_UNUSED;
}
}
zend_do_extended_fcall_end(CLS_C);
do_extended_fcall_end(CLS_C);
}
void zend_do_indirect_references(znode *result, znode *num_references, znode *variable CLS_DC)
void do_indirect_references(znode *result, znode *num_references, znode *variable CLS_DC)
{
int i;
zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
do_end_variable_parse(BP_VAR_R, 0 CLS_CC);
for (i=1; i<num_references->u.constant.value.lval; i++) {
fetch_simple_variable_ex(result, variable, 0, ZEND_FETCH_R CLS_CC);
*variable = *result;
}
zend_do_begin_variable_parse(CLS_C);
do_begin_variable_parse(CLS_C);
fetch_simple_variable(result, variable, 1 CLS_CC);
}
void zend_do_unset(znode *variable CLS_DC)
void do_unset(znode *variable CLS_DC)
{
zend_op *last_op;
@@ -2002,11 +2000,11 @@ void zend_do_unset(znode *variable CLS_DC)
}
void zend_do_isset_or_isempty(int type, znode *result, znode *variable CLS_DC)
void do_isset_or_isempty(int type, znode *result, znode *variable CLS_DC)
{
zend_op *opline;
zend_do_end_variable_parse(BP_VAR_IS, 0 CLS_CC);
do_end_variable_parse(BP_VAR_IS, 0 CLS_CC);
opline = get_next_op(CG(active_op_array) CLS_CC);
opline->opcode = ZEND_ISSET_ISEMPTY;
@@ -2019,7 +2017,7 @@ void zend_do_isset_or_isempty(int type, znode *result, znode *variable CLS_DC)
}
void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable CLS_DC)
void do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -2051,7 +2049,7 @@ void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brack
}
void zend_do_foreach_cont(znode *value, znode *key, znode *as_token CLS_DC)
void do_foreach_cont(znode *value, znode *key, znode *as_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
znode result_value, result_key, dummy;
@@ -2090,20 +2088,20 @@ void zend_do_foreach_cont(znode *value, znode *key, znode *as_token CLS_DC)
result_key = opline->result;
}
zend_do_assign(&dummy, value, &result_value CLS_CC);
do_assign(&dummy, value, &result_value CLS_CC);
CG(active_op_array)->opcodes[CG(active_op_array)->last-1].result.u.EA.type |= EXT_TYPE_UNUSED;
if (key->op_type != IS_UNUSED) {
zend_do_assign(&dummy, key, &result_key CLS_CC);
do_assign(&dummy, key, &result_key CLS_CC);
CG(active_op_array)->opcodes[CG(active_op_array)->last-1].result.u.EA.type |= EXT_TYPE_UNUSED;
}
zend_do_free(as_token CLS_CC);
do_free(as_token CLS_CC);
do_begin_loop(CLS_C);
INC_BPC(CG(active_op_array));
}
void zend_do_foreach_end(znode *foreach_token, znode *open_brackets_token CLS_DC)
void do_foreach_end(znode *foreach_token, znode *open_brackets_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -2124,13 +2122,13 @@ void zend_do_foreach_end(znode *foreach_token, znode *open_brackets_token CLS_DC
}
void zend_do_declare_begin(CLS_D)
void do_declare_begin(CLS_D)
{
zend_stack_push(&CG(declare_stack), &CG(declarables), sizeof(zend_declarables));
}
void zend_do_declare_stmt(znode *var, znode *val CLS_DC)
void do_declare_stmt(znode *var, znode *val CLS_DC)
{
convert_to_string(&var->u.constant);
@@ -2142,7 +2140,7 @@ void zend_do_declare_stmt(znode *var, znode *val CLS_DC)
}
void zend_do_declare_end(CLS_D)
void do_declare_end(CLS_D)
{
zend_declarables *declarables;
@@ -2151,7 +2149,7 @@ void zend_do_declare_end(CLS_D)
}
void zend_do_end_heredoc(CLS_D)
void do_end_heredoc(CLS_D)
{
int opline_num = get_next_op_number(CG(active_op_array))-1;
zend_op *opline = &CG(active_op_array)->opcodes[opline_num];
@@ -2169,7 +2167,7 @@ void zend_do_end_heredoc(CLS_D)
}
void zend_do_exit(znode *result, znode *message CLS_DC)
void do_exit(znode *result, znode *message CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -2183,7 +2181,7 @@ void zend_do_exit(znode *result, znode *message CLS_DC)
}
void zend_do_begin_silence(znode *strudel_token CLS_DC)
void do_begin_silence(znode *strudel_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -2196,7 +2194,7 @@ void zend_do_begin_silence(znode *strudel_token CLS_DC)
}
void zend_do_end_silence(znode *strudel_token CLS_DC)
void do_end_silence(znode *strudel_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -2206,7 +2204,7 @@ void zend_do_end_silence(znode *strudel_token CLS_DC)
}
void zend_do_begin_qm_op(znode *cond, znode *qm_token CLS_DC)
void do_begin_qm_op(znode *cond, znode *qm_token CLS_DC)
{
int jmpz_op_number = get_next_op_number(CG(active_op_array));
zend_op *opline;
@@ -2223,7 +2221,7 @@ void zend_do_begin_qm_op(znode *cond, znode *qm_token CLS_DC)
}
void zend_do_qm_true(znode *true_value, znode *qm_token, znode *colon_token CLS_DC)
void do_qm_true(znode *true_value, znode *qm_token, znode *colon_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -2245,7 +2243,7 @@ void zend_do_qm_true(znode *true_value, znode *qm_token, znode *colon_token CLS_
}
void zend_do_qm_false(znode *result, znode *false_value, znode *qm_token, znode *colon_token CLS_DC)
void do_qm_false(znode *result, znode *false_value, znode *qm_token, znode *colon_token CLS_DC)
{
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
@@ -2262,7 +2260,7 @@ void zend_do_qm_false(znode *result, znode *false_value, znode *qm_token, znode
}
void zend_do_extended_info(CLS_D)
void do_extended_info(CLS_D)
{
zend_op *opline;
@@ -2278,7 +2276,7 @@ void zend_do_extended_info(CLS_D)
}
void zend_do_extended_fcall_begin(CLS_D)
void do_extended_fcall_begin(CLS_D)
{
zend_op *opline;
@@ -2294,7 +2292,7 @@ void zend_do_extended_fcall_begin(CLS_D)
}
void zend_do_extended_fcall_end(CLS_D)
void do_extended_fcall_end(CLS_D)
{
zend_op *opline;
@@ -2309,7 +2307,7 @@ void zend_do_extended_fcall_end(CLS_D)
SET_UNUSED(opline->op2);
}
void zend_do_ticks(CLS_D)
void do_ticks(CLS_D)
{
if (CG(declarables).ticks.value.lval) {
zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
+90 -95
View File
@@ -44,7 +44,6 @@
#define FREE_PNODE(znode) zval_dtor(&znode->u.constant);
#define FREE_OP(op, should_free) if (should_free) zval_dtor(&Ts[(op)->u.var].tmp_var);
#define SET_UNUSED(op) (op).op_type = IS_UNUSED
#if SUPPORT_INTERACTIVE
#define INC_BPC(op_array) ((op_array)->backpatch_count++)
@@ -237,145 +236,145 @@ int zend_get_zendleng(CLS_D);
/* parser-driven code generators */
void zend_do_binary_op(int op, znode *result, znode *op1, znode *op2 CLS_DC);
void zend_do_unary_op(int op, znode *result, znode *op1 CLS_DC);
void zend_do_binary_assign_op(int op, znode *result, znode *op1, znode *op2 CLS_DC);
void zend_do_assign(znode *result, znode *variable, znode *value CLS_DC);
void zend_do_assign_ref(znode *result, znode *lvar, znode *rvar CLS_DC);
void do_binary_op(int op, znode *result, znode *op1, znode *op2 CLS_DC);
void do_unary_op(int op, znode *result, znode *op1 CLS_DC);
void do_binary_assign_op(int op, znode *result, znode *op1, znode *op2 CLS_DC);
void do_assign(znode *result, znode *variable, znode *value CLS_DC);
void do_assign_ref(znode *result, znode *lvar, znode *rvar CLS_DC);
void fetch_simple_variable(znode *result, znode *varname, int bp CLS_DC);
void fetch_simple_variable_ex(znode *result, znode *varname, int bp, int op CLS_DC);
void zend_do_indirect_references(znode *result, znode *num_references, znode *variable CLS_DC);
void zend_do_fetch_global_or_static_variable(znode *varname, znode *static_assignment, int fetch_type CLS_DC);
void zend_do_fetch_globals(znode *varname CLS_DC);
void do_indirect_references(znode *result, znode *num_references, znode *variable CLS_DC);
void do_fetch_global_or_static_variable(znode *varname, znode *static_assignment, int fetch_type CLS_DC);
void do_fetch_globals(znode *varname CLS_DC);
void fetch_array_begin(znode *result, znode *varname, znode *first_dim CLS_DC);
void fetch_array_dim(znode *result, znode *parent, znode *dim CLS_DC);
void fetch_string_offset(znode *result, znode *parent, znode *offset CLS_DC);
void zend_do_print(znode *result, znode *arg CLS_DC);
void zend_do_echo(znode *arg CLS_DC);
void do_print(znode *result, znode *arg CLS_DC);
void do_echo(znode *arg CLS_DC);
typedef int (*unary_op_type)(zval *, zval *);
ZEND_API unary_op_type get_unary_op(int opcode);
ZEND_API void *get_binary_op(int opcode);
void zend_do_while_cond(znode *expr, znode *close_bracket_token CLS_DC);
void zend_do_while_end(znode *while_token, znode *close_bracket_token CLS_DC);
void zend_do_do_while_begin(CLS_D);
void zend_do_do_while_end(znode *do_token, znode *expr_open_bracket, znode *expr CLS_DC);
void do_while_cond(znode *expr, znode *close_bracket_token CLS_DC);
void do_while_end(znode *while_token, znode *close_bracket_token CLS_DC);
void do_do_while_begin(CLS_D);
void do_do_while_end(znode *do_token, znode *expr_open_bracket, znode *expr CLS_DC);
void zend_do_if_cond(znode *cond, znode *closing_bracket_token CLS_DC);
void zend_do_if_after_statement(znode *closing_bracket_token, unsigned char initialize CLS_DC);
void zend_do_if_end(CLS_D);
void do_if_cond(znode *cond, znode *closing_bracket_token CLS_DC);
void do_if_after_statement(znode *closing_bracket_token, unsigned char initialize CLS_DC);
void do_if_end(CLS_D);
void zend_do_for_cond(znode *expr, znode *second_semicolon_token CLS_DC);
void zend_do_for_before_statement(znode *cond_start, znode *second_semicolon_token CLS_DC);
void zend_do_for_end(znode *second_semicolon_token CLS_DC);
void do_for_cond(znode *expr, znode *second_semicolon_token CLS_DC);
void do_for_before_statement(znode *cond_start, znode *second_semicolon_token CLS_DC);
void do_for_end(znode *second_semicolon_token CLS_DC);
void zend_do_pre_incdec(znode *result, znode *op1, int op CLS_DC);
void zend_do_post_incdec(znode *result, znode *op1, int op CLS_DC);
void do_pre_incdec(znode *result, znode *op1, int op CLS_DC);
void do_post_incdec(znode *result, znode *op1, int op CLS_DC);
void zend_do_begin_variable_parse(CLS_D);
void zend_do_end_variable_parse(int type, int arg_offset CLS_DC);
void do_begin_variable_parse(CLS_D);
void do_end_variable_parse(int type, int arg_offset CLS_DC);
void zend_do_free(znode *op1 CLS_DC);
void do_free(znode *op1 CLS_DC);
void zend_do_init_string(znode *result CLS_DC);
void zend_do_add_char(znode *result, znode *op1, znode *op2 CLS_DC);
void zend_do_add_string(znode *result, znode *op1, znode *op2 CLS_DC);
void zend_do_add_variable(znode *result, znode *op1, znode *op2 CLS_DC);
void do_init_string(znode *result CLS_DC);
void do_add_char(znode *result, znode *op1, znode *op2 CLS_DC);
void do_add_string(znode *result, znode *op1, znode *op2 CLS_DC);
void do_add_variable(znode *result, znode *op1, znode *op2 CLS_DC);
void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference CLS_DC);
void zend_do_end_function_declaration(znode *function_token CLS_DC);
void zend_do_receive_arg(int op, znode *var, znode *offset, znode *initialization, unsigned char pass_type CLS_DC);
int zend_do_begin_function_call(znode *function_name CLS_DC);
void zend_do_begin_dynamic_function_call(znode *function_name CLS_DC);
void zend_do_begin_class_member_function_call(znode *class_name, znode *function_name CLS_DC);
void zend_do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall CLS_DC);
void zend_do_return(znode *expr, int do_end_vparse CLS_DC);
void do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference CLS_DC);
void do_end_function_declaration(znode *function_token CLS_DC);
void do_receive_arg(int op, znode *var, znode *offset, znode *initialization, unsigned char pass_type CLS_DC);
int do_begin_function_call(znode *function_name CLS_DC);
void do_begin_dynamic_function_call(znode *function_name CLS_DC);
void do_begin_class_member_function_call(znode *class_name, znode *function_name CLS_DC);
void do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall CLS_DC);
void do_return(znode *expr, int do_end_vparse CLS_DC);
ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, HashTable *class_table, int compile_time);
void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
void zend_do_early_binding(CLS_D);
void do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
void do_early_binding(CLS_D);
void zend_do_pass_param(znode *param, int op, int offset CLS_DC);
void do_pass_param(znode *param, int op, int offset CLS_DC);
void zend_do_boolean_or_begin(znode *expr1, znode *op_token CLS_DC);
void zend_do_boolean_or_end(znode *result, znode *expr1, znode *expr2, znode *op_token CLS_DC);
void zend_do_boolean_and_begin(znode *expr1, znode *op_token CLS_DC);
void zend_do_boolean_and_end(znode *result, znode *expr1, znode *expr2, znode *op_token CLS_DC);
void do_boolean_or_begin(znode *expr1, znode *op_token CLS_DC);
void do_boolean_or_end(znode *result, znode *expr1, znode *expr2, znode *op_token CLS_DC);
void do_boolean_and_begin(znode *expr1, znode *op_token CLS_DC);
void do_boolean_and_end(znode *result, znode *expr1, znode *expr2, znode *op_token CLS_DC);
void zend_do_brk_cont(int op, znode *expr CLS_DC);
void do_brk_cont(int op, znode *expr CLS_DC);
void zend_do_switch_cond(znode *cond CLS_DC);
void zend_do_switch_end(znode *case_list CLS_DC);
void zend_do_case_before_statement(znode *case_list, znode *case_token, znode *case_expr CLS_DC);
void zend_do_case_after_statement(znode *result, znode *case_token CLS_DC);
void zend_do_default_before_statement(znode *case_list, znode *default_token CLS_DC);
void do_switch_cond(znode *cond CLS_DC);
void do_switch_end(znode *case_list CLS_DC);
void do_case_before_statement(znode *case_list, znode *case_token, znode *case_expr CLS_DC);
void do_case_after_statement(znode *result, znode *case_token CLS_DC);
void do_default_before_statement(znode *case_list, znode *default_token CLS_DC);
void zend_do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_DC);
void zend_do_end_class_declaration(CLS_D);
void zend_do_declare_property(znode *var_name, znode *value CLS_DC);
void do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_DC);
void do_end_class_declaration(CLS_D);
void do_declare_property(znode *var_name, znode *value CLS_DC);
void zend_do_fetch_property(znode *result, znode *object, znode *property CLS_DC);
void do_fetch_property(znode *result, znode *object, znode *property CLS_DC);
void zend_do_push_object(znode *object CLS_DC);
void zend_do_pop_object(znode *object CLS_DC);
void do_push_object(znode *object CLS_DC);
void do_pop_object(znode *object CLS_DC);
void zend_do_begin_new_object(znode *new_token, znode *class_name CLS_DC);
void zend_do_end_new_object(znode *result, znode *class_name, znode *new_token, znode *argument_list CLS_DC);
void do_begin_new_object(znode *new_token, znode *class_name CLS_DC);
void do_end_new_object(znode *result, znode *class_name, znode *new_token, znode *argument_list CLS_DC);
void zend_do_fetch_constant(znode *result, znode *constant_name, int mode CLS_DC);
void do_fetch_constant(znode *result, znode *constant_name, int mode CLS_DC);
void zend_do_shell_exec(znode *result, znode *cmd CLS_DC);
void do_shell_exec(znode *result, znode *cmd CLS_DC);
void zend_do_init_array(znode *result, znode *expr, znode *offset, int is_ref CLS_DC);
void zend_do_add_array_element(znode *result, znode *expr, znode *offset, int is_ref CLS_DC);
void zend_do_add_static_array_element(znode *result, znode *offset, znode *expr);
void zend_do_list_init(CLS_D);
void zend_do_list_end(znode *result, znode *expr CLS_DC);
void zend_do_add_list_element(znode *element CLS_DC);
void zend_do_new_list_begin(CLS_D);
void zend_do_new_list_end(CLS_D);
void do_init_array(znode *result, znode *expr, znode *offset, int is_ref CLS_DC);
void do_add_array_element(znode *result, znode *expr, znode *offset, int is_ref CLS_DC);
void do_add_static_array_element(znode *result, znode *offset, znode *expr);
void do_list_init(CLS_D);
void do_list_end(znode *result, znode *expr CLS_DC);
void do_add_list_element(znode *element CLS_DC);
void do_new_list_begin(CLS_D);
void do_new_list_end(CLS_D);
void zend_do_cast(znode *result, znode *expr, int type CLS_DC);
void zend_do_include_or_eval(int type, znode *result, znode *op1 CLS_DC);
void do_cast(znode *result, znode *expr, int type CLS_DC);
void do_include_or_eval(int type, znode *result, znode *op1 CLS_DC);
void zend_do_unset(znode *variable CLS_DC);
void zend_do_isset_or_isempty(int type, znode *result, znode *variable CLS_DC);
void do_unset(znode *variable CLS_DC);
void do_isset_or_isempty(int type, znode *result, znode *variable CLS_DC);
void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable CLS_DC);
void zend_do_foreach_cont(znode *value, znode *key, znode *as_token CLS_DC);
void zend_do_foreach_end(znode *foreach_token, znode *open_brackets_token CLS_DC);
void do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable CLS_DC);
void do_foreach_cont(znode *value, znode *key, znode *as_token CLS_DC);
void do_foreach_end(znode *foreach_token, znode *open_brackets_token CLS_DC);
void zend_do_declare_begin(CLS_D);
void zend_do_declare_stmt(znode *var, znode *val CLS_DC);
void zend_do_declare_end(CLS_D);
void do_declare_begin(CLS_D);
void do_declare_stmt(znode *var, znode *val CLS_DC);
void do_declare_end(CLS_D);
void zend_do_end_heredoc(CLS_D);
void do_end_heredoc(CLS_D);
void zend_do_exit(znode *result, znode *message CLS_DC);
void do_exit(znode *result, znode *message CLS_DC);
void zend_do_begin_silence(znode *strudel_token CLS_DC);
void zend_do_end_silence(znode *strudel_token CLS_DC);
void do_begin_silence(znode *strudel_token CLS_DC);
void do_end_silence(znode *strudel_token CLS_DC);
void zend_do_begin_qm_op(znode *cond, znode *qm_token CLS_DC);
void zend_do_qm_true(znode *true_value, znode *qm_token, znode *colon_token CLS_DC);
void zend_do_qm_false(znode *result, znode *false_value, znode *qm_token, znode *colon_token CLS_DC);
void do_begin_qm_op(znode *cond, znode *qm_token CLS_DC);
void do_qm_true(znode *true_value, znode *qm_token, znode *colon_token CLS_DC);
void do_qm_false(znode *result, znode *false_value, znode *qm_token, znode *colon_token CLS_DC);
void zend_do_extended_info(CLS_D);
void zend_do_extended_fcall_begin(CLS_D);
void zend_do_extended_fcall_end(CLS_D);
void do_extended_info(CLS_D);
void do_extended_fcall_begin(CLS_D);
void do_extended_fcall_end(CLS_D);
void zend_do_ticks(CLS_D);
void do_ticks(CLS_D);
ZEND_API void function_add_ref(zend_function *function);
#define INITIAL_OP_ARRAY_SIZE 64
/* helper functions in zend_language_scanner.l */
/* helper functions in zend-scanner.l */
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type CLS_DC);
ZEND_API zend_op_array *compile_string(zval *source_string, char *filename CLS_DC);
ZEND_API zend_op_array *compile_filename(int type, zval *filename CLS_DC ELS_DC);
@@ -538,8 +537,6 @@ int zendlex(znode *zendlval CLS_DC);
#define ZEND_TICKS 105
#define ZEND_SEND_VAR_NO_REF 106
/* end of block */
@@ -597,8 +594,6 @@ int zendlex(znode *zendlval CLS_DC);
#define ZEND_MEMBER_FUNC_CALL 1<<0
#define ZEND_CTOR_CALL 1<<1
#define ZEND_ARG_SEND_BY_REF (1<<0)
#define ZEND_ARG_COMPILE_TIME_BOUND (1<<1)
#define AI_USE_PTR(ai) \
if ((ai).ptr_ptr) { \
+21 -55
View File
@@ -1643,68 +1643,40 @@ do_fcall_common:
}
{
zval *valptr;
zval *value;
value = get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
ALLOC_ZVAL(valptr);
*valptr = *value;
if (!EG(free_op1)) {
zval_copy_ctor(valptr);
}
*valptr = Ts[opline->op1.u.var].tmp_var;
INIT_PZVAL(valptr);
zend_ptr_stack_push(&EG(argument_stack), valptr);
}
NEXT_OPCODE();
case ZEND_SEND_VAR_NO_REF:
if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */
if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) {
goto send_by_var;
}
} else if (!ARG_SHOULD_BE_SENT_BY_REF(opline->op2.u.opline_num, fbc, fbc->common.arg_types)) {
goto send_by_var;
case ZEND_SEND_VAR:
if (opline->extended_value==ZEND_DO_FCALL_BY_NAME
&& ARG_SHOULD_BE_SENT_BY_REF(opline->op2.u.opline_num, fbc, fbc->common.arg_types)) {
goto send_by_ref;
}
{
zval *varptr;
varptr = get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) {
varptr->is_ref = 1;
varptr->refcount++;
zend_ptr_stack_push(&EG(argument_stack), varptr);
NEXT_OPCODE();
if (varptr == &EG(uninitialized_zval)) {
ALLOC_ZVAL(varptr);
INIT_ZVAL(*varptr);
varptr->refcount = 0;
} else if (PZVAL_IS_REF(varptr)) {
zval *original_var = varptr;
ALLOC_ZVAL(varptr);
*varptr = *original_var;
varptr->is_ref = 0;
varptr->refcount = 0;
zval_copy_ctor(varptr);
}
zend_error(E_ERROR, "Only variables can be passed by reference");
varptr->refcount++;
zend_ptr_stack_push(&EG(argument_stack), varptr);
FREE_OP(&opline->op1, EG(free_op1)); /* for string offsets */
}
NEXT_OPCODE();
case ZEND_SEND_VAR:
if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME)
&& ARG_SHOULD_BE_SENT_BY_REF(opline->op2.u.opline_num, fbc, fbc->common.arg_types)) {
goto send_by_ref;
}
send_by_var:
{
zval *varptr;
varptr = get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
if (varptr == &EG(uninitialized_zval)) {
ALLOC_ZVAL(varptr);
INIT_ZVAL(*varptr);
varptr->refcount = 0;
} else if (PZVAL_IS_REF(varptr)) {
zval *original_var = varptr;
ALLOC_ZVAL(varptr);
*varptr = *original_var;
varptr->is_ref = 0;
varptr->refcount = 0;
zval_copy_ctor(varptr);
}
varptr->refcount++;
zend_ptr_stack_push(&EG(argument_stack), varptr);
FREE_OP(&opline->op1, EG(free_op1)); /* for string offsets */
}
NEXT_OPCODE();
send_by_ref:
case ZEND_SEND_REF: {
zval **varptr_ptr;
@@ -2298,13 +2270,7 @@ send_by_ref:
NEXT_OPCODE();
case ZEND_EXIT:
if (opline->op1.op_type != IS_UNUSED) {
zval *ptr;
ptr = get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
if (Z_TYPE_P(ptr) == IS_LONG) {
EG(exit_status) = Z_LVAL_P(ptr);
}
zend_print_variable(ptr);
zend_print_variable(get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R));
FREE_OP(&opline->op1, EG(free_op1));
}
zend_bailout();
+30 -33
View File
@@ -23,6 +23,23 @@
ZEND_API zend_llist zend_extensions;
static int last_resource_number;
int zend_load_extensions(char **extension_paths)
{
char **p = extension_paths;
if (!p) {
return SUCCESS;
}
while (*p) {
if (zend_load_extension(*p)==FAILURE) {
return FAILURE;
}
p++;
}
return SUCCESS;
}
int zend_load_extension(char *path)
{
#if ZEND_EXTENSIONS_SUPPORT
@@ -47,19 +64,17 @@ int zend_load_extension(char *path)
return FAILURE;
}
/* allow extension to proclaim compatibility with any Zend version */
if(extension_version_info->zend_extension_api_no != ZEND_EXTENSION_API_NO &&(!new_extension->api_no_check || new_extension->api_no_check(ZEND_EXTENSION_API_NO) != SUCCESS)) {
if (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) {
fprintf(stderr, "%s requires Zend Engine API version %d\n"
if (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) {
fprintf(stderr, "%s requires Zend Engine API version %d\n"
"The installed Zend Engine API version is %d\n\n",
new_extension->name,
extension_version_info->zend_extension_api_no,
ZEND_EXTENSION_API_NO);
DL_UNLOAD(handle);
return FAILURE;
} else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) {
fprintf(stderr, "%s designed to be used with the Zend Engine API %d is outdated\n"
DL_UNLOAD(handle);
return FAILURE;
} else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) {
/* we may be able to allow for downwards compatability in some harmless cases. */
fprintf(stderr, "%s designed to be used with the Zend Engine API %d is outdated\n"
"It requires a more recent version of the Zend Engine\n"
"The installed Zend Engine API version is %d\n"
"Contact %s at %s for a later version of this module.\n\n",
@@ -68,9 +83,8 @@ int zend_load_extension(char *path)
ZEND_EXTENSION_API_NO,
new_extension->author,
new_extension->URL);
DL_UNLOAD(handle);
return FAILURE;
}
DL_UNLOAD(handle);
return FAILURE;
} else if (ZTS_V!=extension_version_info->thread_safe) {
fprintf(stderr, "Cannot load %s - it %s thread safe, whereas Zend %s\n",
new_extension->name,
@@ -124,16 +138,14 @@ static void zend_extension_shutdown(zend_extension *extension)
#endif
}
static int zend_extension_startup(zend_extension *extension)
static void zend_extension_startup(zend_extension *extension)
{
#if ZEND_EXTENSIONS_SUPPORT
if (extension->startup) {
if (extension->startup(extension)!=SUCCESS) {
return 1;
DL_UNLOAD(extension->handle);
}
}
#endif
return 0;
}
@@ -148,7 +160,7 @@ int zend_startup_extensions_mechanism()
int zend_startup_extensions()
{
zend_llist_apply_with_del(&zend_extensions, (int (*)(void *)) zend_extension_startup);
zend_llist_apply(&zend_extensions, (void (*)(void *)) zend_extension_startup);
return SUCCESS;
}
@@ -199,18 +211,3 @@ ZEND_API int zend_get_resource_handle(zend_extension *extension)
return -1;
}
}
ZEND_API zend_extension *zend_get_extension(char *extension_name)
{
zend_llist_element *element;
for (element = zend_extensions.head; element; element = element->next) {
zend_extension *extension = (zend_extension *) element->data;
if (!strcmp(extension->name, extension_name)) {
return extension;
}
}
return NULL;
}
+15 -33
View File
@@ -23,7 +23,7 @@
#include "zend_compile.h"
#define ZEND_EXTENSION_API_NO 20001120
#define ZEND_EXTENSION_API_NO 20001002
typedef struct _zend_extension_version_info {
int zend_extension_api_no;
@@ -35,23 +35,6 @@ typedef struct _zend_extension_version_info {
typedef struct _zend_extension zend_extension;
/* Typedef's for zend_extension function pointers */
typedef int (*startup_func_t)(zend_extension *extension);
typedef void (*shutdown_func_t)(zend_extension *extension);
typedef void (*activate_func_t)();
typedef void (*deactivate_func_t)();
typedef void (*message_handler_func_t)(int message, void *arg);
typedef void (*op_array_handler_func_t)(zend_op_array *op_array);
typedef void (*statement_handler_func_t)(zend_op_array *op_array);
typedef void (*fcall_begin_handler_func_t)(zend_op_array *op_array);
typedef void (*fcall_end_handler_func_t)(zend_op_array *op_array);
typedef void (*op_array_ctor_func_t)(zend_op_array *op_array);
typedef void (*op_array_dtor_func_t)(zend_op_array *op_array);
struct _zend_extension {
char *name;
char *version;
@@ -59,23 +42,23 @@ struct _zend_extension {
char *URL;
char *copyright;
startup_func_t startup;
shutdown_func_t shutdown;
activate_func_t activate;
deactivate_func_t deactivate;
int (*startup)(zend_extension *extension);
void (*shutdown)(zend_extension *extension);
void (*activate)();
void (*deactivate)();
message_handler_func_t message_handler;
void (*message_handler)(int message, void *arg);
op_array_handler_func_t op_array_handler;
void (*op_array_handler)(zend_op_array *op_array);
void (*statement_handler)(zend_op_array *op_array);
void (*fcall_begin_handler)(zend_op_array *op_array);
void (*fcall_end_handler)(zend_op_array *op_array);
statement_handler_func_t statement_handler;
fcall_begin_handler_func_t fcall_begin_handler;
fcall_end_handler_func_t fcall_end_handler;
void (*op_array_ctor)(zend_op_array *op_array);
void (*op_array_dtor)(zend_op_array *op_array);
op_array_ctor_func_t op_array_ctor;
op_array_dtor_func_t op_array_dtor;
int (*api_no_check)(int api_no);
void *reserved1;
void *reserved2;
void *reserved3;
void *reserved4;
@@ -99,18 +82,17 @@ ZEND_API void zend_extension_dispatch_message(int message, void *arg);
ZEND_EXT_API zend_extension_version_info extension_version_info = { ZEND_EXTENSION_API_NO, ZEND_VERSION, ZTS_V, ZEND_DEBUG }
#define STANDARD_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
#define COMPAT_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
ZEND_API extern zend_llist zend_extensions;
void zend_extension_dtor(zend_extension *extension);
ZEND_API int zend_load_extension(char *path);
ZEND_API int zend_load_extensions(char **extension_paths);
ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
void zend_append_version_info(zend_extension *extension);
int zend_startup_extensions_mechanism(void);
int zend_startup_extensions(void);
void zend_shutdown_extensions(void);
ZEND_API zend_extension *zend_get_extension(char *extension_name);
#endif /* ZEND_EXTENSIONS_H */
+1 -1
View File
@@ -74,7 +74,7 @@ typedef struct _zend_fast_cache_list_entry {
{ \
ALS_FETCH(); \
\
((zend_fast_cache_list_entry *) (p))->next = (zend_fast_cache_list_entry *) AG(fast_cache_list_head)[fc_type]; \
((zend_fast_cache_list_entry *) (p))->next = AG(fast_cache_list_head)[fc_type]; \
AG(fast_cache_list_head)[fc_type] = (zend_fast_cache_list_entry *) (p); \
}
+3 -7
View File
@@ -40,7 +40,6 @@
#ifdef __cplusplus
class ZendFlexLexer;
class ZendIniFlexLexer;
#endif
BEGIN_EXTERN_C()
@@ -107,15 +106,13 @@ struct _zend_compiler_globals {
zend_bool unclean_shutdown;
zend_bool ini_parser_unbuffered_errors;
zend_llist open_files;
#if defined(ZTS) && defined(__cplusplus)
#ifdef ZTS
#ifdef __cplusplus
ZendFlexLexer *ZFL;
ZendIniFlexLexer *ini_scanner;
#else
void *ZFL;
void *ini_parser;
#endif
#endif
};
@@ -151,7 +148,6 @@ struct _zend_executor_globals {
int error_reporting;
int orig_error_reporting;
int exit_status;
zend_op_array *active_op_array;
+1 -1
View File
@@ -19,7 +19,7 @@
#include "zend.h"
#include "zend_language_parser.h"
#include "zend-parser.h"
#include "zend_compile.h"
#include "zend_highlight.h"
#include "zend_ptr_stack.h"
+2 -2
View File
@@ -40,8 +40,8 @@ typedef struct _zend_syntax_highlighter_ini {
BEGIN_EXTERN_C()
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name);
int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini);
int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name);
ZEND_API void zend_html_putc(char c);
ZEND_API void zend_html_puts(char *s, uint len);
END_EXTERN_C()
+1 -1
View File
@@ -22,7 +22,7 @@
#include "zend.h"
#include "zend_language_parser.h"
#include "zend-parser.h"
#include "zend_compile.h"
#include "zend_indent.h"
-485
View File
@@ -1,485 +0,0 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 0.92 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.zend.com/license/0_92.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
#include <stdlib.h>
#include "zend.h"
#include "zend_API.h"
#include "zend_ini.h"
#include "zend_alloc.h"
#include "zend_operators.h"
static HashTable known_directives;
/*
* hash_apply functions
*/
static int zend_remove_ini_entries(zend_ini_entry *ini_entry, int *module_number)
{
if (ini_entry->module_number == *module_number) {
return 1;
} else {
return 0;
}
}
static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage)
{
if (ini_entry->modified) {
if (ini_entry->on_modify) {
ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage);
}
efree(ini_entry->value);
ini_entry->value = ini_entry->orig_value;
ini_entry->value_length = ini_entry->orig_value_length;
ini_entry->modified = 0;
ini_entry->orig_value = NULL;
ini_entry->orig_value_length = 0;
}
return 0;
}
/*
* Startup / shutdown
*/
int zend_ini_mstartup()
{
if (zend_hash_init_ex(&known_directives, 100, NULL, NULL, 1, 0)==FAILURE) {
return FAILURE;
}
return SUCCESS;
}
int zend_ini_mshutdown()
{
zend_hash_destroy(&known_directives);
return SUCCESS;
}
int zend_ini_rshutdown()
{
zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) zend_restore_ini_entry_cb, (void *) ZEND_INI_STAGE_DEACTIVATE);
return SUCCESS;
}
static int ini_key_compare(const void *a, const void *b)
{
Bucket *f;
Bucket *s;
f = *((Bucket **) a);
s = *((Bucket **) b);
if (f->nKeyLength==0 && s->nKeyLength==0) { /* both numeric */
return ZEND_NORMALIZE_BOOL(f->nKeyLength - s->nKeyLength);
} else if (f->nKeyLength==0) { /* f is numeric, s is not */
return -1;
} else if (s->nKeyLength==0) { /* s is numeric, f is not */
return 1;
} else { /* both strings */
return zend_binary_strcasecmp(f->arKey, f->nKeyLength, s->arKey, s->nKeyLength);
}
}
void zend_ini_sort_entries(void)
{
zend_hash_sort(&known_directives, qsort, ini_key_compare, 0);
}
/*
* Registration / unregistration
*/
ZEND_API int zend_register_ini_entries(zend_ini_entry *ini_entry, int module_number)
{
zend_ini_entry *p = ini_entry;
zend_ini_entry *hashed_ini_entry;
zval *default_value;
while (p->name) {
p->module_number = module_number;
if (zend_hash_add(&known_directives, p->name, p->name_length, p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry)==FAILURE) {
zend_unregister_ini_entries(module_number);
return FAILURE;
}
if ((default_value=cfg_get_entry(p->name, p->name_length))) {
if (!hashed_ini_entry->on_modify
|| hashed_ini_entry->on_modify(hashed_ini_entry, default_value->value.str.val, default_value->value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP)==SUCCESS) {
hashed_ini_entry->value = default_value->value.str.val;
hashed_ini_entry->value_length = default_value->value.str.len;
}
} else {
if (hashed_ini_entry->on_modify) {
hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP);
}
}
p++;
}
return SUCCESS;
}
ZEND_API void zend_unregister_ini_entries(int module_number)
{
zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) zend_remove_ini_entries, (void *) &module_number);
}
static int zend_ini_refresh_cache(zend_ini_entry *p, int stage)
{
if (p->on_modify) {
p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage);
}
return 0;
}
ZEND_API void zend_ini_refresh_caches(int stage)
{
zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) zend_ini_refresh_cache, (void *)(long) stage);
}
ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage)
{
zend_ini_entry *ini_entry;
char *duplicate;
if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
return FAILURE;
}
if (!(ini_entry->modifyable & modify_type)) {
return FAILURE;
}
duplicate = estrndup(new_value, new_value_length);
if (!ini_entry->on_modify
|| ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage)==SUCCESS) {
if (!ini_entry->modified) {
ini_entry->orig_value = ini_entry->value;
ini_entry->orig_value_length = ini_entry->value_length;
} else { /* we already changed the value, free the changed value */
efree(ini_entry->value);
}
ini_entry->value = duplicate;
ini_entry->value_length = new_value_length;
ini_entry->modified = 1;
} else {
efree(duplicate);
}
return SUCCESS;
}
ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage)
{
zend_ini_entry *ini_entry;
if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
return FAILURE;
}
zend_restore_ini_entry_cb(ini_entry, stage);
return SUCCESS;
}
ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type))
{
zend_ini_entry *ini_entry;
if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
return FAILURE;
}
ini_entry->displayer = displayer;
return SUCCESS;
}
/*
* Data retrieval
*/
ZEND_API long zend_ini_long(char *name, uint name_length, int orig)
{
zend_ini_entry *ini_entry;
if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==SUCCESS) {
if (orig && ini_entry->modified) {
return (ini_entry->orig_value ? strtol(ini_entry->orig_value, NULL, 0) : 0);
} else if (ini_entry->value) {
return strtol(ini_entry->value, NULL, 0);
}
}
return 0;
}
ZEND_API double zend_ini_double(char *name, uint name_length, int orig)
{
zend_ini_entry *ini_entry;
if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==SUCCESS) {
if (orig && ini_entry->modified) {
return (double) (ini_entry->orig_value ? strtod(ini_entry->orig_value, NULL) : 0.0);
} else if (ini_entry->value) {
return (double) strtod(ini_entry->value, NULL);
}
}
return 0.0;
}
ZEND_API char *zend_ini_string(char *name, uint name_length, int orig)
{
zend_ini_entry *ini_entry;
if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==SUCCESS) {
if (orig && ini_entry->modified) {
return ini_entry->orig_value;
} else {
return ini_entry->value;
}
}
return "";
}
zend_ini_entry *get_ini_entry(char *name, uint name_length)
{
zend_ini_entry *ini_entry;
if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==SUCCESS) {
return ini_entry;
} else {
return NULL;
}
}
static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
{
if (ini_entry->displayer) {
ini_entry->displayer(ini_entry, type);
} else {
char *display_string;
uint display_string_length;
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
if (ini_entry->orig_value) {
display_string = ini_entry->orig_value;
display_string_length = ini_entry->orig_value_length;
} else {
display_string = "<i>no value</i>";
display_string_length = sizeof("<i>no value</i>")-1;
}
} else if (ini_entry->value && ini_entry->value[0]) {
display_string = ini_entry->value;
display_string_length = ini_entry->value_length;
} else {
display_string = "<i>no value</i>";
display_string_length = sizeof("<i>no value</i>")-1;
}
ZEND_WRITE(display_string, display_string_length);
}
}
ZEND_INI_DISP(zend_ini_boolean_displayer_cb)
{
int value;
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = (ini_entry->orig_value ? atoi(ini_entry->orig_value) : 0);
} else if (ini_entry->value) {
value = atoi(ini_entry->value);
} else {
value = 0;
}
if (value) {
ZEND_PUTS("On");
} else {
ZEND_PUTS("Off");
}
}
ZEND_INI_DISP(zend_ini_color_displayer_cb)
{
char *value;
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ini_entry->orig_value;
} else if (ini_entry->value) {
value = ini_entry->value;
} else {
value = NULL;
}
if (value) {
zend_printf("<font color=\"%s\">%s</font>", value, value);
} else {
ZEND_PUTS("<i>no value</i>;");
}
}
ZEND_INI_DISP(display_link_numbers)
{
char *value;
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
value = ini_entry->orig_value;
} else if (ini_entry->value) {
value = ini_entry->value;
} else {
value = NULL;
}
if (value) {
if (atoi(value)==-1) {
ZEND_PUTS("Unlimited");
} else {
zend_printf("%s", value);
}
}
}
ZEND_API void zend_ini_apply_with_argument(apply_func_arg_t apply_func, void *arg)
{
zend_hash_apply_with_argument(&known_directives, apply_func, arg);
}
/* Standard message handlers */
ZEND_API ZEND_INI_MH(OnUpdateBool)
{
zend_bool *p;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
char *base;
base = (char *) ts_resource(*((int *) mh_arg2));
#endif
p = (zend_bool *) (base+(size_t) mh_arg1);
*p = (zend_bool) atoi(new_value);
return SUCCESS;
}
ZEND_API ZEND_INI_MH(OnUpdateInt)
{
long *p;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
char *base;
base = (char *) ts_resource(*((int *) mh_arg2));
#endif
p = (long *) (base+(size_t) mh_arg1);
*p = zend_atoi(new_value, new_value_length);
return SUCCESS;
}
ZEND_API ZEND_INI_MH(OnUpdateReal)
{
double *p;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
char *base;
base = (char *) ts_resource(*((int *) mh_arg2));
#endif
p = (double *) (base+(size_t) mh_arg1);
*p = strtod(new_value, NULL);
return SUCCESS;
}
ZEND_API ZEND_INI_MH(OnUpdateString)
{
char **p;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
char *base;
base = (char *) ts_resource(*((int *) mh_arg2));
#endif
p = (char **) (base+(size_t) mh_arg1);
*p = new_value;
return SUCCESS;
}
ZEND_API ZEND_INI_MH(OnUpdateStringUnempty)
{
char **p;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
char *base;
base = (char *) ts_resource(*((int *) mh_arg2));
#endif
if (new_value && !new_value[0]) {
return FAILURE;
}
p = (char **) (base+(size_t) mh_arg1);
*p = new_value;
return SUCCESS;
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
-168
View File
@@ -1,168 +0,0 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 0.92 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.zend.com/license/0_92.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_INI_H
#define ZEND_INI_H
#define ZEND_INI_USER (1<<0)
#define ZEND_INI_PERDIR (1<<1)
#define ZEND_INI_SYSTEM (1<<2)
#define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM)
typedef struct _zend_ini_entry zend_ini_entry;
#define ZEND_INI_MH(name) int name(zend_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage)
#define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type)
struct _zend_ini_entry {
int module_number;
int modifyable;
char *name;
uint name_length;
ZEND_INI_MH((*on_modify));
void *mh_arg1;
void *mh_arg2;
void *mh_arg3;
char *value;
uint value_length;
char *orig_value;
uint orig_value_length;
int modified;
void (*displayer)(zend_ini_entry *ini_entry, int type);
};
int zend_ini_mstartup(void);
int zend_ini_mshutdown(void);
int zend_ini_rshutdown(void);
void zend_ini_sort_entries(void);
ZEND_API int zend_register_ini_entries(zend_ini_entry *ini_entry, int module_number);
ZEND_API void zend_unregister_ini_entries(int module_number);
ZEND_API void zend_ini_refresh_caches(int stage);
ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage);
ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage);
ZEND_API void display_ini_entries(zend_module_entry *module);
ZEND_API long zend_ini_long(char *name, uint name_length, int orig);
ZEND_API double zend_ini_double(char *name, uint name_length, int orig);
ZEND_API char *zend_ini_string(char *name, uint name_length, int orig);
zend_ini_entry *get_ini_entry(char *name, uint name_length);
ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type));
ZEND_API void zend_ini_apply_with_argument(apply_func_arg_t apply_func, void *arg);
ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb);
ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb);
ZEND_API ZEND_INI_DISP(display_link_numbers);
#define ZEND_INI_BEGIN() static zend_ini_entry ini_entries[] = {
#define ZEND_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, NULL } };
#define ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, arg3, displayer) \
{ 0, modifyable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0, displayer },
#define ZEND_INI_ENTRY3(name, default_value, modifyable, on_modify, arg1, arg2, arg3) \
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, arg3, NULL)
#define ZEND_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, arg1, arg2, displayer) \
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, NULL, displayer)
#define ZEND_INI_ENTRY2(name, default_value, modifyable, on_modify, arg1, arg2) \
ZEND_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, arg1, arg2, NULL)
#define ZEND_INI_ENTRY1_EX(name, default_value, modifyable, on_modify, arg1, displayer) \
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, NULL, NULL, displayer)
#define ZEND_INI_ENTRY1(name, default_value, modifyable, on_modify, arg1) \
ZEND_INI_ENTRY1_EX(name, default_value, modifyable, on_modify, arg1, NULL)
#define ZEND_INI_ENTRY_EX(name, default_value, modifyable, on_modify, displayer) \
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, NULL, NULL, NULL, displayer)
#define ZEND_INI_ENTRY(name, default_value, modifyable, on_modify) \
ZEND_INI_ENTRY_EX(name, default_value, modifyable, on_modify, NULL)
#ifdef ZTS
#define STD_ZEND_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
#define STD_ZEND_INI_ENTRY_EX(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr, displayer) \
ZEND_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
#define STD_ZEND_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, NULL, zend_ini_boolean_displayer_cb)
#else
#define STD_ZEND_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
#define STD_ZEND_INI_ENTRY_EX(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr, displayer) \
ZEND_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
#define STD_ZEND_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, zend_ini_boolean_displayer_cb)
#endif
#define INI_INT(name) zend_ini_long((name), sizeof(name), 0)
#define INI_FLT(name) zend_ini_double((name), sizeof(name), 0)
#define INI_STR(name) zend_ini_string((name), sizeof(name), 0)
#define INI_BOOL(name) ((zend_bool) INI_INT(name))
#define INI_ORIG_INT(name) zend_ini_long((name), sizeof(name), 1)
#define INI_ORIG_FLT(name) zend_ini_double((name), sizeof(name), 1)
#define INI_ORIG_STR(name) zend_ini_string((name), sizeof(name), 1)
#define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name))
#define REGISTER_INI_ENTRIES() zend_register_ini_entries(ini_entries, module_number)
#define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries(module_number)
#define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
#define REGISTER_INI_DISPLAYER(name, displayer) zend_ini_register_displayer((name), sizeof(name), displayer)
#define REGISTER_INI_BOOLEAN(name) REGISTER_INI_DISPLAYER(name, zend_ini_boolean_displayer_cb)
zval *cfg_get_entry(char *name, uint name_length);
/* Standard message handlers */
ZEND_API ZEND_INI_MH(OnUpdateBool);
ZEND_API ZEND_INI_MH(OnUpdateInt);
ZEND_API ZEND_INI_MH(OnUpdateReal);
ZEND_API ZEND_INI_MH(OnUpdateString);
ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
#define ZEND_INI_DISPLAY_ORIG 1
#define ZEND_INI_DISPLAY_ACTIVE 2
#define ZEND_INI_STAGE_STARTUP (1<<0)
#define ZEND_INI_STAGE_SHUTDOWN (1<<1)
#define ZEND_INI_STAGE_ACTIVATE (1<<2)
#define ZEND_INI_STAGE_DEACTIVATE (1<<3)
#define ZEND_INI_STAGE_RUNTIME (1<<4)
/* INI parsing engine */
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, int callback_type, void *arg);
int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg);
#define ZEND_INI_PARSER_ENTRY 1
#define ZEND_INI_PARSER_SECTION 2
#endif /* ZEND_INI_H */
-231
View File
@@ -1,231 +0,0 @@
%{
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 0.92 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.zend.com/license/0_92.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#define DEBUG_CFG_PARSER 0
#include "zend.h"
#include "zend_API.h"
#include "zend_ini.h"
#include "zend_constants.h"
#include "zend_ini_scanner.h"
#include "zend_extensions.h"
#if WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winbase.h>
#endif
typedef struct _zend_ini_parser_param {
zend_ini_parser_cb_t ini_parser_cb;
void *arg;
} zend_ini_parser_param;
#define YYSTYPE zval
#define YYPARSE_PARAM ini_parser_param
#define ZEND_INI_PARSER_CB ((zend_ini_parser_param *) ini_parser_param)->ini_parser_cb
#define ZEND_INI_PARSER_ARG ((zend_ini_parser_param *) ini_parser_param)->arg
int ini_lex(zval *ini_lval);
int ini_parse(void *ini_parser_param);
zval yylval;
#ifndef ZTS
extern int ini_lex(zval *ini_lval);
extern FILE *ini_in;
extern int ini_lineno;
extern void init_cfg_scanner(void);
#endif
void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2)
{
int i_result;
int i_op1, i_op2;
char str_result[MAX_LENGTH_OF_LONG];
i_op1 = atoi(op1->value.str.val);
free(op1->value.str.val);
if (op2) {
i_op2 = atoi(op2->value.str.val);
free(op2->value.str.val);
} else {
i_op2 = 0;
}
switch (type) {
case '|':
i_result = i_op1 | i_op2;
break;
case '&':
i_result = i_op1 & i_op2;
break;
case '~':
i_result = ~i_op1;
break;
case '!':
i_result = !i_op1;
break;
default:
i_result = 0;
break;
}
result->value.str.len = zend_sprintf(str_result, "%d", i_result);
result->value.str.val = (char *) malloc(result->value.str.len+1);
memcpy(result->value.str.val, str_result, result->value.str.len);
result->value.str.val[result->value.str.len] = 0;
result->type = IS_STRING;
}
void zend_ini_get_constant(zval *result, zval *name)
{
zval z_constant;
if (zend_get_constant(name->value.str.val, name->value.str.len, &z_constant)) {
/* z_constant is emalloc()'d */
convert_to_string(&z_constant);
result->value.str.val = zend_strndup(z_constant.value.str.val, z_constant.value.str.len);
result->value.str.len = z_constant.value.str.len;
result->type = z_constant.type;
zval_dtor(&z_constant);
free(name->value.str.val);
} else {
*result = *name;
}
}
static void ini_error(char *str)
{
char *error_buf;
int error_buf_len;
char *currently_parsed_filename = zend_ini_scanner_get_filename();
CLS_FETCH();
error_buf_len = 128+strlen(currently_parsed_filename); /* should be more than enough */
error_buf = (char *) emalloc(error_buf_len);
sprintf(error_buf, "Error parsing %s on line %d\n", currently_parsed_filename, zend_ini_scanner_get_lineno());
if (CG(ini_parser_unbuffered_errors)) {
#ifdef PHP_WIN32
MessageBox(NULL, error_buf, "PHP Error", MB_OK|MB_TOPMOST|0x00200000L);
#else
fprintf(stderr, "PHP: %s", error_buf);
#endif
} else {
zend_error(E_CORE_WARNING, error_buf);
}
efree(error_buf);
}
int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg)
{
zend_ini_parser_param ini_parser_param;
int retval;
CLS_FETCH();
ini_parser_param.ini_parser_cb = ini_parser_cb;
ini_parser_param.arg = arg;
if (zend_ini_open_file_for_scanning(fh)==FAILURE) {
return FAILURE;
}
CG(ini_parser_unbuffered_errors) = unbuffered_errors;
retval = ini_parse(&ini_parser_param);
zend_ini_close_file(fh);
if (retval==0) {
return SUCCESS;
} else {
return FAILURE;
}
}
%}
%pure_parser
%token TC_STRING
%token TC_ENCAPSULATED_STRING
%token SECTION
%token CFG_TRUE
%token CFG_FALSE
%left '|' '&'
%right '~' '!'
%%
statement_list:
statement_list statement
| /* empty */
;
statement:
TC_STRING '=' string_or_value {
#if DEBUG_CFG_PARSER
printf("'%s' = '%s'\n", $1.value.str.val, $3.value.str.val);
#endif
ZEND_INI_PARSER_CB(&$1, &$3, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG);
free($1.value.str.val);
free($3.value.str.val);
}
| TC_STRING { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG); free($1.value.str.val); }
| SECTION { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_SECTION, ZEND_INI_PARSER_ARG); free($1.value.str.val); }
| '\n'
;
string_or_value:
expr { $$ = $1; }
| TC_ENCAPSULATED_STRING { $$ = $1; }
| CFG_TRUE { $$ = $1; }
| CFG_FALSE { $$ = $1; }
| '\n' { $$.value.str.val = strdup(""); $$.value.str.len=0; $$.type = IS_STRING; }
| '\0' { $$.value.str.val = strdup(""); $$.value.str.len=0; $$.type = IS_STRING; }
;
expr:
constant_string { $$ = $1; }
| expr '|' expr { zend_ini_do_op('|', &$$, &$1, &$3); }
| expr '&' expr { zend_ini_do_op('&', &$$, &$1, &$3); }
| '~' expr { zend_ini_do_op('~', &$$, &$2, NULL); }
| '!' expr { zend_ini_do_op('!', &$$, &$2, NULL); }
| '(' expr ')' { $$ = $2; }
;
constant_string:
TC_STRING { zend_ini_get_constant(&$$, &$1); }
;
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
-24
View File
@@ -1,24 +0,0 @@
#ifndef _ZEND_INI_SCANNER_H
#define _ZEND_INI_SCANNER_H
#if defined(ZTS) && defined(__cplusplus)
class ZendIniFlexLexer : public yyFlexLexer
{
public:
virtual ~ZendIniFlexLexer();
int lex_scan(zval *zendlval);
void BeginState(int state);
char *filename;
};
#endif /* ZTS && __cplusplus */
BEGIN_EXTERN_C()
int zend_ini_scanner_get_lineno();
char *zend_ini_scanner_get_filename();
int zend_ini_open_file_for_scanning(zend_file_handle *fh);
void zend_ini_close_file(zend_file_handle *fh);
int ini_lex(zval *ini_lval);
END_EXTERN_C()
#endif /* _ZEND_INI_SCANNER_H */
-283
View File
@@ -1,283 +0,0 @@
%{
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 0.92 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.zend.com/license/0_92.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
#include "zend.h"
#include "zend_globals.h"
#include "zend_ini_parser.h"
#include "zend_ini_scanner.h"
#ifdef ZTS
# ifdef HAVE_STDIOSTR_H
# include <stdiostr.h>
# endif
# ifdef HAVE_STDIOSTREAM_H
# include <stdiostream.h>
# endif
# ifdef ZEND_WIN32
# include <strstrea.h>
# else
# include <strstream.h>
# endif
#endif
#undef YYSTYPE
#define YYSTYPE zval
#ifdef ZTS
#define YY_DECL int ZendIniFlexLexer::lex_scan(zval *ini_lval)
#else
#define YY_DECL int ini_lex(zval *ini_lval)
#endif
#ifndef ZTS
static char *ini_filename;
void init_ini_scanner()
{
ini_lineno=1;
}
int zend_ini_scanner_get_lineno()
{
return ini_lineno;
}
char *zend_ini_scanner_get_filename()
{
return ini_filename;
}
#else /* ZTS */
int zend_ini_scanner_get_lineno()
{
CLS_FETCH();
return CG(ini_scanner)->lineno();
}
char *zend_ini_scanner_get_filename()
{
CLS_FETCH();
return CG(ini_scanner)->filename;
}
int ini_lex(zval *ini_lval)
{
CLS_FETCH();
return CG(ini_scanner)->lex_scan(ini_lval);
}
ZendIniFlexLexer::~ZendIniFlexLexer()
{
if (yy_start_stack) {
yy_flex_free(yy_start_stack);
}
}
int yyFlexLexer::yylex()
{
fprintf(stderr, "Error: yyFlexLexer::yylex() called\n");
return -1;
}
#endif
int zend_ini_open_file_for_scanning(zend_file_handle *fh)
{
FILE *fp;
CLS_FETCH();
switch (fh->type) {
case ZEND_HANDLE_FP:
fp = fh->handle.fp;
break;
case ZEND_HANDLE_FILENAME:
fp = zend_fopen(fh->filename, NULL);
fh->type = ZEND_HANDLE_FP;
break;
default:
return FAILURE;
}
#ifdef ZTS
if (!fp) {
return FAILURE;
}
fh->handle.is = new istdiostream(fp);
fh->type = ZEND_HANDLE_STDIOSTREAM;
CG(ini_scanner) = new ZendIniFlexLexer;
CG(ini_scanner)->switch_streams(fh->handle.is, &cout);
CG(ini_scanner)->filename = fh->filename;
#else
init_ini_scanner();
yyin = fp;
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
ini_filename = fh->filename;
#endif
return SUCCESS;
}
void zend_ini_close_file(zend_file_handle *fh)
{
switch (fh->type) {
case ZEND_HANDLE_FP:
fclose(fh->handle.fp);
break;
#ifdef ZTS
case ZEND_HANDLE_STDIOSTREAM: {
CLS_FETCH();
delete CG(ini_scanner);
}
break;
#endif
}
}
%}
%option noyywrap
%option yylineno
%%
<INITIAL>[ ]*("true"|"on"|"yes")[ ]* {
ini_lval->value.str.val = zend_strndup("1",1);
ini_lval->value.str.len = 1;
ini_lval->type = IS_STRING;
return CFG_TRUE;
}
<INITIAL>[ ]*("false"|"off"|"no"|"none")[ ]* {
ini_lval->value.str.val = zend_strndup("",0);
ini_lval->value.str.len = 0;
ini_lval->type = IS_STRING;
return CFG_FALSE;
}
<INITIAL>[[][^[]+[\]]([\n]?|"\r\n"?) {
/* SECTION */
/* eat trailng ] */
while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']')) {
yyleng--;
yytext[yyleng]=0;
}
/* eat leading [ */
yytext++;
yyleng--;
ini_lval->value.str.val = zend_strndup(yytext,yyleng);
ini_lval->value.str.len = yyleng;
ini_lval->type = IS_STRING;
return SECTION;
}
<INITIAL>["][^\n\r"]*["] {
/* ENCAPSULATED TC_STRING */
/* eat trailing " */
yytext[yyleng-1]=0;
/* eat leading " */
yytext++;
ini_lval->value.str.val = zend_strndup(yytext, yyleng - 2);
ini_lval->value.str.len = yyleng - 2;
ini_lval->type = IS_STRING;
return TC_ENCAPSULATED_STRING;
}
<INITIAL>[&|~()!] {
return yytext[0];
}
<INITIAL>[^=\n\r\t;|&~()!"]+ {
/* STRING */
register int i;
/* eat trailing whitespace */
for (i=yyleng-1; i>=0; i--) {
if (yytext[i]==' ' || yytext[i]=='\t') {
yytext[i]=0;
yyleng--;
} else {
break;
}
}
/* eat leading whitespace */
while (yytext[0]) {
if (yytext[0]==' ' || yytext[0]=='\t') {
yytext++;
yyleng--;
} else {
break;
}
}
if (yyleng!=0) {
ini_lval->value.str.val = zend_strndup(yytext,yyleng);
ini_lval->value.str.len = yyleng;
ini_lval->type = IS_STRING;
return TC_STRING;
} else {
/* whitespace */
}
}
<INITIAL>[=\n] {
return yytext[0];
}
<INITIAL>"\r\n" {
return '\n';
}
<INITIAL>[;][^\r\n]*[\r\n]? {
/* comment */
return '\n';
}
<INITIAL>[ \t] {
/* eat whitespace */
}
<INITIAL>. {
#if DEBUG
php_error(E_NOTICE,"Unexpected character on line %d: '%s' (ASCII %d)\n",yylineno,yytext,yytext[0]);
#endif
}
<<EOF>> {
yy_delete_buffer(YY_CURRENT_BUFFER);
yyterminate();
}
-725
View File
@@ -1,725 +0,0 @@
%{
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 0.92 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.zend.com/license/0_92.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/*
* LALR shift/reduce conflicts and how they are resolved:
*
* - 2 shift/reduce conflicts due to the dangeling elseif/else ambiguity. Solved by shift.
* - 1 shift/reduce conflict due to arrays within encapsulated strings. Solved by shift.
* - 1 shift/reduce conflict due to objects within encapsulated strings. Solved by shift.
*
*/
#include "zend_compile.h"
#include "zend.h"
#include "zend_list.h"
#include "zend_globals.h"
#include "zend_API.h"
#define YYERROR_VERBOSE
#define YYSTYPE znode
#ifdef ZTS
# define YYPARSE_PARAM compiler_globals
# define YYLEX_PARAM compiler_globals
#endif
%}
%pure_parser
%expect 4
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
%left ','
%left T_LOGICAL_OR
%left T_LOGICAL_XOR
%left T_LOGICAL_AND
%right T_PRINT
%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL
%left '?' ':'
%left T_BOOLEAN_OR
%left T_BOOLEAN_AND
%left '|'
%left '^'
%left '&'
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
%left T_SL T_SR
%left '+' '-' '.'
%left '*' '/' '%'
%right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@'
%right '['
%nonassoc T_NEW
%token T_EXIT
%token T_IF
%left T_ELSEIF
%left T_ELSE
%left T_ENDIF
%token T_LNUMBER
%token T_DNUMBER
%token T_STRING
%token T_STRING_VARNAME
%token T_VARIABLE
%token T_NUM_STRING
%token T_INLINE_HTML
%token T_CHARACTER
%token T_BAD_CHARACTER
%token T_ENCAPSED_AND_WHITESPACE
%token T_CONSTANT_ENCAPSED_STRING
%token T_ECHO
%token T_DO
%token T_WHILE
%token T_ENDWHILE
%token T_FOR
%token T_ENDFOR
%token T_FOREACH
%token T_ENDFOREACH
%token T_DECLARE
%token T_ENDDECLARE
%token T_AS
%token T_SWITCH
%token T_ENDSWITCH
%token T_CASE
%token T_DEFAULT
%token T_BREAK
%token T_CONTINUE
%token T_OLD_FUNCTION
%token T_FUNCTION
%token T_CONST
%token T_RETURN
%token T_USE
%token T_GLOBAL
%token T_STATIC
%token T_VAR
%token T_UNSET
%token T_ISSET
%token T_EMPTY
%token T_CLASS
%token T_EXTENDS
%token T_OBJECT_OPERATOR
%token T_DOUBLE_ARROW
%token T_LIST
%token T_ARRAY
%token T_LINE
%token T_FILE
%token T_COMMENT
%token T_ML_COMMENT
%token T_OPEN_TAG
%token T_OPEN_TAG_WITH_ECHO
%token T_CLOSE_TAG
%token T_WHITESPACE
%token T_START_HEREDOC
%token T_END_HEREDOC
%token T_DOLLAR_OPEN_CURLY_BRACES
%token T_CURLY_OPEN
%token T_PAAMAYIM_NEKUDOTAYIM
%% /* Rules */
start:
top_statement_list
;
top_statement_list:
top_statement_list { zend_do_extended_info(CLS_C); } top_statement { HANDLE_INTERACTIVE(); }
| /* empty */
;
top_statement:
statement
| declaration_statement { zend_do_early_binding(CLS_C); }
;
inner_statement_list:
inner_statement_list { zend_do_extended_info(CLS_C); } inner_statement { HANDLE_INTERACTIVE(); }
| /* empty */
;
inner_statement:
statement
| declaration_statement
;
statement:
unticked_statement { zend_do_ticks(CLS_C); }
;
unticked_statement:
'{' inner_statement_list '}'
| T_IF '(' expr ')' { zend_do_if_cond(&$3, &$4 CLS_CC); } statement { zend_do_if_after_statement(&$4, 1 CLS_CC); } elseif_list else_single { zend_do_if_end(CLS_C); }
| T_IF '(' expr ')' ':' { zend_do_if_cond(&$3, &$4 CLS_CC); } inner_statement_list { zend_do_if_after_statement(&$4, 1 CLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { zend_do_if_end(CLS_C); }
| T_WHILE '(' { $1.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' { zend_do_while_cond(&$4, &$5 CLS_CC); } while_statement { zend_do_while_end(&$1, &$5 CLS_CC); }
| T_DO { $1.u.opline_num = get_next_op_number(CG(active_op_array)); zend_do_do_while_begin(CLS_C); } statement T_WHILE '(' { $5.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' ';' { zend_do_do_while_end(&$1, &$5, &$7 CLS_CC); }
| T_FOR
'('
for_expr
';' { zend_do_free(&$3 CLS_CC); $4.u.opline_num = get_next_op_number(CG(active_op_array)); }
for_expr
';' { zend_do_extended_info(CLS_C); zend_do_for_cond(&$6, &$7 CLS_CC); }
for_expr
')' { zend_do_free(&$9 CLS_CC); zend_do_for_before_statement(&$4, &$7 CLS_CC); }
for_statement { zend_do_for_end(&$7 CLS_CC); }
| T_SWITCH '(' expr ')' { zend_do_switch_cond(&$3 CLS_CC); } switch_case_list { zend_do_switch_end(&$6 CLS_CC); }
| T_BREAK ';' { zend_do_brk_cont(ZEND_BRK, NULL CLS_CC); }
| T_BREAK expr ';' { zend_do_brk_cont(ZEND_BRK, &$2 CLS_CC); }
| T_CONTINUE ';' { zend_do_brk_cont(ZEND_CONT, NULL CLS_CC); }
| T_CONTINUE expr ';' { zend_do_brk_cont(ZEND_CONT, &$2 CLS_CC); }
| T_RETURN ';' { zend_do_return(NULL, 0 CLS_CC); }
| T_RETURN expr_without_variable ';' { zend_do_return(&$2, 0 CLS_CC); }
| T_RETURN cvar ';' { zend_do_return(&$2, 1 CLS_CC); }
| T_GLOBAL global_var_list ';'
| T_STATIC static_var_list ';'
| T_ECHO echo_expr_list ';'
| T_INLINE_HTML { zend_do_echo(&$1 CLS_CC); }
| expr ';' { zend_do_free(&$1 CLS_CC); }
| T_USE use_filename ';' { zend_error(E_COMPILE_ERROR,"use: Not yet supported. Please use include_once() or require_once()"); zval_dtor(&$2.u.constant); }
| T_UNSET '(' unset_variables ')' ';'
| T_FOREACH '(' w_cvar T_AS { zend_do_foreach_begin(&$1, &$3, &$2, &$4, 1 CLS_CC); } w_cvar foreach_optional_arg ')' { zend_do_foreach_cont(&$6, &$7, &$4 CLS_CC); } foreach_statement { zend_do_foreach_end(&$1, &$2 CLS_CC); }
| T_FOREACH '(' expr_without_variable T_AS { zend_do_foreach_begin(&$1, &$3, &$2, &$4, 0 CLS_CC); } w_cvar foreach_optional_arg ')' { zend_do_foreach_cont(&$6, &$7, &$4 CLS_CC); } foreach_statement { zend_do_foreach_end(&$1, &$2 CLS_CC); }
| T_DECLARE { zend_do_declare_begin(CLS_C); } '(' declare_list ')' declare_statement { zend_do_declare_end(CLS_C); }
| ';' /* empty statement */
;
unset_variables:
unset_variable
| unset_variables ',' unset_variable
;
unset_variable:
cvar { zend_do_end_variable_parse(BP_VAR_UNSET, 0 CLS_CC); zend_do_unset(&$1 CLS_CC); }
;
use_filename:
T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
| '(' T_CONSTANT_ENCAPSED_STRING ')' { $$ = $2; }
;
declaration_statement:
unticked_declaration_statement { zend_do_ticks(CLS_C); }
;
unticked_declaration_statement:
T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 0, $3.op_type CLS_CC); }
'(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 CLS_CC); }
| T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 0, $3.op_type CLS_CC); }
parameter_list '(' inner_statement_list ')' ';' { zend_do_end_function_declaration(&$1 CLS_CC); }
| T_CLASS T_STRING { zend_do_begin_class_declaration(&$2, NULL CLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(CLS_C); }
| T_CLASS T_STRING T_EXTENDS T_STRING { zend_do_begin_class_declaration(&$2, &$4 CLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(CLS_C); }
;
foreach_optional_arg:
/* empty */ { $$.op_type = IS_UNUSED; }
| T_DOUBLE_ARROW w_cvar { $$ = $2; }
;
for_statement:
statement
| ':' inner_statement_list T_ENDFOR ';'
;
foreach_statement:
statement
| ':' inner_statement_list T_ENDFOREACH ';'
;
declare_statement:
statement
| ':' inner_statement_list T_ENDDECLARE ';'
;
declare_list:
T_STRING '=' static_scalar { zend_do_declare_stmt(&$1, &$3 CLS_CC); }
| declare_list ',' T_STRING '=' static_scalar { zend_do_declare_stmt(&$3, &$5 CLS_CC); }
;
switch_case_list:
'{' case_list '}' { $$ = $2; }
| '{' ';' case_list '}' { $$ = $3; }
| ':' case_list T_ENDSWITCH ';' { $$ = $2; }
| ':' ';' case_list T_ENDSWITCH ';' { $$ = $3; }
;
case_list:
/* empty */ { $$.op_type = IS_UNUSED; }
| case_list T_CASE expr case_separator { zend_do_extended_info(CLS_C); zend_do_case_before_statement(&$1, &$2, &$3 CLS_CC); } inner_statement_list { zend_do_case_after_statement(&$$, &$2 CLS_CC); $$.op_type = IS_CONST }
| case_list T_DEFAULT case_separator { zend_do_extended_info(CLS_C); zend_do_default_before_statement(&$1, &$2 CLS_CC); } inner_statement_list { zend_do_case_after_statement(&$$, &$2 CLS_CC); $$.op_type = IS_CONST; }
;
case_separator:
':'
| ';'
;
while_statement:
statement
| ':' inner_statement_list T_ENDWHILE ';'
;
elseif_list:
/* empty */
| elseif_list T_ELSEIF '(' expr ')' { zend_do_if_cond(&$4, &$5 CLS_CC); } statement { zend_do_if_after_statement(&$5, 0 CLS_CC); }
;
new_elseif_list:
/* empty */
| new_elseif_list T_ELSEIF '(' expr ')' ':' { zend_do_if_cond(&$4, &$5 CLS_CC); } inner_statement_list { zend_do_if_after_statement(&$5, 0 CLS_CC); }
;
else_single:
/* empty */
| T_ELSE statement
;
new_else_single:
/* empty */
| T_ELSE ':' inner_statement_list
;
parameter_list:
non_empty_parameter_list
| /* empty */
;
non_empty_parameter_list:
T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$1, 0 CLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE CLS_CC); }
| '&' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$2, 0 CLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_FORCE CLS_CC); }
| T_CONST T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$2, 0 CLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE CLS_CC); }
| T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$1, 0 CLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$3, BYREF_NONE CLS_CC); }
| non_empty_parameter_list ',' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$3, 0 CLS_CC); $$=$1; $$.u.constant.value.lval++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE CLS_CC); }
| non_empty_parameter_list ',' '&' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$4, 0 CLS_CC); $$=$1; $$.u.constant.value.lval++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_FORCE CLS_CC); }
| non_empty_parameter_list ',' T_CONST T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$4, 0 CLS_CC); $$=$1; $$.u.constant.value.lval++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE CLS_CC); }
| non_empty_parameter_list ',' T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$3, 0 CLS_CC); $$=$1; $$.u.constant.value.lval++; zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$5, BYREF_NONE CLS_CC); }
;
function_call_parameter_list:
non_empty_function_call_parameter_list { $$ = $1; }
| /* empty */ { $$.u.constant.value.lval = 0; }
;
non_empty_function_call_parameter_list:
expr_without_variable { $$.u.constant.value.lval = 1; zend_do_pass_param(&$1, ZEND_SEND_VAL, $$.u.constant.value.lval CLS_CC); }
| cvar { $$.u.constant.value.lval = 1; zend_do_pass_param(&$1, ZEND_SEND_VAR, $$.u.constant.value.lval CLS_CC); }
| '&' w_cvar { $$.u.constant.value.lval = 1; zend_do_pass_param(&$2, ZEND_SEND_REF, $$.u.constant.value.lval CLS_CC); }
| non_empty_function_call_parameter_list ',' expr_without_variable { $$.u.constant.value.lval=$1.u.constant.value.lval+1; zend_do_pass_param(&$3, ZEND_SEND_VAL, $$.u.constant.value.lval CLS_CC); }
| non_empty_function_call_parameter_list ',' cvar { $$.u.constant.value.lval=$1.u.constant.value.lval+1; zend_do_pass_param(&$3, ZEND_SEND_VAR, $$.u.constant.value.lval CLS_CC); }
| non_empty_function_call_parameter_list ',' '&' w_cvar { $$.u.constant.value.lval=$1.u.constant.value.lval+1; zend_do_pass_param(&$4, ZEND_SEND_REF, $$.u.constant.value.lval CLS_CC); }
;
global_var_list:
global_var_list ',' global_var { zend_do_fetch_global_or_static_variable(&$3, NULL, ZEND_FETCH_GLOBAL CLS_CC); }
| global_var { zend_do_fetch_global_or_static_variable(&$1, NULL, ZEND_FETCH_GLOBAL CLS_CC); }
;
global_var:
T_VARIABLE { $$ = $1; }
| '$' r_cvar { $$ = $2; }
| '$' '{' expr '}' { $$ = $3; }
;
static_var_list:
static_var_list ',' T_VARIABLE { zend_do_fetch_global_or_static_variable(&$3, NULL, ZEND_FETCH_STATIC CLS_CC); }
| static_var_list ',' T_VARIABLE '=' static_scalar { zend_do_fetch_global_or_static_variable(&$3, &$5, ZEND_FETCH_STATIC CLS_CC); }
| T_VARIABLE { zend_do_fetch_global_or_static_variable(&$1, NULL, ZEND_FETCH_STATIC CLS_CC); }
| T_VARIABLE '=' static_scalar { zend_do_fetch_global_or_static_variable(&$1, &$3, ZEND_FETCH_STATIC CLS_CC); }
;
class_statement_list:
class_statement_list class_statement
| /* empty */
;
class_statement:
T_VAR class_variable_decleration ';'
| T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type CLS_CC); } '('
parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 CLS_CC); }
| T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type CLS_CC); }
parameter_list '(' inner_statement_list ')' ';' { zend_do_end_function_declaration(&$1 CLS_CC); }
;
is_reference:
/* empty */ { $$.op_type = ZEND_RETURN_VAL; }
| '&' { $$.op_type = ZEND_RETURN_REF; }
class_variable_decleration:
class_variable_decleration ',' T_VARIABLE { zend_do_declare_property(&$3, NULL CLS_CC); }
| class_variable_decleration ',' T_VARIABLE '=' static_scalar { zend_do_declare_property(&$3, &$5 CLS_CC); }
| T_VARIABLE { zend_do_declare_property(&$1, NULL CLS_CC); }
| T_VARIABLE '=' static_scalar { zend_do_declare_property(&$1, &$3 CLS_CC); }
;
echo_expr_list:
| echo_expr_list ',' expr { zend_do_echo(&$3 CLS_CC); }
| expr { zend_do_echo(&$1 CLS_CC); }
;
for_expr:
/* empty */ { $$.op_type = IS_CONST; $$.u.constant.type = IS_BOOL; $$.u.constant.value.lval = 1; }
| non_empty_for_expr { $$ = $1; }
;
non_empty_for_expr:
non_empty_for_expr ',' { zend_do_free(&$1 CLS_CC); } expr { $$ = $4; }
| expr { $$ = $1; }
;
expr_without_variable:
T_LIST '(' { zend_do_list_init(CLS_C); } assignment_list ')' '=' expr { zend_do_list_end(&$$, &$7 CLS_CC); }
| cvar '=' expr { zend_do_end_variable_parse(BP_VAR_W, 0 CLS_CC); zend_do_assign(&$$, &$1, &$3 CLS_CC); }
| cvar '=' '&' w_cvar { zend_do_end_variable_parse(BP_VAR_W, 0 CLS_CC); zend_do_assign_ref(&$$, &$1, &$4 CLS_CC); }
| cvar '=' '&' function_call { zend_do_end_variable_parse(BP_VAR_W, 0 CLS_CC); zend_do_assign_ref(&$$, &$1, &$4 CLS_CC); }
| T_NEW class_name { zend_do_extended_fcall_begin(CLS_C); zend_do_begin_new_object(&$1, &$2 CLS_CC); } ctor_arguments { zend_do_end_new_object(&$$, &$2, &$1, &$4 CLS_CC); zend_do_extended_fcall_end(CLS_C);}
| cvar T_PLUS_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_ADD, &$$, &$1, &$3 CLS_CC); }
| cvar T_MINUS_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SUB, &$$, &$1, &$3 CLS_CC); }
| cvar T_MUL_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_MUL, &$$, &$1, &$3 CLS_CC); }
| cvar T_DIV_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_DIV, &$$, &$1, &$3 CLS_CC); }
| cvar T_CONCAT_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_CONCAT, &$$, &$1, &$3 CLS_CC); }
| cvar T_MOD_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_MOD, &$$, &$1, &$3 CLS_CC); }
| cvar T_AND_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_AND, &$$, &$1, &$3 CLS_CC); }
| cvar T_OR_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_OR, &$$, &$1, &$3 CLS_CC); }
| cvar T_XOR_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_XOR, &$$, &$1, &$3 CLS_CC); }
| cvar T_SL_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SL, &$$, &$1, &$3 CLS_CC); }
| cvar T_SR_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SR, &$$, &$1, &$3 CLS_CC); }
| rw_cvar T_INC { zend_do_post_incdec(&$$, &$1, ZEND_POST_INC CLS_CC); }
| T_INC rw_cvar { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_INC CLS_CC); }
| rw_cvar T_DEC { zend_do_post_incdec(&$$, &$1, ZEND_POST_DEC CLS_CC); }
| T_DEC rw_cvar { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_DEC CLS_CC); }
| expr T_BOOLEAN_OR { zend_do_boolean_or_begin(&$1, &$2 CLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 CLS_CC); }
| expr T_BOOLEAN_AND { zend_do_boolean_and_begin(&$1, &$2 CLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 CLS_CC); }
| expr T_LOGICAL_OR { zend_do_boolean_or_begin(&$1, &$2 CLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 CLS_CC); }
| expr T_LOGICAL_AND { zend_do_boolean_and_begin(&$1, &$2 CLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 CLS_CC); }
| expr T_LOGICAL_XOR expr { zend_do_binary_op(ZEND_BOOL_XOR, &$$, &$1, &$3 CLS_CC); }
| expr '|' expr { zend_do_binary_op(ZEND_BW_OR, &$$, &$1, &$3 CLS_CC); }
| expr '&' expr { zend_do_binary_op(ZEND_BW_AND, &$$, &$1, &$3 CLS_CC); }
| expr '^' expr { zend_do_binary_op(ZEND_BW_XOR, &$$, &$1, &$3 CLS_CC); }
| expr '.' expr { zend_do_binary_op(ZEND_CONCAT,&$$,&$1,&$3 CLS_CC); }
| expr '+' expr { zend_do_binary_op(ZEND_ADD,&$$,&$1,&$3 CLS_CC); }
| expr '-' expr { zend_do_binary_op(ZEND_SUB,&$$,&$1,&$3 CLS_CC); }
| expr '*' expr { zend_do_binary_op(ZEND_MUL,&$$,&$1,&$3 CLS_CC); }
| expr '/' expr { zend_do_binary_op(ZEND_DIV,&$$,&$1,&$3 CLS_CC); }
| expr '%' expr { zend_do_binary_op(ZEND_MOD,&$$,&$1,&$3 CLS_CC); }
| expr T_SL expr { zend_do_binary_op(ZEND_SL, &$$, &$1, &$3 CLS_CC); }
| expr T_SR expr { zend_do_binary_op(ZEND_SR, &$$, &$1, &$3 CLS_CC); }
| '+' expr { $1.u.constant.value.lval=0; $1.u.constant.type=IS_LONG; $1.op_type = IS_CONST; INIT_PZVAL(&$1.u.constant); zend_do_binary_op(ZEND_ADD, &$$, &$1, &$2 CLS_CC); }
| '-' expr { $1.u.constant.value.lval=0; $1.u.constant.type=IS_LONG; $1.op_type = IS_CONST; INIT_PZVAL(&$1.u.constant); zend_do_binary_op(ZEND_SUB, &$$, &$1, &$2 CLS_CC); }
| '!' expr { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$2 CLS_CC); }
| '~' expr { zend_do_unary_op(ZEND_BW_NOT, &$$, &$2 CLS_CC); }
| expr T_IS_IDENTICAL expr { zend_do_binary_op(ZEND_IS_IDENTICAL, &$$, &$1, &$3 CLS_CC); }
| expr T_IS_NOT_IDENTICAL expr { zend_do_binary_op(ZEND_IS_NOT_IDENTICAL, &$$, &$1, &$3 CLS_CC); }
| expr T_IS_EQUAL expr { zend_do_binary_op(ZEND_IS_EQUAL, &$$, &$1, &$3 CLS_CC); }
| expr T_IS_NOT_EQUAL expr { zend_do_binary_op(ZEND_IS_NOT_EQUAL, &$$, &$1, &$3 CLS_CC); }
| expr '<' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$1, &$3 CLS_CC); }
| expr T_IS_SMALLER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$1, &$3 CLS_CC); }
| expr '>' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 CLS_CC); }
| expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 CLS_CC); }
| '(' expr ')' { $$ = $2; }
| expr '?' { zend_do_begin_qm_op(&$1, &$2 CLS_CC); }
expr ':' { zend_do_qm_true(&$4, &$2, &$5 CLS_CC); }
expr { zend_do_qm_false(&$$, &$7, &$2, &$5 CLS_CC); }
| function_call { $$ = $1; }
| internal_functions_in_yacc { $$ = $1; }
| T_INT_CAST expr { zend_do_cast(&$$, &$2, IS_LONG CLS_CC); }
| T_DOUBLE_CAST expr { zend_do_cast(&$$, &$2, IS_DOUBLE CLS_CC); }
| T_STRING_CAST expr { zend_do_cast(&$$, &$2, IS_STRING CLS_CC); }
| T_ARRAY_CAST expr { zend_do_cast(&$$, &$2, IS_ARRAY CLS_CC); }
| T_OBJECT_CAST expr { zend_do_cast(&$$, &$2, IS_OBJECT CLS_CC); }
| T_BOOL_CAST expr { zend_do_cast(&$$, &$2, IS_BOOL CLS_CC); }
| T_UNSET_CAST expr { zend_do_cast(&$$, &$2, IS_NULL CLS_CC); }
| T_EXIT exit_expr { zend_do_exit(&$$, &$2 CLS_CC); }
| '@' { zend_do_begin_silence(&$1 CLS_CC); } expr { zend_do_end_silence(&$1 CLS_CC); $$ = $3; }
| scalar { $$ = $1; }
| T_ARRAY '(' array_pair_list ')' { $$ = $3; }
| '`' encaps_list '`' { zend_do_shell_exec(&$$, &$2 CLS_CC); }
| T_PRINT expr { zend_do_print(&$$, &$2 CLS_CC); }
;
function_call:
T_STRING '(' { $2.u.opline_num = zend_do_begin_function_call(&$1 CLS_CC); }
function_call_parameter_list
')' { zend_do_end_function_call(&$1, &$$, &$4, 0, $2.u.opline_num CLS_CC); zend_do_extended_fcall_end(CLS_C); }
| cvar '(' { zend_do_begin_dynamic_function_call(&$1 CLS_CC); }
function_call_parameter_list
')' { zend_do_end_function_call(&$1, &$$, &$4, 0, 1 CLS_CC); zend_do_extended_fcall_end(CLS_C);}
| T_STRING T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { zend_do_extended_fcall_begin(CLS_C); zend_do_begin_class_member_function_call(&$1, &$3 CLS_CC); }
function_call_parameter_list
')' { zend_do_end_function_call(&$3, &$$, &$6, 1, 1 CLS_CC); zend_do_extended_fcall_end(CLS_C);}
;
exit_expr:
/* empty */ { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
| '(' ')' { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
| '(' expr ')' { $$ = $2; }
;
ctor_arguments:
/* empty */ { $$.u.constant.value.lval=0; }
| '(' function_call_parameter_list ')' { $$ = $2; }
;
class_name:
T_STRING { $$ = $1; }
| r_cvar { $$ = $1; }
;
common_scalar:
T_LNUMBER { $$ = $1; }
| T_DNUMBER { $$ = $1; }
| T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
| T_LINE { $$ = $1; }
| T_FILE { $$ = $1; }
;
static_scalar: /* compile-time evaluated scalars */
common_scalar { $$ = $1; }
| T_STRING { zend_do_fetch_constant(&$$, &$1, ZEND_CT CLS_CC); }
| '+' static_scalar { $$ = $1; }
| '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval = -1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one); $$ = $2; }
| T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = IS_CONSTANT_ARRAY; }
;
scalar:
T_STRING { zend_do_fetch_constant(&$$, &$1, ZEND_RT CLS_CC); }
| T_STRING_VARNAME { $$ = $1; }
| common_scalar { $$ = $1; }
| '"' encaps_list '"' { $$ = $2; }
| '\'' encaps_list '\'' { $$ = $2; }
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; zend_do_end_heredoc(CLS_C); }
;
static_array_pair_list:
/* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); }
| non_empty_static_array_pair_list possible_comma { $$ = $1; }
;
possible_comma:
/* empty */
| ','
;
non_empty_static_array_pair_list:
non_empty_static_array_pair_list ',' static_scalar T_DOUBLE_ARROW static_scalar { zend_do_add_static_array_element(&$$, &$3, &$5); }
| non_empty_static_array_pair_list ',' static_scalar { zend_do_add_static_array_element(&$$, NULL, &$3); }
| static_scalar T_DOUBLE_ARROW static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, &$1, &$3); }
| static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, NULL, &$1); }
;
expr:
r_cvar { $$ = $1; }
| expr_without_variable { $$ = $1; }
;
/*
w_expr:
w_cvar { $$ = $1; }
| expr_without_variable { $$ = $1; }
;
*/
r_cvar:
cvar { zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC); $$ = $1; }
;
w_cvar:
cvar { zend_do_end_variable_parse(BP_VAR_W, 0 CLS_CC); $$ = $1; }
;
rw_cvar:
cvar { zend_do_end_variable_parse(BP_VAR_RW, 0 CLS_CC); $$ = $1; }
;
cvar:
cvar_without_objects { $$ = $1; }
| cvar_without_objects T_OBJECT_OPERATOR { zend_do_push_object(&$1 CLS_CC); } ref_list { $$ = $4; }
;
cvar_without_objects:
reference_variable { $$ = $1; }
| simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 CLS_CC); }
;
reference_variable:
reference_variable '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 CLS_CC); }
| reference_variable '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 CLS_CC); }
| compound_variable { zend_do_fetch_globals(&$1 CLS_CC); zend_do_begin_variable_parse(CLS_C); fetch_simple_variable(&$$, &$1, 1 CLS_CC); }
;
compound_variable:
T_VARIABLE { $$ = $1; }
| '$' '{' expr '}' { $$ = $3; }
;
dim_offset:
/* empty */ { $$.op_type = IS_UNUSED; }
| expr { $$ = $1; }
;
ref_list:
object_property { $$ = $1; }
| ref_list T_OBJECT_OPERATOR { zend_do_push_object(&$1 CLS_CC); } object_property { $$ = $4; }
;
object_property:
object_dim_list { $$ = $1; }
| cvar_without_objects { zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC); } { znode tmp_znode; zend_do_pop_object(&tmp_znode CLS_CC); zend_do_fetch_property(&$$, &tmp_znode, &$1 CLS_CC);}
;
object_dim_list:
object_dim_list '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 CLS_CC); }
| object_dim_list '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 CLS_CC); }
| variable_name { znode tmp_znode; zend_do_pop_object(&tmp_znode CLS_CC); zend_do_fetch_property(&$$, &tmp_znode, &$1 CLS_CC);}
;
variable_name:
T_STRING { $$ = $1; }
| '{' expr '}' { $$ = $2; }
;
simple_indirect_reference:
'$' { $$.u.constant.value.lval = 1; }
| simple_indirect_reference '$' { $$.u.constant.value.lval++; }
;
assignment_list:
assignment_list ',' assignment_list_element
| assignment_list_element
;
assignment_list_element:
cvar { zend_do_add_list_element(&$1 CLS_CC); }
| T_LIST '(' { zend_do_new_list_begin(CLS_C); } assignment_list ')' { zend_do_new_list_end(CLS_C); }
| /* empty */ { zend_do_add_list_element(NULL CLS_CC); }
;
array_pair_list:
/* empty */ { zend_do_init_array(&$$, NULL, NULL, 0 CLS_CC); }
| non_empty_array_pair_list possible_comma { $$ = $1; }
;
non_empty_array_pair_list:
non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr { zend_do_add_array_element(&$$, &$5, &$3, 0 CLS_CC); }
| non_empty_array_pair_list ',' expr { zend_do_add_array_element(&$$, &$3, NULL, 0 CLS_CC); }
| expr T_DOUBLE_ARROW expr { zend_do_init_array(&$$, &$3, &$1, 0 CLS_CC); }
| expr { zend_do_init_array(&$$, &$1, NULL, 0 CLS_CC); }
| non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_cvar { zend_do_add_array_element(&$$, &$6, &$3, 1 CLS_CC); }
| non_empty_array_pair_list ',' '&' w_cvar { zend_do_add_array_element(&$$, &$4, NULL, 1 CLS_CC); }
| expr T_DOUBLE_ARROW '&' w_cvar { zend_do_init_array(&$$, &$4, &$1, 1 CLS_CC); }
| '&' w_cvar { zend_do_init_array(&$$, &$2, NULL, 1 CLS_CC); }
;
encaps_list:
encaps_list encaps_var { zend_do_end_variable_parse(BP_VAR_R, 0 CLS_CC); zend_do_add_variable(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_STRING { zend_do_add_string(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_NUM_STRING { zend_do_add_string(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_ENCAPSED_AND_WHITESPACE { zend_do_add_string(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_CHARACTER { zend_do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_BAD_CHARACTER { zend_do_add_string(&$$, &$1, &$2 CLS_CC); }
| encaps_list '[' { $2.u.constant.value.lval = (long) '['; zend_do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list ']' { $2.u.constant.value.lval = (long) ']'; zend_do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list '{' { $2.u.constant.value.lval = (long) '{'; zend_do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list '}' { $2.u.constant.value.lval = (long) '}'; zend_do_add_char(&$$, &$1, &$2 CLS_CC); }
| encaps_list T_OBJECT_OPERATOR { znode tmp; $2.u.constant.value.lval = (long) '-'; zend_do_add_char(&tmp, &$1, &$2 CLS_CC); $2.u.constant.value.lval = (long) '>'; zend_do_add_char(&$$, &tmp, &$2 CLS_CC); }
| /* empty */ { zend_do_init_string(&$$ CLS_CC); }
;
encaps_var:
T_VARIABLE { zend_do_fetch_globals(&$1 CLS_CC); zend_do_begin_variable_parse(CLS_C); fetch_simple_variable(&$$, &$1, 1 CLS_CC); }
| T_VARIABLE '[' { zend_do_begin_variable_parse(CLS_C); } encaps_var_offset ']' { zend_do_fetch_globals(&$1 CLS_CC); fetch_array_begin(&$$, &$1, &$4 CLS_CC); }
| T_VARIABLE T_OBJECT_OPERATOR T_STRING { zend_do_begin_variable_parse(CLS_C); fetch_simple_variable(&$2, &$1, 1 CLS_CC); zend_do_fetch_property(&$$, &$2, &$3 CLS_CC); }
| T_DOLLAR_OPEN_CURLY_BRACES expr '}' { zend_do_begin_variable_parse(CLS_C); fetch_simple_variable(&$$, &$2, 1 CLS_CC); }
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' { zend_do_begin_variable_parse(CLS_C); fetch_array_begin(&$$, &$2, &$4 CLS_CC); }
| T_CURLY_OPEN cvar '}' { $$ = $2; }
;
encaps_var_offset:
T_STRING { $$ = $1; }
| T_NUM_STRING { $$ = $1; }
| T_VARIABLE { fetch_simple_variable(&$$, &$1, 1 CLS_CC); }
;
internal_functions_in_yacc:
T_ISSET '(' cvar ')' { zend_do_isset_or_isempty(ZEND_ISSET, &$$, &$3 CLS_CC); }
| T_EMPTY '(' cvar ')' { zend_do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 CLS_CC); }
| T_INCLUDE expr { zend_do_include_or_eval(ZEND_INCLUDE, &$$, &$2 CLS_CC); }
| T_INCLUDE_ONCE expr { zend_do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 CLS_CC); }
| T_EVAL '(' expr ')' { zend_do_include_or_eval(ZEND_EVAL, &$$, &$3 CLS_CC); }
| T_REQUIRE expr { zend_do_include_or_eval(ZEND_REQUIRE, &$$, &$2 CLS_CC); }
| T_REQUIRE_ONCE expr { zend_do_include_or_eval(ZEND_REQUIRE_ONCE, &$$, &$2 CLS_CC); }
;
%%
+1 -5
View File
@@ -397,12 +397,8 @@ void zend_destroy_rsrc_list_dtors()
char *zend_rsrc_list_get_rsrc_type(int resource)
{
zend_rsrc_list_dtors_entry *lde;
int rsrc_type;
if (!zend_list_find(resource, &rsrc_type))
return NULL;
if (zend_hash_index_find(&list_destructors, rsrc_type, (void **) &lde)==SUCCESS) {
if (zend_hash_index_find(&list_destructors, resource, (void **) &lde)==SUCCESS) {
return lde->type_name;
} else {
return NULL;
+14 -33
View File
@@ -63,30 +63,26 @@ ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element)
}
#define DEL_LLIST_ELEMENT(current,l) \
if (current->prev) {\
current->prev->next = current->next;\
} else {\
l->head = current->next;\
}\
if (current->next) {\
current->next->prev = current->prev;\
} else {\
l->tail = current->prev;\
}\
if (l->dtor) {\
l->dtor(current->data);\
pefree(current, l->persistent);\
}
ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2))
{
zend_llist_element *current=l->head;
while (current) {
if (compare(current->data, element)) {
DEL_LLIST_ELEMENT(current,l);
if (current->prev) {
current->prev->next = current->next;
} else {
l->head = current->next;
}
if (current->next) {
current->next->prev = current->prev;
} else {
l->tail = current->prev;
}
if (l->dtor) {
l->dtor(current->data);
pefree(current, l->persistent);
}
break;
}
current = current->next;
@@ -143,21 +139,6 @@ ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src)
}
ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data))
{
zend_llist_element *element, *next;
element=l->head;
while (element) {
next = element->next;
if (func(element->data)) {
DEL_LLIST_ELEMENT(element,l);
}
element = next;
}
}
ZEND_API void zend_llist_apply(zend_llist *l, void (*func)(void *data))
{
zend_llist_element *element;
-1
View File
@@ -55,7 +55,6 @@ ZEND_API void zend_llist_clean(zend_llist *l);
ZEND_API void zend_llist_remove_tail(zend_llist *l);
ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src);
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t);
ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data));
ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t, void *arg);
ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func, int num_args, ...);
ZEND_API int zend_llist_count(zend_llist *l);
+1 -1
View File
@@ -75,7 +75,7 @@ struct _zend_module_entry {
};
extern ZEND_API HashTable module_registry;
extern HashTable module_registry;
void module_destructor(zend_module_entry *module);
int module_registry_cleanup(zend_module_entry *module);
+4 -6
View File
@@ -189,7 +189,7 @@ void init_op(zend_op *op CLS_DC)
{
memset(&op->result, 0, sizeof(znode));
op->lineno = CG(zend_lineno);
SET_UNUSED(op->result);
op->result.op_type = IS_UNUSED;
op->extended_value = 0;
memset(&op->op1, 0, sizeof(znode));
memset(&op->op2, 0, sizeof(znode));
@@ -211,7 +211,7 @@ zend_op *get_next_op(zend_op_array *op_array CLS_DC)
zend_bailout();
}
#endif
op_array->size *= 4;
op_array->size *= 2;
op_array_alloc_ops(op_array);
}
@@ -260,8 +260,8 @@ static void zend_update_extended_info(zend_op_array *op_array CLS_DC)
}
opline = get_next_op(op_array CLS_CC);
opline->opcode = ZEND_EXT_STMT;
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
opline->op1.op_type = IS_UNUSED;
opline->op2.op_type = IS_UNUSED;
if (op_array->last>0) {
opline->lineno= op_array->opcodes[op_array->last-2].lineno;
}
@@ -302,8 +302,6 @@ int pass_two(zend_op_array *op_array)
}
opline++;
}
op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
op_array->size = op_array->last;
op_array->done_pass_two = 1;
return 0;
}
+3 -36
View File
@@ -32,34 +32,10 @@
#include "zend_list.h"
#include "zend_fast_cache.h"
#if 0&&WITH_BCMATH
#if WITH_BCMATH
#include "ext/bcmath/number.h"
#endif
ZEND_API int zend_atoi(const char *str, int str_len)
{
int retval;
if (!str_len) {
str_len = strlen(str);
}
retval = atoi(str);
if (str_len>0) {
switch (str[str_len-1]) {
case 'k':
case 'K':
retval *= 1024;
break;
case 'm':
case 'M':
retval *= 1048576;
break;
}
}
return retval;
}
ZEND_API double zend_string_to_double(const char *number, zend_uint length)
{
double divisor = 10.0;
@@ -116,7 +92,7 @@ ZEND_API void convert_scalar_to_number(zval *op)
case IS_DOUBLE:
case IS_LONG:
break;
#if 0&&WITH_BCMATH
#if WITH_BCMATH
case FLAG_IS_BC:
op->type = IS_DOUBLE; /* may have lost significant digits */
break;
@@ -1363,13 +1339,6 @@ static void increment_string(zval *str)
int last=0; /* Shut up the compiler warning */
int ch;
if (str->value.str.len == 0) {
STR_FREE(str->value.str.val);
str->value.str.val = estrndup("1", sizeof("1")-1);
str->value.str.len = 1;
return;
}
while(pos >= 0) {
ch = s[pos];
if (ch >= 'a' && ch <= 'z') {
@@ -1598,7 +1567,7 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2)
if ((ret1=is_numeric_string(s1->value.str.val, s1->value.str.len, &lval1, &dval1)) &&
(ret2=is_numeric_string(s2->value.str.val, s2->value.str.len, &lval2, &dval2))) {
#if 0&&WITH_BCMATH
#if WITH_BCMATH
if ((ret1==FLAG_IS_BC) || (ret2==FLAG_IS_BC)) {
bc_num first, second;
@@ -1748,6 +1717,4 @@ static inline int is_numeric_string(char *str, int length, long *lval, double *d
}
}
#endif
+3 -14
View File
@@ -28,9 +28,8 @@
#include <ieeefp.h>
#endif
#if 0&&WITH_BCMATH
#include "ext/bcmath/libbcmath/src/bcmath.h"
#if WITH_BCMATH
#include "ext/bcmath/number.h"
#endif
#define MAX_LENGTH_OF_LONG 18
@@ -89,7 +88,7 @@ static inline int is_numeric_string(char *str, int length, long *lval, double *d
if (dval) {
*dval = local_dval;
}
#if 0&&WITH_BCMATH
#if WITH_BCMATH
if (length>16) {
register char *ptr=str, *end=str+length;
@@ -159,7 +158,6 @@ ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable
ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2);
ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2);
ZEND_API int zend_atoi(const char *str, int str_len);
#define convert_to_ex_master(ppzv, lower_type, upper_type) \
if ((*ppzv)->type!=IS_##upper_type) { \
@@ -209,9 +207,6 @@ ZEND_API int zend_atoi(const char *str, int str_len);
#define Z_STRVAL(zval) (zval).value.str.val
#define Z_STRLEN(zval) (zval).value.str.len
#define Z_ARRVAL(zval) (zval).value.ht
#define Z_OBJPROP(zval) (zval).value.obj.properties
#define Z_OBJCE(zval) (zval).value.obj.ce
#define Z_RESVAL(zval) (zval).value.lval
#define Z_LVAL_P(zval_p) Z_LVAL(*zval_p)
#define Z_BVAL_P(zval_p) Z_BVAL(*zval_p)
@@ -219,9 +214,6 @@ ZEND_API int zend_atoi(const char *str, int str_len);
#define Z_STRVAL_P(zval_p) Z_STRVAL(*zval_p)
#define Z_STRLEN_P(zval_p) Z_STRLEN(*zval_p)
#define Z_ARRVAL_P(zval_p) Z_ARRVAL(*zval_p)
#define Z_OBJPROP_P(zval_p) Z_OBJPROP(*zval_p)
#define Z_OBJCE_P(zval_p) Z_OBJCE(*zval_p)
#define Z_RESVAL_P(zval_p) Z_RESVAL(*zval_p)
#define Z_LVAL_PP(zval_pp) Z_LVAL(**zval_pp)
#define Z_BVAL_PP(zval_pp) Z_BVAL(**zval_pp)
@@ -229,9 +221,6 @@ ZEND_API int zend_atoi(const char *str, int str_len);
#define Z_STRVAL_PP(zval_pp) Z_STRVAL(**zval_pp)
#define Z_STRLEN_PP(zval_pp) Z_STRLEN(**zval_pp)
#define Z_ARRVAL_PP(zval_pp) Z_ARRVAL(**zval_pp)
#define Z_OBJPROP_PP(zval_pp) Z_OBJPROP(**zval_pp)
#define Z_OBJCE_PP(zval_pp) Z_OBJCE(**zval_pp)
#define Z_RESVAL_PP(zval_pp) Z_RESVAL(**zval_pp)
#define Z_TYPE(zval) (zval).type
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)
+3 -46
View File
@@ -51,13 +51,9 @@ AC_DEFUN(PHP_READDIR_R_TYPE,[
#include <sys/types.h>
#include <dirent.h>
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
main() {
DIR *dir;
char entry[sizeof(struct dirent)+PATH_MAX];
char entry[sizeof(struct dirent)+257];
struct dirent *pentry = (struct dirent *) &entry;
dir = opendir("/");
@@ -208,7 +204,7 @@ dnl Sets PHP_ARG_NAME either to the user value or to the default value.
dnl default-val defaults to no.
dnl
AC_DEFUN(PHP_ARG_WITH,[
PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_))
PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
])
AC_DEFUN(PHP_REAL_ARG_WITH,[
@@ -480,7 +476,7 @@ AC_DEFUN(AC_EXPAND_PATH,[
$2="$1"
else
changequote({,})
ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`"
ep_dir="`echo $1|sed 's%/*[^/][^/]*$%%'`"
changequote([,])
ep_realdir="`(cd \"$ep_dir\" && pwd)`"
$2="$ep_realdir/`basename \"$1\"`"
@@ -883,42 +879,3 @@ int main(void) {
fi
])
AC_DEFUN(PHP_FOPENCOOKIE,[
AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ])
if test "$have_glibc_fopencookie" = "yes" ; then
dnl this comes in two flavors:
dnl newer glibcs (since 2.1.2 ? )
dnl have a type called cookie_io_functions_t
AC_TRY_COMPILE([ #define _GNU_SOURCE
#include <stdio.h>
],
[ cookie_io_functions_t cookie; ],
[ have_cookie_io_functions_t=yes ],
[ ] )
if test "$have_cookie_io_functions_t" = "yes" ; then
cookie_io_functions_t=cookie_io_functions_t
have_fopen_cookie=yes
else
dnl older glibc versions (up to 2.1.2 ?)
dnl call it _IO_cookie_io_functions_t
AC_TRY_COMPILE([ #define _GNU_SOURCE
#include <stdio.h>
],
[ _IO_cookie_io_functions_t cookie; ],
[ have_IO_cookie_io_functions_t=yes ],
[] )
if test "$have_cookie_io_functions_t" = "yes" ; then
cookie_io_functions_t=_IO_cookie_io_functions_t
have_fopen_cookie=yes
fi
fi
if test "$have_fopen_cookie" = "yes" ; then
AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
fi
fi
])
+1 -1
View File
@@ -238,7 +238,7 @@ registers two INI entries - "foo" and "bar". They're given defaults "1"
and "bah" respectively - note that all defaults are always given as
strings. That doesn't reduce your ability to use integer values, simply
specify them as strings. "foo" is marked so that it can be changed by
anyone at any time (PHP_INI_ALL), whereas "bar" is marked so it can be
anyone at any time (PHP_INI_ALL), whereas "foo" is marked so it can be
changed only at startup in the php3.ini only, presumably, by the system
administrator (PHP_INI_SYSTEM).
When "foo" changes, no function is called. Access to it is done using the
File renamed without changes.
+1 -1
View File
@@ -26,7 +26,7 @@ LT_TARGETS = ltconfig ltmain.sh config.guess config.sub
makefile_in_files = $(makefile_am_files:.am=.in)
makefile_files = $(makefile_am_files:e.am=e)
config_h_in = main/php_config.h.in
config_h_in = php_config.h.in
acconfig_h_SOURCES = acconfig.h.in $(config_h_files)
+1 -1
View File
@@ -32,7 +32,7 @@ mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
INSTALL = $(top_srcdir)/build/shtool install -c
INSTALL_DATA = $(INSTALL) -m 644
DEFS = -I. -I$(srcdir) -I$(top_builddir)/main -I$(top_srcdir)
DEFS = -I. -I$(srcdir) -I$(top_builddir) -I$(top_builddir)/main
moduledir = $(EXTENSION_DIR)
+23 -46
View File
@@ -51,7 +51,7 @@ dnl ## All of these are normally in the extension directories.
dnl ## Diversion 5 is the last one. Here we generate files and clean up.
dnl ## This is where the version number is changed from now on!
AM_INIT_AUTOMAKE(php, 4.0.4RC3)
AM_INIT_AUTOMAKE(php, 4.0.3)
PHP_VERSION=$VERSION
echo "/* automatically generated by configure */" > php_version.h.new
@@ -65,7 +65,7 @@ else
rm -f php_version.h.new
fi
AM_CONFIG_HEADER(main/php_config.h)
AM_CONFIG_HEADER(php_config.h)
AM_MAINTAINER_MODE
AC_CANONICAL_HOST
@@ -139,7 +139,6 @@ dnl paths to the targets are relative to the build directory
SAPI_PROGRAM=php
SAPI_SHARED=libs/libphp4.$SHLIB_SUFFIX_NAME
SAPI_STATIC=libs/libphp4.a
SAPI_LIBTOOL=libphp4.la
PHP_CONFIGURE_PART(Configuring SAPI modules)
@@ -199,7 +198,7 @@ if test -d /usr/pkg/include -a -d /usr/pkg/lib ; then
LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
fi
INCLUDES="$INCLUDES -I\$(top_builddir)/Zend"
INCLUDES="$INCLUDES -I\$(top_builddir)/Zend -I\$(top_srcdir)"
AC_CHECK_LIB(socket, socket, [
@@ -334,13 +333,13 @@ dnl Checks for types
AC_TYPE_SIZE_T
AC_TYPE_UID_T
dnl Check for IPv6 support
AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
dnl Check for struct sockaddr_in6
AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_struct_sockaddr_in6,
[AC_TRY_COMPILE([#include <sys/socket.h>
#include <netinet/in.h>], [struct sockaddr_in6 s; int i=AF_INET6; s],
ac_cv_ipv6_support=yes, ac_cv_ipv6_support=no)])
if test "$ac_cv_ipv6_support" = yes; then
AC_DEFINE(HAVE_IPV6,1,[Whether you have IPv6 support])
#include <netinet/in.h>], [struct sockaddr_in6 s; s;],
ac_cv_struct_sockaddr_in6=yes, ac_cv_struct_sockaddr_in6=no)])
if test "$ac_cv_struct_sockaddr_in6" = yes; then
AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6,1,[Whether you have struct sockaddr_in6])
fi
dnl Checks for library functions.
@@ -401,7 +400,7 @@ vsnprintf \
dnl Check for getaddrinfo, should be a better way, but...
AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo,
[AC_TRY_COMPILE([#include <netdb.h>],
[struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);],
[struct addrinfo h;getaddrinfo("","",&h,&h);],
ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no)])
if test "$ac_cv_func_getaddrinfo" = yes; then
AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
@@ -501,38 +500,6 @@ AC_ARG_WITH(exec-dir,
AC_MSG_RESULT(/usr/local/php/bin)
])
PHP_ARG_WITH(openssl,for OpenSSL support,
[ --with-openssl[=DIR] Include OpenSSL support])
if test "$PHP_OPENSSL" = "yes"; then
PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl"
fi
AC_DEFUN(PHP_SETUP_OPENSSL,[
if test "$PHP_OPENSSL" = "no"; then
PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl"
fi
for i in $PHP_OPENSSL; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_DIR=$i
OPENSSL_INC=$i/include
fi
done
if test -z "$OPENSSL_DIR"; then
AC_MSG_ERROR(Cannot find OpenSSL's <evp.h>)
fi
AC_ADD_LIBPATH($OPENSSL_DIR/lib)
AC_ADD_LIBRARY(ssl)
AC_ADD_LIBRARY(crypto)
AC_ADD_INCLUDE($OPENSSL_INC)
])
if test "$PHP_OPENSSL" != "no"; then
PHP_SETUP_OPENSSL
fi
PHP_ARG_ENABLE(sigchild,whether to enable PHP's own SIGCHLD handler,
[ --enable-sigchild Enable PHP's own SIGCHLD handler.],no)
@@ -576,6 +543,16 @@ else
AC_DEFINE(DEFAULT_SHORT_OPEN_TAG,0,[ ])
fi
PHP_ARG_ENABLE(url-fopen-wrapper,whether to enable the URL-aware fopen wrapper,
[ --disable-url-fopen-wrapper
Disable the URL-aware fopen wrapper that allows
accessing files via http or ftp.], yes)
if test "$PHP_URL_FOPEN_WRAPPER" = "yes"; then
AC_DEFINE(PHP_URL_FOPEN, 1, [ ])
else
AC_DEFINE(PHP_URL_FOPEN, 0, [ ])
fi
PHP_ARG_ENABLE(pic,whether to enable PIC for shared objects,
[ --disable-pic Disable PIC for shared objects], yes)
@@ -842,7 +819,7 @@ PHP_CONFIGURE_PART(Generating files)
PHP_GEN_CONFIG_VARS
ALL_OUTPUT_FILES="php4.spec Zend/Makefile main/build-defs.h $PHP_OUTPUT_FILES"
ALL_OUTPUT_FILES="php4.spec Zend/Makefile build-defs.h $PHP_OUTPUT_FILES"
AC_OUTPUT($ALL_OUTPUT_FILES, [], [
@@ -866,11 +843,11 @@ fi
#
if test -d TSRM; then
echo '#include "../main/php_config.h"' > TSRM/tsrm_config.h
echo '#include "../php_config.h"' > TSRM/tsrm_config.h
fi
cat >Zend/zend_config.h <<FEO
#include "../main/php_config.h"
#include "../php_config.h"
#if defined(APACHE) && defined(PHP_API_VERSION)
#undef HAVE_DLFCN_H
#endif
-6
View File
@@ -54,13 +54,7 @@ AC_DEFUN(LIB_BUILD,[
lib_target=""
$php_shtool mkdir -p $1
if test "$BSD_MAKEFILE" = "yes"; then
lib_include_conf=".include \"\$(top_builddir)/config_vars.mk\""
else
lib_include_conf="include \$(top_builddir)/config_vars.mk"
fi
cat >$lib_makefile<<EOF
$lib_include_conf
LTLIBRARY_OBJECTS = \$(LTLIBRARY_SOURCES:.c=.lo) \$(LTLIBRARY_OBJECTS_X)
LTLIBRARY_SHARED_OBJECTS = \$(LTLIBRARY_OBJECTS:.lo=.slo)
EOF
-2
View File
@@ -1,2 +0,0 @@
aspell
Rasmus Lerdorf
+2 -3
View File
@@ -52,16 +52,15 @@ zend_module_entry aspell_module_entry = {
ZEND_GET_MODULE(aspell)
#endif
static void php_aspell_close(zend_rsrc_list_entry *rsrc)
static void php_aspell_close(aspell *sc)
{
aspell *sc = (aspell *)rsrc->ptr;
aspell_free(sc);
}
PHP_MINIT_FUNCTION(aspell)
{
le_aspell = zend_register_list_destructors_ex(php_aspell_close, NULL, "aspell", module_number);
le_aspell = register_list_destructors(php_aspell_close,NULL);
return SUCCESS;
}
-2
View File
@@ -1,2 +0,0 @@
BC Math
Andi Gutmans
-5
View File
@@ -2,10 +2,5 @@
LTLIBRARY_NAME = libbcmath.la
LTLIBRARY_SOURCES = bcmath.c number.c
LTLIBRARY_SHARED_NAME = bcmath.la
LTLIBRARY_DEPENDENCIES = libbcmath/libbcmath.la
LTLIBRARY_LIBADD = $(LTLIBRARY_DEPENDENCIES)
LTLIBRARY_SHARED_LIBADD = $(LTLIBRARY_LIBADD)
SUBDIRS = libbcmath
include $(top_srcdir)/build/dynlib.mk
+74 -121
View File
@@ -22,9 +22,9 @@
#if WITH_BCMATH
#include "number.h"
#include "ext/standard/info.h"
#include "php_bcmath.h"
#include "ext/bcmath/libbcmath/src/bcmath.h"
function_entry bcmath_functions[] = {
PHP_FE(bcadd, NULL)
@@ -42,10 +42,10 @@ function_entry bcmath_functions[] = {
zend_module_entry bcmath_module_entry = {
"bcmath",
bcmath_functions,
PHP_MINIT(bcmath),
PHP_MSHUTDOWN(bcmath),
PHP_RINIT(bcmath),
NULL,
NULL,
PHP_RINIT(bcmath),
PHP_RSHUTDOWN(bcmath),
PHP_MINFO(bcmath),
STANDARD_MODULE_PROPERTIES
};
@@ -58,67 +58,20 @@ ZEND_GET_MODULE(bcmath)
static long bc_precision;
#endif
/* Storage used for special numbers. */
bc_num _zero_;
bc_num _one_;
bc_num _two_;
/* Make a copy of a number! Just increments the reference count! */
bc_num copy_num (bc_num num)
{
num->n_refs++;
return num;
}
/* Initialize a number NUM by making it a copy of zero. */
void init_num (bc_num *num)
{
*num = copy_num (_zero_);
}
PHP_MINIT_FUNCTION(bcmath)
{
extern bc_num _zero_;
extern bc_num _one_;
extern bc_num _two_;
_zero_ = bc_new_num (1,0);
_one_ = bc_new_num (1,0);
_one_->n_value[0] = 1;
_two_ = bc_new_num (1,0);
_two_->n_value[0] = 2;
persist_alloc(_zero_);
persist_alloc(_one_);
persist_alloc(_two_);
persist_alloc(_zero_->n_ptr);
persist_alloc(_one_->n_ptr);
persist_alloc(_two_->n_ptr);
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(bcmath)
{
bc_free_num(&_zero_);
bc_free_num(&_one_);
bc_free_num(&_two_);
return SUCCESS;
}
PHP_RINIT_FUNCTION(bcmath)
{
init_numbers();
if (cfg_get_long("bcmath.scale",&bc_precision)==FAILURE) {
bc_precision=0;
}
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(bcmath)
{
destruct_numbers();
return SUCCESS;
}
PHP_MINFO_FUNCTION(bcmath)
{
@@ -154,18 +107,18 @@ PHP_FUNCTION(bcadd)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first,(*left)->value.str.val,scale);
bc_str2num(&second,(*right)->value.str.val,scale);
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 = bc_num2str(result);
return_value->value.str.val = num2str(result);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
free_num(&first);
free_num(&second);
free_num(&result);
return;
}
/* }}} */
@@ -197,18 +150,18 @@ PHP_FUNCTION(bcsub)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first,(*left)->value.str.val,scale);
bc_str2num(&second,(*right)->value.str.val,scale);
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 = bc_num2str(result);
return_value->value.str.val = num2str(result);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
free_num(&first);
free_num(&second);
free_num(&result);
return;
}
/* }}} */
@@ -240,18 +193,18 @@ PHP_FUNCTION(bcmul)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first,(*left)->value.str.val,scale);
bc_str2num(&second,(*right)->value.str.val,scale);
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 = bc_num2str(result);
return_value->value.str.val = num2str(result);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
free_num(&first);
free_num(&second);
free_num(&result);
return;
}
/* }}} */
@@ -283,14 +236,14 @@ PHP_FUNCTION(bcdiv)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first,(*left)->value.str.val,scale);
bc_str2num(&second,(*right)->value.str.val,scale);
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 = bc_num2str(result);
return_value->value.str.val = num2str(result);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
break;
@@ -298,9 +251,9 @@ PHP_FUNCTION(bcdiv)
php_error(E_WARNING,"Division by zero");
break;
}
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
free_num(&first);
free_num(&second);
free_num(&result);
return;
}
/* }}} */
@@ -324,14 +277,14 @@ PHP_FUNCTION(bcmod)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first,(*left)->value.str.val,0);
bc_str2num(&second,(*right)->value.str.val,0);
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 = bc_num2str(result);
return_value->value.str.val = num2str(result);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
break;
@@ -339,9 +292,9 @@ PHP_FUNCTION(bcmod)
php_error(E_WARNING,"Division by zero");
break;
}
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
free_num(&first);
free_num(&second);
free_num(&result);
return;
}
/* }}} */
@@ -373,18 +326,18 @@ PHP_FUNCTION(bcpow)
}
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
bc_str2num(&first,(*left)->value.str.val,scale);
bc_str2num(&second,(*right)->value.str.val,scale);
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 = bc_num2str(result);
return_value->value.str.val = num2str(result);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&result);
free_num(&first);
free_num(&second);
free_num(&result);
return;
}
/* }}} */
@@ -415,16 +368,16 @@ PHP_FUNCTION(bcsqrt)
break;
}
convert_to_string_ex(left);
bc_init_num(&result);
bc_str2num(&result,(*left)->value.str.val,scale);
init_num(&result);
str2num(&result,(*left)->value.str.val,scale);
if (bc_sqrt (&result, scale) != 0) {
return_value->value.str.val = bc_num2str(result);
return_value->value.str.val = num2str(result);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
} else {
php_error(E_WARNING,"Square root of negative number");
}
bc_free_num(&result);
free_num(&result);
return;
}
/* }}} */
@@ -457,16 +410,16 @@ PHP_FUNCTION(bccomp)
convert_to_string_ex(left);
convert_to_string_ex(right);
bc_init_num(&first);
bc_init_num(&second);
init_num(&first);
init_num(&second);
bc_str2num(&first,(*left)->value.str.val,scale);
bc_str2num(&second,(*right)->value.str.val,scale);
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;
bc_free_num(&first);
bc_free_num(&second);
free_num(&first);
free_num(&second);
return;
}
/* }}} */
+7 -5
View File
@@ -1,14 +1,16 @@
dnl $Id$
PHP_ARG_WITH(bcmath, for bc style precision math functions,
[ --without-bcmath Compile without bc style precision math functions. ], yes)
PHP_ARG_ENABLE(bcmath,whether to enable bc style precision math functions,
[ --enable-bcmath Compile with bc style precision math functions.
Read README-BCMATH for instructions on how to
get this module installed. ])
if test "$PHP_BCMATH" != "no"; then
AC_DEFINE(WITH_BCMATH, 1, [Whether you have bcmath])
PHP_EXTENSION(bcmath, $ext_shared)
PHP_FAST_OUTPUT($ext_builddir/libbcmath/Makefile $ext_builddir/libbcmath/src/Makefile)
LIB_BUILD($ext_builddir/libbcmath,$ext_shared,yes)
LIB_BUILD($ext_builddir/libbcmath/src,$ext_shared,yes)
if test ! -f $ext_srcdir/number.c || grep "Dummy File" $ext_srcdir/number.c >/dev/null; then
AC_MSG_ERROR(You do not have the bcmath package. Please read the README.BCMATH file.)
fi
fi
dnl ## Local Variables:
-3
View File
@@ -1,3 +0,0 @@
Phil Nelson <philnelson@acm.org> wrote bcmath library.
-515
View File
@@ -1,515 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations
below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
^L
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it
becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
^L
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control
compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
^L
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
^L
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
^L
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
^L
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply, and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License
may add an explicit geographical distribution limitation excluding those
countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
^L
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
^L
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms
of the ordinary General Public License).
To apply these terms, attach the following notices to the library.
It is safest to attach them to the start of each source file to most
effectively convey the exclusion of warranty; and each file should
have at least the "copyright" line and a pointer to where the full
notice is found.
<one line to give the library's name and a brief idea of what it
does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser 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
Also add information on how to contact you by electronic and paper
mail.
You should also get your employer (if you work as a programmer) or
your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James
Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
-10
View File
@@ -1,10 +0,0 @@
Wed Jun 7 09:39:02 2000 Phil Nelson <phil@cs.wwu.edu>
* configure.in and many others: version number now at 0.2.
Many other changes/additions for getting a distribution
to work.
2000-05-21 Phil Nelson <phil@cs.wwu.edu>
* Initial setup of bcmath library., calling it version 0.1.
-21
View File
@@ -1,21 +0,0 @@
BCMATH FAQ:
1) Why BCMATH?
The math routines of GNU bc become more generally useful in a
library form. By separating the BCMATH library from GNU bc,
GNU bc can be under the GPL and BCMATH can be under the LGPL.
2) Why BCMATH when GMP exists?
GMP has "integers" (no digits after a decimal), "rational numbers"
(stored as 2 integers) and "floats". None of these will correctly
represent a POSIX BC number. Floats are the closest, but will not
behave correctly for many computations. For example, BC numbers have
a "scale" that represent the number of digits to represent after the
decimal point. The multiplying two of these numbers requires one to
calculate an exact number of digits after the decimal point regardless
of the number of digits in the integer part. GMP floats have a
"fixed, but arbitrary" mantissa and so multiplying two floats will end
up dropping digits BC must calculate.
-9
View File
@@ -1,9 +0,0 @@
Currently, only libbcmath.a is built. To build and install it, do
configure
make
make install
Typical configure parameters are available. (e.g. PREFIX)
Bugs and comments to philnelson@acm.org.
-12
View File
@@ -1,12 +0,0 @@
## Process this file with automake to produce Makefile.in
SUBDIRS= src doc
MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in \
stamp-h.in *~
dist-hook:
cp $(srcdir)/doc/bcmath.1 $(distdir)/doc
cp $(srcdir)/src/private.h $(distdir)/src
cp $(srcdir)/FAQ $(distdir)
-9
View File
@@ -1,9 +0,0 @@
LTLIBRARY_NAME = libbcmath.la
LTLIBRARY_DEPENDENCIES = src/libbcmath.la
LTLIBRARY_LIBADD = $(LTLIBRARY_DEPENDENCIES)
LTLIBRARY_SHARED_LIBADD = $(LTLIBRARY_LIBADD)
SUBDIRS = src
include $(top_srcdir)/build/dynlib.mk
-3
View File
@@ -1,3 +0,0 @@
NEWS for bcmath library:
May 2000: The library is created.
-9
View File
@@ -1,9 +0,0 @@
This is bcmath, a library of arbitrary precision math routines.
These routines, in a different form, are the routines that to
the arbitrary precision calculations for GNU bc and GNU dc.
This library is provided to make these routines useful in a
larger context with less restrictions on the use of them.
These routines do not duplicate functionality of the GNU gmp
library. gmp is similar, but the actual computation is different.
-9
View File
@@ -1,9 +0,0 @@
/* PACKAGE name */
#undef PACKAGE
/* Package VERSION number */
#undef VERSION
/* Define to `size_t' if <sys/types.h> and <stddef.h> don't define. */
#undef ptrdiff_t
-127
View File
@@ -1,127 +0,0 @@
dnl aclocal.m4 generated automatically by aclocal 1.4
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
# serial 1
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
AC_SUBST(VERSION)
dnl test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
ifelse([$3],,
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN(AM_SANITY_CHECK,
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftestfile
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
if test "[$]*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftestfile`
fi
if test "[$]*" != "X $srcdir/configure conftestfile" \
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "[$]2" = conftestfile
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
rm -f conftest*
AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN(AM_MISSING_PROG,
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT(found)
else
$1="$3/missing $2"
AC_MSG_RESULT(missing)
fi
AC_SUBST($1)])
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN(AM_CONFIG_HEADER,
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
dnl This file resides in the same directory as the config header
dnl that is generated. We must strip everything past the first ":",
dnl and everything past the last "/".
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
<<am_indx=1
for am_file in <<$1>>; do
case " <<$>>CONFIG_HEADERS " in
*" <<$>>am_file "*<<)>>
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
;;
esac
am_indx=`expr "<<$>>am_indx" + 1`
done<<>>dnl>>)
changequote([,]))])
-41
View File
@@ -1,41 +0,0 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
#undef const
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to `size_t' if <sys/types.h> and <stddef.h> don't define. */
#undef ptrdiff_t
/* Define if you have the <lib.h> header file. */
#undef HAVE_LIB_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION
-1859
View File
File diff suppressed because it is too large. Load diff
-18
View File
@@ -1,18 +0,0 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(doc/bcmath.1)
AM_INIT_AUTOMAKE("bcmath", "0.2")
AM_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_MAKE_SET
AC_CHECK_HEADERS(stdarg.h stddef.h stdlib.h string.h limits.h unistd.h lib.h)
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ptrdiff_t, size_t)
AC_OUTPUT(Makefile src/Makefile doc/Makefile)
-3
View File
@@ -1,3 +0,0 @@
# Documentation makefile
MAINTAINERCLEANFILES= Makefile.in
-171
View File
@@ -1,171 +0,0 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# Documentation makefile
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
CC = @CC@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
MAINTAINERCLEANFILES = Makefile.in
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps doc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = doc
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
mostlyclean-am: mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
-1
View File
@@ -1 +0,0 @@
./" bcmath library documentation
-238
View File
@@ -1,238 +0,0 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
tranformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
-134
View File
@@ -1,134 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
# 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, 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; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison touch file \`y.tab.c'
makeinfo touch the output file
yacc touch file \`y.tab.c'"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing - GNU libit 0.0"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. It should be needed only if
you modified \`acinclude.m4' or \`configure.in'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. It should be needed only if
you modified \`configure.in'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. It should be needed only if
you modified \`acconfig.h' or \`configure.in'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
touch config.h.in
;;
automake)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. It should be needed only if
you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print \
| sed 's/^\(.*\).am$/touch \1.in/' \
| sh
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. It should be needed only if
your modified any \`.y' file. For being effective, your
modifications might require the \`Bison' package. Grab it from
any GNU archive site."
touch y.tab.c
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. It should be needed only if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
-36
View File
@@ -1,36 +0,0 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Last modified: 1994-03-25
# Public domain
errstatus=0
for file in ${1+"$@"} ; do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d in ${1+"$@"} ; do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
fi
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here
-21
View File
@@ -1,21 +0,0 @@
# Makefile for bcmath library
lib_LIBRARIES = libbcmath.a
include_HEADERS = bcmath.h
libbcmath_a_SOURCES= add.c compare.c debug.c div.c divmod.c doaddsub.c \
init.c int2num.c nearzero.c neg.c num2long.c num2str.c output.c \
raise.c raisemod.c recmul.c rmzero.c sqrt.c str2num.c sub.c zero.c \
outofmem.c rt.c
INCLUDES = -I$(srcdir) -I..
CFLAGS = @CFLAGS@ $(INCLUDES) -Wall
MAINTAINERCLEANFILES= Makefile.in $(libbcmath_a_SOURCES) private.h bcmath.h
all: $(bin_LIBRARIES)
clean:
rm -f $(OBJS) $(LIB) *~
-7
View File
@@ -1,7 +0,0 @@
LTLIBRARY_NAME = libbcmath.la
LTLIBRARY_SOURCES = add.c div.c init.c neg.c outofmem.c raisemod.c rt.c sub.c \
compare.c divmod.c int2num.c num2long.c output.c recmul.c \
sqrt.c zero.c debug.c doaddsub.c nearzero.c num2str.c raise.c \
rmzero.c str2num.c
include $(top_srcdir)/build/dynlib.mk
-88
View File
@@ -1,88 +0,0 @@
/* add.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Here is the full add routine that takes care of negative numbers.
N1 is added to N2 and the result placed into RESULT. SCALE_MIN
is the minimum scale for the result. */
void
bc_add (n1, n2, result, scale_min)
bc_num n1, n2, *result;
int scale_min;
{
bc_num sum = NULL;
int cmp_res;
int res_scale;
if (n1->n_sign == n2->n_sign)
{
sum = _bc_do_add (n1, n2, scale_min);
sum->n_sign = n1->n_sign;
}
else
{
/* subtraction must be done. */
cmp_res = _bc_do_compare (n1, n2, FALSE, FALSE); /* Compare magnitudes. */
switch (cmp_res)
{
case -1:
/* n1 is less than n2, subtract n1 from n2. */
sum = _bc_do_sub (n2, n1, scale_min);
sum->n_sign = n2->n_sign;
break;
case 0:
/* They are equal! return zero with the correct scale! */
res_scale = MAX (scale_min, MAX(n1->n_scale, n2->n_scale));
sum = bc_new_num (1, res_scale);
memset (sum->n_value, 0, res_scale+1);
break;
case 1:
/* n2 is less than n1, subtract n2 from n1. */
sum = _bc_do_sub (n1, n2, scale_min);
sum->n_sign = n1->n_sign;
}
}
/* Clean up and return. */
bc_free_num (result);
*result = sum;
}
-158
View File
@@ -1,158 +0,0 @@
/* bcmath.h: bcmath library header. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#ifndef _BCMATH_H_
#define _BCMATH_H_
typedef enum {PLUS, MINUS} sign;
typedef struct bc_struct *bc_num;
typedef struct bc_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. */
bc_num n_next; /* Linked list for available list. */
char *n_ptr; /* The pointer to the actual storage.
If NULL, n_value points to the inside of
another number (bc_multiply...) and should
not be "freed." */
char *n_value; /* The number. Not zero char terminated.
May not point to the same place as n_ptr as
in the case of leading zeros generated. */
} bc_struct;
/* 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')
#ifdef MIN
#undef MIN
#undef MAX
#endif
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)>(b)?(b):(a))
#define ODD(a) ((a)&1)
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#ifndef LONG_MAX
#define LONG_MAX 0x7ffffff
#endif
/* Global numbers. */
extern bc_num _zero_;
extern bc_num _one_;
extern bc_num _two_;
/* Function Prototypes */
/* Define the _PROTOTYPE macro if it is needed. */
#ifndef _PROTOTYPE
#ifdef __STDC__
#define _PROTOTYPE(func, args) func args
#else
#define _PROTOTYPE(func, args) func()
#endif
#endif
_PROTOTYPE(void bc_init_numbers, (void));
_PROTOTYPE(bc_num bc_new_num, (int length, int scale));
_PROTOTYPE(void bc_free_num, (bc_num *num));
_PROTOTYPE(bc_num bc_copy_num, (bc_num num));
_PROTOTYPE(void bc_init_num, (bc_num *num));
_PROTOTYPE(void bc_str2num, (bc_num *num, char *str, int scale));
_PROTOTYPE(char *bc_num2str, (bc_num num));
_PROTOTYPE(void bc_int2num, (bc_num *num, int val));
_PROTOTYPE(long bc_num2long, (bc_num num));
_PROTOTYPE(int bc_compare, (bc_num n1, bc_num n2));
_PROTOTYPE(char bc_is_zero, (bc_num num));
_PROTOTYPE(char bc_is_near_zero, (bc_num num, int scale));
_PROTOTYPE(char bc_is_neg, (bc_num num));
_PROTOTYPE(void bc_add, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
_PROTOTYPE(void bc_sub, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale));
_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale));
_PROTOTYPE(int bc_modulo, (bc_num num1, bc_num num2, bc_num *result,
int scale));
_PROTOTYPE(int bc_divmod, (bc_num num1, bc_num num2, bc_num *quot,
bc_num *rem, int scale));
_PROTOTYPE(int bc_raisemod, (bc_num base, bc_num expo, bc_num mod,
bc_num *result, int scale));
_PROTOTYPE(void bc_raise, (bc_num num1, bc_num num2, bc_num *result,
int scale));
_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale));
_PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int),
int leading_zero));
/* Prototypes needed for external utility routines. */
_PROTOTYPE(void bc_rt_warn, (char *mesg ,...));
_PROTOTYPE(void bc_rt_error, (char *mesg ,...));
_PROTOTYPE(void bc_out_of_memory, (void));
#endif
-161
View File
@@ -1,161 +0,0 @@
/* compare.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Compare two bc numbers. Return value is 0 if equal, -1 if N1 is less
than N2 and +1 if N1 is greater than N2. If USE_SIGN is false, just
compare the magnitudes. */
int
_bc_do_compare (n1, n2, use_sign, ignore_last)
bc_num n1, n2;
int use_sign;
int ignore_last;
{
char *n1ptr, *n2ptr;
int count;
/* First, compare signs. */
if (use_sign && n1->n_sign != n2->n_sign)
{
if (n1->n_sign == PLUS)
return (1); /* Positive N1 > Negative N2 */
else
return (-1); /* Negative N1 < Positive N1 */
}
/* Now compare the magnitude. */
if (n1->n_len != n2->n_len)
{
if (n1->n_len > n2->n_len)
{
/* Magnitude of n1 > n2. */
if (!use_sign || n1->n_sign == PLUS)
return (1);
else
return (-1);
}
else
{
/* Magnitude of n1 < n2. */
if (!use_sign || n1->n_sign == PLUS)
return (-1);
else
return (1);
}
}
/* If we get here, they have the same number of integer digits.
check the integer part and the equal length part of the fraction. */
count = n1->n_len + MIN (n1->n_scale, n2->n_scale);
n1ptr = n1->n_value;
n2ptr = n2->n_value;
while ((count > 0) && (*n1ptr == *n2ptr))
{
n1ptr++;
n2ptr++;
count--;
}
if (ignore_last && count == 1 && n1->n_scale == n2->n_scale)
return (0);
if (count != 0)
{
if (*n1ptr > *n2ptr)
{
/* Magnitude of n1 > n2. */
if (!use_sign || n1->n_sign == PLUS)
return (1);
else
return (-1);
}
else
{
/* Magnitude of n1 < n2. */
if (!use_sign || n1->n_sign == PLUS)
return (-1);
else
return (1);
}
}
/* They are equal up to the last part of the equal part of the fraction. */
if (n1->n_scale != n2->n_scale)
{
if (n1->n_scale > n2->n_scale)
{
for (count = n1->n_scale-n2->n_scale; count>0; count--)
if (*n1ptr++ != 0)
{
/* Magnitude of n1 > n2. */
if (!use_sign || n1->n_sign == PLUS)
return (1);
else
return (-1);
}
}
else
{
for (count = n2->n_scale-n1->n_scale; count>0; count--)
if (*n2ptr++ != 0)
{
/* Magnitude of n1 < n2. */
if (!use_sign || n1->n_sign == PLUS)
return (-1);
else
return (1);
}
}
}
/* They must be equal! */
return (0);
}
/* This is the "user callable" routine to compare numbers N1 and N2. */
int
bc_compare (n1, n2)
bc_num n1, n2;
{
return _bc_do_compare (n1, n2, TRUE, FALSE);
}
-9
View File
@@ -1,9 +0,0 @@
#if PHP_WIN32
#include "../../../../main/config.w32.h"
#else
#include "php_config.h"
#endif
#include <string.h>
#include "zend.h"
#include "zend_alloc.h"
-70
View File
@@ -1,70 +0,0 @@
/* debug.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* pn prints the number NUM in base 10. */
static void
out_char (int c)
{
putchar(c);
}
void
pn (num)
bc_num num;
{
bc_out_num (num, 10, out_char, 0);
out_char ('\n');
}
/* pv prints a character array as if it was a string of bcd digits. */
void
pv (name, num, len)
char *name;
unsigned char *num;
int len;
{
int i;
printf ("%s=", name);
for (i=0; i<len; i++) printf ("%c",BCD_CHAR(num[i]));
printf ("\n");
}
-276
View File
@@ -1,276 +0,0 @@
/* div.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Some utility routines for the divide: First a one digit multiply.
NUM (with SIZE digits) is multiplied by DIGIT and the result is
placed into RESULT. It is written so that NUM and RESULT can be
the same pointers. */
static void
_one_mult (num, size, digit, result)
unsigned char *num;
int size, digit;
unsigned char *result;
{
int carry, value;
unsigned char *nptr, *rptr;
if (digit == 0)
memset (result, 0, size);
else
{
if (digit == 1)
memcpy (result, num, size);
else
{
/* Initialize */
nptr = (unsigned char *) (num+size-1);
rptr = (unsigned char *) (result+size-1);
carry = 0;
while (size-- > 0)
{
value = *nptr-- * digit + carry;
*rptr-- = value % BASE;
carry = value / BASE;
}
if (carry != 0) *rptr = carry;
}
}
}
/* The full division routine. This computes N1 / N2. It returns
0 if the division is ok and the result is in QUOT. The number of
digits after the decimal point is SCALE. It returns -1 if division
by zero is tried. The algorithm is found in Knuth Vol 2. p237. */
int
bc_divide (n1, n2, quot, scale)
bc_num n1, n2, *quot;
int scale;
{
bc_num qval;
unsigned char *num1, *num2;
unsigned char *ptr1, *ptr2, *n2ptr, *qptr;
int scale1, val;
unsigned int len1, len2, scale2, qdigits, extra, count;
unsigned int qdig, qguess, borrow, carry;
unsigned char *mval;
char zero;
unsigned int norm;
/* Test for divide by zero. */
if (bc_is_zero (n2)) return -1;
/* Test for divide by 1. If it is we must truncate. */
if (n2->n_scale == 0)
{
if (n2->n_len == 1 && *n2->n_value == 1)
{
qval = bc_new_num (n1->n_len, scale);
qval->n_sign = (n1->n_sign == n2->n_sign ? PLUS : MINUS);
memset (&qval->n_value[n1->n_len],0,scale);
memcpy (qval->n_value, n1->n_value,
n1->n_len + MIN(n1->n_scale,scale));
bc_free_num (quot);
*quot = qval;
}
}
/* Set up the divide. Move the decimal point on n1 by n2's scale.
Remember, zeros on the end of num2 are wasted effort for dividing. */
scale2 = n2->n_scale;
n2ptr = (unsigned char *) n2->n_value+n2->n_len+scale2-1;
while ((scale2 > 0) && (*n2ptr-- == 0)) scale2--;
len1 = n1->n_len + scale2;
scale1 = n1->n_scale - scale2;
if (scale1 < scale)
extra = scale - scale1;
else
extra = 0;
num1 = (unsigned char *) emalloc (n1->n_len+n1->n_scale+extra+2);
if (num1 == NULL) bc_out_of_memory();
memset (num1, 0, n1->n_len+n1->n_scale+extra+2);
memcpy (num1+1, n1->n_value, n1->n_len+n1->n_scale);
len2 = n2->n_len + scale2;
num2 = (unsigned char *) emalloc (len2+1);
if (num2 == NULL) bc_out_of_memory();
memcpy (num2, n2->n_value, len2);
*(num2+len2) = 0;
n2ptr = num2;
while (*n2ptr == 0)
{
n2ptr++;
len2--;
}
/* Calculate the number of quotient digits. */
if (len2 > len1+scale)
{
qdigits = scale+1;
zero = TRUE;
}
else
{
zero = FALSE;
if (len2>len1)
qdigits = scale+1; /* One for the zero integer part. */
else
qdigits = len1-len2+scale+1;
}
/* Allocate and zero the storage for the quotient. */
qval = bc_new_num (qdigits-scale,scale);
memset (qval->n_value, 0, qdigits);
/* Allocate storage for the temporary storage mval. */
mval = (unsigned char *) emalloc (len2+1);
if (mval == NULL) bc_out_of_memory ();
/* Now for the full divide algorithm. */
if (!zero)
{
/* Normalize */
norm = 10 / ((int)*n2ptr + 1);
if (norm != 1)
{
_one_mult (num1, len1+scale1+extra+1, norm, num1);
_one_mult (n2ptr, len2, norm, n2ptr);
}
/* Initialize divide loop. */
qdig = 0;
if (len2 > len1)
qptr = (unsigned char *) qval->n_value+len2-len1;
else
qptr = (unsigned char *) qval->n_value;
/* Loop */
while (qdig <= len1+scale-len2)
{
/* Calculate the quotient digit guess. */
if (*n2ptr == num1[qdig])
qguess = 9;
else
qguess = (num1[qdig]*10 + num1[qdig+1]) / *n2ptr;
/* Test qguess. */
if (n2ptr[1]*qguess >
(num1[qdig]*10 + num1[qdig+1] - *n2ptr*qguess)*10
+ num1[qdig+2])
{
qguess--;
/* And again. */
if (n2ptr[1]*qguess >
(num1[qdig]*10 + num1[qdig+1] - *n2ptr*qguess)*10
+ num1[qdig+2])
qguess--;
}
/* Multiply and subtract. */
borrow = 0;
if (qguess != 0)
{
*mval = 0;
_one_mult (n2ptr, len2, qguess, mval+1);
ptr1 = (unsigned char *) num1+qdig+len2;
ptr2 = (unsigned char *) mval+len2;
for (count = 0; count < len2+1; count++)
{
val = (int) *ptr1 - (int) *ptr2-- - borrow;
if (val < 0)
{
val += 10;
borrow = 1;
}
else
borrow = 0;
*ptr1-- = val;
}
}
/* Test for negative result. */
if (borrow == 1)
{
qguess--;
ptr1 = (unsigned char *) num1+qdig+len2;
ptr2 = (unsigned char *) n2ptr+len2-1;
carry = 0;
for (count = 0; count < len2; count++)
{
val = (int) *ptr1 + (int) *ptr2-- + carry;
if (val > 9)
{
val -= 10;
carry = 1;
}
else
carry = 0;
*ptr1-- = val;
}
if (carry == 1) *ptr1 = (*ptr1 + 1) % 10;
}
/* We now know the quotient digit. */
*qptr++ = qguess;
qdig++;
}
}
/* Clean up and return the number. */
qval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS );
if (bc_is_zero (qval)) qval->n_sign = PLUS;
_bc_rm_leading_zeros (qval);
bc_free_num (quot);
*quot = qval;
/* Clean up temporary storage. */
efree (mval);
efree (num1);
efree (num2);
return 0; /* Everything is OK. */
}
-91
View File
@@ -1,91 +0,0 @@
/* divmod.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Division *and* modulo for numbers. This computes both NUM1 / NUM2 and
NUM1 % NUM2 and puts the results in QUOT and REM, except that if QUOT
is NULL then that store will be omitted.
*/
int
bc_divmod (num1, num2, quot, rem, scale)
bc_num num1, num2, *quot, *rem;
int scale;
{
bc_num quotient = NULL;
bc_num temp;
int rscale;
/* Check for correct numbers. */
if (bc_is_zero (num2)) return -1;
/* Calculate final scale. */
rscale = MAX (num1->n_scale, num2->n_scale+scale);
bc_init_num(&temp);
/* Calculate it. */
bc_divide (num1, num2, &temp, scale);
if (quot)
quotient = bc_copy_num (temp);
bc_multiply (temp, num2, &temp, rscale);
bc_sub (num1, temp, rem, rscale);
bc_free_num (&temp);
if (quot)
{
bc_free_num (quot);
*quot = quotient;
}
return 0; /* Everything is OK. */
}
/* Modulo for numbers. This computes NUM1 % NUM2 and puts the
result in RESULT. */
int
bc_modulo (num1, num2, result, scale)
bc_num num1, num2, *result;
int scale;
{
return bc_divmod (num1, num2, NULL, result, scale);
}
-232
View File
@@ -1,232 +0,0 @@
/* doaddsub.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Perform addition: N1 is added to N2 and the value is
returned. The signs of N1 and N2 are ignored.
SCALE_MIN is to set the minimum scale of the result. */
bc_num
_bc_do_add (n1, n2, scale_min)
bc_num n1, n2;
int scale_min;
{
bc_num sum;
int sum_scale, sum_digits;
char *n1ptr, *n2ptr, *sumptr;
int carry, n1bytes, n2bytes;
int count;
/* Prepare sum. */
sum_scale = MAX (n1->n_scale, n2->n_scale);
sum_digits = MAX (n1->n_len, n2->n_len) + 1;
sum = bc_new_num (sum_digits, MAX(sum_scale, scale_min));
/* Zero extra digits made by scale_min. */
if (scale_min > sum_scale)
{
sumptr = (char *) (sum->n_value + sum_scale + sum_digits);
for (count = scale_min - sum_scale; count > 0; count--)
*sumptr++ = 0;
}
/* Start with the fraction part. Initialize the pointers. */
n1bytes = n1->n_scale;
n2bytes = n2->n_scale;
n1ptr = (char *) (n1->n_value + n1->n_len + n1bytes - 1);
n2ptr = (char *) (n2->n_value + n2->n_len + n2bytes - 1);
sumptr = (char *) (sum->n_value + sum_scale + sum_digits - 1);
/* Add the fraction part. First copy the longer fraction.*/
if (n1bytes != n2bytes)
{
if (n1bytes > n2bytes)
while (n1bytes>n2bytes)
{ *sumptr-- = *n1ptr--; n1bytes--;}
else
while (n2bytes>n1bytes)
{ *sumptr-- = *n2ptr--; n2bytes--;}
}
/* Now add the remaining fraction part and equal size integer parts. */
n1bytes += n1->n_len;
n2bytes += n2->n_len;
carry = 0;
while ((n1bytes > 0) && (n2bytes > 0))
{
*sumptr = *n1ptr-- + *n2ptr-- + carry;
if (*sumptr > (BASE-1))
{
carry = 1;
*sumptr -= BASE;
}
else
carry = 0;
sumptr--;
n1bytes--;
n2bytes--;
}
/* Now add carry the longer integer part. */
if (n1bytes == 0)
{ n1bytes = n2bytes; n1ptr = n2ptr; }
while (n1bytes-- > 0)
{
*sumptr = *n1ptr-- + carry;
if (*sumptr > (BASE-1))
{
carry = 1;
*sumptr -= BASE;
}
else
carry = 0;
sumptr--;
}
/* Set final carry. */
if (carry == 1)
*sumptr += 1;
/* Adjust sum and return. */
_bc_rm_leading_zeros (sum);
return sum;
}
/* Perform subtraction: N2 is subtracted from N1 and the value is
returned. The signs of N1 and N2 are ignored. Also, N1 is
assumed to be larger than N2. SCALE_MIN is the minimum scale
of the result. */
bc_num
_bc_do_sub (n1, n2, scale_min)
bc_num n1, n2;
int scale_min;
{
bc_num diff;
int diff_scale, diff_len;
int min_scale, min_len;
char *n1ptr, *n2ptr, *diffptr;
int borrow, count, val;
/* Allocate temporary storage. */
diff_len = MAX (n1->n_len, n2->n_len);
diff_scale = MAX (n1->n_scale, n2->n_scale);
min_len = MIN (n1->n_len, n2->n_len);
min_scale = MIN (n1->n_scale, n2->n_scale);
diff = bc_new_num (diff_len, MAX(diff_scale, scale_min));
/* Zero extra digits made by scale_min. */
if (scale_min > diff_scale)
{
diffptr = (char *) (diff->n_value + diff_len + diff_scale);
for (count = scale_min - diff_scale; count > 0; count--)
*diffptr++ = 0;
}
/* Initialize the subtract. */
n1ptr = (char *) (n1->n_value + n1->n_len + n1->n_scale -1);
n2ptr = (char *) (n2->n_value + n2->n_len + n2->n_scale -1);
diffptr = (char *) (diff->n_value + diff_len + diff_scale -1);
/* Subtract the numbers. */
borrow = 0;
/* Take care of the longer scaled number. */
if (n1->n_scale != min_scale)
{
/* n1 has the longer scale */
for (count = n1->n_scale - min_scale; count > 0; count--)
*diffptr-- = *n1ptr--;
}
else
{
/* n2 has the longer scale */
for (count = n2->n_scale - min_scale; count > 0; count--)
{
val = - *n2ptr-- - borrow;
if (val < 0)
{
val += BASE;
borrow = 1;
}
else
borrow = 0;
*diffptr-- = val;
}
}
/* Now do the equal length scale and integer parts. */
for (count = 0; count < min_len + min_scale; count++)
{
val = *n1ptr-- - *n2ptr-- - borrow;
if (val < 0)
{
val += BASE;
borrow = 1;
}
else
borrow = 0;
*diffptr-- = val;
}
/* If n1 has more digits then n2, we now do that subtract. */
if (diff_len != min_len)
{
for (count = diff_len - min_len; count > 0; count--)
{
val = *n1ptr-- - borrow;
if (val < 0)
{
val += BASE;
borrow = 1;
}
else
borrow = 0;
*diffptr-- = val;
}
}
/* Clean up and return. */
_bc_rm_leading_zeros (diff);
return diff;
}
-135
View File
@@ -1,135 +0,0 @@
/* init.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Storage used for special numbers. */
bc_num _zero_;
bc_num _one_;
bc_num _two_;
bc_num _bc_Free_list = NULL;
/* new_num allocates a number and sets fields to known values. */
bc_num
bc_new_num (length, scale)
int length, scale;
{
bc_num temp;
/* PHP Change: malloc() -> emalloc(), removed free_list code */
temp = (bc_num) emalloc (sizeof(bc_struct)+length+scale);
#if 0
if (_bc_Free_list != NULL) {
temp = _bc_Free_list;
_bc_Free_list = temp->n_next;
} else {
temp = (bc_num) emalloc (sizeof(bc_struct));
if (temp == NULL) bc_out_of_memory ();
}
#endif
temp->n_sign = PLUS;
temp->n_len = length;
temp->n_scale = scale;
temp->n_refs = 1;
/* PHP Change: malloc() -> emalloc() */
temp->n_ptr = (char *) emalloc (length+scale);
if (temp->n_ptr == NULL) bc_out_of_memory();
temp->n_value = temp->n_ptr;
memset (temp->n_ptr, 0, length+scale);
return temp;
}
/* "Frees" a bc_num NUM. Actually decreases reference count and only
frees the storage if reference count is zero. */
void
bc_free_num (num)
bc_num *num;
{
if (*num == NULL) return;
(*num)->n_refs--;
if ((*num)->n_refs == 0) {
if ((*num)->n_ptr)
/* PHP Change: free() -> efree(), removed free_list code */
efree ((*num)->n_ptr);
efree(*num);
#if 0
(*num)->n_next = _bc_Free_list;
_bc_Free_list = *num;
#endif
}
*num = NULL;
}
/* Intitialize the number package! */
void
bc_init_numbers ()
{
_zero_ = bc_new_num (1,0);
_one_ = bc_new_num (1,0);
_one_->n_value[0] = 1;
_two_ = bc_new_num (1,0);
_two_->n_value[0] = 2;
}
/* Make a copy of a number! Just increments the reference count! */
bc_num
bc_copy_num (num)
bc_num num;
{
num->n_refs++;
return num;
}
/* Initialize a number NUM by making it a copy of zero. */
void
bc_init_num (num)
bc_num *num;
{
*num = bc_copy_num (_zero_);
}
-84
View File
@@ -1,84 +0,0 @@
/* int2num.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Convert an integer VAL to a bc number NUM. */
void
bc_int2num (num, val)
bc_num *num;
int val;
{
char buffer[30];
char *bptr, *vptr;
int ix = 1;
char neg = 0;
/* Sign. */
if (val < 0)
{
neg = 1;
val = -val;
}
/* Get things going. */
bptr = buffer;
*bptr++ = val % BASE;
val = val / BASE;
/* Extract remaining digits. */
while (val != 0)
{
*bptr++ = val % BASE;
val = val / BASE;
ix++; /* Count the digits. */
}
/* Make the number. */
bc_free_num (num);
*num = bc_new_num (ix, 0);
if (neg) (*num)->n_sign = MINUS;
/* Assign the digits. */
vptr = (*num)->n_value;
while (ix-- > 0)
*vptr++ = *--bptr;
}
-69
View File
@@ -1,69 +0,0 @@
/* nearzero.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* In some places we need to check if the number NUM is almost zero.
Specifically, all but the last digit is 0 and the last digit is 1.
Last digit is defined by scale. */
char
bc_is_near_zero (num, scale)
bc_num num;
int scale;
{
int count;
char *nptr;
/* Error checking */
if (scale > num->n_scale)
scale = num->n_scale;
/* Initialize */
count = num->n_len + scale;
nptr = num->n_value;
/* The check */
while ((count > 0) && (*nptr++ == 0)) count--;
if (count != 0 && (count != 1 || *--nptr != 1))
return FALSE;
else
return TRUE;
}
-49
View File
@@ -1,49 +0,0 @@
/* neg.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* In some places we need to check if the number is negative. */
char
bc_is_neg (num)
bc_num num;
{
return num->n_sign == MINUS;
}
-70
View File
@@ -1,70 +0,0 @@
/* num2long.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Convert a number NUM to a long. The function returns only the integer
part of the number. For numbers that are too large to represent as
a long, this function returns a zero. This can be detected by checking
the NUM for zero after having a zero returned. */
long
bc_num2long (num)
bc_num num;
{
long val;
char *nptr;
int index;
/* Extract the int value, ignore the fraction. */
val = 0;
nptr = num->n_value;
for (index=num->n_len; (index>0) && (val<=(LONG_MAX/BASE)); index--)
val = val*BASE + *nptr++;
/* Check for overflow. If overflow, return zero. */
if (index>0) val = 0;
if (val < 0) val = 0;
/* Return the value. */
if (num->n_sign == PLUS)
return (val);
else
return (-val);
}
-79
View File
@@ -1,79 +0,0 @@
/* num2str.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
/* Convert a numbers to a string. Base 10 only.*/
char
*bc_num2str (num)
bc_num num;
{
char *str, *sptr;
char *nptr;
int index, signch;
/* Allocate the string memory. */
signch = ( num->n_sign == PLUS ? 0 : 1 ); /* Number of sign chars. */
if (num->n_scale > 0)
str = (char *) emalloc (num->n_len + num->n_scale + 2 + signch);
else
str = (char *) emalloc (num->n_len + 1 + signch);
if (str == NULL) bc_out_of_memory();
/* The negative sign if needed. */
sptr = str;
if (signch) *sptr++ = '-';
/* Load the whole number. */
nptr = num->n_value;
for (index=num->n_len; index>0; index--)
*sptr++ = BCD_CHAR(*nptr++);
/* Now the fraction. */
if (num->n_scale > 0)
{
*sptr++ = '.';
for (index=0; index<num->n_scale; index++)
*sptr++ = BCD_CHAR(*nptr++);
}
/* Terminate the string and return it! */
*sptr = '\0';
return (str);
}
-46
View File
@@ -1,46 +0,0 @@
/* outofmem.c: bcmath library file. */
/*
Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 2000 Philip A. Nelson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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
Lesser General Public License for more details. (COPYING.LIB)
You should have received a copy of the GNU Lesser 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.
You may contact the author by:
e-mail: philnelson@acm.org
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"
void bc_out_of_memory (void)
{
(void) fprintf (stderr, "bcmath: out of memory!\n");
exit (1);
}
Loaded 100 of 605 files, more files were not shown because too many files have changed in this diff. Show more