Re: [PHP-DEV] Using CLI as a shell

2003-02-03 Thread gk
At 07:31 PM 2/3/2003 +0100, Marcus Börger wrote:

After adding -B, -F, -R and -E which will hopefully liked by the rest of 
development
team so that the stuff need not to be removed. I (or better a friend of 
mine) had another
idea. Here comes:

I am glad to hear someone else is interested in php.cli improvements.

I have written an extension to Gnu Make which enables using sapi/cli/php in 
a makefile environment with auto-detection of dependencies. See: 
http://www.xmake.org

I have previously posted twice on the subject of a -M switch (similar to 
gcc -M), for enabling proper use of sapi/cli/php in a makefile environment 
- I got no responses.

Here is the proposal:

* Add a '-M' option to sapi/cli/php that would behave essentially the same 
as gcc -M and enable the use of php command-line scripts to work properly 
in a makefile build environment (See below for explanation of gcc -M).

* 'php -M -f myFile.php' should differ from 'gcc -M myFile.c', in two ways:
a) Command output should only list prerequisite files rather than 
a complete dependency makefile rule since there is no standard suffix for 
php output as for C [ myFile.o : myFile.c ... ]
b) Detect dependencies other than included and required files, as 
reported by get_included_files(). There are many other ways that a PHP 
script could become dependent on other files which cannot easily be 
determined automatically unless a function is available for a script to 
explicitly declare that it depends on an external file. [Example: ? if 
(file_exists($myFile)) echo hello;?].

* Add two built-in PHP functions to allow '-M' option to accurately 
identify file dependencies in PHP source files (the names could change):
void register_prerequisite_file( string $myFile )
Array get_prerequisite_files( )

* With the above two functions, this is how the system should work:
In the following example, /usr/local/bin/php-cli is the command-line 
version of PHP: sapi/cli/php
- file: test.php
#!/usr/local/bin/php-cli
?
php include( myIncludedFile.php );
register_prerequisite_file( myRequiredFile)
if (file_exists( myRequiredFile )) echo got file;
?
 eof

Internally php-cli -M would call get_included_files() and 
get_prerequisite_files() and join them together in a space separated list, 
with the first item being the source file. Here is what php-cli would do 
from the command line:

$/usr/local/bin/php-cli -M -f test.php
test.php myIncludedFile.php myRequiredFile

---
# example makefile which implements the functionality without php -M

# Command for generating output files from source files
# the command-line version of php binary must be specified in: 
XME_php.cli_outfileCmd
# this is built under php_source_dir/sapi/cli/php
XME_php.cli_outfileCmd:=/usr/local/bin/php

# Command to generate a list of dependencies from a source file (including 
the source file)
# $(1) - source file
define XME_php.cli_dependCmd
$(shell $(XME_php.cli_outfileCmd) -r 'include $(1); $$tmpFile = 
$(XMAKE_TMP_DIR)/php.cli_dependCmd_out; if 
(function_exists('get_prerequisite_files')){ $$files = 
get_prerequisite_files();}else{$$files = get_included_files();} $$str = 
join( ,$$files); $$fp  = @fopen( $$tmpFile, w); fputs( $$fp, $$str );' 
1$(XMAKE_TMP_DIR)/php.cli_dependCmd_junk || { cat 
$(XMAKE_TMP_DIR)/php.cli_dependCmd_junk; exit 1; }; cat 
$(XMAKE_TMP_DIR)/php.cli_dependCmd_out; )
endef

# end of makefile


Below is what the include file looks like

?php
/*
These functions supporting php dependency makefile rule generation
This file would become obsolete if sapi/cli/php -M option is approved for 
inclusion in PHP

USAGE:
// paths to files must be ABSOLUTE paths, resolving any symbolic links
// assume your script uses a file 'file1', in the same directory as the 
script file
// $file1=realpath(file1) doesn't work since it returns false if the file 
doesn't exist
// since file1 may be created by XMake, we need the path whether or not it 
exists
// Try this:

require_once( getenv(XMAKE_HOME)./config/XMExtensions/php.cli.inc );
$filesArray=array( dirname(__FILE__).'/file1'  );
register_prerequisite_files( $filesArray );

*/

