Annotation of embedaddon/php/ext/phar/phar_path_check.c, revision 1.1
1.1 ! misho 1: /* Generated by re2c 0.13.5 on Fri Feb 25 04:29:05 2011 */
! 2: #line 1 "ext/phar/phar_path_check.re"
! 3: /*
! 4: +----------------------------------------------------------------------+
! 5: | phar php single-file executable PHP extension |
! 6: +----------------------------------------------------------------------+
! 7: | Copyright (c) 2007-2012 The PHP Group |
! 8: +----------------------------------------------------------------------+
! 9: | This source file is subject to version 3.01 of the PHP license, |
! 10: | that is bundled with this package in the file LICENSE, and is |
! 11: | available through the world-wide-web at the following url: |
! 12: | http://www.php.net/license/3_01.txt. |
! 13: | If you did not receive a copy of the PHP license and are unable to |
! 14: | obtain it through the world-wide-web, please send a note to |
! 15: | license@php.net so we can mail you a copy immediately. |
! 16: +----------------------------------------------------------------------+
! 17: | Authors: Marcus Boerger <helly@php.net> |
! 18: +----------------------------------------------------------------------+
! 19: */
! 20:
! 21: /* $Id: phar_path_check.c 321634 2012-01-01 13:15:04Z felipe $ */
! 22:
! 23: #include "phar_internal.h"
! 24:
! 25: phar_path_check_result phar_path_check(char **s, int *len, const char **error)
! 26: {
! 27: const unsigned char *p = (const unsigned char*)*s;
! 28: const unsigned char *m;
! 29:
! 30: if (*len == 1 && *p == '.') {
! 31: *error = "current directory reference";
! 32: return pcr_err_curr_dir;
! 33: } else if (*len == 2 && p[0] == '.' && p[1] == '.') {
! 34: *error = "upper directory reference";
! 35: return pcr_err_up_dir;
! 36: }
! 37:
! 38: #define YYCTYPE unsigned char
! 39: #define YYCURSOR p
! 40: #define YYLIMIT p+*len
! 41: #define YYMARKER m
! 42: #define YYFILL(n)
! 43:
! 44: loop:
! 45:
! 46: #line 47 "ext/phar/phar_path_check.c"
! 47: {
! 48: YYCTYPE yych;
! 49:
! 50: if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
! 51: yych = *YYCURSOR;
! 52: if (yych <= '.') {
! 53: if (yych <= '\n') {
! 54: if (yych <= 0x00) goto yy13;
! 55: if (yych <= '\t') goto yy10;
! 56: goto yy12;
! 57: } else {
! 58: if (yych <= 0x19) goto yy10;
! 59: if (yych == '*') goto yy6;
! 60: goto yy15;
! 61: }
! 62: } else {
! 63: if (yych <= '?') {
! 64: if (yych <= '/') goto yy2;
! 65: if (yych <= '>') goto yy15;
! 66: goto yy8;
! 67: } else {
! 68: if (yych == '\\') goto yy4;
! 69: if (yych <= 0x7F) goto yy15;
! 70: goto yy10;
! 71: }
! 72: }
! 73: yy2:
! 74: yych = *(YYMARKER = ++YYCURSOR);
! 75: if (yych <= '-') goto yy3;
! 76: if (yych <= '.') goto yy16;
! 77: if (yych <= '/') goto yy18;
! 78: yy3:
! 79: #line 93 "ext/phar/phar_path_check.re"
! 80: {
! 81: goto loop;
! 82: }
! 83: #line 84 "ext/phar/phar_path_check.c"
! 84: yy4:
! 85: ++YYCURSOR;
! 86: #line 60 "ext/phar/phar_path_check.re"
! 87: {
! 88: *error = "back-slash";
! 89: return pcr_err_back_slash;
! 90: }
! 91: #line 92 "ext/phar/phar_path_check.c"
! 92: yy6:
! 93: ++YYCURSOR;
! 94: #line 64 "ext/phar/phar_path_check.re"
! 95: {
! 96: *error = "star";
! 97: return pcr_err_star;
! 98: }
! 99: #line 100 "ext/phar/phar_path_check.c"
! 100: yy8:
! 101: ++YYCURSOR;
! 102: #line 68 "ext/phar/phar_path_check.re"
! 103: {
! 104: if (**s == '/') {
! 105: (*s)++;
! 106: }
! 107: *len = (p - (const unsigned char*)*s) -1;
! 108: *error = NULL;
! 109: return pcr_use_query;
! 110: }
! 111: #line 112 "ext/phar/phar_path_check.c"
! 112: yy10:
! 113: ++YYCURSOR;
! 114: yy11:
! 115: #line 76 "ext/phar/phar_path_check.re"
! 116: {
! 117: *error ="illegal character";
! 118: return pcr_err_illegal_char;
! 119: }
! 120: #line 121 "ext/phar/phar_path_check.c"
! 121: yy12:
! 122: yych = *++YYCURSOR;
! 123: goto yy11;
! 124: yy13:
! 125: ++YYCURSOR;
! 126: #line 80 "ext/phar/phar_path_check.re"
! 127: {
! 128: if (**s == '/') {
! 129: (*s)++;
! 130: (*len)--;
! 131: }
! 132: if ((p - (const unsigned char*)*s) - 1 != *len)
! 133: {
! 134: *error ="illegal character";
! 135: return pcr_err_illegal_char;
! 136: }
! 137: *error = NULL;
! 138: return pcr_is_ok;
! 139: }
! 140: #line 141 "ext/phar/phar_path_check.c"
! 141: yy15:
! 142: yych = *++YYCURSOR;
! 143: goto yy3;
! 144: yy16:
! 145: yych = *++YYCURSOR;
! 146: if (yych <= 0x00) goto yy21;
! 147: if (yych <= '-') goto yy17;
! 148: if (yych <= '.') goto yy20;
! 149: if (yych <= '/') goto yy21;
! 150: yy17:
! 151: YYCURSOR = YYMARKER;
! 152: goto yy3;
! 153: yy18:
! 154: ++YYCURSOR;
! 155: #line 48 "ext/phar/phar_path_check.re"
! 156: {
! 157: *error = "double slash";
! 158: return pcr_err_double_slash;
! 159: }
! 160: #line 161 "ext/phar/phar_path_check.c"
! 161: yy20:
! 162: yych = *++YYCURSOR;
! 163: if (yych <= 0x00) goto yy23;
! 164: if (yych == '/') goto yy23;
! 165: goto yy17;
! 166: yy21:
! 167: ++YYCURSOR;
! 168: #line 56 "ext/phar/phar_path_check.re"
! 169: {
! 170: *error = "current directory reference";
! 171: return pcr_err_curr_dir;
! 172: }
! 173: #line 174 "ext/phar/phar_path_check.c"
! 174: yy23:
! 175: ++YYCURSOR;
! 176: #line 52 "ext/phar/phar_path_check.re"
! 177: {
! 178: *error = "upper directory reference";
! 179: return pcr_err_up_dir;
! 180: }
! 181: #line 182 "ext/phar/phar_path_check.c"
! 182: }
! 183: #line 96 "ext/phar/phar_path_check.re"
! 184:
! 185: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>