Changeset 869


Ignore:
Timestamp:
2012-03-29T18:48:19+02:00 (2 years ago)
Author:
moo
Message:

fix opened_path for when stat=1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r867 r869  
    900900/* }}} */ 
    901901 
    902 #define XC_INCLUDE_PATH_XSTAT_FUNC(name) zend_bool name(const char *absolute_path, size_t absolute_path_len, void *data TSRMLS_DC) 
     902#define XC_INCLUDE_PATH_XSTAT_FUNC(name) zend_bool name(const char *filepath, size_t absolute_path_len, void *data TSRMLS_DC) 
    903903typedef XC_INCLUDE_PATH_XSTAT_FUNC((*include_path_xstat_func_t)); 
    904 static zend_bool xc_include_path_apply(const char *filepath, char *opened_path_buffer, include_path_xstat_func_t xstat_func, void *data TSRMLS_DC) /* {{{ */ 
     904static zend_bool xc_include_path_apply(const char *filepath, char *path_buffer, include_path_xstat_func_t xstat_func, void *data TSRMLS_DC) /* {{{ */ 
    905905{ 
    906906    char *paths, *path; 
     
    916916 
    917917    for (path = php_strtok_r(paths, tokens, &tokbuf); path; path = php_strtok_r(NULL, tokens, &tokbuf)) { 
    918         absolute_path_len = snprintf(opened_path_buffer, MAXPATHLEN, "%s/%s", path, filepath); 
     918        absolute_path_len = snprintf(path_buffer, MAXPATHLEN, "%s/%s", path, filepath); 
    919919        if (absolute_path_len < MAXPATHLEN - 1) { 
    920             if (xstat_func(opened_path_buffer, absolute_path_len, data)) { 
     920            if (xstat_func(path_buffer, absolute_path_len, data)) { 
    921921                ret = 1; 
    922922                goto finish; 
     
    936936                    if (dirname_len + filename_len < MAXPATHLEN - 1) { 
    937937                        ++dirname_len; /* include tailing slash */ 
    938                         memcpy(opened_path_buffer, executed_filename, dirname_len); 
    939                         memcpy(opened_path_buffer + dirname_len, filepath, filename_len); 
     938                        memcpy(path_buffer, executed_filename, dirname_len); 
     939                        memcpy(path_buffer + dirname_len, filepath, filename_len); 
    940940                        absolute_path_len = dirname_len + filename_len; 
    941                         if (xstat_func(opened_path_buffer, absolute_path_len, data) == 0) { 
     941                        if (xstat_func(path_buffer, absolute_path_len, data) == 0) { 
    942942                            ret = 1; 
    943943                            goto finish; 
     
    960960static XC_INCLUDE_PATH_XSTAT_FUNC(xc_stat_file) /* {{{ */ 
    961961{ 
    962     return VCWD_STAT(absolute_path, (struct stat *) data) == 0 ? 1 : 0; 
    963 } 
    964 /* }}} */ 
    965 static int xc_include_path_stat(const char *filepath, char *opened_path_buffer, struct stat *pbuf TSRMLS_DC) /* {{{ */ 
    966 { 
    967     return xc_include_path_apply(filepath, opened_path_buffer, xc_stat_file, (void *) pbuf TSRMLS_DC) 
     962    return VCWD_STAT(filepath, (struct stat *) data) == 0 ? 1 : 0; 
     963} 
     964/* }}} */ 
     965static int xc_include_path_stat(const char *filepath, char *path_buffer, struct stat *pbuf TSRMLS_DC) /* {{{ */ 
     966{ 
     967    return xc_include_path_apply(filepath, path_buffer, xc_stat_file, (void *) pbuf TSRMLS_DC) 
    968968        ? SUCCESS 
    969969        : FAILURE; 
     
    980980    xc_compiler_t *compiler = entry_find_include_path_data->compiler; 
    981981 
    982     compiler->new_entry.entry.name.str.val = absolute_path; 
     982    compiler->new_entry.entry.name.str.val = expand_filepath(filepath, compiler->opened_path_buffer TSRMLS_CC); 
    983983    compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val); 
    984984 
     
    993993} 
    994994/* }}} */ 
    995 static int xc_entry_find_include_path_dmz(xc_compiler_t *compiler, const char *filepath, char *opened_path_buffer, xc_entry_php_t **stored_entry TSRMLS_DC) /* {{{ */ 
    996 { 
     995static int xc_entry_find_include_path_dmz(xc_compiler_t *compiler, const char *filepath, xc_entry_php_t **stored_entry TSRMLS_DC) /* {{{ */ 
     996{ 
     997    char path_buffer[MAXPATHLEN]; 
    997998    xc_entry_find_include_path_data_t entry_find_include_path_data; 
    998999    entry_find_include_path_data.compiler = compiler; 
    9991000    entry_find_include_path_data.stored_entry = stored_entry; 
    10001001 
    1001     return xc_include_path_apply(filepath, opened_path_buffer, xc_entry_find_include_path_func_dmz, (void *) &entry_find_include_path_data TSRMLS_DC) 
     1002    return xc_include_path_apply(filepath, path_buffer, xc_entry_find_include_path_func_dmz, (void *) &entry_find_include_path_data TSRMLS_DC) 
    10021003        ? SUCCESS 
    10031004        : FAILURE; 
     
    10581059 
    10591060        if (xc_entry_php_quick_resolve_opened_path(compiler, &buf TSRMLS_CC) != SUCCESS) { 
    1060             if (xc_include_path_stat(compiler->filename, compiler->opened_path_buffer, &buf TSRMLS_CC) != SUCCESS) { 
     1061            char path_buffer[MAXPATHLEN]; 
     1062            if (xc_include_path_stat(compiler->filename, path_buffer, &buf TSRMLS_CC) != SUCCESS) { 
    10611063                return FAILURE; 
    10621064            } 
    1063             compiler->opened_path = compiler->opened_path_buffer; 
     1065            compiler->opened_path = expand_filepath(path_buffer, compiler->opened_path_buffer TSRMLS_CC); 
    10641066        } 
    10651067 
     
    18551857 
    18561858    ENTER_LOCK_EX(cache) { 
    1857         if (!compiler->opened_path && xc_entry_find_include_path_dmz(compiler, compiler->filename, compiler->opened_path_buffer, &stored_entry TSRMLS_CC) == SUCCESS) { 
     1859        if (!compiler->opened_path && xc_entry_find_include_path_dmz(compiler, compiler->filename, &stored_entry TSRMLS_CC) == SUCCESS) { 
    18581860            compiler->opened_path = compiler->opened_path_buffer; 
    18591861        } 
     
    18641866                } 
    18651867                /* fall back to real stat call */ 
    1866                 else if (xc_include_path_stat(compiler->filename, compiler->opened_path_buffer, &statbuf TSRMLS_CC) == SUCCESS) { 
    1867                     compiler->opened_path = compiler->opened_path_buffer; 
    1868                 } 
    18691868                else { 
    1870                     gaveup = 1; 
    1871                     break; 
     1869                    char path_buffer[MAXPATHLEN]; 
     1870                    if (xc_include_path_stat(compiler->filename, path_buffer, &statbuf TSRMLS_CC) == SUCCESS) { 
     1871                        compiler->opened_path = expand_filepath(path_buffer, compiler->opened_path_buffer TSRMLS_CC); 
     1872                    } 
     1873                    else { 
     1874                        gaveup = 1; 
     1875                        break; 
     1876                    } 
    18721877                } 
    18731878            } 
Note: See TracChangeset for help on using the changeset viewer.