Skip to content

Commit 046bc79

Browse files
author
livecodeali
committed
Merge remote-tracking branch 'upstream/develop-7.0' into merge-develop_7.0_12.06.15
Conflicts: ide libfoundation/include/foundation.h libfoundation/src/foundation-number.cpp
2 parents f8869b9 + 92d78fc commit 046bc79

17 files changed

Lines changed: 205 additions & 203 deletions

docs/notes/bugfix-15386.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Failure to incorporate code with 'include' on 7.0 servers

docs/notes/bugfix-15474.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Max interger literal number limited to 2^32 on 64-bit Linux

engine/src/dispatch.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,11 @@ IO_stat MCDispatch::loadfile(MCStringRef p_name, MCStack *&sptr)
979979
{
980980
if ((stream = MCS_open(p_name, kMCOpenFileModeRead, True, False, 0)) != NULL)
981981
{
982-
// This should probably use resolvepath().
983-
// SN-2015-06-03: [[ Bug 15432 ]] Use resolvepath
982+
// SN-20015-06-01: [[ Bug 15432 ]] We want to use MCS_resolvepath to
983+
// keep consistency and let '~' be resolved as it is in MCS_open
984+
// MCS_resolve_path leaves a backslash-delimited path on Windows,
985+
// and MCS_get_canonical_path is made to cope with this.
986+
// In 7.0, MCS_resolvepath does not return a native path.
984987
t_found = MCS_resolvepath(p_name, &t_open_path);
985988
}
986989
}
@@ -997,10 +1000,7 @@ IO_stat MCDispatch::loadfile(MCStringRef p_name, MCStack *&sptr)
9971000
t_leaf_name = p_name;
9981001
if ((stream = MCS_open(*t_leaf_name, kMCOpenFileModeRead, True, False, 0)) != NULL)
9991002
{
1000-
MCAutoStringRef t_curpath;
1001-
/* UNCHECKED */ MCS_getcurdir(&t_curpath);
1002-
/* UNCHECKED */ MCStringFormat(&t_open_path, "%@/%@", *t_curpath, p_name);
1003-
t_found = true;
1003+
t_found = MCS_resolvepath(*t_leaf_name, &t_open_path);
10041004
}
10051005

10061006
if (!t_found)

engine/src/dsklnx.cpp

Lines changed: 37 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,36 +2056,35 @@ class MCLinuxDesktop: public MCSystemInterface
20562056
}
20572057
delete tpath;
20582058
}
2059+
else if (path[0] != '/')
2060+
{
2061+
// SN-2015-06-05: [[ Bug 15432 ]] Fix resolvepath on Linux: we want an
2062+
// absolute path.
2063+
char *t_curfolder;
2064+
t_curfolder = MCS_getcurdir();
2065+
tildepath = new char[strlen(t_curfolder) + strlen(path) + 2];
2066+
/* UNCHECKED */ sprintf(tildepath, "%s/%s", t_curfolder, path);
2067+
2068+
delete t_curfolder;
2069+
}
20592070
else
20602071
tildepath = strclone(path);
20612072

20622073
struct stat64 buf;
20632074
if (lstat64(tildepath, &buf) != 0 || !S_ISLNK(buf.st_mode))
20642075
return tildepath;
2065-
int4 size;
2076+
20662077
char *newname = new char[PATH_MAX + 2];
2067-
if ((size = readlink(tildepath, newname, PATH_MAX)) < 0)
2078+
2079+
// SN-2015-06-05: [[ Bug 15432 ]] Use realpath to solve the symlink.
2080+
if (realpath(tildepath, newname) == NULL)
20682081
{
2069-
delete tildepath;
2082+
// Clear the memory in case of failure
20702083
delete newname;
2071-
return NULL;
2084+
newname = NULL;
20722085
}
2086+
20732087
delete tildepath;
2074-
newname[size] = '\0';
2075-
if (newname[0] != '/')
2076-
{
2077-
char *fullpath = new char[strlen(path) + strlen(newname) + 2];
2078-
strcpy(fullpath, path);
2079-
char *sptr = strrchr(fullpath, '/');
2080-
if (sptr == NULL)
2081-
sptr = fullpath;
2082-
else
2083-
sptr++;
2084-
strcpy(sptr, newname);
2085-
delete newname;
2086-
newname = MCS_resolvepath(fullpath);
2087-
delete fullpath;
2088-
}
20892088
return newname;
20902089
#endif /* MCS_resolvepath_dsk_lnx */
20912090
if (MCStringGetLength(p_path) == 0)
@@ -2130,12 +2129,30 @@ class MCLinuxDesktop: public MCSystemInterface
21302129
else
21312130
t_tilde_path = p_path;
21322131
}
2132+
else if (MCStringGetNativeCharAtIndex(p_path, 0) != '/')
2133+
{
2134+
// SN-2015-06-05: [[ Bug 15432 ]] Fix resolvepath on Linux: we want an
2135+
// absolute path.
2136+
MCAutoStringRef t_curdir;
2137+
MCS_getcurdir(&t_curdir);
2138+
2139+
if (!MCStringFormat(&t_tilde_path, "%@/%@", *t_curdir, p_path))
2140+
{
2141+
return false;
2142+
}
2143+
}
21332144
else
21342145
t_tilde_path = p_path;
21352146

