2011-03-01 12:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbformat/utils/hbformat.prg
  * contrib/hbformat/hbformat.hbx
  * contrib/hbformat/hbfmtcls.prg
  * contrib/hbformat/hbformat.hbp
  - contrib/hbformat/fileread.c
    ! Fixed to load LF delimited files on non-*nix systems.
    * Changed output EOL type to OS default (from 'no change')
    * Changed the way EOL type is detected in 'no change' mode.
      (it's pretty simple code and not as efficient as previously.
      my main goal was to fix file load.)
    + Showing number of lines.

  * examples/hbqt_tut/win21.prg
  * examples/hbqt_tut/win12.prg
  + examples/hbqt_tut/win22.prg
  + examples/hbqt_tut/win23.prg
    + Updated. [Marco Bra]
    ! Fixed formatting. Please use hbformat on the code before submitting.
This commit is contained in:
Viktor Szakats
2011-03-01 11:56:20 +00:00
parent 09283469f1
commit df93e5e6da
10 changed files with 132 additions and 132 deletions

View File

@@ -16,6 +16,26 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-03-01 12:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbformat/utils/hbformat.prg
* contrib/hbformat/hbformat.hbx
* contrib/hbformat/hbfmtcls.prg
* contrib/hbformat/hbformat.hbp
- contrib/hbformat/fileread.c
! Fixed to load LF delimited files on non-*nix systems.
* Changed output EOL type to OS default (from 'no change')
* Changed the way EOL type is detected in 'no change' mode.
(it's pretty simple code and not as efficient as previously.
my main goal was to fix file load.)
+ Showing number of lines.
* examples/hbqt_tut/win21.prg
* examples/hbqt_tut/win12.prg
+ examples/hbqt_tut/win22.prg
+ examples/hbqt_tut/win23.prg
+ Updated. [Marco Bra]
! Fixed formatting. Please use hbformat on the code before submitting.
2011-03-01 11:50 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/config/win/bcc.mk
* harbour/utils/hbmk2/hbmk2.prg

View File

@@ -1,118 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Harbour source code formatter
*
* Copyright 2009 Alexander S.Kresin <alex@belacy.belgorod.su>
* www - http://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.
*
*/
#include "hbapi.h"
#include "hbapiitm.h"
HB_FUNC( __HBFORMAT_FILEREAD ) /* ( cText, @cEol ) */
{
const char * szText = hb_parcx( 1 );
const char * ptr;
const char * ptr1;
HB_SIZE n, nLines = 0;
PHB_ITEM arr;
ptr = szText;
while( *ptr )
{
if( *ptr == '\r' || *ptr == '\n' )
{
if( ! nLines )
hb_storclen( ptr, ( *( ptr + 1 ) == '\r' || *( ptr + 1 ) == '\n' ) ? 2 : 1, 2 );
if( *( ptr + 1 ) == '\r' || *( ptr + 1 ) == '\n' )
ptr++;
nLines++;
}
else if( ( unsigned int ) ( *ptr ) < 9 )
{
hb_ret();
return;
}
ptr++;
}
ptr--;
if( *ptr != '\r' && *ptr != '\n' )
nLines++;
arr = hb_itemArrayNew( nLines );
ptr = ptr1 = szText;
n = 1;
while( *ptr )
{
if( *ptr == '\r' || *ptr == '\n' )
{
hb_arraySetCL( arr, n, ptr1, ptr - ptr1 );
if( *( ptr + 1 ) == '\r' || *( ptr + 1 ) == '\n' )
ptr++;
ptr1 = ptr + 1;
n++;
}
ptr++;
}
if( n == nLines )
{
if( *( ptr - 1 ) == 0x1A )
ptr--;
hb_arraySetCL( arr, n, ptr1, ptr - ptr1 );
}
hb_itemReturnRelease( arr );
}

View File

