Skip to content

Commit 523b209

Browse files
committed
remaing marcos in new header file with a PYSTRING prefix so that they don't clash with other definitions when used in different contexts
1 parent b69f734 commit 523b209

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

pystring_impl.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const std::string colon = ":";
3636

3737

3838
/* helper macro to fixup start/end slice values */
39-
#define ADJUST_INDICES(start, end, len) \
39+
#define PYSTRING_ADJUST_INDICES(start, end, len) \
4040
if (end > len) \
4141
end = len; \
4242
else if (end < 0) { \
@@ -218,9 +218,9 @@ const std::string colon = ":";
218218
//////////////////////////////////////////////////////////////////////////////////////////////
219219
///
220220
///
221-
#define LEFTSTRIP 0
222-
#define RIGHTSTRIP 1
223-
#define BOTHSTRIP 2
221+
#define PYSTRING_LEFTSTRIP 0
222+
#define PYSTRING_RIGHTSTRIP 1
223+
#define PYSTRING_BOTHSTRIP 2
224224

225225
//////////////////////////////////////////////////////////////////////////////////////////////
226226
///
@@ -232,7 +232,7 @@ const std::string colon = ":";
232232
if ( charslen == 0 )
233233
{
234234
i = 0;
235-
if ( striptype != RIGHTSTRIP )
235+
if ( striptype != PYSTRING_RIGHTSTRIP )
236236
{
237237
while ( i < len && ::isspace( str[i] ) )
238238
{
@@ -241,7 +241,7 @@ const std::string colon = ":";
241241
}
242242

243243
j = len;
244-
if ( striptype != LEFTSTRIP )
244+
if ( striptype != PYSTRING_LEFTSTRIP )
245245
{
246246
do
247247
{
@@ -259,7 +259,7 @@ const std::string colon = ":";
259259
const char * sep = chars.c_str();
260260

261261
i = 0;
262-
if ( striptype != RIGHTSTRIP )
262+
if ( striptype != PYSTRING_RIGHTSTRIP )
263263
{
264264
while ( i < len && memchr(sep, str[i], charslen) )
265265
{
@@ -268,7 +268,7 @@ const std::string colon = ":";
268268
}
269269

270270
j = len;
271-
if (striptype != LEFTSTRIP)
271+
if (striptype != PYSTRING_LEFTSTRIP)
272272
{
273273
do
274274
{
@@ -339,23 +339,23 @@ const std::string colon = ":";
339339
///
340340
std::string strip( const std::string & str, const std::string & chars )
341341
{
342-
return do_strip( str, BOTHSTRIP, chars );
342+
return do_strip( str, PYSTRING_BOTHSTRIP, chars );
343343
}
344344

345345
//////////////////////////////////////////////////////////////////////////////////////////////
346346
///
347347
///
348348
std::string lstrip( const std::string & str, const std::string & chars )
349349
{
350-
return do_strip( str, LEFTSTRIP, chars );
350+
return do_strip( str, PYSTRING_LEFTSTRIP, chars );
351351
}
352352

353353
//////////////////////////////////////////////////////////////////////////////////////////////
354354
///
355355
///
356356
std::string rstrip( const std::string & str, const std::string & chars )
357357
{
358-
return do_strip( str, RIGHTSTRIP, chars );
358+
return do_strip( str, PYSTRING_RIGHTSTRIP, chars );
359359
}
360360

361361
//////////////////////////////////////////////////////////////////////////////////////////////
@@ -402,7 +402,7 @@ const std::string colon = ":";
402402
const char* sub = substr.c_str();
403403
const char* str = self.c_str();
404404

405-
ADJUST_INDICES(start, end, len);
405+
PYSTRING_ADJUST_INDICES(start, end, len);
406406

407407
if (direction < 0) {
408408
// startswith
@@ -815,7 +815,7 @@ const std::string colon = ":";
815815
///
816816
std::string slice( const std::string & str, int start, int end )
817817
{
818-
ADJUST_INDICES(start, end, (int) str.size());
818+
PYSTRING_ADJUST_INDICES(start, end, (int) str.size());
819819
if ( start >= end ) return empty_string;
820820
return str.substr( start, end - start );
821821
}
@@ -826,7 +826,7 @@ const std::string colon = ":";
826826
///
827827
int find( const std::string & str, const std::string & sub, int start, int end )
828828
{
829-
ADJUST_INDICES(start, end, (int) str.size());
829+
PYSTRING_ADJUST_INDICES(start, end, (int) str.size());
830830

831831
std::string::size_type result = str.find( sub, start );
832832

@@ -854,7 +854,7 @@ const std::string colon = ":";
854854
///
855855
int rfind( const std::string & str, const std::string & sub, int start, int end )
856856
{
857-
ADJUST_INDICES(start, end, (int) str.size());
857+
PYSTRING_ADJUST_INDICES(start, end, (int) str.size());
858858

859859
std::string::size_type result = str.rfind( sub, end );
860860

0 commit comments

Comments
 (0)