Commit 4f61205b

4f61205bc61cMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 5 files · +4 added · ~1 modified

Description

Merge pull request #370 from mame/pr/codegen-cruby-compat-string-index

fix(codegen): CRuby-compat for two String#index / #rindex sites

Details

Commit
4f61205bc61c
Parent
286d05bb0f02
Merge parent
6b9e6f1988ba

spinel_codegen.rbmodifiedView file

@@ -1230,7 +1230,8 @@
12301230 end
12311231 if @current_method_name != ""
12321232 cls_idx = @current_method_name.index("_cls_")
1233- if cls_idx >= 0
1233+ # CRuby returns nil when not found; spinel runtime returns -1.
1234+ if cls_idx != nil && cls_idx >= 0
12341235 return @current_method_name[0, cls_idx]
12351236 end
12361237 end
@@ -7112,7 +7113,8 @@
71127113 mp = ""
71137114 else
71147115 idx = mp.rindex("_")
7115- if idx < 0
7116+ # CRuby returns nil when not found; spinel runtime returns -1.
7117+ if idx == nil || idx < 0
71167118 mp = ""
71177119 else
71187120 mp = mp[0, idx]