21362147
// SN-2014-12-18: [[ Bug 14001 ]] Update the server file resolution to use realpath
21372148
// so that we get the absolute path (needed for MCcmd for instance).
2138-
#ifdef _SERVER
2149+
// SN-2015-06-08: Use realpath on desktop as well.
2150+
#ifndef _SERVER
2151+
// IM-2012-07-23
2152+
// Keep (somewhat odd) semantics of the original function for now
2153+
if (!MCS_lnx_is_link(*t_tilde_path))
2154+
return MCStringCopy(*t_tilde_path, r_resolved_path);
2155+
#endif
21392156
MCAutoStringRefAsSysString t_tilde_path_sys;
21402157
t_tilde_path_sys . Lock(*t_tilde_path);
21412158

@@ -2155,40 +2172,6 @@ class MCLinuxDesktop: public MCSystemInterface
21552172
MCMemoryDelete(t_resolved_path);
21562173

21572174
return t_success;
2158-
#else
2159-
2160-
// IM-2012-07-23
2161-
// Keep (somewhat odd) semantics of the original function for now
2162-
if (!MCS_lnx_is_link(*t_tilde_path))
2163-
return MCStringCopy(*t_tilde_path, r_resolved_path);
2164-
2165-
MCAutoStringRef t_newname;
2166-
if (!MCS_lnx_readlink(*t_tilde_path, &t_newname))
2167-
return false;
2168-
2169-
if (MCStringGetCharAtIndex(*t_newname, 0) != '/')
2170-
{
2171-
MCAutoStringRef t_resolved;
2172-
2173-
uindex_t t_last_component;
2174-
uindex_t t_path_length;
2175-
2176-
t_path_length = MCStringGetLength(p_path);
2177-
2178-
if (MCStringLastIndexOfChar(p_path, '/', t_path_length, kMCStringOptionCompareExact, t_last_component))
2179-
t_last_component++;
2180-
else
2181-
t_last_component = 0;
2182-
2183-
if (!MCStringMutableCopySubstring(p_path, MCRangeMake(0, t_last_component), &t_resolved) ||
2184-
!MCStringAppend(*t_resolved, *t_newname))
2185-
return false;
2186-
2187-
return MCStringCopy(*t_resolved, r_resolved_path);
2188-
}
2189-
else
2190-
return MCStringCopy(*t_newname, r_resolved_path);
2191-
#endif
21922175
}
21932176

21942177
virtual bool LongFilePath(MCStringRef p_path, MCStringRef& r_long_path)

engine/src/dskmac.cpp

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6380,30 +6380,17 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
63806380
struct stat buf;
63816381
if (lstat(tildepath, &buf) != 0 || !S_ISLNK(buf.st_mode))
63826382
return tildepath;
6383-
int4 size;
63846383
char *newname = new char[PATH_MAX + 2];
6385-
if ((size = readlink(tildepath, newname, PATH_MAX)) < 0)
6384+
6385+
// SN-2015-06-05: [[ Bug 15432 ]] Use realpath to solve the symlink.
6386+
if (realpath(tildepath, newname) == NULL)
63866387
{
6387-
delete tildepath;
6388+
// Clear the memory in case of failure
63886389
delete newname;
6389-
return NULL;
6390+
newname = NULL;
63906391
}
6392+
63916393
delete tildepath;
6392-
newname[size] = '\0';
6393-
if (newname[0] != '/')
6394-
{
6395-
char *fullpath = new char[strlen(path) + strlen(newname) + 2];
6396-
strcpy(fullpath, path);
6397-
char *sptr = strrchr(fullpath, '/');
6398-
if (sptr == NULL)
6399-
sptr = fullpath;
6400-
else
6401-
sptr++;
6402-
strcpy(sptr, newname);
6403-
delete newname;
6404-
newname = MCS_resolvepath(fullpath);
6405-
delete fullpath;
6406-
}
64076394
return newname;
64086395
#endif /* MCS_resolvepath_dsk_mac */
64096396
if (MCStringGetLength(p_path) == 0)
@@ -6461,32 +6448,29 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
64616448
if (!MCS_mac_is_link(*t_fullpath))
64626449
return MCStringCopy(*t_fullpath, r_resolved_path);
64636450

