From 73bdced7d35bd7cfd80d3b3f100fe0952b5aaa6a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 14 Feb 2011 09:21:22 +0000 Subject: [PATCH] 2011-02-14 10:20 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/hbdoc.prg + Added logic to detect in which column the actual content starts and read it accordingly. It uses the first content line as a base, so if that one is wrong, the content will be read wrongly and such NG sources should be fixed manually. * On output it will always start content in column 8 (base 1). * contrib/hbmysql/mysql.c ! MYSQL_REAL_ESCAPE_STRING() fixed taking wrong params. Reported by Bacco, thanks! * contrib/hbrun/pullext.prg * contrib/hbrun/hbrun.prg * contrib/hbrun/plugins.prg * contrib/hbrun/headers.prg * Formatting. --- harbour/ChangeLog | 19 +++++++++++++++++++ harbour/contrib/hbmysql/mysql.c | 4 ++-- harbour/contrib/hbrun/hbrun.prg | 18 +++++++++--------- harbour/contrib/hbrun/headers.prg | 2 +- harbour/contrib/hbrun/plugins.prg | 6 ++---- harbour/contrib/hbrun/pullext.prg | 4 ++-- harbour/src/rtl/hbdoc.prg | 10 ++++++++-- 7 files changed, 43 insertions(+), 20 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b7216f6a78..99628debf6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,25 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-14 10:20 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/hbdoc.prg + + Added logic to detect in which column the actual + content starts and read it accordingly. + It uses the first content line as a base, so if + that one is wrong, the content will be read wrongly + and such NG sources should be fixed manually. + * On output it will always start content in column 8 (base 1). + + * contrib/hbmysql/mysql.c + ! MYSQL_REAL_ESCAPE_STRING() fixed taking wrong params. + Reported by Bacco, thanks! + + * contrib/hbrun/pullext.prg + * contrib/hbrun/hbrun.prg + * contrib/hbrun/plugins.prg + * contrib/hbrun/headers.prg + * Formatting. + 2011-02-14 01:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/hbdoc.prg * tests/hbdocext.prg diff --git a/harbour/contrib/hbmysql/mysql.c b/harbour/contrib/hbmysql/mysql.c index 5cd62dff3b..ef760e0826 100644 --- a/harbour/contrib/hbmysql/mysql.c +++ b/harbour/contrib/hbmysql/mysql.c @@ -576,8 +576,8 @@ HB_FUNC( MYSQL_REAL_ESCAPE_STRING ) /* unsigned long STDCALL mysql_real_escape_s if( mysql ) { - const char * from = hb_parcx( 1 ); - unsigned long nSize = ( unsigned long ) hb_parclen( 1 ); + const char * from = hb_parcx( 2 ); + unsigned long nSize = ( unsigned long ) hb_parclen( 2 ); char * buffer = ( char * ) hb_xgrab( nSize * 2 + 1 ); nSize = mysql_real_escape_string( mysql, buffer, from, nSize ); hb_retclen_buffer( ( char * ) buffer, nSize ); diff --git a/harbour/contrib/hbrun/hbrun.prg b/harbour/contrib/hbrun/hbrun.prg index 1ebc936d02..c4b45b8977 100644 --- a/harbour/contrib/hbrun/hbrun.prg +++ b/harbour/contrib/hbrun/hbrun.prg @@ -247,7 +247,7 @@ STATIC FUNCTION plugins_load( hPlugins, aParams ) SWITCH Lower( hb_FNameExt( cFile:__enumKey() ) ) CASE ".hbs" CASE ".prg" - cFile := hb_compileFromBuf( cFile, "-n2", "-w", "-es2", "-q0" ) + cFile := hb_compileFromBuf( cFile, hb_ProgName(), "-n2", "-w", "-es2", "-q0" ) IF cFile == NIL EXIT ENDIF @@ -303,7 +303,7 @@ STATIC FUNCTION plugins_valid_id( plugins, cID ) RETURN .F. -STATIC FUNCTION plugins_valid_list( plugins ) +STATIC FUNCTION plugins_valid_id_list( plugins ) LOCAL plugin LOCAL aList := {} @@ -345,11 +345,11 @@ STATIC PROCEDURE hbrun_Prompt( aParams, cCommand ) hbrun_HistoryLoad() - AADD( s_aHistory, padr( "quit", HB_LINE_LEN ) ) + AAdd( s_aHistory, padr( "quit", HB_LINE_LEN ) ) nHistIndex := Len( s_aHistory ) + 1 IF ISCHARACTER( cCommand ) - AADD( s_aHistory, PadR( cCommand, HB_LINE_LEN ) ) + AAdd( s_aHistory, PadR( cCommand, HB_LINE_LEN ) ) hbrun_Info( cCommand ) hbrun_Exec( cCommand ) ELSE @@ -378,7 +378,7 @@ STATIC PROCEDURE hbrun_Prompt( aParams, cCommand ) nMaxCol := MaxCol() @ nMaxRow, 0 SAY cDomain + "." @ nMaxRow, Col() GET cLine ; - PICTURE "@KS" + hb_NToS( nMaxCol - Col() + 1 ) + PICTURE "@KS" + hb_ntos( nMaxCol - Col() + 1 ) SetCursor( iif( ReadInsert(), SC_INSERT, SC_NORMAL ) ) @@ -402,7 +402,7 @@ STATIC PROCEDURE hbrun_Prompt( aParams, cCommand ) SetKey( K_INS, bKeyIns ) SetKey( HB_K_RESIZE, bKeyResize ) - IF LastKey() == K_ESC .OR. EMPTY( cLine ) .OR. ; + IF LastKey() == K_ESC .OR. Empty( cLine ) .OR. ; ( lResize .AND. LastKey() == K_ENTER ) IF lResize lResize := .F. @@ -438,7 +438,7 @@ STATIC PROCEDURE hbrun_Prompt( aParams, cCommand ) ELSEIF plugins_valid_id( plugins, SubStr( cCommand, 2 ) ) cDomain := SubStr( cCommand, 2 ) ELSE - FOR EACH tmp IN plugins_valid_list( plugins ) + FOR EACH tmp IN plugins_valid_id_list( plugins ) hbrun_ToConsole( "." + tmp ) NEXT ENDIF @@ -573,7 +573,7 @@ STATIC PROCEDURE hbrun_Err( oErr, cCommand ) ELSEIF ISCHARACTER( oErr ) cMessage += oErr ENDIF - cMessage += ";;" + ProcName( 2 ) + "(" + hb_NToS( ProcLine( 2 ) ) + ")" + cMessage += ";;" + ProcName( 2 ) + "(" + hb_ntos( ProcLine( 2 ) ) + ")" Alert( cMessage ) @@ -593,7 +593,7 @@ STATIC PROCEDURE hbrun_Exec( cCommand ) BEGIN SEQUENCE WITH {|oErr| hbrun_Err( oErr, cCommand ) } - cHRB := HB_COMPILEFROMBUF( cFunc, hb_ProgName(), "-n2", "-q2" ) + cHRB := hb_compileFromBuf( cFunc, hb_ProgName(), "-n2", "-q2" ) IF cHRB == NIL EVAL( ErrorBlock(), "Syntax error." ) ELSE diff --git a/harbour/contrib/hbrun/headers.prg b/harbour/contrib/hbrun/headers.prg index a71ebf840e..18716b89ae 100644 --- a/harbour/contrib/hbrun/headers.prg +++ b/harbour/contrib/hbrun/headers.prg @@ -4,7 +4,7 @@ /* * Harbour Project source code: - * Header puller + * header puller * * Copyright 2010-2011 Przemyslaw Czerpak * www - http://harbour-project.org diff --git a/harbour/contrib/hbrun/plugins.prg b/harbour/contrib/hbrun/plugins.prg index eeb8c80ce2..7e99fba974 100644 --- a/harbour/contrib/hbrun/plugins.prg +++ b/harbour/contrib/hbrun/plugins.prg @@ -4,7 +4,7 @@ /* * Harbour Project source code: - * plugin puller + * plugin container * * Copyright 2011 Viktor Szakats (harbour.01 syenar.hu) * www - http://harbour-project.org @@ -54,9 +54,7 @@ #pragma __streaminclude <(cFile)>|\[ <(cFile)> \] := %s FUNCTION __hbrun_plugins() - LOCAL hPlugins - - hPlugins := { => } + LOCAL hPlugins := { => } ADD PLUGIN TO hPlugins FILE "netioeng.prg" diff --git a/harbour/contrib/hbrun/pullext.prg b/harbour/contrib/hbrun/pullext.prg index 0b38c9b1b9..90fb2d821c 100644 --- a/harbour/contrib/hbrun/pullext.prg +++ b/harbour/contrib/hbrun/pullext.prg @@ -50,11 +50,11 @@ * */ -#xtranslate PULLEXT => REQUEST __HBEXTERN____ ; AAdd( aList, Lower( <"cName"> ) ) - FUNCTION __hbrun_extensions() LOCAL aList := {} + #xtranslate PULLEXT => REQUEST __HBEXTERN____ ; AAdd( aList, Lower( <"cName"> ) ) + PULLEXT hbct PULLEXT hbexpat PULLEXT hbmemio diff --git a/harbour/src/rtl/hbdoc.prg b/harbour/src/rtl/hbdoc.prg index 0aeea4f026..b87d1d7c1f 100644 --- a/harbour/src/rtl/hbdoc.prg +++ b/harbour/src/rtl/hbdoc.prg @@ -156,6 +156,7 @@ STATIC PROCEDURE __hbdoc__read_stream( aEntry, cFile, cFileName, hMeta, aErrMsg LOCAL cSection LOCAL tmp LOCAL nLine + LOCAL nStartCol cFile := StrTran( cFile, Chr( 13 ) ) cFile := StrTran( cFile, Chr( 9 ), " " ) @@ -203,8 +204,13 @@ STATIC PROCEDURE __hbdoc__read_stream( aEntry, cFile, cFileName, hMeta, aErrMsg ELSEIF ! Empty( cSection ) IF ! Empty( hEntry[ cSection ] ) hEntry[ cSection ] += Chr( 13 ) + Chr( 10 ) + ELSE + /* some "heuristics" to detect in which column the real content starts, + we assume the first line of content is correct, and use this with all + consecutive lines. [vszakats] */ + nStartCol := Len( cLine ) - Len( LTrim( cLine ) ) + 1 ENDIF - hEntry[ cSection ] += cLine + hEntry[ cSection ] += SubStr( cLine, nStartCol ) ELSEIF ! Empty( cLine ) _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$s: Content outside section", cFileName, hb_ntos( nLine ) ) ) ENDIF @@ -232,7 +238,7 @@ FUNCTION __hbdoc_ToSource( aEntry ) !( Left( item:__enumKey(), 1 ) == "_" ) cSource += " * $" + item:__enumKey() + "$" + hb_eol() FOR EACH cLine IN hb_ATokens( StrTran( item, Chr( 13 ) ), Chr( 10 ) ) - cSource += " * " + cLine + hb_eol() + cSource += " * " + Space( 4 ) + cLine + hb_eol() NEXT ENDIF NEXT