2006-09-05 15:51 UTC+0100 Viktor Szakats (viktor.szakats syenar.hu)

* harbour/include/hbset.h
   * harbour/include/set.ch
   * harbour/source/pp/pptable.c
   * harbour/source/rtl/set.c
     + Added Set( _SET_DEFEXTENSIONS, <logical: .T./.F.> )
       Default value is .T. (CA-Cl*pper compatible). If set to .F.,
       Harbour runtime/RDD code will never attempt to add a
       default extension to the filename arguments. Commands/functions
       where this setting makes a difference are:
       - SET ALTERNATE TO / Set( _SET_ALTFILE_, ... )
       - SET PRINTER TO / Set( _SET_PRINTFILE_, ... )
       - Set( _SET_EXTRAFILE, ... )
       - SAVE TO / __mvSave()
       - RESTORE FROM / __mvRestore()
       - LABEL FORM
       - REPORT FORM
       - COPY TO ... DELIMITED
       - COPY TO ... SDF
       - LIST / __dbList()
       - USE / dbUseArea()
       - dbCreate()
       - SET INDEX TO / ordListAdd() (not yet implemented)
       - __HRBLOAD(), __HRBRUN()
     ; Notes:
       - From now on, it possible to create/load files using the
         above functions/commands which have no extension. This
         might be desirable in a few platform and/or situations.
         For example on Win32, it's possible to directly print
         to a shared Windows printer queue, using these commands:
             lOldValue := Set( _SET_DEFEXTENSIONS, .F. )
             SET PRINTER TO \\myserver\myprinter
             Set( _SET_DEFEXTENSIONS, lOldValue )
         Or, it is possible to open a dbf file which has no extension:
             dbUseArea(.T., NIL, "dbf_filename_with_no_extension", "w_DATA", .F., .F.)
       - Compiler is (of course) not affected by this setting.
       - Preprocessor (PP) lib flavour is not affected by this setting.
       - Support is not full in the RDD code yet.

   * harbour/source/rdd/dbf1.c
   * harbour/source/rdd/dblist.prg
   * harbour/source/rdd/delim1.c
   * harbour/source/rdd/sdf1.c
   * harbour/source/rtl/tlabel.prg
   * harbour/source/rtl/treport.prg
   * harbour/source/rtl/set.c
   * harbour/source/vm/memvars.c
   * harbour/source/vm/runner.c
     + Honoring _SET_DEFEXTENSIONS setting all over the code.
This commit is contained in:
Viktor Szakats
2006-09-08 12:47:27 +00:00
parent 26de328b8d
commit 076082265a
13 changed files with 158 additions and 94 deletions

View File

@@ -42,6 +42,56 @@
* harbour/source/vm/fm.c
! fixed typo in memset() when HB_PARANOID_MEM_CHECK enabled
* harbour/source/vm/hvm.c
! fixed item type used for iterator
2006-09-06 12:02 UTC+0300 Chen Kedem <niki@actcom.co.il>
* utils/hbrun/hbrun.prg
* Change Main() into _APPMAIN() to avoid collision with user function
Default value is .T. (CA-Cl*pper compatible). If set to .F.,
Harbour runtime/RDD code will never attempt to add a
default extension to the filename arguments. Commands/functions
2006-09-05 16:10 UTC+0300 Alexander Kresin <alex@belacy.belgorod.su>
* source/rtl/cdpapi.c
! Bug fixed in hb_cdpcmp(), which caused strange comparison results as
( s1 > s2 ) != ( s2 > s1 ).
2006-09-05 15:51 UTC+0100 Viktor Szakats (viktor.szakats syenar.hu)
* harbour/include/hbset.h
* harbour/include/set.ch
* harbour/source/pp/pptable.c
* harbour/source/rtl/set.c
+ Added Set( _SET_DEFEXTENSIONS, <logical: .T./.F.> )
Default value is .T. (CA-Cl*pper compatible). If set to .F.,
Harbour runtime/RDD code will never attempt to add a
default extension to the filename arguments. Commands/functions
where this setting makes a difference are:
- SET ALTERNATE TO / Set( _SET_ALTFILE_, ... )
- From now on, it possible to create/load files using the
above functions/commands which have no extension. This
- SAVE TO / __mvSave()
For example on Win32, it's possible to directly print
- LABEL FORM
- REPORT FORM
- COPY TO ... DELIMITED
- COPY TO ... SDF
- LIST / __dbList()
- USE / dbUseArea()
- dbCreate()
- SET INDEX TO / ordListAdd() (not yet implemented)
- __HRBLOAD(), __HRBRUN()
; Notes:
- From now on, it possible to create/load files using the
above functions/commands which have no extension. This
might be desirable in a few platform and/or situations.
For example on Win32, it's possible to directly print
to a shared Windows printer queue, using these commands:
lOldValue := Set( _SET_DEFEXTENSIONS, .F. )
SET PRINTER TO \\myserver\myprinter
Set( _SET_DEFEXTENSIONS, lOldValue )
Or, it is possible to open a dbf file which has no extension:
dbUseArea(.T., NIL, "dbf_filename_with_no_extension", "w_DATA", .F., .F.)
- Compiler is (of course) not affected by this setting.
- Preprocessor (PP) lib flavour is not affected by this setting.
- Support is not full in the RDD code yet.

