Am Samstag, 2. September 2006 11:05 schrieb Abdelrazak Younes:
> I have a lot of warning following the patch using MSVC. Should we fix 
> them? I guess most of them will be fixed once the code is ported to 
> char_type and docstring. I list them here for reference:
> 
> ..\..\..\trunk\src\insets\insetcollapsable.C(258) : warning C4244: 
> 'argument' : conversion from 'Paragraph::value_type' to 'char', possible 
> loss of data

That one will be fixed with one of my next patches, but I would be 
surprised if it was caused by my last commit.

> ..\..\..\trunk\src\graphics\PreviewImage.C(59) : warning C4355: 'this' : 
> used in base member initializer list

That one is bogus.

> D:\devel\lyx\trunk\src\lyxserver.h(113) : warning C4355: 'this' : used 
> in base member initializer list

That one too.

> Copy of qt_helpers.obj : warning LNK4006: "class 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > __cdecl makeFontName(class 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > const &,class std::basic_string<char,struct 
> std::char_traits<char>,class std::allocator<char> > const &)" 
> (?makeFontName@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?
[EMAIL PROTECTED]@2@@std@@[EMAIL PROTECTED]@Z) 
> already defined in qt_helpers.obj; second definition ignored

makeFontName is only defined once. Why does the compiler produce two 
copies? And is this really a new warning?

> Copy of qt_helpers.obj : warning LNK4006: "class QString const __cdecl 
> toqstr(char const *)" (?toqstr@@YA?BVQString@@[EMAIL PROTECTED]) already 
> defined in 
> qt_helpers.obj; second definition ignored
> Copy of qt_helpers.obj : warning LNK4006: "class QString const __cdecl 
> toqstr(class std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > const &)" 
> (?toqstr@@YA?BVQString@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?
[EMAIL PROTECTED]@2@@std@@@Z) 
> already defined in qt_helpers.obj; second definition ignored

Ditto. We have three versions of toqstr, but only one with a 
std::basic_string<char,struct std::char_traits<char>,class 
std::allocator<char> > argument

With the following similar warnings and this one:

> Copy of qt_helpers.obj : warning LNK4221: no public symbols found; 
> archive member will be inaccessible

this looks to me as if you include qt_helpers.obj twice in the link 
command. Maybe you project file is damaged. Can you please check that?

> ..\..\..\..\trunk\src\frontends\controllers\ControlSpellchecker.C(165) : 
> warning C4244: 'argument' : conversion from 'const 
> Paragraph::value_type' to 'char', possible loss of data

This one is fixed by the attached patch.

> ..\..\..\..\trunk\src\frontends\controllers\ControlSpellchecker.C(166) : 
> warning C4244: 'argument' : conversion from 'const 
> Paragraph::value_type' to 'unsigned char', possible loss of data

This one is not so easy (can digits be something else than ASCII 0-9?)
        
> D:\devel\lyx\trunk\src\support/lstrings.h(96) : warning C4244: 
> 'argument' : conversion from 'Paragraph::value_type' to 'char', possible 
> loss of data
> ..\..\..\..\trunk\src\frontends\controllers\ControlSpellchecker.C(138) : 
> see reference to function template instantiation 'bool 
> lyx::support::contains<Paragraph::value_type>(const std::string &,B)' 
> being compiled
>          with
>          [
>              B=Paragraph::value_type
>          ]

Fixed by this patch.

> ..\..\..\..\trunk\src\frontends\controllers\biblio.C(466) : warning 
> C4101: 'regerr' : unreferenced local variable
> BCView.C
> 
> ..\..\..\trunk\src\mathed\math_nestinset.C(928) : warning C4244: 
> 'argument' : conversion from 'const unsigned long' to 'char', possible 
> loss of data

harmless.

