2009-12-06 19:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* src/vm/set.c
  * src/rdd/dbcmd.c
  * include/set.ch
  * include/hbset.h
    + Added support for SET( _SET_DBCODEPAGE ). This will set the
      default codepage for RDD operation. It affects following
      functions and everything which is based on them:
         DBUSEAREA()
         DBCREATE()
         HB_DBCREATETEMP()
         __DBOPENSDF()
      IOW every function which accepts current "dirty" Harbour
      extension <cCodePage>.
      This new SET() is useful if someone wants to use a different 
      than app codepage in tables, without modifying every above
      calls to pass the db CP as extra parameter (plus maintaining 
      this global setting in app code).
This commit is contained in:
Viktor Szakats
2009-12-06 19:01:01 +00:00
parent 3cba61fb5c
commit 97e5dce09c
5 changed files with 69 additions and 8 deletions

View File

@@ -17,6 +17,25 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-12-06 19:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/vm/set.c
* src/rdd/dbcmd.c
* include/set.ch
* include/hbset.h
+ Added support for SET( _SET_DBCODEPAGE ). This will set the
default codepage for RDD operation. It affects following
functions and everything which is based on them:
DBUSEAREA()
DBCREATE()
HB_DBCREATETEMP()
__DBOPENSDF()
IOW every function which accepts current "dirty" Harbour
extension <cCodePage>.
This new SET() is useful if someone wants to use a different
than app codepage in tables, without modifying every above
calls to pass the db CP as extra parameter (plus maintaining
this global setting in app code).
2009-12-06 18:48 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbide/idemisc.prg
! Minor typo in prev.
@@ -9768,7 +9787,7 @@
* contrib/hbwin/wapi_shellapi.c
+ Added _SET_OSCODEPAGE support for WAPI_SHELLEXECUTE() and
WIN_RUNDETACHED(). This may make these functions incompatible
in some situations. This clears to TODOs in source.
in some situations. This clears two TODOs in source.
* INSTALL
* Minor.
@@ -73927,7 +73946,7 @@
! Fixed get/set clipboard when format is CF_UNICODETEXT.
(untested, please someone review me)
! Fixed get clipboard when CF_TEXT/CF_OEMTEXT format
is used, so that an additionaly zero byte won't be
is used, so that an additional zero byte won't be
appended anymore to the returned string.
[1.0.0RC1] (someone pls verify this)

View File

@@ -137,7 +137,8 @@ typedef enum
HB_SET_HBOUTLOGINFO = 113,
HB_SET_CODEPAGE = 114,
HB_SET_OSCODEPAGE = 115,
HB_SET_TIMEFORMAT = 116
HB_SET_TIMEFORMAT = 116,
HB_SET_DBCODEPAGE = 117
} HB_set_enum;
@@ -216,6 +217,7 @@ typedef struct
char * HB_SET_HBOUTLOGINFO;
char * HB_SET_OSCODEPAGE;
char * HB_SET_TIMEFORMAT;
char * HB_SET_DBCODEPAGE;
} HB_SET_STRUCT, * PHB_SET_STRUCT;
@@ -332,6 +334,7 @@ extern HB_EXPORT const char * hb_setGetHBOUTLOG( void );
extern HB_EXPORT const char * hb_setGetHBOUTLOGINFO( void );
extern HB_EXPORT const char * hb_setGetOSCODEPAGE( void );
extern HB_EXPORT void * hb_setGetOSCP( void );
extern HB_EXPORT const char * hb_setGetDBCODEPAGE( void );
HB_EXTERN_END

View File

@@ -131,8 +131,9 @@
#define _SET_CODEPAGE 114 /* Harbour extension */
#define _SET_OSCODEPAGE 115 /* Harbour extension */
#define _SET_TIMEFORMAT 116 /* Harbour extension */
#define _SET_DBCODEPAGE 117 /* Harbour extension */
#define HB_SET_BASE 100
#define HB_SET_COUNT 15
#define HB_SET_COUNT ( _SET_DBCODEPAGE - HB_SET_BASE + 1 )
#endif /* _SET_CH */

