From 7b10d473fc73a210263e49ce042f57b5b085e071 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 16 Aug 1999 20:09:36 +0000 Subject: [PATCH] 19990816-21:57 GMT+1 --- harbour/ChangeLog | 13 ++++++++ harbour/include/Makefile | 1 + harbour/include/extend.h | 30 +++++++++---------- harbour/include/hbdefs.h | 16 +++++----- harbour/source/rtl/console.c | 48 ++++++++++++++++++++++++------ harbour/tests/working/colorind.prg | 2 ++ 6 files changed, 78 insertions(+), 32 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1ed8ac4d54..b48d1eff5a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,15 @@ +19990816-21:57 GMT+1 Victor Szel + * source/rtl/console.c + tests/working/colorind.prg + + Added standard header to __ColorIndex() + ! Some Lint warnings fixed. + + Some tests added. + * include/hbdefs.h + include/extend.h + ! Some Lint warnings fixed. + * include/Makefile + + Added hboo.ch + 19990816-22:15 GMT+3 Alexander Kresin * source/rtl/tbrowse.prg * tests/working/testbrw.prg @@ -15,6 +27,7 @@ + browdb + tone +>>>>>>> 1.792 19990816-15:30 GMT+1 Victor Szel * source/rtl/errorapi.c ! Fixed hb_errLaunch() so that it will handle error handler return diff --git a/harbour/include/Makefile b/harbour/include/Makefile index 1e47cddc95..cb13e7e4ec 100644 --- a/harbour/include/Makefile +++ b/harbour/include/Makefile @@ -44,6 +44,7 @@ PRG_HEADERS=\ error.ch \ fileio.ch \ getexit.ch \ + hboo.ch \ inkey.ch \ memoedit.ch \ rddsys.ch \ diff --git a/harbour/include/extend.h b/harbour/include/extend.h index 1e39f6ffd7..68d1a6c5a2 100644 --- a/harbour/include/extend.h +++ b/harbour/include/extend.h @@ -42,24 +42,24 @@ #endif /* items types */ -#define IT_NIL 0x0000 -#define IT_INTEGER 0x0002 -#define IT_LONG 0x0008 -#define IT_DOUBLE 0x0010 -#define IT_DATE 0x0020 -#define IT_LOGICAL 0x0080 -#define IT_SYMBOL 0x0100 -#define IT_ALIAS 0x0200 -#define IT_STRING 0x0400 -#define IT_MEMOFLAG 0x0800 +#define IT_NIL ((WORD) 0x0000) +#define IT_INTEGER ((WORD) 0x0002) +#define IT_LONG ((WORD) 0x0008) +#define IT_DOUBLE ((WORD) 0x0010) +#define IT_DATE ((WORD) 0x0020) +#define IT_LOGICAL ((WORD) 0x0080) +#define IT_SYMBOL ((WORD) 0x0100) +#define IT_ALIAS ((WORD) 0x0200) +#define IT_STRING ((WORD) 0x0400) +#define IT_MEMOFLAG ((WORD) 0x0800) #define IT_MEMO ( IT_MEMOFLAG & IT_STRING ) -#define IT_BLOCK 0x1000 -#define IT_BYREF 0x2000 -#define IT_MEMVAR 0x4000 -#define IT_ARRAY 0x8000 +#define IT_BLOCK ((WORD) 0x1000) +#define IT_BYREF ((WORD) 0x2000) +#define IT_MEMVAR ((WORD) 0x4000) +#define IT_ARRAY ((WORD) 0x8000) #define IT_OBJECT IT_ARRAY #define IT_NUMERIC ( IT_INTEGER | IT_LONG | IT_DOUBLE ) -#define IT_ANY 0xFFFF +#define IT_ANY ((WORD) 0xFFFF) /* forward declarations */ struct _HB_CODEBLOCK; diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index 2539c55983..1773dac96c 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -120,15 +120,15 @@ typedef char SYMBOLSCOPE; /* stores symbol's scope */ #define IS_SYMBOL( p ) IS_OF_TYPE( p, IT_SYMBOL ) #define IS_MEMVAR( p ) IS_OF_TYPE( p, IT_MEMVAR ) -#define PCOUNT hb_parinfo( 0 ) +#define ISCHAR( n ) ( hb_param( n, IT_STRING ) != NULL ) +#define ISNUM( n ) ( hb_param( n, IT_NUMERIC ) != NULL ) +#define ISLOG( n ) ( hb_param( n, IT_LOGICAL ) != NULL ) +#define ISDATE( n ) ( hb_param( n, IT_DATE ) != NULL ) +#define ISMEMO( n ) ( hb_param( n, IT_MEMO ) != NULL ) +#define ISBYREF( n ) ( hb_param( n, IT_BYREF ) != NULL ) +#define ISARRAY( n ) ( hb_param( n, IT_ARRAY ) != NULL ) -#define ISCHAR( n ) hb_param( n, IT_STRING ) -#define ISNUM( n ) hb_param( n, IT_NUMERIC ) -#define ISLOG( n ) hb_param( n, IT_LOGICAL ) -#define ISDATE( n ) hb_param( n, IT_DATE ) -#define ISMEMO( n ) hb_param( n, IT_MEMO ) -#define ISBYREF( n ) hb_param( n, IT_BYREF ) -#define ISARRAY( n ) hb_param( n, IT_ARRAY ) +#define PCOUNT hb_parinfo( 0 ) #define ALENGTH( n ) hb_parinfa( n, 0 ) #endif /* HB_DEFS_H_ */ diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index 1cd6516685..2e81c144c8 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -1123,13 +1123,43 @@ HARBOUR HB___ACCEPT( void ) /* Internal Clipper function used in ACCEPT command } /* ------------------------------------------------- */ -/* Copyright 1999 Victor Szel */ -/* ------------------------------------------------- */ -/* __COLORINDEX(cColorStr, nColorIndex) -> cColor */ -/* */ -/* ? __ColorIndex("W/N, N/W", CLR_ENHANCED) -> "N/W" */ +/* Copyright (C) 1999 Victor Szel */ /* ------------------------------------------------- */ +/* $DOC$ + * $FUNCNAME$ + * __ColorIndex + * $CATEGORY$ + * GT + * $ONELINER$ + * Extract one color from a full Clipper colorspec string. + * $SYNTAX$ + * __ColorIndex( , ) + * $ARGUMENTS$ + * is a Clipper color list + * is the position of the color item to be extracted, the first + * position is the zero. + * $RETURNS$ + * The selected color string, or if anything goes wrong, and empty + * string + * $DESCRIPTION$ + * Clipper has color spec string, which have more than one single + * colors in it, separated with commas. This function is able to extract + * a given item from this list. You may use the manifest constants + * defined in color.ch to extract common Clipper colors. + * $EXAMPLES$ + * ? __ColorIndex( "W/N, N/W", CLR_ENHANCED ) // "N/W" + * $TESTS$ + * see in coloring.prg for a comprehensive regression test suit. + * $STATUS$ + * R + * $COMPLIANCE$ + * Was not part of CA-Clipper. + * $SEEALSO$ + * ColorSelect() + * $END$ + */ + HARBOUR HB___COLORINDEX( void ) { if ( ISCHAR( 1 ) && ISNUM( 2 ) ) @@ -1137,11 +1167,11 @@ HARBOUR HB___COLORINDEX( void ) char * szColor = hb_parc( 1 ); ULONG ulColorPos; ULONG ulColorLen; - USHORT uiColorIndex = hb_parni( 2 ); + USHORT uiColorIndex = (USHORT) hb_parni( 2 ); /* Skip the given number of commas */ - for ( ulColorPos = 0 ; szColor[ ulColorPos ] && uiColorIndex > 0 ; ulColorPos++ ) + for ( ulColorPos = 0 ; szColor[ ulColorPos ] != '\0' && uiColorIndex > 0 ; ulColorPos++ ) { if ( szColor[ ulColorPos ] == ',' ) uiColorIndex--; @@ -1159,12 +1189,12 @@ HARBOUR HB___COLORINDEX( void ) ulColorLen = 0; - while ( szColor[ ulColorPos + ulColorLen ] && + while ( szColor[ ulColorPos + ulColorLen ] != '\0' && szColor[ ulColorPos + ulColorLen ] != ',' ) ulColorLen++; /* Skip the trailing spaces */ - while ( ulColorLen && + while ( ulColorLen > 0 && szColor[ ulColorPos + ulColorLen - 1 ] == ' ' ) ulColorLen--; /* Return the string */ diff --git a/harbour/tests/working/colorind.prg b/harbour/tests/working/colorind.prg index f2587738ee..c802bb88d4 100644 --- a/harbour/tests/working/colorind.prg +++ b/harbour/tests/working/colorind.prg @@ -10,7 +10,9 @@ STATIC snFail := 0 FUNCTION Main() TEST_LINE( __ColorIndex() , "" ) + TEST_LINE( __ColorIndex("", -1) , "" ) TEST_LINE( __ColorIndex("", 0) , "" ) + TEST_LINE( __ColorIndex("W/R", -1) , "" ) TEST_LINE( __ColorIndex("W/R", 0) , "W/R" ) TEST_LINE( __ColorIndex("W/R", 1) , "" ) TEST_LINE( __ColorIndex("W/R", 2) , "" )