2001-05-10 11:30 GMT+0200 (MET DST) Martin Vogel <vogel@inttec.de>

This commit is contained in:
Martin Vogel
2001-05-10 09:39:48 +00:00
parent 5578c6fd04
commit 3a3a9b26dd
8 changed files with 504 additions and 8 deletions

View File

@@ -1,3 +1,17 @@
2001-05-10 11:30 GMT+0200 (MET DST) Martin Vogel <vogel@inttec.de>
* contrib/libct/token1.c
+ added some documentation for the functions in token1.c
* contrib/libct/readme.txt
+ added some information to the "enhancements" paragraph
+ contrib/libct/tests/numtoken.prg
+ contrib/libct/tests/tokenlow.prg
+ contrib/libct/tests/tokenupp.prg
+ contrib/libct/tests/tokensep.prg
! small test programs for new functions
2001-05-10 09:46 UTC+0300 Chen Kedem <niki@actcom.co.il>
* doc/en/objfunc.txt
* update the doc for __objGetMsgList() to reflect

View File

@@ -39,6 +39,9 @@ Changes and Enhancements over the original CA-T**ls 3 Library
* SETATLIKE() 2nd parameter can be passed by reference so that SETATLIKE
can store the acutal wildcard character in it
* TOKEN() New 5th and 6th parameter there the function can store
* TOKEN() New 5th and 6th parameter where the function can store
the tokenizer before and after the extracted token.
* TOKENLOWER() New 4th parameter <nSkipWidth>
* TOKENUPPER() New 4th parameter <nSkipWidth>

View File

@@ -60,9 +60,9 @@ PRG_SOURCES=\
numtoken.prg \
setatlik.prg \
token.prg \
tokenlower.prg \
tokenlow.prg \
tokensep.prg \
tokenupper.prg \
tokenupp.prg \
valpos.prg \

View File

