Skip to content

Commit

Permalink
Fixed shadowy 'index' declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Feb 24, 2017
1 parent 6b0f749 commit 8c7b751
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 36 deletions.
1 change: 0 additions & 1 deletion xdebug_compat.h
Expand Up @@ -45,7 +45,6 @@ zval *xdebug_read_property(zend_class_entry *ce, zval *exception, char *name, in
# define HASH_KEY_IS_NUMERIC(k) ((k) == NULL)
# define HASH_APPLY_KEY_VAL(k) (k)->val
# define HASH_APPLY_KEY_LEN(k) (k)->len + 1
# define HASH_APPLY_NUMERIC(k) index

# define STR_NAME_VAL(k) (k)->val
# define STR_NAME_LEN(k) (k)->len
Expand Down
22 changes: 11 additions & 11 deletions xdebug_handler_dbgp.c
Expand Up @@ -1970,15 +1970,15 @@ static int xdebug_dbgp_parse_cmd(char *line, char **cmd, xdebug_dbgp_arg **ret_a
break;
case STATE_VALUE_FOLLOWS:
if ((*ptr == ' ' && opt != '-') || *ptr == '\0') {
int index = opt - 'a';
int opt_index = opt - 'a';

if (opt == '-') {
index = 26;
opt_index = 26;
}

if (!args->value[index]) {
args->value[index] = xdcalloc(1, ptr - value_begin + 1);
memcpy(args->value[index], value_begin, ptr - value_begin);
if (!args->value[opt_index]) {
args->value[opt_index] = xdcalloc(1, ptr - value_begin + 1);
memcpy(args->value[opt_index], value_begin, ptr - value_begin);
state = STATE_NORMAL;
} else {
goto duplicate_opts;
Expand All @@ -1994,21 +1994,21 @@ static int xdebug_dbgp_parse_cmd(char *line, char **cmd, xdebug_dbgp_arg **ret_a
charescaped = !charescaped;
} else
if (*ptr == '"') {
int index = opt - 'a';
int opt_index = opt - 'a';

if (charescaped) {
charescaped = 0;
break;
}
if (opt == '-') {
index = 26;
opt_index = 26;
}

if (!args->value[index]) {
if (!args->value[opt_index]) {
int len = ptr - value_begin;
args->value[index] = xdcalloc(1, len + 1);
memcpy(args->value[index], value_begin, len);
xdebug_stripcslashes(args->value[index], &len);
args->value[opt_index] = xdcalloc(1, len + 1);
memcpy(args->value[opt_index], value_begin, len);
xdebug_stripcslashes(args->value[opt_index], &len);

state = STATE_SKIP_CHAR;
} else {
Expand Down
6 changes: 3 additions & 3 deletions xdebug_superglobals.c
Expand Up @@ -30,15 +30,15 @@ void xdebug_superglobals_dump_dtor(void *user, void *ptr)
free(ptr);
}

static void dump_hash_elem(zval *z, char *name, long index, char *elem, int html, xdebug_str *str TSRMLS_DC)
static void dump_hash_elem(zval *z, char *name, long index_key, char *elem, int html, xdebug_str *str TSRMLS_DC)
{
int len;

if (html) {
if (elem) {
xdebug_str_add(str, xdebug_sprintf("<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s['%s']&nbsp;=</pre></td>", name, elem), 1);
} else {
xdebug_str_add(str, xdebug_sprintf("<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s[%ld]&nbsp;=</pre></td>", name, index), 1);
xdebug_str_add(str, xdebug_sprintf("<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s[%ld]&nbsp;=</pre></td>", name, index_key), 1);
}
}

Expand Down Expand Up @@ -69,7 +69,7 @@ static void dump_hash_elem(zval *z, char *name, long index, char *elem, int html
}
}

static int dump_hash_elem_va(zval *pDest, zend_ulong index, zend_string *hash_key, char *name, int html, xdebug_str *str)
static int dump_hash_elem_va(zval *pDest, zend_ulong index_key, zend_string *hash_key, char *name, int html, xdebug_str *str)
{
if (HASH_KEY_IS_NUMERIC(hash_key)) {
dump_hash_elem(*((zval **) pDest), name, hash_key->h, NULL, html, str TSRMLS_CC);
Expand Down
42 changes: 21 additions & 21 deletions xdebug_var.c
Expand Up @@ -763,15 +763,15 @@ xdebug_var_export_options* xdebug_var_get_nolimit_options(TSRMLS_D)
** Normal variable printing routines
*/

static int xdebug_array_element_export(zval *zv_nptr, zend_ulong index, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options)
static int xdebug_array_element_export(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options)
{
zval **zv = &zv_nptr;

if (options->runtime[level].current_element_nr >= options->runtime[level].start_element_nr &&
options->runtime[level].current_element_nr < options->runtime[level].end_element_nr)
{
if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */
xdebug_str_add(str, xdebug_sprintf(XDEBUG_INT_FMT " => ", HASH_APPLY_NUMERIC(hash_key)), 1);
xdebug_str_add(str, xdebug_sprintf(XDEBUG_INT_FMT " => ", index_key), 1);
} else { /* string key */
size_t newlen = 0;
char *tmp, *tmp2;
Expand All @@ -798,7 +798,7 @@ static int xdebug_array_element_export(zval *zv_nptr, zend_ulong index, zend_str
return 0;
}

static int xdebug_object_element_export(zval *zv_nptr, zend_ulong index, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name)
static int xdebug_object_element_export(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name)
{
zval **zv = &zv_nptr;

Expand All @@ -818,7 +818,7 @@ static int xdebug_object_element_export(zval *zv_nptr, zend_ulong index, zend_st
xdfree(prop_name);
xdfree(prop_class_name);
} else {
xdebug_str_add(str, xdebug_sprintf("public $%d = ", HASH_APPLY_NUMERIC(hash_key)), 1);
xdebug_str_add(str, xdebug_sprintf("public $%d = ", index_key), 1);
}
xdebug_var_export(zv, str, level + 2, debug_zval, options TSRMLS_CC);
xdebug_str_addl(str, "; ", 2, 0);
Expand Down Expand Up @@ -1112,7 +1112,7 @@ char* xdebug_get_zval_synopsis(zval *val, int debug_zval, xdebug_var_export_opti
#define ANSI_COLOR_BOLD (mode == 1 ? "" : "")
#define ANSI_COLOR_BOLD_OFF (mode == 1 ? "" : "")

static int xdebug_array_element_export_text_ansi(zval *zv_nptr, zend_ulong index, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options)
static int xdebug_array_element_export_text_ansi(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options)
{
zval **zv = &zv_nptr;

Expand All @@ -1122,7 +1122,7 @@ static int xdebug_array_element_export_text_ansi(zval *zv_nptr, zend_ulong index
xdebug_str_add(str, xdebug_sprintf("%*s", (level * 2), ""), 1);

if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */
xdebug_str_add(str, xdebug_sprintf("[" XDEBUG_INT_FMT "] %s=>%s\n", HASH_APPLY_NUMERIC(hash_key), ANSI_COLOR_POINTER, ANSI_COLOR_RESET), 1);
xdebug_str_add(str, xdebug_sprintf("[" XDEBUG_INT_FMT "] %s=>%s\n", index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET), 1);
} else { /* string key */
size_t newlen = 0;
char *tmp, *tmp2;
Expand All @@ -1148,7 +1148,7 @@ static int xdebug_array_element_export_text_ansi(zval *zv_nptr, zend_ulong index
return 0;
}

static int xdebug_object_element_export_text_ansi(zval *zv_nptr, zend_ulong index, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options)
static int xdebug_object_element_export_text_ansi(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, int mode, xdebug_str *str, int debug_zval, xdebug_var_export_options *options)
{
zval **zv = &zv_nptr;

Expand All @@ -1170,7 +1170,7 @@ static int xdebug_object_element_export_text_ansi(zval *zv_nptr, zend_ulong inde
} else {
xdebug_str_add(str, xdebug_sprintf("%s%spublic%s%s ${%d} %s=>%s\n",
ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_RESET,
HASH_APPLY_NUMERIC(hash_key), ANSI_COLOR_POINTER, ANSI_COLOR_RESET), 1);
index_key, ANSI_COLOR_POINTER, ANSI_COLOR_RESET), 1);
}
xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options TSRMLS_CC);
}
Expand Down Expand Up @@ -1471,11 +1471,11 @@ typedef struct
char type;
char *name;
int name_len;
ulong index;
ulong index_key;
zval *zv;
} xdebug_object_item;

static int object_item_add_to_merged_hash(zval *zv_nptr, zend_ulong index, zend_string *hash_key, HashTable *merged, int object_type)
static int object_item_add_to_merged_hash(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, HashTable *merged, int object_type)
{
zval **zv = &zv_nptr;
xdebug_object_item *item;
Expand All @@ -1487,9 +1487,9 @@ static int object_item_add_to_merged_hash(zval *zv_nptr, zend_ulong index, zend_
if (hash_key) {
item->name = (char*) HASH_APPLY_KEY_VAL(hash_key);
item->name_len = HASH_APPLY_KEY_LEN(hash_key) - 1;
item->index = hash_key->h;
item->index_key = hash_key->h;
} else {
item->name = xdebug_sprintf(XDEBUG_INT_FMT, index);
item->name = xdebug_sprintf(XDEBUG_INT_FMT, index_key);
item->name_len = strlen(item->name);
}

Expand Down Expand Up @@ -1594,7 +1594,7 @@ static void add_encoded_text_value_attribute_or_element(xdebug_var_export_option
}


static int xdebug_array_element_export_xml_node(zval *zv_nptr, zend_ulong index, zend_string *hash_key, int level, xdebug_xml_node *parent, char *parent_name, xdebug_var_export_options *options)
static int xdebug_array_element_export_xml_node(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_xml_node *parent, char *parent_name, xdebug_var_export_options *options)
{
zval **zv = &zv_nptr;
xdebug_xml_node *node;
Expand Down Expand Up @@ -1627,7 +1627,7 @@ static int xdebug_array_element_export_xml_node(zval *zv_nptr, zend_ulong index,
zend_string_release(tmp_fullname_zstr);
zend_string_release(i_string);
} else {
name = xdebug_sprintf(XDEBUG_INT_FMT, HASH_APPLY_NUMERIC(hash_key));
name = xdebug_sprintf(XDEBUG_INT_FMT, index_key);
name_len = strlen(name);
if (parent_name) {
xdebug_str_add(&full_name, xdebug_sprintf("%s[%s]", parent_name, name), 1);
Expand All @@ -1646,7 +1646,7 @@ static int xdebug_array_element_export_xml_node(zval *zv_nptr, zend_ulong index,
return 0;
}

static int xdebug_object_element_export_xml_node(xdebug_object_item *item_nptr, zend_ulong index, zend_string *hash_key, int level, xdebug_xml_node *parent, char *parent_name, xdebug_var_export_options *options, char *class_name)
static int xdebug_object_element_export_xml_node(xdebug_object_item *item_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_xml_node *parent, char *parent_name, xdebug_var_export_options *options, char *class_name)
{
xdebug_object_item **item = &item_nptr;
xdebug_xml_node *node;
Expand Down Expand Up @@ -1685,10 +1685,10 @@ static int xdebug_object_element_export_xml_node(xdebug_object_item *item_nptr,
} else { /* Numerical property name */
modifier = "public";

add_name_attribute_or_element(options, node, "name", 4, xdebug_sprintf(XDEBUG_INT_FMT, (*item)->index), SIZE_MAX);
add_name_attribute_or_element(options, node, "name", 4, xdebug_sprintf(XDEBUG_INT_FMT, (*item)->index_key), SIZE_MAX);

if (parent_name) {
full_name = xdebug_sprintf("%s%s" XDEBUG_INT_FMT, parent_name, (*item)->type == XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY ? "::" : "->", (*item)->index);
full_name = xdebug_sprintf("%s%s" XDEBUG_INT_FMT, parent_name, (*item)->type == XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY ? "::" : "->", (*item)->index_key);
add_name_attribute_or_element(options, node, "fullname", 8, full_name, SIZE_MAX);
}
}
Expand Down Expand Up @@ -2006,7 +2006,7 @@ xdebug_xml_node* xdebug_get_zval_value_xml_node_ex(char *name, zval *val, int va
#define COLOR_OBJECT "#8f5902"
#define COLOR_RESOURCE "#2e3436"

static int xdebug_array_element_export_fancy(zval *zv_nptr, zend_ulong index, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options)
static int xdebug_array_element_export_fancy(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options)
{
zval **zv = &zv_nptr;
size_t newlen;
Expand All @@ -2018,7 +2018,7 @@ static int xdebug_array_element_export_fancy(zval *zv_nptr, zend_ulong index, ze
xdebug_str_add(str, xdebug_sprintf("%*s", (level * 4) - 2, ""), 1);

if (HASH_KEY_IS_NUMERIC(hash_key)) { /* numeric key */
xdebug_str_add(str, xdebug_sprintf(XDEBUG_INT_FMT " <font color='%s'>=&gt;</font> ", HASH_APPLY_NUMERIC(hash_key), COLOR_POINTER), 1);
xdebug_str_add(str, xdebug_sprintf(XDEBUG_INT_FMT " <font color='%s'>=&gt;</font> ", index_key, COLOR_POINTER), 1);
} else { /* string key */
xdebug_str_addl(str, "'", 1, 0);
tmp_str = xdebug_xmlize((char*) HASH_APPLY_KEY_VAL(hash_key), HASH_APPLY_KEY_LEN(hash_key) - 1, &newlen);
Expand All @@ -2036,7 +2036,7 @@ static int xdebug_array_element_export_fancy(zval *zv_nptr, zend_ulong index, ze
return 0;
}

static int xdebug_object_element_export_fancy(zval *zv_nptr, zend_ulong index, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name)
static int xdebug_object_element_export_fancy(zval *zv_nptr, zend_ulong index_key, zend_string *hash_key, int level, xdebug_str *str, int debug_zval, xdebug_var_export_options *options, char *class_name)
{
zval **zv = &zv_nptr;

Expand All @@ -2058,7 +2058,7 @@ static int xdebug_object_element_export_fancy(zval *zv_nptr, zend_ulong index, z
xdfree(prop_name);
xdfree(prop_class_name);
} else {
xdebug_str_add(str, xdebug_sprintf("<i>public</i> %d <font color='%s'>=&gt;</font> ", HASH_APPLY_NUMERIC(hash_key), COLOR_POINTER), 1);
xdebug_str_add(str, xdebug_sprintf("<i>public</i> %d <font color='%s'>=&gt;</font> ", index_key, COLOR_POINTER), 1);
}
xdebug_var_export_fancy(zv, str, level + 1, debug_zval, options TSRMLS_CC);
}
Expand Down

0 comments on commit 8c7b751

Please sign in to comment.