Skip to content

Commit

Permalink
Merge pull request #1570 from MasterDuke17/fix_warnings_found_by_gcc_…
Browse files Browse the repository at this point in the history
…at_O2_optimization_level
  • Loading branch information
MasterDuke17 committed Oct 19, 2021
2 parents 7b5b6ba + 4293ea8 commit d48a5a4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/profiler/configuration.c
Expand Up @@ -143,6 +143,9 @@ static MVMuint8 operand_size(MVMThreadContext *tc, MVMuint8 operand) {

case MVM_operand_obj:
case MVM_operand_type_var: size = 2; break;
default:
MVM_exception_throw_adhoc(tc, "TODO: unknown operand type");
/*fail(val, MSG(val, "unknown operand type %"PRIu32), type);*/
}
}
else {
Expand Down
44 changes: 28 additions & 16 deletions src/strings/ops.c
Expand Up @@ -546,11 +546,18 @@ static MVMint64 MVM_string_memmem_grapheme32str (MVMThreadContext *tc, MVMString
MVMint64 rtrn;
if (needle->body.storage_type != MVM_STRING_GRAPHEME_32) {
MVMStringIndex i;
MVMGraphemeIter n_gi;
needle_buf = MVM_malloc(needle->body.num_graphs * sizeof(MVMGrapheme32));
if (needle->body.storage_type != MVM_STRING_GRAPHEME_8) MVM_string_gi_init(tc, &n_gi, needle);
for (i = 0; i < needle->body.num_graphs; i++) {
needle_buf[i] = needle->body.storage_type == MVM_STRING_GRAPHEME_8 ? needle->body.storage.blob_8[i] : MVM_string_gi_get_grapheme(tc, &n_gi);
if (needle->body.storage_type != MVM_STRING_GRAPHEME_8) {
MVMGraphemeIter n_gi;
MVM_string_gi_init(tc, &n_gi, needle);
for (i = 0; i < needle->body.num_graphs; i++) {
needle_buf[i] = MVM_string_gi_get_grapheme(tc, &n_gi);
}
}
else {
for (i = 0; i < needle->body.num_graphs; i++) {
needle_buf[i] = needle->body.storage.blob_8[i];
}
}
}
rtrn = MVM_string_memmem_grapheme32(tc, Haystack->body.storage.blob_32, needle_buf ? needle_buf : needle->body.storage.blob_32, H_start, H_graphs, n_graphs);
Expand Down Expand Up @@ -593,20 +600,25 @@ MVMint64 MVM_string_index(MVMThreadContext *tc, MVMString *Haystack, MVMString *
MVMGrapheme8 *needle_buf = NULL;
if (needle->body.storage_type != MVM_STRING_GRAPHEME_8) {
MVMStringIndex i;
MVMGraphemeIter n_gi;
needle_buf = MVM_malloc(needle->body.num_graphs * sizeof(MVMGrapheme8));
if (needle->body.storage_type != MVM_STRING_GRAPHEME_32) MVM_string_gi_init(tc, &n_gi, needle);
for (i = 0; i < needle->body.num_graphs; i++) {
MVMGrapheme32 g = needle->body.storage_type == MVM_STRING_GRAPHEME_32
? needle->body.storage.blob_32[i]
: MVM_string_gi_get_grapheme(tc, &n_gi);
/* Haystack is 8 bit, needle is 32 bit. if we encounter a non8bit grapheme
* it's impossible to match */
if (!can_fit_into_8bit(g)) {
MVM_free(needle_buf);
return -1;
if (needle->body.storage_type != MVM_STRING_GRAPHEME_32) {
MVMGraphemeIter n_gi;
MVM_string_gi_init(tc, &n_gi, needle);
for (i = 0; i < needle->body.num_graphs; i++) {
needle_buf[i] = MVM_string_gi_get_grapheme(tc, &n_gi);
}
}
else {
for (i = 0; i < needle->body.num_graphs; i++) {
MVMGrapheme32 g = needle->body.storage.blob_32[i];
/* Haystack is 8 bit, needle is 32 bit. if we encounter a non8bit grapheme
* it's impossible to match */
if (!can_fit_into_8bit(g)) {
MVM_free(needle_buf);
return -1;
}
needle_buf[i] = g;
}
needle_buf[i] = g;
}
}
mm_return_8 = MVM_memmem(
Expand Down

0 comments on commit d48a5a4

Please sign in to comment.