Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit d62dc1b

Browse files
committed
[[ Bug 20324 ]] Fix Windows drop files conversion
This patch adds a kMCNulString foudation constant and uses it when splitting the drop-files string in the Windows clipboard code. Previously it was attempting to use MCSTR("\0") which won't work as MCSTR's must be NUL-terminated.
1 parent bf53f84 commit d62dc1b

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

docs/notes/bugfix-20324.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Convert dropped file paths correctly on Windows

engine/src/w32-clipboard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ MCStringRef MCWin32RawClipboardCommon::DecodeTransferredFileList(MCDataRef p_dat
317317

318318
// Split the file name list into individual paths
319319
MCAutoArrayRef t_native_paths;
320-
if (!MCStringSplit(*t_decoded, MCSTR("\0"), NULL, kMCStringOptionCompareExact, &t_native_paths))
320+
if (!MCStringSplit(*t_decoded, kMCNulString, NULL, kMCStringOptionCompareExact, &t_native_paths))
321321
return nullptr;
322322

323323
uindex_t npaths = MCArrayGetCount(*t_native_paths);

libfoundation/include/foundation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,9 @@ MC_DLLEXPORT extern MCStringRef kMCLineEndString;
19491949
// The default string for '\t'.
19501950
MC_DLLEXPORT extern MCStringRef kMCTabString;
19511951

1952+
// The default string for '\0'.
1953+
MC_DLLEXPORT extern MCStringRef kMCNulString;
1954+
19521955
/////////
19531956

19541957
// Creates an MCStringRef wrapping the given constant c-string. Note that

libfoundation/src/foundation-string.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6228,6 +6228,7 @@ MC_DLLEXPORT_DEF MCStringRef kMCMixedString;
62286228
MC_DLLEXPORT_DEF MCStringRef kMCCommaString;
62296229
MC_DLLEXPORT_DEF MCStringRef kMCLineEndString;
62306230
MC_DLLEXPORT_DEF MCStringRef kMCTabString;
6231+
MC_DLLEXPORT_DEF MCStringRef kMCNulString;
62316232

62326233
bool __MCStringInitialize(void)
62336234
{
@@ -6251,6 +6252,9 @@ bool __MCStringInitialize(void)
62516252

62526253
if (!MCStringCreateWithNativeChars((const char_t *)"\t", 1, kMCTabString))
62536254
return false;
6255+
6256+
if (!MCStringCreateWithNativeChars((const char_t *)"\0", 1, kMCNulString))
6257+
return false;
62546258

62556259
return true;
62566260
}
@@ -6272,6 +6276,8 @@ void __MCStringFinalize(void)
62726276
kMCLineEndString = nil;
62736277
MCValueRelease(kMCTabString);
62746278
kMCTabString = nil;
6279+
MCValueRelease(kMCNulString);
6280+
kMCNulString = nil;
62756281
}
62766282

62776283
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)