Permalink
Browse files

[cage] (TT #397) PDD07 enforcement for Parrot_str_not_equal(foo,bar)==0

git-svn-id: https://svn.parrot.org/parrot/trunk@37099 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 4c531f3 commit 4b380b1bade61e8e45d64a39a9de3abfc05edfb7 @Util Util committed Mar 3, 2009
@@ -191,7 +191,7 @@ add_string_const(bytecode * const bc, char const * const str, char const * chars
while (index < count) {
constant = bc->interp->code->const_table->constants[index];
if (constant->type == PFC_STRING) {
- if (Parrot_str_not_equal(bc->interp, constant->u.string, parrotstr) == 0) {
+ if (Parrot_str_equal(bc->interp, constant->u.string, parrotstr)) {
#if DEBUGBC
fprintf(stderr, "found string %s at index %d\n", str, index);
#endif
@@ -269,7 +269,7 @@ add_key_const(bytecode * const bc, PMC *key) {
if (constant->type == PFC_KEY) {
STRING *s2 = key_set_to_string(bc->interp, constant->u.key);
- if (Parrot_str_not_equal(bc->interp, s1, s2) == 0) {
+ if (Parrot_str_equal(bc->interp, s1, s2)) {
#if DEBUGBC
fprintf(stderr, "found equal key (%d)\n", index);
#endif
@@ -57,10 +57,10 @@ matchrange_locate_keyed_int(Interp* interp, PMC* self, STRING *key)
STRING *start = Parrot_str_new(interp, "start", 5);
STRING *end;
- if (0 == Parrot_str_not_equal(interp, key, start))
+ if (Parrot_str_equal(interp, key, start))
return &RANGE_START(self);
end = Parrot_str_new(interp, "end", 3);
- if (0 == Parrot_str_not_equal(interp, key, end))
+ if (Parrot_str_equal(interp, key, end))
return &RANGE_END(self);
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND,
"MatchRange: key is neither 'start' nor 'end'");
View
@@ -1305,7 +1305,7 @@ locate_named_named(PARROT_INTERP, ARGMOD(call_state *st))
? st->dest.ctx->constants[idx]->u.string
: CTX_REG_STR(st->dest.ctx, idx);
- if (st->name == param || Parrot_str_not_equal(interp, st->name, param) == 0) {
+ if (st->name == param || Parrot_str_equal(interp, st->name, param)) {
++i;
st->dest.sig = VTABLE_get_integer_keyed_int(interp,
st->dest.u.op.signature, i);
View
@@ -516,7 +516,7 @@ Parrot_clone_lib_into(ARGMOD(Interp *d), ARGMOD(Interp *s), ARGIN(PMC *lib_pmc))
STRING * const type =
VTABLE_get_string(s, VTABLE_getprop(s, lib_pmc, type_str));
- if (!Parrot_str_not_equal(s, type, ops)) {
+ if (Parrot_str_equal(s, type, ops)) {
/* we can't clone oplibs in the normal way, since they're actually
* shared between interpreters dynop_register modifies the (statically
* allocated) op_lib_t structure from core_ops.c, for example.
View
@@ -123,7 +123,7 @@ die_from_exception(PARROT_INTERP, ARGIN(PMC *exception))
}
}
- if (Parrot_str_not_equal(interp, message, CONST_STRING(interp, "")) == 1) {
+ if (Parrot_str_not_equal(interp, message, CONST_STRING(interp, ""))) {
Parrot_io_eprintf(interp, "%S\n", message);
/* caution against output swap (with PDB_backtrace) */
@@ -206,7 +206,7 @@ Parrot_ex_throw_from_op(PARROT_INTERP, ARGIN(PMC *exception), ARGIN_NULLOK(void
const INTVAL severity = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "severity"));
if (severity < EXCEPT_error) {
PMC * const resume = VTABLE_get_attr_str(interp, exception, CONST_STRING(interp, "resume"));
- if (Parrot_str_not_equal(interp, message, CONST_STRING(interp, "")) == 1) {
+ if (Parrot_str_not_equal(interp, message, CONST_STRING(interp, ""))) {
Parrot_io_eprintf(interp, "%S\n", message);
}
else {
View
@@ -238,7 +238,7 @@ Parrot_register_HLL_lib(PARROT_INTERP, ARGIN(STRING *hll_lib))
if (!PMC_IS_NULL(lib_name)) {
const STRING * const name = VTABLE_get_string(interp, lib_name);
- if (Parrot_str_not_equal(interp, name, hll_lib) == 0)
+ if (Parrot_str_equal(interp, name, hll_lib))
break;
}
}
View
@@ -653,7 +653,7 @@ Parrot_io_is_encoding(PARROT_INTERP, ARGIN(PMC *filehandle), ARGIN(STRING *value
if (STRING_IS_NULL(handle_struct->encoding))
return 0;
- if (Parrot_str_not_equal(interp, value, handle_struct->encoding) == 0)
+ if (Parrot_str_equal(interp, value, handle_struct->encoding))
return 1;
return 0;
View
@@ -535,15 +535,15 @@ try_bytecode_extensions(PARROT_INTERP, ARGMOD(STRING* path))
if (Parrot_str_byte_length(interp, test_path) > 4) {
STRING *orig_ext = Parrot_str_substr(interp, test_path, -4, 4, NULL, 0);
/* First try substituting .pbc for the .pir extension */
- if (Parrot_str_not_equal(interp, orig_ext, pir_extension) == 0) {
+ if (Parrot_str_equal(interp, orig_ext, pir_extension)) {
STRING * const without_ext = Parrot_str_chopn(interp, test_path, 4);
test_path = Parrot_str_append(interp, without_ext, bytecode_extension);
result = try_load_path(interp, test_path);
if (result)
return result;
}
/* Next try substituting .pir, then .pasm for the .pbc extension */
- else if (Parrot_str_not_equal(interp, orig_ext, bytecode_extension) == 0) {
+ else if (Parrot_str_equal(interp, orig_ext, bytecode_extension)) {
STRING * const without_ext = Parrot_str_chopn(interp, test_path, 4);
test_path = Parrot_str_append(interp, without_ext, pir_extension);
result = try_load_path(interp, test_path);
@@ -561,7 +561,7 @@ try_bytecode_extensions(PARROT_INTERP, ARGMOD(STRING* path))
/* Finally, try substituting .pbc for the .pasm extension. */
if (Parrot_str_byte_length(interp, test_path) > 5) {
STRING * const orig_ext = Parrot_str_substr(interp, test_path, -5, 5, NULL, 0);
- if (Parrot_str_not_equal(interp, orig_ext, pasm_extension) == 0) {
+ if (Parrot_str_equal(interp, orig_ext, pasm_extension)) {
STRING * const without_ext = Parrot_str_chopn(interp, test_path, 5);
test_path = Parrot_str_append(interp, without_ext, bytecode_extension);
result = try_load_path(interp, test_path);
View
@@ -659,13 +659,13 @@ mmd_build_type_tuple_from_type_list(PARROT_INTERP, ARGIN(PMC *type_list))
STRING *type_name = VTABLE_get_string_keyed_int(interp, type_list, i);
INTVAL type;
- if (Parrot_str_not_equal(interp, type_name, CONST_STRING(interp, "DEFAULT"))==0)
+ if (Parrot_str_equal(interp, type_name, CONST_STRING(interp, "DEFAULT")))
type = enum_type_PMC;
- else if (Parrot_str_not_equal(interp, type_name, CONST_STRING(interp, "STRING"))==0)
+ else if (Parrot_str_equal(interp, type_name, CONST_STRING(interp, "STRING")))
type = enum_type_STRING;
- else if (Parrot_str_not_equal(interp, type_name, CONST_STRING(interp, "INTVAL"))==0)
+ else if (Parrot_str_equal(interp, type_name, CONST_STRING(interp, "INTVAL")))
type = enum_type_INTVAL;
- else if (Parrot_str_not_equal(interp, type_name, CONST_STRING(interp, "FLOATVAL"))==0)
+ else if (Parrot_str_equal(interp, type_name, CONST_STRING(interp, "FLOATVAL")))
type = enum_type_FLOATVAL;
else
type = pmc_type(interp, type_name);
View
@@ -772,7 +772,7 @@ Parrot_find_method_direct(PARROT_INTERP, ARGIN(PMC *_class), ARGIN(STRING *metho
return found;
- if (!Parrot_str_not_equal(interp, method_name, CONST_STRING(interp, "__get_string")))
+ if (Parrot_str_equal(interp, method_name, CONST_STRING(interp, "__get_string")))
return find_method_direct_1(interp, _class, CONST_STRING(interp, "__get_repr"));
return PMCNULL;
@@ -1195,7 +1195,7 @@ Parrot_ComposeRole(PARROT_INTERP, ARGIN(PMC *role),
const STRING * const check =
VTABLE_get_string_keyed_int(interp, exclude, i);
- if (Parrot_str_not_equal(interp, check, method_name) == 0) {
+ if (Parrot_str_equal(interp, check, method_name)) {
excluded = 1;
break;
}
View
@@ -77,7 +77,7 @@ inline op eq(in NUM, in NUM, inconst LABEL) :base_core {
}
op eq(in STR, in STR, inconst LABEL) :base_core {
- if (Parrot_str_not_equal(interp, $1, $2) == 0) {
+ if (Parrot_str_equal(interp, $1, $2)) {
goto OFFSET($3);
}
}
@@ -113,7 +113,7 @@ op eq(invar PMC, in NUM, inconst LABEL) :base_core {
}
op eq(invar PMC, in STR, inconst LABEL) :base_core {
- if (0 == Parrot_str_not_equal(interp,
+ if (Parrot_str_equal(interp,
VTABLE_get_string(interp, $1), $2)) {
goto OFFSET($3);
}
@@ -184,7 +184,7 @@ inline op ne(in NUM, in NUM, inconst LABEL) :base_core {
}
op ne(in STR, in STR, inconst LABEL) :base_core {
- if (Parrot_str_not_equal(interp, $1, $2) != 0) {
+ if (Parrot_str_not_equal(interp, $1, $2)) {
goto OFFSET($3);
}
}
@@ -214,7 +214,7 @@ op ne(invar PMC, in NUM, inconst LABEL) :base_core {
}
op ne(invar PMC, in STR, inconst LABEL) :base_core {
- if (0 != Parrot_str_not_equal(interp,
+ if (Parrot_str_not_equal(interp,
VTABLE_get_string(interp, $1), $2)) {
goto OFFSET($3);
}
@@ -842,7 +842,7 @@ inline op iseq(out INT, in NUM, in NUM) {
}
inline op iseq(out INT, in STR, in STR) {
- $1 = Parrot_str_not_equal(interp, $2, $3) == 0;
+ $1 = ( Parrot_str_equal(interp, $2, $3) ? 1 : 0 );
}
inline op iseq(out INT, invar PMC, invar PMC) {
@@ -873,7 +873,7 @@ inline op isne(out INT, in NUM, in NUM) {
}
inline op isne(out INT, in STR, in STR) {
- $1 = Parrot_str_not_equal(interp, $2, $3) != 0;
+ $1 = ( Parrot_str_not_equal(interp, $2, $3) ? 1 : 0 );
}
inline op isne(out INT, invar PMC, invar PMC) {
View
@@ -4327,7 +4327,7 @@ PackFile_Annotations_add_entry(PARROT_INTERP, ARGMOD(PackFile_Annotations *self)
for (i = 0; i < self->num_keys; i++) {
STRING *test_key = PF_CONST(self->code, self->keys[i]->name)->u.string;
- if (Parrot_str_not_equal(interp, test_key, key_name) == 0) {
+ if (Parrot_str_equal(interp, test_key, key_name)) {
key_id = i;
break;
}
@@ -4450,7 +4450,7 @@ PackFile_Annotations_lookup(PARROT_INTERP, ARGIN(PackFile_Annotations *self),
if (key) {
for (i = 0; i < self->num_keys; i++) {
STRING *test_key = PF_CONST(self->code, self->keys[i]->name)->u.string;
- if (Parrot_str_not_equal(interp, test_key, key) == 0) {
+ if (Parrot_str_equal(interp, test_key, key)) {
key_id = i;
break;
}
@@ -4590,7 +4590,7 @@ Parrot_load_bytecode(PARROT_INTERP, ARGIN_NULLOK(STRING *file_str))
pbc = CONST_STRING(interp, "pbc");
- if (Parrot_str_not_equal(interp, ext, pbc) == 0)
+ if (Parrot_str_equal(interp, ext, pbc))
file_type = PARROT_RUNTIME_FT_PBC;
else
file_type = PARROT_RUNTIME_FT_SOURCE;
View
@@ -808,7 +808,7 @@ Adds the supplied PMC to the list of parents for the class.
STRING * const current_name = VTABLE_get_string(interp, current_parent);
/* throw an exception if we already have this parent */
- if (Parrot_str_not_equal(interp, current_name, parent_name) == 0)
+ if (Parrot_str_equal(interp, current_name, parent_name))
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
"The class '%S' already has a parent class '%S'. "
@@ -970,40 +970,40 @@ Array of Class PMCs representing the direct parents of this class.
/* What should we return? */
PMC *found;
- if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "name")) == 0) {
+ if (Parrot_str_equal(interp, what, CONST_STRING(interp, "name"))) {
found = pmc_new(interp, enum_class_String);
VTABLE_set_string_native(interp, found, _class->name);
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "id")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "id"))) {
found = pmc_new(interp, enum_class_Integer);
VTABLE_set_integer_native(interp, found, _class->id);
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "namespace")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "namespace"))) {
/* Should not clone this. */
return _class->_namespace;
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "attributes")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "attributes"))) {
found = _class->attrib_metadata;
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "attrib_index")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "attrib_index"))) {
found = _class->attrib_index;
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "methods")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "methods"))) {
found = _class->methods;
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "vtable_overrides")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "vtable_overrides"))) {
found = _class->vtable_overrides;
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "parents")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "parents"))) {
found = _class->parents;
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "all_parents")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "all_parents"))) {
found = _class->all_parents;
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "roles")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "roles"))) {
found = _class->roles;
}
- else if (Parrot_str_not_equal(interp, what, CONST_STRING(interp, "flags")) == 0) {
+ else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "flags"))) {
found = pmc_new(interp, enum_class_Integer);
VTABLE_set_integer_native(interp, found,
(INTVAL)PObj_get_FLAGS(SELF));
@@ -1290,7 +1290,7 @@ Returns whether the class is or inherits from C<*class>.
: make_class_name(interp, SELF);
/* Check if the passed name is the same as the stored short name. */
- INTVAL name_match = Parrot_str_not_equal(interp, classname, self_name) == 0;
+ INTVAL name_match = Parrot_str_equal(interp, classname, self_name);
Parrot_str_free(interp, classname);
if (is_proxy)
@@ -1329,7 +1329,7 @@ Returns whether the class is or inherits from C<*classname>.
PMC *want_class;
/* hard-code this one exception right away */
- if (Parrot_str_not_equal(interp, classname, CONST_STRING(interp, "Class")) == 0)
+ if (Parrot_str_equal(interp, classname, CONST_STRING(interp, "Class")))
return 1;
want_class = Parrot_oo_get_class_str(interp, classname);
View
@@ -86,7 +86,7 @@ A newline is automatically added to the end of the fmt.
I0 = Parrot_str_to_int(INTERP, key);
repl = VTABLE_get_string_keyed_int(INTERP, args, I0);
}
- else if (0 == Parrot_str_not_equal(INTERP, key, comma)) {
+ else if (Parrot_str_equal(INTERP, key, comma)) {
repl = VTABLE_get_string_keyed_int(INTERP, args, 0);
repl = Parrot_str_new_COW(INTERP, repl);
I1 = VTABLE_elements(INTERP, args);
@@ -99,7 +99,7 @@ A newline is automatically added to the end of the fmt.
I0++;
}
}
- else if (0 == Parrot_str_not_equal(INTERP, key, percent)) {
+ else if (Parrot_str_equal(INTERP, key, percent)) {
repl = percent;
}
else {
View
@@ -483,10 +483,10 @@ Returns the requested number (real part for C<real> and imaginary for C<imag>).
VTABLE FLOATVAL get_number_keyed_str(STRING *key) {
FLOATVAL value;
- if (Parrot_str_not_equal(INTERP, key, CONST_STRING(INTERP, "real")) == 0) {
+ if (Parrot_str_equal(INTERP, key, CONST_STRING(INTERP, "real"))) {
GET_ATTR_re(INTERP, SELF, value);
}
- else if (Parrot_str_not_equal(INTERP, key, CONST_STRING(INTERP, "imag")) == 0) {
+ else if (Parrot_str_equal(INTERP, key, CONST_STRING(INTERP, "imag"))) {
GET_ATTR_im(INTERP, SELF, value);
}
else
@@ -670,10 +670,10 @@ to C<value>.
}
VTABLE void set_number_keyed_str(STRING *key, FLOATVAL value) {
- if (Parrot_str_not_equal(INTERP, key, CONST_STRING(INTERP, "real")) == 0) {
+ if (Parrot_str_equal(INTERP, key, CONST_STRING(INTERP, "real"))) {
SET_ATTR_re(INTERP, SELF, value);
}
- else if (Parrot_str_not_equal(INTERP, key, CONST_STRING(INTERP, "imag")) == 0) {
+ else if (Parrot_str_equal(INTERP, key, CONST_STRING(INTERP, "imag"))) {
SET_ATTR_im(INTERP, SELF, value);
}
else
Oops, something went wrong.

0 comments on commit 4b380b1

Please sign in to comment.