Skip to content

Commit

Permalink
refs modelica#4473 Remove legacy behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
beutlich committed Oct 20, 2024
1 parent 8e7876b commit aa3e239
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Modelica/Resources/C-Sources/ModelicaInternal.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
*/

/* Changelog:
Oct. 20, 2024: by Thomas Beutlich
Removed legacy behaviour in ModelicaInternal_stat for
MSVC Visual Studio >= 2015 (ticket #4473)
Jan. 15, 2024: by Thomas Beutlich
Utilized ModelicaDuplicateString and
ModelicaDuplicateStringWithErrorReturn (ticket #3686)
Expand Down Expand Up @@ -402,10 +406,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
struct _stat fileInfo;
int statReturn = _stat(name, &fileInfo);
if (0 != statReturn) {
/* For some reason _stat requires "a:\" and "a:\test1" but fails
* on "a:" and "a:\test1\", respectively. It could be handled in the
* Modelica code, but seems better to have it here.
*/
/* _stat requires "a:\" instead of "a:" */
const char* firstSlash = strpbrk(name, "/\\");
const char* firstColon = strchr(name, ':');
const char c = (NULL != firstColon) ? firstColon[1] : '\0';
Expand All @@ -419,6 +420,10 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
free(nameTmp);
}
}
#if defined(_MSC_VER) && _MSC_VER >= 1900
/* _stat accepts both "a:\dir" and "a:\dir\" */
#else
/* _stat requires "a:\dir" instead of "a:\dir\" */
else if (NULL != firstSlash && len > 1 &&
('/' == name[len - 1] || '\\' == name[len - 1])) {
char* nameTmp = (char*)malloc(len*(sizeof(char)));
Expand All @@ -429,6 +434,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
free(nameTmp);
}
}
#endif
}
if ( statReturn != 0 ) {
type = FileType_NoFile;
Expand Down

0 comments on commit aa3e239

Please sign in to comment.