[Kde-cygwin-cvs] CVS: qt-3/src/kernel qfont_win.cpp, 1.1.2.17,
1.1.2.18
Peter Kuemmel
kuemmel at coffeelogic.de
Wed Sep 8 10:47:45 CEST 2004
Using _tcsncpy prevents preprocessor macros!
Functions:
char *strncpy ( char * , const char * , size_t );
wchar_t *wcsncpy ( wchar_t *, const wchar_t *, size_t );
A small table for _tcsncpy:
UNICODE | NO yes
-------------------------------
_tcsncpy | strncpy wcsncpy
LPTSTR | LPSTR LPWSTR
Types in WinNT.h:
typedef char CHAR
typedef CHAR * LPSTR
typedef CONST CHAR * LPCSTR
and
typedef wchar_t WCHAR
typedef WCHAR * LPWSTR
typedef CONST WCHAR * LPCWST
Hence,
_tcsncpy( ( LPTSTR ) lf.lfFaceName, ( LPCTSTR ) qt_winTchar(subFamily,0), 32 );
and the diff:
Index: qfont_win.cpp
===================================================================
RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qfont_win.cpp,v
retrieving revision 1.1.2.17
diff -u -b -B -r1.1.2.17 qfont_win.cpp
--- qfont_win.cpp 6 Sep 2004 03:20:57 -0000 1.1.2.17
+++ qfont_win.cpp 8 Sep 2004 08:37:43 -0000
@@ -1032,22 +1032,10 @@
QString subFamily = QFont::substitute( request.family );
if ( request.family )
-#if UNICODE
-
- wcsncpy( ( LPTSTR ) lf.lfFaceName, subFamily.ucs2(), 32 );
-#else
-
- strncpy( ( LPTSTR ) lf.lfFaceName, subFamily.latin1(), 32 );
-#endif
-
- else // FIXME: What to set in case of no valid substitutions (Ha)
-#if UNICODE
-
- wcsncpy( ( LPTSTR ) lf.lfFaceName, QString( "Default Font" ).ucs2(), 32 );
-#else
-
- strncpy( ( LPTSTR ) lf.lfFaceName, QString( "Default Font" ).latin1(), 32 );
-#endif
+ _tcsncpy( ( LPTSTR ) lf.lfFaceName, ( LPCTSTR ) qt_winTchar(subFamily,0), 32 );
+ else
+ _tcsncpy( ( LPTSTR ) lf.lfFaceName, ( LPCTSTR ) qt_winTchar(QString("Default Font"),0), 32 );
+ // FIXME: What to set in case of no valid substitutions (Ha)
Cheers,
Peter
Ralf Habacker wrote:
> Update of /cvsroot/kde-cygwin/qt-3/src/kernel
> In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15492/src/kernel
>
> Modified Files:
> Tag: QT_WIN32_3_BRANCH
> qfont_win.cpp
> Log Message:
> fixed unicode type conversation problem
>
> Index: qfont_win.cpp
> ===================================================================
> RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qfont_win.cpp,v
> retrieving revision 1.1.2.17
> retrieving revision 1.1.2.18
> diff -u -r1.1.2.17 -r1.1.2.18
> --- qfont_win.cpp 6 Sep 2004 03:20:57 -0000 1.1.2.17
> +++ qfont_win.cpp 8 Sep 2004 06:38:21 -0000 1.1.2.18
> @@ -1032,18 +1032,18 @@
> QString subFamily = QFont::substitute( request.family );
>
> if ( request.family )
> -#if UNICODE
> +#if defined(UNICODE)
>
> - wcsncpy( ( LPTSTR ) lf.lfFaceName, subFamily.ucs2(), 32 );
> + wcsncpy( (wchar_t *) lf.lfFaceName, (wchar_t *) subFamily.ucs2(), 32 );
> #else
>
> strncpy( ( LPTSTR ) lf.lfFaceName, subFamily.latin1(), 32 );
> #endif
>
> else // FIXME: What to set in case of no valid substitutions (Ha)
> -#if UNICODE
> +#if defined(UNICODE)
>
> - wcsncpy( ( LPTSTR ) lf.lfFaceName, QString( "Default Font" ).ucs2(), 32 );
> + wcsncpy( ( wchar_t *) lf.lfFaceName, (wchar_t *) QString( "Default Font" ).ucs2(), 32 );
> #else
>
> strncpy( ( LPTSTR ) lf.lfFaceName, QString( "Default Font" ).latin1(), 32 );
More information about the kde-cygwin
mailing list