> ..\..\trunk\intl\dcigettext.c(1005) : warning C4116: unnamed type 
> definition in parentheses
> ..\..\trunk\intl\dcigettext.c(1006) : warning C4116: unnamed type 
> definition in parentheses
> 
> ..\..\trunk\intl\loadmsgcat.c(940) : warning C4013: 'open' undefined; 
> assuming extern returning int
> ..\..\trunk\intl\loadmsgcat.c(955) : warning C4013: 'close' undefined; 
> assuming extern returning int
> ..\..\trunk\intl\loadmsgcat.c(988) : warning C4013: 'read' undefined; 
> assuming extern returning int
>
> ..\..\..\..\trunk\boost\libs\regex\src\cregex.cpp(568) : warning C4309: 
> 'static_cast' : truncation of constant value
> 
> d:\devel\lyx\trunk\src\aspell_local.h(20) : warning C4099: 
> 'AspellSpeller' : type name first seen using 'struct' now seen 
using 'class'
>          D:\program\gnuwin32\include\aspell.h(355) : see declaration of 
> 'AspellSpeller'
> d:\devel\lyx\trunk\src\aspell_local.h(21) : warning C4099: 
> 'AspellStringEnumeration' : type name first seen using 'struct' now seen 
> using 'class'
>          D:\program\gnuwin32\include\aspell.h(549) : see declaration of 
> 'AspellStringEnumeration'
> d:\devel\lyx\trunk\src\aspell_local.h(22) : warning C4099: 
> 'AspellCanHaveError' : type name first seen using 'struct' now seen 
> using 'class'
>          D:\program\gnuwin32\include\aspell.h(219) : see declaration of 
> 'AspellCanHaveError'
> d:\devel\lyx\trunk\src\aspell_local.h(23) : warning C4099: 
> 'AspellConfig' : type name first seen using 'struct' now seen 
using 'class'
>          D:\program\gnuwin32\include\aspell.h(89) : see declaration of 
> 'AspellConfig'

all not my doing.

> ..\..\trunk\src\text3.C(952) : warning C4244: 'argument' : conversion 
> from 'lyx::char_type' to 'char', possible loss of data
> ..\..\trunk\src\text3.C(956) : warning C4244: 'argument' : conversion 
> from 'lyx::char_type' to 'char', possible loss of data

Both fixed.

> ..\..\trunk\src\text3.C(1414) : warning C4244: 'argument' : conversion 
> from 'const unsigned long' to 'char', possible loss of data

See FIXME comment.

> text2.C
> text.C
> ..\..\trunk\src\text.C(454) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'unsigned char', possible loss of data

isPrintable needs to be fixed.

> ..\..\trunk\src\text.C(460) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'unsigned char', possible loss of data

Encodings::isComposeChar_arabic ditto

> ..\..\trunk\src\text.C(464) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'unsigned char', possible loss of data

> ..\..\trunk\src\text.C(1201) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'unsigned char', possible loss of data
> ..\..\trunk\src\text.C(1209) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'unsigned char', possible loss of data
> ..\..\trunk\src\text.C(1238) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'char', possible loss of data

all fixed.

> ..\..\trunk\src\text.C(1627) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'char', possible loss of data
> ..\..\trunk\src\text.C(1630) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'char', possible loss of data
> ..\..\trunk\src\text.C(1634) : warning C4244: 'argument' : conversion 
> from 'LyXText::char_type' to 'char', possible loss of data

lowercase and uppercase need to be fixed.

> d:\devel\lyx\trunk\src\support/lstrings.h(96) : warning C4244: 
> 'argument' : conversion from 'LyXText::char_type' to 'char', possible 
> loss of data
>          ..\..\trunk\src\text.C(1201) : see reference to function 
> template instantiation 'bool 
> lyx::support::contains<LyXText::char_type>(const std::string &,B)' being 
> compiled
>          with
>          [
>              B=LyXText::char_type
>          ]

fixed. Here I got bored and did not look at the others, since they do 
probably not result from my patch. Please have a look yourself if you find 
some time.

This patch goes in now. Log:
Fix some conversion problems spotted by MSVC warnings
        * src/insets/insetquotes.[Ch]
        (InsetQuotes::InsetQuotes): char -> lyx::char_type

        * src/support/lstrings.h
        (contains): new variant for docstrings

        * src/frontends/controllers/ControlSpellchecker.C
        (isLetter): Add missing conversion to utf8
        (nextWord): ditto


