Skip to content

Commit 6ecb35e

Browse files
committed
Preparing release 3.0.2
1 parent 0c6a93e commit 6ecb35e

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2017 Nov 16 Sergey Satskiy <sergey.satskiy@gmail.com>
2+
3+
* Release 3.0.2
4+
* Bug fix: correct handling of the docstrings which start with 'r' or 'u'
5+
16
2017 Aug 21 Sergey Satskiy <sergey.satskiy@gmail.com>
27

38
* Release v.3.0.1

cdmpyparserversion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = '3.0.2'

src/cdmpyparser.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ static void collectTestString( node * from, char * buffer, int * length )
659659
}
660660

661661

662-
/* returns 1 or 3, i.e. the number of quotes used in a string literal part */
662+
/* returns 1, 2, 3 or 4,
663+
i.e. the number of leading quotes used in a string literal part */
663664
static size_t getStringLiteralPrefixLength( node * tree )
664665
{
665666
/* tree must be of STRING type */
@@ -668,6 +669,22 @@ static size_t getStringLiteralPrefixLength( node * tree )
668669
return 3;
669670
if ( strncmp( tree->n_str, "'''", 3 ) == 0 )
670671
return 3;
672+
if ( strncmp( tree->n_str, "r\"\"\"", 4 ) == 0 )
673+
return 4;
674+
if ( strncmp( tree->n_str, "r'''", 4 ) == 0 )
675+
return 4;
676+
if ( strncmp( tree->n_str, "u\"\"\"", 4 ) == 0 )
677+
return 4;
678+
if ( strncmp( tree->n_str, "u'''", 4 ) == 0 )
679+
return 4;
680+
if ( strncmp( tree->n_str, "r\"", 2 ) == 0 )
681+
return 2;
682+
if ( strncmp( tree->n_str, "r'", 2 ) == 0 )
683+
return 2;
684+
if ( strncmp( tree->n_str, "u\"", 2 ) == 0 )
685+
return 2;
686+
if ( strncmp( tree->n_str, "u'", 2 ) == 0 )
687+
return 2;
671688
return 1;
672689
}
673690

@@ -731,7 +748,13 @@ static void checkForDocstring( node * tree,
731748
return;
732749

733750
charsToSkip = getStringLiteralPrefixLength( stringChild );
734-
charsToCopy = strlen( stringChild->n_str ) - 2 * charsToSkip;
751+
charsToCopy = strlen( stringChild->n_str ) - charsToSkip;
752+
if ( charsToSkip == 2 )
753+
charsToCopy -= 1;
754+
else if ( charsToSkip == 4 )
755+
charsToCopy -= 3;
756+
else
757+
charsToCopy -= charsToSkip;
735758

736759
if ( collected + charsToCopy + 1 > MAX_DOCSTRING_SIZE )
737760
{

0 commit comments

Comments
 (0)