gallu’s blog

エンジニアでゲーマーで講師で占い師なおいちゃんのブログです。

だめだ…

PHP、相変わらず色々とあってソースチェックとかしてるです。
………だめだ。この言語、まず確定で「未来永劫落ち着きません」モード全開。


ちょっと真面目に書くと。多分「ハッカーのおもちゃ」からスタートしたんじゃないかなぁ?
で、ソースコードの質もまた「実験的おもちゃ」のレベルのまんま進んじゃったイメージをうけるです。
むしろ「よくもまぁこんなコードで動いてるよ」って感じでしょうか。
以下実例。…C言語を真面目にやった諸氏は、あんまり見ないほうがいいかもしれないけど。

/usr/src/php-5.1.2/ext/date/lib/parse_date.c

yy0:
if((YYLIMIT - YYCURSOR) < 26) YYFILL(26);
yych = *YYCURSOR;
YYDEBUG(-1, yych);
switch(yych){
case 0x00: case 0x0A: goto yy48;
case ' ': goto yy45;
case '(': goto yy42;
case '+': case '-': goto yy41;
case ',': case '.': goto yy47;
case '0': goto yy13;
case '1': goto yy14;
case '2': goto yy15;
case '3': goto yy16;
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': goto yy17;
case '@': goto yy11;
case 'A': goto yy25;
case 'B':
case 'C': case 'G':
case 'H': case 'K': case 'Q':
case 'R': case 'U': case 'Z': goto yy43;
case 'D': goto yy31;
case 'E': goto yy35;
case 'F': goto yy23;
case 'I': goto yy18;
case 'J': goto yy21;
case 'L': goto yy37;
case 'M': goto yy7;
case 'N': goto yy5;
case 'O': goto yy29;
case 'P': goto yy39;
case 'S': goto yy27;
case 'T': goto yy9;
case 'V': goto yy19;
case 'W': goto yy33;
case 'X': goto yy20;
case 'Y': goto yy2;
case 'a': goto yy26;
case 'b':
case 'c': case 'g':
case 'h':
case 'i': case 'k': case 'q':
case 'r': case 'u':
case 'v': case 'x': case 'z': goto yy44;
case 'd': goto yy32;
case 'e': goto yy36;
case 'f': goto yy24;
case 'j': goto yy22;
case 'l': goto yy38;
case 'm': goto yy8;
case 'n': goto yy6;
case 'o': goto yy30;
case 'p': goto yy40;
case 's': goto yy28;
case 't': goto yy10;
case 'w': goto yy34;
case 'y': goto yy4;
default: goto yy50;
}
yy2:
YYDEBUG(2, *YYCURSOR);
++YYCURSOR;
if((yych = *YYCURSOR) <= 'E'){
if(yych <= ')'){
if(yych >= ')') goto yy132;
goto yy3;
} else {
if(yych <= '@') goto yy3;
if(yych <= 'D') goto yy133;
goto yy1283;
}
} else {
if(yych <= 'd'){
if(yych <= 'Z') goto yy133;
if(yych >= 'a') goto yy136;
goto yy3;
} else {
if(yych <= 'e') goto yy1292;
if(yych <= 'z') goto yy136;
goto yy3;
}
}
yy3:
YYDEBUG(3, *YYCURSOR);

{
int tz_not_found;
DEBUG_OUTPUT("tzcorrection | tz");
TIMELIB_INIT;
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_no
t_found, s->tzdb);
s->errors += tz_not_found;
TIMELIB_DEINIT;
return TIMELIB_TIMEZONE;
}
yy4:
YYDEBUG(4, *YYCURSOR);
yych = *++YYCURSOR;
if(yych <= 'E'){
if(yych <= ')'){
if(yych <= '(') goto yy3;
goto yy132;
} else {
if(yych <= '@') goto yy3;
if(yych <= 'D') goto yy133;
goto yy1283;
}
} else {
if(yych <= 'd'){
if(yych <= 'Z') goto yy133;
if(yych <= '`') goto yy3;
goto yy133;
} else {
if(yych <= 'e') goto yy1283;
if(yych <= 'z') goto yy133;
goto yy3;
}
}
-中略-