@@ -72,7 +72,7 @@ CREATE CLASS HBFORMATCODE
VAR cEol
VAR nLineErr, nErr, cLineErr
VAR nEol INIT -1 // Eol: -1 - no change, 0 - OS default, 1 - DOS, 2 - UNIX
VAR nEol INIT 0 // Eol: -1 - no change, 0 - OS default, 1 - DOS, 2 - UNIX
VAR lFCaseLow INIT .F. // If true, convert file name to lower case
VAR lNoTabs INIT .T. // If true, converts all tabs to spaces
VAR lIndent INIT .T. // If true, indent code
@@ -214,6 +214,9 @@ METHOD Reformat( aFile ) CLASS HBFORMATCODE
IF aFile[ i ] == NIL
EXIT
ENDIF
IF Empty( aFile[ i ] )
LOOP
ENDIF
IF ::bCallBack != NIL
Eval( ::bCallBack, aFile, i )
ENDIF
@@ -773,12 +776,16 @@ METHOD ReadIni( cIniName ) CLASS HBFORMATCODE
METHOD File2Array( cFileName ) CLASS HBFORMATCODE
LOCAL aFile, cEol
LOCAL aFile
IF hb_FileExists( cFileName )
aFile := __hbformat_FileRead( MemoRead( cFileName ), @cEol )
aFile := hb_ATokens( StrTran( MemoRead( cFileName ), Chr( 13 ) + Chr( 10 ), Chr( 10 ) ), Chr( 10 ) )
IF ::nEol < 0
::cEol := cEol
IF Chr( 13 ) + Chr( 10 ) $ MemoRead( cFileName )
::cEol := Chr( 13 ) + Chr( 10 )
ELSE
::cEol := Chr( 10 )
ENDIF
ENDIF
ENDIF
@@ -788,7 +795,7 @@ METHOD Array2File( cFileName, aFile ) CLASS HBFORMATCODE
LOCAL handle, i, nLen := Len( aFile ), cName, cBakName, cPath
cName := iif( ( i := Rat(".",cFileName ) ) == 0, cFileName, SubStr( cFileName, 1, i - 1 ) )
cName := iif( ( i := RAt( ".", cFileName ) ) == 0, cFileName, SubStr( cFileName, 1, i - 1 ) )
IF Empty( ::cExtSave )
cBakName := cName + iif( Left( ::cExtBack, 1 ) != ".", ".", "" ) + ::cExtBack
IF FRename( cFileName, cBakName ) == F_ERROR
@@ -800,8 +807,8 @@ METHOD Array2File( cFileName, aFile ) CLASS HBFORMATCODE
cFileName := cName + iif( Left( ::cExtSave, 1 ) != ".", ".", "" ) + ::cExtSave
ENDIF
IF ::lFCaseLow
cPath := iif( ( i := Rat( '\', cFileName ) ) == 0, ;
iif( ( i := Rat( '/', cFileName ) ) == 0, "", Left( cFileName, i ) ), ;
cPath := iif( ( i := RAt( "\", cFileName ) ) == 0, ;
iif( ( i := RAt( "/", cFileName ) ) == 0, "", Left( cFileName, i ) ), ;
Left( cFileName, i ) )
cFileName := cPath + Lower( iif( i == 0, cFileName, Substr( cFileName, i + 1 ) ) )
ENDIF

View File

@@ -14,4 +14,3 @@
hbformat.hbx
hbfmtcls.prg
fileread.c

View File

@@ -26,7 +26,6 @@
#endif
DYNAMIC HBFORMATCODE
DYNAMIC __HBFORMAT_FILEREAD
#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBFORMAT__REQUEST )
#uncommand DYNAMIC <fncs,...> => EXTERNAL <fncs>

View File

@@ -117,7 +117,7 @@ STATIC PROCEDURE Reformat( oRef, cFileName )
LOCAL aFile
IF !Empty( aFile := oRef:File2Array( cFileName ) )
OutStd( "Reformatting " + cFileName + hb_eol() )
OutStd( "Reformatting " + cFileName + " (" + hb_ntos( Len( aFile ) ) + " lines)" + hb_eol() )
OutStd( "<" + hb_eol() )
IF oRef:Reformat( aFile )
oRef:Array2File( cFileName, aFile )

View File

@@ -85,6 +85,8 @@ PROCEDURE ultimo()
PROCEDURE creafiletest()
LOCAL aCampi, i, m_num
IF .NOT. File( "test.dbf" )
aCampi := {}
AAdd( aCampi, { "num", "N", 6, 0 } )

View File

@@ -33,8 +33,8 @@ PROCEDURE incrementa()
LOCAL x
x = lcd:value()
x ++
x := lcd:value()
x++
lcd:display( x )
RETURN
@@ -43,8 +43,8 @@ PROCEDURE decrementa()
LOCAL x
x = lcd:value()
x --
x := lcd:value()
x--
lcd:display( x )
RETURN

View File

@@ -0,0 +1,46 @@
#include "hbqtgui.ch"
STATIC s_qApp
STATIC finestra
STATIC testo
STATIC edit1, edit2, edit3
STATIC calcola
PROCEDURE Main()
SET DATE ITALIAN
s_qApp := QApplication()
finestra := QMainWindow()
finestra:resize( 400, 300 )
finestra:setWindowTitle( "Giovanni" )
testo := QLabel( finestra )
testo:setText( "Difference between two dates" )
testo:move( 130, 20 )
testo:resize( 171, 16 )
edit1 := QLineEdit( finestra )
edit1:resize( 113, 20 )
edit1:move( 140, 100 )
edit2 := QLineEdit( finestra )
edit2:resize( 113, 20 )
edit2:move( 140, 130 )
edit3 := QLineEdit( finestra )
edit3:resize( 113, 20 )
edit3:move( 140, 180 )
calcola := QPushButton( finestra )
calcola:resize( 75, 23 )
calcola:move( 270, 180 )
calcola:setText( "Calculate" )
calcola:Connect( "clicked()", { || calcola() } )
finestra:show()
s_qApp:exec()
RETURN
PROCEDURE calcola()
LOCAL differenza
differenza = Abs( CToD( edit1:text() ) - CToD( edit2:text() ) )
edit3:setText( AllTrim( Str(differenza ) ) )
RETURN

View File

@@ -0,0 +1,45 @@
#include "hbqtgui.ch"
STATIC s_qApp
STATIC finestra
STATIC bottone1, bottone2, bottone3
PROCEDURE Main()
s_qApp := QApplication()
finestra := QMainWindow()
finestra:resize( 400, 300 )
finestra:setWindowTitle( "Giovanni" )
bottone1 := QRadioButton( finestra )
bottone1:move( 100, 50 )
bottone1:setText( "Si" )
bottone1:Connect( "clicked()", { || messaggio( "SI" ) } )
bottone2 := QRadioButton( finestra )
bottone2:move( 100, 80 )
bottone2:setText( "No" )
bottone2:Connect( "clicked()", { || messaggio( "NO" ) } )
bottone3 := QRadioButton( finestra )
bottone3:move( 100, 110 )
bottone3:setText( "Non so" )
bottone3:Connect( "clicked()", { || messaggio( "NON SO" ) } )
finestra:show()
s_qApp:exec()
RETURN
PROCEDURE messaggio( msg )
STATIC oBox
oBox := QMessageBox()
oBox:setInformativeText( msg )
oBox:setWindowTitle( "Informazione" )
oBox:show()
RETURN