Skip to content

Commit 103c86b

Browse files
Merge branch 'develop-7.0' of https://github.com/runrev/livecode into develop-7.0-gyp
2 parents e064690 + 6ac7196 commit 103c86b

12 files changed

Lines changed: 167 additions & 164 deletions

File tree

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
@@ -972,8 +972,11 @@ IO_stat MCDispatch::loadfile(MCStringRef p_name, MCStack *&sptr)
972972
{
973973
if ((stream = MCS_open(p_name, kMCOpenFileModeRead, True, False, 0)) != NULL)
974974
{
975-
// This should probably use resolvepath().
976-
// SN-2015-06-03: [[ Bug 15432 ]] Use resolvepath
975+
// SN-20015-06-01: [[ Bug 15432 ]] We want to use MCS_resolvepath to
976+
// keep consistency and let '~' be resolved as it is in MCS_open
977+
// MCS_resolve_path leaves a backslash-delimited path on Windows,
978+
// and MCS_get_canonical_path is made to cope with this.
979+
// In 7.0, MCS_resolvepath does not return a native path.
977980
t_found = MCS_resolvepath(p_name, &t_open_path);
978981
}
979982
}
@@ -990,10 +993,7 @@ IO_stat MCDispatch::loadfile(MCStringRef p_name, MCStack *&sptr)
990993
t_leaf_name = p_name;
991994
if ((stream = MCS_open(*t_leaf_name, kMCOpenFileModeRead, True, False, 0)) != NULL)
992995
{
993-
MCAutoStringRef t_curpath;
994-
/* UNCHECKED */ MCS_getcurdir(&t_curpath);
995-
/* UNCHECKED */ MCStringFormat(&t_open_path, "%@/%@", *t_curpath, p_name);
996-
t_found = true;
996+
t_found = MCS_resolvepath(*t_leaf_name, &t_open_path);
997997
}
998998

999999
if (!t_found)

engine/src/dsklnx.cpp

Lines changed: 36 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,36 +2050,35 @@ class MCLinuxDesktop: public MCSystemInterface
20502050
}
20512051
delete tpath;
20522052
}
2053+
else if (path[0] != '/')
2054+
{
2055+
// SN-2015-06-05: [[ Bug 15432 ]] Fix resolvepath on Linux: we want an
2056+
// absolute path.
2057+
char *t_curfolder;
2058+
t_curfolder = MCS_getcurdir();
2059+
tildepath = new char[strlen(t_curfolder) + strlen(path) + 2];
2060+
/* UNCHECKED */ sprintf(tildepath, "%s/%s", t_curfolder, path);
2061+
2062+
delete t_curfolder;
2063+
}
20532064
else
20542065
tildepath = strclone(path);
20552066

20562067
struct stat64 buf;
20572068
if (lstat64(tildepath, &buf) != 0 || !S_ISLNK(buf.st_mode))
20582069
return tildepath;
2059-
int4 size;
2070+
20602071
char *newname = new char[PATH_MAX + 2];
2061-
if ((size = readlink(tildepath, newname, PATH_MAX)) < 0)
2072+
2073+
// SN-2015-06-05: [[ Bug 15432 ]] Use realpath to solve the symlink.
2074+
if (realpath(tildepath, newname) == NULL)
20622075
{
2063-
delete tildepath;
2076+
// Clear the memory in case of failure
20642077
delete newname;
2065-
return NULL;
2078+
newname = NULL;
20662079
}
2080+
20672081
delete tildepath;
2068-
newname[size] = '\0';
2069-
if (newname[0] != '/')
2070-
{
2071-
char *fullpath = new char[strlen(path) + strlen(newname) + 2];
2072-
strcpy(fullpath, path);
2073-
char *sptr = strrchr(fullpath, '/');
2074-
if (sptr == NULL)
2075-
sptr = fullpath;
2076-
else
2077-
sptr++;
2078-
strcpy(sptr, newname);
2079-
delete newname;
2080-
newname = MCS_resolvepath(fullpath);
2081-
delete fullpath;
2082-
}
20832082
return newname;
20842083
#endif /* MCS_resolvepath_dsk_lnx */
20852084
if (MCStringGetLength(p_path) == 0)
@@ -2124,12 +2123,28 @@ class MCLinuxDesktop: public MCSystemInterface
21242123
else
21252124
t_tilde_path = p_path;
21262125
}
2126+
else if (MCStringGetNativeCharAtIndex(p_path, 0) != '/')
2127+
{
2128+
// SN-2015-06-05: [[ Bug 15432 ]] Fix resolvepath on Linux: we want an
2129+
// absolute path.
2130+
MCAutoStringRef t_curdir;
2131+
MCS_getcurdir(&t_curdir);
2132+
2133+
if (!MCStringFormat(&t_tilde_path, "%@/%@", *t_curdir, p_path))
2134+
return false;
2135+
}
21272136
else
21282137
t_tilde_path = p_path;
21292138

21302139
// SN-2014-12-18: [[ Bug 14001 ]] Update the server file resolution to use realpath
21312140
// so that we get the absolute path (needed for MCcmd for instance).
2132-
#ifdef _SERVER
2141+
// SN-2015-06-08: Use realpath on desktop as well.
2142+
#ifndef _SERVER
2143+
// IM-2012-07-23
2144+
// Keep (somewhat odd) semantics of the original function for now
2145+
if (!MCS_lnx_is_link(*t_tilde_path))
2146+
return MCStringCopy(*t_tilde_path, r_resolved_path);
2147+
#endif
21332148
MCAutoStringRefAsSysString t_tilde_path_sys;
21342149
t_tilde_path_sys . Lock(*t_tilde_path);
21352150

@@ -2144,45 +2159,11 @@ class MCLinuxDesktop: public MCSystemInterface
21442159
if (t_resolved_path != NULL)
21452160
t_success = MCStringCreateWithSysString(t_resolved_path, r_resolved_path);
21462161
else
2147-
t_success = MCStringCopy(*t_tilde_path, r_resolved_path);
2162+
t_success = false;
21482163

21492164
MCMemoryDelete(t_resolved_path);
21502165

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

21882169
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/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-platform.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,8 @@ MCPlayer::MCPlayer()
880880
m_should_attach = false;
881881
m_should_recreate = false;
882882

883-
dontuseqt = false;
884-
MCdontuseQT = false;
883+
dontuseqt = False;
884+
usingqt = False;
885885
}
886886

887887
MCPlayer::MCPlayer(const MCPlayer &sref) : MCControl(sref)

engine/src/srvposix.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,17 @@ struct MCPosixSystem: public MCSystemInterface
516516
else
517517
t_tilde_path = p_path;
518518
}
519+
else if (p_path[0] != '/')
520+
{
521+
// SN-2015-06-05: [[ Bug 15432 ]] Fix resolvepath on Linux: we want an
522+
// absolute path.
523+
char *t_curfolder;
524+
t_curfolder = MCS_getcurdir();
525+
t_tilde_path = new char[strlen(t_curfolder) + strlen(p_path) + 2];
526+
/* UNCHECKED */ sprintf(t_tilde_path, "%s/%s", t_curfolder, p_path);
527+
528+
delete t_curfolder;
529+
}
519530
else
520531
t_tilde_path = p_path;
521532

0 commit comments

Comments
 (0)