yy13:
YYDEBUG(13, *YYCURSOR);
yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
YYDEBUG(-1, yych);
switch(yych){
case ' ':
case '!':
case '"':
case '#':
case '$':
case '%':
case '&':
case '\'':
case '(':
case ')':
case '*':
case '+':
case ',': case 'A': case 'D': case 'F': case 'H':
case 'I':
case 'J': case 'M':
case 'N':
case 'O': case 'S':
case 'T': case 'V':
case 'W':
case 'X':
case 'Y': case 'a': case 'd': case 'f': case 'h': case 'j': case 'm': case 'o'

case 'w'
case 'y': goto yy1121;

case '-': goto yy615;
case '.': goto yy1123;
case '/': goto yy614;
case '0': goto yy1156;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': goto yy1155;
case ':': goto yy1124;
case 'n': goto yy612;
case 'r': goto yy613;
case 's': goto yy606;
case 't': goto yy610;
default: goto yy12;
}
yy14:
YYDEBUG(14, *YYCURSOR);
yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
YYDEBUG(-1, yych);
switch(yych){
case ' ':
case '!':
case '"':

/usr/src/php-5.1.2/main/main.c
(どこか適当に中略してるですが…場所がわからなくなりました(苦笑))

PHP_INI_BEGIN()
PHP_INI_ENTRY_EX("define_syslog_variables", "0", PHP_INI_ALL, NULL,
php_ini_boolean_displayer_cb)
PHP_INI_ENTRY_EX("highlight.bg", HL_BG_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
PHP_INI_ENTRY_EX("highlight.comment", HL_COMMENT_COLOR, PHP_INI_ALL, NULL,
php_ini_color_displayer_cb)
PHP_INI_ENTRY_EX("highlight.default", HL_DEFAULT_COLOR, PHP_INI_ALL, NULL,
php_ini_color_displayer_cb)
PHP_INI_ENTRY_EX("highlight.html", HL_HTML_COLOR, PHP_INI_ALL, NULL,
php_ini_color_displayer_cb)
PHP_INI_ENTRY_EX("highlight.keyword", HL_KEYWORD_COLOR, PHP_INI_ALL, NULL,
php_ini_color_displayer_cb)
PHP_INI_ENTRY_EX("highlight.string", HL_STRING_COLOR, PHP_INI_ALL, NULL,
php_ini_color_displayer_cb)

STD_PHP_INI_BOOLEAN("allow_call_time_pass_reference", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, allow_call_time_pass_reference, zend_compiler_globals, compiler_globals)
STD_PHP_INI_BOOLEAN("asp_tags", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, asp_tags, zend_compiler_globals, compiler_globals)
STD_PHP_INI_BOOLEAN("display_errors", "1", PHP_INI_ALL, OnUpdateBool, display_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("display_startup_errors", "0", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("docref_ext", "", PHP_INI_ALL, OnUpdateString, docref_ext, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("html_errors", "1", PHP_INI_ALL, OnUpdateBool, html_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("xmlrpc_errors", "0", PHP_INI_SYSTEM, OnUpdateBool, xmlrpc_errors, php_core_globals, core_globals)

STD_PHP_INI_ENTRY("max_input_time", "-1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateLong, max_input_time, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("ignore_user_abort", "0", PHP_INI_ALL, OnUpdateBool , ignore_user_abort, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("implicit_flush", "0", PHP_INI_ALL, OnUpdateBool, implicit_flush, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("log_errors", "0", PHP_INI_ALL, OnUpdateBool, log_errors, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("log_errors_max_len", "1024", PHP_INI_ALL, OnUpdateLong, log_errors_max_len, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("ignore_repeated_errors", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("ignore_repeated_source", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_source, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("report_memleaks", "1", PHP_INI_ALL, OnUpdateBool, report_memleaks, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("report_zend_debug", "1", PHP_INI_ALL, OnUpdateBool, report_zend_debug, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, magic_quotes_gpc, php_core_globals, core_globals)

STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, magic_quotes_gpc, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("magic_quotes_runtime", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_runtime, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_sybase, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLong, output_buffering, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateString, output_handler, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_globals", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_globals, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_long_arrays", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_long_arrays, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
#if PHP_SAFE_MODE
STD_PHP_INI_BOOLEAN("safe_mode", "1", PHP_INI_SYSTEM, OnUpdateBool, safe_mode, php_core_globals, core_globals)
#else
STD_PHP_INI_BOOLEAN("safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, safe_mode, php_core_globals, core_globals)
#endif
STD_PHP_INI_ENTRY("safe_mode_include_dir", NULL, PHP_INI_SYSTEM, OnUpdateString, safe_mode_include_dir, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("safe_mode_gid", "0", PHP_INI_SYSTEM, OnUpdateBool , safe_mode_gid, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("short_open_tag", DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals)
STD_PHP_INI_BOOLEAN("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool , sql_safe_mode, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("y2k_compliance", "1", PHP_INI_ALL, OnUpdateBool, y2k_compliance, php_core_globals, core_globals)

PHP_INI_ENTRY("precision", "14", PHP_INI_ALL, OnSetPrecision)
PHP_INI_ENTRY("sendmail_from", NULL, PHP_INI_ALL, NULL)
PHP_INI_ENTRY("sendmail_path", DEFAULT_SENDMAIL_PATH, PHP_INI_SYSTEM, NULL)
PHP_INI_ENTRY("mail.force_extra_parameters",NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, NULL)
PHP_INI_ENTRY("disable_functions", "", PHP_INI_SYSTEM, NULL)
PHP_INI_ENTRY("disable_classes", "", PHP_INI_SYSTEM, NULL)

STD_PHP_INI_BOOLEAN("allow_url_fopen", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("always_populate_raw_post_data", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, always_populate_raw_post_data, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("realpath_cache_size", "16K", PHP_INI_SYSTEM, OnUpdateLong, realpath_cache_size_limit, virtual_cwd_globals, cwd_globals)
STD_PHP_INI_ENTRY("realpath_cache_ttl", "120", PHP_INI_SYSTEM, OnUpdateLong, realpath_cache_ttl, virtual_cwd_globals, cwd_globals)
PHP_INI_END()
/* }}} */

………C言語の基本的な禁止事項ってしってますか? > PHP作ってる方々