From: Zeev Suraski Date: Sat, 26 Feb 2000 14:29:27 +0000 (+0000) Subject: @- The string None is now recognized as a keyword by the php.ini processor, and X-Git-Tag: PHP-4.0-RC1~396 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88b31ecb28c4d6497bbfdb66655b662e9da104a0;p=php @- The string None is now recognized as a keyword by the php.ini processor, and @ can be used to denote an empty string (Zeev) - Added None keyword support to the INI parser - Removed specialized "none" code --- diff --git a/main/SAPI.c b/main/SAPI.c index 885b95553d..e1be74d3a9 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -184,7 +184,7 @@ SAPI_API char *sapi_get_default_content_type(SLS_D) mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE; charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET; - if (strncasecmp(mimetype, "text/", 5) == 0 && strcasecmp(charset, "none") != 0) { + if (strncasecmp(mimetype, "text/", 5) == 0 && *charset) { int len = strlen(mimetype) + sizeof("; charset=") + strlen(charset); content_type = emalloc(len); snprintf(content_type, len, "%s; charset=%s", mimetype, charset); @@ -205,13 +205,12 @@ SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_h memcpy(default_header->header, "Content-type: ", sizeof("Content-type: ")); memcpy(default_header->header+sizeof("Content-type: ")-1, default_content_type, default_content_type_len); default_header->header[default_header->header_len] = 0; - efree(default_content_type); } /* * Add charset on content-type header if the MIME type starts with - * "text/", the default_charset directive is not set to "none" and + * "text/", the default_charset directive is not empty and * there is not already a charset option in there. * * If "mimetype" is non-NULL, it should point to a pointer allocated @@ -226,7 +225,7 @@ SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len SLS_DC) int newlen; charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET; - if (strcasecmp(charset, "none") != 0 && strncmp(*mimetype, "text/", 5) == 0 && strstr(*mimetype, "charset=") == NULL) { + if (*charset && strncmp(*mimetype, "text/", 5) == 0 && strstr(*mimetype, "charset=") == NULL) { newlen = len + (sizeof(";charset=")-1) + strlen(charset); newtype = emalloc(newlen + 1); strlcpy(newtype, *mimetype, len); diff --git a/main/configuration-scanner.l b/main/configuration-scanner.l index f059f0c06e..4467cb10f0 100644 --- a/main/configuration-scanner.l +++ b/main/configuration-scanner.l @@ -77,14 +77,13 @@ void init_cfg_scanner() } -[ ]*("false"|"off"|"no")[ ]* { +[ ]*("false"|"off"|"no"|"none")[ ]* { cfglval->value.str.val = zend_strndup("",0); cfglval->value.str.len = 0; cfglval->type = IS_STRING; return CFG_FALSE; } - [[][^[]+[\]]([\n]?|"\r\n"?) { /* SECTION */ diff --git a/main/main.c b/main/main.c index 9d141ef786..e21fa781ba 100644 --- a/main/main.c +++ b/main/main.c @@ -203,8 +203,8 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, auto_append_file, php_core_globals, core_globals) STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, auto_prepend_file, php_core_globals, core_globals) STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateStringUnempty, default_charset, sapi_globals_struct,sapi_globals) - STD_PHP_INI_ENTRY("default_mimetype",SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateStringUnempty, default_mimetype, sapi_globals_struct,sapi_globals) + STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, default_charset, sapi_globals_struct,sapi_globals) + STD_PHP_INI_ENTRY("default_mimetype",SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct,sapi_globals) STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateString, error_log, php_core_globals, core_globals) STD_PHP_INI_ENTRY("extension_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals) STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals) @@ -1103,8 +1103,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_ UpdateIniFromRegistry(primary_file->filename); #endif - if (PG(auto_prepend_file) && PG(auto_prepend_file)[0] && - strncmp(PG(auto_prepend_file), "none", 4) != 0) { + if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) { prepend_file.filename = PG(auto_prepend_file); prepend_file.free_filename = 0; prepend_file.type = ZEND_HANDLE_FILENAME; @@ -1112,8 +1111,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_ } else { prepend_file_p = NULL; } - if (PG(auto_append_file) && PG(auto_append_file)[0] && - strncmp(PG(auto_append_file), "none", 4) != 0) { + if (PG(auto_append_file) && PG(auto_append_file)[0]) { append_file.filename = PG(auto_append_file); append_file.free_filename = 0; append_file.type = ZEND_HANDLE_FILENAME; diff --git a/php.ini-dist b/php.ini-dist index 2c817081d0..d59d2f1f5a 100644 --- a/php.ini-dist +++ b/php.ini-dist @@ -21,7 +21,7 @@ ; Directive names are *case sensitive* - foo=bar is different from FOO=bar. ; ; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one -; of the INI constants (On, Off, True, False, Yes and No) or an expression +; of the INI constants (On, Off, True, False, Yes, No and None) or an expression ; (e.g. E_ALL & ~E_NOTICE), or a quoted string ("foo"). ; ; Expressions in the INI file are limited to bitwise operators and parentheses: @@ -32,6 +32,13 @@ ; Boolean flags can be turned on using the values 1, On, True or Yes. ; They can be turned off using the values 0, Off, False or No. ; +; An empty string can be denoted by simply not writing anything after the equal +; sign, or by using the None keyword: +; +; foo = ; sets foo to an empty string +; foo = none ; sets foo to an empty string +; foo = "none" ; sets foo to the string 'none' +; ; If you use constants in your value, and these constants belong to a dynamically ; loaded extension (either a PHP extension or a Zend extension), you may only ; use these constants *after* the line that loads the extension. @@ -184,11 +191,11 @@ auto_prepend_file = auto_append_file = ; As of 4.0b4, PHP always outputs a character encoding by default in -; the Content-type: header. Set default_charset to "none" to disable -; this. PHP's built-in default is text/html with the iso-8859-1 -; charset. -;default_mimetype = "text/html" -;default_charset = "iso-8859-1" +; the Content-type: header. To disable sending of the charset, simply +; set it to be empty. +; PHP's built-in default is text/html with the iso-8859-1 charset. +default_mimetype = "text/html" +default_charset = "iso-8859-1" ;;;;;;;;;;;;;;;;;;;;;;;;; ; Paths and Directories ;