Skip to content

Commit d50b5bf

Browse files
committed
refs modelica#4473 Remove legacy behaviour
1 parent be949b2 commit d50b5bf

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Modelica/Resources/C-Sources/ModelicaInternal.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
*/
3131

3232
/* Changelog:
33+
Oct. 20, 2024: by Thomas Beutlich
34+
Removed legacy behaviour in ModelicaInternal_stat for
35+
MSVC Visual Studio >= 2015 (ticket #4473)
36+
3337
Jan. 15, 2024: by Thomas Beutlich
3438
Utilized ModelicaDuplicateString and
3539
ModelicaDuplicateStringWithErrorReturn (ticket #3686)
@@ -402,10 +406,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
402406
struct _stat fileInfo;
403407
int statReturn = _stat(name, &fileInfo);
404408
if (0 != statReturn) {
405-
/* For some reason _stat requires "a:\" and "a:\test1" but fails
406-
* on "a:" and "a:\test1\", respectively. It could be handled in the
407-
* Modelica code, but seems better to have it here.
408-
*/
409+
/* _stat requires "a:\" instead of "a:" */
409410
const char* firstSlash = strpbrk(name, "/\\");
410411
const char* firstColon = strchr(name, ':');
411412
const char c = (NULL != firstColon) ? firstColon[1] : '\0';
@@ -419,6 +420,10 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
419420
free(nameTmp);
420421
}
421422
}
423+
#if defined(_MSC_VER) && _MSC_VER >= 1900
424+
/* _stat accepts both "a:\dir" and "a:\dir\" */
425+
#else
426+
/* _stat requires "a:\dir" instead of "a:\dir\" */
422427
else if (NULL != firstSlash && len > 1 &&
423428
('/' == name[len - 1] || '\\' == name[len - 1])) {
424429
char* nameTmp = (char*)malloc(len*(sizeof(char)));
@@ -429,6 +434,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
429434
free(nameTmp);
430435
}
431436
}
437+
#endif
432438
}
433439
if ( statReturn != 0 ) {
434440
type = FileType_NoFile;

0 commit comments

Comments
 (0)