$XMAKE_PHP_PREREQUISITE_FILES=array();

function register_prerequisite_files( $filesArray ){
global $XMAKE_PHP_PREREQUISITE_FILES;
$XMAKE_PHP_PREREQUISITE_FILES = 
array_merge($XMAKE_PHP_PREREQUISITE_FILES, $filesArray);
}

function get_prerequisite_files(){
global $XMAKE_PHP_PREREQUISITE_FILES;
$filesArray = array_merge(get_included_files(), 
$XMAKE_PHP_PREREQUISITE_FILES);
return $filesArray;
}
?

- Greg Keraunen
http://www.xmake.org
http://www.xmlmake.com


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



[PHP-DEV] PROPOSAL: sapi/cli/php -M (similar to gcc -M)

2003-01-14 Thread gk
I have recenlty posted on this topic but got no response, probably because 
I didn't phrase it well.
I would like to implement this proposed feature if I can get some feedback 
to know if it would be accepted for inclusion.

Here is the proposal:

* Add a '-M' option to sapi/cli/php that would behave essentially the same 
as gcc -M and enable the use of php command-line scripts to work properly 
in a makefile build environment (See below for explanation of gcc -M).

* 'php -M -f myFile.php' should differ from 'gcc -M myFile.c', in two ways:
a) Command output should only list prerequisite files rather than 
a complete dependency makefile rule since there is no standard suffix for 
php output as for C [ myFile.o : myFile.c ... ]
b) Detect dependencies other than included and required files, as 
reported by get_included_files(). There are many other ways that a PHP 
script could become dependent on other files which cannot easily be 
determined automatically unless a function is available for a script to 
explicitly declare that it depends on an external file. [Example: ? if 
(file_exists($myFile)) echo hello;?].

* Add two built-in PHP functions to allow '-M' option to accurately 
identify file dependencies in PHP source files (the names could change):
void register_prerequisite_file( string $myFile )
Array get_prerequisite_files( )

* With the above two functions, this is how the system should work:
In the following example, /usr/local/bin/php-cli is the command-line 
version of PHP: sapi/cli/php
- file: test.php
#!/usr/local/bin/php-cli
?
php include( myIncludedFile.php );
register_prerequisite_file( myRequiredFile)
if (file_exists( myRequiredFile )) echo got file;
?
 eof

Internally php-cli -M would call get_included_files() and 
get_prerequisite_files() and join them together in a space separated list, 
with the first item being the source file. Here is what php-cli would do 
from the command line:

$/usr/local/bin/php-cli -M -f test.php
test.php myIncludedFile.php myRequiredFile

---
# A makefile rule could now use these features:

$(PHP):=/usr/local/bin/php-cli

define phpDependencies
$(shell $(PHP) -M -f $(1))
endef

myFile.html : $(call phpDependencies,myFile.php)
$(PHP) -f $  $@ || { echo failed; cat $@; exit 1; }
# end of makefile

-- APPENDIX - For those unfamiliar with gcc -M, following if 
from info gcc

`-M'
 Tell the preprocessor to output a rule suitable for `make'
 describing the dependencies of each object file.  For each source
 file, the preprocessor outputs one `make'-rule whose target is the
 object file name for that source file and whose dependencies are
 all the `#include' header files it uses.  This rule may be a
 single line or may be continued with `\'-newline if it is long.
 The list of rules is printed on standard output instead of the
 preprocessed C program.

 `-M' implies `-E'.

 Another way to specify output of a `make' rule is by setting the
 environment variable `DEPENDENCIES_OUTPUT' (*note Environment
 Variables::.).

