r19793 by jghali - #12893: fix counting of words in story editor

scribus-commit scribus-commit at lists.scribus.net
Thu Feb 5 22:15:57 UTC 2015


Author: jghali
Date: Thu Feb  5 22:15:57 2015
New Revision: 19793

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19793
Log:
#12893: fix counting of words in story editor

Modified:
    trunk/Scribus/scribus/ui/storyeditor.cpp

Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19793&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp (original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp Thu Feb  5 22:15:57 2015
@@ -2662,24 +2662,22 @@
 
 	ParC->setText(tmp.setNum(Editor->StyledText.nrOfParagraphs()));
 	CharC2->setText(tmp.setNum(Editor->StyledText.length()));
-
 	CharC->setText(tmp.setNum(end - start));
+
 	QRegExp rx( "(\\w+)\\b" );
 	const QString& txt(Editor->StyledText.text(0, Editor->StyledText.length()));
-	int pos = 1;
-	int counter = end > start? 1 : 0;
-	int counter2 = Editor->StyledText.length() > 0? 1 : 0;
-	while ( pos >= 0 )
-	{
-		pos = rx.indexIn( txt, pos );
-		if ( pos > -1 )
-		{
-			if (pos > start && pos < end)
-				counter++;
-
-			counter2++;
-			pos += rx.matchedLength();
-		}
+	int counter  = 0;
+	int counter2 = 0;
+
+	int pos = rx.indexIn(txt, 0);
+	while (pos >= 0)
+	{
+		if (pos >= start && pos < end)
+			counter++;
+
+		counter2++;
+		pos += rx.matchedLength();
+		pos  = rx.indexIn(txt, pos);
 	}
 
 	WordC->setText(tmp.setNum(counter));




More information about the scribus-commit mailing list