@@ -611,7 +611,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
611611 for (;i<l;i++)
612612 {
613613 char c=src[i];
614- char nc=i<l- 1 ? src[i+1 ] : ' ' ;
614+ char nc=i+ 1 <l ? src[i+1 ] : ' ' ;
615615
616616 auto searchForKeyword = [&](const char *kw,size_t &matchLen,size_t totalLen)
617617 {
@@ -665,7 +665,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
665665 break ;
666666 case ' <' : // current char is a <
667667 *dst++=c;
668- if (i<l- 1 &&
668+ if (i+ 1 <l &&
669669 (isId (nc)) && // next char is an id char
670670 (osp<8 ) // string in front is not "operator"
671671 )
@@ -682,17 +682,17 @@ QCString removeRedundantWhiteSpace(const QCString &s)
682682 *dst++=' ' ; // add extra space in front
683683 }
684684 *dst++=c;
685- if (i<l- 1 && (nc==' -' || nc==' &' )) // '>-' -> '> -'
685+ if (i+ 1 <l && (nc==' -' || nc==' &' )) // '>-' -> '> -'
686686 {
687687 *dst++=' ' ; // add extra space after
688688 }
689689 break ;
690690 case ' ,' : // current char is a ,
691691 *dst++=c;
692692 if (i>0 && !isspace (static_cast <uint8_t >(pc)) &&
693- ((i<l- 1 && (isId (nc) || nc==' [' )) || // the [ is for attributes (see bug702170)
694- (i<l- 2 && nc==' $' && isId (src[i+2 ])) || // for PHP: ',$name' -> ', $name'
695- (i<l- 3 && nc==' &' && src[i+2 ]==' $' && isId (src[i+3 ])) // for PHP: ',&$name' -> ', &$name'
693+ ((i+ 1 <l && (isId (nc) || nc==' [' )) || // the [ is for attributes (see bug702170)
694+ (i+ 2 <l && nc==' $' && isId (src[i+2 ])) || // for PHP: ',$name' -> ', $name'
695+ (i+ 3 <l && nc==' &' && src[i+2 ]==' $' && isId (src[i+3 ])) // for PHP: ',&$name' -> ', &$name'
696696 )
697697 )
698698 {
@@ -702,14 +702,14 @@ QCString removeRedundantWhiteSpace(const QCString &s)
702702 case ' ^' : // CLI 'Type^name' -> 'Type^ name'
703703 case ' %' : // CLI 'Type%name' -> 'Type% name'
704704 *dst++=c;
705- if (cliSupport && i<l- 1 && (isId (nc) || nc==' -' ))
705+ if (cliSupport && i+ 1 <l && (isId (nc) || nc==' -' ))
706706 {
707707 *dst++=' ' ; // add extra space after
708708 }
709709 break ;
710710 case ' )' : // current char is a ) -> ')name' -> ') name'
711711 *dst++=c;
712- if (i<l- 1 && (isId (nc) || nc==' -' ))
712+ if (i+ 1 <l && (isId (nc) || nc==' -' ))
713713 {
714714 *dst++=' ' ; // add extra space after
715715 }
@@ -746,7 +746,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
746746 // else fallthrough
747747 case ' @' : // '@name' -> ' @name'
748748 case ' \' ' : // ''name' -> '' name'
749- if (i>0 && i<l- 1 && pc!=' =' && pc!=' :' && !isspace (static_cast <uint8_t >(pc)) &&
749+ if (i>0 && i+ 1 <l && pc!=' =' && pc!=' :' && !isspace (static_cast <uint8_t >(pc)) &&
750750 isId (nc) && osp<8 ) // ")id" -> ") id"
751751 {
752752 *dst++=' ' ;
@@ -797,7 +797,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
797797 auto correctKeywordAllowedInsideScope = [&](char cc,size_t &matchLen,size_t totalLen) {
798798 if (c==cc && matchLen==totalLen)
799799 {
800- if ((i<l- 2 && src[i+1 ] == ' :' && src[i+2 ] == ' :' ) || // keyword::
800+ if ((i+ 2 <l && src[i+1 ] == ' :' && src[i+2 ] == ' :' ) || // keyword::
801801 ((i>matchLen && src[i-matchLen] == ' :' && src[i-matchLen-1 ] == ' :' )) // ::keyword
802802 ) matchLen = 0 ;
803803 };
@@ -808,7 +808,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
808808
809809 auto correctKeywordNotPartOfScope = [&](char cc,size_t &matchLen,size_t totalLen)
810810 {
811- if (c==cc && matchLen==totalLen && i<l- 1 && // found matching keyword
811+ if (c==cc && matchLen==totalLen && i+ 1 <l && // found matching keyword
812812 !(isId (nc) || nc==' )' || nc==' ,' || qisspace (nc))
813813 ) // prevent keyword ::A from being converted to keyword::A
814814 {
@@ -883,7 +883,7 @@ bool rightScopeMatch(const QCString &scope, const QCString &name)
883883 size_t nl=name.length ();
884884 return (name==scope || // equal
885885 (scope.right (nl)==name && // substring
886- sl-nl> 1 && scope.at (sl-nl-1 )==' :' && scope.at (sl-nl-2 )==' :' // scope
886+ sl> 1 +nl && scope.at (sl-nl-1 )==' :' && scope.at (sl-nl-2 )==' :' // scope
887887 )
888888 );
889889}
0 commit comments