diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a9b2f58732..6233258f95 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,12 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ + +2002-03-12 11:40 UTC+0300 Alexander Kresin + * source/rtl/dbsdf.prg + * bug fixed, reported by Mikhail Malyh + +2002-03-10 15:25 UTC-0300 Luiz Rafael Culik * source/pp/pptable.c * Fixed command for SET PRINTER TO * source/rtl/set.c diff --git a/harbour/doc/en/compiler.txt b/harbour/doc/en/compiler.txt index 8a69a91b8c..b146a7bf81 100644 --- a/harbour/doc/en/compiler.txt +++ b/harbour/doc/en/compiler.txt @@ -2,233 +2,239 @@ * $Id$ */ -/* - * Las siguientes partes son derechos adquiridos de sus autores individuales. - * www - http://www.harbour-project.org - * - * Copyright 2000 Alejandro de Gárate - * Documentación en Español de: Opciones del Compilador - * - * Vea doc/license.txt por los términos de la licencia. - * - */ - - /* $DOC$ * $FUNCNAME$ - * Opciones del Compilador + * Compiler Options * $CATEGORY$ - * Documentación + * Document * $ONELINER$ - * Opciones del Compilador + * Compiler Options * $DESCRIPTION$ * - * Invocando al compilador Harbour: - * =============================== + * Invoking the Harbour compiler: + * ============================== * - * harbour [opciones] - * or - * harbour [opciones] + * harbour [options] + * or + * harbour [options] * or - * harbour [opciones] [opciones] + * harbour [options] [options] * + * The command line options have to be separated by at least one space. + * The option can start with either '/' character or '-' character. * - * Las opciones de la línea de comandos debe ser separada, al menos por - * un espacio en blanco. - * Las opciones pueden comenzar con el carácter '/' ó '-', + * The Harbour command line options: + * ================================= * - * Opciones de la línea de comandos de: - * ==================================== + * /a automatic memvar declaration + * ================= + + * This causes all variables declared by PARAMETER, PRIVATE or PUBLIC + * statements to be automatically declared as MEMVAR variables. * - * /a Declaración Automática de memvar - * ----------------- - * Esto causa que todas las variables declaradas por las sentencias - * PARAMETER, PRIVATE ó PUBLIC sean automáticamente declaradas como - * variables MEMVAR. - * - * /b Información de depuración (Bug) - * ----------------- - * El compilador genera toda la información requerida para depuración + * /b debug info + * ================= + + * The compiler generates all information required for debugging * * /d[=] #define - * ----------------- + * ================= * - * /es[] establece la Severidad de la salida (Exit Severity) - * ----------------- + * /es[] set exit severity + * ================= * - * /es or /es0 - Todas las advertencias son ignoradas y el código de - * salida retornado por el compilador (accedido por el - * comando de DOS ERRORLEVEL) es igual a cero si no - * hay errores en el archivo fuente compilado. - * /es1 - Cualquier advertencia genera un código de salida - * distinto de cero, pero la salida es aún creada. - * /es2 - Cualquier advertencia es tratada como error y ningún - * archivo de salida es creado. El código de salida es - * establecido a un valor distinto de cero. + * /es or /es0 - all warnings are ignored and exit code returned by + * the compiler (accessed by DOS ERRORLEVEL command) + * is equal to 0 if there are no errors in compiled + * source file. * - * /g Generación del tipo de archivo de salida - * ----------------- + * /es1 - any warnings generate a non-zero exit code, but + * output is still created. * - * /gc tipo de salida: fuente de lenguaje C (.c) (defecto) - * /gf tipo de salida: Windows/DOS OBJ32 (.obj) - * /gh tipo de salida: Objeto Portable de Harbour (.hrb) - * /gj tipo de salida: fuente de Java (.java) - * /gp tipo de salida: fuente de Pascal (.pas) - * /gr tipo de salida: recursos de Windows (.rc) + * /es2 - all warnings are treated as errors and no output + * file is created. The exit code is set to a non-zero + * value. + + * /g output type generated is + * ================= * - * /i agrega la ruta de búsqueda de archivos #Include - * ----------------- + * /gc[] output type: C source (.c) (default) + * : 0=compact 1=normal 2=verbose (default) * - * /l suprime la información del número de Línea - * ----------------- - * El compilador no genera el número de línea del código fuente - * en el archivo de salida. La función PROCLINE() retornará cero - * para los módulos compilados usando esta opción. + * /go output type: Platform dependant object module * - * /m compilar el Módulo actual solamente - * ----------------- + * /gh output type: Harbour Portable Object (.hrb) * - * /n sin procedimiento de inicio implícito - * ----------------- - * El compilador no crea un procedimiento con el mismo nombre - * que el del archivo compilado. Esto significa que algunas - * declaraciones puestas antes de la primera sentencia de - * PROCEDURE ó FUNCTION tienen el alcance del archivo y pueden ser - * accedidas/usadas en todas las funciones/procedimientos definidos - * en el archivo fuente compilado. Todas las sentencias ejecutables - * puestas al principio del archivo y antes de la primera sentencia - * de PROCEDURE ó FUNCTION son ignoradas. + + * /i add #include file search path + * ================= * - * /o unidad de disco y/o ruta para el archivo de salida - * ----------------- + * /k enable compatibility mode + * ================= * - * /p genera un archivo de salida Pre-procesada (.ppo) - * ----------------- - * El compilador solamente crea el archivo que contiene el - * resultado del archivo fuente pre-procesado. + * /kc clear all flags (strict Clipper compatibility) * - * /q Quieto - * ----------------- - * El compilador no imprime ningún mensaje durante la compilación - * (excepto la información del copyright). + * /kh Harbour extensions (default) * - * /q0 que permanezca realmente Quieto y no muestre ni - * siquiera la información del copyright. + * /ki HB_INLINE support enabled (default) * - * /r[] solicita al linker Revisar por (ó ninguna) - * ----------------- - * Actualmente no soportado en Harbour. + * /kr use runtime settings for the macro compiler * - * /s solo chequeo de Sintaxis. - * ----------------- - * El compilador chequea la sintaxis solamente. Ningún archivo de - * salida es generado. + * /kx other xbase dialects extensions (default) * - * /t ruta para la creación de un archivo Temporario - * ----------------- - * Actualmente no usado en harbour (El compilador de harbour no - * crea ningún archivo temporal) + * /k? invoke help information * - * /u[] Usar la definición de comando establecido en el - * (ó ninguno) - * ----------------- - * Aún no soportado. + * /l suppress line number information + * ================= * - * /v las Variables son asumidas como M-> - * ----------------- - * Todas las variables sin declarar ó unaliased son asumidas como - * variables MEMVAR (variables privadas ó públicas). si este switch - * no es usado entones el alcance de estas variables es chequeado - * en tiempo de ejecución. + * The compiler does not generate the source code line numbers in + * the output file. The PROCLINE() function will return 0 for + * modules compiled using this option. * - * /w[] Establece el número de nivel de las advertencias - * (Warnings) (0..4, por defecto es 1) - * ----------------- + * /m compile current module only + * ================= * - * /w0 - sin advertencias - * /w or /w1 - advertencias compatibles con Clipper - * /w2 - algunas advertencias útiles ausentes en Clipper - * /w3 - advertencias generadas para extensiones al lenguaje - * hechas en Harbour. También habilita el chequeo de - * sintaxis fuertemente tipeada pero sólo advierte - * contra los tipos declarados, o los tipos que pueden - * ser calculados en tiempo de compilación. - * /w4 - habilita advertencias acerca de operaciones que son - * sospechosas, lo cual significa que si se mezclan tipos - * sin declarar ó tipos que no pueden ser calculados - * en tiempo de compilación, junto con los tipos ya - * declarados, una advertencia será generada. + * /n no implicit starting procedure + * ================= * - * /x[] establece el símbolo del prefijo agregado al nombre - * de función (para archivo.c solamente) - * ----------------- - * Establece el símbolo del prefijo agregado al nombre de función - * de inicio (en la salida de lenguaje C, actualmente). Esta función - * es generada automáticamente para cada módulo de PRG compilado. - * Este prefijo adicional puede ser usado para suprimir problemas - * con símbolos duplicados durante el enlazado de una aplicación - * (linking) con alguna librería de terceros. + * The compiler does not create a procedure with the same name as + * the compiled file. This means that any declarations placed + * before the first PROCEDURE or FUNCTION statement have file- + * wide scope and can be accessed/used in all functions/procedures + * defined in the compiled source file. All executable statements + * placed at the beginning of the file and before the first + * PROCEDURE/FUNCTION statement are ignored. * - * /y seguimiento de la actividad de Lex & Yacc - * ----------------- - * El compilador Harbour usa las utilidades FLEX y YACC para analizar - * el código fuente y generar el archivo de salida requerido. - * Esta opción sigue la actividad de esas utilidades. + * /o output file drive and/or path + * ================= * - * /z suprime el cortocircuito lógico (.and. y .or.) - * ----------------- + * /p generate pre-processed output (.ppo) file + * ================= * - * /10 restringe la longitud de símbolos a 10 caracteres. - * ----------------- - * Todos los nombres de variables y de funciones son cortados a un - * máximo de 10 caracteres. + * The compiler only creates the file that contains the result of + * pre-processing the source file. * + * /q quiet + * ================= * - * Compilación en modo lote (batch). - * ================================ + * The compiler does not print any messages during compiling + * (except the copyright info). * - * @ compila la lista de módulos en el - * ----------------- - * No soportado aún. + * /q0 be really quiet and don't display even the copyright info * + * /r[] request linker to search (or none) + * ================= * + * Currently not supported in Harbour. * - * Conocidas incompatibilidades entre compiladores harbour y clipper - * ================================================================= + * /s syntax check only + * ================= + * + * The compiler checks the syntax only. No output file is generated. + * + * /t path for temp file creation + * ================= + * + * Currently not used in Harbour (the Harbour compiler does not + * create any temporary files). + * + * /u[] use command definition set in (or none) + * ================= + * + * /v variables are assumed M-> + * ================= + * + * All undeclared or unaliased variables are assumed MEMVAR + * variables (private or public variables). If this switch is not + * used then the scope of such variables is checked at runtime. + * + * /w[] set warning level number (0..4, default 1) + * ================= + * + * /w0 - no warnings + * + * /w or /w1 - Clipper compatible warnings + * + * /w2 - some useful warnings missed in Clipper + * + * /w3 - warnings generated for Harbour language extensions + * and also enables strong type checking but only + * warns against declared types, or types which may be + * calculated at compile time + * + * /w4 - Enables warning about suspicious operations, which + * means if you mix undeclared types, or types which + * can not be calculated at compile time,together with + * declared types, a warning will be generated. + * + * /x[] set symbol init function name prefix (for .c only) + * ================= + * + * Sets the prefix added to the generated symbol init function name + * (in C output currently). This function is generated + * automatically for every PRG module compiled. This additional + * prefix can be used to suppress problems with duplicated symbols + * during linking an application with some third party libraries. + * + * /y trace lex & yacc activity + * ================= + * + * The Harbour compiler uses the FLEX and YACC utilities to parse + * the source code and to generate the required output file. This + * option traces the activity of these utilities. + * + * /z suppress logical shortcutting (.and. & .or.) + * ================= + * + * /10 restrict symbol length to 10 characters + * ================= + * + * All variable and function names are cut to maximum 10 characters. + * + * Compilation in batch mode. + * ========================== + * + * @ compile list of modules in + * ================= + * + * Not supported yet. + * + * Known incompatibilities between harbour and clipper compilers + * ============================================================= * * NOTE: - * Si desea librerías de compilación y ejecución 100 % compatibles, - * entonces Ud. debe definir: HARBOUR_STRICT_CLIPPER_COMPATIBILITY. - * Esta opción debe ser definida en el archvivo ../include/hbsetup.h - * (en efecto esta opción es puesta en un comentario por defecto - Ud. - * necesita remover los caracteres /* */ solamente. Este cambio debe ser - * realizado antes de invocar la utilidad make. + * + * If you want a 100% compatible runtime libraries then + * you have to define HARBOUR_STRICT_CLIPPER_COMPATIBILITY. This + * option should be defined in the file include/hbsetup.h (in fact this + * option is placed in a comment by default - you need to remove the + * /* */ characters only). This change has to be done before invoking + * the make utility. * * - * Manejo de variables sin declarar - * -------------------------------- - * Cuando un valor es asignado a una variable no declarada y la opción - * -v de la línea de comandos no es usada, entonces el compilador - * Clipper asume que la variable es una variable PRIVATE ó PUBLIC y - * genera un opcode POPM (pop memvar). + * Handling of undeclared variables + * ================================ * - * Cuando el valor de una variable no declarada es accedido y la opción - * -v de la línea de comandos no es usada, el compilador Harbour genera - * un opcode PUSHV (push variable) para determinar el tipo de variable - * en tiempo de ejecución - - * Si un campo con el nombre requerido existe en el area de trabajo - * actual, entonces este valor es usado. Si no existe el campo, entones - * una variable PRIVATE ó PUBLIC es usada (si existe). + * When a value is assigned to an undeclared variable and the '-v' + * command line option is not used, then the Clipper compiler assumes + * that the variable is a PRIVATE or a PUBLIC variable and generates + * POPM (pop memvar) opcode. * - * El compilador Harbour genera un opcode para determinar el tipo de - * variable en tiempo de ejecución (POPVARIABLE or PUSHVARIABLE) en - * ambos casos (asignación y acceso). + * When the value of an undeclared variable is accessed and the '-v' + * command line option is not used, the Clipper compiler generates PUSHV + * (push variable) opcode that determines the type of variable at runtime. + * If a field with the requested name exists in the current workarea then + * its value is used. If there is no field then a PRIVATE or a PUBLIC + * variable is used (if exists). + * + * The Harbour compiler generates an opcode to determine the type of + * variable at runtime (POPVARIABLE or PUSHVARIABLE) in both cases + * (assignment and access). + * + * The difference can be checked by the following code: * - * La diferencia puede ser chequeada por el siguiente código: - * - * PROCEDURE MAIN() + * PROCEDURE MAIN() * PRIVATE myname * * DBCREATE( "TEST", { { "MYNAME", "C", 10, 0} } ) @@ -251,62 +257,61 @@ * * RETURN * + * + * Passing an undeclared variable by the reference + * =============================================== * - * Pasando por refeerencia una variable no declarada - * ------------------------------------------------- - * El compilador Harbour usa un opcode especial PUSHP para pasar una - * referencia a una variable no declarada ( el operador '@' ). El tipo - * de la variable pasada es chequeada en tiempo de ejecución (field or - * memvar). Sin embargo las variables de campo no pueden ser pasadas por - * referencia. Esto significa que Clipper chequea sólo la variable memvar - * y no mira por una de campo. - * Esta es la razón por la cual el compilador Harbour usa el opcode - * habitual PUSHMEMVARREF en estos casos. Nótese que el comportamiento - * en tiempo de ejecución es el mismo en Clipper y en Harbour - sólo los - * opcodes generados son diferentes. + * The Clipper compiler uses the special opcode PUSHP to pass a + * reference to an undeclared variable ( '@' operator ). The type of + * passed variable is checked at runtime (field or memvar). However, + * field variables cannot be passed by reference. This means that + * Clipper checks the memvar variable only and doesn't look for a field. + * This is the reason why the Harbour compiler uses the usual + * PUSHMEMVARREF opcode in such cases. Notice that the runtime behavior + * is the same in Clipper and in Harbour - only the generated opcodes + * are different. * * - * Manejo de mensajes a objetos - * ---------------------------- + * Handling of object messages + * =========================== * - * El seteo de HARBOUR_STRICT_CLIPPER_COMPATIBILITY determina - * la forma en que el envío encadenado de mensajes es manejado + * The HARBOUR_STRICT_CLIPPER_COMPATIBILITY setting determines + * the way chained send messages are handled. * - * Por ejemplo, el siguiente código: + * For example, the following code: * - * a:b( COUNT() ):c += 1 + * a:b( COUNT() ):c += 1 * - * será manejado como: + * will be handled as: * - * a:b( COUNT() ):c := a:b( COUNT() ):c + 1 - * en modo de compatibilidad estricta y + * a:b( COUNT() ):c := a:b( COUNT() ):c + 1 * - * temp := a:b( COUNT() ), temp:c += 1 - * en modo no-estricto. + * in strict Clipper compatibility mode and * - * En la práctica, Clipper llamará a la función COUNT() dos veces: - * La primera vez antes de la adición y la segunda después de la - * adición. - * En Harbour, COUNT() será llamada sólo una vez, antes de la adición. + * temp := a:b( COUNT() ), temp:c += 1 * - * El método Harbour (no-estricto) es: - * 1) Más rápido - * 2) Garantiza que la misma variable de instancia del mismo - * objeto será cambiada. + * in non-strict mode. * - * (Ver también: ../source/compiler/expropt.c) + * In practice, Clipper will call the COUNT() function two times: + * the first time before addition and the second one after addition. + * In Harbour, COUNT() will be called only once, before addition. * + * The Harbour (non-strict) method is: + * 1) faster + * 2) it guarantees that the same instance variable of the same object + * will be changed * - * Inicialización variables estáticas - * ---------------------------------- + * (See also: source/compiler/expropt.c) * - * Hay una diferencia en la inicialización de las variables estáticas - * que son inicializadas con un bloque de código que refiere a una - * variable local. Por ejemplo: + * Initialization of static variables + * ================================== + * + * There is a difference in the initialization of static + * variables that are initialized with a codeblock that refers to + * a local variable. For example: * * PROCEDURE TEST() - * * LOCAL MyLocalVar * STATIC MyStaticVar := {|| MyLocalVar } * @@ -316,24 +321,22 @@ * RETURN * - * El código de arriba compila bien en Clipper, pero éste genera un - * error de ejecución: - * Error/BASE 1132 Bound error: array access - * Called from (b)STATICS$(0) + * The above code compiles fine in Clipper, but it generates a + * runtime error Error/BASE 1132 Bound error: array access + * Called form (b)STATICS$(0) * - * En Harbour este código genera un error en tiempo de compilación: - * Error E0009 Illegal variable (b) initializer: 'MyLocalVar' + * In Harbour this code generates a compile time error: + * Error E0009 Illegal variable (b) initializer: 'MyLocalVar' * - * Ambos Clipper y Harbour estan manejando todas las variables locales - * usadas en una forma especial: ellas son separadas de la pila (stack) - * local de la función / procedimiento donde ellas son declaradas. - * Esto permite acceder a estas variables despues de la salida de una - * función / procedimiento. Sin embargo todas las variables estáticas - * son inicializadas en un procedimiento separado ('STATICS$' en Clipper - * y '(_INITSTATICS)' en Harbour) antes del procedimiento principal y - * antes de todos los procedimientos INIT. Las variables locales no - * existen en la pila de evaluación (eval stack) donde las variables - * estáticas son inicializadas, así ellas no pueden ser separadas. + * Both Clipper and Harbour are handling all local variables used in a + * codeblock in a special way: they are detached from the local stack + * of function/procedure where they are declared. This allows access to + * these variables after the exit from a function/procedure. However, + * all static variables are initialized in a separate procedure + * ('STATICS$' in Clipper and '(_INITSTATICS)' in Harbour) before the + * main procedure and before all INIT procedures. The local variables + * don't exist on the eval stack when static variables are initialized, + * so they cannot be detached. * * $END$ */ diff --git a/harbour/source/rtl/dbsdf.prg b/harbour/source/rtl/dbsdf.prg index 9e899364d6..235d13ad06 100644 --- a/harbour/source/rtl/dbsdf.prg +++ b/harbour/source/rtl/dbsdf.prg @@ -185,12 +185,16 @@ PROCEDURE __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest IF EMPTY( aFields ) // Process all fields. FOR index := 1 TO FCOUNT() - FieldPut( index,ImportFixed( handle,index,aStruct ) ) + IF !ImportFixed( handle,index,aStruct ) + EXIT + ENDIF NEXT index ELSE // Process the specified fields. FOR index := 1 TO LEN( aFields ) - FieldPut( FIELDPOS( aFields[ index ] ),ImportFixed( handle,FIELDPOS( aFields[ index ] ),aStruct ) ) + IF !ImportFixed( handle,FIELDPOS( aFields[ index ] ),aStruct ) + EXIT + ENDIF NEXT index END IF // Set up for the start of the next record. @@ -217,17 +221,29 @@ STATIC FUNCTION ExportFixed( handle, xField ) RETURN .T. STATIC FUNCTION ImportFixed( handle, index, aStruct ) - LOCAL cBuffer := Space(aStruct[ index,3 ]) - FREAD( handle, @cBuffer, aStruct[ index,3 ] ) - DO CASE - CASE aStruct[ index,2 ] == "C" - RETURN cBuffer - CASE aStruct[ index,2 ] == "D" - RETURN HB_STOD( cBuffer ) - CASE aStruct[ index,2 ] == "L" - RETURN iif( cBuffer == "T",.T.,.F. ) - CASE aStruct[ index,2 ] == "N" - RETURN VAL( cBuffer ) - END CASE -RETURN cBuffer + LOCAL cBuffer := Space(aStruct[ index,3 ]), pos, res := .T. + LOCAL vres + + FREAD( handle, @cBuffer, aStruct[ index,3 ] ) + IF ( pos := At( CHR(13),cBuffer ) ) > 0 + res := .F. + FSEEK( handle, -( aStruct[ index,3 ] - pos + 1 ), FS_RELATIVE ) + IF pos > 1 + cBuffer := Left( cBuffer,pos-1 ) + ELSE + RETURN res + ENDIF + ENDIF + DO CASE + CASE aStruct[ index,2 ] == "D" + vres := HB_STOD( cBuffer ) + CASE aStruct[ index,2 ] == "L" + vres := iif( cBuffer == "T",.T.,.F. ) + CASE aStruct[ index,2 ] == "N" + vres := VAL( cBuffer ) + OTHERWISE + vres := cBuffer + END CASE + FIELDPUT( index, vres ) +RETURN res