View File

@@ -129,7 +129,8 @@ typedef enum
HB_SET_EOF = 105,
HB_SET_HARDCOMMIT = 106,
HB_SET_FORCEOPT = 107,
HB_SET_DBFLOCKSCHEME = 108
HB_SET_DBFLOCKSCHEME = 108,
HB_SET_DEFEXTENSIONS = 109
} HB_set_enum;
@@ -196,6 +197,7 @@ typedef struct
int HB_SET_DBFLOCKSCHEME;
BOOL HB_SET_HARDCOMMIT;
BOOL HB_SET_FORCEOPT;
BOOL HB_SET_DEFEXTENSIONS;
} HB_SET_STRUCT;
#define HB_SET_CASE_MIXED 0

View File

@@ -55,76 +55,77 @@
#ifndef _SET_CH
#define _SET_CH
#define _SET_EXACT 1
#define _SET_FIXED 2
#define _SET_DECIMALS 3
#define _SET_DATEFORMAT 4
#define _SET_EPOCH 5
#define _SET_PATH 6
#define _SET_DEFAULT 7
#define _SET_EXCLUSIVE 8
#define _SET_SOFTSEEK 9
#define _SET_UNIQUE 10
#define _SET_DELETED 11
#define _SET_CANCEL 12
#define _SET_DEBUG 13
#define _SET_TYPEAHEAD 14
#define _SET_COLOR 15
#define _SET_CURSOR 16
#define _SET_CONSOLE 17
#define _SET_ALTERNATE 18
#define _SET_ALTFILE 19
#define _SET_DEVICE 20
#define _SET_EXTRA 21
#define _SET_EXTRAFILE 22
#define _SET_PRINTER 23
#define _SET_PRINTFILE 24
#define _SET_MARGIN 25
#define _SET_BELL 26
#define _SET_CONFIRM 27
#define _SET_ESCAPE 28
#define _SET_INSERT 29
#define _SET_EXIT 30
#define _SET_INTENSITY 31
#define _SET_SCOREBOARD 32
#define _SET_DELIMITERS 33
#define _SET_DELIMCHARS 34
#define _SET_WRAP 35
#define _SET_MESSAGE 36
#define _SET_MCENTER 37
#define _SET_SCROLLBREAK 38
#define _SET_EVENTMASK 39 /* CA-Cl*pper 5.3 compatible */
#define _SET_VIDEOMODE 40 /* CA-Cl*pper 5.3 compatible */
#define _SET_MBLOCKSIZE 41 /* CA-Cl*pper 5.3 compatible */
#define _SET_MFILEEXT 42 /* CA-Cl*pper 5.3 compatible */
#define _SET_STRICTREAD 43 /* CA-Cl*pper 5.3 compatible */
#define _SET_OPTIMIZE 44 /* CA-Cl*pper 5.3 compatible */
#define _SET_AUTOPEN 45 /* CA-Cl*pper 5.3 compatible */
#define _SET_AUTORDER 46 /* CA-Cl*pper 5.3 compatible */
#define _SET_AUTOSHARE 47 /* CA-Cl*pper 5.3 compatible */
#define _SET_COUNT 47
#define _SET_LANGUAGE 100 /* Harbour extension */
#define _SET_IDLEREPEAT 101 /* Harbour extension */
#define _SET_FILECASE 102 /* Harbour extension */
#define _SET_DIRCASE 103 /* Harbour extension */
#define _SET_DIRSEPARATOR 104 /* Harbour extension */
#define _SET_EOF 105 /* Harbour extension */
#define _SET_HARDCOMMIT 106 /* Harbour extension */
#define _SET_FORCEOPT 107 /* Harbour extension */
#define _SET_DBFLOCKSCHEME 108 /* Harbour extension */
#define HB_SET_BASE 100
#define HB_SET_COUNT 9
#define _SET_EXACT 1
#define _SET_FIXED 2
#define _SET_DECIMALS 3
#define _SET_DATEFORMAT 4
#define _SET_EPOCH 5
#define _SET_PATH 6
#define _SET_DEFAULT 7
#define _SET_EXCLUSIVE 8
#define _SET_SOFTSEEK 9
#define _SET_UNIQUE 10
#define _SET_DELETED 11
#define _SET_CANCEL 12
#define _SET_DEBUG 13
#define _SET_TYPEAHEAD 14
#define _SET_COLOR 15
#define _SET_CURSOR 16
#define _SET_CONSOLE 17
#define _SET_ALTERNATE 18
#define _SET_ALTFILE 19
#define _SET_DEVICE 20
#define _SET_EXTRA 21
#define _SET_EXTRAFILE 22
#define _SET_PRINTER 23
#define _SET_PRINTFILE 24
#define _SET_MARGIN 25
#define _SET_BELL 26
#define _SET_CONFIRM 27
#define _SET_ESCAPE 28
#define _SET_INSERT 29
#define _SET_EXIT 30
#define _SET_INTENSITY 31
#define _SET_SCOREBOARD 32
#define _SET_DELIMITERS 33
#define _SET_DELIMCHARS 34
#define _SET_WRAP 35
#define _SET_MESSAGE 36
#define _SET_MCENTER 37
#define _SET_SCROLLBREAK 38
#define _SET_EVENTMASK 39 /* CA-Cl*pper 5.3 compatible */
#define _SET_VIDEOMODE 40 /* CA-Cl*pper 5.3 compatible */
#define _SET_MBLOCKSIZE 41 /* CA-Cl*pper 5.3 compatible */
#define _SET_MFILEEXT 42 /* CA-Cl*pper 5.3 compatible */
#define _SET_STRICTREAD 43 /* CA-Cl*pper 5.3 compatible */
#define _SET_OPTIMIZE 44 /* CA-Cl*pper 5.3 compatible */
#define _SET_AUTOPEN 45 /* CA-Cl*pper 5.3 compatible */
#define _SET_AUTORDER 46 /* CA-Cl*pper 5.3 compatible */
#define _SET_AUTOSHARE 47 /* CA-Cl*pper 5.3 compatible */
#define _SET_COUNT 47
#define _SET_LANGUAGE 100 /* Harbour extension */
#define _SET_IDLEREPEAT 101 /* Harbour extension */
#define _SET_FILECASE 102 /* Harbour extension */
#define _SET_DIRCASE 103 /* Harbour extension */
#define _SET_DIRSEPARATOR 104 /* Harbour extension */
#define _SET_EOF 105 /* Harbour extension */
#define _SET_HARDCOMMIT 106 /* Harbour extension */
#define _SET_FORCEOPT 107 /* Harbour extension */
#define _SET_DBFLOCKSCHEME 108 /* Harbour extension */
#define _SET_DEFEXTENSIONS 109 /* Harbour extension */
#define HB_SET_BASE 100
#define HB_SET_COUNT 10
#endif /* _SET_CH */

