diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e967c0425c..ea1e341373 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,18 @@ The license applies to all entries newer than 2009-04-28. */ +2012-07-19 21:10 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbnf/descendn.c + * contrib/hbnf/dispc.c + * contrib/hbnf/fttext.c + * contrib/hbnf/peek.c + * contrib/hbnf/poke.c + * contrib/hbnf/proper.c + * contrib/hbnf/prtscr.c + * uncrustified + ! fixed warning on __max()/__min() macros by replacing them + with Harbour macros + 2012-07-19 20:49 UTC+0200 Viktor Szakats (vszakats syenar.net) * examples/hbapollo/dbedit.prg ! fix (to a source redone for Harbour) diff --git a/harbour/contrib/hbnf/descendn.c b/harbour/contrib/hbnf/descendn.c index 605e4d1dbc..29785011c5 100644 --- a/harbour/contrib/hbnf/descendn.c +++ b/harbour/contrib/hbnf/descendn.c @@ -28,37 +28,37 @@ HB_FUNC( FT_DESCEND ) { #if defined( HB_OS_DOS ) || defined( HB_OS_WIN ) { - PHB_ITEM iP = hb_itemParam( 1 ); - HB_TYPE uiType = hb_itemType( iP ); + PHB_ITEM iP = hb_itemParam( 1 ); + HB_TYPE uiType = hb_itemType( iP ); - PHB_ITEM iR = NULL; - HB_SIZE uiLen, n; - char * pDescend; + PHB_ITEM iR = NULL; + HB_SIZE uiLen, n; + char * pDescend; - if ( ( uiType & HB_IT_NUMERIC ) && ( uiType & HB_IT_DOUBLE ) ) + if( ( uiType & HB_IT_NUMERIC ) && ( uiType & HB_IT_DOUBLE ) ) iR = hb_itemPutND( 0, 0 - hb_itemGetND( iP ) ); - else if ( uiType & HB_IT_NUMERIC ) + else if( uiType & HB_IT_NUMERIC ) iR = hb_itemPutNL( 0, 0 - hb_itemGetNL( iP ) ); - else if ( uiType & HB_IT_DATE ) + else if( uiType & HB_IT_DATE ) iR = hb_itemPutNL( 0, 0x4FD4C0L - hb_itemGetNL( iP ) ); - else if ( uiType & HB_IT_TIMESTAMP ) + else if( uiType & HB_IT_TIMESTAMP ) iR = hb_itemPutND( 0, 0x4FD4C0L - hb_itemGetTD( iP ) ); - else if ( uiType & HB_IT_LOGICAL ) + else if( uiType & HB_IT_LOGICAL ) iR = hb_itemPutL( 0, ( hb_itemGetL( iP ) > 0 ) ? 0 : 1 ); - else if ( uiType & HB_IT_STRING ) + else if( uiType & HB_IT_STRING ) { - uiLen = hb_itemSize( iP ); + uiLen = hb_itemSize( iP ); pDescend = ( char * ) hb_xgrab( uiLen ); hb_itemCopyC( iP, pDescend, uiLen ); - for ( n = 0; n < uiLen; n++ ) + for( n = 0; n < uiLen; n++ ) pDescend[ n ] = ( char ) 0 - pDescend[ n ]; iR = hb_itemPutCL( 0, pDescend, uiLen ); diff --git a/harbour/contrib/hbnf/dispc.c b/harbour/contrib/hbnf/dispc.c index 01d4d171d9..dee92666f8 100644 --- a/harbour/contrib/hbnf/dispc.c +++ b/harbour/contrib/hbnf/dispc.c @@ -57,61 +57,61 @@ #include "inkey.ch" -#define K_STRING 0 -#define K_LIST (!K_STRING) +#define K_STRING 0 +#define K_LIST ( ! K_STRING ) -#define CR ((char) 13) -#define LF ((char) 10) -#define FEOF ((char) 26) +#define CR ( ( char ) 13 ) +#define LF ( ( char ) 10 ) +#define FEOF ( ( char ) 26 ) -#define READONLY 0 /* open file modes */ -#define WRITEONLY 1 -#define READWRITE 2 +#define READONLY 0 /* open file modes */ +#define WRITEONLY 1 +#define READWRITE 2 -#define BUFFERSIZE 4096 /* maximum size of the file buffer */ -#define MAXLINE 255 /* default maximum size of a line */ +#define BUFFERSIZE 4096 /* maximum size of the file buffer */ +#define MAXLINE 255 /* default maximum size of a line */ -#define TABSET 8 +#define TABSET 8 -HB_FOFFSET buffoffset; /* offset into buffer of current line */ -HB_FOFFSET fsize; /* file size in bytes */ -HB_ISIZ bufftop, buffbot; /* first and last character in buffer */ -int wintop, winbot; /* first and last character in window */ -int winrow, wincol; /* row and column of window highlight */ -int sline, eline; /* start and end line of window */ -int scol, ecol; /* start and end col of window */ -int height, width; /* height and width of window */ -HB_FHANDLE infile; /* input file handle */ -int maxlin; /* line size */ -HB_ISIZ buffsize; /* buffer size */ -int hlight; /* highlight attribute */ -int norm; /* normal attribute */ -HB_ISIZ kcount; /* number of keys in terminate key list*/ -int colinc; /* col increment amount */ -HB_BOOL bBrowse; /* browse flag */ -HB_BOOL bRefresh; /* HB_TRUE means refresh screen */ -char kstr[25]; /* terminate key string */ -int keylist[24]; /* terminate key list */ -int keytype; /* K_STRING or K_LIST */ +HB_FOFFSET buffoffset; /* offset into buffer of current line */ +HB_FOFFSET fsize; /* file size in bytes */ +HB_ISIZ bufftop, buffbot; /* first and last character in buffer */ +int wintop, winbot; /* first and last character in window */ +int winrow, wincol; /* row and column of window highlight */ +int sline, eline; /* start and end line of window */ +int scol, ecol; /* start and end col of window */ +int height, width; /* height and width of window */ +HB_FHANDLE infile; /* input file handle */ +int maxlin; /* line size */ +HB_ISIZ buffsize; /* buffer size */ +int hlight; /* highlight attribute */ +int norm; /* normal attribute */ +HB_ISIZ kcount; /* number of keys in terminate key list*/ +int colinc; /* col increment amount */ +HB_BOOL bBrowse; /* browse flag */ +HB_BOOL bRefresh; /* HB_TRUE means refresh screen */ +char kstr[ 25 ]; /* terminate key string */ +int keylist[ 24 ]; /* terminate key list */ +int keytype; /* K_STRING or K_LIST */ -HB_BOOL bIsAllocated; /* if buffers were allocated */ -char *buffer; /* file buffer pointer */ -char *lbuff; /* line buffer pointer */ -char *vseg; /* video segment variable */ +HB_BOOL bIsAllocated; /* if buffers were allocated */ +char * buffer; /* file buffer pointer */ +char * lbuff; /* line buffer pointer */ +char * vseg; /* video segment variable */ - /* prototypes */ +/* prototypes */ -static void chattr(int x, int y, int len, int attr); +static void chattr( int x, int y, int len, int attr ); static HB_FOFFSET getblock( HB_FOFFSET offset ); -static void buff_align(void); -static void win_align(void); -static void disp_update(int offset); -static void windown(void); -static void winup(void); -static void linedown(void); -static void lineup(void); -static void filetop(void); -static void filebot(void); +static void buff_align( void ); +static void win_align( void ); +static void disp_update( int offset ); +static void windown( void ); +static void winup( void ); +static void linedown( void ); +static void lineup( void ); +static void filetop( void ); +static void filebot( void ); /* * chattr() replace the color attribute with a new one starting at @@ -119,16 +119,16 @@ static void filebot(void); * */ -static void chattr(int x, int y, int len, int attr) +static void chattr( int x, int y, int len, int attr ) { - int i; - char *vmem; + int i; + char * vmem; - vmem = vseg + (y * (width + 1) * 2) + (x * 2) + 1; - /* calc the screen memory coord */ + vmem = vseg + ( y * ( width + 1 ) * 2 ) + ( x * 2 ) + 1; + /* calc the screen memory coord */ - for (i = 0; i <= len; i++, vmem += 2) /* write the new attribute value */ - *vmem = (char) attr; + for( i = 0; i <= len; i++, vmem += 2 ) /* write the new attribute value */ + *vmem = ( char ) attr; } /* @@ -144,37 +144,37 @@ static void chattr(int x, int y, int len, int attr) static HB_FOFFSET getblock( HB_FOFFSET offset ) { - /* - set the file pointer to the proper offset - and if an error occured then check to see - if a positive offset was requested, if so - then set the pointer to the offset from - the end of the file, otherwise set it from - the beginning of the file. - */ + /* + set the file pointer to the proper offset + and if an error occured then check to see + if a positive offset was requested, if so + then set the pointer to the offset from + the end of the file, otherwise set it from + the beginning of the file. + */ - hb_fsSeekLarge( infile, offset, FS_SET ); + hb_fsSeekLarge( infile, offset, FS_SET ); - /* read in the file and set the buffer bottom variable equal */ - /* to the number of bytes actually read in. */ + /* read in the file and set the buffer bottom variable equal */ + /* to the number of bytes actually read in. */ - buffbot = hb_fsReadLarge( infile, buffer, buffsize ); + buffbot = hb_fsReadLarge( infile, buffer, buffsize ); - /* if a full buffer's worth was not read in, make it full. */ + /* if a full buffer's worth was not read in, make it full. */ - if (( buffbot != buffsize ) && ( fsize > buffsize )) - { - if ( offset > 0 ) - hb_fsSeekLarge( infile, -buffsize, FS_END ); - else - hb_fsSeekLarge( infile, buffsize, FS_SET ); + if( ( buffbot != buffsize ) && ( fsize > buffsize ) ) + { + if( offset > 0 ) + hb_fsSeekLarge( infile, -buffsize, FS_END ); + else + hb_fsSeekLarge( infile, buffsize, FS_SET ); - buffbot = hb_fsReadLarge( infile, buffer, buffsize ); - } + buffbot = hb_fsReadLarge( infile, buffer, buffsize ); + } - /* return the actual file position */ + /* return the actual file position */ - return hb_fsSeekLarge( infile, 0, FS_RELATIVE ) - buffbot; + return hb_fsSeekLarge( infile, 0, FS_RELATIVE ) - buffbot; } /* @@ -185,47 +185,47 @@ static HB_FOFFSET getblock( HB_FOFFSET offset ) static void buff_align() { - HB_ISIZ i; + HB_ISIZ i; - bufftop = 0; - buffbot = buffsize; + bufftop = 0; + buffbot = buffsize; - if ( buffoffset != 0 ) /* if the buffoffset is otherthan 0 */ - { - i = bufftop; /* start at the top of the file and scan */ - /* forward until a CR is reached. */ + if( buffoffset != 0 ) /* if the buffoffset is otherthan 0 */ + { + i = bufftop; /* start at the top of the file and scan */ + /* forward until a CR is reached. */ - while (( buffer[i] != CR ) && ( i < buffbot )) - i++; + while( ( buffer[ i ] != CR ) && ( i < buffbot ) ) + i++; - bufftop = i + 2; - } + bufftop = i + 2; + } - /* if the buffer offset is not a complete */ - /* buffer's length away from the file end */ + /* if the buffer offset is not a complete */ + /* buffer's length away from the file end */ - if ( buffoffset + buffbot != fsize ) - { - /* - if the file position of the last byte - of the buffer would end up past the - end of the file, then the buffer does - contain a complete buffer full and the - buffer end pointer needs to be set to - the last character of the file. - */ + if( buffoffset + buffbot != fsize ) + { + /* + if the file position of the last byte + of the buffer would end up past the + end of the file, then the buffer does + contain a complete buffer full and the + buffer end pointer needs to be set to + the last character of the file. + */ - if ( buffoffset + buffbot > fsize ) - buffbot = ( HB_ISIZ ) ( fsize - buffoffset ); + if( buffoffset + buffbot > fsize ) + buffbot = ( HB_ISIZ ) ( fsize - buffoffset ); - i = buffbot; /* point the end of the buffer to a valid */ - /* complete text line. */ + i = buffbot; /* point the end of the buffer to a valid */ + /* complete text line. */ - while (( buffer[i] != CR ) && ( i > bufftop )) - i--; + while( ( buffer[ i ] != CR ) && ( i > bufftop ) ) + i--; - buffbot = i + 2; - } + buffbot = i + 2; + } } /* @@ -238,37 +238,37 @@ static void buff_align() static void win_align() { - int i; + int i; - winbot = wintop; /* find out if there is enough text for */ - i = 0; /* full window. */ + winbot = wintop; /* find out if there is enough text for */ + i = 0; /* full window. */ - while (( winbot < buffbot ) && ( i < height )) - { - if ( buffer[winbot] == CR ) + while( ( winbot < buffbot ) && ( i < height ) ) + { + if( buffer[ winbot ] == CR ) + i++; + winbot++; + } + + if( i < height ) /* if there is not a full window, */ + { + /* then retrofit winbot to the end of a line */ + while( buffer[ winbot ] != LF && winbot > bufftop ) + winbot--; + + wintop = winbot; + i = 0; /* and setup wintop */ + + while( ( wintop > bufftop ) && ( i <= height ) ) + { + if( buffer[ wintop ] == LF ) i++; - winbot++; - } + wintop--; + } - if ( i < height ) /* if there is not a full window, */ - { - /* then retrofit winbot to the end of a line */ - while ( buffer[winbot] != LF && winbot > bufftop) - winbot--; - - wintop = winbot; - i = 0; /* and setup wintop */ - - while (( wintop > bufftop ) && ( i <= height )) - { - if ( buffer[wintop] == LF ) - i++; - wintop--; - } - - if ( wintop != bufftop ) - wintop += 2; - } + if( wintop != bufftop ) + wintop += 2; + } } /* @@ -280,57 +280,58 @@ static void win_align() * */ -static void disp_update(int offset) +static void disp_update( int offset ) { - int line, col, pos, i; - char *vmem; + int line, col, pos, i; + char * vmem; - bRefresh = HB_FALSE; - line = 0; + bRefresh = HB_FALSE; + line = 0; - while ( line < height ) - { - /* - calculate the initial position, this save execution - time because each column is considered as a offset - from the line start - */ + while( line < height ) + { + /* + calculate the initial position, this save execution + time because each column is considered as a offset + from the line start + */ - pos = (line * (width + 1) * 2); + pos = ( line * ( width + 1 ) * 2 ); - /* copy string to temp buffer */ + /* copy string to temp buffer */ - for (i = 0; buffer[offset] != CR && offset <= winbot; offset++) - { - if ( i <= maxlin ) - { - if (buffer[offset] == '\t') /* check for a tab */ - { - lbuff[i++] = ' '; /* pad with spaces */ - while (i % TABSET && i <= maxlin) /* until tab stop */ - lbuff[i++] = ' '; /* is reached or EOL */ - } - else lbuff[i++] = buffer[offset]; + for( i = 0; buffer[ offset ] != CR && offset <= winbot; offset++ ) + { + if( i <= maxlin ) + { + if( buffer[ offset ] == '\t' ) /* check for a tab */ + { + lbuff[ i++ ] = ' '; /* pad with spaces */ + while( i % TABSET && i <= maxlin ) /* until tab stop */ + lbuff[ i++ ] = ' '; /* is reached or EOL */ + } + else + lbuff[ i++ ] = buffer[ offset ]; - } - } + } + } - for (; i <= maxlin; i++) /* fill out with spaces */ - lbuff[i] = ' '; + for(; i <= maxlin; i++ ) /* fill out with spaces */ + lbuff[ i ] = ' '; - /* place the proper characters onto the screen */ + /* place the proper characters onto the screen */ - for (i = wincol, col = 0; col <= width; col++) - { - vmem = vseg + pos + (col * 2); + for( i = wincol, col = 0; col <= width; col++ ) + { + vmem = vseg + pos + ( col * 2 ); - *vmem = lbuff[i++]; - } + *vmem = lbuff[ i++ ]; + } - line += 1; - offset += 2; - } - hb_gtRest( sline, scol, eline, ecol, vseg ); + line += 1; + offset += 2; + } + hb_gtRest( sline, scol, eline, ecol, vseg ); } /* @@ -342,42 +343,43 @@ static void disp_update(int offset) static void winup() { - int k; - HB_FOFFSET i, j; + int k; + HB_FOFFSET i, j; - bRefresh = HB_TRUE; - k = wintop - 3; + bRefresh = HB_TRUE; + k = wintop - 3; - while (( buffer[k] != CR ) && ( k > bufftop )) - k--; + while( ( buffer[ k ] != CR ) && ( k > bufftop ) ) + k--; - if ( k >= bufftop ) - { - if (buffer[k] == CR) k += 2; + if( k >= bufftop ) + { + if( buffer[ k ] == CR ) + k += 2; - wintop = k; - k = winbot - 3; + wintop = k; + k = winbot - 3; - while ( buffer[k] != CR ) - k--; + while( buffer[ k ] != CR ) + k--; - winbot = k + 2; - } - else - if ( bufftop + buffoffset > 0 && fsize > buffsize ) - { - i = buffoffset + wintop; - j = buffoffset - (buffsize / 2); + winbot = k + 2; + } + else + if( bufftop + buffoffset > 0 && fsize > buffsize ) + { + i = buffoffset + wintop; + j = buffoffset - ( buffsize / 2 ); - if ( j < 0 ) - j = 0; + if( j < 0 ) + j = 0; - buffoffset = getblock(j); - wintop = ((int) (i - buffoffset)); + buffoffset = getblock( j ); + wintop = ( ( int ) ( i - buffoffset ) ); - buff_align(); - win_align(); - } + buff_align(); + win_align(); + } } /* @@ -389,385 +391,392 @@ static void winup() static void windown() { - int k; - HB_FOFFSET i, j; + int k; + HB_FOFFSET i, j; - bRefresh = HB_TRUE; - k = winbot; + bRefresh = HB_TRUE; + k = winbot; - while (( buffer[k] != CR ) && ( k <= buffbot )) - k++; - k += 2; + while( ( buffer[ k ] != CR ) && ( k <= buffbot ) ) + k++; + k += 2; - if ( k <= buffbot ) - { - winbot = k; - k = wintop; + if( k <= buffbot ) + { + winbot = k; + k = wintop; - while ( buffer[k] != CR ) - k++; - wintop = k + 2; - } - else - if ( (buffbot + buffoffset) < fsize && fsize > buffsize) - { - i = buffoffset + wintop; - j = i; + while( buffer[ k ] != CR ) + k++; + wintop = k + 2; + } + else + if( ( buffbot + buffoffset ) < fsize && fsize > buffsize ) + { + i = buffoffset + wintop; + j = i; - if ( j > fsize ) - j = fsize - buffsize; + if( j > fsize ) + j = fsize - buffsize; - buffoffset = getblock(j); + buffoffset = getblock( j ); - if ( i < buffoffset ) - wintop = 0; - else - wintop = ((int) (i - buffoffset)); + if( i < buffoffset ) + wintop = 0; + else + wintop = ( ( int ) ( i - buffoffset ) ); - buff_align(); - win_align(); - } + buff_align(); + win_align(); + } } /* move the cursor one line down */ static void linedown() { - if ( winrow < eline ) /* if cursor not at last line */ - winrow += 1; - else /* otherwise adjust the window top variable */ - windown(); + if( winrow < eline ) /* if cursor not at last line */ + winrow += 1; + else /* otherwise adjust the window top variable */ + windown(); } /* move the cursor one line up */ static void lineup() { - if ( winrow > sline ) - winrow -= 1; - else - winup(); + if( winrow > sline ) + winrow -= 1; + else + winup(); } /* go to the top of the file */ static void filetop() { - if ( buffoffset != 0 ) - { - buffoffset = getblock(0); + if( buffoffset != 0 ) + { + buffoffset = getblock( 0 ); - buff_align(); - } + buff_align(); + } - bRefresh = HB_TRUE; - wintop = ( int ) buffoffset; - winrow = sline; - wincol = 0; + bRefresh = HB_TRUE; + wintop = ( int ) buffoffset; + winrow = sline; + wincol = 0; - win_align(); + win_align(); } /* goto the bottom of the file */ static void filebot() { - if( ( buffbot + buffoffset) < fsize && fsize > buffsize ) - { - buffoffset = getblock(fsize + 1); + if( ( buffbot + buffoffset ) < fsize && fsize > buffsize ) + { + buffoffset = getblock( fsize + 1 ); - buff_align(); - } + buff_align(); + } - bRefresh = HB_TRUE; - wintop = ( int ) buffbot - 3; - winrow = eline; - wincol = 0; + bRefresh = HB_TRUE; + wintop = ( int ) buffbot - 3; + winrow = eline; + wincol = 0; - win_align(); + win_align(); } HB_FUNC( _FT_DFINIT ) { - int rval; - HB_ISIZ j; - HB_ISIZ i; - HB_SIZE ulSize; + int rval; + HB_ISIZ j; + HB_ISIZ i; + HB_SIZE ulSize; - rval = 0; + rval = 0; - sline = hb_parni(2); /* top row of window */ - scol = hb_parni(3); /* left col */ - eline = hb_parni(4); /* bottom row */ - ecol = hb_parni(5); /* right col */ + sline = hb_parni( 2 ); /* top row of window */ + scol = hb_parni( 3 ); /* left col */ + eline = hb_parni( 4 ); /* bottom row */ + ecol = hb_parni( 5 ); /* right col */ - width = ecol - scol; /* calc width of window */ - height = eline - sline + 1; /* calc height of window */ + width = ecol - scol; /* calc width of window */ + height = eline - sline + 1; /* calc height of window */ - hb_gtRectSize( sline, scol, eline, ecol, &ulSize ); - vseg = (char * ) hb_xalloc( ulSize ); - if (vseg != NULL) - hb_gtSave( sline, scol, eline, ecol, vseg ); + hb_gtRectSize( sline, scol, eline, ecol, &ulSize ); + vseg = ( char * ) hb_xalloc( ulSize ); + if( vseg != NULL ) + hb_gtSave( sline, scol, eline, ecol, vseg ); - maxlin = hb_parni(12); - buffsize = hb_parns(13); /* yes - load value */ + maxlin = hb_parni( 12 ); + buffsize = hb_parns( 13 ); /* yes - load value */ - buffer = (char *) hb_xalloc(buffsize); /* allocate memory */ - lbuff = (char *) hb_xalloc(maxlin + 1); /* for buffers */ + buffer = ( char * ) hb_xalloc( buffsize ); /* allocate memory */ + lbuff = ( char * ) hb_xalloc( maxlin + 1 ); /* for buffers */ - bIsAllocated = !(buffer == NULL || lbuff == NULL || vseg == NULL); - /* memory allocated? */ - if (!bIsAllocated) - { - rval = 8; /* return error code 8 (memory) */ - if (buffer != NULL) hb_xfree(buffer); - if (lbuff != NULL) hb_xfree(lbuff); - if (vseg != NULL) hb_xfree(vseg); - } - else /* get parameters */ - { - infile = hb_numToHandle( hb_parnint( 1 ) ); /* file handle */ - j = hb_parni(6); /* starting line value */ - norm = hb_parni(7); /* normal color attribute */ - hlight = hb_parni(8); /* highlight color attribute */ + bIsAllocated = ! ( buffer == NULL || lbuff == NULL || vseg == NULL ); + /* memory allocated? */ + if( ! bIsAllocated ) + { + rval = 8; /* return error code 8 (memory) */ + if( buffer != NULL ) + hb_xfree( buffer ); + if( lbuff != NULL ) + hb_xfree( lbuff ); + if( vseg != NULL ) + hb_xfree( vseg ); + } + else /* get parameters */ + { + infile = hb_numToHandle( hb_parnint( 1 ) ); /* file handle */ + j = hb_parni( 6 ); /* starting line value */ + norm = hb_parni( 7 ); /* normal color attribute */ + hlight = hb_parni( 8 ); /* highlight color attribute */ - if( HB_ISARRAY( 9 ) ) - { - keytype = K_LIST; - kcount = hb_parinfa( 9, 0 ); - if (kcount > 24) - kcount = 24; - for (i = 1; i <= kcount; i++) - keylist[i - 1] = hb_parvni( 9, i ); /* get exit key list */ - } - else - { - keytype = K_STRING; - kcount = hb_parclen( 9 ); - if( kcount > 24 ) - kcount = 24; - hb_strncpy(kstr, hb_parcx( 9 ), kcount - 1); /* get exit key string */ - } + if( HB_ISARRAY( 9 ) ) + { + keytype = K_LIST; + kcount = hb_parinfa( 9, 0 ); + if( kcount > 24 ) + kcount = 24; + for( i = 1; i <= kcount; i++ ) + keylist[ i - 1 ] = hb_parvni( 9, i ); /* get exit key list */ + } + else + { + keytype = K_STRING; + kcount = hb_parclen( 9 ); + if( kcount > 24 ) + kcount = 24; + hb_strncpy( kstr, hb_parcx( 9 ), kcount - 1 ); /* get exit key string */ + } - bBrowse = hb_parl(10); /* get browse flag */ + bBrowse = hb_parl( 10 ); /* get browse flag */ - colinc = hb_parni(11); /* column skip value */ + colinc = hb_parni( 11 ); /* column skip value */ - bufftop = 0; /* init buffer top pointer */ - buffbot = buffsize; /* init buffer bottom pointer */ - buffoffset = 0; /* curr line offset into buffer */ - winrow = sline; /* init window row */ - wincol = 0; /* init window col */ - wintop = 0; /* init window top pointer */ - winbot = 0; /* init window bottom pointer */ + bufftop = 0; /* init buffer top pointer */ + buffbot = buffsize; /* init buffer bottom pointer */ + buffoffset = 0; /* curr line offset into buffer */ + winrow = sline; /* init window row */ + wincol = 0; /* init window col */ + wintop = 0; /* init window top pointer */ + winbot = 0; /* init window bottom pointer */ - /* get file size */ + /* get file size */ - fsize = hb_fsSeek( infile, 0, FS_END ) - 1; + fsize = hb_fsSeek( infile, 0, FS_END ) - 1; - /* get the first block */ + /* get the first block */ - hb_fsSeek( infile, 0, FS_SET ); + hb_fsSeek( infile, 0, FS_SET ); - /* if block less than buffsize */ + /* if block less than buffsize */ - if ( fsize < buffbot ) - buffbot = (int) fsize; /* then set buffer bottom */ + if( fsize < buffbot ) + buffbot = ( int ) fsize; /* then set buffer bottom */ - /* set the current lines buffer offset pointer */ + /* set the current lines buffer offset pointer */ - buffoffset = getblock( bufftop ); + buffoffset = getblock( bufftop ); - /* align buffer and window pointer to valid values */ + /* align buffer and window pointer to valid values */ - buff_align(); - win_align(); + buff_align(); + win_align(); - /* point line pointer to line passed by caller */ + /* point line pointer to line passed by caller */ - for (i = 1; i < j; i++) - linedown(); + for( i = 1; i < j; i++ ) + linedown(); - hb_gtRest( sline, scol, eline, ecol, vseg ); + hb_gtRest( sline, scol, eline, ecol, vseg ); - } + } - hb_retni(rval); + hb_retni( rval ); } -HB_FUNC ( _FT_DFCLOS ) +HB_FUNC( _FT_DFCLOS ) { - if (bIsAllocated) - { - if (buffer != NULL) hb_xfree(buffer); /* free up allocated buffer memory */ - if (lbuff != NULL) hb_xfree(lbuff); - if (vseg != NULL) hb_xfree(vseg); - } + if( bIsAllocated ) + { + if( buffer != NULL ) + hb_xfree( buffer ); /* free up allocated buffer memory */ + if( lbuff != NULL ) + hb_xfree( lbuff ); + if( vseg != NULL ) + hb_xfree( vseg ); + } } HB_FUNC( FT_DISPFILE ) { - int i; - char rval[2]; - HB_BOOL bDone; + int i; + char rval[ 2 ]; + HB_BOOL bDone; - int ch; + int ch; - /* make sure buffers were allocated and file was opened */ - if (bIsAllocated && infile > 0) + /* make sure buffers were allocated and file was opened */ + if( bIsAllocated && infile > 0 ) + { + bDone = HB_FALSE; + bRefresh = HB_TRUE; + + /* draw inside of window with normal color attribute */ + + for( i = 0; i < height; i++ ) + chattr( 0, i, width, norm ); + + hb_gtRest( sline, scol, eline, ecol, vseg ); + + /* main processing loop -- terminated by user key press */ + + do { - bDone = HB_FALSE; - bRefresh = HB_TRUE; + if( bRefresh ) /* redraw window contents? */ + disp_update( wintop ); - /* draw inside of window with normal color attribute */ + hb_gtRest( sline, scol, eline, ecol, vseg ); - for (i = 0; i < height; i++) - chattr(0, i, width, norm); + /* if not browse, highlight the current line */ - hb_gtRest( sline, scol, eline, ecol, vseg ); + if( ! bBrowse ) + chattr( 0, winrow - sline, width, hlight ); - /* main processing loop -- terminated by user key press */ + hb_gtRest( sline, scol, eline, ecol, vseg ); - do - { - if( bRefresh ) /* redraw window contents? */ - disp_update(wintop); + hb_gtSetPos( winrow, scol ); - hb_gtRest( sline, scol, eline, ecol, vseg ); + ch = hb_inkey( HB_TRUE, 0.0, INKEY_ALL ); - /* if not browse, highlight the current line */ + /* if not browse, then un-highlight current line */ - if( ! bBrowse ) - chattr(0, winrow - sline, width, hlight); + if( ! bBrowse ) + chattr( 0, winrow - sline, width, norm ); - hb_gtRest( sline, scol, eline, ecol, vseg ); + hb_gtRest( sline, scol, eline, ecol, vseg ); - hb_gtSetPos( winrow, scol ); + /* figure out what the user wants to do */ - ch = hb_inkey( HB_TRUE, 0.0, INKEY_ALL ); + switch( ch ) + { + case K_DOWN: if( bBrowse ) /* if browse flag */ + winrow = eline; /* is set, force */ + /* active line to */ + linedown(); /* be last line */ + break; - /* if not browse, then un-highlight current line */ + case K_UP: if( bBrowse ) /* if browse flag */ + winrow = sline; /* is set, force */ + /* active line to */ + lineup(); /* be first line */ + break; - if( ! bBrowse ) - chattr(0, winrow - sline, width, norm); + case K_LEFT: wincol -= colinc; /* move cursor */ + bRefresh = HB_TRUE; /* to the left */ - hb_gtRest( sline, scol, eline, ecol, vseg ); + if( wincol < 0 ) + wincol = 0; - /* figure out what the user wants to do */ + break; - switch (ch) - { - case K_DOWN : if( bBrowse ) /* if browse flag */ - winrow = eline; /* is set, force */ - /* active line to */ - linedown(); /* be last line */ - break; + case K_RIGHT: wincol += colinc; /* move cursor */ + bRefresh = HB_TRUE; /* to the right */ - case K_UP : if( bBrowse ) /* if browse flag */ - winrow = sline; /* is set, force */ - /* active line to */ - lineup(); /* be first line */ - break; + if( wincol > ( maxlin - width ) ) + wincol = maxlin - width; - case K_LEFT : wincol -= colinc; /* move cursor */ - bRefresh = HB_TRUE; /* to the left */ + break; - if ( wincol < 0 ) - wincol = 0; + case K_HOME: wincol = 0; /* move cursor */ + bRefresh = HB_TRUE; /* to first col */ - break; + break; - case K_RIGHT : wincol += colinc; /* move cursor */ - bRefresh = HB_TRUE; /* to the right */ + /* move cursor to last col */ - if ( wincol > (maxlin - width) ) - wincol = maxlin - width; + case K_END: wincol = maxlin - width; + bRefresh = HB_TRUE; - break; + break; - case K_HOME : wincol = 0; /* move cursor */ - bRefresh = HB_TRUE; /* to first col */ + case K_CTRL_LEFT: wincol -= 16; /* move cursor */ + bRefresh = HB_TRUE; /* 16 col to left */ - break; + if( wincol < 0 ) + wincol = 0; - /* move cursor to last col */ + break; - case K_END : wincol = maxlin - width; - bRefresh = HB_TRUE; + case K_CTRL_RIGHT: wincol += 16; /* move cursor */ + bRefresh = HB_TRUE; /* 16 col to right */ - break; + if( wincol > ( maxlin - width ) ) + wincol = maxlin - width; - case K_CTRL_LEFT : wincol -= 16; /* move cursor */ - bRefresh = HB_TRUE; /* 16 col to left */ + break; - if ( wincol < 0 ) - wincol = 0; + case K_PGUP: for( i = 0; i < height; i++ ) /* move window */ + winup(); /* up one page */ - break; + break; - case K_CTRL_RIGHT : wincol += 16; /* move cursor */ - bRefresh = HB_TRUE; /* 16 col to right */ + case K_PGDN: for( i = 0; i < height; i++ ) /* move window */ + windown(); /* down 1 page */ - if ( wincol > (maxlin - width) ) - wincol = maxlin - width; + break; - break; + case K_CTRL_PGUP: filetop(); /* move cursor to */ + break; /* to top of file */ - case K_PGUP : for (i = 0; i < height; i++) /* move window */ - winup(); /* up one page */ + case K_CTRL_PGDN: filebot(); /* move cursor to */ + break; /* to bot of file */ - break; + case K_ENTER: bDone = HB_TRUE; /* carriage return */ + break; /* terminates */ - case K_PGDN : for (i = 0; i < height; i++) /* move window */ - windown(); /* down 1 page */ + case K_ESC: bDone = HB_TRUE; /* escape key */ + break; /* terminates */ - break; + /* scan key list and see if key pressed is there */ - case K_CTRL_PGUP : filetop(); /* move cursor to */ - break; /* to top of file */ - - case K_CTRL_PGDN : filebot(); /* move cursor to */ - break; /* to bot of file */ - - case K_ENTER : bDone = HB_TRUE; /* carriage return */ - break; /* terminates */ - - case K_ESC : bDone = HB_TRUE; /* escape key */ - break; /* terminates */ - - /* scan key list and see if key pressed is there */ - - default : if (keytype == K_STRING) - { - for (i = 0; i <= kcount; i++) - if ((ch > 0) && (ch < 256)) - if ( (int) kstr[i] == ch ) - bDone = HB_TRUE; - break; /* if so terminate */ - } - else - { - for (i = 0; i < kcount; i++) - if ( keylist[i] == ch ) - bDone = HB_TRUE; - break; - } - } - } while( ! bDone ); + default: if( keytype == K_STRING ) + { + for( i = 0; i <= kcount; i++ ) + if( ( ch > 0 ) && ( ch < 256 ) ) + if( ( int ) kstr[ i ] == ch ) + bDone = HB_TRUE; + break; /* if so terminate */ + } + else + { + for( i = 0; i < kcount; i++ ) + if( keylist[ i ] == ch ) + bDone = HB_TRUE; + break; + } + } } - else + while( ! bDone ); + } + else ch = 0; - /* store the key pressed as a character to be returned */ + /* store the key pressed as a character to be returned */ - /* return key value to caller */ + /* return key value to caller */ - if( keytype == K_STRING ) - { - rval[0] = (char) ch; - rval[1] = '\0'; - hb_retc( rval ); - } - else - hb_retni( ch ); + if( keytype == K_STRING ) + { + rval[ 0 ] = ( char ) ch; + rval[ 1 ] = '\0'; + hb_retc( rval ); + } + else + hb_retni( ch ); } diff --git a/harbour/contrib/hbnf/fttext.c b/harbour/contrib/hbnf/fttext.c index e4674f45e1..521c3e5ce3 100644 --- a/harbour/contrib/hbnf/fttext.c +++ b/harbour/contrib/hbnf/fttext.c @@ -152,7 +152,7 @@ enddo ft_fuse() -*/ + */ /* * The following parts are Copyright of the individual authors. @@ -166,11 +166,11 @@ */ /* up this number if you need more than 10 text file areas */ -#define TEXT_WORKAREAS 10 +#define TEXT_WORKAREAS 10 /* raise or lower this number for best performance on your system (larger for dealing with large files or long records, smaller for faster reads) */ -#define BUFFSIZE 4096 +#define BUFFSIZE 4096 #include "hbapi.h" #include "hbapifs.h" @@ -181,7 +181,7 @@ #pragma warning( disable : 4704 ) #endif -#define VALLOC_FLAG 0 +#define VALLOC_FLAG 0 /* routines internal to this module */ static HB_ISIZ _findeol( char * buf, HB_ISIZ buf_len ); @@ -194,18 +194,18 @@ static HB_BOOL _writeeol( HB_FHANDLE fhnd ); /* arrays used by the text workareas */ static int area = 0; -static long recno[ TEXT_WORKAREAS]; -static HB_FOFFSET offset[ TEXT_WORKAREAS]; -static HB_FHANDLE handles[ TEXT_WORKAREAS]; -static long last_rec[TEXT_WORKAREAS]; -static HB_FOFFSET last_off[TEXT_WORKAREAS]; -static HB_FOFFSET lastbyte[TEXT_WORKAREAS]; -static HB_BOOL isBof[ TEXT_WORKAREAS]; -static HB_BOOL isEof[ TEXT_WORKAREAS]; -static HB_ERRCODE error[ TEXT_WORKAREAS]; +static long recno[ TEXT_WORKAREAS ]; +static HB_FOFFSET offset[ TEXT_WORKAREAS ]; +static HB_FHANDLE handles[ TEXT_WORKAREAS ]; +static long last_rec[ TEXT_WORKAREAS ]; +static HB_FOFFSET last_off[ TEXT_WORKAREAS ]; +static HB_FOFFSET lastbyte[ TEXT_WORKAREAS ]; +static HB_BOOL isBof[ TEXT_WORKAREAS ]; +static HB_BOOL isEof[ TEXT_WORKAREAS ]; +static HB_ERRCODE error[ TEXT_WORKAREAS ]; /* for debugging purposes */ -static int doInt = 0; +static int doInt = 0; HB_FUNC_EXTERN( FT_GOBOT ); @@ -216,47 +216,43 @@ HB_FUNC( FTSETINT ) HB_FUNC( FT_FOFFSET ) { - hb_retnint( offset[area] ); + hb_retnint( offset[ area ] ); } -/* standard macros */ -#define __max(a,b) (((a) > (b)) ? (a) : (b)) -#define __min(a,b) (((a) < (b)) ? (a) : (b)) - -#define FT_CHR_CR 13 -#define FT_CHR_LF 10 -#define FT_CHR_EOF 26 +#define FT_CHR_CR 13 +#define FT_CHR_LF 10 +#define FT_CHR_EOF 26 HB_FUNC( FT_FUSE ) { int attr = hb_parnidef( 2, FO_READWRITE | FO_DENYNONE ); - error[area] = 0; + error[ area ] = 0; - if ( HB_ISCHAR(1) ) + if( HB_ISCHAR( 1 ) ) { - handles[area] = hb_fsOpen( hb_parc( 1 ), ( HB_USHORT ) attr ) ; - if( handles[area] <= 0 ) - error[area] = hb_fsError(); - offset[area] = 0 ; - recno[area] = 1; - lastbyte[area] = hb_fsSeekLarge( handles[area], 0, FS_END ); - hb_retnint( handles[area] ); + handles[ area ] = hb_fsOpen( hb_parc( 1 ), ( HB_USHORT ) attr ); + if( handles[ area ] <= 0 ) + error[ area ] = hb_fsError(); + offset[ area ] = 0; + recno[ area ] = 1; + lastbyte[ area ] = hb_fsSeekLarge( handles[ area ], 0, FS_END ); + hb_retnint( handles[ area ] ); } else { - if ( handles[area] != 0 ) + if( handles[ area ] != 0 ) { - hb_fsClose( handles[area] ); + hb_fsClose( handles[ area ] ); hb_retnint( 0 ); - recno[area] = 0L; - offset[area] = 0L; - handles[area] = 0; - last_rec[area] = 0L; - last_off[area] = 0L; - lastbyte[area] = 0L; - isBof[area] = HB_FALSE; - isEof[area] = HB_FALSE; + recno[ area ] = 0L; + offset[ area ] = 0L; + handles[ area ] = 0; + last_rec[ area ] = 0L; + last_off[ area ] = 0L; + lastbyte[ area ] = 0L; + isBof[ area ] = HB_FALSE; + isEof[ area ] = HB_FALSE; } } } @@ -266,16 +262,16 @@ HB_FUNC( FT_FSELECT ) int oldarea = area + 1; int newArea; - if ( HB_ISNUM(1) ) + if( HB_ISNUM( 1 ) ) { - newArea = hb_parni(1); + newArea = hb_parni( 1 ); if( newArea <= TEXT_WORKAREAS ) { - if ( newArea == 0 ) + if( newArea == 0 ) { - for ( ; newArea < TEXT_WORKAREAS - 1; newArea++ ) + for(; newArea < TEXT_WORKAREAS - 1; newArea++ ) { - if ( handles[ newArea] == 0 ) + if( handles[ newArea ] == 0 ) { area = newArea; break; @@ -291,51 +287,51 @@ HB_FUNC( FT_FSELECT ) HB_FUNC( FT_FGOTOP ) { - error[area] = 0; - offset[area] = 0L; - recno[area] = 1L; - isBof[area] = HB_FALSE; - isEof[area] = HB_FALSE; + error[ area ] = 0; + offset[ area ] = 0L; + recno[ area ] = 1L; + isBof[ area ] = HB_FALSE; + isEof[ area ] = HB_FALSE; } HB_FUNC( FT_FERROR ) { - hb_retni( error[area] ); + hb_retni( error[ area ] ); } HB_FUNC( FT_FRECNO ) { - hb_retnl( recno[area] ); + hb_retnl( recno[ area ] ); } HB_FUNC( FT_FGOBOT ) { - error[area] = 0; - if( !last_rec[area] ) + error[ area ] = 0; + if( ! last_rec[ area ] ) { /* if the last record has not already been found */ _ft_skip( 0 ); } - recno[ area] = last_rec[area]; - offset[area] = last_off[area]; - isBof[area] = HB_FALSE; - isEof[area] = HB_FALSE; + recno[ area ] = last_rec[ area ]; + offset[ area ] = last_off[ area ]; + isBof[ area ] = HB_FALSE; + isEof[ area ] = HB_FALSE; } HB_FUNC( FT_FSKIP ) { - if ( HB_ISNUM(1) ) + if( HB_ISNUM( 1 ) ) { - if( hb_parnl(1) ) - hb_retnl( _ft_skip( hb_parnl(1) ) ); - else - hb_retnl( 0L ); + if( hb_parnl( 1 ) ) + hb_retnl( _ft_skip( hb_parnl( 1 ) ) ); + else + hb_retnl( 0L ); } else - hb_retnl( _ft_skip(1L) ); + hb_retnl( _ft_skip( 1L ) ); } /* internal routine to do buffer skips. Passing a positive value performs @@ -345,50 +341,52 @@ HB_FUNC( FT_FSKIP ) static long _ft_skip( long iRecs ) { - HB_ISIZ iByteCount; - HB_ISIZ iBytesRead, iBytesRemaining; - char * cPtr; - long iSkipped = 0; + HB_ISIZ iByteCount; + HB_ISIZ iBytesRead, iBytesRemaining; + char * cPtr; + long iSkipped = 0; - char * cBuff = ( char * ) hb_xgrab( BUFFSIZE ); - HB_FOFFSET fpOffset = offset[area]; + char * cBuff = ( char * ) hb_xgrab( BUFFSIZE ); + HB_FOFFSET fpOffset = offset[ area ]; - isBof[area] = HB_FALSE; - isEof[area] = HB_FALSE; - error[area] = 0; + isBof[ area ] = HB_FALSE; + isEof[ area ] = HB_FALSE; + error[ area ] = 0; /* iRecs is zero if they want to find the EOF, start a top of file */ - if( iRecs == 0 ) + if( iRecs == 0 ) { - fpOffset = 0L; - recno[area] = 1; + fpOffset = 0L; + recno[ area ] = 1; } - if ( iRecs >= 0 ) + if( iRecs >= 0 ) { - do { - cPtr = cBuff; + do + { + cPtr = cBuff; /* position file pointer to beginning of current record */ - hb_fsSeekLarge( handles[area], fpOffset, FS_SET ); + hb_fsSeekLarge( handles[ area ], fpOffset, FS_SET ); /* read a chunk */ - iBytesRead = hb_fsRead( handles[area], cBuff, BUFFSIZE ); + iBytesRead = hb_fsRead( handles[ area ], cBuff, BUFFSIZE ); - if( !iBytesRead ) + if( ! iBytesRead ) { /* buffer is empty thus EOF, set vars and quit */ - isEof[area] = HB_TRUE; - last_rec[area] = recno[ area]; - last_off[area] = offset[area]; - error[area] = hb_fsError(); + isEof[ area ] = HB_TRUE; + last_rec[ area ] = recno[ area ]; + last_off[ area ] = offset[ area ]; + error[ area ] = hb_fsError(); break; } iBytesRemaining = iBytesRead; /* parse the buffer while there's still stuff in it */ - do { + do + { /* get count of chars in this line */ iByteCount = _findeol( cPtr, iBytesRemaining ); @@ -397,11 +395,11 @@ static long _ft_skip( long iRecs ) { /* found a CRLF, iByteCount points to first char of next record */ - iBytesRemaining -= iByteCount; - fpOffset += iByteCount; - cPtr += iByteCount; - offset[area] = fpOffset; - recno[area]++; + iBytesRemaining -= iByteCount; + fpOffset += iByteCount; + cPtr += iByteCount; + offset[ area ] = fpOffset; + recno[ area ]++; iSkipped++; if( iRecs && ( iSkipped == iRecs ) ) iBytesRemaining = iBytesRead = 0; @@ -410,69 +408,72 @@ static long _ft_skip( long iRecs ) { /* no more CRLFs in this buffer, or CRLF is last - chars in the buffer */ + chars in the buffer */ /* check for EOF */ if( iBytesRead != BUFFSIZE ) { /* buffer was not full, thus EOF, set vars and quit */ - iBytesRemaining = 0; - last_rec[area] = recno[area]; - last_off[area] = offset[area]; + iBytesRemaining = 0; + last_rec[ area ] = recno[ area ]; + last_off[ area ] = offset[ area ]; if( iRecs ) - isEof[area] = HB_TRUE; + isEof[ area ] = HB_TRUE; } else { /* buffer was full, so probably not EOF, but maybe CRLF straddled end of buffer, so back up pointer a bit before doing the next read */ - fpOffset = hb_fsSeekLarge( handles[area], 0, FS_RELATIVE ) - 1; - iBytesRemaining = 0; + fpOffset = hb_fsSeekLarge( handles[ area ], 0, FS_RELATIVE ) - 1; + iBytesRemaining = 0; } } - } while( iBytesRemaining > 0 ); - } while( iBytesRead == BUFFSIZE ); + } + while( iBytesRemaining > 0 ); + } + while( iBytesRead == BUFFSIZE ); } else { /* skip backwards */ iRecs = -iRecs; - if( recno[area] > iRecs ) + if( recno[ area ] > iRecs ) { do { /* calc offset to read area of file ahead of current pointer */ - fpOffset = __max( offset[area] - BUFFSIZE, 0L ); + fpOffset = HB_MAX( offset[ area ] - BUFFSIZE, 0L ); /* move file pointer */ - hb_fsSeekLarge( handles[area], fpOffset, FS_SET ); + hb_fsSeekLarge( handles[ area ], fpOffset, FS_SET ); /* read a chunk */ iBytesRead = - hb_fsRead( handles[area], cBuff, BUFFSIZE ); + hb_fsRead( handles[ area ], cBuff, BUFFSIZE ); - if( !iBytesRead ) + if( ! iBytesRead ) { /* buffer is empty thus file is zero len, set vars and quit */ - isBof[area] = HB_TRUE; - isEof[area] = HB_TRUE; - recno[area] = 0; - offset[area] = 0; - last_rec[area] = 0; - error[area] = hb_fsError(); + isBof[ area ] = HB_TRUE; + isEof[ area ] = HB_TRUE; + recno[ area ] = 0; + offset[ area ] = 0; + last_rec[ area ] = 0; + error[ area ] = hb_fsError(); break; } /* set pointer within buffer */ - iBytesRemaining = (int) ( offset[area] - fpOffset ); + iBytesRemaining = ( int ) ( offset[ area ] - fpOffset ); - cPtr = cBuff + iBytesRemaining; + cPtr = cBuff + iBytesRemaining; /* parse the buffer while there's still stuff in it */ - do { + do + { /* get count of chars in this line */ iByteCount = _findbol( cPtr, iBytesRemaining ); @@ -481,11 +482,11 @@ static long _ft_skip( long iRecs ) { /* found a CRLF, iByteCount points to first char of next record */ - iBytesRemaining -= iByteCount; - offset[area] -= iByteCount; - cPtr -= iByteCount; - fpOffset = offset[area]; - recno[area]--; + iBytesRemaining -= iByteCount; + offset[ area ] -= iByteCount; + cPtr -= iByteCount; + fpOffset = offset[ area ]; + recno[ area ]--; iSkipped++; if( iSkipped == iRecs ) iBytesRemaining = iBytesRead = 0; @@ -499,26 +500,28 @@ static long _ft_skip( long iRecs ) if( iBytesRead != BUFFSIZE ) { /* buffer was not full, thus BOF, set vars and quit */ - iBytesRemaining = 0; - offset[area] = 0; - recno[area] = 1; - isBof[area] = HB_TRUE; + iBytesRemaining = 0; + offset[ area ] = 0; + recno[ area ] = 1; + isBof[ area ] = HB_TRUE; } else { /* buffer was full, so not BOF */ - iBytesRemaining = 0; + iBytesRemaining = 0; } } - } while ( ( iBytesRemaining > 0 ) ); - } while( ( fpOffset > 0 ) && ( iBytesRead == BUFFSIZE ) ); + } + while( ( iBytesRemaining > 0 ) ); + } + while( ( fpOffset > 0 ) && ( iBytesRead == BUFFSIZE ) ); } else { - offset[area] = 0; - recno[area] = 1; - isBof[area] = HB_TRUE; + offset[ area ] = 0; + recno[ area ] = 1; + isBof[ area ] = HB_TRUE; } } @@ -529,22 +532,22 @@ static long _ft_skip( long iRecs ) HB_FUNC( FT_FREADLN ) { - HB_ISIZ iByteCount; - HB_ISIZ iBytesRead; - char * cPtr = ( char * ) hb_xgrab( BUFFSIZE ); + HB_ISIZ iByteCount; + HB_ISIZ iBytesRead; + char * cPtr = ( char * ) hb_xgrab( BUFFSIZE ); - hb_fsSeekLarge( handles[area], offset[area], FS_SET ); - iBytesRead = hb_fsReadLarge( handles[area], cPtr, BUFFSIZE ); + hb_fsSeekLarge( handles[ area ], offset[ area ], FS_SET ); + iBytesRead = hb_fsReadLarge( handles[ area ], cPtr, BUFFSIZE ); - error[area] = 0; + error[ area ] = 0; - if( !iBytesRead ) - error[area] = hb_fsError(); + if( ! iBytesRead ) + error[ area ] = hb_fsError(); iByteCount = _findeol( cPtr, iBytesRead ); if( iByteCount ) - hb_retclen( cPtr, iByteCount-2 ); + hb_retclen( cPtr, iByteCount - 2 ); else hb_retclen( cPtr, iBytesRead ); @@ -553,72 +556,73 @@ HB_FUNC( FT_FREADLN ) HB_FUNC( FT_FDELETE ) { - int iBytesRead; - HB_FOFFSET srcPtr; - HB_FOFFSET destPtr; - long cur_rec = recno[area]; - HB_FOFFSET cur_off = offset[area]; - char * Buff = ( char * ) hb_xgrab( BUFFSIZE ); + int iBytesRead; + HB_FOFFSET srcPtr; + HB_FOFFSET destPtr; + long cur_rec = recno[ area ]; + HB_FOFFSET cur_off = offset[ area ]; + char * Buff = ( char * ) hb_xgrab( BUFFSIZE ); /* save address to current record ( first record to be deleted ) */ - destPtr = offset[area]; + destPtr = offset[ area ]; /* skip over deleted records, point to first 'to be retained' record */ _ft_skip( hb_parnldef( 1, 1 ) ); - srcPtr = hb_fsSeekLarge( handles[area], offset[area], FS_SET ); + srcPtr = hb_fsSeekLarge( handles[ area ], offset[ area ], FS_SET ); /* buffer read retained data, write atop old data */ do { - hb_fsSeekLarge( handles[area], srcPtr, FS_SET ); - iBytesRead = hb_fsRead( handles[area], Buff , BUFFSIZE ); /* now read in a big glob */ - srcPtr += iBytesRead; - hb_fsSeekLarge( handles[area], destPtr, FS_SET ); - destPtr += hb_fsWriteLarge( handles[area], Buff, iBytesRead ); - } while( iBytesRead > 0 ); + hb_fsSeekLarge( handles[ area ], srcPtr, FS_SET ); + iBytesRead = hb_fsRead( handles[ area ], Buff, BUFFSIZE ); /* now read in a big glob */ + srcPtr += iBytesRead; + hb_fsSeekLarge( handles[ area ], destPtr, FS_SET ); + destPtr += hb_fsWriteLarge( handles[ area ], Buff, iBytesRead ); + } + while( iBytesRead > 0 ); /* move DOS EOF marker */ - hb_fsSeekLarge( handles[area], srcPtr, FS_SET ); - hb_fsWrite( handles[area], Buff, 0 ); + hb_fsSeekLarge( handles[ area ], srcPtr, FS_SET ); + hb_fsWrite( handles[ area ], Buff, 0 ); - error[area] = hb_fsError(); + error[ area ] = hb_fsError(); /* restore pointers */ - recno[area] = cur_rec; - offset[area]= cur_off; + recno[ area ] = cur_rec; + offset[ area ] = cur_off; /* re_calc EOF */ - lastbyte[area] = hb_fsSeekLarge( handles[area], 0L, FS_END ); + lastbyte[ area ] = hb_fsSeekLarge( handles[ area ], 0L, FS_END ); _ft_skip( 0 ); /* restore pointers again */ - recno[area] = cur_rec; - offset[area]= cur_off; + recno[ area ] = cur_rec; + offset[ area ] = cur_off; /* if we've deleted to EOF, leave EOF flag set, otherwise clear it */ - if( recno[area] != last_rec[area] ) - isEof[area] = HB_FALSE; + if( recno[ area ] != last_rec[ area ] ) + isEof[ area ] = HB_FALSE; hb_xfree( Buff ); - hb_retl( error[area] ? 0 : 1 ); + hb_retl( error[ area ] ? 0 : 1 ); } HB_FUNC( FT_FINSERT ) { - int no_lines = hb_parnidef( 1, 1 ); - HB_ISIZ no_bytes = no_lines * 2 ; - int err = 1; + int no_lines = hb_parnidef( 1, 1 ); + HB_ISIZ no_bytes = no_lines * 2; + int err = 1; if( _ins_buff( no_bytes ) ) err = 0; else { while( no_lines-- ) - if( !_writeeol( handles[area] ) ) + if( ! _writeeol( handles[ area ] ) ) { - error[area] = hb_fsError(); - err = 0; + error[ area ] = hb_fsError(); + err = 0; break; } } @@ -628,13 +632,13 @@ HB_FUNC( FT_FINSERT ) HB_FUNC( FT_FAPPEND ) { - int no_lines = hb_parnidef( 1, 1 ); - HB_ISIZ iRead; - HB_ISIZ iByteCount; + int no_lines = hb_parnidef( 1, 1 ); + HB_ISIZ iRead; + HB_ISIZ iByteCount; - char * buff = ( char * ) hb_xgrab( BUFFSIZE ); + char * buff = ( char * ) hb_xgrab( BUFFSIZE ); - error[area] = 0; + error[ area ] = 0; /* go to end of file */ @@ -642,72 +646,72 @@ HB_FUNC( FT_FAPPEND ) /* find end of record */ - hb_fsSeekLarge( handles[area], offset[area], FS_SET ); - iRead = hb_fsRead( handles[area], buff, BUFFSIZE ); /* now read in a big glob */ + hb_fsSeekLarge( handles[ area ], offset[ area ], FS_SET ); + iRead = hb_fsRead( handles[ area ], buff, BUFFSIZE ); /* now read in a big glob */ /* determine if CRLF pair exists, if not, add one */ /* get count of chars in this line */ iByteCount = _findeol( buff, iRead ); if( iByteCount == 0 ) - hb_fsSeekLarge( handles[area], 0, FS_END ); + hb_fsSeekLarge( handles[ area ], 0, FS_END ); else { - offset[area] = hb_fsSeekLarge( handles[area], offset[area] + iByteCount, FS_SET ); - recno[area]++; + offset[ area ] = hb_fsSeekLarge( handles[ area ], offset[ area ] + iByteCount, FS_SET ); + recno[ area ]++; no_lines--; } while( no_lines-- ) { - if( !_writeeol( handles[area] ) ) + if( ! _writeeol( handles[ area ] ) ) { - error[area] = hb_fsError(); + error[ area ] = hb_fsError(); break; } - recno[area]++; - offset[area] = hb_fsSeekLarge( handles[area], 0, FS_RELATIVE ); + recno[ area ]++; + offset[ area ] = hb_fsSeekLarge( handles[ area ], 0, FS_RELATIVE ); /* no_lines--; !Harbour FIX! */ } - if( !error[area] ) + if( ! error[ area ] ) { /* move DOS eof marker */ - hb_fsWrite( handles[area], buff, 0 ); - error[area] = hb_fsError(); + hb_fsWrite( handles[ area ], buff, 0 ); + error[ area ] = hb_fsError(); } /* force recalc of last record/offset */ - last_rec[area] = 0; + last_rec[ area ] = 0; hb_xfree( buff ); - hb_retl( error[area] ? 0 : 1 ); + hb_retl( error[ area ] ? 0 : 1 ); } HB_FUNC( FT_FWRITELN ) { - const char * theData = hb_parc( 1 ); - HB_ISIZ iDataLen = hb_parclen( 1 ); - HB_BOOL bInsert = hb_parl( 2 ); - int err; - HB_ISIZ iLineLen = 0; - HB_ISIZ iRead, iEOL; + const char * theData = hb_parc( 1 ); + HB_ISIZ iDataLen = hb_parclen( 1 ); + HB_BOOL bInsert = hb_parl( 2 ); + int err; + HB_ISIZ iLineLen = 0; + HB_ISIZ iRead, iEOL; - char * buffer; + char * buffer; /* position file pointer to insertion point */ - hb_fsSeekLarge( handles[area], offset[area], FS_SET ); + hb_fsSeekLarge( handles[ area ], offset[ area ], FS_SET ); if( bInsert ) { /* insert mode, insert the length of new string + crlf */ err = _ins_buff( iDataLen + 2 ); - if( !err ) + if( ! err ) { - hb_fsSeekLarge( handles[area], offset[area], FS_SET ); + hb_fsSeekLarge( handles[ area ], offset[ area ], FS_SET ); err = _writeLine( theData, iDataLen ); } } @@ -719,7 +723,7 @@ HB_FUNC( FT_FWRITELN ) /* find length of current line, loop if longer than buffer */ do { - iRead = hb_fsRead( handles[area], buffer, BUFFSIZE ); + iRead = hb_fsRead( handles[ area ], buffer, BUFFSIZE ); iEOL = _findeol( buffer, iRead ); if( iEOL == 0 ) { @@ -730,28 +734,29 @@ HB_FUNC( FT_FWRITELN ) iLineLen += iEOL; break; } - } while( iRead == BUFFSIZE ); + } + while( iRead == BUFFSIZE ); hb_xfree( buffer ); - if( (iDataLen+2) <= iLineLen ) + if( ( iDataLen + 2 ) <= iLineLen ) { /* delete excess bytes from current record */ _del_buff( iLineLen - iDataLen - 2 ); /* write the new record's contents */ - hb_fsWriteLarge( handles[area], theData, iDataLen ); - } + hb_fsWriteLarge( handles[ area ], theData, iDataLen ); + } else { /* insert extra bytes into current record */ _ins_buff( iDataLen - iLineLen + 2 ); /* write the new record's contents */ - hb_fsWriteLarge( handles[area], theData, iDataLen ); + hb_fsWriteLarge( handles[ area ], theData, iDataLen ); } - error[area] = hb_fsError(); - err = (error[area]) ? 0 : 1; + error[ area ] = hb_fsError(); + err = ( error[ area ] ) ? 0 : 1; } hb_retl( err ); } @@ -763,56 +768,56 @@ HB_FUNC( FT_FWRITEL ) HB_FUNC( FT_FLASTRE ) { - long cur_rec; - HB_FOFFSET cur_offset; + long cur_rec; + HB_FOFFSET cur_offset; - cur_rec = recno[area]; - cur_offset = offset[area]; + cur_rec = recno[ area ]; + cur_offset = offset[ area ]; HB_FUNC_EXEC( FT_FGOBOT ); - hb_retnl( last_rec[area] ); + hb_retnl( last_rec[ area ] ); - recno[area] = cur_rec; - offset[area] = cur_offset; + recno[ area ] = cur_rec; + offset[ area ] = cur_offset; } HB_FUNC( FT_FEOF ) { - hb_retl( isEof[area] ); + hb_retl( isEof[ area ] ); } HB_FUNC( FT_FBOF ) { - hb_retl( isBof[area] ); + hb_retl( isBof[ area ] ); } HB_FUNC( FT_FGOTO ) { - long target = hb_parnl(1); + long target = hb_parnl( 1 ); /* if a recno was passed, do a relative skip */ if( target ) { /* skip relative */ - target -= recno[area]; + target -= recno[ area ]; if( target ) - _ft_skip( target ); + _ft_skip( target ); } else { /* goto 0 passed, go top then skip back */ - target = recno[area]; + target = recno[ area ]; - offset[area] = 0L; - recno[area] = 1L; - isBof[area] = HB_FALSE; - isEof[area] = HB_FALSE; + offset[ area ] = 0L; + recno[ area ] = 1L; + isBof[ area ] = HB_FALSE; + isEof[ area ] = HB_FALSE; if( --target ) _ft_skip( target ); } - error[area] = hb_fsError(); + error[ area ] = hb_fsError(); } /*---------------------------------------------------------------------- @@ -828,7 +833,7 @@ HB_FUNC( FT_FGOTO ) If no CRLF found return is zero. (could mean EOF or line is longer than buffer end) -------------------------------------------------------------------------*/ + ------------------------------------------------------------------------*/ static HB_ISIZ _findeol( char * buf, HB_ISIZ buf_len ) { HB_ISIZ tmp; @@ -854,7 +859,7 @@ static HB_ISIZ _findeol( char * buf, HB_ISIZ buf_len ) mov bx, di ; save buffer start for offset calc later mov cx, buf_len ; scan entire buffer mov al, 13 -_feol1:repne scasb ; look for a CR + _feol1:repne scasb ; look for a CR jcxz _feolerr ; no find, return entire buffer cmp es:[di], 10 ; got a CRLF pair? @@ -865,14 +870,14 @@ _feol1:repne scasb ; look for a CR sub ax, bx ; learn offset within buffer jmp _feoldone -_feolerr: + _feolerr: mov ax, 0 -_feoldone: + _feoldone: popf pop es pop di } -*/ + */ } /* end _findeol() */ /*---------------------------------------------------------------------- @@ -886,15 +891,15 @@ _feoldone: initial position and first character _after_ the preceding CRLF pair (beginning of line). -------------------------------------------------------------------------*/ + ------------------------------------------------------------------------*/ static HB_ISIZ _findbol( char * buf, HB_ISIZ buf_len ) { HB_ISIZ tmp = buf_len - 1; if( tmp != 0 ) { - char * p = buf - 1; - char b = *p; + char * p = buf - 1; + char b = *p; if( b == FT_CHR_EOF ) { @@ -923,7 +928,7 @@ static HB_ISIZ _findbol( char * buf, HB_ISIZ buf_len ) } } - for( ; tmp > 0; tmp--, p-- ) + for(; tmp > 0; tmp--, p-- ) { if( *p == FT_CHR_LF && *( p - 1 ) == FT_CHR_CR ) return buf_len - ( tmp + 2 ) + 1; @@ -953,7 +958,7 @@ static HB_ISIZ _findbol( char * buf, HB_ISIZ buf_len ) dec cx jnz _fbst jmp _fbolerr -_fbst: + _fbst: cmp al, 0Ah ; check if pointer is sitting on a CRLF pair jne _fbol1 ; if not a LF go ahead and scan entire buffer dec di ; got LF, look at next character for CR @@ -965,7 +970,7 @@ _fbst: dec di ; skip over the CR dec cx jcxz _fbolerr -_fbol1: + _fbol1: mov al, 0Ah ; look for a LF repne scasb jcxz _fbolerr ; if no find return entire buffer @@ -973,10 +978,10 @@ _fbol1: jne _fbol1 ; no keep trying add di, 2 ; adjust pointer to beginning of string return bx - di ; subtract current pointer pos from start to learn offset within buffer -_fbolerr: + _fbolerr: return buf_len ; on no find return length of buffer } -*/ + */ } /* end _findbol() */ /*--------------------------------------------------------------------------*/ @@ -986,91 +991,91 @@ _fbolerr: static int _ins_buff( HB_ISIZ iLen ) { - char * ReadBuff = ( char * ) hb_xgrab( BUFFSIZE ); - char * WriteBuff = ( char * ) hb_xgrab( BUFFSIZE ); - char * SaveBuff; - HB_FOFFSET fpRead, fpWrite; - HB_ISIZ WriteLen, ReadLen; - HB_ISIZ SaveLen; - HB_ISIZ iLenRemaining = iLen; + char * ReadBuff = ( char * ) hb_xgrab( BUFFSIZE ); + char * WriteBuff = ( char * ) hb_xgrab( BUFFSIZE ); + char * SaveBuff; + HB_FOFFSET fpRead, fpWrite; + HB_ISIZ WriteLen, ReadLen; + HB_ISIZ SaveLen; + HB_ISIZ iLenRemaining = iLen; /* set target move distance, this allows iLen to be greater than BUFFSIZE */ - iLen = __min( iLenRemaining, BUFFSIZE ); - iLenRemaining -= iLen; + iLen = HB_MIN( iLenRemaining, BUFFSIZE ); + iLenRemaining -= iLen; /* initialize file pointers */ - fpRead = offset[area]; - fpWrite= offset[area] + iLen; + fpRead = offset[ area ]; + fpWrite = offset[ area ] + iLen; /* do initial load of both buffers */ - hb_fsSeekLarge( handles[area], fpRead, FS_SET ); - WriteLen = hb_fsRead( handles[area], WriteBuff, BUFFSIZE ); - fpRead += WriteLen; + hb_fsSeekLarge( handles[ area ], fpRead, FS_SET ); + WriteLen = hb_fsRead( handles[ area ], WriteBuff, BUFFSIZE ); + fpRead += WriteLen; - ReadLen = hb_fsRead( handles[area], ReadBuff, BUFFSIZE ); - fpRead += ReadLen; + ReadLen = hb_fsRead( handles[ area ], ReadBuff, BUFFSIZE ); + fpRead += ReadLen; - error[area] = 0; + error[ area ] = 0; - while( !error[area] && iLen > 0 ) + while( ! error[ area ] && iLen > 0 ) { while( WriteLen > 0 ) { /* position to beginning of write area */ - if( hb_fsSeekLarge( handles[area], fpWrite, FS_SET ) != fpWrite ) + if( hb_fsSeekLarge( handles[ area ], fpWrite, FS_SET ) != fpWrite ) { - error[area] = hb_fsError(); + error[ area ] = hb_fsError(); break; } - SaveLen = hb_fsWriteLarge( handles[area], WriteBuff, WriteLen ); + SaveLen = hb_fsWriteLarge( handles[ area ], WriteBuff, WriteLen ); - if( !SaveLen ) + if( ! SaveLen ) { - error[area] = hb_fsError(); + error[ area ] = hb_fsError(); break; } /* move write pointer */ fpWrite += SaveLen; - if( SaveLen != WriteLen ) + if( SaveLen != WriteLen ) { /* error, fetch errcode and quit */ - error[area] = hb_fsError(); + error[ area ] = hb_fsError(); break; } /* WriteLen = SaveLen; */ /* swap buffers */ - SaveBuff = WriteBuff; - WriteBuff = ReadBuff ; - ReadBuff = SaveBuff ; - WriteLen = ReadLen ; + SaveBuff = WriteBuff; + WriteBuff = ReadBuff; + ReadBuff = SaveBuff; + WriteLen = ReadLen; /* return to read area and read another buffer */ - hb_fsSeekLarge( handles[area], fpRead, FS_SET ); - ReadLen = hb_fsRead( handles[area], ReadBuff, BUFFSIZE ); - fpRead += ReadLen; + hb_fsSeekLarge( handles[ area ], fpRead, FS_SET ); + ReadLen = hb_fsRead( handles[ area ], ReadBuff, BUFFSIZE ); + fpRead += ReadLen; } - iLen = __min( iLenRemaining, BUFFSIZE ); - iLenRemaining -= iLen; + iLen = HB_MIN( iLenRemaining, BUFFSIZE ); + iLenRemaining -= iLen; } /* store length in bytes, set EOF marker for DOS */ - lastbyte[area] = hb_fsSeekLarge( handles[area], fpWrite, FS_SET ); - hb_fsWrite( handles[area], WriteBuff, 0 ); + lastbyte[ area ] = hb_fsSeekLarge( handles[ area ], fpWrite, FS_SET ); + hb_fsWrite( handles[ area ], WriteBuff, 0 ); /* clear last_rec so next gobot will recount the records */ - last_rec[area] = 0L; - hb_fsSeekLarge( handles[area], offset[area], FS_SET ); + last_rec[ area ] = 0L; + hb_fsSeekLarge( handles[ area ], offset[ area ], FS_SET ); hb_xfree( ReadBuff ); hb_xfree( WriteBuff ); - return error[area]; + return error[ area ]; } /* _ins_buff */ @@ -1078,55 +1083,55 @@ static int _ins_buff( HB_ISIZ iLen ) /* deletes xxx bytes from the current file, beginning at the current record */ static int _del_buff( HB_ISIZ iLen ) { - char * WriteBuff = ( char * ) hb_xgrab( BUFFSIZE ); - HB_FOFFSET fpRead, fpWrite; - HB_ISIZ WriteLen; - HB_ISIZ SaveLen; + char * WriteBuff = ( char * ) hb_xgrab( BUFFSIZE ); + HB_FOFFSET fpRead, fpWrite; + HB_ISIZ WriteLen; + HB_ISIZ SaveLen; /* initialize file pointers */ - fpWrite = offset[area]; - fpRead = offset[area] + iLen; + fpWrite = offset[ area ]; + fpRead = offset[ area ] + iLen; /* do initial load of buffer */ - hb_fsSeekLarge( handles[area], fpRead, FS_SET ); - WriteLen = hb_fsRead( handles[area], WriteBuff, BUFFSIZE ); - fpRead += WriteLen; + hb_fsSeekLarge( handles[ area ], fpRead, FS_SET ); + WriteLen = hb_fsRead( handles[ area ], WriteBuff, BUFFSIZE ); + fpRead += WriteLen; - error[area] = 0; + error[ area ] = 0; while( WriteLen > 0 ) { /* position to beginning of write area */ - hb_fsSeekLarge( handles[area], fpWrite, FS_SET ); - SaveLen = hb_fsWriteLarge( handles[area], WriteBuff, WriteLen ); + hb_fsSeekLarge( handles[ area ], fpWrite, FS_SET ); + SaveLen = hb_fsWriteLarge( handles[ area ], WriteBuff, WriteLen ); /* move write pointer */ - fpWrite += SaveLen; + fpWrite += SaveLen; - if( SaveLen != WriteLen ) + if( SaveLen != WriteLen ) { /* error, fetch errcode and quit */ - error[area] = hb_fsError(); + error[ area ] = hb_fsError(); break; } /* return to read area and read another buffer */ - hb_fsSeekLarge( handles[area], fpRead, FS_SET ); - WriteLen = hb_fsRead( handles[area], WriteBuff, BUFFSIZE ); - fpRead += WriteLen; + hb_fsSeekLarge( handles[ area ], fpRead, FS_SET ); + WriteLen = hb_fsRead( handles[ area ], WriteBuff, BUFFSIZE ); + fpRead += WriteLen; } /* store length in bytes, set EOF marker for DOS */ - lastbyte[area] = hb_fsSeekLarge( handles[area], fpWrite, FS_SET ); - hb_fsWrite( handles[area], WriteBuff, 0 ); + lastbyte[ area ] = hb_fsSeekLarge( handles[ area ], fpWrite, FS_SET ); + hb_fsWrite( handles[ area ], WriteBuff, 0 ); /* clear last_rec so next gobot will recount the records */ - last_rec[area] = 0L; - hb_fsSeekLarge( handles[area], offset[area], FS_SET ); + last_rec[ area ] = 0L; + hb_fsSeekLarge( handles[ area ], offset[ area ], FS_SET ); hb_xfree( WriteBuff ); - return error[area]; + return error[ area ]; } /* _del_buff */ @@ -1134,26 +1139,26 @@ static int _del_buff( HB_ISIZ iLen ) /* writes a line of data to the file, including the terminating CRLF */ static int _writeLine( const char * theData, HB_SIZE iDataLen ) { - int err = 0; + int err = 0; - if( !( hb_fsWriteLarge( handles[area], theData, iDataLen ) == iDataLen ) ) + if( ! ( hb_fsWriteLarge( handles[ area ], theData, iDataLen ) == iDataLen ) ) { - err = 1; - error[area] = hb_fsError(); + err = 1; + error[ area ] = hb_fsError(); } else - if( !_writeeol( handles[area] ) ) - { - err = 1; - error[area] = hb_fsError(); - } + if( ! _writeeol( handles[ area ] ) ) + { + err = 1; + error[ area ] = hb_fsError(); + } return err; } static HB_BOOL _writeeol( HB_FHANDLE fhnd ) { - const char * crlf = hb_conNewLine(); - HB_SIZE len = strlen( crlf ); + const char * crlf = hb_conNewLine(); + HB_SIZE len = strlen( crlf ); return hb_fsWriteLarge( fhnd, crlf, len ) == len; } diff --git a/harbour/contrib/hbnf/peek.c b/harbour/contrib/hbnf/peek.c index fd70e132cb..f13e206160 100644 --- a/harbour/contrib/hbnf/peek.c +++ b/harbour/contrib/hbnf/peek.c @@ -37,25 +37,27 @@ HB_FUNC( FT_PEEK ) { - auto unsigned int ProtMode = cpmiIsProtected(); + auto unsigned int ProtMode = cpmiIsProtected(); auto unsigned char * bytePtr; - if ( ( PCOUNT >= 2 ) && ( HB_ISNUM( 1 ) ) && ( HB_ISNUM( 2 ) ) ) + if( ( PCOUNT >= 2 ) && ( HB_ISNUM( 1 ) ) && ( HB_ISNUM( 2 ) ) ) { FP_SEG( bytePtr ) = hb_parni( 1 ); FP_OFF( bytePtr ) = hb_parni( 2 ); - if ( ProtMode ) + if( ProtMode ) { FP_SEG( bytePtr ) = hb_cpmiProtectedPtr( bytePtr, 1 ); FP_OFF( bytePtr ) = 0; - if ( FP_SEG( bytePtr ) == 0 ) goto Bogus; + if( FP_SEG( bytePtr ) == 0 ) + goto Bogus; } _retni( ( int ) *bytePtr ); - if ( ProtMode ) hb_cpmiFreeSelector( FP_SEG( bytePtr ) ); + if( ProtMode ) + hb_cpmiFreeSelector( FP_SEG( bytePtr ) ); } else Bogus: hb_retni( -1 ); diff --git a/harbour/contrib/hbnf/poke.c b/harbour/contrib/hbnf/poke.c index 2c34867b7c..53aa221cbd 100644 --- a/harbour/contrib/hbnf/poke.c +++ b/harbour/contrib/hbnf/poke.c @@ -37,25 +37,27 @@ HB_FUNC( FT_POKE ) { - auto unsigned int ProtMode = hb_cpmiIsProtected(); + auto unsigned int ProtMode = hb_cpmiIsProtected(); auto unsigned char * bytePtr; - if ( ( PCOUNT >= 3 ) && ( HB_ISNUM( 1 ) ) && ( HB_ISNUM( 2 ) ) && ( HB_ISNUM( 3 ) ) ) + if( ( PCOUNT >= 3 ) && ( HB_ISNUM( 1 ) ) && ( HB_ISNUM( 2 ) ) && ( HB_ISNUM( 3 ) ) ) { FP_SEG( bytePtr ) = hb_parni( 1 ); FP_OFF( bytePtr ) = hb_parni( 2 ); - if ( ProtMode ) + if( ProtMode ) { FP_SEG( bytePtr ) = hb_cpmiProtectedPtr( bytePtr, 1 ); FP_OFF( bytePtr ) = 0; - if ( FP_SEG( bytePtr ) == 0 ) goto Bogus; + if( FP_SEG( bytePtr ) == 0 ) + goto Bogus; } *bytePtr = ( unsigned char ) hb_parni( 3 ); - if ( ProtMode ) hb_cpmiFreeSelector( FP_SEG( bytePtr ) ); + if( ProtMode ) + hb_cpmiFreeSelector( FP_SEG( bytePtr ) ); hb_retl( HB_TRUE ); } diff --git a/harbour/contrib/hbnf/proper.c b/harbour/contrib/hbnf/proper.c index 48c2c7a0a2..e01de7f360 100644 --- a/harbour/contrib/hbnf/proper.c +++ b/harbour/contrib/hbnf/proper.c @@ -61,42 +61,47 @@ static HB_BOOL _ftIsAlpha( char c ) HB_FUNC( FT_PROPER ) { - HB_ISIZ iLen = hb_parclen(1); - const char *cStr; - char *cDst = NULL; - HB_ISIZ i; /*, iPos = 0; */ - HB_BOOL fCap = HB_TRUE; + HB_ISIZ iLen = hb_parclen( 1 ); + const char * cStr; + char * cDst = NULL; + HB_ISIZ i; /*, iPos = 0; */ + HB_BOOL fCap = HB_TRUE; hb_storc( NULL, 1 ); - cStr = hb_parc(1); + cStr = hb_parc( 1 ); - for( i = 0; i < iLen; i++ ) { - if( _ftIsAlpha( cStr[i] ) ) { - if( !cDst ) { - cDst = (char *) hb_xgrab(iLen + 1); - memcpy(cDst, cStr, iLen + 1); + for( i = 0; i < iLen; i++ ) + { + if( _ftIsAlpha( cStr[ i ] ) ) + { + if( ! cDst ) + { + cDst = ( char * ) hb_xgrab( iLen + 1 ); + memcpy( cDst, cStr, iLen + 1 ); } if( fCap ) - cDst[i] = _ftToUpper( cDst[i] ); + cDst[ i ] = _ftToUpper( cDst[ i ] ); else - cDst[i] = _ftToLower( cDst[i] ); - } - fCap = ( cStr[i] == ' ' || cStr[i] == '-' || cStr[i] == 0x27 ); + cDst[ i ] = _ftToLower( cDst[ i ] ); + } + fCap = ( cStr[ i ] == ' ' || cStr[ i ] == '-' || cStr[ i ] == 0x27 ); } /* Find "Mc" */ - if( cDst ) { + if( cDst ) + { for( i = 0; i < iLen - 2; i++ ) - if( cStr[i] == 'M' && cStr[i+1] == 'c' ) { - cDst[i+2] = _ftToUpper( cDst[i+2] ); + if( cStr[ i ] == 'M' && cStr[ i + 1 ] == 'c' ) + { + cDst[ i + 2 ] = _ftToUpper( cDst[ i + 2 ] ); } } /* // If "Mc" was found, Cap next letter if Alpha - if( iPos > 1 ) + if( iPos > 1 ) if( iPos < iLen ) if( ! _ftIsUpper( cStr[iPos] ) ) cStr[iPos] = _ftToUpper( cStr[iPos] ); - */ + */ if( cDst ) hb_retclen_buffer( cDst, iLen ); else diff --git a/harbour/contrib/hbnf/prtscr.c b/harbour/contrib/hbnf/prtscr.c index ea4c3a139f..2114d84c9b 100644 --- a/harbour/contrib/hbnf/prtscr.c +++ b/harbour/contrib/hbnf/prtscr.c @@ -35,15 +35,15 @@ HB_FUNC( FT_PRTSCR ) { #if defined( HB_OS_DOS ) - if ( HB_ISLOG( 1 ) ) + if( HB_ISLOG( 1 ) ) { - if ( hb_parl( 1 ) ) - pbyte = 0; + if( hb_parl( 1 ) ) + pbyte = 0; else - pbyte = 1; + pbyte = 1; } - if ( pbyte == 1) + if( pbyte == 1 ) hb_retl( HB_FALSE ); else hb_retl( HB_TRUE );