diff --git a/harbour/ChangeLog b/harbour/ChangeLog index fbf90ee789..df889402df 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,31 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2001-12-18 21:47 UTC+0100 Viktor Szakats + + * include/hbapi.h + * include/hbsetup.ch + + include/hbcommon.ch + * include/Makefile + + Added HB_FILE_VER( id ) for Harbour and C + sources. Note that in order to work in + .prg files, HB_FILE_VER() should come after + the #includes and the file should #include "hbcommon.ch" + which will automatically include "hbsetup.ch" too. + + Added HB_FILE_VER_STATIC define which will + enable the inclusion of HB_FILE_VER info. + + * source/common/hbffind.c + * source/rtl/dbdelim.prg + * source/rtl/dbsdf.prg + + Added experimental HB_FILE_VER() lines. + + * doc/genhtm.rsp + + doc/en/dbdelim.txt + + doc/en/dbsdf.txt + % Some small optimization for speed. + * Separated documentation from the source. + 2001-12-18 20:15 UTC+0300 Alexander Kresin * tests/db_brows.prg Some changes to eliminate using of functions from libmisc. @@ -19,7 +44,6 @@ hb_gcReleaseAll() will increase cleanup speed (on app termination), and will result in a more complete cleanup in certain situations. - 2001-12-18 10:03 UTC+0100 Viktor Szakats * source/common/hbffind.c diff --git a/harbour/doc/en/dbdelim.txt b/harbour/doc/en/dbdelim.txt new file mode 100644 index 0000000000..cb9a41e5f7 --- /dev/null +++ b/harbour/doc/en/dbdelim.txt @@ -0,0 +1,80 @@ +/* + * $Id$ + */ + +/* + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * Copyright 2001-2002 David G. Holm + * Documentation for: __dbDelim() + * + * See doc/license.txt for licensing terms. + * + */ + +/* $DOC$ + * $FUNCNAME$ + * __dbDelim() + * $CATEGORY$ + * Conversion + * $ONELINER$ + * Copies the contents of a database to a delimited text file or + * appends the contents of a delimited text file to a database. + * $SYNTAX$ + * __dbDelim( , , [], [], + * [], [], [], [], ) --> NIL + * $ARGUMENTS$ + * If set to .T., copies records to a delimited file. + * If set to .F., append records from a delimited file. + * The name of the text file to copy to or append from. + * If a file extension is not specified, ".txt" is used by default. + * Either the character to use as the character field + * delimiter (only the first character is used). or "BLANK" (not case + * sensitive), which eliminates the character field delimiters and + * sets the field separator to a single space instead of a comma. + * An aray of field names to limit the processint to. If + * not specified, or if empty, then all fields are processed. + * An optional code block containing a FOR expression that + * will reduce the number of records to be processed. + * An optional code block containing a WHILE expression + * that will reduce the number of records to be processed. + * If present, but nRecord is not present, specifies to + * process this number of records, starting with the current record. + * A value of 0 means to process no records. + * If present, specifies the only record to process. A + * value of 0 means to process no records. Overrides nNext and lRest. + * If lExport is .T., then if set to .T. and there are no + * nRecord, nNext, or bWhile arguments, processes all records from + * current to last. + * $RETURNS$ + * NIL + * $DESCRIPTION$ + * __dbDelim() copies all or selected contents of a database table + * to an SDF text file or appends all or selected contents of an SDF + * text file to a database table. + * $EXAMPLES$ + * // Copy delinquent accounts into a delimited text file. + * USE ACCOUNTS NEW + * COPY TO overdue DELIMITED FOR !EMPTY( accounts->duedate ) ; + * .AND. DATE() - accounts->duedate > 30 + * // Import new customer records. + * USE CUSTOMER NEW + * APPEND FROM customer DELIMITED + * $TESTS$ + * + * $STATUS$ + * S + * $COMPLIANCE$ + * __dbDelim() is intended to be fully compliant with CA-Clipper's + * function of the same name and is the underlying implementation + * of the APPEND FROM DELIMITED and COPY TO DELIMITED commands. + * $PLATFORMS$ + * All + * $FILES$ + * + * $SEEALSO$ + * __dbSDF(), APPEND FROM, COPY TO + * $END$ + */ + diff --git a/harbour/doc/en/dbsdf.txt b/harbour/doc/en/dbsdf.txt new file mode 100644 index 0000000000..1173ae7656 --- /dev/null +++ b/harbour/doc/en/dbsdf.txt @@ -0,0 +1,76 @@ +/* + * $Id$ + */ + +/* + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * Copyright 2001-2002 David G. Holm + * Documentation for: __dbSDF() + * + * See doc/license.txt for licensing terms. + * + */ + +/* $DOC$ + * $FUNCNAME$ + * __dbSDF() + * $CATEGORY$ + * Conversion + * $ONELINER$ + * Copies the contents of a database to an SDF text file or + * appends the contents of an SDF text file to a database. + * $SYNTAX$ + * __dbSDF( , , [], + * [], [], [], [], ) --> NIL + * $ARGUMENTS$ + * If set to .T., copies records to an SDF file. + * If set to .F., append records from an SDF file. + * The name of the text file to copy to or append from. + * If a file extension is not specified, ".txt" is used by default. + * An aray of field names to limit the processint to. If + * not specified, or if empty, then all fields are processed. + * An optional code block containing a FOR expression that + * will reduce the number of records to be processed. + * An optional code block containing a WHILE expression + * that will reduce the number of records to be processed. + * If present, but nRecord is not present, specifies to + * process this number of records, starting with the current record. + * A value of 0 means to process no records. + * If present, specifies the only record to process. A + * value of 0 means to process no records. Overrides nNext and lRest. + * If lExport is .T., then if set to .T. and there are no + * nRecord, nNext, or bWhile arguments, processes all records from + * current to last. + * $RETURNS$ + * NIL + * $DESCRIPTION$ + * __dbSDF() copies all or selected contents of a database table + * to an SDF text file or appends all or selected contents of an + * SDF text file to a database table. + * $EXAMPLES$ + * // Copy delinquent accounts into an SDF text file. + * USE ACCOUNTS NEW + * COPY TO overdue SDF FOR !EMPTY( accounts->duedate ) ; + * .AND. DATE() - accounts->duedate > 30 + * // Import new customer records. + * USE CUSTOMER NEW + * APPEND FROM customer SDF + * $TESTS$ + * + * $STATUS$ + * S + * $COMPLIANCE$ + * __dbSDF() is intended to be fully compliant with CA-Clipper's + * function of the same name and is the underlying implementation + * of the APPEND FROM SDF and COPY TO SDF commands. + * $PLATFORMS$ + * All + * $FILES$ + * + * $SEEALSO$ + * __dbDelim(), APPEND FROM, COPY TO + * $END$ + */ + diff --git a/harbour/doc/genhtm.rsp b/harbour/doc/genhtm.rsp index 66d1bf494d..2944c3cc53 100644 --- a/harbour/doc/genhtm.rsp +++ b/harbour/doc/genhtm.rsp @@ -3,6 +3,8 @@ en\binnum.txt en\browse.txt en\command.txt en\datetime.txt +en\dbdelim.txt +en\dbsdf.txt en\dbstrux.txt en\diskspac.txt en\dir.txt diff --git a/harbour/include/Makefile b/harbour/include/Makefile index fce02d4a4e..376e6fd2b1 100644 --- a/harbour/include/Makefile +++ b/harbour/include/Makefile @@ -56,6 +56,7 @@ PRG_HEADERS=\ fileio.ch \ getexit.ch \ hbclass.ch \ + hbcommon.ch \ hbextern.ch \ hbgetcmt.ch \ hbinkey.ch \ diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index c8aad8634e..b7664887dd 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -582,6 +582,14 @@ extern void hb_verBuildInfo( void ); /* display harbour, compiler, and platfor /* WARNING: This returned pointer must be freed using hb_xfree( ( void * ) ptr ); */ extern char * hb_getenv( const char * name ); +/* Version tracking related things */ + +#ifdef HB_FILE_VER_STATIC + #define HB_FILE_VER( id ) static char s_hb_file_ver[] = id; +#else + #define HB_FILE_VER( id ) +#endif + /* Translation related things */ /* Dummy define for start */ diff --git a/harbour/include/hbcommon.ch b/harbour/include/hbcommon.ch new file mode 100644 index 0000000000..b5bf9af226 --- /dev/null +++ b/harbour/include/hbcommon.ch @@ -0,0 +1,65 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Common header file for the source of Harbour itself. + * + * Copyright 2001-2002 Viktor Szakats + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#ifndef HB_HBCOMMON_CH_ +#define HB_HBCOMMON_CH_ + +#include "hbsetup.ch" + +#ifdef HB_FILE_VER_STATIC + #define HB_FILE_VER( id ) STATIC s_hb_file_ver := id +#else + #define HB_FILE_VER( id ) +#endif + +#endif /* HB_HBCOMMON_CH_ */ + diff --git a/harbour/include/hbsetup.ch b/harbour/include/hbsetup.ch index 6757776e40..256500bd67 100644 --- a/harbour/include/hbsetup.ch +++ b/harbour/include/hbsetup.ch @@ -79,6 +79,8 @@ #define HB_SHORTNAMES #endif +/* #define HB_FILE_VER_STATIC */ /* Enable inclusion of file version strings */ + /*#define HB_CLS_ENFORCERO */ /* Activate the RO checking on OO DATA */ /* when not called from a constructor */ diff --git a/harbour/source/common/hbffind.c b/harbour/source/common/hbffind.c index 5d07af50db..93bcd3ebb8 100644 --- a/harbour/source/common/hbffind.c +++ b/harbour/source/common/hbffind.c @@ -64,6 +64,8 @@ #include "hbdate.h" #include "hb_io.h" +HB_FILE_VER( "$Id$" ) + /* ------------------------------------------------------------- */ #include @@ -80,7 +82,6 @@ typedef struct { - void * dta; struct ffblk entry; } HB_FFIND_INFO, * PHB_FFIND_INFO; diff --git a/harbour/source/rtl/dbdelim.prg b/harbour/source/rtl/dbdelim.prg index 135d38d138..0eddede056 100644 --- a/harbour/source/rtl/dbdelim.prg +++ b/harbour/source/rtl/dbdelim.prg @@ -7,7 +7,7 @@ * Copies the contents of a database to a delimited text file. * Appends the contents of a delimited text file to a database. * - * Copyright 2001 David G. Holm + * Copyright 2001-2002 David G. Holm * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -51,76 +51,17 @@ * */ -#include -#include -#include +#include "hbcommon.ch" +#include "fileio.ch" +#include "error.ch" -/* $DOC$ - * $FUNCNAME$ - * __dbDelim() - * $CATEGORY$ - * Conversion - * $ONELINER$ - * Copies the contents of a database to a delimited text file or - * appends the contents of a delimited text file to a database. - * $SYNTAX$ - * __dbDelim( , , [], [], - * [], [], [], [], ) --> NIL - * $ARGUMENTS$ - * If set to .T., copies records to a delimited file. - * If set to .F., append records from a delimited file. - * The name of the text file to copy to or append from. - * If a file extension is not specified, ".txt" is used by default. - * Either the character to use as the character field - * delimiter (only the first character is used). or "BLANK" (not case - * sensitive), which eliminates the character field delimiters and - * sets the field separator to a single space instead of a comma. - * An aray of field names to limit the processint to. If - * not specified, or if empty, then all fields are processed. - * An optional code block containing a FOR expression that - * will reduce the number of records to be processed. - * An optional code block containing a WHILE expression - * that will reduce the number of records to be processed. - * If present, but nRecord is not present, specifies to - * process this number of records, starting with the current record. - * A value of 0 means to process no records. - * If present, specifies the only record to process. A - * value of 0 means to process no records. Overrides nNext and lRest. - * If lExport is .T., then if set to .T. and there are no - * nRecord, nNext, or bWhile arguments, processes all records from - * current to last. - * $RETURNS$ - * NIL - * $DESCRIPTION$ - * __dbDelim() copies all or selected contents of a database table - * to an SDF text file or appends all or selected contents of an SDF - * text file to a database table. - * $EXAMPLES$ - * // Copy delinquent accounts into a delimited text file. - * USE ACCOUNTS NEW - * COPY TO overdue DELIMITED FOR !EMPTY( accounts->duedate ) ; - * .AND. DATE() - accounts->duedate > 30 - * // Import new customer records. - * USE CUSTOMER NEW - * APPEND FROM customer DELIMITED - * $TESTS$ - * - * $STATUS$ - * S - * $COMPLIANCE$ - * __dbDelim() is intended to be fully compliant with CA-Clipper's - * function of the same name and is the underlying implementation - * of the APPEND FROM DELIMITED and COPY TO DELIMITED commands. - * $PLATFORMS$ - * All - * $FILES$ - * - * $SEEALSO$ - * __dbSDF(), APPEND FROM, COPY TO - * $END$ - */ +HB_FILE_VER( "$Id$" ) -FUNCTION __dbDelim( lExport, cFile, cDelimArg, aFields, bFor, bWhile, nNext, nRecord, lRest ) +#define AppendEOL( handle ) FWRITE( handle, CHR( 13 ) + CHR( 10 ) ) +#define AppendEOF( handle ) FWRITE( handle, CHR( 26 ) ) +#define AppendSep( handle, cSep ) FWRITE( handle, cSep ) + +PROCEDURE __dbDelim( lExport, cFile, cDelimArg, aFields, bFor, bWhile, nNext, nRecord, lRest ) LOCAL index, handle, lWriteSep, cFileName := cFile, nStart, nCount, oErr LOCAL cSeparator := ",", cDelim := CHR( 34 ) @@ -270,34 +211,19 @@ FUNCTION __dbDelim( lExport, cFile, cDelimArg, aFields, bFor, bWhile, nNext, nRe END IF */ END IF -RETURN NIL +RETURN STATIC FUNCTION ExportVar( handle, xField, cDelim ) - LOCAL cText := "", lWrite := .F. DO CASE CASE VALTYPE( xField ) == "C" - cText := cDelim + TRIM( xField ) + cDelim - lWrite := .T. + FWRITE( handle, cDelim + TRIM( xField ) + cDelim ) CASE VALTYPE( xField ) == "D" - cText := DTOS( xField ) - lWrite := .T. + FWRITE( handle, DTOS( xField ) ) CASE VALTYPE( xField ) == "L" - cText := IF( xField, "T", "F" ) - lWrite := .T. + FWRITE( handle, iif( xField, "T", "F" ) ) CASE VALTYPE( xField ) == "N" - cText := LTRIM( STR( xField ) ) - lWrite := .T. + FWRITE( handle, LTRIM( STR( xField ) ) ) + OTHERWISE + RETURN .F. END CASE - FWRITE( handle, cText ) -RETURN lWrite - -STATIC FUNCTION AppendEOL( handle ) - STATIC cEOL := CHR( 13 ) + CHR( 10 ) -RETURN FWRITE( handle, cEOL ) - -STATIC FUNCTION AppendEOF( handle ) - STATIC cEOF := CHR( 26 ) -RETURN FWRITE( handle, cEOF ) - -STATIC FUNCTION AppendSep( handle, cSep ) -RETURN FWRITE( handle, cSep ) +RETURN .T. diff --git a/harbour/source/rtl/dbsdf.prg b/harbour/source/rtl/dbsdf.prg index 5875e9e52a..48600411ec 100644 --- a/harbour/source/rtl/dbsdf.prg +++ b/harbour/source/rtl/dbsdf.prg @@ -7,7 +7,7 @@ * Copies the contents of a database to an SDF text file. * Appends the contents of an SDF text file to a database. * - * Copyright 2001 David G. Holm + * Copyright 2001-2002 David G. Holm * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -51,72 +51,16 @@ * */ -#include -#include -#include +#include "hbcommon.ch" +#include "fileio.ch" +#include "error.ch" -/* $DOC$ - * $FUNCNAME$ - * __dbSDF() - * $CATEGORY$ - * Conversion - * $ONELINER$ - * Copies the contents of a database to an SDF text file or - * appends the contents of an SDF text file to a database. - * $SYNTAX$ - * __dbSDF( , , [], - * [], [], [], [], ) --> NIL - * $ARGUMENTS$ - * If set to .T., copies records to an SDF file. - * If set to .F., append records from an SDF file. - * The name of the text file to copy to or append from. - * If a file extension is not specified, ".txt" is used by default. - * An aray of field names to limit the processint to. If - * not specified, or if empty, then all fields are processed. - * An optional code block containing a FOR expression that - * will reduce the number of records to be processed. - * An optional code block containing a WHILE expression - * that will reduce the number of records to be processed. - * If present, but nRecord is not present, specifies to - * process this number of records, starting with the current record. - * A value of 0 means to process no records. - * If present, specifies the only record to process. A - * value of 0 means to process no records. Overrides nNext and lRest. - * If lExport is .T., then if set to .T. and there are no - * nRecord, nNext, or bWhile arguments, processes all records from - * current to last. - * $RETURNS$ - * NIL - * $DESCRIPTION$ - * __dbSDF() copies all or selected contents of a database table - * to an SDF text file or appends all or selected contents of an - * SDF text file to a database table. - * $EXAMPLES$ - * // Copy delinquent accounts into an SDF text file. - * USE ACCOUNTS NEW - * COPY TO overdue SDF FOR !EMPTY( accounts->duedate ) ; - * .AND. DATE() - accounts->duedate > 30 - * // Import new customer records. - * USE CUSTOMER NEW - * APPEND FROM customer SDF - * $TESTS$ - * - * $STATUS$ - * S - * $COMPLIANCE$ - * __dbSDF() is intended to be fully compliant with CA-Clipper's - * function of the same name and is the underlying implementation - * of the APPEND FROM SDF and COPY TO SDF commands. - * $PLATFORMS$ - * All - * $FILES$ - * - * $SEEALSO$ - * __dbDelim(), APPEND FROM, COPY TO - * $END$ - */ +HB_FILE_VER( "$Id$" ) -FUNCTION __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest ) +#define AppendEOL( handle ) FWRITE( handle, CHR( 13 ) + CHR( 10 ) ) +#define AppendEOF( handle ) FWRITE( handle, CHR( 26 ) ) + +PROCEDURE __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest ) LOCAL index, handle, cFileName := cFile, nStart, nCount, oErr // Process the file name argument. @@ -246,31 +190,20 @@ FUNCTION __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest ) END IF */ END IF -RETURN NIL +RETURN STATIC FUNCTION ExportFixed( handle, xField ) - LOCAL cText := "", lWrite := .F. DO CASE CASE VALTYPE( xField ) == "C" - cText := xField - lWrite := .T. + FWRITE( handle, xField ) CASE VALTYPE( xField ) == "D" - cText := DTOS( xField ) - lWrite := .T. + FWRITE( handle, DTOS( xField ) ) CASE VALTYPE( xField ) == "L" - cText := IF( xField, "T", "F" ) - lWrite := .T. + FWRITE( handle, iif( xField, "T", "F" ) ) CASE VALTYPE( xField ) == "N" - cText := STR( xField ) - lWrite := .T. + FWRITE( handle, STR( xField ) ) + OTHERWISE + RETURN .F. END CASE - FWRITE( handle, cText ) -RETURN lWrite +RETURN .T. -STATIC FUNCTION AppendEOL( handle ) - STATIC cEOL := CHR( 13 ) + CHR( 10 ) -RETURN FWRITE( handle, cEOL ) - -STATIC FUNCTION AppendEOF( handle ) - STATIC cEOF := CHR( 26 ) -RETURN FWRITE( handle, cEOF )