View File

@@ -128,6 +128,7 @@ void hb_pp_Table( void )
static DEFINES sD___57 = {"_SET_HARDCOMMIT", 15,NULL,-1,"106", &sD___56 };
static DEFINES sD___58 = {"_SET_FORCEOPT", 13,NULL,-1,"107", &sD___57 };
static DEFINES sD___59 = {"_SET_DBFLOCKSCHEME", 18,NULL,-1,"108", &sD___58 };
static DEFINES sD___60 = {"_SET_DEFEXTENSIONS", 18,NULL,-1,"109", &sD___59 };
static COMMANDS sC___1 = {0,"NOTE", 4,"\1A30",NULL,NULL };
static COMMANDS sC___2 = {0,"DO",2,"WHILE \1A00","while \1A00",&sC___1 };
@@ -450,7 +451,7 @@ void hb_pp_Table( void )
static COMMANDS sC___262 = {0,"SET",3,"DBFLOCKSCHEME TO \1A00","Set(_SET_DBFLOCKSCHEME, \1A00 )",&sC___261 };
static COMMANDS sC___263 = {0,"SET",3,"DBFLOCKSCHEME TO","Set(_SET_DBFLOCKSCHEME, 0 )",&sC___262 };
hb_pp_topDefine = &sD___59;
hb_pp_topDefine = &sD___60;
hb_pp_topCommand = &sC___263;
hb_pp_topTranslate = NULL;
}

View File

