From f424b514176914f84dff507fefab722897fa18c2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 28 Oct 2008 08:45:18 +0000 Subject: [PATCH] 2008-10-28 09:44 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * contrib/examples/guestbk/inifiles.prg * contrib/examples/guestbk/testcgi.prg * contrib/examples/guestbk/guestbk.prg * contrib/examples/guestbk/bld_b32.bat * contrib/examples/guestbk/bld_vc.bat * contrib/examples/pe/bld_b32.bat * contrib/examples/pe/bld_vc.bat * contrib/examples/pe/editorhi.prg * Minor updates, optimizations. * source/rtl/version.c % Using better method to return HB_V_BITWIDTH. * utils/hbtest/rt_str.prg ! Changed to use 'hb_version( HB_V_BITWIDTH ) >= 64' instead of #ifdef __ARCH64BIT__. --- harbour/ChangeLog | 18 ++++ harbour/contrib/examples/guestbk/bld_b32.bat | 8 +- harbour/contrib/examples/guestbk/bld_vc.bat | 9 +- harbour/contrib/examples/guestbk/guestbk.prg | 14 +-- harbour/contrib/examples/guestbk/inifiles.prg | 102 +++++++++--------- harbour/contrib/examples/guestbk/testcgi.prg | 2 +- harbour/contrib/examples/pe/bld_b32.bat | 7 +- harbour/contrib/examples/pe/bld_vc.bat | 7 +- harbour/contrib/examples/pe/editorhi.prg | 3 +- harbour/source/rtl/version.c | 13 +-- harbour/utils/hbtest/rt_str.prg | 10 +- 11 files changed, 96 insertions(+), 97 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 316181efcf..e95243201c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,24 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-28 09:44 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * contrib/examples/guestbk/inifiles.prg + * contrib/examples/guestbk/testcgi.prg + * contrib/examples/guestbk/guestbk.prg + * contrib/examples/guestbk/bld_b32.bat + * contrib/examples/guestbk/bld_vc.bat + * contrib/examples/pe/bld_b32.bat + * contrib/examples/pe/bld_vc.bat + * contrib/examples/pe/editorhi.prg + * Minor updates, optimizations. + + * source/rtl/version.c + % Using better method to return HB_V_BITWIDTH. + + * utils/hbtest/rt_str.prg + ! Changed to use 'hb_version( HB_V_BITWIDTH ) >= 64' + instead of #ifdef __ARCH64BIT__. + 2008-10-28 01:52 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/Makefile * include/hbextern.ch diff --git a/harbour/contrib/examples/guestbk/bld_b32.bat b/harbour/contrib/examples/guestbk/bld_b32.bat index 5a956f7a3a..adcb6559ae 100644 --- a/harbour/contrib/examples/guestbk/bld_b32.bat +++ b/harbour/contrib/examples/guestbk/bld_b32.bat @@ -3,9 +3,7 @@ rem rem $Id$ rem -..\..\..\bin\harbour /n guestbk /i..\..\..\include\ -..\..\..\bin\harbour /n inifiles /i..\..\..\include\ -..\..\..\bin\harbour /n testcgi /i..\..\..\include\ +..\..\..\bin\harbour /n /i..\..\..\include\ guestbk inifiles testcgi echo -O2 -I..\..\..\include -L..\..\..\lib > build.tmp echo guestbk.c >> build.tmp @@ -29,8 +27,6 @@ del build.tmp del *.obj -del guestbk.c -del inifiles.c -del testcgi.c +del guestbk.c inifiles.c testcgi.c guestbk diff --git a/harbour/contrib/examples/guestbk/bld_vc.bat b/harbour/contrib/examples/guestbk/bld_vc.bat index 8cddbf4b70..f32f6cc858 100644 --- a/harbour/contrib/examples/guestbk/bld_vc.bat +++ b/harbour/contrib/examples/guestbk/bld_vc.bat @@ -3,16 +3,11 @@ rem rem $Id$ rem -..\..\..\bin\harbour /n guestbk /i..\..\..\include\ -..\..\..\bin\harbour /n inifiles /i..\..\..\include\ -..\..\..\bin\harbour /n testcgi /i..\..\..\include\ +..\..\..\bin\harbour /n /i..\..\..\include\ guestbk inifiles testcgi cl -D_CRT_SECURE_NO_DEPRECATE -nologo -O2 -W3 -I..\..\..\include guestbk.c inifiles.c testcgi.c /link /subsystem:CONSOLE /LIBPATH:..\..\..\lib hbcpage.lib hbdebug.lib hbvm.lib hbrtl.lib gtwin.lib hblang.lib hbrdd.lib hbmacro.lib hbpp.lib rddntx.lib rddcdx.lib rddfpt.lib hbsix.lib hbcommon.lib hbpcre.lib hbzlib.lib user32.lib winspool.lib del *.obj - -del guestbk.c -del inifiles.c -del testcgi.c +del guestbk.c inifiles.c testcgi.c guestbk diff --git a/harbour/contrib/examples/guestbk/guestbk.prg b/harbour/contrib/examples/guestbk/guestbk.prg index a39e941bb7..a56c48d8bc 100644 --- a/harbour/contrib/examples/guestbk/guestbk.prg +++ b/harbour/contrib/examples/guestbk/guestbk.prg @@ -3,13 +3,13 @@ */ /* - Harbour Project source code - - This file contains source for a script of a Guestbook - - Copyright (C) 1999 Felipe G. Coury - www - http://www.harbour-project.org - + * Harbour Project source code + * + * This file contains source for a script of a Guestbook + * + * Copyright (C) 1999 Felipe G. Coury + * 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) diff --git a/harbour/contrib/examples/guestbk/inifiles.prg b/harbour/contrib/examples/guestbk/inifiles.prg index 07bf2df3d1..8021463056 100644 --- a/harbour/contrib/examples/guestbk/inifiles.prg +++ b/harbour/contrib/examples/guestbk/inifiles.prg @@ -2,31 +2,33 @@ * $Id$ */ -#define CRLF (Chr(13) + Chr(10)) +#include "common.ch" + +#define CRLF hb_osNewLine() function TIniFile() static oClass if oClass == nil - oClass := HBClass():New( 'TINIFILE' ) // starts a new class definition + oClass := HBClass():New( "TINIFILE" ) // starts a new class definition - oClass:AddData( 'FileName' ) // define this class objects datas - oClass:AddData( 'Contents' ) + oClass:AddData( "FileName" ) // define this class objects datas + oClass:AddData( "Contents" ) - oClass:AddMethod( 'New', @New() ) // define this class objects methods - oClass:AddMethod( 'ReadString', @ReadString() ) - oClass:AddMethod( 'WriteString', @WriteString() ) - oClass:AddMethod( 'ReadNumber', @ReadNumber() ) - oClass:AddMethod( 'WriteNumber', @WriteNumber() ) - oClass:AddMethod( 'ReadDate', @ReadDate() ) - oClass:AddMethod( 'WriteDate', @WriteDate() ) - oClass:AddMethod( 'ReadBool', @ReadBool() ) - oClass:AddMethod( 'WriteBool', @WriteBool() ) - oClass:AddMethod( 'ReadSection', @ReadSection() ) - oClass:AddMethod( 'ReadSections', @ReadSections() ) - oClass:AddMethod( 'DeleteKey', @DeleteKey() ) - oClass:AddMethod( 'EraseSection', @EraseSection() ) - oClass:AddMethod( 'UpdateFile', @UpdateFile() ) + oClass:AddMethod( "New", @New() ) // define this class objects methods + oClass:AddMethod( "ReadString", @ReadString() ) + oClass:AddMethod( "WriteString", @WriteString() ) + oClass:AddMethod( "ReadNumber", @ReadNumber() ) + oClass:AddMethod( "WriteNumber", @WriteNumber() ) + oClass:AddMethod( "ReadDate", @ReadDate() ) + oClass:AddMethod( "WriteDate", @WriteDate() ) + oClass:AddMethod( "ReadBool", @ReadBool() ) + oClass:AddMethod( "WriteBool", @WriteBool() ) + oClass:AddMethod( "ReadSection", @ReadSection() ) + oClass:AddMethod( "ReadSections", @ReadSections() ) + oClass:AddMethod( "DeleteKey", @DeleteKey() ) + oClass:AddMethod( "EraseSection", @EraseSection() ) + oClass:AddMethod( "UpdateFile", @UpdateFile() ) oClass:Create() // builds this class endif @@ -39,7 +41,7 @@ static function New(cFileName) if empty(cFileName) // raise an error? - outerr('No filename passed to TIniFile():New()') + outerr("No filename passed to TIniFile():New()") return nil else @@ -54,13 +56,13 @@ static function New(cFileName) hFile := fcreate(cFilename) endif - cLine := '' + cLine := "" Done := .f. while !Done cFile := space(256) Done := (fread(hFile, @cFile, 256) <= 0) - cFile := strtran(cFile, chr(10), '') // so we can just search for CHR(13) + cFile := strtran(cFile, chr(10), "") // so we can just search for CHR(13) // prepend last read cFile := cLine + cFile @@ -70,8 +72,8 @@ static function New(cFileName) cFile := substr(cFile, nPos + 1) if !empty(cLine) - if Left(cLine, 1) == '[' // new section - if (nPos := At(']', cLine)) > 1 + if Left(cLine, 1) == "[" // new section + if (nPos := At("]", cLine)) > 1 cLine := substr(cLine, 2, nPos - 2); else @@ -81,26 +83,26 @@ static function New(cFileName) AAdd(::Contents, { cLine, { /* this will be CurrArray */ } } ) CurrArray := ::Contents[Len(::Contents)][2] - elseif Left(cLine, 1) == ';' // preserve comments + elseif Left(cLine, 1) == ";" // preserve comments AAdd( CurrArray, { NIL, cLine } ) else - if (nPos := At('=', cLine)) > 0 + if (nPos := At("=", cLine)) > 0 cIdent := Left(cLine, nPos - 1) cLine := SubStr(cLine, nPos + 1) AAdd( CurrArray, { cIdent, cLine } ) else - AAdd( CurrArray, { cLine, '' } ) + AAdd( CurrArray, { cLine, "" } ) endif endif - cLine := '' // to stop prepend later on + cLine := "" // to stop prepend later on endif else cLine := cFile - cFile := '' + cFile := "" endif end end @@ -116,7 +118,7 @@ static function ReadString(cSection, cIdent, cDefault) if Empty(cSection) cFind := lower(cIdent) - j := AScan( ::Contents, {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cFind .and. ValType(x[2]) == 'C'} ) + j := AScan( ::Contents, {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cFind .and. ISCHARACTER(x[2]) } ) if j > 0 cResult := ::Contents[j][2] @@ -124,11 +126,11 @@ static function ReadString(cSection, cIdent, cDefault) else cFind := lower(cSection) - i := AScan( ::Contents, {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cFind} ) + i := AScan( ::Contents, {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cFind} ) if i > 0 cFind := lower(cIdent) - j := AScan( ::Contents[i][2], {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cFind} ) + j := AScan( ::Contents[i][2], {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cFind} ) if j > 0 cResult := ::Contents[i][2][j][2] @@ -142,11 +144,11 @@ static procedure WriteString(cSection, cIdent, cString) local i, j, cFind if Empty(cIdent) - outerr('Must specify an identifier') + outerr("Must specify an identifier") elseif Empty(cSection) cFind := lower(cIdent) - j := AScan( ::Contents, {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cFind .and. ValType(x[2]) == 'C'} ) + j := AScan( ::Contents, {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cFind .and. ISCHARACTER(x[2]) } ) if j > 0 ::Contents[j][2] := cString @@ -159,9 +161,9 @@ static procedure WriteString(cSection, cIdent, cString) else cFind := lower(cSection) - if (i := AScan( ::Contents, {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cFind .and. ValType(x[2]) == 'A'})) > 0 + if (i := AScan( ::Contents, {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cFind .and. ISARRAY(x[2]) })) > 0 cFind := lower(cIdent) - j := AScan( ::Contents[i][2], {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cFind} ) + j := AScan( ::Contents[i][2], {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cFind} ) if j > 0 ::Contents[i][2][j][2] := cString @@ -198,14 +200,14 @@ return static function ReadBool(cSection, cIdent, lDefault) local Self := QSelf() - local cDefault := Iif( lDefault, '.t.', '.f.' ) + local cDefault := Iif( lDefault, ".t.", ".f." ) -return ::ReadString(cSection, cIdent, cDefault) == '.t.' +return ::ReadString(cSection, cIdent, cDefault) == ".t." static procedure WriteBool(cSection, cIdent, lBool) local Self := QSelf() - ::WriteString( cSection, cIdent, Iif(lBool, '.t.', '.f.') ) + ::WriteString( cSection, cIdent, Iif(lBool, ".t.", ".f.") ) return static procedure DeleteKey(cSection, cIdent) @@ -213,11 +215,11 @@ static procedure DeleteKey(cSection, cIdent) local i, j cSection := lower(cSection) - i := AScan( ::Contents, {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cSection} ) + i := AScan( ::Contents, {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cSection} ) if i > 0 cIdent := lower(cIdent) - j := AScan( ::Contents[i][2], {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cIdent} ) + j := AScan( ::Contents[i][2], {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cIdent} ) ADel( ::Contents[i][2], j ) ASize( ::Contents[i][2], Len(::Contents[i][2]) - 1 ) @@ -229,14 +231,14 @@ static procedure EraseSection(cSection) local i if Empty(cSection) - while (i := AScan( ::Contents, {|x| valtype(x[1]) == 'C' .and. ValType(x[2]) == 'C'})) > 0 + while (i := AScan( ::Contents, {|x| ISCHARACTER(x[1]) .and. ISCHARACTER(x[2]) })) > 0 ADel( ::Contents, i ) ASize( ::Contents, len(::Contents) - 1 ) end else cSection := lower(cSection) - if (i := AScan( ::Contents, {|x| valtype(x[1]) == 'C' .and. lower(x[1]) == cSection .and. ValType(x[2]) == 'A'})) > 0 + if (i := AScan( ::Contents, {|x| ISCHARACTER(x[1]) .and. lower(x[1]) == cSection .and. ISARRAY(x[2]) })) > 0 ADel( ::Contents, i ) ASize( ::Contents, Len(::Contents) - 1 ) endif @@ -249,14 +251,14 @@ static function ReadSection(cSection) if Empty(cSection) for i := 1 to len(::Contents) - if valtype(::Contents[i][1]) == 'C' .and. valtype(::Contents[i][2]) == 'C' + if ISCHARACTER(::Contents[i][1]) .and. ISCHARACTER(::Contents[i][2]) aadd(aSection, ::Contents[i][1]) endif next else cSection := lower(cSection) - if (i := AScan( ::Contents, {|x| valtype(x[1]) == 'C' .and. x[1] == cSection .and. ValType(x[2]) == 'A'})) > 0 + if (i := AScan( ::Contents, {|x| ISCHARACTER(x[1]) .and. x[1] == cSection .and. ISARRAY(x[2]) })) > 0 for j := 1 to Len(::Contents[i][2]) @@ -274,7 +276,7 @@ static function ReadSections() for i := 1 to Len(::Contents) - if ValType(::Contents[i][2]) == 'A' + if ISARRAY(::Contents[i][2]) AAdd(aSections, ::Contents[i][1]) endif next @@ -290,21 +292,21 @@ static procedure UpdateFile() if ::Contents[i][1] == NIL fwrite(hFile, ::Contents[i][2] + Chr(13) + Chr(10)) - elseif ValType(::Contents[i][2]) == 'A' - fwrite(hFile, '[' + ::Contents[i][1] + ']' + Chr(13) + Chr(10)) + elseif ISARRAY(::Contents[i][2]) + fwrite(hFile, "[" + ::Contents[i][1] + "]" + Chr(13) + Chr(10)) for j := 1 to Len(::Contents[i][2]) if ::Contents[i][2][j][1] == NIL fwrite(hFile, ::Contents[i][2][j][2] + Chr(13) + Chr(10)) else - fwrite(hFile, ::Contents[i][2][j][1] + '=' + ::Contents[i][2][j][2] + Chr(13) + Chr(10)) + fwrite(hFile, ::Contents[i][2][j][1] + "=" + ::Contents[i][2][j][2] + Chr(13) + Chr(10)) endif next fwrite(hFile, Chr(13) + Chr(10)) - elseif ValType(::Contents[i][2]) == 'C' - fwrite(hFile, ::Contents[i][1] + '=' + ::Contents[i][2] + Chr(13) + Chr(10)) + elseif ISCHARACTER(::Contents[i][2]) + fwrite(hFile, ::Contents[i][1] + "=" + ::Contents[i][2] + Chr(13) + Chr(10)) endif next diff --git a/harbour/contrib/examples/guestbk/testcgi.prg b/harbour/contrib/examples/guestbk/testcgi.prg index 48c01be987..2e1f5aab38 100644 --- a/harbour/contrib/examples/guestbk/testcgi.prg +++ b/harbour/contrib/examples/guestbk/testcgi.prg @@ -37,7 +37,7 @@ FUNCTION ParseString( cString, cDelim, nRet ) LOCAL cBuf, aElem, nPosFim, nSize, i - nSize := len( cString ) - len( StrTran( cString, cDelim, '' ) ) + 1 + nSize := len( cString ) - len( StrTran( cString, cDelim, "" ) ) + 1 aElem := array( nSize ) cBuf := cString diff --git a/harbour/contrib/examples/pe/bld_b32.bat b/harbour/contrib/examples/pe/bld_b32.bat index 970c7f8a21..d3a8788912 100644 --- a/harbour/contrib/examples/pe/bld_b32.bat +++ b/harbour/contrib/examples/pe/bld_b32.bat @@ -3,8 +3,7 @@ rem rem $Id$ rem -..\..\..\bin\harbour /n pe /i..\..\..\include\ -..\..\..\bin\harbour /n editorhi /i..\..\..\include\ +..\..\..\bin\harbour /n /i..\..\..\include\ pe editorhi echo -O2 -I..\..\..\include -L..\..\..\lib > build.tmp echo pe.c >> build.tmp @@ -27,8 +26,6 @@ bcc32 @build.tmp del build.tmp del *.obj - -del pe.c -del editorhi.c +del pe.c editorhi.c pe diff --git a/harbour/contrib/examples/pe/bld_vc.bat b/harbour/contrib/examples/pe/bld_vc.bat index 616a49d457..685789db62 100644 --- a/harbour/contrib/examples/pe/bld_vc.bat +++ b/harbour/contrib/examples/pe/bld_vc.bat @@ -3,14 +3,11 @@ rem rem $Id$ rem -..\..\..\bin\harbour /n pe /i..\..\..\include\ -..\..\..\bin\harbour /n editorhi /i..\..\..\include\ +..\..\..\bin\harbour /n /i..\..\..\include\ pe editorhi cl -D_CRT_SECURE_NO_DEPRECATE -nologo -O2 -W3 -I..\..\..\include pe.c editorhi.c editorlo.c /link /subsystem:CONSOLE /LIBPATH:..\..\..\lib hbcpage.lib hbdebug.lib hbvm.lib hbrtl.lib gtwin.lib hblang.lib hbrdd.lib hbmacro.lib hbpp.lib rddntx.lib rddcdx.lib rddfpt.lib hbsix.lib hbcommon.lib hbpcre.lib hbzlib.lib user32.lib winspool.lib del *.obj - -del pe.c -del editorhi.c +del pe.c editorhi.c pe diff --git a/harbour/contrib/examples/pe/editorhi.prg b/harbour/contrib/examples/pe/editorhi.prg index 2998c113cd..560e197353 100644 --- a/harbour/contrib/examples/pe/editorhi.prg +++ b/harbour/contrib/examples/pe/editorhi.prg @@ -11,6 +11,7 @@ #include "setcurs.ch" #include "fileio.ch" #include "box.ch" +#include "common.ch" #define EXPORT @@ -277,7 +278,7 @@ LOCAL nSize IF lSave == NIL lSave := .T. ENDIF - IF VALTYPE(xInput) == "C" + IF ISCHARACTER(xInput) nHandle := FOPEN( xInput ) lClose := .T. ELSE diff --git a/harbour/source/rtl/version.c b/harbour/source/rtl/version.c index 080bc78330..01b52303ac 100644 --- a/harbour/source/rtl/version.c +++ b/harbour/source/rtl/version.c @@ -96,18 +96,7 @@ HB_FUNC( HB_VERSION ) case HB_V_FLAG_HARBOUR: hb_retc_const( hb_verFlagsPRG() ); break; case HB_V_FLAG_C: hb_retc_const( hb_verFlagsC() ); break; case HB_V_FLAG_LINKER: hb_retc_const( hb_verFlagsL() ); break; - - case HB_V_BITWIDTH: - #if defined( HB_ARCH_16BIT ) - hb_retni( 16 ); - #elif defined( HB_ARCH_32BIT ) - hb_retni( 32 ); - #elif defined( HB_ARCH_64BIT ) - hb_retni( 64 ); - #else - hb_retni( 0 ); - #endif - break; + case HB_V_BITWIDTH: hb_retni( ( int ) sizeof( void * ) ); break; case HB_V_ENDIANNESS: #if defined( HB_LITTLE_ENDIAN ) diff --git a/harbour/utils/hbtest/rt_str.prg b/harbour/utils/hbtest/rt_str.prg index 5b508ab550..1e664df1f4 100644 --- a/harbour/utils/hbtest/rt_str.prg +++ b/harbour/utils/hbtest/rt_str.prg @@ -55,6 +55,10 @@ /* Don't change the position of this #include. */ #include "rt_vars.ch" +#ifdef __HARBOUR__ + #include "hbver.ch" +#endif + PROCEDURE Main_STR() /* VAL() */ @@ -530,11 +534,11 @@ PROCEDURE Main_STR() /* REPLICATE() */ #ifdef __HARBOUR__ - #ifdef __ARCH64BIT__ + IF hb_version( HB_V_BITWIDTH ) >= 64 TEST_LINE( Replicate("XXX", 9000000000000000000) , "E BASE 1234 String overflow REPLICATE A:2:C:XXX;N:9000000000000000000 F:S" ) - #else + ELSE TEST_LINE( Replicate("XXX", 2000000000) , "E BASE 1234 String overflow REPLICATE A:2:C:XXX;N:2000000000 F:S" ) - #endif + ENDIF #else TEST_LINE( Replicate("XXX", 30000) , "E BASE 1234 String overflow REPLICATE A:2:C:XXX;N:30000 F:S" ) #endif