lq-text: LQU_ReverseString

API char * LQU_ReverseString (start, end, type) char *start; char *end; int type;

Purpose

Reverses the bytes in the given string; if `type' is even, the individual whitespace-delimited words are reversed in place; if type is even, he entire string is reveresed. The process is repeated with (type - 1) until type is zero. Hence, a reverse type of zero does nothing, and a reverse type of one reverses the string in place; a reverse type of 2 will reverse the order of the words in the string; a reverse type of 3 is the same as a reverse type of one, and a reverse type of 4 leaves the string in place. Values greater than two are thus pointless, but are allowed for convenience.

Returns

the given start pointer; the string is reversed in place.

Errors

An internal error (always fatal) is produced if either start or end is a null pointer, or if end < start (implying a string of negative length), or if the type argument is outside the range from zero to eight inclusive.

Notes

The string must be in read-write memory; to reverse a string that was a manifest constant at compile time, you must first copy it into a dynamically allocated buffer.

This function is used by lqkwic, which contains some examples.