View File

@@ -354,7 +354,7 @@ HB_FUNC( DBCREATE )
fCurrArea = fKeepOpen && !hb_parl( 4 );
szAlias = hb_parc( 5 );
pDelim = hb_param( 6, HB_IT_ANY );
szCpId = hb_parc( 7 );
szCpId = HB_ISCHAR( 7 ) ? hb_parc( 7 ) : hb_setGetDBCODEPAGE();
ulConnection = hb_parnl( 8 );
/*
@@ -411,7 +411,7 @@ HB_FUNC( HB_DBCREATETEMP )
szAlias = hb_parc( 1 );
pStruct = hb_param( 2, HB_IT_ARRAY );
szDriver = hb_parc( 3 );
szCpId = hb_parc( 4 );
szCpId = HB_ISCHAR( 4 ) ? hb_parc( 4 ) : hb_setGetDBCODEPAGE();
ulConnection = hb_parnl( 5 );
/*
@@ -481,7 +481,7 @@ HB_FUNC( __DBOPENSDF )
fCurrArea = fKeepOpen && !hb_parl( 4 );
szAlias = hb_parc( 5 );
pDelim = hb_param( 6, HB_IT_ANY );
szCpId = hb_parc( 7 );
szCpId = HB_ISCHAR( 7 ) ? hb_parc( 7 ) : hb_setGetDBCODEPAGE();
ulConnection = hb_parnl( 8 );
if( !pStruct ||
@@ -897,7 +897,7 @@ HB_FUNC( DBUSEAREA )
hb_retl( hb_rddOpenTable( hb_parc( 3 ), hb_parc( 2 ),
hb_parl( 1 ) ? 0 : hb_rddGetCurrentWorkAreaNumber(),
hb_parc( 4 ), HB_ISLOG( 5 ) ? hb_parl( 5 ) : !hb_setGetExclusive(),
hb_parl( 6 ), hb_parc( 7 ), hb_parnl( 8 ), NULL, NULL ) == HB_SUCCESS );
hb_parl( 6 ), HB_ISCHAR( 7 ) ? hb_parc( 7 ) : hb_setGetDBCODEPAGE(), hb_parnl( 8 ), NULL, NULL ) == HB_SUCCESS );
}
HB_FUNC( __DBZAP )

View File

@@ -989,6 +989,20 @@ HB_FUNC( SET )
pSet->hb_set_oscp = ( void * ) cdpOS;
}
break;
case HB_SET_DBCODEPAGE:
if( pSet->HB_SET_DBCODEPAGE )
hb_retc( pSet->HB_SET_DBCODEPAGE );
else
hb_ret();
if( args > 1 && ( HB_IS_STRING( pArg2 ) || HB_IS_NIL( pArg2 ) ) )
{
PHB_CODEPAGE cdpOS = hb_cdpFindExt( hb_itemGetCPtr( pArg2 ) );
char * szValue = cdpOS ? hb_strdup( cdpOS->id ) : NULL;
if( pSet->HB_SET_DBCODEPAGE )
hb_xfree( pSet->HB_SET_DBCODEPAGE );
pSet->HB_SET_DBCODEPAGE = szValue;
}
break;
case HB_SET_INVALID_:
/* Return NIL if called with invalid SET specifier */
@@ -1098,6 +1112,7 @@ void hb_setInitialize( PHB_SET_STRUCT pSet )
pSet->HB_SET_HBOUTLOG = hb_strdup( "hb_out.log" );
pSet->HB_SET_HBOUTLOGINFO = hb_strdup( "" );
pSet->HB_SET_OSCODEPAGE = NULL;
pSet->HB_SET_DBCODEPAGE = NULL;
hb_xsetfilename( pSet->HB_SET_HBOUTLOG );
hb_xsetinfo( pSet->HB_SET_HBOUTLOGINFO );
@@ -1128,6 +1143,7 @@ void hb_setRelease( PHB_SET_STRUCT pSet )
if( pSet->HB_SET_HBOUTLOG ) hb_xfree( pSet->HB_SET_HBOUTLOG );
if( pSet->HB_SET_HBOUTLOGINFO ) hb_xfree( pSet->HB_SET_HBOUTLOGINFO );
if( pSet->HB_SET_OSCODEPAGE ) hb_xfree( pSet->HB_SET_OSCODEPAGE );
if( pSet->HB_SET_DBCODEPAGE ) hb_xfree( pSet->HB_SET_DBCODEPAGE );
hb_fsFreeSearchPath( pSet->hb_set_path );
@@ -1175,6 +1191,7 @@ PHB_SET_STRUCT hb_setClone( PHB_SET_STRUCT pSrc )
if( pSet->HB_SET_HBOUTLOG ) pSet->HB_SET_HBOUTLOG = hb_strdup( pSet->HB_SET_HBOUTLOG );
if( pSet->HB_SET_HBOUTLOGINFO ) pSet->HB_SET_HBOUTLOGINFO = hb_strdup( pSet->HB_SET_HBOUTLOGINFO );
if( pSet->HB_SET_OSCODEPAGE ) pSet->HB_SET_OSCODEPAGE = hb_strdup( pSet->HB_SET_OSCODEPAGE );
if( pSet->HB_SET_DBCODEPAGE ) pSet->HB_SET_DBCODEPAGE = hb_strdup( pSet->HB_SET_DBCODEPAGE );
return pSet;
}
@@ -1821,6 +1838,17 @@ BOOL hb_setSetItem( HB_set_enum set_specifier, PHB_ITEM pItem )
fResult = TRUE;
}
break;
case HB_SET_DBCODEPAGE:
if( HB_IS_STRING( pItem ) || HB_IS_NIL( pItem ) )
{
PHB_CODEPAGE cdpOS = hb_cdpFindExt( hb_itemGetCPtr( pItem ) );
szValue = cdpOS ? hb_strdup( cdpOS->id ) : NULL;
if( pSet->HB_SET_DBCODEPAGE )
hb_xfree( pSet->HB_SET_DBCODEPAGE );
pSet->HB_SET_DBCODEPAGE = szValue;
fResult = TRUE;
}
break;
case HB_SET_INVALID_:
break;
@@ -1977,6 +2005,7 @@ BOOL hb_setGetL( HB_set_enum set_specifier )
case HB_SET_HBOUTLOG:
case HB_SET_HBOUTLOGINFO:
case HB_SET_OSCODEPAGE:
case HB_SET_DBCODEPAGE:
case HB_SET_INVALID_:
break;
#if 0
@@ -2030,6 +2059,8 @@ const char * hb_setGetCPtr( HB_set_enum set_specifier )
return pSet->HB_SET_HBOUTLOGINFO;
case HB_SET_OSCODEPAGE:
return pSet->HB_SET_OSCODEPAGE;
case HB_SET_DBCODEPAGE:
return pSet->HB_SET_DBCODEPAGE;
case HB_SET_LANGUAGE:
return hb_langID();
case HB_SET_CODEPAGE:
@@ -2183,6 +2214,7 @@ int hb_setGetNI( HB_set_enum set_specifier )
case HB_SET_HBOUTLOG:
case HB_SET_HBOUTLOGINFO:
case HB_SET_OSCODEPAGE:
case HB_SET_DBCODEPAGE:
case HB_SET_INVALID_:
break;
#if 0
@@ -2606,6 +2638,12 @@ void * hb_setGetOSCP( void )
return hb_stackSetStruct()->hb_set_oscp;
}
const char * hb_setGetDBCODEPAGE( void )
{
HB_STACK_TLS_PRELOAD
return hb_stackSetStruct()->HB_SET_DBCODEPAGE;
}
const char * hb_osEncodeCP( const char * szName, char ** pszFree, ULONG * pulSize )
{
HB_STACK_TLS_PRELOAD