Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v9-minor'
Browse files Browse the repository at this point in the history
  • Loading branch information
scip-ci committed Oct 17, 2024
2 parents ac50e5e + 8dee6cf commit 51211be
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 126 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Interface changes
- added SCIPtpiIsAvailable() to check whether a working task processing interface is available (TPI != none)
- added SCIPtpiGetLibraryName() and SCIPtpiGetLibraryDesc()
- SCIPdelCons() can now also be called in SCIP_STAGE_TRANSFORMED
- added SCIPstrcasecmp() and SCIPstrncasecmp() for case-insensitive string comparison

### Command line interface
### Interfaces to external software
Expand Down Expand Up @@ -151,6 +152,9 @@ Miscellaneous
-------------

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

@section RN912 SCIP 9.1.2
*************************
Expand Down
1 change: 0 additions & 1 deletion lint/scip.lnt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@
// avoid significant prototype coercion (this is usually happening
// because the length of the string is given by an integer constant,
// while the argument is unsigned long):
-ecall(747,strncasecmp)
-ecall(747,strncpy)
-ecall(747,strncat)
-ecall(747,strncpy)
Expand Down
16 changes: 8 additions & 8 deletions src/scip/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ SCIP_RETCODE readSolfile(
}

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

/* cast the value, check first for inv(alid) or inf(inite) ones that need special treatment */
if( strncasecmp(valuestring, "inv", 3) == 0 )
if( SCIPstrncasecmp(valuestring, "inv", 3) == 0 )
continue;
else if( strncasecmp(valuestring, "+inf", 4) == 0 || strncasecmp(valuestring, "inf", 3) == 0 )
else if( SCIPstrncasecmp(valuestring, "+inf", 4) == 0 || SCIPstrncasecmp(valuestring, "inf", 3) == 0 )
val = SCIPsetInfinity(set);
else if( strncasecmp(valuestring, "-inf", 4) == 0 )
else if( SCIPstrncasecmp(valuestring, "-inf", 4) == 0 )
val = -SCIPsetInfinity(set);
else
{
Expand Down
1 change: 0 additions & 1 deletion src/scip/def.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
#ifdef _WIN32
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define getcwd _getcwd
#endif

/*
Expand Down
6 changes: 1 addition & 5 deletions src/scip/heur_alns.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@
#include "scip/scip_var.h"
#include <string.h>

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

#define HEUR_NAME "alns"
#define HEUR_DESC "Large neighborhood search heuristic that orchestrates the popular neighborhoods Local Branching, RINS, RENS, DINS etc."
#define HEUR_DISPCHAR SCIP_HEURDISPCHAR_LNS
Expand Down Expand Up @@ -3824,7 +3820,7 @@ SCIP_DECL_HEURINIT(heurInitAlns)
}

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

Expand Down
3 changes: 0 additions & 3 deletions src/scip/heur_scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
#include "scip/scip_var.h"
#include <string.h>

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

#define HEUR_NAME "scheduler"
#define HEUR_DESC "Adaptive heuristic to schedule LNS and diving heuristics"
Expand Down
31 changes: 31 additions & 0 deletions src/scip/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
#include <errno.h>
#include <ctype.h>
#include <math.h>
#ifndef _MSC_VER
#include <strings.h>
#endif

#include "scip/def.h"
#include "scip/pub_message.h"
Expand Down Expand Up @@ -10909,6 +10912,34 @@ int SCIPsnprintf(
return n;
}

/** portable version of strcasecmp for case-insensitive comparison of two strings */
int SCIPstrcasecmp(
const char* s1, /**< first string */
const char* s2 /**< second string */
)
{
#ifdef _MSC_VER
return _stricmp(s1, s2);
#else
return strcasecmp(s1, s2);
#endif
}

/** portable version of strncasecmp for case-insensitive comparison of two strings up to a given number of characters */
int SCIPstrncasecmp(
const char* s1, /**< first string */
const char* s2, /**< second string */
int length /**< maximal length to compare */
)
{
assert(length >= 0);
#ifdef _MSC_VER
return _strnicmp(s1, s2, (size_t)length);
#else
return strncasecmp(s1, s2, (size_t)length); /*lint !e571*/
#endif
}

/** safe version of strncpy
*
* Copies string in s to t using at most @a size-1 nonzero characters (strncpy copies size characters). It always adds
Expand Down
4 changes: 2 additions & 2 deletions src/scip/paramset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,11 +1247,11 @@ SCIP_RETCODE paramParseBool(
assert(set != NULL);
assert(valuestr != NULL);

if( strcasecmp(valuestr, "TRUE") == 0 )
if( SCIPstrcasecmp(valuestr, "TRUE") == 0 )
{
SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, TRUE, FALSE, TRUE) );
}
else if( strcasecmp(valuestr, "FALSE") == 0 )
else if( SCIPstrcasecmp(valuestr, "FALSE") == 0 )
{
SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, FALSE, FALSE, TRUE) );
}
Expand Down
15 changes: 15 additions & 0 deletions src/scip/pub_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,21 @@ int SCIPstrncpy(
int size /**< maximal size of t */
);

