From f90c989f05612fa75c13b9c0e9c6dfd740bb02b0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 1 Jul 2010 07:58:22 +0000 Subject: [PATCH] 2010-07-01 09:56 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/hbmk2_plugin_qt.prg + Added .qrc to .prg generator logic. ! Fixed .qrc to .c generator leaving last few bytes off. % Optimized .qrc to .c generator output to have only one line. * utils/hbrun/hbrun.prg + Internal history length changed to 128 (from 32). - Deleted extra limit on number of saved history items. % Minor optimization to history saving. * src/rtl/gtsln/gtsln.c * Whitespace formatting. --- harbour/ChangeLog | 15 +++++ harbour/contrib/hbqt/hbmk2_plugin_qt.prg | 73 +++++++++++++++++------- harbour/src/rtl/gtsln/gtsln.c | 28 ++++----- harbour/utils/hbrun/hbrun.prg | 13 ++--- 4 files changed, 87 insertions(+), 42 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 73f586e258..a1799b2d96 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,21 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-01 09:56 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbqt/hbmk2_plugin_qt.prg + + Added .qrc to .prg generator logic. + ! Fixed .qrc to .c generator leaving last few bytes off. + % Optimized .qrc to .c generator output to have only one + line. + + * utils/hbrun/hbrun.prg + + Internal history length changed to 128 (from 32). + - Deleted extra limit on number of saved history items. + % Minor optimization to history saving. + + * src/rtl/gtsln/gtsln.c + * Whitespace formatting. + 2010-07-01 02:31 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/compiler/harbour.y * harbour/src/compiler/harbour.yyh diff --git a/harbour/contrib/hbqt/hbmk2_plugin_qt.prg b/harbour/contrib/hbqt/hbmk2_plugin_qt.prg index 8eddb7ea76..937af21c41 100644 --- a/harbour/contrib/hbqt/hbmk2_plugin_qt.prg +++ b/harbour/contrib/hbqt/hbmk2_plugin_qt.prg @@ -255,7 +255,7 @@ FUNCTION hbmk2_plugin_qt( hbmk2 ) EXIT ENDIF ELSE - IF ! qrc_bin_to_c( hbmk2, cTmp, cDst, hbmk2_FNameToSymbol( hbmk2_FNameNameGet( cSrc ) ) ) + IF ! qrc_bin_to_src( hbmk2, cTmp, cDst, hbmk2_FNameToSymbol( hbmk2_FNameNameGet( cSrc ) ) ) IF ! hbmk2[ "lIGNOREERROR" ] FErase( cTmp ) cRetVal := "error" @@ -378,7 +378,7 @@ PROCEDURE Main( cSrc, cDst ) SWITCH Lower( cExt ) CASE ".qrc" IF ( nError := hb_processRun( "rcc " + cSrc + " -binary -o " + cTmp ) ) == 0 - IF ! qrc_bin_to_c( NIL, cTmp, cDst, cName ) + IF ! qrc_bin_to_src( NIL, cTmp, cDst, cName ) nError := 9 ENDIF ELSE @@ -417,11 +417,12 @@ STATIC FUNCTION hbmk2_OutErr( hbmk2, ... ) #endif -STATIC FUNCTION qrc_bin_to_c( hbmk2, cFileNameSrc, cFileNameDst, cName ) +STATIC FUNCTION qrc_bin_to_src( hbmk2, cFileNameSrc, cFileNameDst, cName ) LOCAL cFile LOCAL cChar LOCAL cOutput LOCAL cLine + LOCAL cExt IF hb_FileExists( cFileNameSrc ) @@ -429,28 +430,58 @@ STATIC FUNCTION qrc_bin_to_c( hbmk2, cFileNameSrc, cFileNameDst, cName ) IF ! Empty( cFile ) + cName := "hbqtres_" + cName + + hb_FNameSplit( cFileNameDst,,, @cExt ) + cOutput := "/* WARNING: Automatically generated source file. DO NOT EDIT! */" + hb_osNewLine() cOutput += hb_osNewLine() - cOutput += '#include "hbapi.h"' + hb_osNewLine() - cOutput += hb_osNewLine() - cOutput += "HB_FUNC( " + Upper( "hbqtres_" + cName ) + " )" + hb_osNewLine() - cOutput += "{" + hb_osNewLine() - cOutput += Chr( 9 ) + "static const char s_res_data[] =" + hb_osNewLine() - cOutput += Chr( 9 ) + "{" + hb_osNewLine() - cLine := Chr( 9 ) + Chr( 9 ) - FOR EACH cChar IN cFile - cLine += "0x" + hb_NumToHex( Asc( cChar ) ) + "," - IF Len( cLine ) >= 74 - cOutput += cLine + hb_osNewLine() - cLine := Chr( 9 ) + Chr( 9 ) - ENDIF - NEXT + SWITCH Lower( cExt ) + CASE ".c" - cOutput += Chr( 9 ) + "};" + hb_osNewLine() - cOutput += hb_osNewLine() - cOutput += Chr( 9 ) + "hb_retclen_const( s_res_data, sizeof( s_res_data ) );" + hb_osNewLine() - cOutput += "}" + hb_osNewLine() + cOutput += '#include "hbapi.h"' + hb_osNewLine() + cOutput += hb_osNewLine() + cOutput += "HB_FUNC( " + Upper( cName ) + " )" + hb_osNewLine() + cOutput += "{" + hb_osNewLine() + cOutput += Chr( 9 ) + "static const char s_res_data[] =" + hb_osNewLine() + cOutput += Chr( 9 ) + "{" + hb_osNewLine() + + cOutput += Chr( 9 ) + Chr( 9 ) + FOR EACH cChar IN cFile + cOutput += "0x" + hb_NumToHex( Asc( cChar ) ) + "," + NEXT + + cOutput += hb_osNewLine() + + cOutput += Chr( 9 ) + "};" + hb_osNewLine() + cOutput += hb_osNewLine() + cOutput += Chr( 9 ) + "hb_retclen_const( s_res_data, sizeof( s_res_data ) );" + hb_osNewLine() + cOutput += "}" + hb_osNewLine() + + EXIT + + CASE ".prg" + + cOutput += "#pragma -km+" + hb_osNewLine() + cOutput += hb_osNewLine() + cOutput += "FUNCTION " + cName + "()" + hb_osNewLine() + cOutput += Chr( 9 ) + "RETURN ;" + hb_osNewLine() + + cLine := Chr( 9 ) + Chr( 9 ) + "e" + Chr( 34 ) + FOR EACH cChar IN cFile + cLine += "\x" + hb_NumToHex( Asc( cChar ), 2 ) + IF Len( cLine ) >= 1024 + cOutput += cLine + Chr( 34 ) + " +;" + hb_osNewLine() + cLine := Chr( 9 ) + Chr( 9 ) + "e" + Chr( 34 ) + ENDIF + NEXT + + cOutput += cLine + Chr( 34 ) + hb_osNewLine() + + EXIT + + ENDSWITCH IF hb_MemoWrit( cFileNameDst, cOutput ) RETURN .T. diff --git a/harbour/src/rtl/gtsln/gtsln.c b/harbour/src/rtl/gtsln/gtsln.c index 33b5f6c5fc..20da016d2f 100644 --- a/harbour/src/rtl/gtsln/gtsln.c +++ b/harbour/src/rtl/gtsln/gtsln.c @@ -303,13 +303,13 @@ static void hb_sln_setACSCtrans( void ) } HB_SLN_BUILD_RAWCHAR( SLch, 0, 0 ); - for ( i = 0; i < 3 && !HB_SLN_IS_CHAR( SLch ); i++ ) + for( i = 0; i < 3 && !HB_SLN_IS_CHAR( SLch ); i++ ) SLch = chBoard[ i ]; - if ( !HB_SLN_IS_CHAR( SLch ) ) + if( !HB_SLN_IS_CHAR( SLch ) ) HB_SLN_BUILD_RAWCHAR( SLch, '#', 0 ); - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - if ( !HB_SLN_IS_CHAR( chBoard[ i ] ) ) + if( !HB_SLN_IS_CHAR( chBoard[ i ] ) ) chBoard[ i ] = SLch; } s_outputTab[ 176 ] = chBoard[ 0 ]; @@ -332,7 +332,7 @@ static void hb_sln_setACSCtrans( void ) * Below it's a hack for this version of slang which fix the * problem. */ - if ( SLSMG_UTEE_CHAR_TERM == 'v' ) + if( SLSMG_UTEE_CHAR_TERM == 'v' ) { SLch = s_outputTab[ 193 ]; s_outputTab[ 193 ] = s_outputTab[ 194 ]; @@ -413,7 +413,7 @@ static void hb_sln_setKeyTrans( PHB_CODEPAGE cdpHost, PHB_CODEPAGE cdpTerm ) char *p; int i; - for ( i = 0; i < 256; i++ ) + for( i = 0; i < 256; i++ ) hb_sln_inputTab[ i ] = ( unsigned char ) hb_cdpTranslateChar( i, HB_FALSE, cdpTerm, cdpHost ); hb_sln_cdpIN = cdpTerm ? cdpTerm : cdpHost; @@ -831,7 +831,7 @@ static const char * hb_gt_sln_Version( PHB_GT pGT, int iType ) HB_SYMBOL_UNUSED( pGT ); - if ( iType == 0 ) + if( iType == 0 ) return HB_GT_DRVNAME( HB_GT_NAME ); return "Harbour Terminal: Slang"; @@ -907,7 +907,7 @@ static HB_BOOL hb_gt_sln_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_sln_Info(%p,%d,%p)", pGT, iType, pInfo ) ); - switch ( iType ) + switch( iType ) { case HB_GTI_FULLSCREEN: case HB_GTI_KBDSUPPORT: @@ -941,12 +941,12 @@ static HB_BOOL hb_gt_sln_SetDispCP( PHB_GT pGT, const char * pszTermCDP, const c { PHB_CODEPAGE cdpTerm = NULL, cdpHost = NULL; - if ( pszHostCDP ) + if( pszHostCDP ) cdpHost = hb_cdpFind( pszHostCDP ); - if ( ! cdpHost ) + if( ! cdpHost ) cdpHost = hb_vmCDP(); - if ( pszTermCDP ) + if( pszTermCDP ) cdpTerm = hb_cdpFind( pszTermCDP ); hb_sln_setCharTrans( cdpHost, cdpTerm, fBox ); @@ -964,12 +964,12 @@ static HB_BOOL hb_gt_sln_SetKeyCP( PHB_GT pGT, const char * pszTermCDP, const ch { PHB_CODEPAGE cdpTerm = NULL, cdpHost = NULL; - if ( pszHostCDP ) + if( pszHostCDP ) cdpHost = hb_cdpFind( pszHostCDP ); - if ( ! cdpHost ) + if( ! cdpHost ) cdpHost = hb_vmCDP(); - if ( pszTermCDP ) + if( pszTermCDP ) cdpTerm = hb_cdpFind( pszTermCDP ); hb_sln_setKeyTrans( cdpHost, cdpTerm ); diff --git a/harbour/utils/hbrun/hbrun.prg b/harbour/utils/hbrun/hbrun.prg index 7c766038ee..900df2e726 100644 --- a/harbour/utils/hbrun/hbrun.prg +++ b/harbour/utils/hbrun/hbrun.prg @@ -70,7 +70,7 @@ REQUEST HB_GT_CGI REQUEST HB_GT_PCA REQUEST HB_GT_STD -#define HB_HISTORY_LEN 32 +#define HB_HISTORY_LEN 128 #define HB_LINE_LEN 256 #define HB_PROMPT "." @@ -387,8 +387,7 @@ STATIC FUNCTION HBRawVersion() /* ********************************************************************** */ -#define _HISTORY_DISABLE_LINE "no" -#define _HISTORY_SAVE_LINE_MAX 500 +#define _HISTORY_DISABLE_LINE "no" STATIC PROCEDURE hbrun_HistoryLoad() LOCAL cHistory @@ -411,13 +410,13 @@ STATIC PROCEDURE hbrun_HistoryLoad() STATIC PROCEDURE hbrun_HistorySave() LOCAL cHistory - LOCAL tmp + LOCAL cLine IF s_lPreserveHistory cHistory := "" - FOR tmp := Max( 1, Len( s_aHistory ) - _HISTORY_SAVE_LINE_MAX ) TO Len( s_aHistory ) - IF !( Lower( AllTrim( s_aHistory[ tmp ] ) ) == "quit" ) - cHistory += AllTrim( s_aHistory[ tmp ] ) + hb_osNewLine() + FOR EACH cLine IN s_aHistory + IF !( Lower( AllTrim( cLine ) ) == "quit" ) + cHistory += AllTrim( cLine ) + hb_osNewLine() ENDIF NEXT hb_MemoWrit( hbrun_HistoryFileName(), cHistory )