Skip to content

Commit 09fe8b0

Browse files
committed
Merge branch 'develop' into 'main'
New GDX release 7.11.14 See merge request devel/gdx!103
2 parents b11af19 + 34469b4 commit 09fe8b0

File tree

11 files changed

+101
-41
lines changed

11 files changed

+101
-41
lines changed

.gitlab-ci.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ variables:
3434
build-leg-image:
3535
extends: .build-leg-image
3636
script:
37-
- docker build -t registry.gams.com/devel/gdx/leg/builder-gdx:latest ci/images/leg
38-
- docker push registry.gams.com/devel/gdx/leg/builder-gdx:latest
37+
- docker build -t $DEVEL_CONTAINER_REG/gdx/leg/builder-gdx:latest ci/images/leg
38+
- docker push $DEVEL_CONTAINER_REG/gdx/leg/builder-gdx:latest
3939

4040
build-leg-analyze-image:
4141
extends: .build-leg-image
4242
script:
43-
- docker build -t registry.gams.com/devel/gdx/leg/builder-analyze:latest ci/images/leg-analyze
44-
- docker push registry.gams.com/devel/gdx/leg/builder-analyze:latest
43+
- docker build -t $DEVEL_CONTAINER_REG/gdx/leg/builder-analyze:latest ci/images/leg-analyze
44+
- docker push $DEVEL_CONTAINER_REG/gdx/leg/builder-analyze:latest
4545

4646
build-leg-deploy-image:
4747
extends: .build-leg-image
4848
script:
49-
- docker build -t registry.gams.com/devel/gdx/leg/builder-deploy:latest ci/images/leg-deploy
50-
- docker push registry.gams.com/devel/gdx/leg/builder-deploy:latest
49+
- docker build -t $DEVEL_CONTAINER_REG/gdx/leg/builder-deploy:latest ci/images/leg-deploy
50+
- docker push $DEVEL_CONTAINER_REG/gdx/leg/builder-deploy:latest
5151

5252
#=======================================================================================================================
5353

@@ -56,7 +56,7 @@ apigenerator:
5656
tags: [linux]
5757
dependencies: []
5858
image:
59-
name: registry.gams.com/devel/gdx/leg/builder-gdx:latest
59+
name: $DEVEL_CONTAINER_REG/gdx/leg/builder-gdx:latest
6060
entrypoint: [ "" ]
6161
script:
6262
- mkdir -p apifiles
@@ -420,7 +420,7 @@ leak-check-leg:
420420
stage: leak-check
421421
tags: [linux]
422422
image:
423-
name: registry.gams.com/devel/ciscripts/leg/builder-valgrind-codequality:latest
423+
name: $DEVEL_CONTAINER_REG/ciscripts/leg/builder-valgrind-codequality:latest
424424
entrypoint: [""]
425425
when: manual # FIXME: resolve GLIBC_2.* not found!
426426
needs: [fetch-ci-scripts,build-debug-leg]
@@ -523,7 +523,7 @@ deploy-gitlab-github:
523523
tags: [linux]
524524
needs: [build-leg,build-dac,build-wei,apigenerator]
525525
image:
526-
name: registry.gams.com/devel/gdx/leg/builder-deploy:latest
526+
name: $DEVEL_CONTAINER_REG/gdx/leg/builder-deploy:latest
527527
entrypoint: [""] # prevent startup.sh
528528
script:
529529
- GDX_TAG_NAME="`python3 ci/changelog_head.py tag_name`"

changelog.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
- 7.11.14:
3+
- Correctly deal with GDX files that have long absolute paths (>260 characters) in GDX library and all tools (`gdxdump`, `gdxdiff`, `gdxmerge`).
24
- 7.11.13:
35
- Fixed the processing of commands via a text file (`@filename`) in `gdxmerge`.
46
- Corrected documentation of `SyNr` argument of `gdxSymbolGetDomain(X)`.

src/gdlib/statlibobj.cpp