/** portable version of strcasecmp for case-insensitive comparison of two strings */
SCIP_EXPORT
int SCIPstrcasecmp(
const char* s1, /**< first string */
const char* s2 /**< second string */
);

/** portable version of strncasecmp for case-insensitive comparison of two strings up to a given number of characters */
SCIP_EXPORT
int SCIPstrncasecmp(
const char* s1, /**< first string */
const char* s2, /**< second string */
int length /**< maximal length to compare */
);

/** 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
*
* @return Returns TRUE if a value could be extracted, otherwise FALSE
Expand Down
2 changes: 1 addition & 1 deletion src/scip/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ SCIP_Bool readerIsApplicable(
assert(reader != NULL);
assert(reader->extension != NULL);

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

Expand Down
17 changes: 6 additions & 11 deletions src/scip/reader_bnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@
#include "scip/scip_var.h"
#include <string.h>

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


#define READER_NAME "bndreader"
#define READER_DESC "file reader for variable bounds"
#define READER_EXTENSION "bnd"
Expand Down Expand Up @@ -172,11 +167,11 @@ SCIP_RETCODE readBounds(
}

/* cast the lower bound value */
if( strncasecmp(lbstring, "inv", 3) == 0 )
if( SCIPstrncasecmp(lbstring, "inv", 3) == 0 )
continue;
else if( strncasecmp(lbstring, "+inf", 4) == 0 || strncasecmp(lbstring, "inf", 3) == 0 )
else if( SCIPstrncasecmp(lbstring, "+inf", 4) == 0 || SCIPstrncasecmp(lbstring, "inf", 3) == 0 )
lb = SCIPinfinity(scip);
else if( strncasecmp(lbstring, "-inf", 4) == 0 )
else if( SCIPstrncasecmp(lbstring, "-inf", 4) == 0 )
lb = -SCIPinfinity(scip);
else
{
Expand All @@ -191,11 +186,11 @@ SCIP_RETCODE readBounds(
}

/* cast the upper bound value */
if( strncasecmp(ubstring, "inv", 3) == 0 )
if( SCIPstrncasecmp(ubstring, "inv", 3) == 0 )
continue;
else if( strncasecmp(ubstring, "+inf", 4) == 0 || strncasecmp(ubstring, "inf", 3) == 0 )
else if( SCIPstrncasecmp(ubstring, "+inf", 4) == 0 || SCIPstrncasecmp(ubstring, "inf", 3) == 0 )
ub = SCIPinfinity(scip);
else if( strncasecmp(ubstring, "-inf", 4) == 0 )
else if( SCIPstrncasecmp(ubstring, "-inf", 4) == 0 )
ub = -SCIPinfinity(scip);
else
{
Expand Down
13 changes: 5 additions & 8 deletions src/scip/reader_cip.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
#include "scip/scip_prob.h"
#include "scip/scip_reader.h"
#include "scip/scip_var.h"
#if !defined(_WIN32) && !defined(_WIN64)
#include <strings.h> /*lint --e{766}*/ /* needed for strncasecmp() */
#endif


#define READER_NAME "cipreader"
Expand Down Expand Up @@ -303,7 +300,7 @@ SCIP_RETCODE getObjective(
/* remove white space */
SCIP_CALL( SCIPskipSpace(&buf) );

if( strncasecmp(buf, "Sense", 5) == 0 )
if( SCIPstrncasecmp(buf, "Sense", 5) == 0 )
{
SCIP_OBJSENSE objsense;

Expand All @@ -321,9 +318,9 @@ SCIP_RETCODE getObjective(
/* remove white space in front of the name */
SCIP_CALL( SCIPskipSpace(&name) );

if( strncasecmp(name, "minimize", 3) == 0 )
if( SCIPstrncasecmp(name, "min", 3) == 0 )
objsense = SCIP_OBJSENSE_MINIMIZE;
else if( strncasecmp(name, "maximize", 3) == 0 )
else if( SCIPstrncasecmp(name, "max", 3) == 0 )
objsense = SCIP_OBJSENSE_MAXIMIZE;
else
{
Expand All @@ -335,7 +332,7 @@ SCIP_RETCODE getObjective(
SCIP_CALL( SCIPsetObjsense(scip, objsense) );
SCIPdebugMsg(scip, "objective sense <%s>\n", objsense == SCIP_OBJSENSE_MINIMIZE ? "minimize" : "maximize");
}
else if( strncasecmp(buf, "Offset", 6) == 0 )
else if( SCIPstrncasecmp(buf, "Offset", 6) == 0 )
{
SCIP_Real off = 0;
char* endptr;
Expand Down Expand Up @@ -365,7 +362,7 @@ SCIP_RETCODE getObjective(
return SCIP_OKAY;
}
}
else if( strncasecmp(buf, "Scale", 5) == 0 )
else if( SCIPstrncasecmp(buf, "Scale", 5) == 0 )
{
SCIP_Real scale = 1.0;
char* endptr;
Expand Down
6 changes: 1 addition & 5 deletions src/scip/reader_diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
#include <stdlib.h>
#include <string.h>

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

#define READER_NAME "diffreader"
#define READER_DESC "file reader for changes in the LP file"
#define READER_EXTENSION "diff"
Expand Down Expand Up @@ -577,7 +573,7 @@ SCIP_Bool isValue(
assert(lpinput != NULL);
assert(value != NULL);

if( strcasecmp(lpinput->token, "INFINITY") == 0 || strcasecmp(lpinput->token, "INF") == 0 )
if( SCIPstrcasecmp(lpinput->token, "INFINITY") == 0 || SCIPstrcasecmp(lpinput->token, "INF") == 0 )
{
*value = SCIPinfinity(scip);
return TRUE;
Expand Down
13 changes: 4 additions & 9 deletions src/scip/reader_fix.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@
#include "scip/scip_var.h"
#include <string.h>

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



#define READER_NAME "fixreader"
#define READER_DESC "file reader for variable fixings"
Expand Down Expand Up @@ -121,7 +116,7 @@ SCIP_RETCODE readSol(
lineno++;

/* the lines "solution status: ..." and "objective value: ..." may preceed the solution information */
if( strncasecmp(buffer, "solution status:", 16) == 0 || strncasecmp(buffer, "objective value:", 16) == 0 )
if( SCIPstrncasecmp(buffer, "solution status:", 16) == 0 || SCIPstrncasecmp(buffer, "objective value:", 16) == 0 )
continue;

/* parse the line */
Expand All @@ -148,11 +143,11 @@ SCIP_RETCODE readSol(
}

/* cast the value */
if( strncasecmp(valuestring, "inv", 3) == 0 )
if( SCIPstrncasecmp(valuestring, "inv", 3) == 0 )
continue;
else if( strncasecmp(valuestring, "+inf", 4) == 0 || strncasecmp(valuestring, "inf", 3) == 0 )
else if( SCIPstrncasecmp(valuestring, "+inf", 4) == 0 || SCIPstrncasecmp(valuestring, "inf", 3) == 0 )
value = SCIPinfinity(scip);
else if( strncasecmp(valuestring, "-inf", 4) == 0 )
else if( SCIPstrncasecmp(valuestring, "-inf", 4) == 0 )
value = -SCIPinfinity(scip);
else
{
Expand Down
Loading

0 comments on commit 51211be

Please sign in to comment.