6464-
MCAutoStringRef t_newname;
6465-
if (!MCS_mac_readlink(*t_fullpath, &t_newname))
6466-
return false;
6467-
6468-
// IM - Should we really be using the original p_path parameter here?
6469-
// seems like we should use the computed t_fullpath value.
6470-
if (MCStringGetCharAtIndex(*t_newname, 0) != '/')
6471-
{
6472-
MCAutoStringRef t_resolved;
6473-
6474-
uindex_t t_last_component;
6475-
uindex_t t_path_length;
6476-
6477-
if (MCStringLastIndexOfChar(p_path, '/', MCStringGetLength(p_path), kMCStringOptionCompareExact, t_last_component))
6478-
t_last_component++;
6479-
else
6480-
t_last_component = 0;
6481-
6482-
if (!MCStringMutableCopySubstring(p_path, MCRangeMake(0, t_last_component), &t_resolved) ||
6483-
!MCStringAppend(*t_resolved, *t_newname))
6484-
return false;
6485-
6486-
return MCStringCopy(*t_resolved, r_resolved_path);
6487-
}
6451+
// SN-2015-06-08: [[ Bug 15432 ]] Use realpath to solve the symlink
6452+
MCAutoStringRefAsUTF8String t_utf8_path;
6453+
bool t_success;
6454+
t_success = true;
6455+
6456+
if (t_success)
6457+
t_success = t_utf8_path . Lock(*t_fullpath);
6458+
6459+
char *t_resolved_path;
6460+
6461+
t_resolved_path = realpath(*t_utf8_path, NULL);
6462+
6463+
// If the does not exist, then realpath will fail: we want to
6464+
// return something though, so we keep the input path (as it
6465+
// is done for desktop).
6466+
if (t_resolved_path != NULL)
6467+
t_success = MCStringCreateWithBytes((const byte_t*)t_resolved_path, strlen(t_resolved_path), kMCStringEncodingUTF8, false, r_resolved_path);
64886468
else
6489-
return MCStringCopy(*t_newname, r_resolved_path);
6469+
t_success = false;
6470+
6471+
MCMemoryDelete(t_resolved_path);
6472+
6473+
return t_success;
64906474
}
64916475

64926476
virtual IO_handle DeployOpen(MCStringRef p_path, intenum_t p_mode)

engine/src/execpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,7 @@ Exec_stat MCExecPoint::eval(MCExecPoint &ep)
25592559
Exec_stat stat = ES_ERROR;
25602560
if (sp.parseexp(False, True, &exp) == PS_NORMAL && sp.next(type) == PS_EOF)
25612561
{
2562-
stat = exp->eval(*this);
2562+
stat = exp->eval(ep);
25632563
grabsvalue();
25642564
}
25652565
delete exp;

engine/src/globals.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,10 +1233,7 @@ int X_close(void)
12331233
while (MCcur_effects != NULL)
12341234
{
12351235
MCEffectList *veptr = MCcur_effects;
1236-
MCcur_effects = MCcur_effects->getnext();
1237-
// AL-2014-08-14: [[ Bug 13176 ]] Release visual effect strings
1238-
MCValueRelease(veptr -> name);
1239-
MCValueRelease(veptr -> sound);
1236+
MCcur_effects = MCcur_effects->getnext();
12401237
delete veptr;
12411238
}
12421239

engine/src/lnxspec.cpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -670,37 +670,36 @@ char *MCS_resolvepath(const char *path)
670670
}
671671
delete tpath;
672672
}
673-
else
674-
tildepath = strclone(path);
673+
else if (path[0] != '/')
674+
{
675+
// SN-2015-06-05: [[ Bug 15432 ]] Fix resolvepath on Linux: we want an
676+
// absolute path.
677+
char *t_curfolder;
678+
t_curfolder = MCS_getcurdir();
679+
tildepath = new char[strlen(t_curfolder) + strlen(path) + 2];
680+
/* UNCHECKED */ sprintf(tildepath, "%s/%s", t_curfolder, path);
681+
682+
delete t_curfolder;
683+
}
684+
else
685+
tildepath = strclone(path);
675686

