Sponsored Content
Full Discussion: while ..until
Top Forums Programming while ..until Post 28596 by Perderabo on Friday 20th of September 2002 01:42:58 PM
Old 09-20-2002
Re: OR

Quote:
Originally posted by darkspace
Better use:

while(chr != ' ' || chr !='<') {
chr--; // or *chr-- whatever is reqd.
}
You will stay in that loop while:
chr is not a space OR
chr is not a less than sign

One of those will always be true. So you have an infinite loop, now.

The original answer was better, but both seem to be using chr as both a pointer to character and as a character.

I don't like the do/until concept, but that is what the OP requested. For some reason, he is sure that the loop must be executed at least once.

And also, when scanning a string, you really need to check for the end of the string. I know that the OP didn't request this, but I can't help myself on this one.

So my answer:
Code:
do {
    chr--;
} while (*chr && *chr != ' ' && *chr != '<');

 
TCRMGR(1)							   Tokyo Tyrant 							 TCRMGR(1)

NAME
tcrmgr - the command line utility of the remote database API DESCRIPTION
The command `tcrmgr' is a utility for test and debugging of the remote database API and its applications. `host' specifies the host name of the server. `key' specifies the key of a record. `value' specifies the value of a record. `params' specifies the tuning parameters. `dpath' specifies the destination file. `func specifies the name of the function. `arg' specifies the arguments of the function. `file' specifies the input file. `upath' specifies the update log directory. `mhost' specifies the host name of the replication master. `url' specifies the target URL. tcrmgr inform [-port num] [-st] host Print miscellaneous information to the standard output. tcrmgr put [-port num] [-sx] [-sep chr] [-dk|-dc|-dai|-dad] host key value Store a record. tcrmgr out [-port num] [-sx] [-sep chr] host key Remove a record. tcrmgr get [-port num] [-sx] [-sep chr] [-px] [-pz] host key Print the value of a record. tcrmgr mget [-port num] [-sx] [-sep chr] [-px] host [key...] Print keys and values of multiple records. tcrmgr list [-port num] [-sep chr] [-m num] [-pv] [-px] [-fm str] host Print keys of all records, separated by line feeds. tcrmgr ext [-port num] [-xlr|-xlg] [-sx] [-sep chr] [-px] host func [key [value]] Call a script language extension function. tcrmgr sync [-port num] host Synchronize updated contents with the database file. tcrmgr optimize [-port num] host [params] Optimize the database file. tcrmgr vanish [-port num] host Remove all records. tcrmgr copy [-port num] host dpath Copy the database file. tcrmgr misc [-port num] [-mnu] [-sx] [-sep chr] [-px] host func [arg...] Call a versatile function for miscellaneous operations. tcrmgr importtsv [-port num] [-nr] [-sc] host [file] Store records of TSV in each line of a file. tcrmgr restore [-port num] [-ts num] [-rcc] host upath Restore the database with update log. tcrmgr setmst [-port num] [-mport num] [-ts num] [-rcc] host [mhost] Set the replication master. tcrmgr repl [-port num] [-ts num] [-sid num] [-ph] host Replicate the update log. tcrmgr http [-ah name value] [-ih] url Fetch the resource of a URL by HTTP. tcrmgr version Print the version information of Tokyo Tyrant. Options feature the following. -port num : specify the port number. -st : print miscellaneous status data. -sx : input data is evaluated as a hexadecimal data string. -sep chr : specify the separator of the input data. -dk : use the function `tcrdbputkeep' instead of `tcrdbput'. -dc : use the function `tcrdbputcat' instead of `tcrdbput'. -dai : use the function `tcrdbaddint' instead of `tcrdbput'. -dad : use the function `tcrdbadddouble' instead of `tcrdbput'. -px : output data is converted into a hexadecimal data string. -pz : do not append line feed at the end of the output. -m num : specify the maximum number of the output. -pv : print values of records also. -fm str : specify the prefix of keys. -xlr : perform record locking. -xlg : perform global locking. -mnu : omit the update log. -nr : use the function `tcrdbputnr' instead of `tcrdbput'. -sc : normalize keys as lower cases. -mport num : specify the port number of the replication master. -ts num : specify the beginning time stamp. -rcc : check consistency of replication. -sid num : specify the self server ID. -ph : print human-readable data. -ah name value : add a request header. -ih : output response headers also. If the port number is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter. This command returns 0 on success, another on failure. SEE ALSO
ttserver(1), ttultest(1), ttulmgr(1), tcrtest(1), tcrmttest(1), ttutil(3), tcrdb(3) Man Page 2010-01-20 TCRMGR(1)
All times are GMT -4. The time now is 01:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy