]> granicus.if.org Git - php/commitdiff
@- The string None is now recognized as a keyword by the php.ini processor, and
authorZeev Suraski <zeev@php.net>
Sat, 26 Feb 2000 14:29:27 +0000 (14:29 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 26 Feb 2000 14:29:27 +0000 (14:29 +0000)
@  can be used to denote an empty string (Zeev)
- Added None keyword support to the INI parser
- Removed specialized "none" code

main/SAPI.c
main/configuration-scanner.l
main/main.c
php.ini-dist

index 885b95553d39c5463ef04b44455222c407d79a71..e1be74d3a9f729440832bd2bcb5b79a40dc51439 100644 (file)
@@ -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);
index f059f0c06e173e82634b549b2aec035518bf6dcd..4467cb10f078189ecec7bd16c9a3ea697dd86378 100644 (file)
@@ -77,14 +77,13 @@ void init_cfg_scanner()
 }
 
 
-<INITIAL>[ ]*("false"|"off"|"no")[ ]* {
+<INITIAL>[ ]*("false"|"off"|"no"|"none")[ ]* {
        cfglval->value.str.val = zend_strndup("",0);
        cfglval->value.str.len = 0;
        cfglval->type = IS_STRING;
        return CFG_FALSE;
 }
 
-
 <INITIAL>[[][^[]+[\]]([\n]?|"\r\n"?) {
        /* SECTION */
 
index 9d141ef786c53819474b5b471ae8a2f7812d0997..e21fa781ba149ed0f3ff989d58ba09d292b53b67 100644 (file)
@@ -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;
index 2c817081d05bc43b5e047dc93cf815788ea21abd..d59d2f1f5a8901b34370237b57fa827b664047e9 100644 (file)
@@ -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:
 ; 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 ;