@@ -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 */
663664static 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