Georg
Index: src/insets/insetquotes.C
===================================================================
--- src/insets/insetquotes.C	(Revision 14866)
+++ src/insets/insetquotes.C	(Arbeitskopie)
@@ -92,21 +92,21 @@ InsetQuotes::InsetQuotes(quote_language 
 {}
 
 
-InsetQuotes::InsetQuotes(char c, BufferParams const & params)
+InsetQuotes::InsetQuotes(lyx::char_type c, BufferParams const & params)
 	: language_(params.quotes_language), times_(params.quotes_times)
 {
 	getPosition(c);
 }
 
 
-InsetQuotes::InsetQuotes(char c, quote_language l, quote_times t)
+InsetQuotes::InsetQuotes(lyx::char_type c, quote_language l, quote_times t)
 	: language_(l), times_(t)
 {
 	getPosition(c);
 }
 
 
-void InsetQuotes::getPosition(char c)
+void InsetQuotes::getPosition(lyx::char_type c)
 {
 	// Decide whether left or right
 	switch (c) {
Index: src/insets/insetquotes.h
===================================================================
--- src/insets/insetquotes.h	(Revision 14866)
+++ src/insets/insetquotes.h	(Arbeitskopie)
@@ -15,6 +15,8 @@
 
 #include "inset.h"
 
+#include "support/types.h"
+
 class BufferParams;
 class Language;
 
@@ -66,9 +68,9 @@ public:
 	explicit
 	InsetQuotes(std::string const & str = "eld");
 	/// Create the right quote inset after character c
-	InsetQuotes(char c, BufferParams const & params);
+	InsetQuotes(lyx::char_type c, BufferParams const & params);
 	/// Direct access to inner/outer quotation marks
-	InsetQuotes(char c, quote_language l, quote_times t);
+	InsetQuotes(lyx::char_type c, quote_language l, quote_times t);
 	///
 	void metrics(MetricsInfo &, Dimension &) const;
 	///
@@ -117,7 +119,7 @@ private:
 	 */
 	InsetQuotes(quote_language l, quote_side s, quote_times t);
 	/// Decide whether we need left or right quotation marks
-	void getPosition(char c);
+	void getPosition(lyx::char_type c);
 	///
 	void parseString(std::string const &);
 	///
Index: src/support/lstrings.h
===================================================================
--- src/support/lstrings.h	(Revision 14866)
+++ src/support/lstrings.h	(Arbeitskopie)
@@ -19,7 +19,6 @@
 #include "support/types.h"
 
 #include <vector>
-#include <string>
 
 
 namespace lyx {
@@ -96,6 +95,12 @@ bool contains(std::string const & a, B b
 	return a.find(b) != std::string::npos;
 }
 
+template <typename B>
+bool contains(lyx::docstring const & a, B b)
+{
+	return a.find(b) != lyx::docstring::npos;
+}
+
 ///
 bool containsOnly(std::string const &, std::string const &);
 
Index: src/frontends/controllers/ControlSpellchecker.C
===================================================================
--- src/frontends/controllers/ControlSpellchecker.C	(Revision 14866)
+++ src/frontends/controllers/ControlSpellchecker.C	(Arbeitskopie)
@@ -134,7 +134,7 @@ bool isLetter(DocIterator const & dit)
 		&& dit.pos() != dit.lastpos()
 		&& (dit.paragraph().isLetter(dit.pos())
 		    // We want to pass the ' and escape chars to ispell
-		    || contains(lyxrc.isp_esc_chars + '\'',
+		    || contains(lyx::from_utf8(lyxrc.isp_esc_chars + '\''),
 				dit.paragraph().getChar(dit.pos())))
 		&& !isDeletedText(dit.paragraph(), dit.pos());
 }
@@ -146,7 +146,8 @@ WordLangTuple nextWord(LCursor & cur, pt
 	bool inword = false;
 	bool ignoreword = false;
 	cur.resetAnchor();
-	string word, lang_code;
+	docstring word;
+	string lang_code;
 
 	while (cur.depth()) {
 		if (isLetter(cur)) {
@@ -170,7 +171,7 @@ WordLangTuple nextWord(LCursor & cur, pt
 			if (inword)
 				if (!word.empty() && !ignoreword) {
 					cur.setSelection();
-					return WordLangTuple(word, lang_code);
+					return WordLangTuple(lyx::to_utf8(word), lang_code);
 				} else
 					inword = false;
 		}

Reply via email to