]> granicus.if.org Git - php/commitdiff
@- Added -w option to the cgi-version. This will remove all comments and
authorThies C. Arntzen <thies@php.net>
Sat, 8 Dec 2001 12:27:01 +0000 (12:27 +0000)
committerThies C. Arntzen <thies@php.net>
Sat, 8 Dec 2001 12:27:01 +0000 (12:27 +0000)
@  whitespace from teh script. (Thies)

sapi/cgi/cgi_main.c

index 527cb0159e3fb7ba0cfd31094c0b3b6346eb4337..ca83c2fd705379868b53e900f1b794d71ad2e1a0 100644 (file)
 #define PHP_MODE_HIGHLIGHT     2
 #define PHP_MODE_INDENT                3
 #define PHP_MODE_LINT          4
+#define PHP_MODE_STRIP         5
 
 extern char *ap_php_optarg;
 extern int ap_php_optind;
 
-#define OPTSTRING "aCc:d:ef:g:hilmnqs?vz:"
+#define OPTSTRING "aCc:d:ef:g:hilmnqsw?vz:"
 
 static int _print_module_info(zend_module_entry *module, void *arg TSRMLS_DC)
 {
@@ -254,6 +255,7 @@ static void php_cgi_usage(char *argv0)
        php_printf("Usage: %s [-q] [-h] [-s [-v] [-i] [-f <file>] |  {<file> [args...]}\n"
                                "  -q             Quiet-mode.  Suppress HTTP Header output.\n"
                                "  -s             Display colour syntax highlighted source.\n"
+                               "  -w             Display source with stripped comments and whitespace.\n"
                                "  -f <file>      Parse <file>.  Implies `-q'\n"
                                "  -v             Version number\n"
                 "  -C             Do not chdir to the script's directory\n"
@@ -628,6 +630,10 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
                                                exit(1);
                                                break;
 
+                               case 'w': 
+                                               behavior=PHP_MODE_STRIP;
+                                               break;
+
                                case 'z': /* load extension file */
                                                zend_load_extension(ap_php_optarg);
                                                break;
@@ -755,6 +761,13 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
                                        zend_printf("Errors parsing %s\n", file_handle.filename);
                                }
                                break;
+                       case PHP_MODE_STRIP:
+                               if (open_file_for_scanning(&file_handle TSRMLS_CC)==SUCCESS) {
+                                       zend_strip(TSRMLS_C);
+                                       fclose(file_handle.handle.fp);
+                               }
+                               return SUCCESS;
+                               break;
                        case PHP_MODE_HIGHLIGHT:
                                {
                                        zend_syntax_highlighter_ini syntax_highlighter_ini;