`-E'
 Run only the C preprocessor.  Preprocess all the C source files
 specified and output the results to standard output or to the
 specified output file.




- Greg Keraunen
http://www.xmake.org
http://www.xmlmake.com


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



[PHP-DEV] register_prerequisite_file( $myFile ); //or cli option to generate dependency list

2003-01-11 Thread gk
I use php a lot to process php files in a makefile driven build environment 
I have written: xmake.org
I think it would be nice to have an option to sapi/cli to generate a list 
of dependencies, like gcc -M

get_included_files() is useful, but not sufficient since it only reports 
included or required files - any other dependencies are not detected, such 
as files opened by other means such as file(), file_exists(), 

I use the following macro in my makefile to generate a rule for the input 
source file $(1).

# Command to generate a list of dependencies from a source file (including 
the source file)
# $(1) - source file
define XMakeExt_php.cli_dependCmd
$(shell /usr/local/bin/php -r 'ob_start(); include $(1);ob_end_clean() ; 
$$files = get_included_files(); foreach($$files as $$file) echo $$file ;')
endef

I'd like to know what others think might be a good solution.
I see two options:
1. give sapi/cli an option to auto-detect dependencies
2. Add a simple a function you could call to register a prerequisite file 
such as:
?php
register_prerequisite_file( $myFile );
// code follows which uses the file for something...
$array=($myFile);
?

I think PHP is a great tool for command line scripting but without 
dependency-detection, applications are limited.

- Greg Keraunen
http://www.xmake.org
http://www.xmlmake.com


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



[PHP-DEV] when PHP code causes crash due to bad input, is it a bug?

2003-01-10 Thread gk
I am trying to help with PHP. But this experience makes me feel like it is 
not worth it.
Can anyone give me some clarification.
Is there a common agreement on what constitutes a bug?

I have worked as Sr. SQA engineer for many years and have always worked 
under the understanding that crashes are unacceptible - no matter what 
caused them: code should be able to handle bad data and not crash.

See my bug report and analysis by Daniel Veillard of libxml2 at:
http://bugs.php.net/bug.php?id=21477
- Greg

Date: Fri, 10 Jan 2003 11:50:35 -0800
To: [EMAIL PROTECTED]
From: gk [EMAIL PROTECTED]
Subject: Re: Bug #21477 [Opn-Bgs]: $node-dump_node($node) crashes with 
libxml2-2.4.30

At 06:54 PM 1/10/2003 +, you wrote:

You're not in position to decide what is bogus and what is not. This is
bogus.



- Greg Keraunen


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




[PHP-DEV] Bug #5842 Updated: Lost result (not printing all chars from table)

2001-05-14 Thread gk

ID: 5842
User Update by: [EMAIL PROTECTED]
Old-Status: Feedback
Status: Closed
Bug Type: Sybase (dblib) related
Operating system: Linux RH 6.2
PHP Version: 4.0.1pl2
Description: Lost result (not printing all chars from table)

This bug was closed some months ago

Previous Comments:
---

[2001-05-14 12:23:21] [EMAIL PROTECTED]
I could not verify this bug, but I don't have the Oracle stuff here.

As this is a fairly old bug, could you please test 4.0.5 or a snapshot and see if you 
still have the same problem?

---

[2000-07-28 20:03:22] [EMAIL PROTECTED]
sample script:
html
head
titleBug ?/title
/head
table border=0
trtd
any text over 15240 chars. Very important!
/td/tr
/table

?php
$conn = sybase_connect(SYBASE,user,user);
$baza = sybase_select_db(database,1);

$us_inf=sybase_query(SELECT id_user from users,1);
$nrow1=sybase_num_rows($us_inf);
$row=0;
while ($row  $nrow1){
// all data print properly, if comment next line
$data_u=sybase_fetch_array($us_inf);

// all data print properly, if comment next line
$id_user=$data_u[0];

$deb=sybase_query(SELECT id_user from users where id_user=1,1);

// all data print properly, if comment next line
$nrow2=sybase_num_rows($deb);

$row++;
}
?

configure line:
--with-apxs=/usr/local/apache/bin/apxs 
--with-oci8=/home/oracle/u01 
--with-sybase=/home/opt/sybase-11.9.2 
--enable-track-vars 
--enable-sigchild 

php.ini:
any php.ini file

decription:
Any data, printed in table lost, when I try to receive any 
data from Sybase.

---


Full Bug description available at: http://bugs.php.net/?id=5842


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]