From 105cdb0721365aea00c20c3761920642fe47a289 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Oct 2012 17:40:56 +0000 Subject: [PATCH] 2012-10-01 19:39 UTC+0200 Viktor Szakats (harbour syenar.net) * src/rtl/Makefile - src/rtl/cdpbox.prg + src/rtl/cdpbox.c % HB_UTF8TOSTRBOX() converted to C --- harbour/ChangeLog | 6 +++ harbour/src/rtl/Makefile | 2 +- harbour/src/rtl/{cdpbox.prg => cdpbox.c} | 49 ++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 5 deletions(-) rename harbour/src/rtl/{cdpbox.prg => cdpbox.c} (65%) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 89d117c15f..a40b1f58cc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,12 @@ The license applies to all entries newer than 2009-04-28. */ +2012-10-01 19:39 UTC+0200 Viktor Szakats (harbour syenar.net) + * src/rtl/Makefile + - src/rtl/cdpbox.prg + + src/rtl/cdpbox.c + % HB_UTF8TOSTRBOX() converted to C + 2012-10-01 19:30 UTC+0200 Viktor Szakats (harbour syenar.net) * src/rtl/cdpbox.prg % use HB_UTF8TOSTR() instead of HB_TRANSLATE() diff --git a/harbour/src/rtl/Makefile b/harbour/src/rtl/Makefile index 1c9390217b..abb3a3ae35 100644 --- a/harbour/src/rtl/Makefile +++ b/harbour/src/rtl/Makefile @@ -25,6 +25,7 @@ C_SOURCES := \ box.c \ cdpapi.c \ cdpapihb.c \ + cdpbox.c \ cdpdetc.c \ chrasc.c \ chruni.c \ @@ -218,7 +219,6 @@ PRG_SOURCES := \ altd.prg \ browdb.prg \ browse.prg \ - cdpbox.prg \ cdpdet.prg \ checkbox.prg \ color53.prg \ diff --git a/harbour/src/rtl/cdpbox.prg b/harbour/src/rtl/cdpbox.c similarity index 65% rename from harbour/src/rtl/cdpbox.prg rename to harbour/src/rtl/cdpbox.c index 869d4e3dce..4bece575ac 100644 --- a/harbour/src/rtl/cdpbox.prg +++ b/harbour/src/rtl/cdpbox.c @@ -4,8 +4,9 @@ /* * Harbour Project source code: - * Internal support for CP agnostic box drawing chars + * HB_UTF8TOSTRBOX() * + * Copyright 2009-2012 Przemyslaw Czerpak * Copyright 2012 Viktor Szakats (harbour syenar.net) * www - http://harbour-project.org * @@ -50,7 +51,47 @@ * */ -#include "hbgtinfo.ch" +#include "hbapi.h" +#include "hbapiitm.h" +#include "hbapierr.h" +#include "hbapicdp.h" +#include "hbapigt.h" -FUNCTION hb_UTF8ToStrBox( cString ) - RETURN hb_UTF8ToStr( cString, hb_gtInfo( HB_GTI_BOXCP ) ) +HB_FUNC( HB_UTF8TOSTRBOX ) +{ + const char * szString = hb_parc( 1 ); + + if( szString ) + { + HB_SIZE nLen = hb_parclen( 1 ), nDest = 0; + char * szDest = NULL; + + if( nLen ) + { + PHB_CODEPAGE cdp = hb_gtBoxCP(); + + if( cdp ) + { + if( hb_cdpIsUTF8( cdp ) ) + { + hb_itemReturn( hb_param( 1, HB_IT_STRING ) ); + return; + } + else + { + szString = hb_parc( 1 ); + nDest = hb_cdpUTF8AsStrLen( cdp, szString, nLen, 0 ); + szDest = ( char * ) hb_xgrab( nDest + 1 ); + hb_cdpUTF8ToStr( cdp, szString, nLen, szDest, nDest + 1 ); + } + } + } + + if( szDest ) + hb_retclen_buffer( szDest, nDest ); + else + hb_retc_null(); + } + else + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +}