Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 109 lines (99 sloc) 4.525 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
/*
+----------------------------------------------------------------------+
| Xdebug |
+----------------------------------------------------------------------+
| Copyright (c) 2002-2012 Derick Rethans <derick@xdebug.org> |
| (c) 1997-2004 Jim Winstead <jimw@trainedmonkey.com> |
| (c) 1998-2004 Andi Gutmans <andi@zend.com> and |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
| This source file is subject to the following Modified BSD license: |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions |
| are met: |
| |
| 1. Redistributions of source code must retain the above copyright |
| notice, this list of conditions and the following disclaimer. |
| |
| 2. Redistributions in binary form must reproduce the above |
| copyright notice, this list of conditions and the following |
| disclaimer in the documentation and/or other materials provided |
| with the distribution. |
| |
| 3. The name of the author may not be used to endorse or promote |
| products derived from this software without specific prior |
| written permission. |
| |
| THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+----------------------------------------------------------------------+
*/
/* $Id: xdebug_compat.c,v 1.13 2010-05-07 20:39:13 derick Exp $ */

#include "php.h"
#include "main/php_version.h"
#include "xdebug_compat.h"
#include "zend_extensions.h"

#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1
void *php_zend_memrchr(const void *s, int c, size_t n)
{
register unsigned char *e;

if (n <= 0) {
return NULL;
}

for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
if (*e == (unsigned char)c) {
return (void *)e;
}
}

return NULL;
}
#endif

#define T(offset) (*(temp_variable *)((char *) Ts + offset))

zval *xdebug_zval_ptr(znode *node, temp_variable *Ts TSRMLS_DC)
{
switch (node->op_type) {
case IS_CONST:
return &node->u.constant;
break;
case IS_TMP_VAR:
return &T(node->u.var).tmp_var;
break;
case IS_VAR:
if (T(node->u.var).var.ptr) {
return T(node->u.var).var.ptr;
} else {
temp_variable *T = &T(node->u.var);
zval *str = T->str_offset.str;

if (T->str_offset.str->type != IS_STRING
|| ((int)T->str_offset.offset<0)
|| (T->str_offset.str->value.str.len <= T->str_offset.offset)) {
zend_error(E_NOTICE, "Uninitialized string offset: %d", T->str_offset.offset);
T->tmp_var.value.str.val = STR_EMPTY_ALLOC();
T->tmp_var.value.str.len = 0;
} else {
char c = str->value.str.val[T->str_offset.offset];

T->tmp_var.value.str.val = estrndup(&c, 1);
T->tmp_var.value.str.len = 1;
}
T->tmp_var.XDEBUG_REFCOUNT=1;
T->tmp_var.XDEBUG_IS_REF=1;
T->tmp_var.type = IS_STRING;
return &T->tmp_var;
}
break;
case IS_UNUSED:
return NULL;
break;
}
return NULL;
}
Something went wrong with that request. Please try again.