Skip to content

Commit 2dfaa69

Browse files
committed
cleanup IDE code
add OW "Compat" items method to 3-rd switch search pass
1 parent 86f39a1 commit 2dfaa69

File tree

8 files changed

+34
-52
lines changed

8 files changed

+34
-52
lines changed

bld/ide/lib/cpp/mfamily.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ bool WEXPORT MFamily::hasSwitches( bool setable )
127127
return( false );
128128
}
129129

130-
MSwitch* WEXPORT MFamily::findSwitch( WString& switchtag, long fixed_version, int kludge )
130+
MSwitch* WEXPORT MFamily::findSwitch( WString& swtag, long fixed_version, int kludge )
131131
{
132132
//
133133
// Open Watcom IDE configuration/project files are buggy
@@ -136,15 +136,13 @@ MSwitch* WEXPORT MFamily::findSwitch( WString& switchtag, long fixed_version, in
136136
// It is very hard to detect what was broken in each OW version because
137137
// there vere no change to version number of project files
138138
//
139+
// type of non-exact search is defined by kludge parameter
140+
//
139141
int icount = _switches.count();
140-
if( fixed_version == 0 || !isSetable( switchtag ) ) {
142+
if( fixed_version == 0 || !isSetable( swtag ) ) {
141143
for( int i = 0; i < icount; i++ ) {
142144
MSwitch* sw = (MSwitch*)_switches[i];
143-
if( sw->isTagEqual( switchtag, kludge ) ) {
144-
if( kludge == 1 ) {
145-
// upgrade switchtag to current configuration files version
146-
sw->getTag( switchtag );
147-
}
145+
if( sw->isTagEqual( swtag, kludge ) ) {
148146
return( sw );
149147
}
150148
}
@@ -153,11 +151,7 @@ MSwitch* WEXPORT MFamily::findSwitch( WString& switchtag, long fixed_version, in
153151
MSwitch* sw = (MSwitch*)_switches[i];
154152
if( !sw->isSetable() )
155153
continue;
156-
if( sw->isTagEqual( switchtag, kludge ) ) {
157-
if( kludge == 1 ) {
158-
// upgrade switchtag to current configuration files version
159-
sw->getTag( switchtag );
160-
}
154+
if( sw->isTagEqual( swtag, kludge ) ) {
161155
return( sw );
162156
}
163157
}

bld/ide/lib/cpp/mstate.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "mconfig.hpp"
3737
#include "mstate.hpp"
3838
#include "mrule.hpp" //temp
39+
#include "mtypo.hpp"
3940

4041
Define( MState )
4142

@@ -87,6 +88,20 @@ void WEXPORT MState::readSelf( WObjectFile& p )
8788
_switch = _tool->findSwitch( _switchTag, p.version() );
8889
if( _switch == NULL ) {
8990
_switch = _tool->findSwitch( _switchTag, p.version(), 1 );
91+
if( _switch == NULL ) {
92+
if( p.version() >= 40 && p.version() < 50 && _config->version() == 4 ) {
93+
//
94+
// hack for buggy version of configuration/project files
95+
//
96+
if( FixTypo( _switchTag ) != NULL ) {
97+
_switch = _tool->findSwitch( _switchTag, p.version() );
98+
}
99+
}
100+
}
101+
if( _switch != NULL ) {
102+
// upgrade swtag to current configuration files version
103+
_switch->getTag( _switchTag );
104+
}
90105
}
91106
if( p.version() > 27 ) {
92107
p.readObject( &_mode );

bld/ide/lib/cpp/mswitch.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,20 @@ void MSwitch::getTag( WString& tag )
105105
tag.concat( _text );
106106
}
107107

108-
bool MSwitch::isTagEqual( WString& switchtag, int kludge )
108+
bool MSwitch::isTagEqual( WString& swtag, int kludge )
109109
{
110110
WString tag;
111111

112112
tag = _mask;
113113
tag.concat( _text );
114-
if( tag == switchtag )
114+
if( tag == swtag )
115115
return( true );
116116
if( kludge == 1 ) {
117-
size_t jcount = switchtag.size();
117+
size_t jcount = swtag.size();
118118
if( jcount > MASK_SIZE && jcount == tag.size() ) {
119119
for( size_t j = 0; j < jcount; j++ ) {
120120
int ct = (unsigned char)tag[j];
121-
int cs = (unsigned char)switchtag[j];
121+
int cs = (unsigned char)swtag[j];
122122
if( ct == cs )
123123
continue;
124124
// mask must be same
@@ -140,25 +140,6 @@ bool MSwitch::isTagEqual( WString& switchtag, int kludge )
140140
return( false );
141141
}
142142

143-
#if IDE_CFG_VERSION_MAJOR > 4
144-
bool MSwitch::isTagEqual( MTool *tool, WString& switchtag, int kludge )
145-
{
146-
// first check mask
147-
for( int i = 0; i < MASK_SIZE; ++i ) {
148-
if( _mask[i] != switchtag[i] ) {
149-
return( false );
150-
}
151-
}
152-
// second check text/id
153-
WString tag = switchtag;
154-
tag.chop( MASK_SIZE );
155-
if( tool->findSwitchByText( _text, tag, kludge ) == NULL ) {
156-
return( false );
157-
}
158-
return( true );
159-
}
160-
#endif
161-
162143
MSwitch* MSwitch::addSwitch( WVList& list, const char* mask )
163144
{
164145
if( _mask.match( mask ) ) {

bld/ide/lib/cpp/mtool.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "wobjfile.hpp"
3636
#include "mconfig.hpp"
3737
#include "mfamily.hpp"
38-
#include "mtypo.hpp"
3938

4039
Define( MTool )
4140

@@ -101,7 +100,7 @@ void WEXPORT MTool::writeSelf( WObjectFile& p )
101100
}
102101
#endif
103102

104-
MSwitch* WEXPORT MTool::findSwitch( WString& switchtag, long fixed_version, int kludge )
103+
MSwitch* WEXPORT MTool::findSwitch( WString& swtag, long fixed_version, int kludge )
105104
{
106105
//
107106
// Open Watcom IDE configuration/project files are buggy
@@ -110,24 +109,18 @@ MSwitch* WEXPORT MTool::findSwitch( WString& switchtag, long fixed_version, int
110109
// It is very hard to detect what was broken in each OW version because
111110
// there vere no change to version number of project files
112111
//
113-
if( fixed_version != 0 && fixed_version < 50 && _config->version() < 5 ) {
114-
//
115-
// hack for buggy version of configuration/project files
116-
//
117-
FixTypo( switchtag );
118-
}
119112
int icount = _families.count();
120113
for( int i = 0; i < icount; i++ ) {
121114
MFamily* family = (MFamily*)_families[i];
122-
MSwitch* sw = family->findSwitch( switchtag, fixed_version, kludge );
115+
MSwitch* sw = family->findSwitch( swtag, fixed_version, kludge );
123116
if( sw != NULL ) {
124117
return( sw );
125118
}
126119
}
127120
icount = _incTools.count();
128121
for( int i = 0; i < icount; i++ ) {
129122
MTool* tool = (MTool*)_incTools[i];
130-
MSwitch* sw = tool->findSwitch( switchtag, fixed_version, kludge );
123+
MSwitch* sw = tool->findSwitch( swtag, fixed_version, kludge );
131124
if( sw != NULL ) {
132125
return( sw );
133126
}

bld/ide/lib/cpp/mtypo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ void AddTypo( WString &good, WString &bad )
4545
SwitchTypos.add( t );
4646
}
4747

48-
void FixTypo( WString &word )
48+
WString* FixTypo( WString &word )
4949
{
5050
for( int i = 0; i < SwitchTypos.count(); i++ ) {
5151
WTypo *t = (WTypo *)SwitchTypos[i];
5252
if( t->bad() == word ) {
5353
word = t->good();
54-
break;
54+
return( &word );
5555
}
5656
}
57+
return( NULL );
5758
}

bld/ide/lib/h/mswitch.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ WCLASS MSwitch : public WObject
6161
bool hasText() { return( _text.size() > 0 ); }
6262
bool isSetable() { return( _text.size() > 0 && *_text != ' ' ); }
6363
bool isTagEqual( WString& tag, int kludge=0 );
64-
#if IDE_CFG_VERSION_MAJOR > 4
65-
bool isTagEqual( MTool *tool, WString& mask, int kludge=0 );
66-
#endif
6764
bool isTextEqual( MSwitch* text )
6865
{ return( text != NULL && _text.size() > 0 && _text == text->text() ); }
6966
MSwitch* addSwitch( WVList& list, const char* mask );

bld/ide/lib/h/mtool.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ WCLASS MTool : public WObject
5454
WString& tag() { return( _tag ); };
5555
void name( WString& s ) { s = _name; }
5656
const WString& help() { return( _help ); }
57-
MSwitch* findSwitch( WString& switchtag, long fixed_version=0, int kludge=0 );
57+
MSwitch* findSwitch( WString& swtag, long fixed_version=0, int kludge=0 );
5858
#if IDE_CFG_VERSION_MAJOR > 4
5959
WString* findSwitchByText( WString& id, WString& text, int kludge=0 );
6060
#endif

bld/ide/lib/h/mtypo.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*
33
* Open Watcom Project
44
*
5+
* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved.
56
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
67
*
78
* ========================================================================
@@ -51,4 +52,4 @@ WCLASS WTypo : public WObject
5152
#endif //wtypo_class
5253

5354
void AddTypo( WString &good, WString &bad );
54-
void FixTypo( WString &word );
55+
WString* FixTypo( WString &word );

0 commit comments

Comments
 (0)