@@ -2154,7 +2154,7 @@ static ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo )
HB_TRACE(HB_TR_DEBUG, ("hb_dbfCreate(%p, %p)", pArea, pCreateInfo));
pFileName = hb_fsFNameSplit( ( char * ) pCreateInfo->abName );
if( ! pFileName->szExtension )
if( hb_set.HB_SET_DEFEXTENSIONS && ! pFileName->szExtension )
{
pItem = hb_itemPutC( pItem, "" );
if( SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pItem ) != SUCCESS )
@@ -2921,7 +2921,7 @@ static ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo )
pFileName = hb_fsFNameSplit( ( char * ) pOpenInfo->abName );
/* Add default file name extension if necessary */
if( ! pFileName->szExtension )
if( hb_set.HB_SET_DEFEXTENSIONS && ! pFileName->szExtension )
{
pFileExt = hb_itemPutC( NULL, "" );
if( SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pFileExt ) != SUCCESS )

View File

@@ -84,7 +84,7 @@ PROCEDURE __dbList( lOff, abEval, lAll, bFor, bWhile, nNext, nRecord, lRest, lTo
ENDIF
IF !Empty( cToFileName )
hb_FNameSplit( cToFileName, @cPath, @cName, @cExt )
IF Empty( cExt )
IF Set( _SET_DEFEXTENSIONS ) .AND. Empty( cExt )
cExt := ".txt"
ENDIF
lOldExtra := Set( _SET_EXTRA, .T. )

View File

@@ -1213,7 +1213,7 @@ static ERRCODE hb_delimCreate( DELIMAREAP pArea, LPDBOPENINFO pCreateInfo )
#endif
pFileName = hb_fsFNameSplit( ( char * ) pCreateInfo->abName );
if( ! pFileName->szExtension )
if( hb_set.HB_SET_DEFEXTENSIONS && ! pFileName->szExtension )
{
PHB_ITEM pItem = hb_itemPutC( NULL, "" );
SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pItem );
@@ -1305,7 +1305,7 @@ static ERRCODE hb_delimOpen( DELIMAREAP pArea, LPDBOPENINFO pOpenInfo )
pFileName = hb_fsFNameSplit( ( char * ) pOpenInfo->abName );
/* Add default file name extension if necessary */
if( ! pFileName->szExtension )
if( hb_set.HB_SET_DEFEXTENSIONS && ! pFileName->szExtension )
{
PHB_ITEM pFileExt = hb_itemPutC( NULL, "" );
SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pFileExt );

View File

@@ -945,7 +945,7 @@ static ERRCODE hb_sdfCreate( SDFAREAP pArea, LPDBOPENINFO pCreateInfo )
#endif
pFileName = hb_fsFNameSplit( ( char * ) pCreateInfo->abName );
if( ! pFileName->szExtension )
if( hb_set.HB_SET_DEFEXTENSIONS && ! pFileName->szExtension )
{
PHB_ITEM pItem = hb_itemPutC( NULL, "" );
SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pItem );
@@ -1037,7 +1037,7 @@ static ERRCODE hb_sdfOpen( SDFAREAP pArea, LPDBOPENINFO pOpenInfo )
pFileName = hb_fsFNameSplit( ( char * ) pOpenInfo->abName );
/* Add default file name extension if necessary */
if( ! pFileName->szExtension )
if( hb_set.HB_SET_DEFEXTENSIONS && ! pFileName->szExtension )
{
PHB_ITEM pFileExt = hb_itemPutC( NULL, "" );
SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pFileExt );

View File

@@ -229,9 +229,9 @@ static FHANDLE open_handle( char * file_name, BOOL bAppend, char * def_ext, HB_s
{
pFilename = hb_fsFNameSplit( file_name );
if( ! pFilename->szPath && hb_set.HB_SET_DEFAULT )
if( pFilename->szPath == NULL && hb_set.HB_SET_DEFAULT )
pFilename->szPath = hb_set.HB_SET_DEFAULT;
if( ! pFilename->szExtension && def_ext )
if( hb_set.HB_SET_DEFEXTENSIONS && pFilename->szExtension == NULL && def_ext )
pFilename->szExtension = def_ext;
hb_fsFNameMerge( path, pFilename );
@@ -877,6 +877,10 @@ HB_FUNC( SET )
}
}
break;
case HB_SET_DEFEXTENSIONS:
hb_retni( hb_set.HB_SET_DEFEXTENSIONS );
if( args > 1 ) hb_set.HB_SET_DEFEXTENSIONS = set_logical( pArg2, hb_set.HB_SET_DEFEXTENSIONS );
break;
case HB_SET_INVALID_:
/* Return NIL if called with invalid SET specifier */
break;
@@ -979,6 +983,7 @@ void hb_setInitialize( void )
hb_set.HB_SET_VIDEOMODE = 0;
hb_set.HB_SET_WRAP = FALSE;
hb_set.HB_SET_DBFLOCKSCHEME = 0;
hb_set.HB_SET_DEFEXTENSIONS = TRUE;
sp_sl_first = sp_sl_last = NULL;
s_next_listener = 1;

View File

@@ -137,9 +137,11 @@ METHOD New( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, ;
Eval(ErrorBlock(), err)
ELSE
cLBLName := RTrim( cLBLName ) // ; TOFIX: Not very multiplatform.
hb_FNameSplit( cLBLName, NIL, NIL, @cExt )
IF Empty( cExt )
cLBLName += ".lbl"
IF Set( _SET_DEFEXTENSIONS )
hb_FNameSplit( cLBLName, NIL, NIL, @cExt )
IF Empty( cExt )
cLBLName += ".lbl"
ENDIF
ENDIF
ENDIF

View File

@@ -198,9 +198,11 @@ METHOD NEW(cFrmName,lPrinter,cAltFile,lNoConsole,bFor,bWhile,nNext,nRecord,;
Eval(ErrorBlock(), err)
ELSE
cFRMName := RTrim( cFRMName ) // ; TOFIX: Not very multiplatform.
hb_FNameSplit( cFRMName, NIL, NIL, @cExt )
IF Empty( cExt )
cFRMName += ".frm"
IF Set( _SET_DEFEXTENSIONS )
hb_FNameSplit( cFRMName, NIL, NIL, @cExt )
IF Empty( cExt )
cFRMName += ".frm"
ENDIF
ENDIF
ENDIF

View File

@@ -1353,7 +1353,7 @@ HB_FUNC( __MVSAVE )
pFileName = hb_fsFNameSplit( hb_parc( 1 ) );
if( pFileName->szExtension == NULL )
if( hb_set.HB_SET_DEFEXTENSIONS && pFileName->szExtension == NULL )
pFileName->szExtension = ".mem";
if( pFileName->szPath == NULL )
@@ -1423,7 +1423,7 @@ HB_FUNC( __MVRESTORE )
pFileName = hb_fsFNameSplit( hb_parc( 1 ) );
if( pFileName->szExtension == NULL )
if( hb_set.HB_SET_DEFEXTENSIONS && pFileName->szExtension == NULL )
pFileName->szExtension = ".mem";
if( pFileName->szPath == NULL )

View File

@@ -4,7 +4,7 @@
/*
* Harbour Project source code:
* Harbour Portable Object (.HRB) file runner
* Harbour Portable Object (.hrb) file runner
*
* Copyright 1999 Eddie Runia <eddie@runia.com>
* www - http://www.harbour-project.org
@@ -68,6 +68,7 @@
#include "hbapifs.h"
#include "hbvm.h"
#include "hbpcode.h"
#include "hbset.h"
#include "hb_io.h"
/* TODO: Fill the error codes with valid ones (instead of 9999) */
@@ -339,7 +340,7 @@ static PHRB_BODY hb_hrbLoad( char* szHrbBody, ULONG ulBodySize )
pSymRead = ( PHB_SYMB ) hb_xgrab( pHrbBody->ulSymbols * sizeof( HB_SYMB ) );
for( ul = 0; ul < pHrbBody->ulSymbols; ul++ ) /* Read symbols in .HRB */
for( ul = 0; ul < pHrbBody->ulSymbols; ul++ ) /* Read symbols in .hrb */
{
pSymRead[ ul ].szName = hb_hrbReadId( szHrbBody, ulBodySize, &ulBodyOffset );
if( pSymRead[ ul ].szName == NULL || ulBodyOffset + 2 > ulBodySize )
@@ -488,7 +489,7 @@ static PHRB_BODY hb_hrbLoadFromFile( char* szHrb )
/* Create full filename */
pFileName = hb_fsFNameSplit( szHrb );
if( ! pFileName->szExtension )
if( hb_set.HB_SET_DEFEXTENSIONS && pFileName->szExtension == NULL )
{
pFileName->szExtension = ".hrb";
}
@@ -564,7 +565,7 @@ static void hb_hrbDo( PHRB_BODY pHrbBody, int argc, char * argv[] )
/*
__HRBRUN( <cFile> [, xParam1 [, xParamN ] ] ) -> return value.
This program will get the data from the .HRB file and run the p-code
This program will get the data from the .hrb file and run the p-code
contained in it.
In due time it should also be able to collect the data from the