Skip to content

Commit 51211be

Browse files
committed
Merge remote-tracking branch 'origin/v9-minor'
2 parents ac50e5e + 8dee6cf commit 51211be

20 files changed

+137
-126
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Interface changes
118118
- added SCIPtpiIsAvailable() to check whether a working task processing interface is available (TPI != none)
119119
- added SCIPtpiGetLibraryName() and SCIPtpiGetLibraryDesc()
120120
- SCIPdelCons() can now also be called in SCIP_STAGE_TRANSFORMED
121+
- added SCIPstrcasecmp() and SCIPstrncasecmp() for case-insensitive string comparison
121122

122123
### Command line interface
123124
### Interfaces to external software
@@ -151,6 +152,9 @@ Miscellaneous
151152
-------------
152153

153154
- reorder events: BESTSOLFOUND/NODE_FEASIBLE is now processed before the nodes are cut off and before NODE_DELETE events are processed
155+
- removed `#define` of `getcwd` (in case of Windows builds) in scip/def.h
156+
- the `#define` of `strcasecmp` and `strncasecmp` (in case of Windows builds) in scip/def.h will be removed with SCIP 10;
157+
use `SCIPstr(n)casecmp()` (scip/pub_misc.h) instead
154158

155159
@section RN912 SCIP 9.1.2
156160
*************************

lint/scip.lnt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
// avoid significant prototype coercion (this is usually happening
159159
// because the length of the string is given by an integer constant,
160160
// while the argument is unsigned long):
161-
-ecall(747,strncasecmp)
162161
-ecall(747,strncpy)
163162
-ecall(747,strncat)
164163
-ecall(747,strncpy)

src/scip/debug.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ SCIP_RETCODE readSolfile(
206206
}
207207

