<div dir="ltr">Chris,<div><br></div><div>This commit broke building with gcc on Fedora 18.</div><div><br></div><div><div>[ 0%] Building CXX object CMakeFiles/sword.dir/src/mgr/swmgr.cpp.o</div><div>/usr/bin/c++ -DGLOBCONFPATH=\"/sword.conf\" -D_FTPLIB_NO_COMPAT -D_ICU_ -Dsword_EXPORTS -g3 -Wall -O0 -fPIC -I/home/greg/Source/sword/include -o CMakeFiles/sword.dir/src/mgr/swmgr.cpp.o -c /home/greg/Source/sword/src/mgr/swmgr.cpp</div>
<div>In file included from /home/greg/Source/sword/src/mgr/swmgr.cpp:81:0:</div><div>/home/greg/Source/sword/include/utf8arabicpoints.h:39:15: error: extra qualification ‘sword::UTF8ArabicPoints::’ on member ‘next_mark’ [-fpermissive]</div>
</div><div><br></div><div>--Greg</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 8, 2013 at 4:08 AM, <span dir="ltr"><<a href="mailto:chrislit@crosswire.org" target="_blank">chrislit@crosswire.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chrislit<br>
Date: 2013-07-08 02:08:04 -0700 (Mon, 08 Jul 2013)<br>
New Revision: 2862<br>
<br>
Modified:<br>
trunk/include/utf8arabicpoints.h<br>
trunk/src/modules/filters/utf8arabicpoints.cpp<br>
Log:<br>
applied submitted UTF8ArabicPoints code (needs testing because I replaced deprecated bcopy with memmove)<br>
<br>
Modified: trunk/include/utf8arabicpoints.h<br>
===================================================================<br>
--- trunk/include/utf8arabicpoints.h 2013-07-08 09:01:53 UTC (rev 2861)<br>
+++ trunk/include/utf8arabicpoints.h 2013-07-08 09:08:04 UTC (rev 2862)<br>
@@ -35,6 +35,8 @@<br>
UTF8ArabicPoints();<br>
virtual ~UTF8ArabicPoints();<br>
virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0);<br>
+private:<br>
+ static char* UTF8ArabicPoints::next_mark(const char* from, int* mark_size);<br>
};<br>
<br>
SWORD_NAMESPACE_END<br>
<br>
Modified: trunk/src/modules/filters/utf8arabicpoints.cpp<br>
===================================================================<br>
--- trunk/src/modules/filters/utf8arabicpoints.cpp 2013-07-08 09:01:53 UTC (rev 2861)<br>
+++ trunk/src/modules/filters/utf8arabicpoints.cpp 2013-07-08 09:08:04 UTC (rev 2862)<br>
@@ -40,24 +40,140 @@<br>
<br>
UTF8ArabicPoints::~UTF8ArabicPoints(){};<br>
<br>
+char* UTF8ArabicPoints::next_mark(const char* from, int* mark_size)<br>
+{<br>
+ // Arabic vowel points currently targeted for elimination:<br>
+ // Table entries excerpted from<br>
+ // <a href="http://www.utf8-chartable.de/unicode-utf8-table.pl" target="_blank">http://www.utf8-chartable.de/unicode-utf8-table.pl</a>.<br>
+ // Code UTF-8 Description<br>
+ // point<br>
+ // ----- --------- -----------<br>
+ // U+064B d9 8b ARABIC FATHATAN<br>
+ // U+064C d9 8c ARABIC DAMMATAN<br>
+ // U+064D d9 8d ARABIC KASRATAN<br>
+ // U+064E d9 8e ARABIC FATHA<br>
+ // U+064F d9 8f ARABIC DAMMA<br>
+ // U+0650 d9 90 ARABIC KASRA<br>
+ // U+0651 d9 91 ARABIC SHADDA<br>
+ // U+0652 d9 92 ARABIC SUKUN<br>
+ // U+0653 d9 93 ARABIC MADDAH ABOVE<br>
+ // U+0654 d9 94 ARABIC HAMZA ABOVE<br>
+ // U+0655 d9 95 ARABIC HAMZA BELOW<br>
+ //<br>
+ // U+FC5E ef b1 9e ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM<br>
+ // U+FC5F ef b1 9f ARABIC LIGATURE SHADDA WITH KASRATAN ISOLATED FORM<br>
+ // U+FC60 ef b1 a0 ARABIC LIGATURE SHADDA WITH FATHA ISOLATED FORM<br>
+ // U+FC61 ef b1 a1 ARABIC LIGATURE SHADDA WITH DAMMA ISOLATED FORM<br>
+ // U+FC62 ef b1 a2 ARABIC LIGATURE SHADDA WITH KASRA ISOLATED FORM<br>
+ // U+FC63 ef b1 a3 ARABIC LIGATURE SHADDA WITH SUPERSCRIPT ALEF ISOLATED FORM<br>
+ //<br>
+ // U+FE70 ef b9 b0 ARABIC FATHATAN ISOLATED FORM<br>
+ // U+FE71 ef b9 b1 ARABIC TATWEEL WITH FATHATAN ABOVE<br>
+ // U+FE72 ef b9 b2 ARABIC DAMMATAN ISOLATED FORM<br>
+ // U+FE73 ef b9 b3 ARABIC TAIL FRAGMENT<br>
+ // U+FE74 ef b9 b4 ARABIC KASRATAN ISOLATED FORM<br>
+ // U+FE75 ef b9 b5 ???<br>
+ // U+FE76 ef b9 b6 ARABIC FATHA ISOLATED FORM<br>
+ // U+FE77 ef b9 b7 ARABIC FATHA MEDIAL FORM<br>
+ // U+FE78 ef b9 b8 ARABIC DAMMA ISOLATED FORM<br>
+ // U+FE79 ef b9 b9 ARABIC DAMMA MEDIAL FORM<br>
+ // U+FE7A ef b9 ba ARABIC KASRA ISOLATED FORM<br>
+ // U+FE7B ef b9 bb ARABIC KASRA MEDIAL FORM<br>
+ // U+FE7C ef b9 bc ARABIC SHADDA ISOLATED FORM<br>
+ // U+FE7D ef b9 bd ARABIC SHADDA MEDIAL FORM<br>
+ // U+FE7E ef b9 be ARABIC SUKUN ISOLATED FORM<br>
+ // U+FE7F ef b9 bf ARABIC SUKUN MEDIAL FORM<br>
<br>
-char UTF8ArabicPoints::processText(SWBuf &text, const SWKey *key, const SWModule *module) {<br>
- if (!option) {<br>
- //The UTF-8 range 0xFC 0xE5 to 0xFC 0x63 consist of Arabic vowel marks so block those out.<br>
- // Also ranges 0xFE70 til OxFE7F and 0x064b-0x0655<br>
- SWBuf orig = text;<br>
- const unsigned char* from = (unsigned char*)orig.c_str();<br>
- for (text = ""; *from; from++) {<br>
- if ((*from == 0xD9) && (*(from + 1) >= 0x8B && *(from + 1) <= 0x95)) {<br>
- from++;<br>
+ unsigned char* byte = (unsigned char*) from;<br>
+ for (; *byte; ++byte) {<br>
+ if (byte[0] == 0xD9) {<br>
+ if (byte[1] >= 0x8B && byte[1] <= 0x95) {<br>
+ *mark_size = 2;<br>
+ break;<br>
}<br>
- else if ((*from == 0xEF) &&<br>
- (((*(from + 1) == 0xB1) && (*(from + 2) >= 0x9E && *(from + 2) <= 0xA3)) ||<br>
- ((*(from + 1) == 0xB9) && (*(from + 2) >= 0x4B && *(from + 2) <= 0x55)))) {<br>
- from += 2;<br>
- }<br>
+ continue;<br>
}<br>
+ if (byte[0] == 0xEF) {<br>
+ if (byte[1] == 0xB1) {<br>
+ if (byte[2] >= 0x9E && byte[2] <= 0xA3) {<br>
+ *mark_size = 3;<br>
+ break;<br>
+ }<br>
+ continue;<br>
+ }<br>
+ if (byte[1] == 0xB9) {<br>
+ if (byte[2] >= 0xB0 && byte[2] <= 0xBF) {<br>
+ *mark_size = 3;<br>
+ break;<br>
+ }<br>
+ continue;<br>
+ }<br>
+ }<br>
}<br>
+ return (char*)byte;<br>
+}<br>
+<br>
+<br>
+char UTF8ArabicPoints::processText(SWBuf &text, const SWKey *, const SWModule *) {<br>
+ // A non-zero/true option setting means that setOptionValue("On")<br>
+ // was called which apparently means that Arabic Vowel Marks are ENABLED,<br>
+ // so the filter's actions are DISABLED.<br>
+ if (option)<br>
+ return 0;<br>
+<br>
+ // Eliminate Arabic vowel marks from the text.<br>
+ // The recognized marks are determined by the "next_mark" function.<br>
+<br>
+ // If next_mark were polymorphic (a virtual function or a function<br>
+ // pointer), this function could be generically used in any filter that<br>
+ // only removed (vs. replaced) areas of text based on the arbitrary<br>
+ // match criteria encapsulated in the specific next_mark<br>
+ // implementation.<br>
+ int mark_size = 0;<br>
+ char* mark_pos = next_mark(text.c_str(), &mark_size);<br>
+<br>
+ // Here and at the end of the loop,<br>
+ // test BOTH mark_pos AND *mark_pos for safety and to give next_mark<br>
+ // the option of returning either NULL or a pointer to the null<br>
+ // terminator when done.<br>
+ if (!mark_pos || !*mark_pos)<br>
+ return 0; // no marks found.<br>
+<br>
+ // Purposely granting write access into SWBuf internal buffer via<br>
+ // "end_of_output" avoids a needless temporary SWBuf copy.<br>
+ // Everything before the first mark is already in its final position<br>
+ // and can be safely ignored. So start appending at the current mark.<br>
+ char* end_of_output = mark_pos;<br>
+<br>
+ // For consistency, input starts at (vs. after) the first mark as well<br>
+ // -- not a problem since the mark itself gets skipped, anyway.<br>
+ const char* start_of_input = mark_pos;<br>
+ do {<br>
+ // At this point, "mark_pos" and "mark_pos+mark_size" delimit<br>
+ // the text to drop.<br>
+ // "start_of_input" is either mark_pos or any text between the<br>
+ // end of any previous mark and the current mark_pos.<br>
+ // This text is now ready to be moved into the output.<br>
+ int ready_size = mark_pos - start_of_input;<br>
+ if (ready_size > 0) {<br>
+ // Append the input text before the current mark to the<br>
+ // output.<br>
+ // Must use bcopy vs. strncpy because the final<br>
+ // end_of_output may overtake the original<br>
+ // start_of_input.<br>
+ memmove(end_of_output, start_of_input, ready_size);<br>
+ // Keep appending to end_of_output.<br>
+ end_of_output += ready_size;<br>
+ }<br>
+ // Ensure the mark never gets copied.<br>
+ start_of_input = mark_pos + mark_size;<br>
+ // Find the next mark.<br>
+ mark_pos = next_mark(start_of_input, &mark_size);<br>
+<br>
+ } while (mark_pos && *mark_pos); // No more marks.<br>
+<br>
+ // Copy any trailing input text AND always the terminating null.<br>
+ memmove(end_of_output, start_of_input, strlen(start_of_input)+1);<br>
return 0;<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
sword-cvs mailing list<br>
<a href="mailto:sword-cvs@crosswire.org">sword-cvs@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-cvs" target="_blank">http://www.crosswire.org/mailman/listinfo/sword-cvs</a><br>
</blockquote></div><br></div>