@@ -0,0 +1,88 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Test CT3 function NUMTOKEN()
*
* Copyright 2001 IntTec GmbH, Neunlindenstr 32, 79106 Freiburg, Germany
* Author: Martin Vogel <vogel@inttec.de>
*
* 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)
* 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 "../ct.ch"
procedure main
local cStr := ".,.This.,.is.,.a.,.test!"
qout ("Begin test of NUMTOKEN()")
qout ("")
// Some simple tests
qout (" Simple tests:")
qout ([ numtoken ("Hello, World!") == 2 ? ------------------------------> ] + str (numtoken ("Hello, World!"),2))
qout ([ numtoken ("This is good. See you! How do you do?",".!?") == 3 ? -> ] + str (numtoken ("This is good. See you! How do you do?",".!?"),2))
qout ([ numtoken ("one,,three,four,,six",",",1) == 6 ? -----------------> ] + str (numtoken ("one,,three,four,,six",",",1),2))
qout ("")
qout ([ # of tokens in the string "]+cStr+["])
qout ([ separator list = ".,!" and skip width = 1: ]+str (numtoken (cStr, ".,!", 1)))
qout ([ skip width = 3: ]+str (numtoken (cStr, ".,!", 3)))
qout ([ separator list = ",!" and skip width = 1: ]+str (numtoken (cStr, ",!", 1)))
qout ([ skip width = 3: ]+str (numtoken (cStr, ",!", 3)))
qout ([ separator list = "!" and skip width = 1: ]+str (numtoken (cStr, "!", 1)))
qout ([ skip width = 3: ]+str (numtoken (cStr, "!", 3)))
qout ("")
qout ("End test of NUMTOKEN()")
qout ()
return

View File

@@ -0,0 +1,92 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Test CT3 function TOKENLOWER()
*
* Copyright 2001 IntTec GmbH, Neunlindenstr 32, 79106 Freiburg, Germany
* Author: Martin Vogel <vogel@inttec.de>
*
* 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)
* 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 "../ct.ch"
procedure main
local cStr := ".,.This.,.is.,.a.,.test!"
qout ("Begin test of TOKENLOWER()")
qout ("")
// Some simple tests
qout (" Simple tests:")
qout ([ tokenlower("Hello, World, here I am!") == "hello, world, here i am!" ?])
qout ([ -> "] + tokenlower ("Hello, World, here I am!") + ["])
qout ([ tokenlower("Hello, World, here I am!",,3) == "hello, world, here I am!" ?])
qout ([ -> "] + tokenlower ("Hello, World, here I am!",,3) + ["])
qout ([ tokenlower("Hello, World, here I am!",",",3) == "hello, World, here I am!" ?])
qout ([ -> "] + tokenlower ("Hello, World, here I am!",",",3) + ["])
qout ([ tokenlower("Hello, World, here I am!"," W") == "hello, World, here i am!" ?])
qout ([ -> "] + tokenlower ("Hello, World, here I am!"," W") + ["])
qout ("")
qout ([ Lowercase the tokens in the string "]+cStr+["])
qout ([ with csetref (.T.) and "@"])
csetref (.T.)
qout ("")
qout ([ --> return value of tokenlower (@cStr): ],tokenlower(@cStr))
qout ([ --> cStr is now: "]+cStr+["])
qout ("")
qout ("End test of TOKENLOWER()")
qout ()
return

View File

@@ -0,0 +1,94 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Test CT3 function TOKENSEP()
*
* Copyright 2001 IntTec GmbH, Neunlindenstr 32, 79106 Freiburg, Germany
* Author: Martin Vogel <vogel@inttec.de>
*
* 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)
* 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 "../ct.ch"
procedure main
local cStr := ".,.This.,.is.,.a.,.test!"
local ni, npos
local cPre := " "
local cPost := " "
qout ("Begin test of TOKENSEP()")
qout ("")
// Some simple tests
qout ([ Tokenizing the string "]+cStr+["])
qout ([ with skip width == 1 and ".,!" as tokenizer list:])
qout ("")
for ni := 1 to numtoken (cStr, ".,!", 1)
qout ([ Token #]+alltrim(str(ni))+[ ("]+token(cStr, ".,!", ni, 1)+;
[") is tokenized by "]+tokensep(.F.)+[" and "]+tokensep(.T.)+["])
next ni
qout ("")
qout ([ Tokenizing the string "]+cStr+["])
qout ([ with skip width == 3 and ".,!" as tokenizer list:])
qout ("")
for ni := 1 to numtoken (cStr, ".,!", 3)
qout ([ Token #]+alltrim(str(ni))+[ ("]+token(cStr, ".,!", ni, 3)+;
[") is tokenized by "]+tokensep(.F.)+[" and "]+tokensep(.T.)+["])
next ni
qout ("")
qout ("End test of TOKENSEP()")
qout ()
return

View File

@@ -0,0 +1,92 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Test CT3 function TOKENUPPER()
*
* Copyright 2001 IntTec GmbH, Neunlindenstr 32, 79106 Freiburg, Germany
* Author: Martin Vogel <vogel@inttec.de>
*
* 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)
* 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 "../ct.ch"
procedure main
local cStr := ".,.This.,.is.,.a.,.test!"
qout ("Begin test of TOKENUPPER()")
qout ("")
// Some simple tests
qout (" Simple tests:")
qout ([ tokenupper("Hello, world, here I am!") == "Hello, World, Here I Am!" ?])
qout ([ -> "] + tokenupper ("Hello, world, here I am!") + ["])
qout ([ tokenupper("Hello, world, here I am!",,3) == "Hello, World, Here I am!" ?])
qout ([ -> "] + tokenupper ("Hello, world, here I am!",,3) + ["])
qout ([ tokenupper("Hello, world, here I am!",",",3) == "Hello, world, here I am!" ?])
qout ([ -> "] + tokenupper ("Hello, world, here I am!",",",3) + ["])
qout ([ tokenupper("Hello, world, here I am!"," w") == "Hello, wOrld, Here I Am!" ?])
qout ([ -> "] + tokenupper ("Hello, world, here I am!"," w") + ["])
qout ("")
qout ([ Uppercase the tokens in the string "]+cStr+["])
qout ([ with csetref (.T.) and "@"])
csetref (.T.)
qout ("")
qout ([ --> return value of tokenupper (@cStr): ],tokenupper(@cStr))
qout ([ --> cStr is now: "]+cStr+["])
qout ("")
qout ("End test of TOKENUPPER()")
qout ()
return

View File

@@ -84,6 +84,7 @@ static void do_token1 (int iSwitch)
{
int iParamCheck;
int iNoRef = ct_getref();
switch (iSwitch)
{
@@ -233,10 +234,18 @@ static void do_token1 (int iSwitch)
case DO_TOKEN1_TOKENLOWER:
case DO_TOKEN1_TOKENUPPER:
{
if (!ct_getref())
if (!iNoRef)
{
hb_retclen (pcRet, sRetStrLen);
}
else
{
hb_retl (0);
}
if (ISBYREF (1))
{
hb_storclen (pcRet, sRetStrLen, 1);
}
hb_xfree (pcRet);
}; break;
@@ -331,10 +340,18 @@ static void do_token1 (int iSwitch)
case DO_TOKEN1_TOKENLOWER:
case DO_TOKEN1_TOKENUPPER:
{
if (!ct_getref())
if (!iNoRef)
{
hb_retclen (pcRet, sRetStrLen);
}
else
{
hb_retl (0);
}
if (ISBYREF (1))
{
hb_storclen (pcRet, sRetStrLen, 1);
}
hb_xfree (pcRet);
}; break;
@@ -366,7 +383,14 @@ static void do_token1 (int iSwitch)
case DO_TOKEN1_TOKENLOWER:
case DO_TOKEN1_TOKENUPPER:
{
hb_retc ("");
if (!iNoRef)
{
hb_retc ("");
}
else
{
hb_retl (0);
}
}; break;
case DO_TOKEN1_NUMTOKEN:
@@ -546,9 +570,13 @@ HB_FUNC (TOKEN)
* $DESCRIPTION$
* $EXAMPLES$
* $TESTS$
* numtoken ("Hello, World!") == 2
* numtoken ("This is good. See you! How do you do?",".!?") == 3
* numtoken ("one,,three,four,,six",",",1) == 6
* $STATUS$
* Ready
* $COMPLIANCE$
* NUMTOKEN() is compatible with CT3's NUMTOKEN().
* $PLATFORMS$
* All
* $FILES$
@@ -573,24 +601,59 @@ HB_FUNC (NUMTOKEN)
* $CATEGORY$
* CT3 string functions
* $ONELINER$
* Change the first letter of tokens to lower case
* $SYNTAX$
* TOKENLOWER (<[@]cString>, [<cTokenizer>], [<nTokenCount>],
* [<nSkipWidth>]) -> cString
* $ARGUMENTS$
* <[@]cString> is the processed string
* [<cTokenizer>] is a list of characters separating the tokens
* in <cString>
* Default: chr(0)+chr(9)+chr(10)+chr(13)+chr(26)+
* chr(32)+chr(32)+chr(138)+chr(141)+
* ",.;:!\?/\\<>()#&%+-*"
* [<nTokenCount>] specifies the number of tokens that
* should be processed
* Default: all tokens
* [<nSkipWidth>] specifies the maximum number of successive
* tokenizing characters that are combined as
* ONE token stop, e.g. specifying 1 can
* yield to empty token
* Default: 0, any number of successive tokenizing
* characters are combined as ONE token stop
* $RETURNS$
* <cString> the string with the lowercased tokens
* $DESCRIPTION$
* The TOKENLOWER() function changes the first letter of tokens in <cString>
* to lower case. To do this, it uses the same tokenizing mechanism
* as the token() function. If TOKENLOWER() extracts a token that starts
* with a letter, this letter will be changed to lower case.
* You can omit the return value of this function by setting the CSETREF()
* switch to .T., but you must then pass <cString> by reference to get
* the result.
* $EXAMPLES$
* ? tokenlower("Hello, World, here I am!") // "hello, world, here i am!"
* ? tokenlower("Hello, World, here I am!",,3) // "hello, world, here I am!"
* ? tokenlower("Hello, World, here I am!",",",3) // "hello, World, here I am!"
* ? tokenlower("Hello, World, here I am!"," W") // "hello, World, here i am!"
* $TESTS$
* tokenlower("Hello, World, here I am!") == "hello, world, here i am!"
* tokenlower("Hello, World, here I am!",,3) == "hello, world, here I am!"
* tokenlower("Hello, World, here I am!",",",3) == "hello, World, here I am!"
* tokenlower("Hello, World, here I am!"," W") == "hello, World, here i am!"
* $STATUS$
* Ready
* $COMPLIANCE$
* TOKENLOWER() is compatible with CT3's TOKENLOWER(),
* but a new 4th parameter, <nSkipWidth> has been added for
* synchronization with the the other token functions.
* $PLATFORMS$
* All
* $FILES$
* Source is token1.c, library is ct3.
* $SEEALSO$
* TOKEN() NUMTOKEN() ATTOKEN()
* TOKENUPPER() TOKENSEP()
* TOKENUPPER() TOKENSEP() CSETREF()
* $END$
*/
@@ -609,24 +672,59 @@ HB_FUNC (TOKENLOWER)
* $CATEGORY$
* CT3 string functions
* $ONELINER$
* Change the first letter of tokens to upper case
* $SYNTAX$
* TOKENUPPER (<[@]cString>, [<cTokenizer>], [<nTokenCount>],
* [<nSkipWidth>]) -> cString
* $ARGUMENTS$
* <[@]cString> is the processed string
* [<cTokenizer>] is a list of characters separating the tokens
* in <cString>
* Default: chr(0)+chr(9)+chr(10)+chr(13)+chr(26)+
* chr(32)+chr(32)+chr(138)+chr(141)+
* ",.;:!\?/\\<>()#&%+-*"
* [<nTokenCount>] specifies the number of tokens that
* should be processed
* Default: all tokens
* [<nSkipWidth>] specifies the maximum number of successive
* tokenizing characters that are combined as
* ONE token stop, e.g. specifying 1 can
* yield to empty token
* Default: 0, any number of successive tokenizing
* characters are combined as ONE token stop
* $RETURNS$
* <cString> the string with the uppercased tokens
* $DESCRIPTION$
* The TOKENUPPER() function changes the first letter of tokens in <cString>
* to upper case. To do this, it uses the same tokenizing mechanism
* as the token() function. If TOKENUPPER() extracts a token that starts
* with a letter, this letter will be changed to upper case.
* You can omit the return value of this function by setting the CSETREF()
* switch to .T., but you must then pass <cString> by reference to get
* the result.
* $EXAMPLES$
* ? tokenupper("Hello, world, here I am!") // "Hello, World, Here I Am!"
* ? tokenupper("Hello, world, here I am!",,3) // "Hello, World, Here I am!"
* ? tokenupper("Hello, world, here I am!",",",3) // "Hello, world, here I am!"
* ? tokenupper("Hello, world, here I am!"," w") // "Hello, wOrld, Here I Am!"
* $TESTS$
* tokenupper("Hello, world, here I am!") == "Hello, World, Here I Am!"
* tokenupper("Hello, world, here I am!",,3) == "Hello, World, Here I am!"
* tokenupper("Hello, world, here I am!",",",3) == "Hello, world, here I am!"
* tokenupper("Hello, world, here I am!"," w") == "Hello, wOrld, Here I Am!"
* $STATUS$
* Ready
* $COMPLIANCE$
* TOKENUPPER() is compatible with CT3's TOKENUPPER(),
* but a new 4th parameter, <nSkipWidth> has been added for
* synchronization with the the other token functions.
* $PLATFORMS$
* All
* $FILES$
* Source is token1.c, library is ct3.
* $SEEALSO$
* TOKEN() NUMTOKEN() ATTOKEN()
* TOKENLOWER() TOKENSEP()
* TOKENLOWER() TOKENSEP() CSETREF()
* $END$
*/
@@ -645,16 +743,31 @@ HB_FUNC (TOKENUPPER)
* $CATEGORY$
* CT3 string functions
* $ONELINER$
* Retrieves the token separators of the last token() call
* $SYNTAX$
* TOKENSEP ([<lMode>]) -> cSeparator
* $ARGUMENTS$
* [<lMode>] if set to .T., the token separator BEHIND the token
* retrieved from the token() call will be returned.
* Default: .F., returns the separator BEFORE the token
* $RETURNS$
* Depending on the setting of <lMode>, the separating character of the
* the token retrieved from the last token() call will be returned.
* These separating characters can now also be retrieved with the token()
* function.
* $DESCRIPTION$
* When one does extract tokens from a string with the token() function,
* one might be interested in the separator characters that have been
* used to extract a specific token. To get this information you can
* either use the TOKENSEP() function after each token() call, or
* use the new 5th and 6th parameter of the token() function.
* $EXAMPLES$
* see TOKEN() function
* $TESTS$
* $STATUS$
* Ready
* $COMPLIANCE$
* TOKENSEP() is compatible with CT3's TOKENSEP().
* $PLATFORMS$
* All
* $FILES$