208208
/* there are some lines which may preceed the solution information */
209-
if( strncasecmp(buf, "solution status:", 16) == 0 || strncasecmp(buf, "objective value:", 16) == 0 ||
210-
strncasecmp(buf, "Log started", 11) == 0 || strncasecmp(buf, "Variable Name", 13) == 0 ||
211-
strncasecmp(buf, "All other variables", 19) == 0 || strspn(buf, " \n\r\t\f") == strlen(buf) ||
212-
strncasecmp(buf, "NAME", 4) == 0 || strncasecmp(buf, "ENDATA", 6) == 0 || /* allow parsing of SOL-format on the MIPLIB 2003 pages */
213-
strncasecmp(buf, "=obj=", 5) == 0 ) /* avoid "unknown variable" warning when reading MIPLIB SOL files */
209+
if( SCIPstrncasecmp(buf, "solution status:", 16) == 0 || SCIPstrncasecmp(buf, "objective value:", 16) == 0 ||
210+
SCIPstrncasecmp(buf, "Log started", 11) == 0 || SCIPstrncasecmp(buf, "Variable Name", 13) == 0 ||
211+
SCIPstrncasecmp(buf, "All other variables", 19) == 0 || strspn(buf, " \n\r\t\f") == strlen(buf) ||
212+
SCIPstrncasecmp(buf, "NAME", 4) == 0 || SCIPstrncasecmp(buf, "ENDATA", 6) == 0 || /* allow parsing of SOL-format on the MIPLIB 2003 pages */
213+
SCIPstrncasecmp(buf, "=obj=", 5) == 0 ) /* avoid "unknown variable" warning when reading MIPLIB SOL files */
214214
{
215215
++nonvalues;
216216
continue;
@@ -240,11 +240,11 @@ SCIP_RETCODE readSolfile(
240240
}
241241

242242
/* cast the value, check first for inv(alid) or inf(inite) ones that need special treatment */
243-
if( strncasecmp(valuestring, "inv", 3) == 0 )
243+
if( SCIPstrncasecmp(valuestring, "inv", 3) == 0 )
244244
continue;
245-
else if( strncasecmp(valuestring, "+inf", 4) == 0 || strncasecmp(valuestring, "inf", 3) == 0 )
245+
else if( SCIPstrncasecmp(valuestring, "+inf", 4) == 0 || SCIPstrncasecmp(valuestring, "inf", 3) == 0 )
246246
val = SCIPsetInfinity(set);
247-
else if( strncasecmp(valuestring, "-inf", 4) == 0 )
247+
else if( SCIPstrncasecmp(valuestring, "-inf", 4) == 0 )
248248
val = -SCIPsetInfinity(set);
249249
else
250250
{

src/scip/def.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
#ifdef _WIN32
106106
#define strcasecmp _stricmp
107107
#define strncasecmp _strnicmp
108-
#define getcwd _getcwd
109108
#endif
110109

111110
/*

src/scip/heur_alns.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@
7171
#include "scip/scip_var.h"
7272
#include <string.h>
7373

74-
#if !defined(_WIN32) && !defined(_WIN64)
75-
#include <strings.h> /*lint --e{766}*/ /* needed for strncasecmp() */
76-
#endif
77-
7874
#define HEUR_NAME "alns"
7975
#define HEUR_DESC "Large neighborhood search heuristic that orchestrates the popular neighborhoods Local Branching, RINS, RENS, DINS etc."
8076
#define HEUR_DISPCHAR SCIP_HEURDISPCHAR_LNS
@@ -3824,7 +3820,7 @@ SCIP_DECL_HEURINIT(heurInitAlns)
38243820
}
38253821

38263822
/* open reward file for reading */
3827-
if( strncasecmp(heurdata->rewardfilename, DEFAULT_REWARDFILENAME, strlen(DEFAULT_REWARDFILENAME)) != 0 )
3823+
if( strcmp(heurdata->rewardfilename, DEFAULT_REWARDFILENAME) != 0 )
38283824
{
38293825
heurdata->rewardfile = fopen(heurdata->rewardfilename, "w");
38303826

src/scip/heur_scheduler.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@
7272
#include "scip/scip_var.h"
7373
#include <string.h>
7474

75-
#if !defined(_WIN32) && !defined(_WIN64)
76-
#include <strings.h> /*lint --e{766}*/ /* needed for strncasecmp() */
77-
#endif
7875

7976
#define HEUR_NAME "scheduler"
8077
#define HEUR_DESC "Adaptive heuristic to schedule LNS and diving heuristics"

src/scip/misc.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
#include <errno.h>
4646
#include <ctype.h>
4747
#include <math.h>
48+
#ifndef _MSC_VER
49+
#include <strings.h>
50+
#endif
4851

4952
#include "scip/def.h"
5053
#include "scip/pub_message.h"
@@ -10909,6 +10912,34 @@ int SCIPsnprintf(
1090910912
return n;
1091010913
}
1091110914

10915+
/** portable version of strcasecmp for case-insensitive comparison of two strings */
10916+
int SCIPstrcasecmp(
10917+
const char* s1, /**< first string */
10918+
const char* s2 /**< second string */
10919+
)
10920+
{
10921+
#ifdef _MSC_VER
10922+
return _stricmp(s1, s2);
10923+
#else
10924+
return strcasecmp(s1, s2);
10925+
#endif
10926+
}
10927+
10928+
/** portable version of strncasecmp for case-insensitive comparison of two strings up to a given number of characters */
10929+
int SCIPstrncasecmp(
10930+
const char* s1, /**< first string */
10931+
const char* s2, /**< second string */
10932+
int length /**< maximal length to compare */
10933+
)
10934+
{
10935+
assert(length >= 0);
10936+
#ifdef _MSC_VER
10937+
return _strnicmp(s1, s2, (size_t)length);
10938+
#else
10939+
return strncasecmp(s1, s2, (size_t)length); /*lint !e571*/
10940+
#endif
10941+
}
10942+
1091210943
/** safe version of strncpy
1091310944
*
1091410945
* Copies string in s to t using at most @a size-1 nonzero characters (strncpy copies size characters). It always adds

src/scip/paramset.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,11 +1247,11 @@ SCIP_RETCODE paramParseBool(
12471247
assert(set != NULL);
12481248
assert(valuestr != NULL);
12491249

1250-
if( strcasecmp(valuestr, "TRUE") == 0 )
1250+
if( SCIPstrcasecmp(valuestr, "TRUE") == 0 )
12511251
{
12521252
SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, TRUE, FALSE, TRUE) );
12531253
}
1254-
else if( strcasecmp(valuestr, "FALSE") == 0 )
1254+
else if( SCIPstrcasecmp(valuestr, "FALSE") == 0 )
12551255
{
12561256
SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, FALSE, FALSE, TRUE) );
12571257
}

src/scip/pub_misc.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,21 @@ int SCIPstrncpy(
23112311
int size /**< maximal size of t */
23122312
);
23132313

2314+
/** portable version of strcasecmp for case-insensitive comparison of two strings */
2315+
SCIP_EXPORT
2316+
int SCIPstrcasecmp(
2317+
const char* s1, /**< first string */
2318+
const char* s2 /**< second string */
2319+
);
2320+
2321+
/** portable version of strncasecmp for case-insensitive comparison of two strings up to a given number of characters */
2322+
SCIP_EXPORT
2323+
int SCIPstrncasecmp(
2324+
const char* s1, /**< first string */
2325+
const char* s2, /**< second string */
2326+
int length /**< maximal length to compare */
2327+
);
2328+
23142329
/** extract the next token as a integer value if it is one; in case no value is parsed the endptr is set to @p str
23152330
*
23162331
* @return Returns TRUE if a value could be extracted, otherwise FALSE

src/scip/reader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ SCIP_Bool readerIsApplicable(
175175
assert(reader != NULL);
176176
assert(reader->extension != NULL);
177177

178-
return (extension != NULL && strcasecmp(reader->extension, extension) == 0)
178+
return (extension != NULL && SCIPstrcasecmp(reader->extension, extension) == 0)
179179
|| (extension == NULL && *(reader->extension) == '\0');
180180
}
181181

0 commit comments

Comments
 (0)