iliaa Mon Feb 10 17:26:53 2003 EDT Modified files: /php4/ext/standard file.c file.h Log: Merged the flags for the file() function into a single flag. Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.300 php4/ext/standard/file.c:1.301 --- php4/ext/standard/file.c:1.300 Sun Feb 9 18:11:23 2003 +++ php4/ext/standard/file.c Mon Feb 10 17:26:53 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.300 2003/02/09 23:11:23 wez Exp $ */ +/* $Id: file.c,v 1.301 2003/02/10 22:26:53 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -180,6 +180,10 @@ REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_INFO", PHP_STREAM_NOTIFY_SEVERITY_INFO, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_WARN", PHP_STREAM_NOTIFY_SEVERITY_WARN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_ERR", PHP_STREAM_NOTIFY_SEVERITY_ERR, CONST_CS | CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("FILE_USE_INCLUDE_PATH", PHP_FILE_USE_INCLUDE_PATH, +CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FILE_IGNORE_NEW_LINES", PHP_FILE_IGNORE_NEW_LINES, +CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FILE_SKIP_EMPTY_LINES", PHP_FILE_SKIP_EMPTY_LINES, +CONST_CS | CONST_PERSISTENT); #ifdef HAVE_FNMATCH REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_CS | CONST_PERSISTENT); @@ -444,7 +448,7 @@ } /* }}} */ -/* {{{ proto array file(string filename [, bool use_include_path [, bool include_new_line [, bool skip_blank_lines]]]) +/* {{{ proto array file(string filename [, int flags]) Read entire file into an array */ #define PHP_FILE_BUF_SIZE 80 @@ -457,20 +461,26 @@ register int i = 0; int target_len, len; char eol_marker = '\n'; - zend_bool use_include_path = 0; - zend_bool include_new_line = 1; - zend_bool skip_blank_lines = 0; + long flags = 0; + zend_bool use_include_path; + zend_bool include_new_line; + zend_bool skip_blank_lines; php_stream *stream; /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bbb", - &filename, &filename_len, &use_include_path, &include_new_line, &skip_blank_lines) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, +&filename_len, &flags) == FAILURE) { return; } + if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | +PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%l' flag is not +supported.", flags); + RETURN_FALSE; + } + + use_include_path = flags & PHP_FILE_USE_INCLUDE_PATH; + include_new_line = !(flags & PHP_FILE_IGNORE_NEW_LINES); + skip_blank_lines = flags & PHP_FILE_SKIP_EMPTY_LINES; - stream = php_stream_open_wrapper(filename, "rb", - (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, - NULL); + stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH +: 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); if (!stream) { RETURN_FALSE; } Index: php4/ext/standard/file.h diff -u php4/ext/standard/file.h:1.74 php4/ext/standard/file.h:1.75 --- php4/ext/standard/file.h:1.74 Sun Feb 9 15:43:05 2003 +++ php4/ext/standard/file.h Mon Feb 10 17:26:53 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.h,v 1.74 2003/02/09 20:43:05 iliaa Exp $ */ +/* $Id: file.h,v 1.75 2003/02/10 22:26:53 iliaa Exp $ */ /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */ @@ -86,6 +86,10 @@ PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC); #define META_DEF_BUFSIZE 8192 + +#define PHP_FILE_USE_INCLUDE_PATH 1 +#define PHP_FILE_IGNORE_NEW_LINES 2 +#define PHP_FILE_SKIP_EMPTY_LINES 4 typedef enum _php_meta_tags_token { TOK_EOF = 0,
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php