+20-11
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ bool TGMSStatusStream::checkfile( std::string &msg )
717717
{
718718
if( Fstatusopen )
719719
{
720-
fclose(Ffstat);
720+
std::fclose(Ffstat);
721721
Ffstat = nullptr;
722722
Fstatusopen = false;
723723
msg.clear();
@@ -901,7 +901,8 @@ bool TGMSStatusStream::StatusDumpNext( std::string &msg )
901901

902902
if( feof(Ffstat) )
903903
{
904-
fclose(Ffstat);
904+
std::fclose(Ffstat);
905+
Ffstat = nullptr;
905906
Fstatusopen = false;
906907
msg.clear();
907908
return false;
@@ -1017,7 +1018,8 @@ bool TGMSStatusStream::StatusProcessNext( stattypes::tstatusproc &statusproc, st
10171018
case '3':
10181019
statusproc = stattypes::statusEOF;
10191020
msg1 = "End-of-File request";
1020-
fclose( Ffstat );
1021+
std::fclose( Ffstat );
1022+
Ffstat = nullptr;
10211023
Fstatusopen = false;
10221024
return false;
10231025

@@ -1154,7 +1156,8 @@ bool TGMSStatusStream::StatusProcessNext( stattypes::tstatusproc &statusproc, st
11541156
msg1 = "End-of-File reached";
11551157
msg2.clear();
11561158
num = 0;
1157-
fclose( Ffstat );
1159+
std::fclose( Ffstat );
1160+
Ffstat = nullptr;
11581161
Fstatusopen = false;
11591162
return false;
11601163
}
@@ -1163,7 +1166,8 @@ void TGMSStatusStream::StatusSetFilename( const std::string &fn )
11631166
{
11641167
if( Fstatusopen )
11651168
{
1166-
fclose( Ffstat );
1169+
std::fclose( Ffstat );
1170+
Ffstat = nullptr;
11671171
Fstatusopen = false;
11681172
StatusErrorFree();
11691173
}
@@ -1183,7 +1187,8 @@ bool TGMSStatusStream::StatusDummy( std::string &msg )
11831187
writeln_gf( "**** SOLVER DID NOT WRITE A STATUS FILE ****" );
11841188
writeln_gf( "" );
11851189
writeln_gf( "=3" );
1186-
fclose( Ffstat );
1190+
std::fclose( Ffstat );
1191+
Ffstat = nullptr;
11871192
Fstatusopen = false;
11881193
msg.clear();
11891194
return true;
@@ -1295,7 +1300,8 @@ void TGMSStatusStream::StatusClose()
12951300
{
12961301
if( Fstatusopen )
12971302
{
1298-
fclose( Ffstat );
1303+
std::fclose( Ffstat );
1304+
Ffstat = nullptr;
12991305
Fstatusopen = false;
13001306
}
13011307
}
@@ -1322,19 +1328,22 @@ bool TGMSStatusStream::StatusFileOpen( const tfileaction AAction, std::string &m
13221328
// 012345
13231329
// '**** SOLVER DID NOT WRITE A STATUS FILE'
13241330
newstat = s.substr(5, 14) == "SOLVER DID NOT"s;
1325-
fclose( Ffstat );
1331+
std::fclose( Ffstat );
1332+
Ffstat = nullptr;
1333+
Fstatusopen = false;
13261334
} else newstat = true;
13271335
//delete Ffstat;
13281336

13291337
// FIXME: Finish porting!
1338+
// ...
1339+
STUBWARN();
1340+
// TODO: Implement me!
13301341

13311342
if(!newstat && AAction == forAppend) {
13321343
}
13331344
return false;
13341345

1335-
// ...
1336-
STUBWARN();
1337-
// TODO: Implement me!
1346+
13381347
}
13391348

13401349
void TGMSStatusStream::StatusWriteLn( const std::string &s ) const

src/gdlib/utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ void stocp( const std::string &s, char *cp )
586586

587587
int strCompare( const std::string_view S1, const std::string_view S2, const bool caseInsensitive )
588588
{
589-
if( S1.empty() || S2.empty() ) return b2i( !S1.empty() ) - b2i( !S2.empty() );
589+
if( S1.empty() || S2.empty() ) return static_cast<int>( !S1.empty() ) - static_cast<int>( !S2.empty() );
590590
auto L = S1.length();
591591
if( L > S2.length() ) L = S2.length();
592592
for( size_t K {}; K < L; K++ )

src/gdlib/utils.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,6 @@ inline auto ord( const char c )
753753
return static_cast<unsigned char>( c );
754754
}
755755

756-
inline auto b2i(const bool x) { return x ? 1 : 0; }
757-
758756
inline int pos( const char c, const std::string &s )
759757
{
760758
const auto p { s.find( c ) };

src/rtl/p3utils.cpp

+20-11
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,9 @@ static inline bool p3IsValidHandle(const Tp3FileHandle h) {
353353
int p3FileOpen( const std::string &fName, Tp3FileOpenAction mode, Tp3FileHandle &h )
354354
{
355355
#if defined(_WIN32)
356-
DWORD lowMode;
357-
HANDLE hFile;
356+
HANDLE hFile {};
358357

359-
lowMode = mode & 3;
358+
const DWORD lowMode = mode & 3;
360359
if (3 == lowMode) {
361360
h = INVALID_HANDLE_VALUE;
362361
return ERROR_INVALID_PARAMETER;
@@ -373,20 +372,30 @@ int p3FileOpen( const std::string &fName, Tp3FileOpenAction mode, Tp3FileHandle
373372
}
374373
}
375374
else
376-
hFile = CreateFileA (fName.c_str(), accessMode[lowMode], shareMode[lowMode], nullptr,
375+
{
376+
bool longAbsPath {};
377+
#if defined(_WIN32)
378+
longAbsPath = fName.length() > MAX_PATH && std::isalpha(fName.front()) && fName[1] == ':';
379+
#endif
380+
if(longAbsPath)
381+
hFile = CreateFileA ((R"(\\?\)"+fName).c_str(), accessMode[lowMode], shareMode[lowMode], nullptr,
377382
createHow[lowMode], FILE_ATTRIBUTE_NORMAL, nullptr);
378-
if (INVALID_HANDLE_VALUE == hFile) {
383+
else
384+
hFile = CreateFileA (fName.c_str(), accessMode[lowMode], shareMode[lowMode], nullptr,
385+
createHow[lowMode], FILE_ATTRIBUTE_NORMAL, nullptr);
386+
}
387+
if( INVALID_HANDLE_VALUE == hFile )
388+
{
379389
h = INVALID_HANDLE_VALUE;
380-
int result = win2c(static_cast<int>(GetLastError()));
381-
if (0 == result) { /* ouch: just pick a likely but non-specific code */
390+
int result = win2c( static_cast<int>( GetLastError() ) );
391+
if( 0 == result )
392+
{ /* ouch: just pick a likely but non-specific code */
382393
result = EACCES;
383394
}
384395
return result;
385396
}
386-
else {
387-
h = hFile;
388-
return 0;
389-
}
397+
h = hFile;
398+
return 0;
390399
#else
391400
if (fName.empty()) {
392401
if (mode == Tp3FileOpenAction::p3OpenRead)

src/rtl/sysutils_p3.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ std::string ExtractFileExt( const std::string &FileName )
9595
bool FileExists( const std::string &FileName )
9696
{
9797
#if defined(_WIN32)
98+
// put \\?\ in front of long absolute paths
99+
if(FileName.length() > MAX_PATH && std::isalpha(FileName.front()) && FileName[1] == ':')
100+
return !_access((R"(\\?\)"+FileName).c_str(), 0);
98101
return !_access(FileName.c_str(), 0);
99102
#else
100103
return !access(FileName.c_str(), F_OK);
@@ -450,7 +453,11 @@ int FindFirst(const std::string &Path, const int Attr, TSearchRec &F )
450453
#if defined(_WIN32)
451454
HANDLE fHandle;
452455
F.FindData = new _WIN32_FIND_DATAA{}; // will be freed in F destructor
453-
F.FindHandle = fHandle = FindFirstFileA(Path.c_str(), F.FindData );
456+
if(Path.length() > MAX_PATH && std::isalpha(Path.front()) && Path[1] == ':')
457+
fHandle = FindFirstFileA((R"(\\?\)"+Path).c_str(), F.FindData );
458+
else
459+
fHandle = FindFirstFileA(Path.c_str(), F.FindData );
460+
F.FindHandle = fHandle;
454461
if (INVALID_HANDLE_VALUE != fHandle) {
455462
auto res = FindMatchingFile(F);
456463
if (res != 0)

src/tests/rtl/sysutilsp3tests.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <filesystem>
3232
#include <algorithm>
3333

34+
35+
3436
using namespace std::literals::string_literals;
3537
using namespace rtl::sysutils_p3;
3638

@@ -193,6 +195,37 @@ TEST_CASE("Test Find{First,Next,Close}")
193195
}
194196
}
195197

198+
TEST_CASE( "Test file exists" )
199+
{
200+
char sep = '/';
201+
#if defined( _WIN32 )
202+
sep = '\\';
203+
#endif
204+
std::string foldername( 100, '\0' );
205+
for( int i {}; i < static_cast<int>( foldername.length() ); i++ )
206+
foldername[i] = static_cast<char>( '0' + i % 10 );
207+
std::filesystem::create_directory( foldername );
208+
std::filesystem::create_directory( foldername + sep + foldername );
209+
std::string gdxFn { GetCurrentDir() + sep + foldername + sep + foldername + sep + foldername + ".gdx"s },
210+
longGdxFn { gdxFn };
211+
#if defined( _WIN32 )
212+
longGdxFn = R"(\\?\)" + gdxFn;
213+
#endif
214+
std::ofstream ofs { longGdxFn };
215+
ofs.close();
216+
217+
REQUIRE( FileExists( gdxFn ) );
218+
219+
std::filesystem::remove( longGdxFn );
220+
REQUIRE_FALSE( FileExists( gdxFn ) );
221+
222+
std::filesystem::remove( foldername + sep + foldername );
223+
REQUIRE_FALSE( FileExists( foldername + sep + foldername ) );
224+
225+
std::filesystem::remove( foldername );
226+
REQUIRE_FALSE( FileExists( foldername ) );
227+
}
228+
196229
TEST_SUITE_END();
197230

198231
}

src/tools/gdxdiff/gdxdiff.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void CheckGDXError( const gdxHandle_t &PGX )
131131
}
132132
}
133133

134-
void OpenGDX( const library::ShortString_t &fn, gdxHandle_t &PGX )
134+
void OpenGDX( const std::string &fn, gdxHandle_t &PGX )
135135
{
136136
if( !rtl::sysutils_p3::FileExists( fn ) )
137137
FatalError( "Input file not found " + fn, static_cast<int>( ErrorCode_t::ERR_NOFILE ) );
@@ -735,7 +735,7 @@ void Usage( const library::AuditLine_t &AuditLine )
735735
// Function is empty in Delphi code
736736
// void CopyAcronyms( const gdxHandle_t &PGX ) {}
737737

738-
void CheckFile( library::ShortString_t &fn )
738+
void CheckFile( std::string &fn )
739739
{
740740
if( !rtl::sysutils_p3::FileExists( fn ) && gdlib::strutilx::ExtractFileExtEx( fn ).empty() )
741741
fn = gdlib::strutilx::ChangeFileExtEx( fn, ".gdx" );
@@ -744,7 +744,8 @@ void CheckFile( library::ShortString_t &fn )
744744
int main( const int argc, const char *argv[] )
745745
{
746746
int ErrorCode, ErrNr, Dim, iST, StrNr;
747-
library::ShortString_t S, ID, InFile1, InFile2, DiffFileName;
747+
library::ShortString_t S, ID, DiffFileName;
748+
std::string InFile1, InFile2;
748749
std::map<library::ShortString_t, int> IDTable;
749750
bool UsingIDE, RenameOK;
750751
gdxStrIndex_t StrKeys {};

src/tools/gdxdiff/gdxdiff.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void FatalError2( const std::string &Msg1, const std::string &Msg2, int ErrNr );
106106

107107
void CheckGDXError( const gdxHandle_t &PGX );
108108

109-
void OpenGDX( const library::ShortString_t &fn, gdxHandle_t &PGX );
109+
void OpenGDX( const std::string &fn, gdxHandle_t &PGX );
110110

111111
void RegisterDiffUELs();
112112

@@ -118,7 +118,7 @@ void Usage( const library::AuditLine_t &AuditLine );
118118

119119
// void CopyAcronyms( const gdxHandle_t &PGX );
120120

121-
void CheckFile( library::ShortString_t &fn );
121+
void CheckFile( std::string &fn );
122122

123123
int main( int argc, const char *argv[] );
124124

src/tools/gdxmerge/gdxmerge.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ int SymbolList_t::AddSymbol( const std::string &AName, const int ADim, const gdx
151151
void SymbolList_t::AddPGXFile( const int FNr, const ProcessPass_t Pass )
152152
{
153153
bool FrstError;
154-
library::ShortString_t SyName, FileName;
154+
library::ShortString_t SyName;
155+
std::string FileName;
155156

156157
auto CheckError = [&]( const bool Cnd, const std::string &Msg ) -> bool {
157158
bool Result { !Cnd };

0 commit comments

Comments
 (0)