Skip to content

Commit 6ce7603

Browse files
committed
[[ Cleanup ]] Remove MCNameGetCharAtIndex
This patch removes the MCNameGetCharAtIndex function, replacing it with MCStringGetNativeCharAtIndex(MCNameGetString(...), ...).
1 parent 0578ffd commit 6ce7603

File tree

6 files changed

+20
-31
lines changed

6 files changed

+20
-31
lines changed

engine/src/button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2447,7 +2447,7 @@ class ButtonMenuCallback : public IParseMenuCallback
24472447
newbutton->menubutton = parent->menubutton;
24482448
newbutton->menucontrol = MENUCONTROL_ITEM;
24492449
newbutton->m_theme_type = kMCPlatformControlTypeMenu;
2450-
if (MCNameGetCharAtIndex(newbutton -> getname(), 0) == '-')
2450+
if (MCStringGetNativeCharAtIndex(MCNameGetString(newbutton->getname()), 0) == '-')
24512451
{
24522452
newbutton->rect.height = 2;
24532453
newbutton->flags = DIVIDER_FLAGS;

engine/src/foundation-legacy.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,13 +1057,6 @@ bool MCCStringIsInteger(const char *p_string)
10571057

10581058
////////////////////////////////////////////////////////////////////////////////
10591059

1060-
char MCNameGetCharAtIndex(MCNameRef p_name, uindex_t p_at)
1061-
{
1062-
return MCStringGetNativeCharAtIndex(MCNameGetString(p_name), p_at);
1063-
}
1064-
1065-
////////////////////////////////////////////////////////////////////////////////
1066-
10671060
struct get_array_extent_context_t
10681061
{
10691062
index_t minimum;

engine/src/foundation-legacy.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ MCString MCDataGetOldString(MCDataRef data);
7676

7777
////////////////////////////////////////////////////////////////////////////////
7878

79-
char MCNameGetCharAtIndex(MCNameRef name, uindex_t at);
80-
81-
////////////////////////////////////////////////////////////////////////////////
82-
8379
enum IO_stat
8480
{
8581
IO_NORMAL,

engine/src/handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ Parse_stat MCHandler::findvar(MCNameRef p_name, MCVarref **dptr)
615615
}
616616
}
617617

618-
if (MCNameGetCharAtIndex(p_name, 0) == '$')
618+
if (MCStringGetNativeCharAtIndex(MCNameGetString(p_name), 0) == '$')
619619
{
620620
MCVariable *t_global;
621621
/* UNCHECKED */ MCVariable::ensureglobal(p_name, t_global);

engine/src/hndlrlst.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Parse_stat MCHandlerlist::findvar(MCNameRef p_name, bool p_ignore_uql, MCVarref
224224
// In server mode, we need to resolve $ vars in the context of the global
225225
// scope. (This doesn't happen in non-server mode as there is never any
226226
// 'code' in 'global' scope).
227-
if (MCNameGetCharAtIndex(p_name, 0) == '$')
227+
if (MCStringGetNativeCharAtIndex(MCNameGetString(p_name), 0) == '$')
228228
{
229229
for (tmp = MCglobals ; tmp != NULL ; tmp = tmp->getnext())
230230
if (tmp->hasname(p_name))

engine/src/variable.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,11 @@ bool MCVariable::remove(MCExecContext& ctxt, MCSpan<MCNameRef> p_path)
750750

751751
if (is_env)
752752
{
753-
if (!isdigit(MCNameGetCharAtIndex(*name, 1)) && MCNameGetCharAtIndex(*name, 1) != '#')
753+
MCStringRef t_name_string = MCNameGetString(*name);
754+
if (!isdigit(MCStringGetNativeCharAtIndex(t_name_string, 1)) && MCStringGetNativeCharAtIndex(t_name_string, 1) != '#')
754755
{
755756
MCAutoStringRef t_env;
756-
/* UNCHECKED */ MCStringCopySubstring(MCNameGetString(*name), MCRangeMake(1, MCStringGetLength(MCNameGetString(*name))), &t_env);
757+
/* UNCHECKED */ MCStringCopySubstring(MCNameGetString(*name), MCRangeMake(1, MCStringGetLength(t_name_string)), &t_env);
757758
MCS_unsetenv(*t_env);
758759
}
759760
}
@@ -937,21 +938,19 @@ bool MCVariable::ensureglobal(MCNameRef p_name, MCVariable*& r_var)
937938
if (!createwithname(p_name, t_new_global))
938939
return false;
939940

940-
if (MCNameGetCharAtIndex(p_name, 0) == '$')
941-
{
942-
MCAutoStringRef t_env;
943-
/* UNCHECKED */ MCStringCopySubstring(
944-
MCNameGetString(p_name),
945-
MCRangeMake(1, MCStringGetLength(MCNameGetString(p_name))),
946-
&t_env
947-
);
948-
949-
MCAutoStringRef t_value;
950-
if (MCS_getenv(*t_env, &t_value))
951-
t_new_global -> setvalueref(*t_value);
941+
if (MCStringGetNativeCharAtIndex(MCNameGetString(p_name), 0) == '$')
942+
{
943+
MCAutoStringRef t_env;
944+
/* UNCHECKED */ MCStringCopySubstring(MCNameGetString(p_name),
945+
MCRangeMake(1, MCStringGetLength(MCNameGetString(p_name))),
946+
&t_env);
947+
948+
MCAutoStringRef t_value;
949+
if (MCS_getenv(*t_env, &t_value))
950+
t_new_global -> setvalueref(*t_value);
952951

953-
t_new_global -> is_env = true;
954-
}
952+
t_new_global -> is_env = true;
953+
}
955954

956955
t_new_global -> is_global = true;
957956

@@ -1037,7 +1036,8 @@ void MCVariable::synchronize(MCExecContext& ctxt, bool p_notify)
10371036
MCAutoStringRef t_stringref_value;
10381037
if (is_env)
10391038
{
1040-
if (!isdigit(MCNameGetCharAtIndex(*name, 1)) && MCNameGetCharAtIndex(*name, 1) != '#')
1039+
MCStringRef t_name_string = MCNameGetString(*name);
1040+
if (!isdigit(MCStringGetNativeCharAtIndex(t_name_string, 1)) && MCStringGetNativeCharAtIndex(t_name_string, 1) != '#')
10411041
{
10421042
MCExecTypeCopy(value, t_value);
10431043
MCExecTypeConvertAndReleaseAlways(ctxt, t_value . type, &t_value, kMCExecValueTypeStringRef, &(&t_stringref_value));

0 commit comments

Comments
 (0)