From b313865e78c091f64e8cd23f9fc336571f5cefdf Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 4 Dec 2012 13:20:54 +0000 Subject: [PATCH] 2012-12-04 14:14 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbpost.hbm * utils/hbmk2/pkg_dynl.hbm * hack to avoid contrib/addon dynamic libs being used automatically on *nix system when building executables. Now they will be put in bin dir, just like on win. * utils/hbmk2/hbmk2.prg + hbshell_include_list() API to list loaded core headers. + allow loading dynamic extensions on *nix even if built against static HVM. * display statically linked extensions in uppercase in dot prompt UI and dynamic ones with original (lower) case. (was normal case and postfixed with '*' respectively) + do not load dynamic extension if the .hbc file is not found + attempt to detect if dynamic extension loads fine on a given platform and only try loading the dynamic lib if it does. + added protection to not add duplicate compiler options when compiling dot prompt entry. * contrib/hbrun/hbrun.hbp + load default contrib libs dynamically on *nix, even if hbrun is built against static HVM. ; these make work dynamic extensions on *nix systems. * contrib/hbtip/sessid.prg * extras/httpsrv/cgifunc.prg * updated HTTP date format to use preferred format: http://tools.ietf.org/html/rfc2616#section-3.3.1 % optimized code and eliminated unnecessary _SET_DATEFORMATs ; tip_DateToGMT() and its uhttpd_DateToGMT() derivative * src/compiler/hbusage.c * updated contributor list * contrib/sddoci/tests/test1.prg * contrib/sddodbc/tests/test1.prg * contrib/sddodbc/tests/test2.prg * contrib/sddsqlt3/tests/test1.prg * use std way to configure date format --- harbour/ChangeLog.txt | 43 ++++++++++++++++++ harbour/contrib/hbpost.hbm | 6 +-- harbour/contrib/hbrun/hbrun.hbp | 6 +-- harbour/contrib/hbtip/sessid.prg | 22 +++------ harbour/contrib/sddoci/tests/test1.prg | 4 +- harbour/contrib/sddodbc/tests/test1.prg | 3 +- harbour/contrib/sddodbc/tests/test2.prg | 3 +- harbour/contrib/sddsqlt3/tests/test1.prg | 3 +- harbour/extras/httpsrv/cgifunc.prg | 26 ++++------- harbour/src/compiler/hbusage.c | 1 + harbour/utils/hbmk2/hbmk2.prg | 57 ++++++++++++++++-------- harbour/utils/hbmk2/pkg_dynl.hbm | 3 +- 12 files changed, 112 insertions(+), 65 deletions(-) diff --git a/harbour/ChangeLog.txt b/harbour/ChangeLog.txt index b460d94b28..607a359f40 100644 --- a/harbour/ChangeLog.txt +++ b/harbour/ChangeLog.txt @@ -10,6 +10,49 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2012-12-04 14:14 UTC+0100 Viktor Szakats (harbour syenar.net) + * contrib/hbpost.hbm + * utils/hbmk2/pkg_dynl.hbm + * hack to avoid contrib/addon dynamic libs being used + automatically on *nix system when building executables. + Now they will be put in bin dir, just like on win. + + * utils/hbmk2/hbmk2.prg + + hbshell_include_list() API to list loaded core headers. + + allow loading dynamic extensions on *nix even if built + against static HVM. + * display statically linked extensions in uppercase in + dot prompt UI and dynamic ones with original (lower) case. + (was normal case and postfixed with '*' respectively) + + do not load dynamic extension if the .hbc file is not found + + attempt to detect if dynamic extension loads fine on + a given platform and only try loading the dynamic lib + if it does. + + added protection to not add duplicate compiler options + when compiling dot prompt entry. + + * contrib/hbrun/hbrun.hbp + + load default contrib libs dynamically on *nix, even if + hbrun is built against static HVM. + + ; these make work dynamic extensions on *nix systems. + + * contrib/hbtip/sessid.prg + * extras/httpsrv/cgifunc.prg + * updated HTTP date format to use preferred format: + http://tools.ietf.org/html/rfc2616#section-3.3.1 + % optimized code and eliminated unnecessary _SET_DATEFORMATs + ; tip_DateToGMT() and its uhttpd_DateToGMT() derivative + + * src/compiler/hbusage.c + * updated contributor list + + * contrib/sddoci/tests/test1.prg + * contrib/sddodbc/tests/test1.prg + * contrib/sddodbc/tests/test2.prg + * contrib/sddsqlt3/tests/test1.prg + * use std way to configure date format + 2012-12-04 00:59 UTC+0100 Viktor Szakats (harbour syenar.net) * extras/hbusb/hbusb.ch * extras/hbvpdf/hbvpdf.ch diff --git a/harbour/contrib/hbpost.hbm b/harbour/contrib/hbpost.hbm index 6c93767ed4..963db937a9 100644 --- a/harbour/contrib/hbpost.hbm +++ b/harbour/contrib/hbpost.hbm @@ -69,14 +69,12 @@ # output dir (in sync with GNU Make) {hblib}-o../lib/${hb_plat}/${hb_comp}${hb_build}/ {hbexe}-o../bin/${hb_plat}/${hb_comp}${hb_build}/ -{hbdyn&unix&!cygwin}-o../lib/${hb_plat}/${hb_comp}${hb_build}/ -{hbdyn&(cygwin|!unix)}-o../bin/${hb_plat}/${hb_comp}${hb_build}/ +{hbdyn}-o../bin/${hb_plat}/${hb_comp}${hb_build}/ # workdir (in sync with GNU Make) {hblib}-workdir=../lib/${hb_plat}/${hb_comp}${hb_build}/${hb_work}/${hb_outputname}${hb_workdynsub} {hbexe}-workdir=../bin/${hb_plat}/${hb_comp}${hb_build}/${hb_work}/${hb_outputname}${hb_workdynsub} -{hbdyn&unix&!cygwin}-workdir=../lib/${hb_plat}/${hb_comp}${hb_build}/${hb_work}/${hb_outputname}${hb_workdynsub} -{hbdyn&(cygwin|!unix)}-workdir=../bin/${hb_plat}/${hb_comp}${hb_build}/${hb_work}/${hb_outputname}${hb_workdynsub} +{hbdyn}-workdir=../bin/${hb_plat}/${hb_comp}${hb_build}/${hb_work}/${hb_outputname}${hb_workdynsub} # copy contrib-specific public files -instfile=contrib:${_HB_CONTRIB_SUBDIR}*.hb diff --git a/harbour/contrib/hbrun/hbrun.hbp b/harbour/contrib/hbrun/hbrun.hbp index 01c80b572b..fb879b16f9 100644 --- a/harbour/contrib/hbrun/hbrun.hbp +++ b/harbour/contrib/hbrun/hbrun.hbp @@ -15,10 +15,10 @@ # it's required for dynamic extension loading. (only # do that if HB_BUILD_CONTRIB_DYN is enabled, so there # are actual dynamic extensions to load.) -{_HB_BUILD_&(!(HB_BUILD_DYN='no')&!(HB_BUILD_CONTRIB_DYN='no')&(win|wce|os2))}-env:__HBMKDYN=yes +{_HB_BUILD_&(!(HB_BUILD_DYN='no')&!(HB_BUILD_CONTRIB_DYN='no')&(win|wce|os2))}-shared +{shared|(unix&!(HB_BUILD_CONTRIB_DYN='no'))}-env:__HBMKDYN=yes -{__HBMKDYN='yes'}-shared -{__HBMKDYN='yes'}-DHBMK_WITH_EXTS=hbct|hbexpat|hbmemio|hbmzip|hbnetio|hbunix|hbunix|hbwin +{__HBMKDYN='yes'}-DHBMK_WITH_EXTS=hbct|hbexpat|hbmemio|hbmzip|hbnetio|hbunix|hbwin {!(__HBMKDYN='yes')}hbct.hbc {!(__HBMKDYN='yes')}-request=__HBEXTERN__HBCT__ {!(__HBMKDYN='yes')}hbexpat.hbc {!(__HBMKDYN='yes')}-request=__HBEXTERN__HBEXPAT__ diff --git a/harbour/contrib/hbtip/sessid.prg b/harbour/contrib/hbtip/sessid.prg index a09aa6db17..81ffef0b54 100644 --- a/harbour/contrib/hbtip/sessid.prg +++ b/harbour/contrib/hbtip/sessid.prg @@ -125,23 +125,15 @@ FUNCTION tip_CheckSID( cSID, cCRCKey ) FUNCTION tip_DateToGMT( dDate, cTime ) - LOCAL cStr - LOCAL cOldDateFormat := Set( _SET_DATEFORMAT, "dd-mm-yy" ) - LOCAL nDay, nMonth, nYear, nDoW - LOCAL aDays := { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } + LOCAL aDays := { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } LOCAL aMonths := { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } hb_default( @dDate, Date() ) hb_default( @cTime, Time() ) - nDay := Day( dDate ) - nMonth := Month( dDate ) - nYear := Year( dDate ) - nDoW := DoW( dDate ) - - cStr := aDays[ nDow ] + ", " + StrZero( nDay, 2 ) + "-" + aMonths[ nMonth ] + "-" + ; - Right( StrZero( nYear, 4 ), 2 ) + " " + cTime + " GMT" - - Set( _SET_DATEFORMAT, cOldDateFormat ) - - RETURN cStr + RETURN ; + aDays[ DoW( dDate ) ] + ", " + ; + StrZero( Day( dDate ), 2 ) + " " + ; + aMonths[ Month( dDate ) ] + " " + ; + StrZero( Year( dDate ), 4 ) + " " + ; + cTime + " GMT" diff --git a/harbour/contrib/sddoci/tests/test1.prg b/harbour/contrib/sddoci/tests/test1.prg index 5316f10da1..18727b4e48 100644 --- a/harbour/contrib/sddoci/tests/test1.prg +++ b/harbour/contrib/sddoci/tests/test1.prg @@ -20,7 +20,9 @@ PROCEDURE Main() #endif rddSetDefault( "SQLMIX" ) - Set( _SET_DATEFORMAT, "yyyy-mm-dd" ) + + SET DATE ANSI + SET CENTURY ON AEval( rddList(), {| X | QOut( X ) } ) diff --git a/harbour/contrib/sddodbc/tests/test1.prg b/harbour/contrib/sddodbc/tests/test1.prg index b38ba62c50..2a91377d6c 100644 --- a/harbour/contrib/sddodbc/tests/test1.prg +++ b/harbour/contrib/sddodbc/tests/test1.prg @@ -18,7 +18,8 @@ PROCEDURE Main() #endif rddSetDefault( "SQLMIX" ) - Set( _SET_DATEFORMAT, "yyyy-mm-dd" ) + SET DATE ANSI + SET CENTURY ON ? "Connect:", rddInfo( RDDI_CONNECT, { "ODBC", "DBQ=" + hb_DirBase() + "..\..\hbodbc\tests\test.mdb;Driver={Microsoft Access Driver (*.mdb)}" } ) ? "Use:", dbUseArea( .T., , "select * from test", "test" ) ? "Alias:", Alias() diff --git a/harbour/contrib/sddodbc/tests/test2.prg b/harbour/contrib/sddodbc/tests/test2.prg index 345b28557b..806e27bf94 100644 --- a/harbour/contrib/sddodbc/tests/test2.prg +++ b/harbour/contrib/sddodbc/tests/test2.prg @@ -14,7 +14,8 @@ PROCEDURE Main() LOCAL nConnection, nI, aI rddSetDefault( "SQLMIX" ) - Set( _SET_DATEFORMAT, "yyyy-mm-dd" ) + SET DATE ANSI + SET CENTURY ON nConnection := rddInfo( RDDI_CONNECT, { "ODBC", "Server=localhost;Driver={MySQL ODBC 5.1 Driver};dsn=;User=test;database=test;" } ) IF nConnection == 0 ? "Unable connect to server", rddInfo( RDDI_ERRORNO ), rddInfo( RDDI_ERROR ) diff --git a/harbour/contrib/sddsqlt3/tests/test1.prg b/harbour/contrib/sddsqlt3/tests/test1.prg index 3407ad85e8..d089c0d650 100644 --- a/harbour/contrib/sddsqlt3/tests/test1.prg +++ b/harbour/contrib/sddsqlt3/tests/test1.prg @@ -20,7 +20,8 @@ PROCEDURE Main() #endif rddSetDefault( "SQLMIX" ) - Set( _SET_DATEFORMAT, "yyyy-mm-dd" ) + SET DATE ANSI + SET CENTURY ON AEval( rddList(), {| X | QOut( X ) } ) diff --git a/harbour/extras/httpsrv/cgifunc.prg b/harbour/extras/httpsrv/cgifunc.prg index 01eeb95b9f..9cd478173b 100644 --- a/harbour/extras/httpsrv/cgifunc.prg +++ b/harbour/extras/httpsrv/cgifunc.prg @@ -396,15 +396,12 @@ FUNCTION uhttpd_URLDecode( cString ) * cTime : default "00:00:00" * nDayToAdd : default 0 - may be a negative number * - * cGMTDate : The string return in form of "Saturday, 31-Oct-03 00:00:00 GMT" + * cGMTDate : The string return in form of "Sat, 31 Oct 2003 00:00:00 GMT" */ FUNCTION uhttpd_DateToGMT( dDate, cTime, nDayToAdd, nSecsToAdd ) - LOCAL cStr - LOCAL cOldDateFormat := Set( _SET_DATEFORMAT, "dd-mm-yy" ) - LOCAL nDay, nMonth, nYear, nDoW - LOCAL aDays := { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } + LOCAL aDays := { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } LOCAL aMonths := { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } __defaultNIL( @dDate, Date() ) @@ -417,19 +414,12 @@ FUNCTION uhttpd_DateToGMT( dDate, cTime, nDayToAdd, nSecsToAdd ) cTime := uhttpd_AddSecondsToTime( cTime, nSecsToAdd, @nDayToAdd ) dDate += nDayToAdd - nDay := Day( dDate ) - nMonth := Month( dDate ) - nYear := Year( dDate ) - nDoW := DoW( dDate ) - - cStr := aDays[ nDow ] + ", " + StrZero( nDay, 2 ) + "-" + aMonths[ nMonth ] + "-" + ; - Right( StrZero( nYear, 4 ), 2 ) + " " + cTime + " GMT" - - // TraceLog( "DateToGMT", cStr ) - - Set( _SET_DATEFORMAT, cOldDateFormat ) - - RETURN cStr + RETURN ; + aDays[ DoW( dDate ) ] + ", " + ; + StrZero( Day( dDate ), 2 ) + " " + ; + aMonths[ Month( dDate ) ] + " " + ; + StrZero( Year( dDate ), 4 ) + " " + ; + cTime + " GMT" /* * AddSecondsToTime( cTime, nSecsToAdd, @nDaysAdded ) --> cNewTime diff --git a/harbour/src/compiler/hbusage.c b/harbour/src/compiler/hbusage.c index c7689954f0..3e70f5d9a1 100644 --- a/harbour/src/compiler/hbusage.c +++ b/harbour/src/compiler/hbusage.c @@ -186,6 +186,7 @@ void hb_compPrintCredits( HB_COMP_DECL ) " (replace space with @ in e-mail addresses)\n" "\n" "Alejandro de Garate (alex_degarate hotmail com)\n" + "Aleksander Czajczynski \n" "Alex Shashkov (shashkov ostu.ru)\n" "Alexander S. Kresin (alex belacy.belgorod.su)\n" "Alexey Myronenko (m.oleksa ukr.net)\n" diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 23c0bf54a3..2cbd3406a8 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -12850,7 +12850,7 @@ STATIC PROCEDURE __hbshell( cFile, ... ) hbmk := s_hbmk := hbmk_new() hbmk_init_stage2( hbmk ) IF ! hbmk_harbour_dirlayout_detect( hbmk, @l_cHB_INSTALL_PREFIX, .T. ) - IF hb_Version( HB_VERSION_SHARED ) + IF __hbshell_CanLoadDyn() OutErr( StrTran( I_( "Warning: Failed to detect Harbour.\nRun this tool from its original location inside the Harbour installation." ), "\n", hb_eol() ) + _OUT_EOL ) ENDIF ENDIF @@ -13106,11 +13106,12 @@ FUNCTION hbshell_ext_load( cName ) LOCAL cVersion IF ! Empty( cName ) - IF hb_Version( HB_VERSION_SHARED ) + IF __hbshell_CanLoadDyn() IF !( cName $ s_hLibExt ) s_hbmk[ _HBMK_aINCPATH ] := {} s_hbmk[ _HBMK_aCH ] := {} + s_hbmk[ _HBMK_aLIBUSER ] := {} s_hINCPATH[ cName ] := {} s_hCH[ cName ] := {} @@ -13122,19 +13123,26 @@ FUNCTION hbshell_ext_load( cName ) AEval( s_hbmk[ _HBMK_aINCPATH ], {| tmp | AAdd( s_hINCPATH[ cName ], tmp ) } ) AEval( s_hbmk[ _HBMK_aCH ], {| tmp | AAdd( s_hCH[ cName ], tmp ) } ) AAddNew( s_hOPTPRG[ cName ], "-D" + hb_StrFormat( _HBMK_HAS_TPL_HBC, StrToDefine( cName ) ) + "=" + cVersion ) - ENDIF - cFileName := FindInPath( tmp := hb_libName( cName + hb_libPostfix() ), ; - iif( hb_Version( HB_VERSION_UNIX_COMPAT ), GetEnv( "LD_LIBRARY_PATH" ), GetEnv( "PATH" ) ) ) - IF Empty( cFileName ) - OutErr( hb_StrFormat( I_( "'%1$s' (%2$s) not found." ), cName, tmp ) + _OUT_EOL ) - ELSE - hLib := hb_libLoad( cFileName ) - IF Empty( hLib ) - OutErr( hb_StrFormat( I_( "Error loading '%1$s' (%2$s)." ), cName, cFileName ) + _OUT_EOL ) - ELSE - s_hLibExt[ cName ] := hLib - RETURN .T. + /* NOTE: Hack. We detect if the .hbc had defined any libs to load. + (f.e. there won't be any libs if the .hbc was skipped due + to filters) + TODO: In the future the .hbc should specify a list of dynamic libs + to load, and we should load those, if any. */ + IF ! Empty( s_hbmk[ _HBMK_aLIBUSER ] ) + cFileName := FindInPath( tmp := hb_libName( cName + hb_libPostfix() ), ; + iif( hb_Version( HB_VERSION_UNIX_COMPAT ), GetEnv( "LD_LIBRARY_PATH" ), GetEnv( "PATH" ) ) ) + IF Empty( cFileName ) + OutErr( hb_StrFormat( I_( "'%1$s' (%2$s) not found." ), cName, tmp ) + _OUT_EOL ) + ELSE + hLib := hb_libLoad( cFileName ) + IF Empty( hLib ) + OutErr( hb_StrFormat( I_( "Error loading '%1$s' (%2$s)." ), cName, cFileName ) + _OUT_EOL ) + ELSE + s_hLibExt[ cName ] := hLib + RETURN .T. + ENDIF + ENDIF ENDIF ENDIF ENDIF @@ -13163,7 +13171,7 @@ FUNCTION hbshell_ext_get_list() LOCAL hLib FOR EACH hLib IN s_hLibExt - aName[ hLib:__enumIndex() ] := hLib:__enumKey() + iif( Empty( hLib ), "", "*" ) + aName[ hLib:__enumIndex() ] := iif( Empty( hLib ), Upper( hLib:__enumKey() ), hLib:__enumKey() ) NEXT ASort( aName ) @@ -13617,10 +13625,15 @@ STATIC PROCEDURE __hbshell_Info( cCommand ) hb_DispOutAt( 1, MaxCol(), "o", "R/BG" ) ENDIF - hb_DispOutAt( 2, 0, PadR( "Ext: " + ArrayToList( hbshell_ext_get_list(), ", " ), MaxCol() + 1 ), iif( hb_Version( HB_VERSION_SHARED ), "W/B", "N/N*" ) ) + hb_DispOutAt( 2, 0, PadR( "Ext: " + ArrayToList( hbshell_ext_get_list(), ", " ), MaxCol() + 1 ), iif( __hbshell_CanLoadDyn(), "W/B", "N/N*" ) ) RETURN +STATIC FUNCTION __hbshell_CanLoadDyn() + /* Can load them only in -shared builds on Windows, + because dynlibs are built against harbour.dll. */ + RETURN hb_Version( HB_VERSION_UNIX_COMPAT ) .OR. hb_Version( HB_VERSION_SHARED ) + STATIC PROCEDURE __hbshell_Err( oErr, cCommand ) LOCAL xArg, cMessage @@ -13657,9 +13670,9 @@ STATIC PROCEDURE __hbshell_Exec( cCommand ) ENDIF hb_HEval( s_hINCPATH, {| cExt | - AEval( s_hINCPATH[ cExt ], {| tmp | AAdd( aOPTPRG, "-i" + tmp ) } ) - AEval( s_hCH[ cExt ] , {| tmp | AAdd( aOPTPRG, "-u+" + tmp ) } ) - AEval( s_hOPTPRG[ cExt ] , {| tmp | AAdd( aOPTPRG, tmp ) } ) + AEval( s_hINCPATH[ cExt ], {| tmp | AAddNew( aOPTPRG, "-i" + tmp ) } ) + AEval( s_hCH[ cExt ] , {| tmp | AAddNew( aOPTPRG, "-u+" + tmp ) } ) + AEval( s_hOPTPRG[ cExt ] , {| tmp | AAddNew( aOPTPRG, tmp ) } ) RETURN NIL } ) @@ -13942,6 +13955,12 @@ FUNCTION hbshell_uninclude( cName ) RETURN .F. +PROCEDURE hbshell_include_list() + + hb_HEval( s_hCHCORE, {| tmp | __hbshell_ToConsole( tmp ) } ) + + RETURN + /* Public hbshell API */ FUNCTION hbshell_DirBase() RETURN s_cDirBase_hbshell diff --git a/harbour/utils/hbmk2/pkg_dynl.hbm b/harbour/utils/hbmk2/pkg_dynl.hbm index 7f09e94ae8..b364bbde45 100644 --- a/harbour/utils/hbmk2/pkg_dynl.hbm +++ b/harbour/utils/hbmk2/pkg_dynl.hbm @@ -34,5 +34,4 @@ {hbdyn&!unix&!allwin}-o${hb_outputname}${hb_dynsuffix} # output dir (in sync with GNU Make) -{hbdyn&unix&!cygwin}-olib/${hb_plat}/${hb_comp}${hb_build}/ -{hbdyn&(cygwin|!unix)}-obin/${hb_plat}/${hb_comp}${hb_build}/ +{hbdyn}-obin/${hb_plat}/${hb_comp}${hb_build}/