676687
struct stat64 buf;
677688
if (lstat64(tildepath, &buf) != 0 || !S_ISLNK(buf.st_mode))
678689
return tildepath;
679-
int4 size;
680-
char *newname = new char[PATH_MAX + 2];
681-
if ((size = readlink(tildepath, newname, PATH_MAX)) < 0)
682-
{
683-
delete tildepath;
684-
delete newname;
685-
return NULL;
686-
}
687-
delete tildepath;
688-
newname[size] = '\0';
689-
if (newname[0] != '/')
690-
{
691-
char *fullpath = new char[strlen(path) + strlen(newname) + 2];
692-
strcpy(fullpath, path);
693-
char *sptr = strrchr(fullpath, '/');
694-
if (sptr == NULL)
695-
sptr = fullpath;
696-
else
697-
sptr++;
698-
strcpy(sptr, newname);
699-
delete newname;
700-
newname = MCS_resolvepath(fullpath);
701-
delete fullpath;
702-
}
703-
return newname;
690+
691+
char *newname = new char[PATH_MAX + 2];
692+
693+
// SN-2015-06-05: [[ Bug 15432 ]] Use realpath to solve the symlink.
694+
if (realpath(tildepath, newname) == NULL)
695+
{
696+
// Clear the memory in case of failure
697+
delete newname;
698+
newname = NULL;
699+
}
700+
701+
delete tildepath;
702+
return newname;
704703
}
705704

706705
char *MCS_get_canonical_path(const char *p_path)

engine/src/osxfiles.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,31 +2444,19 @@ char *MCS_resolvepath(const char *path)
24442444
struct stat buf;
24452445
if (lstat(tildepath, &buf) != 0 || !S_ISLNK(buf.st_mode))
24462446
return tildepath;
2447-
int4 size;
2448-
char *newname = new char[PATH_MAX + 2];
2449-
if ((size = readlink(tildepath, newname, PATH_MAX)) < 0)
2450-
{
2451-
delete tildepath;
2452-
delete newname;
2453-
return NULL;
2454-
}
2455-
delete tildepath;
2456-
newname[size] = '\0';
2457-
if (newname[0] != '/')
2458-
{
2459-
char *fullpath = new char[strlen(path) + strlen(newname) + 2];
2460-
strcpy(fullpath, path);
2461-
char *sptr = strrchr(fullpath, '/');
2462-
if (sptr == NULL)
2463-
sptr = fullpath;
2464-
else
2465-
sptr++;
2466-
strcpy(sptr, newname);
2467-
delete newname;
2468-
newname = MCS_resolvepath(fullpath);
2469-
delete fullpath;
2470-
}
2471-
return newname;
2447+
2448+
char *newname = new char[PATH_MAX + 2];
2449+
2450+
// SN-2015-06-05: [[ Bug 15432 ]] Use realpath to solve the symlink.
2451+
if (realpath(tildepath, newname) == NULL)
2452+
{
2453+
// Clear the memory in case of failure
2454+
delete newname;
2455+
newname = NULL;
2456+
}
2457+
2458+
delete tildepath;
2459+
return newname;
24722460
}
24732461

24742462
Boolean MCS_rename(const char *oname, const char *nname)

engine/src/player.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ MCPropertyInfo MCPlayer::kProperties[] =
7171
// SN-2014-08-06: [[ Bug 13115 ]] Missing formatted (width|height) in the property table
7272
DEFINE_RO_OBJ_PROPERTY(P_FORMATTED_HEIGHT, Int32, MCPlayer, FormattedHeight)
7373
DEFINE_RO_OBJ_PROPERTY(P_FORMATTED_WIDTH, Int32, MCPlayer, FormattedWidth)
74+
DEFINE_RW_OBJ_PROPERTY(P_DONT_USE_QT, Bool, MCPlayer, DontUseQT)
7475
#ifdef FEATURE_PLATFORM_PLAYER
7576
DEFINE_RO_OBJ_ENUM_PROPERTY(P_STATUS, InterfacePlayerStatus, MCPlayer, Status)
76-
DEFINE_RW_OBJ_PROPERTY(P_DONT_USE_QT, Bool, MCPlayer, DontUseQT)
7777
#endif
7878
};
7979

0 commit comments

Comments
 (0)