Dec 072017
 
An amazingly extensive string/character function library for C language programmers. Documentation is so far above average that it has to be seen to be believed. If you write programs in C, grab this one.
File HH_STR13.ZIP from The Programmer’s Corner in
Category C Source Code
An amazingly extensive string/character function library for C language programmers. Documentation is so far above average that it has to be seen to be believed. If you write programs in C, grab this one.
File Name File Size Zip Size Zip Type
DATEINFO.DOC 1604 796 deflated
DATETEST.C 5349 1102 deflated
DATETEST.EXE 18158 8264 deflated
FUNCFIND.EXE 98638 30313 deflated
HHGROUP.DOC 36750 11998 deflated
HHSTRING.H 16037 2524 deflated
HHSTR_BT.LIB 92160 21555 deflated
HHSTR_MT.LIB 93001 23620 deflated
KWIC.DOC 96816 6727 deflated
MANUAL.DOC 800619 73888 deflated
ORDER.DOC 831 363 deflated
PACKING.LST 2423 1088 deflated
SAMPLE.C 21836 6043 deflated
TEST_STR.C 77316 9761 deflated
TEST_STR.EXE 103302 32916 deflated

Download File HH_STR13.ZIP Here

Contents of the MANUAL.DOC file































hhstring --- the Hobbit House String Library

version 1.3
===========

from

Hobbit House software

2039 Civic Center Dr. Suite 555

N. Las Vegas, NV, 89030

March, 1993













The Hobbit House String Library



TABLE OF CONTENTS
=================


section page #
------------------------------------------------------------- ------

1.0 introduction ............................................ 1

1.1 The Distribution Packagess .......................... 1

1.1.1 The Shareware Package ......................... 1
1.1.2 The Commercial Package ........................ 2

1.2 The Electronic Manual, or "Buddy, Can You
Spare 500 Sheets of Paper?" .......... 2
1.3 Library Usage or "how I Learned to Delegate
Trivia and Get on With the
More Important Things in Life" ........ 2
1.4 New Strings ......................................... 3
1.5 Too Many Functions ? ................................ 3
1.6 Printing the .C files ............................... 3
1.7 Error Conditions .................................... 4
1.8 What's Next ? ....................................... 4

2.0 Documentation ........................................... 5

2.1 Metalanguage ........................................ 5
2.2 Function Documentation .............................. 5
2.3 Naming Conventions .................................. 8

2.3.1 "Standard" Abbreviations ...................... 8
2.3.2 "text" v.s. "word" ............................ 9
2.3.3 "wordnext" v.s. "nextword" .................... 10
2.3.4 Left v.s. Right for the
Directionally Handicapped ................ 10
2.3.5 Some Pointer Examples ......................... 11

2.4 The KWIC Index ...................................... 12
2.5 The Black Model-T Ford .............................. 12
2.6 A Word About Macros ................................. 13
2.7 NULL vs EOS ......................................... 13

3.0 Borland v.s. Microsoft .................................. 14

4.0 Utilities ............................................... 15

4.1 hhstring Utilities .................................. 15

4.1.1 funcfind ...................................... 16
4.1.2 make_man ...................................... 16
4.1.3 test_str and testdate ......................... 16
4.1.4 cprint ........................................ 17

The Hobbit House String Library


4.2 The Creation and Maintenance Uutilities ............. 17

4.2.1 sorc_chk ...................................... 17
4.2.2 window ........................................ 18
4.2.3 index ......................................... 18
4.2.4 compress/expand ............................... 18
4.2.5 drwin ......................................... 18
4.2.6 protoflt ...................................... 19

5.0 Royalties and Distribution Rights ....................... 19

6.0 The Hobbit House Group .................................. 19

7.0 Ordering Information .................................... 20

8.0 Technical Support ....................................... 20

9.0 Function Listings ....................................... 21







































The Hobbit House String Library


1.0 Introduction
================

The hhstring library is an extension of work performed on the user
interface portion of a number of DOS-based programs written under
Borland and/or Microsoft C/C++, starting in 1986 and actively continuing
through the present. The library has been added to, fully tested, and
extensively documented. Several utilities were written along the way to
make the library easy to maintain and easy to use.

The documentation for hhstring comes in 4 parts:

o this manual

o the source code files (which may be included in this manual in
addition to being provided separately)

o the KWIC index

o the online function finder

Only the KWIC index is specifically designed to be printed out. The
documentation is discussed in section 2.0.

Although most of the work done during the creation of the library was
done under the Borland compilers (TC 1.5 through BC 3.1), all of the
functions, plus the test program, have been compiled under the current
Microsoft compiler as well (MSC 7.0). Some comments regarding Borland
and Microsoft are in section 3.0.

Section 4.0 discusses the various utilities which surround the library.
There are two "flavors" of utilities, the hhstring utilities (that is,
ones which are essentially a part of the hhstring library), and the
creation/maintainance utilities (these are not necessary for the use of
the library and are a separate package).


1.1 The Distribution Packages
=============================

The hhstring package comes in two flavors; the demo version and the
commercial version. These are described in the following sections.


1.1.1 The Demo Package
======================

The demo version of hhstring is a fully functional package, but only
includes the tiny model library. It contains the manual (without source
code), the KWIC index, and the on-line function finder. The demo version
may be copied and distributed freely, with only the restriction, that it
be distributed exactly AS IS; that is, all files must be included. If
you ZIP it (or LZH it, or whatever), the .ZIP file should contain only
the three files (readme.1st, squashed.dat, and expand.exe) which are on

page 1 The Hobbit House String Library

the distribution disk for the demo version.


1.1.2 The Commercial Package
============================

The commercial package contains all 6 memory models for both the Borland
(BC 3.1) and the Microsoft (MSC 7.0) compilers, plus full source code for
all of the functions in the library. The manual creation process has the
option to include the source code listings directly in the manual if you
wish.

The commercial version of hhstring is copyrighted and may NOT be copied
or distributed in any way other than the creation of a backup copy for
use by the owner.


1.2 The Electronic Manual, or "Buddy,
Can You Spare 500 Sheets of Paper?"
=======================================

The manual is over 500 pages long (for the commercial version with full
source code included). It just isn't possible to produce and distribute
a printed manual this size and still keep the product priced under $40.
For those of you who want, or insist on (as we do), a printed copy for
your reference shelf, you'll just have to bite the bullet and print it
out.

We regret that this is the case, but hope you will understand.


1.3 Library Usage or "How We Learned to Delegate Trivia
and Get on With the More Important Things in Life"
======================================================

As programmers, we have mixed feelings about libraries. The bad news is
that libraries rob us of the joy of doing it ourselves but the good news
is that libraries let us delegate the "small stuff" and get on with more
creative things. We find that most of our fellow programmers with whom
we discuss this issue feel pretty much the same.

Over the years, we've moved away from the former point of view and
embraced the latter. As we move further into the 90's and see more and
more tools on the order of Visual BASIC, Turbo Vision and so forth,
the programmers who don't pretty quickly get used to delegating the
"small stuff" (which is getting larger and larger as the years go by)
will get left behind.

It's important to know HOW to do the small stuff, but it is also
important to not spend too much of your time actually DOING it! The
intent of hhstring is to allow you to delegate a major portion of your
non-graphical user interface needs to a library which is well organized,
well documented, and fully supported.





The Hobbit House String Library page 2

1.4 New Strings
===============

In some C libraries, the functions create new strings. This has the
advantage that the calling function needn't worry about the creation of
the new string, but it has the disadvantages that (1) the new string
size has to be limited to something fairly small (256 bytes is generally
the largest you will find) because you would otherwise clutter up memory
with an awful lot of string space you don't really need and (2) every
"new-string" function called creates yet another new string which may not
be needed at all (since the calling function might well be able to make
use of only a small number of string allocations to handle ALL of the
"new-string" function calls).

Because of the disadvantages of having the function create the new
string, we decided to have the functions in our library use new strings
allocated by and pointed to by the calling functions. This way, the
size of the created string is not dictated by our library, but rather
is under the control of your calling program.

Additionally, we have provided, for many of the functions, alternate
versions which allow the calling program to specify that the operation
takes place on one string with the result going to a different
string, leaving the original string unchanged. These are the "new"
functions (i.e. those functions whose name ends in "new").


1.5 Too Many Functions ?
========================

We have had a number of comments about the uselessness of various of the
functions. In most cases we have had other users who praised the same
functions. Just as one example, one fellow was irate that we would bother
to include functions which take as input ASCII-numeric strings containing
commas. His argument was that commas are useful for output, since that
makes things more readable for humans, but nobody inputs that way.
Another customer was specifically delighted with the same functions
because of their direct application to his conversion of scanned text to
numeric form.

The point is this: if you think some of the functions are useless you're
probably right. For now. Hang on to them, though; you never know when
they will come in handy. For now just consider them "extras" and make
good use of the functions you CAN use. We think you'll be surprized how
many of them you end up using once you get used to including HHSTRING in
your programming.


1.6 Printing the .C files
=========================

The .C files are spaced for printing by the CPRINT utility. The .EXE
file of this utility is included with the demo package. You are certainly
free to print the source code in any way you wish, we just want you to
know that if you use something other than CPRINT, the page breaks may

page 3 The Hobbit House String Library

come at inappropriate places in the text/source. Another advantage to
using CPRINT is that it will put the file name on the top of each page.

The MAKE_MAN utility uses a dedicated version of CPRINT.


1.7 Error Conditions
====================

In hhstring, error conditions and anomalous conditions have been tested
for and accounted for extensively in the code. Some execution time and
run-time memory space are used by all of the checking we do for erroneous
and/or anomalous conditions. Nothing's free.

The documentation specifically points out any conditions under which the
functions might create anomalous values if used carelessly. This is
particulary true of the "prev" functions. Nothing is every really idiot
proof, 'cause us idiots are so damned clever, but we've spent a lot of
time making hhstring test for boundary conditions and resolve anomalous

conditions.


1.8 What's Next ?
=================

There are a number of functions which we have added to the list of those
that should appear in hhstring, but which we were unable to include in
this release. We would appreciate any suggestions you have as to
functions you would like to see added, or any improvements you would
suggest for hhstring.

Some of the specific functions being considered for the next release are:

o count the number of:
- characters {not} in a group
- characters {not} in a range
- upper/lower case letters
- digits (octal/decimal/hexidecimal)
- punctuation characters
- whitespace characters
- non-whitespace characters
- blanks, tabs, etc and non-blanks, tabs, etc.
- words
- text words
o sum-to-zero checksum functions
o checksum functions which allow binary 0 as a valid data element
o delete characters not in a group, not in a range
o time functions similar to date1 through date7
o convert multiple blanks to one blank
o convert multiple blanks and/or tabs to one blank
o tabtoblanknew/blanktotabnew
o tabtoblankq{new} (these functions handle
o blanktotabq{new} quoted strings properly)
o strisprefix, strissuffix (is given str a prefix/suffix ?)
o Htoc to give 'F' where htoc gives 'f'
o "safe" versons of strwordprev and strtextprev

The Hobbit House String Library page 4

o strn (get the nth word|text)


2.0 Documentation
=================

There are two things that make hhstring stand out from the average
function library. The first is the fact that it addresses only one small
area (strings) but has extreme depth of coverage of that one area. The
second thing is the documentation. This includes a KWIC index, an online
function finder, a full description of every function, and comments on
every line of source code in every function in the library.

The following sections (2.1 through 2.6) discuss various aspects of the
hhstring documentation.


2.1 Metalanguage
================

There are occasional uses in the documentation of fairly common and very
straightforward "metalanguage" symbols. These are:

the "<>" designates required information

| the "|" designates "or"

{optional} the "{}" designates optional information

An example:

ptr {not} hex

implies a set of names, all of which start with "ptr", each of which then
contains exactly one of the substrings "first" or "last" or "next" or
"prev", and each of which may or may not then contain the substring "not"
and all of which end in the substring "hex". This set consists of the
following 8 names:

ptrfirsthex ptrfirstnothex
ptrlasthex ptrlastnothex
ptrnexthex ptrnextnothex
ptrprevhex ptrprevnothex


2.2 Function Documentation
==========================

Every function in the hhstring library is documented in accordance with
the following "function header". It is shown below in "empty" form, and
there follows a complete description of all the fields and what typically
goes into them. The format of this function header is used by the utility
SORC_CHK.EXE (see section 4.4.1) to help verify that all functions are
fully documented.



page 5 The Hobbit House String Library

/* function_name
Hobbit House Software

copyright(c) 1992, 1993

function: function_name (FUNCTION NAME)

purpose:

syntax: #include "hhstring.h"

description:

returns:

comments:

keywords:

key sentence:

see also:

usage example: compiled/executed/verified on


Hobbit House Software
*/


First a general note: the descriptions, comments, etc. in this function
header are frequently done as incomplete sentences and without proper
capitalization and punctuation. The goal here is clarity of expression,
not linguistic purity. If it offends you that we neglect to capitalize
the first letter of each sentence, for example, we apologize, but not an
awful lot. (we are not talking here about the descriptions below, but the
ones being described by the ones below)


function: The function name is shown along with a highlighted (by
--------- capital letters) version of the mnemonic that the
function name is derived from. Note that there is a copy
of the function name at the upper right corner of the
header, another in the syntax line, several in the code
snipped under usage example, one in the function
declaration itself, and finally another in the last line
of the comment. There is a reason for each of these
occurances of the name, but it does leave a lot of room
for mistakes when a name changes, so SORC_CHK.EXE (see
section 4.2.1) makes sure that they are all the same.

KWIC: An informal statement of what the function is good for,
----- done with keywords preceded by the percent character (%),
so that this sentence can be used with the KWIC index
(see section 2.4). A more formal, and rigorous statement
of what the function does appears in "description:"

The Hobbit House String Library page 6

below.

syntax: Shows the formal syntax of the function, including any
------- headers files which need to be included to make the
function work properly, plus the formal parameters of
the function call.

description: Gives a technical description of the function, using the
------------ formal parameters shown in the syntax description above.

returns: Describes the value, if any, returned by the
-------- function

comments: Notes about boundary conditions, peculiarities of any
--------- sort, similarities/difference relative to other
functions, etc.

keywords: The list of keywords used by funcfind for this
--------- function

key sentence: The descriptive sentence used by funcfind for this
------------- function

see also: Refers the user to other functions in the library which
--------- are similar in some way to this functions. Frequently,
the references use the metalanguage conventions described
in section 2.2

usage example: This is a "code snippet" which has been compiled and
-------------- executed. The output shown below the code snippet has
been verified as being what the code snippet acutally
produces. Whenever a source code file is modified, even
in the most trivial way, a file consisting of the
following four lines:

#include

void main(void)

{

}

is read in just in front of the function declaration and the code from
the usage example is moved down to between the curley braces. When
necessary, a .PRJ file (this is usually done under Borland) is created as
well. The resulting program is then complied and executed and the results
are compared against those shown in the usage example. This process is
re-done EVERY time any change is made in the function. The date on which
it is done is inserted on the usage example line. The date on this line
is, therefore, the "latest update" date for the source file. The file
itself may carry a different DOS date stamp because files are "touched"
at release time, but the date on this line is the true date of the most
recent modification, no matter how trivial, of the source code.

To assure that there are no problems with function interaction (some of

page 7 The Hobbit House String Library

the functions call others in the libarary), the TEST_STR.EXE utility (see
section 4.1.3) is recompiled/executed from time to time (always including
just prior to any product release).

The primary goals of the usage examples are:

1) make sure that the function works properly, including tests of
most or all boundary conditions (some usage examples may appear
obsessed with boundary conditions; when this happens, please
remember that it is the boundary conditions where functions
normally fail).
2) show similarities and differences between similar functions by
using similar usage examples.

Note that the useage examples do NOT necessarily give a good example of
how the funciton might most commonly be used in a real-world situation.


2.3 Naming Conventions
======================

There are several issues involving naming conventions for hhstring. These
are addressed in the following subsections, 2.3.1 through 2.3.3.


2.3.1 "Standard" Abbreviations
==============================

Most of the "directional" functions in this library ("left", "right",
and "middle") are named according to the following set of terms. The
two-letter combinations are used in file names so that all file names
can be kept to 8 characters or less. Not all combinations of the
following are valid, but most are. In particular, the "middle" functions
are much more limited than the side functions. For example, one doesn't
shift or rotate to or from the middle.

required required required optional optional
-------- -------- -------- -------- --------
LF
STR MD see below N W
RT

meaning:
/ SH (shift)\
/ RO (rotate)\
/left \ / JS (justify)\
< DL (delete) > {number} {new}
\right/ \ FL (fill) /
\ SZ (size) /
\ TR (trim) /
\PD (pad) /






The Hobbit House String Library page 8

The pointer functions use the following abbreviations for names:

function name uses
file name uses: the part in caps
--------------------------------- ---------------------------------
/ / BK \ \ BLanK
/ / CH \ \ CHaRacter
/ / CI \ \ CHaRacter, case-Independant
/ / DG \ \ DIGit
/ / GR \ \ GRoup
/ FIR \ / {NO} \ {NOT} HEX
/ LAST \ / \ RN / \ RANge
< NEXT >< \ TT / > TEXT-TERMinator
\ PREV / \ \ WH / / WHITEspace
\ THIS*/ \ \ WT / / WORD-TERMinator
\ SUB{I} / SUBstring {case-Independant}
\ TEXT / TEXT (see section 2.3.2)
\ WORD / WORD

*NOTE: "THIS" is only used with TEXT and WORD functions


2.3.2 "text" v.s. "word"
========================

The hhstring library originally used the term "word" to mean a group of
characters not containing whitespace (blanks and/or tabs). This has
been extended to mean a group of characters not containing a "word
terminator", where a "word terminator" is defined as being any of the
characters:

blank
horizontal tab
form-feed
carriage-return
line-feed
vertical tab
End-Of-String (binary zero)

A "text word" is a group of characters not separated by either a word
terminator, or any of the following English language punctuation marks:

.
,
:
;
!
?

The phrase "text terminator", as used with hhstring, means that set of
characters consisting of word terminators (see above) and the punctuation
marks just described.




page 9 The Hobbit House String Library

2.3.3 strwordnext v.s. ptrnextword
==================================

There is an area of possible confusion regarding the names in hhstring
and that is the difference between the "strword..." and the "ptr...word"
functions (and the corresponding "text" functions).

The "ptr...word" functions FIND something whereas the "strword..."
functions GET something. "strwordnext", for example, gets the next word
following a specified pointer and it puts that word into a specified
string. "ptrnextword", on the other hand, will return a pointer to the
next word following a specified pointer. The "str" and "ptr" tell the
difference (ptr => get the pointer, str => get the string), but the names
are also composed to show the relative importance of the direction
information versus the "word". That is, "wordnext" implies that the
"word" is more important than the "next", because the function is getting
a word. "nextword" implies that the next is more important because the
function is finding the position of the "next" whatever.

If this is all too boring to remember, don't worry; that's why we have
the KWIC index and the function finder.


2.3.4 Left v.s. Right for the Directionally Handicapped
=======================================================

Terminology is a wonderful thing. Years ago, people who swept floors were
called "janitors". For many years now, they have been called "building
maintenance engineers". People who carry a few extra pounds around in
front of them are no longer "fat" or "potbellied", they are "horizontally
impaired". People are now called "orifice identification impaired" where
we used to just say that they didn't know their ass from a hole in the
ground. Progress is amazing.

Anyway, to get back to the subject at hand, there is a point of possible
confusion regarding the use of the terms "left" and "right" in this
library. We are confident that everybody can tell which side of a string
is the right side and which is the left. We expect no problems with the
functions "left" and "right" and their normal offspring such as
"strlfdel" (delete the left side of a string) and so forth.

The potential problem comes with the "size" functions. Should "strlfsize"
mean "force a string to a fixed size using the characters from the left
side of the string" or should it mean "force the left side of a string
to do what is necessary so that the string will have a fixed size"?

We feel confident that either choice will seem absurd to some and
reasonable to others. Thus, we offer no defense of the particular
choice made, we just want you to be aware of it.

In hhstring, the latter choice was taken. "strlfsize" means "do whatever
it takes to the left side of a string so that the result will have a
fixed size".

Thus,

The Hobbit House String Library page 10


char Astring[80] = "this is string 1";
char Bstring[80] = "string 2";
printf("\n-->%s", strlfsize(Astring, 11);
printf("\n-->%s", strlfsize(Bstring, 11);

-->is string 1
--> string 2

As you can see, strlfsize either truncates or pads the left side of a
string, as opposed to taking its characters from the left side of the
string.


2.3.5 Some Pointer Examples
===========================

The pointer functions all start (after the "ptr") with "first", "last",
"next", "prev", or "this". First and last seem fairly obvious. Next, prev
and this are also pretty straightforward, but we present the following
examples to avoid any confusion. The examples deal with words and use
only the standard word separator of a blank. The concepts hold equally,
however, for text words as well and for any combination of text or word
terminators (see section 2.3.2).

ptrnextword
-----------

any pointer from here to here will end up here



v vv
first slsdjf lkjs slfdkfjldkf nextword last


ptrprevword
-----------

any pointer from here to here will end up here





v v v
first llssddjf prevword slfdkfjldkf lkjeunse last










page 11 The Hobbit House String Library

ptrthisword
-----------

any pointer from here to here will end up here






v v
first slsdjf lkjs dnsl thisword lskdjfd last


2.4 The KWIC Index
==================

The KWIC index is one of those things that is somewhat difficult to
explain but really easy to understand. The following description is
technically accruate but will make a lot more sense if you have first
examined the KWIC index itself. See the file KWIC.DOC

The "Key Word In Context" index is also known (to UNIX programmers) as a
"permuted index". It works like this: for each "target", a keyword
sentence is constructed with the appropriate keywords flagged in some way
(in hhstring, the percent character (%) is used). A "target" is the
"thing being searched for" and in the case of hhstring, the targets are
functions (that is, function names). The keyword sentences are then
manipulated so that the index created from them contains one occurance of
each sentence for every keyword in the sentence. Thus, if a sentence
contains 5 keywords, that sentence will appear in the KWIC index 5 times.

The sentences are physically arranged on the page so that the keyword is
in the center of the page and is alphabetical within the total index.
Again, this may sound weird, but it will make perfect sense if you just
examine the KWIC.DOC file.


2.5 The Black Model-T Ford
==========================

Henry Ford, commenting on some people's annoyance that his Model-T Fords
were only avaliable in black, is reputed to have said "People can buy my
cars in any color they like, as long as what they like is black."

Why do we bring that up? Well, it's like this. We noticed some years ago
that there are two ways to document software. The first way is to comment
every line of source code and the second way is to NOT comment every line
of source code. We further noticed that if the second method is chosen,
it is inevitable that decisions have to be made as to what should be
commented and what shouldn't be bothered with and the decisions usually
tend towards no documentation at all.

On the other hand, if the first method is chosen, it means putting in
comments that are blatantly obvious to any programmer with an

The Hobbit House String Library page 12

intelligence above that of your average garden vegetable or tree stump.
We don't want our customers to think that we're insulting their
intelligence, but we also don't want to produce code which is not
adequately commented.

So, here's our compromise: you can have our source code any way you like
it as long as what you like is comments on every line.


2.6 Macros
==========

Please observe that most of the macros in hhstring use "char *"
arguments, NOT "char" arguments. As a simple example of this, consider
the following macro from hhstring.h:

#define ISBLANK(s) (*(s) == ' ')

This macro is designed to test the character pointed to by a character
pointer, NOT to test a character directly.

Also be aware, in case you are not already, that macros can be, and
quite often are, created in a way that makes them quite treacherous
to use. The macros in hhstring.h are no exception to this rule.

The problem is that "familiarity breeds contempt" and after long and
accustomed use of macros, we tend to forget that they ARE macros. Then we
do dumb things such as using the statement ISWHITE(ptr++) when the macro
is defined as:

#define ISWHITE(s) ((*(s) == ' ') || (*(s) == '\t'))

The problem is that the macro uses its argument more than once, so if we
use a macro argument which increments, it will increment more than once.
If you do this sort of thing on purpose, you can create interesting and
ammusing results, but if you do it by accident you are not likely to be
even remotely ammused.

During the creation of hhstring, we had a particulary nasty bug due to
the fact that in Borland the "toupper" macro does NOT use it's argument
twice whereas in Microsoft it does. We used the statement:

delupper = toupper(instring[kk] = instring[ii++]);

This worked fine under Borland but produced garbage under Microsoft. That
does not say that Borland did something right, or that Microsoft did
something wrong, it says that we forgot to be careful when using macros!
Our advice to you is, be careful using macros!


2.7 NULL v.s. EOS
=================

Most of the "ptr" functions in hhstring will return a NULL pointer
to flag a "not found" condition. We've had enough questions about this
that we feel compelled to present a little mini-lesson here in the

page 13 The Hobbit House String Library

fundamentals of C programming.

A null string is one which has a binary zero as it's first element. A
pointer to such a string is NOT a NULL pointer. A NULL pointer is a
pointer which is itself a binary zero. Thus if ptr is a NULL pointer,
*ptr may or may not be a NULL string, depending on what's at memory
location zero.

At any rate, if ptr is a return from one of the "ptr" functions in
hhstring, the statement

if (*ptr == EOS)

is a terrible idea, since ptr might be a NULL pointer as opposed to a
pointer to the EOS of the string sent to the "ptr" function.

Instead, use the statement

if (ptr == NULL)


3.0 Borland v.s. Microsoft
==========================

In general, MSC 7.0 is more rigorous about warnings than Borland. The
variable type "size_t" has been used occasionally in the library to
typecast variables. In every instance, this was to eliminate a compiler
warning under Microsoft which did not occur under Borland. Under both
compilers, hhstring is always compiled with all warnings "ON". We approve
of the rigor of MSC 7.0's warning messages.

Borland's IDE is considerably more user friendly than Microsoft's PWB.
The PWB appears to have been written without too much regard to how it
was going to be used, whereas the IDE is specifically designed to be
easy to use. On the other hand, the PWB is far more stable than the IDE.
We can regularly crash the IDE in any number of seemingly innocuous ways
including a simple transfer to "grep" when compiling a large program and
attempting to delete a window entry whose correspoinding file no longer
exists, whereas the PWB seems to be more reliable. This point of view
should be taken with a grain of salt since we use the IDE far more than
we use the PWB and thus we have more opportunities for problems under the
IDE than under the PWB.

The library has been compiled and fully tested under both Borland and
Microsoft. The "code snippets" in the usage example section of every
function's documentation are usually only compiled under Borland. The
TEST_STR utility, however, has been compliled, linked, and run under
both compilers, as has the DATETEST program.

During development there were some peculiarities of warnings and even
errors under Microsoft that didn't occur under Borland. These have been
eliminated in the final product and it will not matter whether you
compile the libary under Borland or Microsoft. If you use the supplied
.LIB files, then of course you have to use the right one for your choice
of compiler.


The Hobbit House String Library page 14

While developing the library, we use various combinations of compiler
flags for various reasons. For the released product, however, we always
use the "Ox" flag which (for both Borland and Microsoft) tells the
compiler to optimize for speed. Interestingly enough, the optimization
for speed causes a reduction in size as well as speed (compared to the
size produced by a totally non-optimized compile).

Also note that, under both Microsoft and Borland, the "no debug info"
flags are set for the final library compilation process, thus the library
code will not be amenable to source level debugging unless you regenerate
the .LIB with debug options on, in which case you should also specify no
optimization since under either compiler, debugging can get messy with
any optimizations on.

If you feel that a module in the library is causing a problem, we suggest
copying the source code directly into your program for test purposes and
then deleting it when you're done. If it actually IS the cause of a
problem, please let us know and we will fix the library. Most of these
functions have been in use for years and those which have been generated
more recently have gone through extensive testing by several users.


4.0 Utilities
=============

There are two classes of utilities associated with hhstring. First, there
are the utilities which facilitate the use of the library, and which are
provided along with the libarary. These are funcfind (the on-line
function finder), make_man (which will create the manual from the .C
files and the MANUAL.RAW file), cprint (a "pretty printer" which can be
used to print the .C files in the form which they are designed to be
printed in) and test_str/datetest (the test programs which you should use
if you modify the library). These utilities are described in section 4.1.

Second, there are the library creation and maintenance utilities which
are used to create and maintain the library but which are not
distributed with the library. These are available separately if you want
to use them to create/maintain your own library or to modify hhstring.
They are not REQUIRED in order to modify hhstring, they just make it easy
do a complete job of creating/maintaining/modifying any library,
including hhstring. They are described in section 4.2.


4.1 hhstring Utilities
======================

This secton describes the utilities which are supplied with hhstring. For
the utilities test_str and datetest, source code is provided as part of
the hhstring package. Source code for the others is available as part of
the library creation/maintainance toolkit discussed in section 4.2.







page 15 The Hobbit House String Library

4.1.1 funcfind
==============

With over 250 functions in the library, and MAJOR similarities among
various groups of functions, it can be a little intimidating to try to
remember just how all of the names are structured so as to come up with
the name of the function you need for a particular application.
FUNCFIND.EXE is the on-line entry in a two-pronged attack on that problem
(the other being the KWIC index, described in section 2.4, which is more
designed for hard-copy reference material).

FUNCFIND.EXE lists all of the keywords which occur in the source listings
and uses them to find the function you are looking for. Click on any
combination of keywords, and the one's you've chosen are ANDed together
to select all functions which contain ALL of those keywords. The
functions names are then listed, in a separate window, and if you want
more details about the function, you may click on any of the names in the
function name window to get a description of that function.

This is very much a "hands-on" tool, and a minute or two of playing
around with it will tell you far more than could be described in several
pages of written description, so ... go play!


4.1.2 make_man
==============

The manual file (HHSTRING.MAN) consists primarily of a "printed" form of
the .C files. We also want to give you a copy of the .C files themselves,
but it just doesn't make sense to provide two copies of the same
information, especially when that information consists of a very large
number of bytes.

We have dealt with this situation by providing:

o the .C files
o a "raw" manual file (MANUAL.RAW, which has no pagination and no
table of contents for the function listings)
o a utility (MAKE_MAN.EXE) which puts it all together, including
pagination, to create the HHSTRING.MAN file.


4.1.3 test_str and datetest
===========================

Although each function has a code snippet which gets compiled and
executed every time the code for the function changes, that leaves two
unresolved issues regarding the testing of the string. First, the code
snippets are always compiled under Borland but only occassionally under
Microsoft, and second, the code snippets don't show function interaction.
That is, a function could be modified in a way that does not show any
problem with its code snippet since the change is consistent with what
the code snipped tests for, but the change could cause a problem when
another function in the library calls the one that has been changed.


The Hobbit House String Library page 16

The solution to both of these problems was to create test file which
fully tests every single function in the library, (including the macros
so that changes in the header file don't get overlooked). The test
program is then compiled under both Borland and Microsoft and when
executed shows that not only does each function work independantly, but
that they are mutually compatible when calling each other.

This technique has identified a number of potential problems during the
development of the library, and we STRONGLY reccommend that if you modify
the library, you update the test file accordingly and use it to make sure
you have not introduced any problems into the library.

Note that the "date" functions are NOT testtest by TEST_STR, but have
their own test program "DATETEST.EXE", which is also provided with the
library package.

By the way, the test_str.exe provided was done under the large memory
model. It's too big to compile under the tiny model unless it is broken
into two test files. Also, test_str has a command line option to report
only errors, rather than reporting on the results of every test. Just
invoke it with F (for Fast) as follows:

test_str F

If you'd like to capture the test results to a file, just do

test_str > myfile


4.1.4 cprint
============

The cprint utility is a very simple "pretty printer" which puts the file
name and a page number at the top of every page of listing. The source
code in hhstring is spaced so as to look good when printed with cprint.


4.2 The Creation and Maintenance Utilities
==========================================

Creating and maintaining a library of this size is a major effort.
Several utilities were developed to facilitate the process. These
utilities are described in the following sections (4.4.1 through 4.4.7).
None of these utilities need be of any concern to you unless you want to
either develop your own library, or modify and maintain this library, in
which case you might want to purchase our library development package
which includes all of these functions. See section 7.0 for ordering
information.


4.2.1 sorc_chk
==============

SORC_CHK.EXE is designed to work with the "function header" format (see
section 2.2) of the Hobbit House Software string library to perform
various tests on the source code files. For example, all of the required

page 17 The Hobbit House String Library

lines in the function header format are tested to see that they are,
first of all, present, and second, not empty. That is, there not only has
to be a line which starts with "KWIC:", it has to have more than just
"KWIC:" or else it is considered empty. The full range of tests performed
by the sorc_chk utility is detailed in the block comments throughout the
body of the source code (see the file SORC_CHK.C).


4.2.2 mak_head
==============

The mak_head utility reads all of the source files and creates a
humonguous header file called keywords.h which is then used to compile
the function finder utility. Keywords.h contains the keywords and key
sentences for each function, plus some additional information needed by
funcfind. The first version of funcfind read in some of the information
now contained in keywords.h and computed the rest. This took over 10
seconds on a 40Mhz 386, so we decided to speed things up by including all
of the information in funcfind.exe. Now, as you can see, funcfind is
essentially instantaneous. Try clicking on the "new" keyword to see what
we mean ("new" happens to be one which pretty much fills up the lower
window).


4.2.3 index
===========

The KWIC index is created from the "KWIC:" lines in the source code files
by the INDEX.EXE utility. For more information, see the INDEX.C file
(Section 4.2.3) and the SORC_CHK utility (Section 4.2.1).


4.2.4 compress/expand
=====================

The compression/expansion utilities used with hhstring are modified
versions of public domain utilites found on bulletin boards. They are
NOT comparable to the ".ZIP" or ".ARJ" or any other commercial products
of that nature, but they get the job done. We use them because they do a
reasonable job and unlike the .ZIP and .ARJ, etc products, they don't
cost us several dollars per diskette for distribution rights.

Unfortunately, we will not even ATTEMPT to support these utilities as
products, so they are not included even if you buy the support package
for the creation/maintenance of libraries. You'll have to either deal
with the commercial vendors for compress/expand utilities, or do as we
have done and come up with your own. Good luck!

If you join the Hobbit House Group, the compression utilities will be
used on your distribution diskettes, which is another way that the Hobbit
House Group saves money for its members.


4.2.5 drwin
===========


The Hobbit House String Library page 18

The findfunc utility uses a "free-ware" (not public domain, but can be
freely used and distributed at no cost) text-based windowing/menu/mouse
library called "drwin". An upgrade of this library, written by Doug
Rodgers of McLean, Virginia, is one of the products being developed under
the auspices of the Hobbit House Group, the distributer of the Hobbit
House Software string library.

If you buy the creation/maintenance utilities, a copy of the no-cost
drwin library will be included. It is NOT documented, to speak of, but
it has been in use for several years, it does a good job, and it has no
known bugs. The function calls used in findfunc are documented well
enough in findfunc that the lack of documentation in drwin need not be
a problem.


4.2.6 protoflt
==============

When working with a library there is occasionally the need to do
something to all of the source files or some subset of the source files.
For example, at one point there was a "latest update: " line in
the description of every function but it was decided that the "compiled/
executed/verified: " line should become the "latest update" line
for the functions and the "latest update: " line had to be deleted
from each of over 250 files. Clearly, this is NOT something that one
would even want to THINK about doing by hand. Similarly, it was
discovered that "occurrence" had been mis-spelled some 234 times in the
source files. What to do, what to do ...

"protoflt" stands for "Prototype Filter". It is a simple program which
handles all of the file and line I/O required to perform various kinds
of filtering on multiple files. It is a "shell" into which you can insert
a very few lines of C code to produce a particular filter for source
files. For example, modifying a spelling mistake in the source files
required the insertion of two lines of C code into protoflt, a compile,
and an execution, and it was all taken care of.


5.0 Royalties and Distribution Rights
=====================================

There are no royalties of any kind on the Hobbit House Software string
library. You may distribute your own applications, whether commercial,
shareware, public domain, or whatever, with embedded object code from
the string library, without restraint.

What you may NOT do is distribute the library itself, in whole or in
part, in object form or in source form, other than as direct copies of
the shareware version, which may be distributed subject to the
restraints listed in section 1.2.1.


6.0 The Hobbit House Group
==========================

The Hobbit House Group is a cooperative effort designed to save money on

page 19 The Hobbit House String Library

production and advertising costs among software developers. Paul Hinds,
the proprietor of Hobbit House Software, is the founder of The Hobbit
House Group, thus the obvious similarity in names.

If you are in the process of developing software for commercial sale, or
even shareware, you should consider joining the Hobbit House Group. For
full details, see the file HHGROUP.DOC.


7.0 Ordering Information
========================

To order hhstring and/or the library creation/maintenance utilities, see
the file ORDER.DOC; you can print that file and use it as your order
form if you want, or you can just send a check with a note stating what
the check is for. We are unable to accept credit card orders at this
time. If you received the demo package through the ad in the C User's
Journal, you will also have received a printed order form rather than the
ORDER.DOC file.


8.0 Technical Support
=====================

Murphy's Law:

If anything can go wrong, it will.

Or, as they say in California, "shit happens".

Murphy's Corollary #27:

There is no such thing as the FINAL release of any software
product.

Most of hhstring has been in use for years and we would like to think
that it has been beaten to death in recent Beta testing and that no
problems will ever arise. Murphy says otherwise.


Please note:


If you find ANY problem, or have any suggestions for
improvements and/or additions to the library, PLEASE
contact us. The first registered user reporting any
particular bug or making any suggestion which is
incorporated in future versions will receive a free
copy of the next upgrade release.








The Hobbit House String Library page 20

9.0 Function Listings
=====================

This section was generated from the .C files using the MAKE_MAN utility
to do pagination. At the time of creation, owners of the commercial
package (but not the demo package) will have been asked whether or
not they wish for the source code to be included in the manual.


atoh ........................................................ 21
atoh2 ....................................................... 22
atolh ....................................................... 23
atolh2 ...................................................... 24
atoo ........................................................ 26
atoo2 ....................................................... 27
btoc ........................................................ 29
ctob ........................................................ 30
ctod ........................................................ 31
ctoh ........................................................ 32
date_without ................................................ 33
date_withpad ................................................ 35
dtoc ........................................................ 37
fnconv_1to2 ................................................. 38
fnconv_2to1 ................................................. 40
htoc ........................................................ 42
isfilename .................................................. 43
make_date_without ........................................... 45
make_date_withpad ........................................... 47
ptrfirstblank ............................................... 49
ptrfirstchr ................................................. 50
ptrfirstchri ................................................ 51
ptrfirstdig ................................................. 52
ptrfirstgr .................................................. 53
ptrfirsthex ................................................. 54
ptrfirstnotblank ............................................ 55
ptrfirstnotchr .............................................. 56
ptrfirstnotchri ............................................. 57
ptrfirstnotdig .............................................. 58
ptrfirstnotgr ............................................... 59
ptrfirstnothex .............................................. 60
ptrfirstnotrange ............................................ 61
ptrfirstnottextterm ......................................... 62
ptrfirstnotwhite ............................................ 63
ptrfirstnotwordterm ......................................... 64
ptrfirstrange ............................................... 65
ptrfirstsub ................................................. 66
ptrfirstsubi ................................................ 67
ptrfirsttext ................................................ 68
ptrfirsttextterm ............................................ 69
ptrfirstwhite ............................................... 70
ptrfirstword ................................................ 71
ptrfirstwordterm ............................................ 72
ptrlastblank ................................................ 73
ptrlastchr .................................................. 74
ptrlastchri ................................................. 75

The Hobbit House String Library

ptrlastdig .................................................. 76
ptrlastgr ................................................... 77
ptrlasthex .................................................. 78
ptrlastnotblank ............................................. 79
ptrlastnotchr ............................................... 80
ptrlastnotchri .............................................. 81
ptrlastnotdig ............................................... 82
ptrlastnotgr ................................................ 83
ptrlastnothex ............................................... 84
ptrlastnotrange ............................................. 85
ptrlastnottextterm .......................................... 86
ptrlastnotwhite ............................................. 87
ptrlastnotwordterm .......................................... 88
ptrlastrange ................................................ 89
ptrlastsub .................................................. 90
ptrlastsubi ................................................. 91
ptrlasttext ................................................. 92
ptrlasttextterm ............................................. 93
ptrlastwhite ................................................ 94
ptrlastword ................................................. 95
ptrlastwordterm ............................................. 96
ptrnextblank ................................................ 97
ptrnextchr .................................................. 99
ptrnextchri ................................................. 101
ptrnextdig .................................................. 103
ptrnextdig .................................................. 105
ptrnextgr ................................................... 107
ptrnexthex .................................................. 109
ptrnextnotblank ............................................. 111
ptrnextnotchr ............................................... 113
ptrnextnotchri .............................................. 115
ptrnextnotgr ................................................ 117
ptrnextnothex ............................................... 119
ptrnextnotrange ............................................. 121
ptrnextnottextterm .......................................... 123
ptrnextnotwhite ............................................. 125
ptrnextnotwordterm .......................................... 127
ptrnextrange ................................................ 129
ptrnextsub .................................................. 131
ptrnextsubi ................................................. 133
ptrnexttext ................................................. 135
ptrnexttextterm ............................................. 137
ptrnextwhite ................................................ 139
ptrnextword ................................................. 141
ptrnextwordterm ............................................. 143
ptrprevblank ................................................ 145
ptrprevchr .................................................. 146
ptrprevchri ................................................. 147
ptrprevdig .................................................. 148
ptrprevgr ................................................... 149
ptrprevhex .................................................. 150
ptrprevnotblank ............................................. 151
ptrprevnotchr ............................................... 152
ptrprevnotchri .............................................. 153
ptrprevnotdig ............................................... 154
ptrprevnotgr ................................................ 155

The Hobbit House String Library

ptrprevnothex ............................................... 156
ptrprevnotrange ............................................. 157
ptrprevnottextterm .......................................... 158
ptrprevnotwhite ............................................. 159
ptrprevnotwordterm .......................................... 160
ptrprevrange ................................................ 161
ptrprevsub .................................................. 162
ptrprevsubi ................................................. 163
ptrprevtext ................................................. 164
ptrprevtextterm ............................................. 166
ptrprevwhite ................................................ 167
ptrprevword ................................................. 168
ptrprevwordterm ............................................. 170
ptrthistext ................................................. 171
ptrthisword ................................................. 172
strblank .................................................... 173
strblanktotab ............................................... 174
strcenter ................................................... 176
strcentern .................................................. 178
strcenternew ................................................ 180
strcenternnew ............................................... 182
strchecksuma ................................................ 184
strchecksumia ............................................... 185
strchecksumil ............................................... 186
strchecksuml ................................................ 187
strchrcount ................................................. 188
strchrcounti ................................................ 189
strchrdel ................................................... 190
strchrdelgr ................................................. 191
strchrdelgrnew .............................................. 192
strchrdeli .................................................. 194
strchrdelinew ............................................... 195
strchrdelnew ................................................ 197
strchrdelrange .............................................. 199
strchrdelrangenew ........................................... 200
strchrfromc ................................................. 202
strchrrpl ................................................... 204
strchrrpli .................................................. 205
strchrrplinew ............................................... 206
strchrrplnew ................................................ 208
strchrtoc ................................................... 210
strcode1 .................................................... 212
strcode2 .................................................... 214
strcomma .................................................... 216
strcommaf ................................................... 217
strcommafnew ................................................ 218
strcommafri ................................................. 220
strcommafrl ................................................. 221
strcommafrui ................................................ 222
strcommafrul ................................................ 223
strcomman ................................................... 224
strcommanew ................................................. 226
strcommannew ................................................ 228
strcommatoi ................................................. 230
strcommatol ................................................. 231
strcommatoui ................................................ 232

The Hobbit House String Library

strcommatoul ................................................ 233
strdate1 .................................................... 234
strdate2 .................................................... 235
strdate3 .................................................... 236
strdate4 .................................................... 237
strdate5 .................................................... 238
strdate6 .................................................... 239
strdate7 .................................................... 240
strdateconv ................................................. 241
strend ...................................................... 242
streos ...................................................... 243
strfromc .................................................... 244
strindex .................................................... 246
strinsert ................................................... 247
strinsertnew ................................................ 248
strisempty .................................................. 250
striswhite .................................................. 252
strleft ..................................................... 253
strleftnew .................................................. 254
strlenmax ................................................... 255
strlenmin ................................................... 256
strlfdel .................................................... 257
strlfdelnew ................................................. 258
strlfjust ................................................... 259
strlfjustnew ................................................ 260
strlfpad .................................................... 262
strlfpadnew ................................................. 263
strlfrot .................................................... 264
strlfrotnew ................................................. 265
strlfset .................................................... 266
strlfsetnew ................................................. 267
strlfsh ..................................................... 269
strlfshnew .................................................. 270
strlfsize ................................................... 271
strlfsizenew ................................................ 272
strlftrim ................................................... 274
strlftrimnew ................................................ 275
strmid ...................................................... 276
strmiddel ................................................... 277
strmiddelnew ................................................ 278
strmidn ..................................................... 280
strmidnew ................................................... 282
strmidnnew .................................................. 284
strmidpad ................................................... 286
strmidpadnew ................................................ 288
strmidset ................................................... 290
strmidsetnew ................................................ 291
strrepeat ................................................... 293
strrepeatn .................................................. 294
strreverse .................................................. 296
strreversenew ............................................... 297
strright .................................................... 298
strrightnew ................................................. 299
strrtdel .................................................... 301
strrtdelnew ................................................. 302
strrtjust ................................................... 303

The Hobbit House String Library

strrtjustnew ................................................ 304
strrtpad .................................................... 306
strrtpadnew ................................................. 307
strrtrot .................................................... 308
strrtrotnew ................................................. 309
strrtset .................................................... 310
strrtsetnew ................................................. 311
strrtsh ..................................................... 312
strrtshnew .................................................. 313
strrtsize ................................................... 314
strrtsizenew ................................................ 315
strrttrim ................................................... 317
strrttrimnew ................................................ 318
strsubcount ................................................. 319
strsubcounti ................................................ 320
strsubdel ................................................... 321
strsubdelall ................................................ 322
strsubdelallnew ............................................. 323
strsubdeli .................................................. 324
strsubdeliall ............................................... 325
strsubdeliallnew ............................................ 326
strsubdelinew ............................................... 327
strsubdelnew ................................................ 328
strsubrpl ................................................... 329
strsubrplall ................................................ 330
strsubrplallnew ............................................. 332
strsubrpli .................................................. 334
strsubrpliall ............................................... 335
strsubrpliallnew ............................................ 337
strsubrplinew ............................................... 339
strsubrplnew ................................................ 341
strtabtoblank ............................................... 343
strtextfirst ................................................ 345
strtextget .................................................. 347
strtextlast ................................................. 349
strtextnext ................................................. 351
strtextprev ................................................. 353
strtextthis ................................................. 355
strtoc ...................................................... 357
strtolower .................................................. 358
strtolowernew ............................................... 359
strtoupper .................................................. 360
strtrim ..................................................... 361
strtrimnew .................................................. 362
strwordfirst ................................................ 364
strwordget .................................................. 365
strwordlast ................................................. 367
strwordnext ................................................. 368
strwordprev ................................................. 370
strwordthis ................................................. 372
strxcat ..................................................... 374
strxcatn .................................................... 375
strzero ..................................................... 377




The Hobbit House String Library



ATOH.C file date: 03/13/93 page 1 of 1 ATOH.C


/* atoh
Hobbit House Software

copyright(c) 1992, 1993

function: atoh (ASCII TO Hex conversion)

KWIC: %convert an %ASCII %hex string to a numerical value

syntax: #include "hhstring.h"
unsigned int atoh(char *hexstring)

description: converts hexstring to an unsigned integer, interpreting
it as an ASCII-hex string

returns: the unsigned integer represented by the ASCII string

comments: There is no test for overflow. If the input string
generates more than 4 nibbles of hex, the rightmost
4 nibbles will be used to fill the result.

keywords: string, ASCII, hex, convert, numeric, integer

key sentence: converts an ASCII-hex string to an unsigned integer,
ignoring leading whitespace

see also: atoh atoh2 atolh atolh2

usage example: compiled/executed/verified on 1/17/93

printf("\n%4.4x", atoh(" dead "));
printf("\n%4.4X", atoh("beef"));

dead
BEEF


Hobbit House Software
*/















The Hobbit House String Library page 21



ATOH2.C file date: 03/13/93 page 1 of 1 ATOH2.C


/* atoh2
Hobbit House Software

copyright(c) 1992, 1993

function: atoh2 (ASCII TO Hex conversion)

KWIC: %convert an ASCII %hex string to a numerical value and
tell how many hex characters were in the string

syntax: #include "hhstring.h"
unsigned int atoh2(int *nchars, char *hexstring)

description: converts hexstring to an unsigned integer, interpreting
it as an ASCII-hex string and ignoring any leading
whitespace. Puts the number of hex characters which were
found in the string into nchars

returns: the integer represented by the ASCII string (also puts
the number of hex characters in the string back into a
calling program variable)

comments: There is no test for overflow. If the input string
generates more than 4 nibbles of hex, the rightmost
4 nibbles will be used to fill the result.

keywords: string, ASCII, hex, convert, numeric, integer

key sentence: converts an ASCII-hex string to an unsigned integer,
ignoring any leading whitespace, and tells how many hex
characters are in the string

see also: atoh atoh2 atolh atolh2

usage example: compiled/executed/verified on 1/17/93

int nchars;
printf("\n%4.4x", atoh2(&nchars, " dead "));
printf(" %d", nchars);
printf("\n%4.4X", atoh2(&nchars, "1a"));
printf(" %d", nchars);

dead 4
001A 2

Hobbit House Software
*/







page 22 The Hobbit House String Library



ATOLH.C file date: 03/13/93 page 1 of 1 ATOLH.C


/* atolh
Hobbit House Software

copyright(c) 1992, 1993

function: atolh (ASCII TO Long Hex conversion)

KWIC: %convert an ASCII %hex string to a numerical value

syntax: #include "hhstring.h"
unsigned long atolh(char *hexstring)

description: converts hexstring to an unsigned long (32-bit) hex
integer, interpreting it as an ASCII-hex string;
leading whitespace is ignored

returns: the long integer represented by the ASCII string

comments: There is no test for overflow. If the input string
generates more than 8 nibbles of hex, the rightmost
8 nibbles will be used to fill the long result.

keywords: string, ASCII, hex, convert, numeric, long

key sentence: converts an ASCII-hex string to an unsigned long
numeric value, ignoring any leading whitespace

see also: atoh atoh2 atolh atolh2

usage example: compiled/executed/verified on 1/17/93

printf("\n%8.8lx", atolh(" deadbeef "));
printf("\n%8.8lx", atolh("123456789"));

deadbeef
23456789


Hobbit House Software
*/














The Hobbit House String Library page 23



ATOLH2.C file date: 03/13/93 page 1 of 2 ATOLH2.C


/* atolh2
Hobbit House Software

copyright(c) 1992, 1993

function: atolh2 (ASCII TO Long Hex conversion)

KWIC: %convert an ASCII %hex string to a numeric value

syntax: #include "hhstring.h"
unsigned long atolh2(int *nchars, char *hexstring)

description: converts hexstring to an unsigned long value, ignoring
any leading whitespace and interpreting it as an ASCII-
hex string. The number of hex characters in the string
is put back into nchar (which, please note, is a pointer
here, not a value)

returns: the unsigned long integer represented by the ASCII string
(also puts the number of hex characters in the string back
into a calling program variable)

comments: There is no test for overflow. If the input string
generates more than 8 nibbles of hex, the rightmost
8 nibbles will be used to fill the long result.

keywords: string, ASCII, hex, convert, numeric, long

key sentence: converts an ASCII-hex string into an unsigned long,
ignoring any leading whitespace; also tells how many
hex characters are in the string

see also: atoh atoh2 atolh atolh2





















page 24 The Hobbit House String Library



ATOLH2.C file date: 03/13/93 page 2 of 2 ATOLH2.C




usage example: compiled/executed/verified on 1/17/93

int nchars;
printf("\n%lx", atolh2(&nchars, " deadbeef "));
printf(" %d", nchars);
printf("\n%lx", atolh2(&nchars, "dead"));
printf(" %d", nchars);
printf("\n%lx", atolh2(&nchars, "123456789"));
printf(" %d", nchars);

deadbeef 8
dead 4
23456789 9


Hobbit House Software
*/



































The Hobbit House String Library page 25



ATOO.C file date: 03/13/93 page 1 of 1 ATOO.C


/* atoo
Hobbit House Software

copyright(c) 1992, 1993

function: atoo (ASCII TO Octal conversion)

KWIC: %convert an ASCII %octal string to a numeric value

syntax: #include "hhstring.h"
unsigned int atoo(char *octalstring)

description: converts octalstring to an unsigned integer, interpreting
it as ASCII-octal and ignoring any leading whitespace

returns: the integer represented by the ASCII string

comments: There is no test for overflow. If the input string
generates more than 15 bits of integer value, then
the rightmost 5 characters will be used in filling
the integer. The function will properly interpret
a 6-character string starting with 1 (which is, of
course, a valid octal number).

keywords: string, ASCII, octal, convert, numeric

key sentence: converts an ASCII-octal string to an unsigned integer,
ignoring any leading whitespace

see also: atoh atohl atoo atoo2

usage example: compiled/executed/verified on 1/17/93

printf("\n%4.4x", atoo(" 123456"));

a72e




Hobbit House Software
*/












page 26 The Hobbit House String Library



ATOO2.C file date: 03/13/93 page 1 of 2 ATOO2.C


/* atoo2
Hobbit House Software

copyright(c) 1992, 1993

function: atoo2 (ASCII TO Octal conversion, version 2)

KWIC: %convert an ASCII %octal string to a numeric value

syntax: #include "hhstring.h"
unsigned int atoo2(int *nchars, char *octalstring)

description: converts octalstring to an unsigned integer, interpreting
it as an ASCII-octal string and ignoring any leading
whitespace

returns: the integer represented by the ASCII string (also puts
the number of characters in the string back into a
variable in the calling program)

comments: There is no test for overflow. If the input string
generates more than 15 bits of integer value, then
the rightmost 5 characters will be used in filling
the integer. The function will properly interpret
a 6-character string starting with 1 (which is, of
course, a valid octal number).

keywords: string, ASCII, octal, convert, numeric

key sentence: converts an ASCII-octal string into an unsigned integer,
ignoring leading whitespace and telling how many octal
characters are in the converted string

see also: atoh atohl atoo atool
atoh2 atohl2 atoo2 atool2



















The Hobbit House String Library page 27



ATOO2.C file date: 03/13/93 page 2 of 2 ATOO2.C




usage example: compiled/executed/verified on 1/17/93

int nchars;
printf("\n%x", atoo2(&nchars, " 123456 "));
printf(" %d", nchars);
printf("\n%x", atoo2(&nchars, "17"));
printf(" %d", nchars);

a72e 6
f 2


Hobbit House Software
*/






































page 28 The Hobbit House String Library



BTOC.C file date: 03/13/93 page 1 of 1 BTOC.C


/* btoc
Hobbit House Software

copyright(c) 1992, 1993

function: btoc (Binary digit TO ASCII Character)

KWIC: %convert a %binary digit to the corresponding ASCII
character.

syntax: #include "hhstring.h"
char btoc(int digit)

description: if digit is 1, return '1', if digit is 0, return '0',
otherwise returns 0 to show error

returns: success: the ASCII character corresponding to the
input digit
failure: 0 (the character isn't a binary digit)

comments: none

keywords: character, ASCII, binary, convert, numeric

key sentence: converts an integer containing either a 0 or a 1 into
'0' or '1' but returns a binary 0 for other input

see also: btoc dtoc htoc
ctob ctod ctoh

usage example: compiled/executed/verified on 1/17/93

int digit = 1;
printf("%d %c", digit, btoc(digit));

1 1


Hobbit House Software
*/














The Hobbit House String Library page 29



CTOB.C file date: 03/13/93 page 1 of 1 CTOB.C


/* ctob
Hobbit House Software

copyright(c) 1992, 1993

function: ctob (Character TO Binary digit)

KWIC: %convert an ASCII character to the equivalent %binary
digit

syntax: #include "hhstring.h"
int ctob(char c)

description: if c is '0', returns 0 and if c is '1', returns 1,
otherwise returns 2 to show bad input

returns: on success: the digit derived from the input character
on failure: 2 (input character is not a binary digit)

comments: none

keywords: character, ASCII, binary, convert, numeric

key sentence: converts an ASCII-binary character to an integer. That is,
an input of '0' returns 0, and input of '1' returns 1, and
anything else in returns 2 (failure flag)

see also: btoc dtoc htoc
ctob ctod ctoh

usage example: compiled/executed/verified on 1/17/93

char c = '1';
printf("%c %d", c, ctob(c));

1 1


Hobbit House Software
*/














page 30 The Hobbit House String Library



CTOD.C file date: 03/13/93 page 1 of 1 CTOD.C


/* ctod
Hobbit House Software

copyright(c) 1992, 1993

function: ctod (Character TO Decimal digit)

KWIC: %convert an ASCII %decimal digit to a numeric value

syntax: #include "hhstring.h"
int ctod(char c)

description: converts c to the corresponding integer value,
interpreting c as an ASCII-decimal digit

returns: on success: the digit derived from the input character
on failure: 10 (input character is not a decimal digit)

comments: none

keywords: character, ASCII, decimal, convert, numeric

key sentence: converts an ASCII-decimal digit to a an integer; returns
the integer 10 if the input is not a decimal digit

see also: btoc dtoc htoc
ctob ctod ctoh

usage example: compiled/executed/verified on 1/17/93

char c = '5';
printf("%c %d", c, ctod(c));

5 5


Hobbit House Software
*/
















The Hobbit House String Library page 31



CTOH.C file date: 03/13/93 page 1 of 1 CTOH.C


/* ctoh
Hobbit House Software

copyright(c) 1992, 1993

function: ctoh (Character TO Hexidecimal digit)

KWIC: %convert an ASCII %hex character to a numeric value

syntax: #include "hhstring.h"
int ctoh(char c)

description: converts c to an integer, interpreting it as an ASCII-hex
character.

returns: on success: the digit derived from the input character
on failure: 16 (input character is not a hex digit)

comments: none

keywords: character, ASCII, hex, convert, numeric

key sentence: converts an ASCII-hex digit to its integer value

see also: btoc dtoc htoc
ctob ctod ctoh

usage example: compiled/executed/verified on 1/17/93

char c = 'f';
printf("%c %d", c, ctoh(c));

f 15


Hobbit House Software
*/

















page 32 The Hobbit House String Library



DATESUB2.C file date: 03/13/93 page 1 of 2 DATESUB2.C


/* date_without
Hobbit House Software

copyright(c) 1992, 1993

function: date_without (get the current date and make it into a DATE
string WITOUT blanks or zeros)

KWIC: create a %date string without a pad character

syntax: #include
#include "hhstring.h"
char *date_without(char *date_string, char *separator)

description: date_string is filled with a string containing today's
date in a format which uses the specified separator but
has no pad characters

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



this is a support function for the functions strdate1
throught strdate7

keywords: date

key sentence: a support function for strdate<1->7>, this function gets
the current date and makes it into a DATE string without
any pad character (normally ' ' or '0')

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad












The Hobbit House String Library page 33



DATESUB2.C file date: 03/13/93 page 2 of 2 DATESUB2.C




usage example: compiled/executed/verified on 2/25/93


see the file TESTDATE.C



Hobbit House Software
*/











































page 34 The Hobbit House String Library



DATESUB1.C file date: 03/13/93 page 1 of 2 DATESUB1.C


/* date_withpad
Hobbit House Software

copyright(c) 1992, 1993

function: date_withpad (get the current date and make it into a DATE
string WITH the specified PAD character

KWIC: create a %date string with a pad character

syntax: #include
#include "hhstring.h"
char *date_withpad(char *date_string, char *separator,
char padchar)

description: date_string is filled with a string containing todays
date in a format which uses the specified separator and
the specified pad character

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



this is a support function for the functions strdate1
throught strdate7

keywords: date

key sentence: a support function for strdate<1->7>, this function gets
the current date and makes it into a DATE string WITH a
specified pad character (normally ' ' or '0')

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad











The Hobbit House String Library page 35



DATESUB1.C file date: 03/13/93 page 2 of 2 DATESUB1.C




usage example: compiled/executed/verified on 2/25/93


see the file TESTDATE.C



Hobbit House Software
*/











































page 36 The Hobbit House String Library



DTOC.C file date: 03/13/93 page 1 of 1 DTOC.C


/* dtoc
Hobbit House Software

copyright(c) 1992, 1993

function: dtoc (Decimal digit TO ASCII Character)

KWIC: %convert an %integer to an ASCII-decimal digit

syntax: #include "hhstring.h"
char dtoc(int digit)

description: converts digit to the corresponding ASCII-decimal digit or
returns 0 if the

returns: success: the ASCII character corresponding to the
input digit
failure: 0 (the number is not in the range 0 to 9)

comments: none

keywords: character, ASCII, decimal, convert, numeric

key sentence: converts an integer in the range 0 to 9 to the
corresponding ASCII-decimal digit

see also: btoc dtoc htoc
ctob ctod ctoh

usage example: compiled/executed/verified on 1/17/93

int dig = 5;
printf("%d %c", dig, dtoc(dig));

5 5


Hobbit House Software
*/















The Hobbit House String Library page 37



FNC12.C file date: 03/13/93 page 1 of 2 FNC12.C


/* fnconv_1to2
Hobbit House Software

copyright(c) 1992, 1993

function: fnconv_1to2 (File Name CONVersion, type 1 TO type 2)

KWIC: %converts %file name format

syntax: #include "hhstring.h"
void fnconv_1to2(char *fname);

description: converts fname from a type 1 format to a type 2 format.
The designation of "type 1" and "type 2" to these two
"types" is purely arbitrary and has no relationship to
any naming convention outside this library

file format 1 is "name.ext" with a period and no embedded
spaces
file format 2 is "name ext", with exactly 12 characters
including however many spaces it takes in
the middle to pad the name and however many
it takes at the end to pad the extent

examples:
format 1: "sub1.h"
format 2: "sub2 h "

returns: a pointer to the converted file name

comments: the file name must have enough space reserved to
accommodate the expanded name under the type 2 format.

Since the file name string is modified in the calling
program's space, use of this function's return value
is optional.

keywords: filename, convert

key sentence: converts a file name from the format containing a period
but no blanks to the one with exactly 12 characters and
no period

see also: fnconv_2to1










page 38 The Hobbit House String Library



FNC12.C file date: 03/13/93 page 2 of 2 FNC12.C




usage example: compiled/executed/verified on 1/17/93

char *filename = "12345678.123";
printf("\n-->%s<--", filename);
strcpy(filename, "sub1.h");
fnconv_1to2(filename);
printf("\n-->%s<--", filename);

-->12345678.123<--
-->sub1 h <--


Hobbit House Software
*/






































The Hobbit House String Library page 39



FNC21.C file date: 03/13/93 page 1 of 2 FNC21.C


/* fnconv_2to1
Hobbit House Software

copyright(c) 1992, 1993

function: fnconv_2to1 (File Name CONVersion, type 2 TO type 1)

KWIC: %converts %file name format

syntax: #include "hhstring.h"
char *fnconv_2to1(char *fname);

description: converts fname from a type 2 format to a type 1 format.
The designation of "type 1" and "type 2" to these two
"types" is purely arbitrary and has no relationship to
any naming convention outside this library

file format 1 is "name.ext" with a period and no embedded
spaces
file format 2 is "name ext", with exactly 12 characters
including however many spaces it takes in
the middle to pad the name and however many
it takes at the end to pad the extent

examples:
format 1: "sub1.h"
format 2: "sub2 h "

returns: a pointer to the converted file name

comments: Since the file name string is modified in the calling
program's space, use of this function's return value
is optional.

keywords: filename, convert

key sentence: converts a file name from the format containing exactly
12 characters and no period to the one with no blanks
and a period

see also: fnconv_1to2













page 40 The Hobbit House String Library



FNC21.C file date: 03/13/93 page 2 of 2 FNC21.C




usage example: compiled/executed/verified on 1/17/93

char *filename = "1234 1 ";
printf("\n-->%s<--", filename);
fnconv_2to1(filename);
printf("\n-->%s<--", filename);

-->1234 1 <--
-->1234.1<--


Hobbit House Software
*/







































The Hobbit House String Library page 41



HTOC.C file date: 03/13/93 page 1 of 1 HTOC.C


/* htoc
Hobbit House Software

copyright(c) 1992, 1993

function: htoc (Hexadecimal digit TO ASCII Character)

KWIC: %convert a %hexadecimal digit to the corresponding ASCII
character.

syntax: #include "hhstring.h"
char htoc(int digit)

description: converts digit to its corresponding ASCII-hex digit

returns: success: the ASCII-hex character corresponding to the
input digit
failure: 0 (the input digit isn't in the range 0 to 15)

comments: none

keywords: character, ASCII, hex, convert, numeric

key sentence: converts an integer from 0 to 15 to its corresponding
ASCII-hex digit character

see also: btoc dtoc htoc
ctob ctod ctoh

usage example: compiled/executed/verified on 1/17/93

int dig = 10;
printf("%d %c", dig, htoc(dig));

10 A


Hobbit House Software
*/















page 42 The Hobbit House String Library



FILENAME.C file date: 03/13/93 page 1 of 2 FILENAME.C


/* isfilename
Hobbit House Software

copyright(c) 1992, 1993

function: isfilename (IS this a valid FILE NAME) (not a path name)

KWIC: determine the %validity of a DOS %file name (but not a
DOS path name)

syntax: #include
#include "hhstring.h"
int isfilename(char *filename)

description: examines the filename to see whether or not it is a
valid DOS file name. Paths are NOT allowed. This merely
checks for illegal characters or too-long names or
extents.

returns: 0 for valid file name
-1 if name contains * or ? but is otherwise OK
-2 if name contains invalid characters
-3 if name is too long
-4 if extent is too long
-5 if name is OK other than a meaningless
use of '*'

comments: none

keywords: filename

key sentence: examines a DOS file name (NOT a path name) and reports
on whether or not it is valid and if not, gives some
information about why not

see also: none


















The Hobbit House String Library page 43



FILENAME.C file date: 03/13/93 page 2 of 2 FILENAME.C




usage example: compiled/executed/verified on 2/1/93

printf("\n%d", isfilename("12345678.9ab"));
printf("\n%d", isfilename("*.bak"));
printf("\n%d", isfilename("123<5>78.9ab"));
printf("\n%d", isfilename("123456789.ab"));
printf("\n%d", isfilename("1234567.89ab"));
printf("\n%d", isfilename("*234*.abc"));

0
-1
-2
-3
-4
-5


Hobbit House Software
*/

































page 44 The Hobbit House String Library



DATESUB4.C file date: 03/13/93 page 1 of 2 DATESUB4.C


/* make_date_without
Hobbit House Software

copyright(c) 1992, 1993

function: make_date_without (MAKE a DATE string WITHOUT any blanks
or zeros. Put into the calling
function's string.)

this is a support function for the functions strdate1
throught strdate7

KWIC: make a %date string without a pad character

syntax: #include
#include
#include "hhstring.h"
char *make_date_without(char *date_string, char
*separator,
struct date *DATE)


description: uses DATE to create date_string, using separator but no
blanks or 0's

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.




keywords: date

key sentence: a support function for strdate<1->7>, this function makes
a date string, from the data in a data structure, without
any padding (blanks or zeros) and using a given seperator
(normally '-' or '/')

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad






The Hobbit House String Library page 45



DATESUB4.C file date: 03/13/93 page 2 of 2 DATESUB4.C




usage example: compiled/executed/verified on 2/25/93


see the file TESTDATE.C



Hobbit House Software
*/











































page 46 The Hobbit House String Library



DATESUB3.C file date: 03/13/93 page 1 of 2 DATESUB3.C


/* make_date_withpad
Hobbit House Software

copyright(c) 1992, 1993

function: make_date_withpad (MAKE a DATE string WITH the specified
PAD (blanks or zeros) and put it into
the calling function's string)

this is a support function for the functions strdate1
throught strdate7

KWIC: make a %date string with a pad character

syntax: #include
#include
#include "hhstring.h"
char *make_date_withpad(char *date_string, char
*separator,
struct date *DATE, char padchar)

description: uses DATE to create date_string, using the separator and
padchar supplied (pad is normally '/' or '-')

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.




keywords: date

key sentence: a support function for strdate<1->7>, this function makes
a date string, from the data in a date structure, with a
specified pad character (normally ' ' or '0'), and using a
given seperator (normally '-' or '/')

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad







The Hobbit House String Library page 47



DATESUB3.C file date: 03/13/93 page 2 of 2 DATESUB3.C




usage example: compiled/executed/verified on 2/25/93


see the file TESTDATE.C



Hobbit House Software
*/











































page 48 The Hobbit House String Library



FIRBLK.C file date: 03/13/93 page 1 of 1 FIRBLK.C


/* ptrfirstblank
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstblank (get PoinTeR to FIRST BLANK)

KWIC: get the pointer to the %first %blank in a string

syntax: #include "hhstring.h"
char *ptrfirstblank(char *instring)

description: this function returns a pointer to the first blank in
instring

returns: a pointer to the first blank (NULL if EOS found before a
blank is found)

comments: none

keywords: pointer, first, character, blank

key sentence: gets the pointer to the first occurrence in a string of a
blank character

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/31/93

char Astring[80] = "thisisthesample string";
char Bstring[80] = "no_blanks_in_this_string";
printf("\n%s", ptrfirstblank(Astring));
printf("\n%s", ptrfirstblank(Bstring));

string
(null)


Hobbit House Software
*/













The Hobbit House String Library page 49



FIRCHR.C file date: 03/13/93 page 1 of 1 FIRCHR.C


/* ptrfirstchr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstchr (get PoinTeR to FIRST occurrence of a
specified CHaRacter)

KWIC: get the pointer to the %first occurrence in a string of a
specified %character

syntax: #include "hhstring.h"
char *ptrfirstchr(char *ptr)

description: this function returns a pointer to the first occurrence in
memory of the specified character, starting at the
beginning of the specified string. If the string does not
contain the character, the return pointer will be NULL.

returns: a pointer to the first occurrence of the character (NULL
if the character does not occur)

comments: none

keywords: pointer, first, character

key sentence: gets the pointer to the first occurrence in a string of a
specified character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 1/31/93

char Astring[80] = "this is the sample string";
printf("\n%s", ptrfirstchr(Astring, 'm'));
printf("\n%s", ptrfirstchr(Astring, 'z'));

mple string
(null)


Hobbit House Software
*/











page 50 The Hobbit House String Library



FIRCHRI.C file date: 03/13/93 page 1 of 1 FIRCHRI.C


/* ptrfirstchri
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstchri (get PoinTeR to FIRST occurrence of a
specified CHaRacter, Independant of case)

KWIC: get the pointer to the %first occurrence in a string of a
specified %character, %independent of case

syntax: #include "hhstring.h"
char *ptrfirstchri(char *ptr)

description: this function returns a pointer to the first occurrence in
memory of the specified character, independent of case,
starting at the beginning of the specified string. If the
string does not contain the character, the return pointer
will be NULL.

returns: a pointer to the first occurrence of the character
regardless of case (NULL if the character does not occur)

comments: none

keywords: pointer, first, character, case-independent

key sentence: gets the pointer to the first occurrence in a string,
independent of case, of a specified character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 1/31/93

char Astring[80] = "this is the Sample string";
printf("\n%s", ptrfirstchri(Astring, 'S'));
printf("\n%s", ptrfirstchri(Astring, 'z'));

s is the Sample string
(null)


Hobbit House Software
*/










The Hobbit House String Library page 51



FIRDIG.C file date: 03/13/93 page 1 of 1 FIRDIG.C


/* ptrfirstdig
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstdig (get PoinTeR to FIRst decimal DIGit)

KWIC: get the pointer to the %first %decimal digit in a string

syntax: #include "hhstring.h"
char *ptrfirstdig(char *ptr)

description: this function returns a pointer to the first decimal digit
in a string.

returns: a pointer to the first decimal digit encountered, or a
NULL if none are found

comments: none

keywords: pointer, first, decimal, digit

key sentence: gets the pointer to the first occurrence in a string of
any
character which is a decimal digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char Astring[80] = "123 af69 is not it ";
printf("\n%s", ptrfirstdig(Astring));
printf("\n%s", ptrfirstdig(Astring + 3));
printf("\n%s", ptrfirstdig(Astring + 10));

123 af69 is not it
69 is not it
(null)


Hobbit House Software
*/











page 52 The Hobbit House String Library



FIRGR.C file date: 03/13/93 page 1 of 1 FIRGR.C


/* ptrfirstgr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstgr (get PoinTeR to FIRST occurrence of
any character in a GRoup of characters)

KWIC: get the pointer to the %first occurance of any one of a
%group of characters

syntax: #include "hhstring.h"
char *ptrfirstgr(char *instring, char *chars)

description: instring is scanned for the occurrence of any character
from the chars string

returns: a pointer to the character found, or a NULL if none
are found

comments: none

keywords: pointer, first, character, group

key sentence: gets the pointer to the first occurrence in a string of
any character which is in a given group of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}group

usage example: compiled/executed/verified on 2/25/93

char *Astring = "This is it: the Sample string";
printf("\n%s", ptrfirstgr(Astring, ".,;:!?"));
printf("\n%s", ptrfirstgr(Astring, "+-=()"));

: the Sample string
(null)


Hobbit House Software
*/












The Hobbit House String Library page 53



FIRHEX.C file date: 03/13/93 page 1 of 1 FIRHEX.C


/* ptrfirsthex
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirsthex (get PoinTeR to FIRST HEX digit in a string)

KWIC: get the pointer to the %first %hex digit in a string

syntax: #include "hhstring.h"
char *ptrfirsthex(char *ptr)

description: this function returns a pointer to the first hex digit
in memory starting at the given pointer. if the pointer
points at a hex digit, that will be the one pointed to
upon return.

returns: a pointer to the first hex digit encountered

comments: if this function is applied to a string which does not
contain a hex digit, it will return a pointer which is not
in the string, but it WILL return a pointer, assuming it
can find a hex digit somewhere in memory. Be careful!

keywords: pointer, first, hex, digit

key sentence: gets the pointer to the first occurrence in a string of
any character which is a hex digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char Astring[80] = "123 af69 is not it";
printf("\n%s", ptrfirsthex(Astring + 3));
printf("\n%s", ptrfirsthex(Astring + 5));
printf("\n%s", ptrfirsthex(Astring + 10));


af69 is not it
af69 is not it
(null)


Hobbit House Software
*/







page 54 The Hobbit House String Library



FIRNOBK.C file date: 03/13/93 page 1 of 1 FIRNOBK.C


/* ptrfirstnotblank
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnotblank (get PoinTeR to FIRST NOT-BLANK)

KWIC: get the pointer to the %first %non-blank in a string

syntax: #include "hhstring.h"
char *ptrfirstnotblank(char *ptr)

description: this function returns a pointer to the first non-blank in
memory starting at the beginning of the specified string.
If the string contains only blanks, the return pointer
will
be NULL.

returns: a pointer to the first non-blank (NULL if only blanks
are found)

comments: note that the ASCII end of line ('\n') is NOT a blank, so
a string consisting of blanks ended by an EOL will NOT get
a NULL return from this function, it will get a pointer to
the EOL.

keywords: pointer, first, character, not, blank

key sentence: gets the pointer to the first character in a string which
is not a blank

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 12/21/92

char Astring[80] = " this is the sample string";
printf("%s", ptrfirstnotblank(Astring));

this the sample string


Hobbit House Software
*/










The Hobbit House String Library page 55



FIRNOCH.C file date: 03/13/93 page 1 of 1 FIRNOCH.C


/* ptrfirstnotchr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnotchr (get PoinTeR to FIRST character which is
NOT the specified CHaRacter)

KWIC: get the pointer to the %first occurrence of a character
which is not the specified %character

syntax: #include "hhstring.h"
char *ptrfirstnotchr(char *ptr, char *find)

description: this function returns a pointer to the first character
which is not find.

returns: a pointer to the first non-find (NULL if only find is
found)

comments: none

keywords: pointer, first, character, not

key sentence: gets the pointer to the first occurrence in a string of
any character other than a specified character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 12/21/92

char *Astring = "aaaaaaaaThis is the Sample string";
printf("%s", ptrfirstnotchr(Astring, 'a'));

This is the Sample string


Hobbit House Software
*/















page 56 The Hobbit House String Library



FIRNOCI.C file date: 03/13/93 page 1 of 1 FIRNOCI.C


/* ptrfirstnotchri
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnotchri (get PoinTeR to FIRST character which is
NOT the specified CHaRacter, Independant
of case)

KWIC: get the pointer to the %first occurrence of a character
which is not the specified %character, %independent of
case

syntax: #include "hhstring.h"
char *ptrfirstnotchri(char *ptr, char *find)

description: this function returns a pointer to the first character
which is not find in uppercase and not find in lowercase.

returns: a pointer to the first non-find (NULL if only find is
found)

comments: none

keywords: pointer, first, character, not, case-independent

key sentence: gets the pointer to the first occurrence in a string of
any character which, independent of case, is not a
specified character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 12/21/92

char *Astring = "aaaAaaAaaThis is the Sample string";
printf("%s", ptrfirstnotchri(Astring, 'A'));

This is the Sample string


Hobbit House Software
*/












The Hobbit House String Library page 57



FIRNODG.C file date: 03/13/93 page 1 of 1 FIRNODG.C


/* ptrfirstnotdig
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnotdig (get PoinTeR to FIRST character which is
NOT a decimal DIGit)

KWIC: get the pointer to the %first %non-digit in a string

syntax: #include "hhstring.h"
char *ptrfirstnotdig(char *ptr)

description: this function returns a pointer to the first non-digit in
memory starting at the beginning of the specified string.
If the string contains only digits, the return pointer
will
be NULL.

returns: a pointer to the first non-digit (NULL if only digits
are found)

comments: none

keywords: pointer, first, character, not, decimal, digit

key sentence: gets the pointer to the first occurrence in a string of
any character which is not a decimal digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/31/93

char Astring[80] = "123,456.78";
char Bstring[80] = "123456789";
printf("\n%s", ptrfirstnotdig(Astring));
printf("\n%s", ptrfirstnotdig(Bstring));

,456.78
(null)


Hobbit House Software
*/









page 58 The Hobbit House String Library



FIRNOGR.C file date: 03/13/93 page 1 of 1 FIRNOGR.C


/* ptrfirstnotgr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnotgr (get PoinTeR to FIRST occurrence of a
character which is NOT in a GRoup of
characters)

KWIC: get the pointer to the %first occurrence of any character
which is not in a %group of characters

syntax: #include "hhstring.h"
char *ptrfirstnotgr(char *instring, char *chars)

description: returns a pointer to the first occurrence in instring of
any character in chars

returns: a pointer to the first character not in the group, or a
NULL if the string contains only characters in the group

comments: none

keywords: pointer, first, not, character, group

key sentence: gets the pointer to the first occurrence in a string of
any character which is not in a given group of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}group

usage example: compiled/executed/verified on 2/25/93

char *Astring = "...!..This is the Sample string";
printf("\n%s", ptrfirstnotgr(Astring, ".,;:!?"));

This is the Sample string


Hobbit House Software
*/













The Hobbit House String Library page 59



FIRNOHX.C file date: 03/13/93 page 1 of 1 FIRNOHX.C


/* ptrfirstnothex
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnothex (get PoinTeR to FIRST character which is
NOT a HEX digit)

KWIC: get the pointer to the %first %non-hexdigit in a string

syntax: #include "hhstring.h"
char *ptrfirstnothex(char *ptr)

description: this function returns a pointer to the first non-hexdigit
in memory starting at the beginning of the specified
string.

returns: a pointer to the first non-hexdigit (NULL if only hex
digits are found)

comments: none

keywords: pointer, first, character, not, hex, digit

key sentence: gets the pointer to the first occurrence in a string of
any character which is not a hex digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 12/21/92

char *Astring = "07af:c1be";
printf("%s", ptrfirstnothex(Astring));

:c1be


Hobbit House Software
*/














page 60 The Hobbit House String Library



FIRNORN.C file date: 03/13/93 page 1 of 1 FIRNORN.C


/* ptrfirstnotrange
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnotrange (get PoinTeR to FIRST occurrence of any
character NOT in a RANGE of characters)

KWIC: gets the pointer to the %first occurrence of any character
not in a %range of characters

syntax: #include "hhstring.h"
char *ptrfirstnotrange(char *instring, char c1, char c2)

description: returns a pointer to the first occurrence in instring of
a character not in the range c1 to c2 inclusive

returns: a pointer to the first character not in the range, or a
NULL if the whole string is in the range

comments: none

keywords: pointer, first, character, not, range

key sentence: gets the pointer to the first occurrence in a string of
any character which is not in a given range of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}set

usage example: compiled/executed/verified on 2/25/93

char *Astring = "This_is_it:_the_Sample_string";
printf("\n%s", ptrfirstnotrange(Astring, 'A', 'z'));
printf("\n%s", ptrfirstnotrange(Astring, '!', 'z'));

:_the_Sample_string
(null)


Hobbit House Software
*/












The Hobbit House String Library page 61



FIRNOTT.C file date: 03/13/93 page 1 of 1 FIRNOTT.C


/* ptrfirstnottextterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnottextterm (get PoinTeR to FIRST NOT-TEXT-
TERMinator)

KWIC: get the pointer to the %first %non-text-terminator in a
string

syntax: #include "hhstring.h"
char *ptrfirstnottextterm(char *ptr)

description: this function returns a pointer to the first non-text-
terminator in memory starting at the beginning of the
specified string.

returns: a pointer to the first non-text-terminator or NULL if only
text terminators are found in the string.

comments: a "text word" is a human language construct as opposed to
a "string word" which is simply a set of characters
surrounded by whitespace. The only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however, may also
be terminated by any of these punctuation marks: .!?:;,

keywords: pointer, first, character, not, text, terminator

key sentence: gets the pointer to the first character in a string which
is not a text terminator

see also: ptr< first | last | next | prev >nottextterm

usage example: compiled/executed/verified on 1/31/93

char Astring[80] = " ? ! this is the sample string";
char Bstring[80] = " ? ! . ";
printf("\n%s", ptrfirstnottextterm(Astring));
printf("\n%s", ptrfirstnottextterm(Bstring));

this the sample string
(null)


Hobbit House Software
*/





page 62 The Hobbit House String Library



FIRNOWH.C file date: 03/13/93 page 1 of 1 FIRNOWH.C


/* ptrfirstnotwhite
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnotwhite (get PoinTeR to FIRST NOT-WHITE)

KWIC: get the pointer to the %first %non-whitespace in a string

syntax: #include "hhstring.h"
char *ptrfirstnotwhite(char *ptr)

description: this function returns a pointer to the first non-white
character in memory starting at the beginning of the
specified string. If the string contains only whitespace,
the return pointer will be NULL.

returns: a pointer to the first non-whitespace character (NULL if
only whitespace is found)

comments: note that the ASCII end of line ('\n') is NOT white, so
a string consisting of nothing but an EOL will NOT get a
NULL return from this function, it will get a pointer to
the EOL.

keywords: pointer, first, character, not, whitespace, blank, tab

key sentence: gets the pointer to the first occurrence in a string of
any character which is not whitespace

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 2/19/93

char Astring[80] = "\t\t this is the sample string";
printf("\n%s", ptrfirstnotwhite(Astring));
printf("\n%s", ptrfirstnotwhite(" \t "));

this the sample string
(null)


Hobbit House Software
*/










The Hobbit House String Library page 63



FIRNOWT.C file date: 03/13/93 page 1 of 1 FIRNOWT.C


/* ptrfirstnotwordterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstnotwordterm (get PoinTeR to FIRST NOT-WORD-
TERMinator)

KWIC: get the pointer to the %first %non-word-terminator in a
string

syntax: #include "hhstring.h"
char *ptrfirstnotwordterm(char *ptr)

description: this function returns a pointer to the first non-word-
terminator in memory starting at the beginning of the
specified string.

returns: a pointer to the first non-word-terminator or NULL if only
word terminators are found in the string.

comments: none

keywords: pointer, first, character, not, word, terminator

key sentence: gets the pointer to the first character in a string which
is not a word terminator

see also: ptr< first | last | next | prev >notwordterm

usage example: compiled/executed/verified on 1/31/93

char Astring[80] = " this is the sample string";
char Bstring[80] = " ";
printf("\n%s", ptrfirstnotwordterm(Astring));
printf("\n%s", ptrfirstnotwordterm(Bstring));

this the sample string
(null)


Hobbit House Software
*/











page 64 The Hobbit House String Library



FIRRAN.C file date: 03/13/93 page 1 of 1 FIRRAN.C


/* ptrfirstrange
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstrange (get PoinTeR to FIRST occurrence of any
character in a RANGE of characters)

KWIC: get the pointer to the %first occurance of any character
from a %range of characters

syntax: #include "hhstring.h"
char *ptrfirstrange(char *instring, char c1, char c2)

description: instring is scanned for the occurrence of any character
contained in the range c1 to c2 inclusive

returns: a pointer to the character found, or a NULL if none
are found

comments: none

keywords: pointer, first, character, range

key sentence: gets the pointer to the first occurrence in a string of
any character which is in a given range of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}set

usage example: compiled/executed/verified on 2/25/93

char *Astring = "This is it: the Sample string";
printf("\n%s", ptrfirstrange(Astring, '!', '?'));
printf("\n%s", ptrfirstrange(Astring, '!', '/'));

: the Sample string
(null)


Hobbit House Software
*/












The Hobbit House String Library page 65



FIRSUB.C file date: 03/13/93 page 1 of 1 FIRSUB.C


/* ptrfirstsub
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstsub (get PoinTeR to FIRST occurrence of a
SUBstring)

KWIC: get the pointer to the %first occurrence of a %substring
in
a string

syntax: #include "hhstring.h"
char *ptrfirstsub(char *instring, char *substring)

description: instring is scanned for the first occurrence of substring

returns: a pointer to the substring, or NULL if substring not found

comments: included to have consistent name in the string lib; this
is a macro, defined in hhstring.h using the ANSI function
strstr, as follows:

#define ptrfirstsub(a, b) strstr(a, b)

keywords: pointer, first, substring

key sentence: gets the pointer to the first occurrence in a string of
a given substring

see also: ptr< first | last | next | prev >sub{i}

usage example: compiled/executed/verified on 12/16/92

char *Astring = "This is the Sample string";
printf("%s", ptrfirstsub(Astring, "Sample"));

Sample string


Hobbit House Software
*/












page 66 The Hobbit House String Library



FIRSUBI.C file date: 03/13/93 page 1 of 1 FIRSUBI.C


/* ptrfirstsubi
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstsubi (get PoinTeR to FIRST occurrence of
a SUBstring, Independant of case)

KWIC: gets the pointer to the %first occurrence of a %substring
in a string

syntax: #include "hhstring.h"
char *ptrfirstsubi(char *instring, char *substring)

description: returns a pointer to the first occurrence of substring in
instring

returns: a pointer to the substring, or a NULL if the substring is
not present

comments: none

keywords: pointer, first, substring, case-independent

key sentence: gets the pointer to the first occurrence in a string,
independent of case, of a given substring

see also: ptr< first | last | next | prev >sub{i}

usage example: compiled/executed/verified on 2/25/93

char *Astring = "This is the Sample string";
printf("\n%s", ptrfirstsubi(Astring, "SAMPLE string"));
printf("\n%s", ptrfirstsubi(Astring, "notpresent"));

Sample string
(null)


Hobbit House Software
*/













The Hobbit House String Library page 67



FIRTEXT.C file date: 03/13/93 page 1 of 1 FIRTEXT.C


/* ptrfirsttext
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirsttext (get PoinTeR to FIRST TEXT word)

KWIC: get the pointer to the %first %text word in a string

syntax: #include "hhstring.h"
char *ptrfirsttext(char *ptr)

description: this function returns a pointer to the first text word
in memory starting at the beginning of the specified
string. If the string contains only whitespace, the
return pointer will be NULL.

returns: a pointer to the first text word (NULL if only whitespace
and punctuation is found)

comments: none

keywords: pointer, first, text, word

key sentence: gets the pointer to the first text word in a string

see also: ptr< first | last | next | this | prev>text

usage example: compiled/executed/verified on 1/30/93

char Astring[80] = "\t\t not. It is";
char Bstring[80] = "first! word comes first";
char Cstring[80] = "\n . \t ? \n";
printf("\n%s", ptrfirsttext(Astring));
printf("\n%s", ptrfirsttext(Bstring));
printf("\n%s", ptrfirsttext(Cstring));

not. It is
first! word comes first
(null)


Hobbit House Software
*/










page 68 The Hobbit House String Library



FIRTXTR.C file date: 03/13/93 page 1 of 1 FIRTXTR.C


/* ptrfirsttextterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirsttextterm (get PoinTeR to FIRST TEXT word
TERMinator)

KWIC: get the pointer to the %first %text word terminator in a
string

syntax: #include "hhstring.h"
char *ptrfirsttextterm(char *substring)

description: this function returns a pointer to the first text word
terminator in instring.

returns: a pointer to the first text word terminator character
(NULL if no text word terminator is found)

comments: a "text word" is a human language construct as opposed to
a "string word" which is simply a set of characters
surrounded by whitespace. The only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however, may also
be terminated by any of these punctuation marks: .!?:;,

keywords: pointer, first, character, text, terminator

key sentence: gets the pointer to the first occurrence in a string of
any character which is a text word terminator. I.E. one
of the characters in " \t\n\0.!?:;,

see also: ptr< first | last | next | prev >textterm

usage example: compiled/executed/verified on 2/10/93

char Astring[80] = "thisisthe.sample string";
char Bstring[80] = "and\tso is this";
printf("\n%s", ptrfirsttextterm(Astring));
printf("\n%s", ptrfirsttextterm(Bstring));
printf("\n%s", ptrfirsttextterm("nonehere"));

.sample string
so is this leading blanks are the tab
(null)


Hobbit House Software
*/



The Hobbit House String Library page 69



FIRWH.C file date: 03/13/93 page 1 of 1 FIRWH.C


/* ptrfirstwhite
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstwhite (get PoinTeR to FIRST WHITEspace)

KWIC: get the pointer to the %first %whitespace in a string

syntax: #include "hhstring.h"
char *ptrfirstwhite(char *substring)

description: this function returns a pointer to the first blank or tab
in instring

returns: a pointer to the first whitespace character (NULL if no
whitespace is found)

comments: none

keywords: pointer, first, character, whitespace, blank, tab

key sentence: gets the pointer to the first occurrence in a string of
any character which is whitespace (a blank or a tab)

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/7/93

char Astring[80] = "thisisthesample string";
char Bstring[80] = "and\tso is this";
printf("\n%s", ptrfirstwhite(Astring));
printf("\n%s", ptrfirstwhite(Bstring));

string
so is this leading blanks are the tab


Hobbit House Software
*/













page 70 The Hobbit House String Library



FIRWORD.C file date: 03/13/93 page 1 of 1 FIRWORD.C


/* ptrfirstword
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstword (get PoinTeR to FIRST WORD)

KWIC: get the pointer to the %first %word in a string

syntax: #include "hhstring.h"
char *ptrfirstword(char *ptr)

description: this function returns a pointer to the first word
in memory starting at the beginning of the specified
string. If the string contains only whitespace, the
return pointer will be NULL.

returns: a pointer to the first word (NULL if only whitespace
is found)

comments: none

keywords: pointer, first, word

key sentence: gets the pointer to the first word in a string

see also: ptr< first | last | next | this | prev>word

usage example: compiled/executed/verified on 12/26/92

char Astring[80] = "\t\t this is the sample string";
char Bstring[80] = "first word comes first";
char Cstring[80] = "\n \t \n";
printf("\n%s", ptrfirstword(Astring));
printf("\n%s", ptrfirstword(Bstring));
printf("\n%s", ptrfirstword(Cstring));

this is the sample string
first word comes first
(null)


Hobbit House Software
*/










The Hobbit House String Library page 71



FIRWDTR.C file date: 03/13/93 page 1 of 1 FIRWDTR.C


/* ptrfirstwordterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrfirstwordterm (get PoinTeR to FIRST WORD TERMinator)

KWIC: get the pointer to the %first %word terminator in a string

syntax: #include "hhstring.h"
char *ptrfirstwordterm(char *substring)

description: this function returns a pointer to the first word
terminator in instring.

returns: a pointer to the first word terminator character (NULL if
no word terminator is found)

comments: Note that word terminator is a member of the set ' ',
'\t', '\n', '\0'. It is NOT an English language
terminator. For those, see the functions using the
term text instead of the term word.

keywords: pointer, first, word, terminator

key sentence: gets the pointer to the first occurrence in a string of
any character which is a word (NOT a "text" word)
terminator. I.E. one of the characters in " \t\n\0"

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/15/93

char Astring[80] = "thisisthesample string";
char Bstring[80] = "and\tso is this";
printf("\n%s", ptrfirstwordterm(Astring));
printf("\n%s", ptrfirstwordterm(Bstring));

string
so is this leading blanks are the tab


Hobbit House Software
*/









page 72 The Hobbit House String Library



LASTBLK.C file date: 03/13/93 page 1 of 1 LASTBLK.C


/* ptrlastblank
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastblank (get PoinTeR to LAST BLANK)

KWIC: get the pointer to the %last %blank in a string

syntax: #include "hhstring.h"
char *ptrlastblank(char *string)

description: gets a pointer to the first blank found when scanning
backwards from the end of the specified string.

returns: a pointer to the last blank in a string (NULL if there
are no blanks in the string)

comments: none

keywords: pointer, last, character, blank

key sentence: gets the pointer to the last occurrence in a string of
a blank character

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string";
printf("\n%s", ptrlastblank(Astring));
printf("\n%s", ptrlastblank("no_blanks_in_this_string"));

string
(null)


Hobbit House Software
*/














The Hobbit House String Library page 73



LASTCHR.C file date: 03/13/93 page 1 of 1 LASTCHR.C


/* ptrlastchr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastchr (get PoinTeR to LAST occurrence of a CHaRacter)

KWIC: get the pointer to the %last occurrence of a %character in
a string

syntax: #include "hhstring.h"
char *ptrlastchr(char *ptr, char findchar)

description: gets a pointer to the first occurrence of a character
found when scanning backwards from the end of the
specified string.

returns: a pointer to the last occurrence of a character in
a string (NULL if the character does not occur in the
string)

comments: none

keywords: pointer, last, character

key sentence: gets the pointer to the last occurrence in a string of
a specified character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string";
printf("%s", ptrlastchr(Astring, 'S'));

Sample string


Hobbit House Software
*/














page 74 The Hobbit House String Library



LASTCHRI.C file date: 03/13/93 page 1 of 1 LASTCHRI.C


/* ptrlastchri
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastchri (get PoinTeR to LAST occurrence of a
CHaRacter,
Independant of case)

KWIC: get the pointer to the %last occurrence, independent of
case, of a %character in a string

syntax: #include "hhstring.h"
char *ptrlastchri(char *ptr, char findchar)

description: gets a pointer to the first occurrence of a character,
independent of case, found when scanning backwards from
the end of the specified string.

returns: a pointer to the last occurrence, independent of case, of
a character in a string (NULL if the character does not
occur in the string)

comments: none

keywords: pointer, last, character, case-independent

key sentence: gets the pointer to the last occurrence in a string,
independent of case, of a given character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string";
printf("%s", ptrlastchri(Astring, 'S'));

string


Hobbit House Software
*/












The Hobbit House String Library page 75



LASTDIG.C file date: 03/13/93 page 1 of 1 LASTDIG.C


/* ptrlastdig
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastdig (get PoinTer to LAST decimal DIGit in a string)

KWIC: get the pointer to the %last %decimal digit in a string

syntax: #include "hhstring.h"
char *ptrlastdig(char *string)

description: gets a pointer to the first decimal digit found when
scanning backwards from the end of the specified string.

returns: a pointer to the last decimal digit in a string (NULL if
there are no hex decimal in the string)

comments: none

keywords: pointer, last, decimal, digit

key sentence: gets the pointer to the last occurrence in a string of
any character which is a decimal digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char *Astring = " 123 abc this is it";
printf("\n%s", ptrlastdig(Astring));
printf("\n%s", ptrlastdig("no digits in this string"));

3 abc this is it
(null)


Hobbit House Software
*/














page 76 The Hobbit House String Library



LASTGR.C file date: 03/13/93 page 1 of 1 LASTGR.C


/* ptrlastgr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastgr (get PoinTeR to LAST occurrence of any character
out of a GRoup of characters)

KWIC: get the pointer to the %last occurrence of a character
from a
%group of characters

syntax: #include "hhstring.h"
char *ptrlastgr(char *instring, char *chars)

description: returns the pointer to the the last occurrence in instring
of any character which is in chars

returns: a pointer to the character found, or a NULL if none
are found

comments: none

keywords: pointer, last, character, group

key sentence: gets the pointer to the last occurrence in a string of
any character which is one of a given group of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}gr

usage example: compiled/executed/verified on 2/4/93

char *Astring = "This is it: the Sample string";
printf("\n%s", ptrlastgr(Astring, ".,;:!?"));
printf("\n%s", ptrlastgr(Astring, "+-=()"));

: the Sample string
(null)


Hobbit House Software
*/











The Hobbit House String Library page 77



LASTHEX.C file date: 03/13/93 page 1 of 1 LASTHEX.C


/* ptrlasthex
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlasthex (get PoinTeR to LAST HEX digit in a string)

KWIC: get the pointer to the %last %hex digit in a string

syntax: #include "hhstring.h"
char *ptrlasthex(char *string)

description: gets a pointer to the first hex digit found when scanning
backwards from the end of the specified string.

returns: a pointer to the last hex digit in a string (NULL if there
are no hex digits in the string)

comments: none

keywords: pointer, last, hex, digit

key sentence: gets the pointer to the last occurrence in a string of
any character which is a hex digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char *Astring = " 123 abc this is it";
printf("\n%s", ptrlasthex(Astring));

c this is it


Hobbit House Software
*/
















page 78 The Hobbit House String Library



LASTNOBK.C file date: 03/13/93 page 1 of 1 LASTNOBK.C


/* ptrlastnotblank
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnotblank (get PoinTeR to LAST NOT-BLANK)

KWIC: get the pointer to the %last %non-blank in a string

syntax: #include "hhstring.h"
char *ptrlastnotblank(char *string)

description: gets a pointer to the first non-blank found when scanning
backwards from the end of the specified string.

returns: a pointer to the last non-blank in a string (NULL if there
are only blanks in the string, or if it is empty)

comments: none

keywords: pointer, last, character, not, blank

key sentence: gets the pointer to the last occurrence in a string of
any character which is not a blank

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/7/93

char *Astring = " This is the Sample string ";
printf("\n-->%s<--", ptrlastnotblank(Astring));
printf("\n-->%s<--", ptrlastnotblank(" "));

-->g <--
-->(null)<--


Hobbit House Software
*/














The Hobbit House String Library page 79



LASTNOCH.C file date: 03/13/93 page 1 of 1 LASTNOCH.C


/* ptrlastnotchr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnotchr (get PoinTeR, to LAST, NOT the CHaRacter)

KWIC: get the pointer to the %last occurrence of a character in
a string which is not the specified %character

syntax: #include "hhstring.h"
char *ptrlastnotchr(char *ptr, char findchar)

description: gets a pointer to the first occurrence of any character
found, when scanning backwards from the end of the
specified string, which is not the specified character.

returns: a pointer to the character found (NULL if the string
consists of nothing but the specified character or is
empty)

comments: none

keywords: pointer, last, not, character

key sentence: gets the pointer to the last occurrence in a string of
any character other than a specified character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string.......";
printf("\n%s", ptrlastnotchr(Astring, '.'));
printf("\n%s", ptrlastnotchr(".......", '.'));

g.......
(null)


Hobbit House Software
*/












page 80 The Hobbit House String Library



LASTNOCI.C file date: 03/13/93 page 1 of 1 LASTNOCI.C


/* ptrlastnotchri
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnotchri (get PoinTeR, to LAST, NOT a CHaRacter,
Independant of case)

KWIC: get the pointer to the %last occurrence, %independent of
case, of a character which is not the specified %character

syntax: #include "hhstring.h"
char *ptrlastnotchri(char *ptr, char findchar)

description: gets a pointer to the first occurrence of any character,
independent of case, found when scanning backwards from
the end of the specified string, which is not the
specified character

returns: a pointer to the character found (NULL if the string
consists only of the specified characters or is empty.

comments: none

keywords: pointer, last, character, not, case-independent

key sentence: gets the pointer to the last occurrence in a string of
any character which, independent of case, is not a
specified character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 1/7/93

char *Astring = "*******this is it*******";
printf("%s", ptrlastnotchri(Astring, '*'));

t*******


Hobbit House Software
*/












The Hobbit House String Library page 81



LASTNODG.C file date: 03/13/93 page 1 of 1 LASTNODG.C


/* ptrlastnotdig
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnotdig (get PoinTer to LAST character in a string
which is NOT a decimal DIGit)

KWIC: get the pointer to the %last character in a string which
is not a %decimal digit

syntax: #include "hhstring.h"
char *ptrlastnotdig(char *string)

description: gets the pointer to the last character in string which is
not a decimal digit

returns: a pointer to the character, or NULL if none are found

comments: none

keywords: pointer, last, character, not, decimal, digit

key sentence: gets the pointer to the last occurrence in a string of
any character which is not a decimal digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char *Astring = "value is: 12345";
printf("\n%s", ptrlastnotdig(Astring));
printf("\n%s", ptrlastnotdig("123456"));


12345
(null)


Hobbit House Software
*/













page 82 The Hobbit House String Library



LASTNOGR.C file date: 03/13/93 page 1 of 1 LASTNOGR.C


/* ptrlastnotgr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnotgr (get PoinTeR to LAST occurrence of a
character which is NOT in a GRoup of
characters)

KWIC: get the pointer to the %last occurrence of any character
which is not in a %group of characters

syntax: #include "hhstring.h"
char *ptrlastnotgr(char *instring, char *chars)

description: gets the pointer to the last occurrence in instring of any
character which is not in chars

returns: a pointer to the character found, or NULL if none found

comments: none

keywords: pointer, last, character, not, group

key sentence: gets the pointer to the last occurrence in a string of
any character which is not in a given group of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}gr

usage example: compiled/executed/verified on 2/4/93

char *Astring = "this is it: -123,456,789.012 ";
printf("\n%s<--", ptrlastnotgr(Astring, "this "));
printf("\n%s", ptrlastnotgr("ababca", "abc"));

2 <--
(null)


Hobbit House Software
*/












The Hobbit House String Library page 83



LASTNOHX.C file date: 03/13/93 page 1 of 1 LASTNOHX.C


/* ptrlastnothex
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnothex (get PoinTeR to LAST character in a string
which is NOT a HEX digit)

KWIC: get the pointer to the %last %hex digit in a string

syntax: #include "hhstring.h"
char *ptrlastnothex(char *string)

description: gets a pointer to the first hex digit found when scanning
backwards from the end of the specified string.

returns: a pointer to the last hex digit in a string (NULL if there
are no hex digits in the string)

comments: none

keywords: pointer, last, character, not, hex, digit

key sentence: gets the pointer to the last occurrence in a string of
any character which is not a hex digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char *Astring = "value is: 1a23fe5";
printf("\n%s", ptrlastnothex(Astring));
printf("\n%s", ptrlastnothex("123abc"));

1a23fe5
(null)


Hobbit House Software
*/













page 84 The Hobbit House String Library



LASTNORN.C file date: 03/13/93 page 1 of 1 LASTNORN.C


/* ptrlastnotrange
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnotrange (get PoinTeR, to LAST, NOT in RANGE)

KWIC: get the pointer to the %last occurrence in a string of any
character which is not in a %range of characters

syntax: #include "hhstring.h"
char *ptrlastnotrange(char *instring, char c1, char c2)

description: gets the pointer to the last character in instring which
is not in the range c1 to c2 inclusive

returns: a pointer to the character found, or NULL if none are
found

comments: none

keywords: pointer, last, character, not, range

key sentence: gets the pointer to the last occurrence in a string of
any character which is not in a given range of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}set

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the {Sample} String";
printf("\n%s", ptrlastnotrange(Astring, ' ', 'z'));
printf("\n%s", ptrlastnotrange("abcdef", 'a', 'f'));

} string
(null)


Hobbit House Software
*/













The Hobbit House String Library page 85



LASTNOTT.C file date: 03/13/93 page 1 of 1 LASTNOTT.C


/* ptrlastnottextterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnottextterm (get PoinTeR to LAST
NOT-TEXT-TERMinator)

KWIC: get the pointer to the %last character in a string other
than %text word terminators

syntax: #include "hhstring.h"
char *ptrlastnottextterm(char *string)

description: gets a pointer to the first character found when scanning
backwards from the end of the specified string, which is
not a text word terminator. I.E. not in the set
"\n\t\f\r\v.!?:;, "

returns: a pointer to the last non-wordterminator character in a
string (NULL if there are only word terminators in the
string)

comments: a "text word" is a human language construct as opposed to
a "string word" which is simply a set of characters
surrounded by whitespace. The only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however, may also
be terminated by any of these punctuation marks: .!?:;,

keywords: pointer, last, character, not, terminator, text, word

key sentence: gets the pointer to the last occurrence in a string of
any character which is not a text word terminator

see also: ptr< first | last | next | prev >textterm

usage example: compiled/executed/verified on 1/30/93

char *Astring = "This is the Sample string . \t ? \n";
printf("-->%s<--", ptrlastnottextterm(Astring));

-->g . ?
<--


Hobbit House Software
*/





page 86 The Hobbit House String Library



LASTNOWH.C file date: 03/13/93 page 1 of 1 LASTNOWH.C


/* ptrlastnotwhite
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnotwhite (get PoinTeR to LAST NOT-WHITE)

KWIC: get the pointer to the %last %non-whitespace character in
a string

syntax: #include "hhstring.h"
char *ptrlastnotwhite(char *string)

description: gets a pointer to the first non-whitespace character
found when scanning backwards from the end of the
specified string.

returns: a pointer to the last non-whitespace character in a
string (NULL if there is only whitespace in the string)

comments: none

keywords: pointer, last, character, not, whitespace, blank, tab

key sentence: gets the pointer to the last occurrence in a string of
any character which is not whitespace (a blank or a tab)

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string ";
printf("-->%s<--", ptrlastnotwhite(Astring));

-->g <--


Hobbit House Software
*/














The Hobbit House String Library page 87



LASTNOWT.C file date: 03/13/93 page 1 of 1 LASTNOWT.C


/* ptrlastnotwordterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastnotwordterm (get PoinTeR to LAST
NOT-WORD-TERMinator)

KWIC: get the pointer to the %last character in a string other
than %word terminators

syntax: #include "hhstring.h"
char *ptrlastnotwordterm(char *string)

description: gets a pointer to the first character found when scanning
backwards from the end of the specified string, which is
not a word terminator. I.E. not in the set " \n\t\f\r\v"

returns: a pointer to the last non-wordterminator character in a
string (NULL if there are only word terminators in the
string)

comments: none

keywords: pointer, last, character, not, word, terminator

key sentence: gets the pointer to the last occurrence in a string of
any character which is not a word terminator

see also: ptr< first | last | next | prev >{not}< blank | white >
ptr< first | last | next | prev >{not}< word | text >term

usage example: compiled/executed/verified on 2/27/93

char *Astring = "This is the Sample string \t \n";
printf("-->%s<--", ptrlastnotwordterm(Astring));

-->g tab expansion doesn't
<-- show, but is present


Hobbit House Software
*/











page 88 The Hobbit House String Library



LASTRAN.C file date: 03/13/93 page 1 of 1 LASTRAN.C


/* ptrlastrange
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastrange (get PoinTeR, to LAST, from RANGE)

KWIC: get the pointer to the %last occurrence in a string of any
character in a %range of characters


syntax: #include "hhstring.h"
char *ptrlastrange(char *instring, char c1, char c2)

description: gets the pointer to the last occurrence in instring of any
character in the range c1 to c2 inclusive

returns: a pointer to the character found, or NULL if all
characters are out of the range

comments: none

keywords: pointer, last, character, range

key sentence: gets the pointer to the last occurrence in a string of
any character which is in a given range of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}set

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is it: the Sample string";
printf("\n%s", ptrlastrange(Astring, '!', '?'));
printf("\n%s", ptrlastrange(Astring, '!', '/'));

: the Sample string
(null)


Hobbit House Software
*/












The Hobbit House String Library page 89



LASTSUB.C file date: 03/13/93 page 1 of 1 LASTSUB.C


/* ptrlastsub
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastsub (get PoinTeR to LAST occurrence of a
SUB-string)

KWIC: get the pointer to the %last occurrence of a %substring

syntax: #include
#include "hhstring.h"
char *ptrlastsub(char *instring, char *substring)

description: returns a pointer to the last occurrence of substring in
string

returns: a pointer to the substring location, or a NULL if the
substring is not found

comments: none

keywords: pointer, last, substring

key sentence: gets the pointer to the last occurrence in a string of
a given substring

see also: ptr< first | last | next | prev >sub{i}

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string";
printf("\n%s", ptrlastsub(Astring, "Sample"));
printf("\n%s", ptrlastsub(Astring, "not there"));

Sample string
(null)


Hobbit House Software
*/













page 90 The Hobbit House String Library



LASTSUBI.C file date: 03/13/93 page 1 of 1 LASTSUBI.C


/* ptrlastsubi
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastsubi (get PoinTeR to LAST occurrence of a SUB-
string, Independant of case)

KWIC: get the pointer to the %last occurrence, %independent of
case, of a %substring

syntax: #include
#include "hhstring.h"
char *ptrlastsubi(char *instring, char *substring)

description: the last occurrence of

returns: a pointer to the substring location, or a NULL if the
substring is not found

comments: none

keywords: pointer, last, substring, case-independent

key sentence: gets the pointer to the last occurrence in a string,
independent of case, of a given substring

see also: ptr< first | last | next | prev >sub{i}

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string";
printf("\n%s", ptrlastsubi(Astring, "SAMPLE"));
printf("\n%s", ptrlastsubi(Astring, "not there"));

Sample string
(null)


Hobbit House Software
*/













The Hobbit House String Library page 91



LASTTEXT.C file date: 03/13/93 page 1 of 1 LASTTEXT.C


/* ptrlasttext
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlasttext (get PoinTeR to LAST TEXT word)

KWIC: get the pointer to the %last %text word in a string

syntax: #include "hhstring.h"
char *ptrlasttext(char *string)

description: gets a pointer to the first text word found when scanning
backwards from the end of the specified string.

returns: a pointer to the last text word it the string (NULL if
there is only whitespace and punctuation in the string)

comments: a "text word" is a human language construct as opposed to
a "string word" which is simply a set of characters
surrounded by whitespace. The only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however, may also
be terminated by any of these punctuation marks: .!?:;,

keywords: pointer, last, word, text

key sentence: gets the pointer to the last text word in a string

see also: ptr< first | last | next | this | prev>text

usage example: compiled/executed/verified on 1/30/93

char *Astring = "This is the Sample string.";
printf("\n%s", ptrlasttext(Astring));
printf("\n%s", ptrlasttext("-----"));
printf("\n%s", ptrlasttext(" . \t ? "));

string.
------
(null)


Hobbit House Software
*/








page 92 The Hobbit House String Library



LASTTXTR.C file date: 03/13/93 page 1 of 1 LASTTXTR.C


/* ptrlasttextterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlasttextterm (get PoinTeR to LAST TEXT TERMinator)

KWIC: get the pointer to the %last %text terminator in a string

syntax: #include "hhstring.h"
char *ptrlasttextterm(char *string)

description: gets a pointer to the first text terminator found when
scanning backwards from the end of the specified string.

returns: a pointer to the last text terminator in a string
(NULL if there are no blanks in the string)

comments: a "text word" is a human language construct as opposed to
a "string word" which is simply a set of characters
surrounded by whitespace. The only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however, may also
be terminated by any of these punctuation marks: .!?:;,

keywords: pointer, last, character, text, terminator

key sentence: gets the pointer to the last occurrence in a string of
a text terminator character

see also: ptr< first | last | next | prev >textterm

usage example: compiled/executed/verified on 2/21/93

char *Astring = " was this. The sample string";
printf("\n%s", ptrlasttextterm(Astring));
printf("\n%s", ptrlasttextterm("no_terms_in_this_string"))
;

string
(null)


Hobbit House Software
*/








The Hobbit House String Library page 93



LASTWH.C file date: 03/13/93 page 1 of 1 LASTWH.C


/* ptrlastwhite
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastwhite (get PoinTeR to LAST WHITEspace)

KWIC: get the pointer to the %last %whitespace character in a
string

syntax: #include "hhstring.h"
char *ptrlastwhite(char *string)

description: gets a pointer to the first whitespace character found
when scanning backwards from the end of the specified
string.

returns: a pointer to the last whitespace character in a string
(NULL if there is no whitespace in the string)

comments: none

keywords: pointer, last, character, whitespace, blank, tab

key sentence: gets the pointer to the last occurrence in a string of
a whitespace character (a blank or a tab)

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string";
printf("\n%s", ptrlastwhite(Astring));
printf("\n%s", ptrlastwhite("no_whitespace_here"));

string
(null)


Hobbit House Software
*/












page 94 The Hobbit House String Library



LASTWORD.C file date: 03/13/93 page 1 of 1 LASTWORD.C


/* ptrlastword
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastword (get PoinTeR to LAST WORD)

KWIC: get the pointer to the %last %word in a string

syntax: #include "hhstring.h"
char *ptrlastword(char *string)

description: gets a pointer to the first word found when scanning
backwards from the end of the specified string.

returns: a pointer to the last word it the string (NULL if there
is only whitespace in the string)

comments: this function is not bothered by final EOL ('\n')
characters in a string

keywords: pointer, last, word

key sentence: gets the pointer to the last word in a string

see also: ptr< first | last | next | this | prev>word

usage example: compiled/executed/verified on 2/27/93

char *Astring = "This is the Sample string\n";
printf("\n%s", ptrlastword(Astring));
printf("\n%s", ptrlastword("--.--"));
printf("\n%s", ptrlastword("--.--:\n"));
printf("\n%s", ptrlastword(" \t "));

string

--.--
--.--:

(null)


Hobbit House Software
*/









The Hobbit House String Library page 95



LASTWDTR.C file date: 03/13/93 page 1 of 1 LASTWDTR.C


/* ptrlastwordterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrlastwordterm (get PoinTeR to LAST WORD TERMinator)

KWIC: get the pointer to the %last %word terminator in a string

syntax: #include "hhstring.h"
char *ptrlastwordterm(char *string)

description: gets a pointer to the first word terminator found when
scanning backwards from the end of the specified string.

returns: a pointer to the last word terminator in a string
(NULL if there are no blanks in the string)

comments: none

keywords: pointer, last, character, word, terminator

key sentence: gets the pointer to the last occurrence in a string of
a word terminator character

see also: ptr< first | last | next | prev >wordterm

usage example: compiled/executed/verified on 1/31/93

char *Astring = " was this. The sample string";
printf("\n%s", ptrlastwordterm(Astring));
printf("\n%s", ptrlastwordterm("no_terms_in_this_string"))
;

string
(null)


Hobbit House Software
*/














page 96 The Hobbit House String Library



NEXTBLK.C file date: 03/13/93 page 1 of 2 NEXTBLK.C


/* ptrnextblank
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextblank (get PoinTeR to NEXT BLANK)

KWIC: get the pointer to the %next %blank in a string

syntax: #include "hhstring.h"
char *ptrnextblank(char *ptr)

description: this function returns a pointer to the first blank in
memory following the given pointer. if the pointer
points at a blank, that will NOT be the one pointed to
upon return.

returns: a pointer to the next blank

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, blank

key sentence: gets the pointer to the next blank in a string

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white



















The Hobbit House String Library page 97



NEXTBLK.C file date: 03/13/93 page 2 of 2 NEXTBLK.C




usage example: compiled/executed/verified on 12/21/92

char *Astring = "thisisthesample string";
printf("%s", ptrnextblank(Astring+5));

string


Hobbit House Software
*/










































page 98 The Hobbit House String Library



NEXTCHR.C file date: 03/13/93 page 1 of 2 NEXTCHR.C


/* ptrnextchr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextchr (get PoinTeR to NEXT occurrence of a specified
CHaRacter)

KWIC: get the pointer to the %next occurrence in a string of a
specified %character

syntax: #include "hhstring.h"
char *ptrnextchr(char *ptr, char findchar)

description: this function returns a pointer to the next occurrence in
memory of the specified character, starting at the
specified pointer. If an EOS is encountered before any
occurrence of the character, then the return pointer will
be NULL.

returns: a pointer to the next occurrence of the character (NULL
if the character does not occur)

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character

key sentence: gets the pointer to the next occurrence of a specified
character in a string

see also: ptr< first | last | next | prev >{not}chr{i}















The Hobbit House String Library page 99



NEXTCHR.C file date: 03/13/93 page 2 of 2 NEXTCHR.C




usage example: compiled/executed/verified on 12/15/92

char Astring[80] = "this is the Sample string";
printf("%s", ptrnextchr(Astring + 3, 's'));

s the sample string


Hobbit House Software
*/










































page 100 The Hobbit House String Library



NEXTCHRI.C file date: 03/13/93 page 1 of 2 NEXTCHRI.C


/* ptrnextchri
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextchri (get PoinTeR to NEXT occurrence of a specified
CHaRacter, independent of case)

KWIC: get the pointer to the %next occurrence in a string of a
specified %character, %independent of case

syntax: #include "hhstring.h"
char *ptrnextchri(char *ptr, char findchar)

description: this function returns a pointer to the next occurrence in
memory of the specified character, independent of case,
starting at the specified pointer. If an EOS is
encountered
before any occurrence of the character, then the return
pointer will be NULL.

returns: a pointer to the next occurrence of the character,
independent of case (NULL if the character does not occur)

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, case-independent

key sentence: gets the pointer to the next case-independent occurrence
of a specified character in a string

see also: ptr< first | last | next | prev >{not}chr{i}














The Hobbit House String Library page 101



NEXTCHRI.C file date: 03/13/93 page 2 of 2 NEXTCHRI.C




usage example: compiled/executed/verified on 12/15/92

char Astring[80] = "this is the Sample string";
printf("%s", ptrnextchri(Astring, 'S'));

s is the Sample string


Hobbit House Software
*/










































page 102 The Hobbit House String Library



NEXTDIG.C file date: 03/13/93 page 1 of 2 NEXTDIG.C


/* ptrnextdig
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextdig (get PoinTeR to NEXT decimal DIGit in a string)

KWIC: get the pointer to the %next %decimal digit in a string

syntax: #include "hhstring.h"
char *ptrnextdig(char *ptr)

description: this function returns a pointer to the first decimal
digit in memory following the given pointer. if the
pointer points at a decimal digit, that will NOT be the
one pointed to upon return.

returns: a pointer to the next decimal digit

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, decimal, digit

key sentence: gets the pointer to the next decimal digit in a string

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex



















The Hobbit House String Library page 103



NEXTDIG.C file date: 03/13/93 page 2 of 2 NEXTDIG.C




usage example: compiled/executed/verified on 12/15/92

char Astring[80] = "123 af69";
printf("\n%s", ptrnextdig(Astring));
printf("\n%s", ptrnextdig(Astring + 3));

23 af69
69


Hobbit House Software
*/








































page 104 The Hobbit House String Library



NEXTNODG.C file date: 03/13/93 page 1 of 2 NEXTNODG.C


/* ptrnextdig
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextdig (get PoinTeR to NEXT decimal DIGit in a string)

KWIC: get the pointer to the %next %decimal digit in a string

syntax: #include "hhstring.h"
char *ptrnextdig(char *ptr)

description: this function returns a pointer to the first decimal
digit in memory following the given pointer. if the
pointer points at a decimal digit, that will NOT be the
one pointed to upon return.

returns: a pointer to the next decimal digit, or a NULL if none are
found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, decimal, digit

key sentence: gets the pointer to the next decimal digit in a string

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex


















The Hobbit House String Library page 105



NEXTNODG.C file date: 03/13/93 page 2 of 2 NEXTNODG.C




usage example: compiled/executed/verified on 1/7/93

char Astring[80] = "123.45678";
printf("\n%s", ptrnextnotdig(Astring));
printf("\n%s", ptrnextnotdig(Astring + 5));

.45678
(null)


Hobbit House Software
*/








































page 106 The Hobbit House String Library



NEXTGR.C file date: 03/13/93 page 1 of 2 NEXTGR.C


/* ptrnextgr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextgr (get PoinTeR to NEXT occurrence of any character
from a GRoup of characters)

KWIC: get the pointer to the %next occurrence of any character
from a %group of characters

syntax: #include "hhstring.h"
char *ptrnextgr(char *string, char *chars)

description: string is scanned for the occurrence of any character in
the chars string

returns: a pointer to the character found, or NULL if none
are found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, group

key sentence: gets the pointer to the next character in a string which
is any one of a group of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}group

















The Hobbit House String Library page 107



NEXTGR.C file date: 03/13/93 page 2 of 2 NEXTGR.C




usage example: compiled/executed/verified on 2/4/93

char *Astring = "This is it: the Sample string";
printf("\n%s", ptrnextgr(Astring, ".,;:!?"));
printf("\n%s", ptrnextgr(Astring, "+-=()"));

: the Sample string
(null)


Hobbit House Software
*/








































page 108 The Hobbit House String Library



NEXTHEX.C file date: 03/13/93 page 1 of 2 NEXTHEX.C


/* ptrnexthex
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnexthex (get PoinTeR to NEXT HEX digit in string)

KWIC: get the pointer to the %next %hex digit in a string

syntax: #include "hhstring.h"
char *ptrnexthex(char *ptr)

description: this function returns a pointer to the first hex digit
in memory following the given pointer. if the pointer
points at a hex digit, that will NOT be the one pointed
to upon return.

returns: a pointer to the next hex digit

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, hex, digit

key sentence: gets the pointer to the next hex digit in a string

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex



















The Hobbit House String Library page 109



NEXTHEX.C file date: 03/13/93 page 2 of 2 NEXTHEX.C




usage example: compiled/executed/verified on 12/15/92

char Astring[80] = "123 af69";
printf("\n%s", ptrnexthex(Astring + 3));
printf("\n%s", ptrnexthex(Astring + 5));

af69
f69


Hobbit House Software
*/








































page 110 The Hobbit House String Library



NEXTNOBK.C file date: 03/13/93 page 1 of 2 NEXTNOBK.C


/* ptrnextnotblank
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnotblank (get PoinTeR to NEXT NOT-BLANK)

KWIC: get the pointer to the %next %non-blank in a string

syntax: #include "hhstring.h"
char *ptrnextnotblank(char *stringptr)

description: this function returns a pointer to the next non-blank
in the input string following the character that is
pointed to by the input pointer. If only blanks are
found to the end of the string, then a NULL is returned.

returns: a pointer to the next non-blank or a NULL if only
blanks are found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, not, blank

key sentence: gets the pointer to the next non-blank character in a
string

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

















The Hobbit House String Library page 111



NEXTNOBK.C file date: 03/13/93 page 2 of 2 NEXTNOBK.C




usage example: compiled/executed/verified on 12/26/92

char *Astring = " label1 size3";
char *Bstring = " lab2\t\t size4";
char *Cstring = " lab4 ";
printf("\n-->%s<--", ptrnextnotblank(Astring+8));
printf("\n-->%s<--", ptrnextnotblank(Bstring+8));
printf("\n-->%s<--", ptrnextnotblank(Cstring+8));

-->size3<--
--> size4<-- the blanks are the expanded '\t'
-->(null)<--


Hobbit House Software
*/




































page 112 The Hobbit House String Library



NEXTNOCH.C file date: 03/13/93 page 1 of 2 NEXTNOCH.C


/* ptrnextnotchr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnotchr (get PoinTeR to NEXT occurrence which is NOT
a specified CHaRacter)

KWIC: get the pointer to the %next occurrence in a string of a
character which is not the specified %character

syntax: #include "hhstring.h"
char *ptrnextnotchr(char *ptr, char findchar)

description: this function returns a pointer to the next occurrence in
memory of a character which is not the specified
character, starting at the specified pointer. If an EOS
is encountered before any occurrence of the non-character,
then the return pointer will be NULL.

returns: a pointer to the next occurrence of the non-character,
or NULL if the character always occurs

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, not

key sentence: gets the pointer to the next occurrence in a string of any
character which is not the specified character

see also: ptr< first | last | next | prev >{not}chr{i}















The Hobbit House String Library page 113



NEXTNOCH.C file date: 03/13/93 page 2 of 2 NEXTNOCH.C




usage example: compiled/executed/verified on 12/21/92

char Astring[80] = "aaaAaAbbb";
printf("%s", ptrnextnotchr(Astring, 'a'));

AaAbbb


Hobbit House Software
*/










































page 114 The Hobbit House String Library



NEXTNOCI.C file date: 03/13/93 page 1 of 2 NEXTNOCI.C


/* ptrnextnotchri
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnotchri (get PoinTeR to NEXT occurrence which is
NOT
a specified CHaRacter, case-Independant)

KWIC: get the pointer to the %next occurrence in a string of a
character which is not the specified %character,
%independent of case

syntax: #include "hhstring.h"
char *ptrnextnotchri(char *ptr, char findchar)

description: this function returns a pointer to the next occurrence in
memory of a character which is not the specified
character, independent of case, starting at the specified
pointer. If an EOS is encountered before any occurrence of
the non-character, then the return pointer will be NULL.

returns: a pointer to the next occurrence of the non-character,
independent of case (NULL if the character always occurs)

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, not, case-independent

key sentence: gets the pointer to the next occurrence in a string of any
character which is not the specified character,
independent of case

see also: ptr< first | last | next | prev >{not}chr{i}












The Hobbit House String Library page 115



NEXTNOCI.C file date: 03/13/93 page 2 of 2 NEXTNOCI.C




usage example: compiled/executed/verified on 12/21/92

char Astring[80] = "aAaAaAbbb";
printf("%s", ptrnextnotchri(Astring, 'a'));

bbb


Hobbit House Software
*/










































page 116 The Hobbit House String Library



NEXTNOGR.C file date: 03/13/93 page 1 of 2 NEXTNOGR.C


/* ptrnextnotgr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnotgr (get PoinTeR to NEXT occurrence of any
character NOT in a GRoup of characters)

KWIC: get the pointer to the %next occurrence of any character
NOT in a %group of characters

syntax: #include "hhstring.h"
char *ptrnextnotgr(char *string, char *chars)


description: string is scanned for the occurrence of any character
which is NOT in the chars string

returns: a pointer to the character found, or NULL if none
are found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.


keywords: pointer, next, character, group, not

key sentence: gets the pointer to the first occurrence in a string of
any
character which is not in a given group of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}gr














The Hobbit House String Library page 117



NEXTNOGR.C file date: 03/13/93 page 2 of 2 NEXTNOGR.C




usage example: compiled/executed/verified on 2/4/93

char *Astring = "0013.58 0014.21 and so on";
printf("\n%s", ptrnextnotgr(Astring, "0123456789 ."));
printf("\n%s", ptrnextnotgr("12345", "0123456789 ."));

and so on
(null)


Hobbit House Software
*/








































page 118 The Hobbit House String Library



NEXTNOHX.C file date: 03/13/93 page 1 of 2 NEXTNOHX.C


/* ptrnextnothex
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnothex (get PoinTeR to NEXT character which is NOT
a HEX digit in string)

KWIC: get the pointer to the %next %non-hex-digit in a string

syntax: #include "hhstring.h"
char *ptrnextnothex(char *ptr)

description: this function returns a pointer to the first character in
memory, following the given pointer, which is not a hex
digit. if the pointer points at a hex digit, that will NOT
be the one pointed to upon return.

returns: a pointer to the next hex digit

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, hex, digit, not

key sentence: gets the pointer to the next non-hex-digit in a string

key sentence: gets the pointer to the next character in a string which
is not a hex digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex















The Hobbit House String Library page 119



NEXTNOHX.C file date: 03/13/93 page 2 of 2 NEXTNOHX.C




usage example: compiled/executed/verified on 1/7/93

char Astring[80] = "123af69 is the answer";
printf("\n%s", ptrnextnothex(Astring));

is the answer


Hobbit House Software
*/










































page 120 The Hobbit House String Library




NEXTNORN.C file date: 03/13/93 page 1 of 2 NEXTNORN.C


/* ptrnextnotrange
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnotrange (get PoinTeR, NEXT, NOT in RANGE)

KWIC: get the pointer to the %next occurrence in a string of any
character NOT in a %range of characters

syntax: #include "hhstring.h"
char *ptrnextnotrange(char *instring, char c1, char c2)

description: instring is scanned for the occurrence of any character
which is NOT in the range c1 to c2 inclusive

returns: a pointer to the character found, or a NULL if none
are found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.


keywords: pointer, next, not, character, range

key sentence: gets the pointer to the next occurrence in a string of any
character NOT in a range of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}set

















The Hobbit House String Library page 121



NEXTNORN.C file date: 03/13/93 page 2 of 2 NEXTNORN.C




usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is it: {the Sample string}";
printf("\n%s", ptrnextnotrange(Astring, ' ', 'z'));
printf("\n%s", ptrnextnotrange(Astring, ' ', '}'));

{the Sample string}
(null)


Hobbit House Software
*/








































page 122 The Hobbit House String Library



NEXTNOTT.C file date: 03/13/93 page 1 of 2 NEXTNOTT.C


/* ptrnextnottextterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnottextterm (get PoinTeR to NEXT NOT-TEXT-
TERMinator)

KWIC: get the pointer to the %next %non-text-terminator in a
string

syntax: #include "hhstring.h"
char *ptrnextnottextterm(char *stringptr)

description: this function returns a pointer to the next non-text
terminator in the input string following the character
that is pointed to by the input pointer. If only text
terminators are found to the end of the string, then a
NULL is returned.

returns: a pointer to the next non-text-terminator or a NULL if
only text terminators are found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, not, text, terminator

key sentence: gets the pointer to the next non-text-terminator
character in a string

see also: ptr< first | last | next | prev >nottextterm















The Hobbit House String Library page 123



NEXTNOTT.C file date: 03/13/93 page 2 of 2 NEXTNOTT.C




usage example: compiled/executed/verified on 1/31/93

char *Astring = " label1 size3";
char *Bstring = " lab2\t\t size4";
char *Cstring = " lab4 . ? ! ";
printf("\n%s", ptrnextnottextterm(Astring+8));
printf("\n%s", ptrnextnottextterm(Bstring+8));
printf("\n%s", ptrnextnottextterm(Cstring+8));

size3
size4
(null)


Hobbit House Software
*/




































page 124 The Hobbit House String Library



NEXTNOWH.C file date: 03/13/93 page 1 of 2 NEXTNOWH.C


/* ptrnextnotwhite

Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnotwhite (get PoinTeR to NEXT NOT-WHITE)

KWIC: get the pointer to the %next %non-whitespace in a string

syntax: #include "hhstring.h"
char *ptrnextnotwhite(char *stringptr)

description: this function returns a pointer to the next "non-white
char" (anything other than a blank or a tab) in the input
string following the character that is pointed to by the
input pointer. If only whitespace characters are found to
the end of the string, then a NULL is returned.

returns: a pointer to the next "non-white char" or a NULL if only
whitespace characters are found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, not, whitespace, blank, tab

key sentence: gets the pointer to the next non-whitespace character
in a string

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white
















The Hobbit House String Library page 125



NEXTNOWH.C file date: 03/13/93 page 2 of 2 NEXTNOWH.C




usage example: compiled/executed/verified on 12/26/92

char *Astring = " label1 size3";
char *Bstring = " lab2\t\t size4";
char *Cstring = " lab4 ";
printf("\n-->%s<--", ptrnextnotwhite(Astring+9));
printf("\n-->%s<--", ptrnextnotwhite(Bstring+9));
printf("\n-->%s<--", ptrnextnotwhite(Cstring+9));

-->size3<--
-->size4<--
-->(null)<--


Hobbit House Software
*/




































page 126 The Hobbit House String Library



NEXTNOWT.C file date: 03/13/93 page 1 of 2 NEXTNOWT.C


/* ptrnextnotwordterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextnotwordterm (get PoinTeR to NEXT NOT-WORD-
TERMinator)

KWIC: get the pointer to the %next %non-word-terminator in a
string

syntax: #include "hhstring.h"
char *ptrnextnotwordterm(char *stringptr)

description: this function returns a pointer to the next non-word
terminator in the input string following the character
that is pointed to by the input pointer. If only word
terminators are found to the end of the string, then a
NULL is returned.

returns: a pointer to the next non-word-terminator or a NULL if
only word terminators are found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, not, word, terminator

key sentence: gets the pointer to the next non-word-terminator
character in a string

see also: ptr< first | last | next | prev >notwordterm















The Hobbit House String Library page 127



NEXTNOWT.C file date: 03/13/93 page 2 of 2 NEXTNOWT.C




usage example: compiled/executed/verified on 1/31/93

char *Astring = " label1 size3";
char *Bstring = " lab2\t\t size4";
char *Cstring = " lab4 ";
printf("\n%s", ptrnextnotwordterm(Astring+8));
printf("\n%s", ptrnextnotwordterm(Bstring+8));
printf("\n%s", ptrnextnotwordterm(Cstring+8));

size3
size4
(null)


Hobbit House Software
*/




































page 128 The Hobbit House String Library



NEXTRAN.C file date: 03/13/93 page 1 of 2 NEXTRAN.C


/* ptrnextrange
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextrange (get PoinTeR, NEXT, from RANGE)

KWIC: get the pointer to the %next occurrence in a string of any
character from a %range of characters

syntax: #include "hhstring.h"
char *ptrnextrange(char *instring, char c1, char c2)

description: instring is scanned for the next occurrence of any
character in the range c1 to c2 inclusive

returns: a pointer to the character found, or a NULL if none
are found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, range

key sentence: gets the pointer to the next occurrence in a string of any
character from a range of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}set


















The Hobbit House String Library page 129



NEXTRAN.C file date: 03/13/93 page 2 of 2 NEXTRAN.C




usage example: compiled/executed/verified on 12/16/92

char *Astring = "This is it: the Sample string";
printf("\n%s", ptrnextrange(Astring, '!', '?'));
printf("\n%s", ptrnextrange(Astring, '!', '/'));

: the Sample string
(null)


Hobbit House Software
*/








































page 130 The Hobbit House String Library



NEXTSUB.C file date: 03/13/93 page 1 of 2 NEXTSUB.C


/* ptrnextsub
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextsub (get PoinTeR to NEXT occurrence of a SUBstring)

KWIC: get the pointer to the %next occurrence of a %substring
in a string

syntax: #include "hhstring.h"
char *ptrnextsub(char *ptr, char *substring)

description: ptr is scanned for the next occurrence of substring

returns: a pointer to the occurrence of substring, or NULL if
the substring does not appear in ptr

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, substring

key sentence: gets the pointer to the next occurrence of a substring in
a
string

see also: ptr< first | last | next | prev >sub{i}



















The Hobbit House String Library page 131



NEXTSUB.C file date: 03/13/93 page 2 of 2 NEXTSUB.C




usage example: compiled/executed/verified on 12/16/92

char *Astring = "This is the Sample string";
printf("%s", ptrnextsub(Astring, "Sample"));

Sample string


Hobbit House Software
*/










































page 132 The Hobbit House String Library



NEXTSUBI.C file date: 03/13/93 page 1 of 2 NEXTSUBI.C


/* ptrnextsubi
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextsubi (get PoinTeR to NEXT occurrence of a
SUBstring, Independant of case)

KWIC: get the pointer to the %next occurrence of a %substring,
%independant of case

syntax: #include "hhstring.h"
char *ptrnextsubi(char *inptr, char *substring)

description: inptr is scanned for the next case-independent
occurrence of substring

returns: a pointer to the occurrence of substring, or a NULL if
substring does not occur in inptr

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, substring, case-independent

key sentence: gets the pointer to the next occurrence, independent of
case, of a substring in a string

see also: ptr< first | last | next | prev >sub{i}


















The Hobbit House String Library page 133



NEXTSUBI.C file date: 03/13/93 page 2 of 2 NEXTSUBI.C




usage example: compiled/executed/verified on 12/16/92

char *Astring = "This is this Sample string";
printf("\n%s", ptrnextsubi(Astring, "THIS"));
printf("\n%s", ptrnextsubi(Astring, "notpresent"));

this Sample string
(null)


Hobbit House Software
*/








































page 134 The Hobbit House String Library



NEXTTEXT.C file date: 03/13/93 page 1 of 2 NEXTTEXT.C


/* ptrnexttext
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnexttext (get PoinTeR to NEXT TEXT word)

KWIC: get the pointer to the %next %text word in a string

syntax: #include "hhstring.h"
char *ptrnexttext(char *instring)

description: this function returns a pointer to the next text word in
instring. If there is no next word, then a NULL is
returned. The "next text word" means the first non-
terminator character following the first terminator
character following instring. Think about it this way;
from instring, you look for the next terminator and then
from there you look for the next non-terminator. That
way, you get the next word whether instring starts with
a word or not.

returns: a pointer to the next text word

comments: a "text word" is a human language construct as opposed to
a "string word" which is simply a set of characters
surrounded by whitespace. The only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however, may also
be terminated by any of these punctuation marks: .!?:;,

while most of the "ptrnext..." functions are macros
using the corresponding "ptrfirst..." function, that
cannot be done with this function because it is
word-oriented not character-oriented

keywords: pointer, next, word, text

key sentence: gets the pointer to the next text word in a string

see also: ptr< first | last | next | this | prev>text












The Hobbit House String Library page 135



NEXTTEXT.C file date: 03/13/93 page 2 of 2 NEXTTEXT.C




usage example: compiled/executed/verified on 1/30/93

char *Astring = "label1 size3";
char *Bstring = "lab2.size4";
char *Cstring = "lab4 ";
printf("\n-->%s<--", ptrnexttext(Astring));
printf("\n-->%s<--", ptrnexttext(Bstring));
printf("\n-->%s<--", ptrnexttext(Cstring+4));

-->size3<--
-->size4<--
-->(null)<--


Hobbit House Software
*/




































page 136 The Hobbit House String Library



NEXTTXTR.C file date: 03/13/93 page 1 of 2 NEXTTXTR.C


/* ptrnexttextterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnexttextterm (get PoinTeR to NEXT TEXT word TERMinator)

KWIC: get the pointer to the %next %text word terminator in a
string

syntax: #include "hhstring.h"
char *ptrnexttextterm(char *ptr)

description: this function returns a pointer to the first text word
terminator in memory following the given pointer. if the
pointer points at a text terminator, that will NOT be the
one pointed to upon return.

returns: a pointer to the next text word terminator (since the
string terminator is a legal text word terminator, this
function will never return a but may return a pointer
to the string terminator.

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, text, terminator

key sentence: gets the pointer to the next text word terminator
in a string

see also: ptr< first | last | next | prev >textterm















The Hobbit House String Library page 137



NEXTTXTR.C file date: 03/13/93 page 2 of 2 NEXTTXTR.C




usage example: compiled/executed/verified on 1/31/93

char *Astring = "thisis.thesample string";
char *Bstring = "one_in_here.";
printf("\n%s", ptrnexttextterm(Astring));
printf("\n%s", ptrnexttextterm(Bstring));

.the sample string
.


Hobbit House Software
*/








































page 138 The Hobbit House String Library



NEXTWH.C file date: 03/13/93 page 1 of 2 NEXTWH.C


/* ptrnextwhite
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextwhite (get PoinTer to NEXT WHITEspace)

KWIC: get the pointer to the %next %whitespace in a string

syntax: #include "hhstring.h"
char *ptrnextwhite(char *stringptr)

description: this function returns a pointer to the next "white char"
(either a blank or a tab) in the input string following
the character that is pointed to by the input pointer. If
no such character is found before the end of string, then
a NULL is returned.

returns: a pointer to the next "white char" or a NULL if no "white
char" is found

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, whitespace, blank, tab

key sentence: gets the pointer to the next whitespace in a string

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

















The Hobbit House String Library page 139



NEXTWH.C file date: 03/13/93 page 2 of 2 NEXTWH.C




usage example: compiled/executed/verified on 1/1/93

char *Astring = "thisisthesample string";
char *Bstring = "thisisthesample\tstring";
printf("\n-->%s<--", ptrnextwhite(Astring+5));
printf("\n-->%s<--", ptrnextwhite(Bstring+5));

--> string<--
--> string<-- (NOTE: the whitespace is
the expanded '\t')


Hobbit House Software
*/






































page 140 The Hobbit House String Library



NEXTWORD.C file date: 03/13/93 page 1 of 2 NEXTWORD.C


/* ptrnextword
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextword (get PoinTeR to NEXT WORD)

KWIC: get the pointer to the %next %word in a string

syntax: #include "hhstring.h"
char *ptrnextword(char *instring)

description: this function returns a pointer to the next word in
instring. If there is no next word, then a NULL is
returned. The "next word" means the first non-whitespace
character following the first whitespace character
following instring. Think about it this way; from
instring, you look for the next whitespace and then from
there you look for the next non-whitespace. That way, you
get the next word whether instring starts with a word or
not.

returns: a pointer to the next word

comments: while most of the "ptrnext..." functions are macros
using the corresponding "ptrfirst..." function, that
cannot be done with this function because it is
word-oriented not character-oriented

keywords: pointer, next, word

key sentence: gets the pointer to the next word in a string

see also: ptr< first | last | next | this | prev>word




















The Hobbit House String Library page 141



NEXTWORD.C file date: 03/13/93 page 2 of 2 NEXTWORD.C




usage example: compiled/executed/verified on 1/6/93

char *Astring = "label1 size3";
char *Bstring = "lab2\t\t size4";
char *Cstring = "lab4 ";
printf("\n-->%s<--", ptrnextword(Astring));
printf("\n-->%s<--", ptrnextword(Bstring+4));
printf("\n-->%s<--", ptrnextword(Cstring+4));

-->size3<--
-->size4<--
-->(null)<--


Hobbit House Software
*/




































page 142 The Hobbit House String Library



NEXTWDTR.C file date: 03/13/93 page 1 of 2 NEXTWDTR.C


/* ptrnextwordterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrnextwordterm (get PoinTeR to NEXT WORD TERMinator)

KWIC: get the pointer to the %next %word terminator in a string

syntax: #include "hhstring.h"
char *ptrnextwordterm(char *ptr)

description: this function returns a pointer to the first word
terminator in memory following the given pointer. if the
pointer points at a word terminator, that will NOT be the
one pointed to upon return.

returns: a pointer to the next word terminator (since the string
terminator is a legal word terminator, this function will
never return a but may return a pointer to the string
terminator.

comments: like most of the ptrnext<...> functions, this one is a
macro which uses the corresponding ptrfirst<...>
function. The ptrnext<...> functions are maintained
primarily for the sake of consistency among the names
in HHSTRING. Also, the self-documented feature of the name
seems to us to outweigh the apparent ridiculousness of
maintaining a large group of macros which do nothing
more than add one to a pointer in a call to an existing
function.

keywords: pointer, next, character, word, terminator

key sentence: gets the pointer to the next word terminator in a string

see also: ptr< first | last | next | prev >wordterm

















The Hobbit House String Library page 143



NEXTWDTR.C file date: 03/13/93 page 2 of 2 NEXTWDTR.C




usage example: compiled/executed/verified on 1/31/93

char *Astring = "thisis.thesample string";
char *Bstring = "none_in_here.";
printf("\n%s", ptrnextwordterm(Astring));
printf("\n-->%s<--", ptrnextwordterm(Bstring));

string
--><--



Hobbit House Software
*/






































page 144 The Hobbit House String Library



PREVBLK.C file date: 03/13/93 page 1 of 1 PREVBLK.C


/* ptrprevblank
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevblank (get PoinTeR to PREVious BLANK)

KWIC: get the pointer to the %previous %blank

syntax: #include "hhstring.h"
char *ptrprevblank(char *ptr)

description: gets a pointer to first blank found when scanning
backwards from the specified pointer. If the pointer
points to a blank, that will NOT be the one pointed
to upon return.

returns: a pointer to the previous blank

comments: note that this function skips over EVERYTHING except
blanks which means that it will not stop at variable
boundaries but will just scan all of memory (backwards)
until a blank is found. If you point it somewhere in
a string that doesn't have any blanks, the pointer you
get back will NOT be the start of the string. Be careful!

keywords: pointer, previous, character, blank

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of a blank

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 12/15/92

char *Astring = "This is the Sample string";
printf("%s", ptrprevblank(Astring + 7));

is the Sample string


Hobbit House Software
*/










The Hobbit House String Library page 145



PREVCHR.C file date: 03/13/93 page 1 of 1 PREVCHR.C


/* ptrprevchr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevchr (get PoinTeR to PREVious occurrence of a
specified CHaRacter)

KWIC: get the pointer to the %previous occurrence of a
%character

syntax: #include "hhstring.h"
char *ptrprevchr(char *ptr, char inchar)

description: gets a pointer to first occurrence of inchar found when
scanning backwards from the specified pointer. If the
pointer pointers to an occurrence of inchar, that will
NOT be the one pointed to upon return.

returns: a pointer to the previous inchar

comments: note that this function skips over EVERYTHING except
inchar which means that it will not stop at variable
boundaries but will just scan all of memory (backwards)
until inchar is found. If you point it somewhere in
a string that doesn't have an inchar, the pointer you
get back will NOT be in the string. Be careful!

keywords: pointer, previous, character

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of a given character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 12/15/92

char *Astring = "This is the Sample string";
printf("%s", ptrprevchr(Astring + 17, 's'));

s the Sample string


Hobbit House Software
*/









page 146 The Hobbit House String Library



PREVCHRI.C file date: 03/13/93 page 1 of 1 PREVCHRI.C


/* ptrprevchri
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevchri (get PoinTeR to PREVious occurrence of a
specified CHaRacter, Independant of case)

KWIC: get the pointer to the %previous occurrence of a
%character, %independent of case

syntax: #include "hhstring.h"
char *ptrprevchri(char *ptr, char inchar)

description: gets a pointer to first occurrence of inchar, independent
of case, found when scanning backwards from the specified
pointer. If the pointer points to an occurrence of inchar,
that will NOT be the one pointed to upon return.

returns: a pointer to the previous inchar

comments: note that this function skips over EVERYTHING except
inchar which means that it will not stop at variable
boundaries but will just scan all of memory (backwards)
until inchar is found. If you point it somewhere in
a string that doesn't have an inchar, the pointer you
get back will NOT be in the string. Be careful!

keywords: pointer, previous, character, case-independent

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of a specified character, independent of
case

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 12/15/92

char *Astring = "This is the Sample string";
printf("%s", ptrprevchri(Astring + 17, 's'));

Sample string


Hobbit House Software
*/








The Hobbit House String Library page 147



PREVDIG.C file date: 03/13/93 page 1 of 1 PREVDIG.C


/* ptrprevdig
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevdig (get PoinTeR to PREVious decimal DIGit in
a string)

KWIC: get the pointer to the %previous %decimal %digit

syntax: #include "hhstring.h"
char *ptrprevdig(char *string)

description: gets a pointer to the first decimal digit found when
scanning backwards from the the specified pointer. If
the pointer points to a decimal digit, that is NOT the
one that will be pointed to on return.

returns: a pointer to the previous hex digit

comments: if this function is pointed to somewhere in a string
that doesn't contain any decimal digits, it will return
a pointer that is NOT in the string. Be careful.

keywords: pointer, previous, character, decimal, digit

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character which is a decimal digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char *Astring = " 123 abc this is it";
printf("\n%s", ptrprevdig(Astring + 9));

3 abc this is it


Hobbit House Software
*/












page 148 The Hobbit House String Library



PREVGR.C file date: 03/13/93 page 1 of 1 PREVGR.C


/* ptrprevgr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevgr (get PoinTeR to PREVious occurrence of any of
the characters in a GRoup of characters)

KWIC: get the pointer to the %previous occurrence of a character
from a %group of characters

syntax: #include "hhstring.h"
char *ptrprevgr(char *ptr, char *chars)

description: memory is searched, backwards, starting one character
before the specified pointer. This continues until a
character is found which in the specified group.

returns: a pointer to the character found, or if the character
group is empty, then a NULL will be returned

comments: this function doesn't honor string boundaries, so if
it is given a pointer in a string that does not contain
any of the given characters, it will keep searching
backwards through memory until it finds one. If nowhere
else, it will certainly find one in itself, so the worst
case is that it will read 64K bytes and then exit with
a garbage pointer. BE CAREFUL!

keywords: pointer, previous, character, group

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character in a group of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}gr

usage example: compiled/executed/verified on 2/4/93

char *Astring = "This is it: the Sample string";
printf("\n%s", ptrprevgr(Astring + 20, ",.:;!?"));

: the Sample string


Hobbit House Software
*/







The Hobbit House String Library page 149



PREVHEX.C file date: 03/13/93 page 1 of 1 PREVHEX.C


/* ptrprevhex
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevhex (get PoinTeR to PREVious HEX digit in a string)

KWIC: get the pointer to the %previous %hex digit

syntax: #include "hhstring.h"
char *ptrprevhex(char *string)

description: gets a pointer to the first hex digit found when scanning
backwards from the the specified pointer. If the pointer
points to a hex digit, that is NOT the one that will be
pointed to on return.

returns: a pointer to the previous hex digit

comments: if this function is pointed to somewhere in a string
that doesn't contain any hex digits, it will return a
pointer that is NOT in the string. Be careful.

keywords: pointer, previous, character, hex, digit

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character which is a hex digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char *Astring = " 123 abc this is it";
printf("\n%s", ptrprevhex(Astring + 9));

c this is it


Hobbit House Software
*/













page 150 The Hobbit House String Library



PREVNOBK.C file date: 03/13/93 page 1 of 1 PREVNOBK.C


/* ptrprevnotblank
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnotblank (get PoinTeR to PREVious NOT-BLANK)

KWIC: get the pointer to the %previous %non-blank character

syntax: #include "hhstring.h"
char *ptrprevnotblank(char *ptr)

description: gets a pointer to first non-blank found when scanning
backwards from the specified pointer. If the pointer
points to a non-blank, that will NOT be the one pointed
to upon return.

returns: a pointer to the previous non-blank

comments: none

keywords: pointer, previous, character, not, blank

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character other than a blank

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string";
printf("%s", ptrprevnotblank(Astring + 8));

s the Sample string


Hobbit House Software
*/















The Hobbit House String Library page 151



PREVNOCH.C file date: 03/13/93 page 1 of 1 PREVNOCH.C


/* ptrprevnotchr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnotchr (get PoinTeR, to PREVious, NOT the specified
CHaRacter)

KWIC: get the pointer to the %previous occurrence of a character
which is not the specified %character

syntax: #include "hhstring.h"
char *ptrprevnotchr(char *ptr, char inchar)

description: gets a pointer to first occurrence, found when scanning
backwards from the specified pointer, of a character which
is not inchar. If the pointer pointers to a character
which
is not inchar, that will NOT be the one pointed to upon
return.

returns: a pointer to the previous non-inchar character

comments: note that this function just scans memory (backwards)
until
a non-inchar character is found. If you point it somewhere
in a string that contains only inchar, the pointer you get
back will NOT be in the string. Be careful!

keywords: pointer, character, previous, not

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character other than a given
character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string*******";
printf("\n%s", ptrprevnotchr(strend(Astring), '*'));

g*******


Hobbit House Software
*/







page 152 The Hobbit House String Library



PREVNOCI.C file date: 03/13/93 page 1 of 1 PREVNOCI.C


/* ptrprevnotchri
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnotchri (get PoinTeR to PREVious occurrence of any
character which is NOT the specified
CHaRacter, Independant of case)

KWIC: get the pointer to the %previous occurrence of a character
which is not the specified %character, %independent of
case

syntax: #include "hhstring.h"
char *ptrprevnotchri(char *ptr, char inchar)

description: gets a pointer to first occurrence found, when scanning
backwards from the specified pointer, of any character
which
is not inchar, independent of case. If the pointer points
to
an occurrence of a character other than inchar, that will
NOT
be the one pointed to upon return.

returns: a pointer to the character found

comments: note that this function keeps scanning (backwards) until a
non-inchar is found. If you point it somewhere in a string
that consists of only inchar characters, the pointer you
get
back will NOT be in the string. Be careful!

keywords: pointer, previous, not, case-independent

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character which, independent of
case, is not a specified character

see also: ptr< first | last | next | prev >{not}chr{i}

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the Sample string.......";
printf("%s", ptrprevnotchri(Astring + strlen(Astring),
'.'));

g.......


Hobbit House Software
*/


The Hobbit House String Library page 153



PREVNODG.C file date: 03/13/93 page 1 of 1 PREVNODG.C


/* ptrprevnotdig
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnotdig (get PoinTeR to PREVious NOT decimal DIGit)

KWIC: get the pointer to the %previous character which is not a
%decimal digit

syntax: #include "hhstring.h"
char *ptrprevnotdig(char *string)

description: gets a pointer to the first character found, when scanning
backwards from the the specified pointer, which is not a
decimal digit. If the pointer points to a decimal digit,
that is NOT the one that will be pointed to on return.

returns: a pointer to the character

comments: if this function is pointed to somewhere in a string
that contains only decimal digits, it will return
a pointer that is NOT in the string. Be careful.

keywords: pointer, previous, character, not, decimal, digit

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character which is not a decimal
digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char *Astring = " this is it: 12345";
printf("\n%s", ptrprevnotdig(Astring + strlen(Astring)));

12345


Hobbit House Software
*/











page 154 The Hobbit House String Library



PREVNOGR.C file date: 03/13/93 page 1 of 1 PREVNOGR.C


/* ptrprevnotgr
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnotgr (get PoinTeR to PREVious occurrence of any
character which is NOT in a GRoup of
characters)

KWIC: get the pointer to the %previous character not in a %group
of characters

syntax: #include
#include "hhstring.h"
char *ptrprevnotgr(char *ptr, char *chars)

description: memory is searched, backwards, starting one character
before the specified pointer. This continues until a
character is found which is not in the specified group.

returns: a pointer to the character found.

comments: this function doesn't honor string boundaries, so if
it is given a pointer in a string that does not contain
any of the given characters, it will keep searching
backwards through memory until it finds one. If nowhere
else, it will certainly find one in itself, so the worst
case is that it will read 64K bytes and then exit with
a garbage pointer. BE CAREFUL!

keywords: pointer, previous, character, not, group

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character which is not in a given
group of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}gr

usage example: compiled/executed/verified on 2/4/93

char *Astring = "this is it: -123,456,789.012 ";
printf("%s", ptrprevnotgr(Astring + 25, " ,.-123456789"));

: -123,456,789.012


Hobbit House Software
*/





The Hobbit House String Library page 155



PREVNOHX.C file date: 03/13/93 page 1 of 1 PREVNOHX.C


/* ptrprevnothex
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnothex (get PoinTeR to PREVious NOT-HEX-digit)

KWIC: get the pointer to the %previous character which is not a
%hex digit

syntax: #include "hhstring.h"
char *ptrprevnothex(char *string)

description: gets a pointer to the first character found when scanning
backwards from the the specified pointer, which is not a
hex
digit. If the pointer points to a non-hex digit, that is
NOT
the one that will be pointed to on return.

returns: a pointer to the previous non-hex-digit

comments: if this function is pointed to somewhere in a string
that doesn't contain any hex digits, it will return a
pointer that is NOT in the string. Be careful.

keywords: pointer, previous, character, not, hex, digit

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character which is not a hex digit

see also: ptr< first | last | next | prev >{not}dig
ptr< first | last | next | prev >{not}hex

usage example: compiled/executed/verified on 1/7/93

char *Astring = " this is it: a12ef3";
printf("\n%s", ptrprevnothex(Astring + strlen(Astring)));

a12ef3


Hobbit House Software
*/










page 156 The Hobbit House String Library



PREVNORN.C file date: 03/13/93 page 1 of 1 PREVNORN.C


/* ptrprevnotrange
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnotrange (get PoinTeR, to PREVious, NOT in RANGE)

KWIC: get the pointer to the %previous occurrence of any
character
not in a %range of characters

syntax: #include
#include "hhstring.h"
char *ptrprevnotrange(char *ptr, char c1, char c2)

description: returns the pointer to the first occurrence in memory,
when
scanning backwards from ptr, of any character not in the
range c1 to c2 inclusive

returns: a pointer to the character

comments: none

keywords: pointer, previous, not, character, range

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character which is not in a given
range of characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}set

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is the {Sample} String";
printf("\n%s", ptrprevnotrange(Astring + 20, ' ', 'z'));

} String


Hobbit House Software
*/











The Hobbit House String Library page 157



PREVNOTT.C file date: 03/13/93 page 1 of 1 PREVNOTT.C


/* ptrprevnottextterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnottextterm (get PoinTeR to PREVious NOT-TEXT-
TERMinator)

KWIC: get the pointer to the %previous %non-text-terminator
character

syntax: #include "hhstring.h"
char *ptrprevnottextterm(char *ptr)

description: gets a pointer to first non-text-terminator found when
scanning backwards from the specified pointer. If the
pointer points to a non-text-terminator, that will NOT
be the one pointed to upon return.

returns: a pointer to the previous non-text-terminator

comments: a "text word" is a human language construct as opposed to
a "string word" which is simply a set of characters
surrounded by whitespace. The only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however, may also
be terminated by any of these punctuation marks: .!?:;,

keywords: pointer, previous, character, not, text, terminator

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character other than a text
terminator

see also: ptr< first | last | next | prev >nottextterm

usage example: compiled/executed/verified on 1/31/93

char *Astring = "This is the Sample string";
printf("%s", ptrprevnottextterm(Astring + 8));

s the Sample string


Hobbit House Software
*/







page 158 The Hobbit House String Library



PREVNOWH.C file date: 03/13/93 page 1 of 1 PREVNOWH.C


/* ptrprevnotwhite
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnotwhite (get PoinTeR to PREVious NOT-WHITEspace)

KWIC: get the pointer to the %previous %non-whitespace character

syntax: #include "hhstring.h"
char *ptrprevnotwhite(char *ptr)

description: gets a pointer to first non-whitespace character found
when scanning backwards from the specified pointer. If
the pointer points to a non-whitespace character, that
will NOT be the one pointed to upon return.

returns: a pointer to the previous non-whitespace

comments: none

keywords: pointer, previous, character, not, whitespace, blank, tab

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character other than whitespace

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is\tthe sample string";
printf("%s", ptrprevnotwhite(Astring + 8));

s the sample string note: blanks are
the expanded TAB


Hobbit House Software
*/














The Hobbit House String Library page 159



PREVNOWT.C file date: 03/13/93 page 1 of 1 PREVNOWT.C


/* ptrprevnotwordterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevnotwordterm (get PoinTeR to PREVious NOT-WORD-
TERMinator)

KWIC: get the pointer to the %previous %non-word-terminator
character

syntax: #include "hhstring.h"
char *ptrprevnotwordterm(char *ptr)

description: gets a pointer to first non-word-terminator found when
scanning backwards from the specified pointer. If the
pointer points to a non-word-terminator, that will NOT
be the one pointed to upon return.

returns: a pointer to the previous non-word-terminator

comments: none

keywords: pointer, previous, character, not, word, terminator

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character other than a word
terminator

see also: ptr< first | last | next | prev >notwordterm

usage example: compiled/executed/verified on 1/31/93

char *Astring = "This is the Sample string";
printf("%s", ptrprevnotwordterm(Astring + 8));

s the Sample string


Hobbit House Software
*/













page 160 The Hobbit House String Library



PREVRAN.C file date: 03/13/93 page 1 of 1 PREVRAN.C


/* ptrprevrange
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevrange (get PoinTeR, PREVious, from RANGE)

KWIC: get the pointer to the %previous occurrence of any
character
from a %range of characters

syntax: #include
#include "hhstring.h"
char *ptrprevrange(char *ptr, char c1, char c2)

description: memory is scanned backwards, starting one character before
ptr, until an occurrence is found of a character which is
in the range c1 to c2 inclusive

returns: a pointer to the character found

comments: none

keywords: pointer, previous, character, range

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of any character from a given range of
characters

see also: ptr< first | last | next | prev >{not}range
ptr< first | last | next | prev >{not}set

usage example: compiled/executed/verified on 1/7/93

char *Astring = "This is it: the Sample string";
printf("\n%s", ptrprevrange(Astring + 20, '!', '?'));

: the Sample string


Hobbit House Software
*/












The Hobbit House String Library page 161



PREVSUB.C file date: 03/13/93 page 1 of 1 PREVSUB.C


/* ptrprevsub
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevsub (get PoinTer to PREVious occurrence of a
SUBstring)

KWIC: get the pointer to the %previous occurrence of a
%substring

syntax: #include "hhstring.h"
char *ptrprevsub(char *ptr, char *substring)

description: gets a pointer to first occurrence of the substring found
when scanning backwards from the specified pointer. If the
pointer pointers to an occurrence of the substring, that
will
NOT be the one pointed to upon return.

returns: a pointer to the substring found

comments: note that this function will just scan all of memory
(backwards) until inchar is found. If you point it
somewhere in a string that doesn't have an inchar, the
pointer you get back will NOT be in the string. Be
careful!

keywords: pointer, previous, substring

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of a given substring

see also: ptr< first | last | next | prev >sub{i}

usage example: compiled/executed/verified on 12/21/92

char *Astring = "This is the Sample string";
printf("%s", ptrprevsub(Astring + 25, "Sample"));

Sample string


Hobbit House Software
*/









page 162 The Hobbit House String Library



PREVSUBI.C file date: 03/13/93 page 1 of 1 PREVSUBI.C


/* ptrprevsubi
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevsubi (get PoinTer to PREVious occurrence of a
SUBstring, Independant of case)

KWIC: get thepointer to the %previous occurrence of a
%substring, %independent of case

syntax: #include "hhstring.h"
char *ptrprevsubi(char *ptr, char *substring)

description: gets a pointer to first case-independent occurrence of the
substring found when scanning backwards from the specified
pointer. If the pointer pointers to an occurrence of the
substring, that will NOT be the one pointed to upon
return.

returns: a pointer to the substring found

comments: note that this function will just scan all of memory
(backwards) until inchar is found. If you point it
somewhere in a string that doesn't have an inchar, the
pointer you get back will NOT be in the string. Be
careful!

keywords: pointer, previous, substring, case-independent

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of a given substring, independent of case

see also: ptr< first | last | next | prev >sub{i}

usage example: compiled/executed/verified on 12/21/92

char *Astring = "This is the Sample string";
printf("%s", ptrprevsubi(Astring + 25, "SAMPLE"));

Sample string


Hobbit House Software
*/









The Hobbit House String Library page 163



PREVTEXT.C file date: 03/13/93 page 1 of 2 PREVTEXT.C


/* ptrprevtext
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevtext (get PoinTeR to PREVious TEXT word)

KWIC: get the pointer to the %previous %text word from a given
pointer

syntax: #include "hhstring.h"
char *ptrprevtext(char *ptr)

description: scans backwards for a character which is a text word
terminator (see comments below), then scans backward
for non-terminator, then scans backward for a terminator
again and returns the pointer to the text word following
that terminator. Think of it this way; given a pointer to
any point in a sentence, this function returns the pointer
to the word preceding the one pointed to. If the pointer
points at a text word terminator, this function returns
the pointer to the text word which precedes the
terminator.

returns: a pointer to the previous text word

comments: If the pointer points to the end of a string or to an EOL
('\n'), the function will return a pointer to the last
word in the string.

If the input pointer points to the first word in a string,
prevword will NOT be that word but will be that word
preceded by all of the characters which precede it in
memory up to and including the previous text word.
Be careful!

keywords: pointer, previous, word, text

key sentence: gets the pointer to the text word previous to the position
pointed to

see also: ptr< first | last | next | this | prev>text












page 164 The Hobbit House String Library



PREVTEXT.C file date: 03/13/93 page 2 of 2 PREVTEXT.C




usage example: compiled/executed/verified on 1/30/93

char str[80] = "time date size.other";
printf("\n%s", ptrprevtext(str+15));
printf("\n%s", ptrprevtext(str+13));

size.other
date size.other


Hobbit House Software
*/









































The Hobbit House String Library page 165



PREVTXTR.C file date: 03/13/93 page 1 of 1 PREVTXTR.C


/* ptrprevtextterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevtextterm (get PoinTeR to PREVious TEXT word
TERMinator)

KWIC: get the pointer to the %previous %text word terminator

syntax: #include "hhstring.h"
char *ptrprevtextterm(char *ptr)

description: gets a pointer to first text word terminator found when
scanning backwards from the specified pointer. If the
pointer points to a text word terminator, that will NOT
be the one pointed to upon return.

returns: a pointer to the previous text word terminator

comments: note that this function skips over EVERYTHING except
word terminators which means that it will not stop at
string boundaries but will just scan all of memory
(backwards) until a text word terminator is found. If you
point it somewhere in a string that doesn't have any
preceding text word terminators, the pointer you get back
will NOT be the start of the string, but will most likely
be a pointer to the string terminator of the previous
string in memory. Be careful!

keywords: pointer, previous, character, text, word, terminator

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of a text word terminator

see also: ptr< first | last | next | prev >textterm

usage example: compiled/executed/verified on 1/31/93

char *Astring = "This is the Sample string";
printf("%s", ptrprevtextterm(Astring + 7));

is the Sample string


Hobbit House Software
*/







page 166 The Hobbit House String Library



PREVWH.C file date: 03/13/93 page 1 of 1 PREVWH.C


/* ptrprevwhite
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevwhite (get PoinTeR to PREVious WHITEspace)

KWIC: get the pointer to the %previous %whitespace character

syntax: #include "hhstring.h"
char *ptrprevwhite(char *ptr)

description: gets a pointer to first whitespace found when scanning
backwards from the specified pointer. If the pointer
points to a white character, that will NOT be the one
pointed to upon return.

returns: a pointer to the previous whitespace character

comments: note that this function skips over EVERYTHING except
blanks and tabs which means that it will not stop at
variable boundaries but will just scan all of memory
(backwards) until a blank or tab is found. If you point
it somewhere in a string that doesn't have any whitespace,
the pointer you get back will NOT be the start of the
string. Be careful!

keywords: pointer, previous, character, whitespace, blank, tab

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of a whitespace character (tab or blank)

see also: ptr< first | last | next | prev >{not}blank
ptr< first | last | next | prev >{not}white

usage example: compiled/executed/verified on 12/14/92

char *Astring = "This is the sample string";
printf("%s", ptrprevwhite(Astring + 7));

is the sample string


Hobbit House Software
*/









The Hobbit House String Library page 167



PREVWORD.C file date: 03/13/93 page 1 of 2 PREVWORD.C


/* ptrprevword
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevword (get PoinTeR to PREVious WORD)

KWIC: get the pointer to the %previous %word from a given
pointer

syntax: #include "hhstring.h"
char *ptrprevword(char *ptr)

description: scans backwards for whitespace, then scans backward
for non-whitespace, then scans backward for whitespace
again and returns the pointer to the word following that
whitespace. Think of it this way; given a pointer to any
point in a sentence, this function returns the pointer to
the word preceding the one pointed to. If the pointer
points at whitespace, this function returns the pointer to
the word which precedes the whitespace.

returns: a pointer to the previous word

comments: If the pointer points to the end of a string or to an EOL
('\n'), the function will return a pointer to the last
word in the string.

If the input pointer points to the first word in a string,
prevword will NOT be that word but will be that word
preceded by all of the characters which precede it in
memory up to and including the previous word. Be careful!

keywords: pointer, previous, word

key sentence: gets the pointer to the word previous to the position
pointed to

see also: ptr< first | last | next | this | prev>word















page 168 The Hobbit House String Library



PREVWORD.C file date: 03/13/93 page 2 of 2 PREVWORD.C




usage example: compiled/executed/verified on 12/14/92

char str[80] = "time date size other";
printf("\n%s", ptrprevword(str+9));
printf("\n%s", ptrprevword(str+13));

date size other
date size other


Hobbit House Software
*/








































The Hobbit House String Library page 169



PREVWDTR.C file date: 03/13/93 page 1 of 1 PREVWDTR.C


/* ptrprevwordterm
Hobbit House Software

copyright(c) 1992, 1993

function: ptrprevwordterm (get PoinTeR to PREVious WORD TERMinator)

KWIC: get the pointer to the %previous %word terminator

syntax: #include "hhstring.h"
char *ptrprevwordterm(char *ptr)

description: gets a pointer to first word terminator found when
scanning backwards from the specified pointer. If the
pointer points to a word terminator, that will NOT be
the one pointed to upon return.

returns: a pointer to the previous word terminator

comments: note that this function skips over EVERYTHING except
word terminators which means that it will not stop at
string boundaries but will just scan all of memory
(backwards) until a word terminator is found. If you
point it somewhere in a string that doesn't have any
preceding word terminators, the pointer you get back
will NOT be the start of the string, but will most likely
be a pointer to the string terminator of the previous
string in memory. Be careful!

keywords: pointer, previous, character, word, terminator

key sentence: gets the pointer to the first occurrence, previous to a
given pointer, of a word terminator

see also: ptr< first | last | next | prev >wordterm

usage example: compiled/executed/verified on 1/31/93

char *Astring = "This is the Sample string";
printf("%s", ptrprevwordterm(Astring + 7));

is the Sample string


Hobbit House Software
*/








page 170 The Hobbit House String Library



THISTEXT.C file date: 03/13/93 page 1 of 1 THISTEXT.C


/* ptrthistext
Hobbit House Software

copyright(c) 1992, 1993

function: ptrthistext (get PoinTeR to THIS TEXT)

KWIC: get the pointer to the beginning of the %text word pointed
to, regardless of what character in the word is pointed to

syntax: #include "hhstring.h"
char *ptrthistext(char *ptr)

description: scans backward until whitespace is encountered and then
returns the pointer to the character following the
whitespace. If the input pointer points at whitespace or
a string terminator, then the return will be NULL.

returns: a pointer to the text word

comments: If the input pointer points to the first text word in a
string, the pointer returned will almost certainly NOT
point to that text word but will point to that text word
preceded by all of the non-text-terminator characters
which precede it in memory.

keywords: pointer, this, text, word

key sentence: gets the pointer to the beginning of the text word pointed
to, regardless of what character in the word is pointed to

see also: ptr< first | last | next | this | prev>text

usage example: compiled/executed/verified on 2/21/93

char string[80] = "time date size other";
printf("\n%s", ptrthistext(string+5));
printf("\n%s", ptrthistext(string+8));

date size other
date size other


Hobbit House Software
*/









The Hobbit House String Library page 171



THISWORD.C file date: 03/13/93 page 1 of 1 THISWORD.C


/* ptrthisword
Hobbit House Software

copyright(c) 1992, 1993

function: ptrthisword (get PoinTeR to THIS WORD)

KWIC: get the pointer to the beginning of the %word pointed to,
regardless of what character in the word is pointed to

syntax: #include "hhstring.h"
char *ptrthisword(char *ptr)

description: scans backward until whitespace is encountered and then
returns the pointer to the character following the
whitespace. If the input pointer points at whitespace or
a string terminator, then the return will be NULL.

returns: a pointer to the word

comments: If the input pointer points to the first word in a string,
the pointer returned will almost certainly NOT point to
that word but will point to that word preceded by all of
the non-whitespace characters which precede it in memory.

keywords: pointer, this, word

key sentence: gets the pointer to the beginning of the word pointed to,
regardless of what character in the word is pointed to

see also: ptr< first | last | next | this | prev>word

usage example: compiled/executed/verified on 12/13/92

char string[80] = "time date size other";
printf("\n%s", ptrthisword(string+5));
printf("\n%s", ptrthisword(string+8));

date size other
date size other


Hobbit House Software
*/










page 172 The Hobbit House String Library



BLANK.C file date: 03/13/93 page 1 of 1 BLANK.C


/* strblank
Hobbit House Software

copyright(c) 1992, 1993

function: strblank (STRing, set to all BLANKs)

KWIC: set a string to all %blanks

syntax: #include "hhstring.h"
char *strblank(char *instring)

description: takes a string which has a terminating '\0' and fills it
with blanks, leaving the terminating zero in place.

returns: a pointer to the string

comments: this is a macro, defined in hhstring as:

#define strblank(s) strset(s, ' ')

keywords: string, character, set, blank

key sentence: sets a string to all blanks

see also: str< blank | eos | set | zero >

usage example: compiled/executed/verified on 12/13/92

char *instring = "this string";
strblank(instring);
printf("%s%d", instring, strlen(instring));

11



Hobbit House Software
*/















The Hobbit House String Library page 173



BLK2TAB.C file date: 03/13/93 page 1 of 2 BLK2TAB.C


/* strblanktotab
Hobbit House Software

copyright(c) 1992, 1993

function: strblanktotab (STRing BLANKs TO TAB compression)

KWIC: compress excess %blanks to %TAB characters

syntax: #include "hhstring.h"
char *strblanktotab(char *inpline, int tabspace)

description: long strings of blanks are compressed to TAB characters.
How many spaces are compressed depends on the tabspace.
A few blanks just before a tabspace boundary will also be
compressed.

returns: a pointer to the string

comments: (1) The string pointed to by the return value of this
function is in the calling function's space. The
return value is provided as a convenience, not a
necessity.
(2) It may see strange, at first glance, that the input
line first has all existing tabs removed before tabs
are added. This is quite necessary, however, to
assure proper operation of the program in all cases.

keywords: string, blank, tab, convert

key sentence: compresses blanks to a specified tab spacing (including
string
inside quotes, so be careful)

see also: strtabtoblank strblanktotab

usage example: compiled/executed/verified on 2/21/93

int ii;
char Astring[80];

strcpy(Astring, "This is the sample line");
printf("\n\n%s", Astring);
strblanktotab(Astring, 8);
printf("\n12345678901234567890123456789012345678\n");
for (ii = 0; ii < strlen(Astring); ii++)
putch(Astring[ii]);

strcpy(Astring, "This is the sample line");
printf("\n\n%s", Astring);
strblanktotab(Astring, 4);
printf("\n12345678901234567890123456789012345678\n");
for (ii = 0; ii < strlen(Astring); ii++)

page 174 The Hobbit House String Library



BLK2TAB.C file date: 03/13/93 page 2 of 2 BLK2TAB.C


putch(Astring[ii]);


[NOTE: in the following "printout", the ^ represents a
TAB]

This is the sample line
12345678901234567890123456789012345678
This^is the^ sample^line

This is the sample line
12345678901234567890123456789012345678
This^is^the^^ sample^^line


Hobbit House Software
*/





































The Hobbit House String Library page 175



CENTER.C file date: 03/13/93 page 1 of 2 CENTER.C


/* strcenter
Hobbit House Software

copyright(c) 1992, 1993

function: strcenter (STRing CENTER)

KWIC: %center a string

syntax: #include "hhstring.h"
char *strcenter(char *instring)

description: evens out the blanks around a string so that the non-blank
text is centered. TABs are treated as non-blank
characters, so this function is not necessarily useful for
strings with leading and/or trailing TABs (the function
strtabtoblank can be used to expand TABs prior to
centering and the function strblanktotab can be used to
replace excess blanks with TABs after centering).

returns: a pointer to the string

comments: this function assumes that the input string contains
whitespace on one or both sides but there is no problem
if it doesn't. If there is no whitespace at all, this
function does nothing.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, center, justify

key sentence: centers a string

see also: str< lf | rt >just{new} strcenter{n}{new}


















page 176 The Hobbit House String Library



CENTER.C file date: 03/13/93 page 2 of 2 CENTER.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = " 2 left blanks, 11 right blanks ";
char *Bstring = " 12 left blanks, 0 right blanks";
strcenter(Astring);
strcenter(Bstring);
printf("\n-->%s<--\n-->%s<--", Astring, Bstring);

--> 2 left blanks, 11 right blanks <--
--> 12 left blanks, 0 right blanks <--


Hobbit House Software
*/






































The Hobbit House String Library page 177



CENTERN.C file date: 03/13/93 page 1 of 2 CENTERN.C


/* strcentern
Hobbit House Software

copyright(c) 1992, 1993

function: strcentern (STRing CENTER to N-char size)

KWIC: %center a string and force it to a specified %size

syntax: #include "hhstring.h"
char *strcentern(char *instring, int width)

description: evens out the blanks around a string so that the non-blank
text is centered, while at the same time setting the total
string size (including blanks) to the specified width.

returns: a pointer to the string;

comments: this function assumes that the input string contains
whitespace on one or both sides but there is no problem
if it doesn't. If there is no whitespace at all, this
function does nothing.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, center, size, justify, truncate

key sentence: centers a string and forces it to a specified width

see also: str< lf | rt >just{new} strcenter{n}{new}






















page 178 The Hobbit House String Library



CENTERN.C file date: 03/13/93 page 2 of 2 CENTERN.C




usage example: compiled/executed/verified on 12/13/92

char Astring[80] = " string #1";
char Bstring[80] = "string #2";
strcentern(Astring, 13);
strcentern(Bstring, 13);
printf("-->%s<--\n-->%s<--", Astring, Bstring);

--> string #1 <--
--> string #2 <--


Hobbit House Software
*/






































The Hobbit House String Library page 179



CENTERW.C file date: 03/13/93 page 1 of 2 CENTERW.C


/* strcenternew
Hobbit House Software

copyright(c) 1992, 1993

function: strcenternew (STRing CENTER to NEW string)

KWIC: %center a string

syntax: #include "hhstring.h"
char *strcenternew(char *newstring, char *instring)

description: evens out the blanks around a string so that the non-blank
text is centered. TABs are treated as non-blank
characters,
so this function is not necessarily useful for strings
with
leading and/or trailing TABs. The result is created in the
new string with the input string being left untouched.

returns: a pointer to the new string

comments: this function assumes that the input string contains
whitespace on one or both sides but there is no problem
if it doesn't. If there is no whitespace at all, this
function just moves instring to newstring.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will not work with this
function and overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, center, justify, new

key sentence: centers a string and puts the result in a new string

see also: str< lf | rt >just{new} strcenter{n}{new}














page 180 The Hobbit House String Library



CENTERW.C file date: 03/13/93 page 2 of 2 CENTERW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = " 2 left blanks, 11 right blanks ";
char *Bstring = " 12 left blanks, 0 right blanks";
char Cstring[80];
char Dstring[80];
strcenternew(Cstring, Astring);
strcenternew(Dstring, Bstring);
printf("\n-->%s<--\n-->%s<--", Cstring, Dstring);

--> 2 left blanks, 11 right blanks <--
--> 12 left blanks, 0 right blanks <--

Hobbit House Software
*/





































The Hobbit House String Library page 181



CENTERNW.C file date: 03/13/93 page 1 of 2 CENTERNW.C


/* strcenternnew
Hobbit House Software

copyright(c) 1992, 1993

function: strcenternnew (STRing, CENTER, to N-chars, to NEW)

KWIC: %center a string and force it to a specified %size

syntax: #include "hhstring.h"
char *strcenternnew(char *newstring, char *instring,
int width)

description: evens out the blanks around a string so that the non-blank
text is centered, while at the same time setting the total
string size (including blanks) to the specified width and
putting the result into newstring.

returns: a pointer to the new string;

comments: this function assumes that the input string contains
whitespace on one or both sides but there is no problem
if it doesn't. If there is no whitespace at all, this
function does nothing.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring does not work with this
function and overlapping newstring/instring may or may not
work so if you must overlap, do it cautiously.

keywords: string, center, justify, size, new, truncate

key sentence: centers a string and forces it to a specified width and
puts the result into a new string

see also: str< lf | rt >just{new} strcenter{n}{new}















page 182 The Hobbit House String Library



CENTERNW.C file date: 03/13/93 page 2 of 2 CENTERNW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = " string #1";
char *Bstring = "string #2";
char Cstring[20];
strcenternnew(Cstring, Astring, 13);
printf("\n-->%s<--", Cstring);
strcenternnew(Cstring, Bstring, 13);
printf("\n-->%s<--", Cstring);

--> string #1 <--
--> string #2 <--


Hobbit House Software
*/




































The Hobbit House String Library page 183



CKSUMA.C file date: 03/13/93 page 1 of 1 CKSUMA.C


/* strchecksuma
Hobbit House Software

copyright(c) 1992, 1993

function: strchecksuma (STRing, get CHECKSUM, Arithmetic)

KWIC: computes the %arithmetic %checksum of a string.

syntax: #include "hhstring.h"
unsigned long strchecksuma(char *instring)

description: an arithmetic checksum is taken on instring

returns: the arithmetic checksum of the input string

comments: Note that a long result is used so as to provide a
substantially more reliable result than is provided by the
original mag-tape checksum concept (circa 1955) in which
the checksum of a string of bytes was a byte (the "sum"
was actually an exclusive-or of the bytes). In other
words, this function gives an arithmetic sum, not a
logical checksum.

keywords: string, checksum, arithmetic

key sentence: computes the arithmetic checksum of a string

see also: strchecksum{i}< a | l >

usage example: compiled/executed/verified on 12/20/92

char *Astring = "This is the Sample string";
printf("%d", strchecksuma(Astring));

2350


Hobbit House Software
*/














page 184 The Hobbit House String Library



CKSUMIA.C file date: 03/13/93 page 1 of 1 CKSUMIA.C


/* strchecksumia
Hobbit House Software

copyright(c) 1992, 1993

function: strchecksumia (STRing, get CHECKSUM, case-Independant,
Arithmetic)

KWIC: computes the %arithmetic %checksum of a string %indpendant
of case

syntax: #include "hhstring.h"
unsigned long strchecksumia(char *instring);

description: an arithmetic checksum is taken on instring with each
character being converted to upper case before the
checksum is taken

returns: the arithmetic checksum of the input string (taken as
being case independent)

comments: Note that a long result is used so as to provide a
substantially more reliable result than is provided by the
original mag-tape checksum concept (circa 1955) in which
the checksum of a string of bytes was a byte (the "sum"
was actually an exclusive-or of the bytes). In other
words, this function gives an arithmetic sum, not a
logical checksum.

keywords: string, checksum, arithmetic, case-independent

key sentence: computes the arithmetic checksum of a string, independent
of case

see also: strchecksum{i}< a | l >

usage example: compiled/executed/verified on 12/20/92

char *Astring = "This is the Sample string";
printf("%d", strchecksumia(Astring));

1742


Hobbit House Software
*/








The Hobbit House String Library page 185



CKSUMIL.C file date: 03/13/93 page 1 of 1 CKSUMIL.C


/* strchecksumil
Hobbit House Software

copyright(c) 1992, 1993

function: strchecksumil (STRing, get CHECKSUM, case-Independant,
Logical)

KWIC: computes the %logical %checksum of a string, %independant
of case

syntax: #include "hhstring.h"
unsigned char strchecksumil(char *instring)

description: a logical checksum is taken on instring, with each
character being converted to upper case before the
checksum is taken

returns: the logical checksum of the input string (taken as a
case-independent string)

comments: Note that this function is based on the original concept
of a checksum as the exclusive-or of string of bytes. This
concept, (circa 1955) is much less reliable than the
arithmetic checksum provided by the functions
strchecksuma and strchecksumia.

keywords: string, checksum, logical, case-independent

key sentence: computes the logical checksum of a string, independent of
case

see also: strchecksum{i}< a | l >

usage example: compiled/executed/verified on 12/20/92

char *Astring = "This is the Sample string";
printf("%2.2x", strchecksumil(Astring));

56


Hobbit House Software
*/










page 186 The Hobbit House String Library



CKSUML.C file date: 03/13/93 page 1 of 1 CKSUML.C


/* strchecksuml
Hobbit House Software

copyright(c) 1992, 1993

function: strchecksuml (STRing, get CHECKSUM, Logical)

KWIC: computes the %logical %checksum of a string.

syntax: #include "hhstring.h"
unsigned char strchecksuml(char *instring);

description: a logical checksum is taken on instring

returns: the logical checksum of the input string

comments: Note that this function is based on the original concept
of a checksum as the exclusive-or of string of bytes. This
concept, (circa 1955) is much less reliable than the
arithmetic checksum provided by the function strchecksuma.

keywords: string, checksum, logical

key sentence: computes the logical checksum of a string

see also: strchecksum{i}< a | l >

usage example: compiled/executed/verified on 12/20/92

char *Astring = "This is the Sample string";
printf("%2.2x", strchecksuml(Astring));

76


Hobbit House Software
*/

















The Hobbit House String Library page 187



CHRCNT.C file date: 03/13/93 page 1 of 1 CHRCNT.C


/* strchrcount
Hobbit House Software

copyright(c) 1992, 1993

function: strchrcount (STRing CHaRacter COUNT of occurrences)

KWIC: return the %count of occurrences of a particular
%character
in a given string

syntax: #include "hhstring.h"
int strchrcount(char *instring, int c)

description: instring is scanned and the occurrences of the character
c are counted

returns: the number of occurrences

comments: none

keywords: string, character, count

key sentence: reports the number of occurrences in a string of a
given character

see also: strchrcount{i}

usage example: compiled/executed/verified on 12/15/92

char *Astring = "This is The Sample String";
printf("%d", strchrcount(Astring, 's'));

2


Hobbit House Software
*/
















page 188 The Hobbit House String Library



CHRCNTI.C file date: 03/13/93 page 1 of 1 CHRCNTI.C


/* strchrcounti
Hobbit House Software

copyright(c) 1992, 1993

function: strchrcounti (STRing CHaRacter, COUNT of occurrences,
case-Independant)

KWIC: return the %count of occurrences, %independant of case, of
a %character in a given string

syntax: #include "hhstring.h"
int strchrcounti(char *instring, char c)

description: instring is scanned and the case-independent occurrences
of the character c are counted

returns: the number of occurrences

comments: none

keywords: string, character, count, case-independent

key sentence: reports the number occurrences in a string of a case-
independent character

see also: strchrcount{i}

usage example: compiled/executed/verified on 12/15/92

char *Astring = "This is The Sample String";
printf("%d", strchrcounti(Astring, 's'));

4


Hobbit House Software
*/
















The Hobbit House String Library page 189




CHRDEL.C file date: 03/13/93 page 1 of 1 CHRDEL.C


/* strchrdel
Hobbit House Software

copyright(c) 1992, 1993

function: strchrdel (STRing CHaRacter DELete)

KWIC: %delete, from a string, all occurrences of a given
%character

syntax: #include "hhstring.h"
char *strchrdel(char *instring, char delchar)

description: all occurrences of delchar are deleted from the string

returns: a pointer to the string

comments: a delchar of binary zero ('\0') will have no effect other
than to waste some machine time.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, character, delete

key sentence: deletes from a string all occurrences of a given character

see also: strchrdel< {i} | range | set >{new}

usage example: compiled/executed/verified on 2/19/93

char *Astring = "Dummy string --- to show char deletion";
printf("\n%s", strchrdel(Astring, '-'));
strchrdel(Astring, ' ');
printf("\n%s", Astring);

Dummy string to show char deletion
Dummystringtoshowchardeletion


Hobbit House Software
*/











page 190 The Hobbit House String Library



CHRDELG.C file date: 03/13/93 page 1 of 1 CHRDELG.C


/* strchrdelgr
Hobbit House Software

copyright(c) 1992, 1993

function: strchrdelgr (STRing, CHaRacter, DELete a GRoup of chars)

KWIC: %delete (from a string) all occurrences of each of a given
%group of characters

syntax: #include "hhstring.h"
char *strchrdelgr(char *instring, char *delchars)

description: all occurrences of each of the characters in delchars are
deleted from the string

returns: a pointer to the string

comments: a delchars character of '\0' will always be taken as the
terminator for the delchars string, so '\0' cannot be a
valid delchars character.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, character, delete, group

key sentence: deletes from a string all occurrences of any of the
characters in a group of characters

see also: strchrdel< {i} | range | gr >{new}

usage example: compiled/executed/verified on 2/4/93

char *Astring = "to // show \\ deletion ----";
printf("\n%s", strchrdelgr(Astring, "/\\"));
printf("\n%s", strchrdelgr(Astring, "- "));

to show deletion ----
toshowdeletion


Hobbit House Software
*/









The Hobbit House String Library page 191



CHRDELGW.C file date: 03/13/93 page 1 of 2 CHRDELGW.C


/* strchrdelgrnew
Hobbit House Software

copyright(c) 1992, 1993

function: strchrdelgrnew (STRing, CHaRacter, DELete a GRoup of
characters to NEW string)

KWIC: %delete all occurances of any character from a %group of
characters

syntax: #include "hhstring.h"
char *strchrdelgrnew(char *newstring, char *instring,
char *delchars)

description: newstring is created as instring without any occurrences
of
any of the characters in delchars

returns: a pointer to newstring

comments: a delchars character of '\0' will always be taken as the
terminator for the delchars string, so '\0' cannot be a
valid delchars character.

Logically, it should not be a requirement that newstring
be as large as instring (one might KNOW that at least
SOME characters were going to get deleted) but this
particular implementation DOES require it.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, character, delete, group, new

key sentence: deletes from a string all occurrences of any of the
characters in a group of characters and puts the result
into a new string

see also: strchrdel< {i} | range | gr >{new}









page 192 The Hobbit House String Library



CHRDELGW.C file date: 03/13/93 page 2 of 2 CHRDELGW.C




usage example: compiled/executed/verified on 2/4/93

char Astring[80] = "to // show \\ deletion ----";
char Bstring[80];
char Cstring[80];
strchrdelgrnew(Bstring, Astring, "/\\");
printf("\n%s", Bstring);
printf("\n%s", strchrdelgrnew(Cstring, Bstring, "- "));

to show deletion ----
toshowdeletion


Hobbit House Software
*/





































The Hobbit House String Library page 193



CHRDELI.C file date: 03/13/93 page 1 of 1 CHRDELI.C


/*
strchrdeli
Hobbit House Software

copyright(c) 1992, 1993

function: strchrdeli (STRing, CHaRacter, DELete, case-Independant)

KWIC: %delete, from a string, all occurrences of a given
%character, %independant of case

syntax: #include "hhstring.h"
char *strchrdeli(char *instring, char delchar)

description: all case-independent occurrences of delchar are deleted
from the string

returns: a pointer to the string

comments: a delchar of binary zero ('\0') will have no effect other
than to waste some machine time.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, character, delete, case-independent

key sentence: deletes from a string all case-independent occurrences
of a given character

see also: strchrdel< {i} | range | set >{new}

usage example: compiled/executed/verified on 2/25/93

char Astring[80] = "Dummy --- to show char deletion";
printf("\n%s", strchrdeli(Astring, '-'));
strchrdeli(Astring, 'd');
printf("\n%s", Astring);

Dummy to show char deletion
ummy to show char eletion


Hobbit House Software
*/








page 194 The Hobbit House String Library



CHRDELIW.C file date: 03/13/93 page 1 of 2 CHRDELIW.C


/* strchrdelinew
Hobbit House Software

copyright(c) 1992, 1993

function: strchrdelinew (STRing, CHaRacter, DELete,
case-Independant, to NEW string)

KWIC: %delete all occurrences of a given %character,
%independant of case

syntax: #include "hhstring.h"
char *strchrdelinew(char *newstring, char *instring,
char delchar)

description: newstring is created as instring but with all case-
independent occurrences of delchar having been deleted

returns: a pointer to newstring

comments: if delchar is binary zero ('\0'), newstring will equal
instring

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, character, delete, case-independent, new

key sentence: deletes from a string all case-independent occurrences
of a given character and puts the result into a new string

see also: strchrdel< {i} | range | set >{new}

















The Hobbit House String Library page 195



CHRDELIW.C file date: 03/13/93 page 2 of 2 CHRDELIW.C




usage example: compiled/executed/verified on 2/25/93

char Astring[80] = "Dummy --- to show char deletion";
char Bstring[80];
char Cstring[80];
printf("\n%s", strchrdelinew(Bstring, Astring, '-'));
strchrdelinew(Cstring, Bstring, 'd');
printf("\n%s", Cstring);

Dummy to show char deletion
ummy to show char eletion


Hobbit House Software
*/





































page 196 The Hobbit House String Library



CHRDELW.C file date: 03/13/93 page 1 of 2 CHRDELW.C


/* strchrdelnew
Hobbit House Software

copyright(c) 1992, 1993

function: strchrdelnew (STRing, CHaRacter, DELete a character to
NEW string)

KWIC: %delete (from a string) all occurrences of a given
%character

syntax: #include "hhstring.h"
char *strchrdelnew(char *newstring, char *instring,
char delchar)

description: newstring is created as instring but with all occurrences
of
delchar having been deleted

returns: a pointer to newstring

comments: if delchar is binary zero ('\0'), newstring will equal
instring

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, character, delete, new

key sentence: deletes from a string all occurrences of a given character
and puts the result into a new string

see also: strchrdel< {i} | range | set >{new}
















The Hobbit House String Library page 197



CHRDELW.C file date: 03/13/93 page 2 of 2 CHRDELW.C




usage example: compiled/executed/verified on 2/19/93

char Astring[80] = "Dummy string --- to show char deletion";
char Bstring[80];
char Cstring[80];
printf("\n%s", strchrdelnew(Bstring, Astring, '-'));
strchrdelnew(Cstring, Bstring, ' ');
printf("\n%s", Cstring);

Dummy string to show char deletion
Dummystringtoshowchardeletion


Hobbit House Software
*/





































page 198 The Hobbit House String Library



CHRDELR.C file date: 03/13/93 page 1 of 1 CHRDELR.C


/* strchrdelrange
Hobbit House Software

copyright(c) 1992, 1993

function: strchrdelrange (STRing, CHaRacter, DELete a RANGE of
characters)

KWIC: %delete all characters in a specified %range, inclusive

syntax: #include "hhstring.h"
char *strchrdelrange(char *instring, char lo, char hi)

description: all of the characters in instring which fall in the range
from lo to hi, inclusive, are deleted from the string

returns: a pointer to the string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, character, delete, range

key sentence: deletes from a string all characters in a specified range

see also: strchrdel< {i} | range | set >{new}

usage example: compiled/executed/verified on 12/15/92

char *Astring = "THIS (is) the Sample";
strchrdelrange(Astring, '!', 'Z');
printf("\n%s", Astring);
printf("\n%s", strchrdelrange(Astring, 'a', 'e'));

is the ample
is th mpl


Hobbit House Software
*/













The Hobbit House String Library page 199



CHRDELRW.C file date: 03/13/93 page 1 of 2 CHRDELRW.C


/* strchrdelrangenew
Hobbit House Software

copyright(c) 1992, 1993

function: strchrdelrangenew (STRing, CHaRacter, DELete a RANGE of
characters to a NEW string)

KWIC: %delete all characters in a specified %range, inclusive

syntax: #include "hhstring.h"
char *strchrdelrangenew(char *newstring, char *instring,
char lo, char hi)

description: all of the characters in instring which fall in the range
from lo to hi, inclusive, are deleted from the string
while the string is otherwise copied to newstring

returns: a pointer to the new string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, character, delete, range, new

key sentence: deletes from a string all characters in a specified
range of characters and puts the result into a new string

see also: strchrdel< {i} | range | set >{new}




















page 200 The Hobbit House String Library



CHRDELRW.C file date: 03/13/93 page 2 of 2 CHRDELRW.C




usage example: compiled/executed/verified on 12/15/92

char *Astring = "THIS (is) the Sample";
char Bstring[80];
strchrdelrangenew(Bstring, Astring, '!', 'Z');
printf("\n%s", Bstring);
printf("\n%s", strchrdelrangenew(Bstring,
Astring, 'a', 'e'));

is the ample
THIS (is) th Smpl


Hobbit House Software
*/





































The Hobbit House String Library page 201



CHRFROMC.C file date: 03/13/93 page 1 of 2 CHRFROMC.C


/* strchrfromc
Hobbit House Software

copyright(c) 1992, 1993

function: strchrfromc (STRing convert CHaRacter FROM C-sequence)

KWIC: convert a character from %C-sequence format to a single
character

syntax: #include "hhstring.h"
char strchrfromc(int *nchars, char *instring)

description: converts a C-sequence "character" to a string. If the
input character is not a C-sequence character, then it
is simply returned. The number of characters found in
the C-sequence is also "returned" by putting it in a
variable back in the calling program (see comments below).
The C-sequence strings handled are:

\0 string terminator
\a bell
\b backspace
\f form feed
\n feed
\r carriage return
\t tab
\v vertical tab

\" double quote
\' single quote
\\ backslash

\xdd dd = one or two hexadecimal digits
\nnn nn = one to three OCTAL digits

returns: the converted character (there is not "failure" mode; all
input strings return a single character).

comments: when converting a single character, the number of
characters in the C-sequence may be irrelevant, but when
using this function to convert a whole string (as is done
when it is used by strfromc) it is necessary to know where
one has left off in the input string; this is the reason
for the nchars parameter.









page 202 The Hobbit House String Library



CHRFROMC.C file date: 03/13/93 page 2 of 2 CHRFROMC.C




keywords: string, convert, character, C-sequence

key sentence: converts a character from C-sequence format to a single
character

see also: str{chr}c

usage example: compiled/executed/verified on 12/15/92

char str1[10] = "\\\\"; note: backslash
char str2[10] = "\\t"; note: tab
int nchars;
printf("%d %d", strchrfromc(&nchars, str1),
strchrfromc(&nchars, str2));

92 9 note: backslash TAB


Hobbit House Software
*/
































The Hobbit House String Library page 203



CHRRPL.C file date: 03/13/93 page 1 of 1 CHRRPL.C


/* strchrrpl
Hobbit House Software

copyright(c) 1992, 1993

function: strchrrpl (STRing CHaRacter RePLace)

KWIC: %replace all occurrences of one %character in a string
with another character

syntax: #include "hhstring.h"
char *strchrrpl(char *instring, char fromchar,
char tochar)

description: all occurrences of fromchar in instring are replaced with
tochar

returns: a pointer to the string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, character, replace

key sentence: replaces, in a string, all occurrences of one character
with another character

see also: strchrrpl{i}{new}

usage example: compiled/executed/verified on 12/15/92

char *Astring = "05/09/90";
strchrrpl(Astring, '/', '-');
printf("%s", Astring);

05-09-90


Hobbit House Software
*/













page 204 The Hobbit House String Library



CHRRPLI.C file date: 03/13/93 page 1 of 1 CHRRPLI.C


/* strchrrpli
Hobbit House Software

copyright(c) 1992, 1993

function: strchrrpli (STRing, CHaRacter, RePLace, case-Independant)

KWIC: %replace all matching %characterss, %indpendant of case

syntax: #include "hhstring.h"
char *strchrrpli(char *instring, int fromchar, int tochar)

description: all occurrences of the character fromchar in instring (no
matter which case it is in instring) are replaced by the
character tochar

returns: a pointer to the modified string

comments: none

keywords: string, character, replace, case-independent

key sentence: replaces, in a string, all case-independent occurrences
of one character with another character

see also: strchrrpl{i}{new}

usage example: compiled/executed/verified on 12/15/92

char *Astring = "This is the Sample String";
strchrrpli(Astring, 's', '*');
printf("\n%s", Astring);
printf("\n%s", strchrrpli(Astring, 't', '@'));

Thi* i* the *ample *tring
@hi* i* @he *ample *@ring


Hobbit House Software
*/














The Hobbit House String Library page 205



CHRRPLIW.C file date: 03/13/93 page 1 of 2 CHRRPLIW.C


/* strchrrplinew
Hobbit House Software

copyright(c) 1992, 1993

function: strchrrplinew (STRing, CHaRacter, RePLace,
case-Independant, to NEW string)

KWIC: %replace all occurrences, %independant of case, of one
%character with another character

syntax: #include "hhstring.h"
char *strchrrplinew(char *newstring, char *instring,
char fromchar, char tochar)

description: all case-independent occurrences of fromchar are replaced
with tochar as the string is otherwise copied from
instring to newstring.

returns: a pointer to the new string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, character, replace, case-independent, new

key sentence: replaces, in a string, all case-independent occurrences
of one character with another character and puts the
result into a new string

see also: strchrrpl{i}{new}


















page 206 The Hobbit House String Library



CHRRPLIW.C file date: 03/13/93 page 2 of 2 CHRRPLIW.C




usage example: compiled/executed/verified on 12/15/92

char *Astring = "This is the Sample String";
char Bstring[80];
strchrrplinew(Bstring, Astring, 's', '*');
printf("\n%s", Bstring);
printf("\n%s", strchrrplinew(Bstring, Astring, 't', '@'));

Thi* i* the *ample *tring
@his is @he Sample [email protected]


Hobbit House Software
*/






































The Hobbit House String Library page 207



CHRRPLW.C file date: 03/13/93 page 1 of 2 CHRRPLW.C


/* strchrrplnew
Hobbit House Software

copyright(c) 1992, 1993

function: strchrrplnew (STRing CHaRacter RePLace to NEW string)

KWIC: %replace all occurrences of one %character with another
character

syntax: #include "hhstring.h"
char *strchrrplnew(char *newstring, char *instring,
char fromchar, char tochar)

description: all occurrences of fromchar are replaced with tochar as
the
string is otherwise copied from instring to newstring.

returns: a pointer to the new string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, character, replace, new

key sentence: replaces, in a string, all occurrences of one character
with another character and puts the result into a new
string

see also: strchrrpl{i}{new}



















page 208 The Hobbit House String Library



CHRRPLW.C file date: 03/13/93 page 2 of 2 CHRRPLW.C




usage example: compiled/executed/verified on 12/15/92

char Astring[80] = "05/09/90";
char Bstring[80] = "05.09.90";
char Cstring[80];
strchrrplnew(Cstring, Astring, '/', '-');
printf("\n%s", Cstring);
printf("\n%s", strchrrplnew(Cstring, Bstring, '.', '-'));

05-09-90
05-09-90


Hobbit House Software
*/





































The Hobbit House String Library page 209



CHRTOC.C file date: 03/13/93 page 1 of 2 CHRTOC.C


/* strchrtoc
Hobbit House Software

copyright(c) 1992, 1993

function: strchrtoc (STRing CHaRacter TO C format)

KWIC: %convert a character to %C-sequence format

syntax: #include "hhstring.h"
int strchrtoc(char* tostring, char inchar)

description: converts a single character into the proper C-language
representation. Characters requiring numerical
representation will be put in the hex-string format.
The C-sequences for all of the characters handled by
this function are:

\0 string terminator
\a bell
\b backspace
\f form feed
\n feed
\r carriage return
\t tab
\v vertical tab
\" double quote
\' single quote
\\ backslash

\xdd dd = two hexadecimal digits (this
format is used for all chars
which require numerical
representation)

returns: the number of characters in the output sequence

comments: note that the output sequence is terminated with a
binary 0, just like any C string

keywords: string, character, convert, C-sequence

key sentence: converts a single character to the C-sequence
representation

see also: str{chr}c








page 210 The Hobbit House String Library



CHRTOC.C file date: 03/13/93 page 2 of 2 CHRTOC.C




usage example: compiled/executed/verified on 12/15/92

char dst[5];
strchrtoc(dst, '\5'); printf("%s ", dst);
strchrtoc(dst, '\t'); printf("%s ", dst);
strchrtoc(dst, '\142'); printf("%s ", dst);

\x05 \t b


Hobbit House Software
*/








































The Hobbit House String Library page 211



CODE1.C file date: 03/13/93 page 1 of 2 CODE1.C


/* strcode1
Hobbit House Software

copyright(c) 1992, 1993

function: strcode1 (STRing en/deCODE, version 1)

KWIC: %encode or %decode a string

common uses: part of copy protection schemes

syntax: #include "hhstring.h"
char *strcode1 (char *instring, char *codestring)

description: This function is a very simple but highly effective
encode/decode scheme, with the nifty property of being
both the encoder and the decoder. When called to act
on an original string, it encodes it using the code
string provided. If called on to act on the encoded
string using the same code string, it then decodes the
string back to the original.

returns: a pointer to the string

comments: When used in conjunction with the function strtoc, this
function can be used to generate strings which can be
used for copy protection schemes or for any other reason
one might have to hide messages in .EXE or .COM files.

keywords: string, encode, decode, convert

key sentence: encodes/decodes a string using a "one-time-pad"

see also: strcode1 strcode2

usage example: compiled/executed/verified on 12/13/92

void dotprint(char *s);

void main(void)
{ char *code = "EXAMPLE CODING STRING";
char *s ="sample string to en/decode";

printf("\n\n");
printf("\noriginal: ");
dotprint(s);
strcode1(s, code);
printf("\nencoded: ");
dotprint(s);
strcode1(s, code);
printf("\nrecoded: ");
dotprint(s);
}

page 212 The Hobbit House String Library



CODE1.C file date: 03/13/93 page 2 of 2 CODE1.C



void dotprint(char *s)
{ int ii;
for (ii = 0; ii < strlen(s); ii++)
if (s[ii] < ' ')
printf(".");
else
printf("%c", s[ii]);
printf("\n");
}

original: sample string to en/decode

encoded: 69,=<)eS7=-')gT
recoded: sample string to en/decode


Hobbit House Software
*/


































The Hobbit House String Library page 213



CODE2.C file date: 03/13/93 page 1 of 2 CODE2.C


/* strcode2
Hobbit House Software

copyright(c) 1992, 1993

function: strcode2 (STRing en/deCODE, version 2)

KWIC: %encode or %decode a string

common uses: part of copy protection schemes

syntax: #include "hhstring.h"
char *strcode2(char *instring)

description: This function is a very simple but highly effective
encode/decode scheme, with the nifty property of being
both the encoder and the decoder. Unlike its sister
function strcode1, this version does not require a code
string. When called to act on an original string, it
encodes it using a fixed code sequence which it
generates. When run on an encoded string, it decodes
the string back to its original form

returns: a pointer to the string

comments: When used in conjunction with the function strtoc, this
function can be used to generate strings which can be
used for copy protection schemes or for any other reason
one might have to hide messages.

keywords: string, encode, decode, convert

key sentence: encodes/decodes a string using a fixed algorithm

see also: strcode1 strcode2

usage example: compiled/executed/verified on 12/13/92

void dotprint(char *s);
void main(void)
{ char *s ="sample string to en/decode";
printf("\n\n");
printf("\noriginal: ");
dotprint(s);
strcode2(s);
printf("\nencoded: ");
dotprint(s);
strcode2(s);
printf("\nrecoded: ");
dotprint(s);
}

void dotprint(char *s)

page 214 The Hobbit House String Library



CODE2.C file date: 03/13/93 page 2 of 2 CODE2.C


{ int ii;
for (ii = 0; ii < strlen(s); ii++)
if (s[ii] < ' ')
printf(".");
else
printf("%c", s[ii]);
printf("\n");
}

original: sample string to en/decode

encoded: .7.P..o.m..&.2..a.e_._.k..

recoded: sample string to en/decode


Hobbit House Software
*/




































The Hobbit House String Library page 215



COMA.C file date: 03/13/93 page 1 of 1 COMA.C


/* strcomma
Hobbit House Software

copyright(c) 1992, 1993

function: strcomma (STRing, add COMMAs)

KWIC: insert %commas in a string

syntax: #include "hhstring.h"
char *strcomma(char *instring)

description: strips whitespace off of both sides of instring and then
adds commas every third place from the right so the result
is proper for decimal numbers

returns: a pointer to instring

comments: (1) the string space in memory must be sufficient to hold
the added commas, else there be dragons
(2) the function works the same regardless of the
character contents of the input string; that is, it
will put commas every three spaces from the right in
ANY string, not just ones which represents a decimal
number.
(3) strcommanew is MUCH more efficient
(4) The string pointed to by the return value of this
function is in the calling function's space. The
return value is provided as a convenience, not a
necessity.

keywords: string, commas, ASCII, decimal, numeric

key sentence: adds commas to an ASCII-decimal string

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 12/16/92

char Astring[80] = " 1234567890 ";
strcomma(Astring);
printf("\n%s\n", Astring);

1,234,567,890


Hobbit House Software
*/






page 216 The Hobbit House String Library



COMAF.C file date: 03/13/93 page 1 of 1 COMAF.C


/* strcommaf
Hobbit House Software

copyright(c) 1992, 1993

function: strcommaf (STRing, add COMMAs, for Floating point #s)

KWIC: insert %commas into a %floating point number string

syntax: #include
#include "hhstring.h"
char *strcommaf(char *instring)

description: strips whitespace off of both sides of instring and then
adds commas every third place to the left of the decimal
point

returns: a pointer to instring

comments: (1) the string space in memory must be sufficient to hold
the added commas.
(2) If there is no decimal point, it is implied as the
last character once whitespace has been stripped off.
(3) This function will cause memory problems if there are
more than 9 digits after the decimal point or more
than 15 digits to the left of the decimal point.
(4) The string pointed to by the return value of this
function is in the calling function's space. The
return value is provided as a convenience, not a
necessity.

keywords: string, commas, float, ASCII

key sentence: adds commas to an ASCII-floating point string

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 1/1/93

char Astring[80] = " 12345678.90 ";
strcommaf(Astring);
printf("\n%s\n", Astring);

12,345,678.90


Hobbit House Software
*/






The Hobbit House String Library page 217



COMAFW.C file date: 03/13/93 page 1 of 2 COMAFW.C


/* strcommafnew
Hobbit House Software

copyright(c) 1992, 1993

function: strcommafnew (STRing, add COMMAs, for Floating point #s,
to NEW string)

KWIC: insert %commas into a %floating point number string

syntax: #include
#include "hhstring.h"
char *strcommafnew(char *newstring, char *instring)

description: strips whitespace off of both sides of instring and then
adds commas every third place to the left of the decimal
point, putting the result in newstring; instring is
unchanged.

returns: a pointer to newstring

comments: (1) If there is no decimal point, it is implied as the
last character once whitespace has been stripped off.
(2) This function will cause memory problems if there are
more than 9 digits after the decimal point or more
than 15 digits to the left of the decimal point.
(3) The string pointed to by the return value of this
function is in the calling function's space. The
return value is provided as a convenience, not a
necessity.

keywords: string, commas, float, new, ASCII

key sentence: adds commas to an ASCII floating point string and puts
the result in a new string

see also: strcomma{f|n}{new} strcomma{u}< i | l >

















page 218 The Hobbit House String Library



COMAFW.C file date: 03/13/93 page 2 of 2 COMAFW.C




usage example: compiled/executed/verified on 1/1/93

char Astring[80] = " 12345678.90 ";
char Bstring[80];
strcommafnew(Bstring, Astring);
printf("%s", Bstring);

12,345,678.90


Hobbit House Software
*/








































The Hobbit House String Library page 219



COMAFRI.C file date: 03/13/93 page 1 of 1 COMAFRI.C


/* strcommafri
Hobbit House Software

copyright(c) 1992, 1993

function: strcommafri (make STRing, with COMMAs, FRom Integer)

KWIC: convert an %integer to a string with %commas

syntax: #include
#include "hhstring.h"
char *strcommafri(char *result, int num)

description: converts the integer "num" into the string "result" and
adds commas ever third place from the right, while dealing
properly with the minus sign (if there is one)

returns: a pointer to the string (result)

comments: The string pointed to by the return value of this
function is in the calling function's space. The return
value is provided as a convenience, not a necessity.

keywords: string, convert, commas, numeric, integer, decimal, ASCII

key sentence: converts a signed integer into an ASCII-decimal string
with
commas

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 1/1/93

char str1[20];
strcommafri(str1, 12345);
printf("\n%s", str1);
printf("\n%s", strcommafri(str1, -12345));

12,345
-12,345


Hobbit House Software
*/










page 220 The Hobbit House String Library



COMAFRL.C file date: 03/13/93 page 1 of 1 COMAFRL.C


/* strcommafrl
Hobbit House Software

copyright(c) 1992, 1993

function: strcommafrl (make STRing, with COMMAs, FRom Long)

KWIC: convert a %long number to a string with %commas

syntax: #include
#include "hhstring.h"
char *strcommafrl(char *result, long num)

description: converts the long number "num" into the string "result"
and adds commas ever third place from the right,
dealing properly with the minus sign (if there is one)

returns: a pointer to the string (result)

comments: The string pointed to by the return value of this
function is in the calling function's space. The return
value is provided as a convenience, not a necessity.

keywords: string, convert, commas, numeric, long, ASCII, decimal

key sentence: converts a signed long number into an ASCII-decimal string
with commas

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 1/1/93

char str1[20];
strcommafrl(str1, 1234567890L);
printf("\n%s", str1);
printf("\n%s", strcommafrl(str1, -12345678L));

1,234,567,890
-12,345,678


Hobbit House Software
*/











The Hobbit House String Library page 221



COMAFRUI.C file date: 03/13/93 page 1 of 1 COMAFRUI.C


/* strcommafrui
Hobbit House Software

copyright(c) 1992, 1993

function: strcommafrui (make STRing, with COMMAs, FRom Unsigned
Integer)

KWIC: convert an unsigned %integer to a string with %commas

syntax: #include
#include "hhstring.h"
char *strcommafrui(char *result, unsigned int num)

description: converts the unsigned integer "num" into the string
"result" and adds commas ever third place from the right

returns: a pointer to the string (result)

comments: The string pointed to by the return value of this
function is in the calling function's space. The return
value is provided as a convenience, not a necessity.

keywords: string, convert, numeric, commas, ASCII, integer

key sentence: converts an unsigned integer into an ASCII-decimal string
with commas

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 1/1/93

char str1[20];
strcommafrui(str1, 12345);
printf("\n%s", str1);
printf("\n%s", strcommafrui(str1, (unsigned int)60000L));

note: the construct "(unsigned int)60000L" is not
strictly necessary, but avoids a compiler warning
in the Borland compiler. A simple 60000 will work,
but will give a warning.

12,345
60,000


Hobbit House Software
*/






page 222 The Hobbit House String Library



COMAFRUL.C file date: 03/13/93 page 1 of 1 COMAFRUL.C


/* strcommafrul
Hobbit House Software

copyright(c) 1992, 1993

function: strcommafrul (make STRing, with COMMAs, FRom Unsigned
Long)

KWIC: convert an unsigned %long number to a string with %commas

syntax: #include
#include "hhstring.h"
char *strcommafrul(char *result, unsigned long num)

description: converts the unsigned long number "num" into the string
"result" and adds commas ever third place from the right

returns: a pointer to the string (result)

comments: The string pointed to by the return value of this
function is in the calling function's space. The return
value is provided as a convenience, not a necessity.

keywords: string, convert, commas, numeric, long, ASCII, decimal

key sentence: converts an unsigned long number into an ASCII-decimal
string with commas

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 12/17/92

char str1[20];
strcommafrul(str1, 4000000000L);
printf("\n%s", str1);
printf("\n%s", strcommafrul(str1, 4000000000L));

4,000,000,000
4,000,000,000


Hobbit House Software
*/











The Hobbit House String Library page 223



COMAN.C file date: 03/13/93 page 1 of 2 COMAN.C


/* strcomman
Hobbit House Software

copyright(c) 1992, 1993

function: strcomman (STRing, add COMMAs, to N-char size)

KWIC: insert %commas into a string and pad the string on the
left
to force it to a given %size

syntax: #include "hhstring.h"
char *strcomman(char *instring, int nchar)

description: strips whitespace off of both sides of instring and then
adds commas every third place from the right so the result
is proper for decimal numbers. Pads with blanks on the
left so as to make instring nchar total characters long.

returns: a pointer to the string

comments: (1) the string space in memory must be sufficient to hold
the added commas.
(2) the function works the same regardless of the
character contents of the input string; that is, it
will put commas every three spaces from the right in
ANY string, not just one which represents a decimal
number.
(3) The string pointed to by the return value of this
function is in the calling function's space. The
return value is provided as a convenience, not a
necessity.

keywords: string, commas, size

key sentence: inserts commas into a string and pads the string on the
left to force it to a given size

see also: strcomma{f|n}{new} strcomma{u}< i | l >















page 224 The Hobbit House String Library



COMAN.C file date: 03/13/93 page 2 of 2 COMAN.C




usage example: compiled/executed/verified on 1/1/93

char Astring[80];
strcpy(Astring, " 1234567890 ");
strcomman(Astring, 15);
printf("-->%s<--", Astring);

--> 1,234,567,890<--


Hobbit House Software
*/








































The Hobbit House String Library page 225



COMAW.C file date: 03/13/93 page 1 of 2 COMAW.C


/* strcommanew

Hobbit House Software

copyright(c) 1992, 1993

function: strcommanew (STRing, add COMMAs, to NEW string)

KWIC: insert %commas into a string

syntax: #include "hhstring.h"
char *strcommanew(char *newstring, char *instring)

description: strips whitespace off of both sides of instring and then
adds commas every third place from the right so the result
is proper for decimal numbers. Puts the result into
newstring; instring is unchanged.

returns: a pointer to the new string

comments: (1) the function works the same regardless of the
character contents of the input string; that is, it
will put commas every three spaces from the right in
ANY string, not just one which represents a decimal
number.
(2) strcommanew is MUCH more efficient than strcomma
(3) Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.
(4) The string pointed to by the return value of this
function is in the calling function's space. The
return value is provided as a convenience, not a
necessity.

keywords: string, commas, new, ASCII, decimal, numeric

key sentence: inserts commas into an ASCII-decimal string, with the
result going to a new string

see also: strcomma{f|n}{new} strcomma{u}< i | l >
















page 226 The Hobbit House String Library



COMAW.C file date: 03/13/93 page 2 of 2 COMAW.C




usage example: compiled/executed/verified on 12/16/92

char Astring[80] = " 1234567890 ";
char Bstring[80];
strcommanew(Bstring, Astring);
printf("%s", Bstring);

1,234,567,890


Hobbit House Software
*/








































The Hobbit House String Library page 227



COMANW.C file date: 03/13/93 page 1 of 2 COMANW.C


/* strcommannew
Hobbit House Software

copyright(c) 1992, 1993

function: strcommannew (STRing, add COMmas, to N-char size, to NEW)

KWIC: insert %commas into a string and pad the string on the
left
to force %size

syntax: #include "hhstring.h"
char *strcommannew(char *newstring, char *instring,
int nchar)

description: strips whitespace off of both sides of instring and then
adds commas every third place from the right so the result
is proper for decimal numbers. Pads with blanks on the
left so as to make the string nchar total characters long
and puts the result in newstring. Instring is unchanged.

returns: a pointer to the new string

comments: (1) the newstring space must be sufficient to hold the
result.
(2) the function works the same regardless of the
character contents of the input string; that is, it
will put commas every three spaces from the right in
ANY string, not just one which represents a decimal
number.
(3) Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.
(4) The string pointed to by the return value of this
function is in the calling function's space. The
return value is provided as a convenience, not a
necessity.

keywords: string, commas, size, new

key sentence: inserts commas into a string and pad the string on the
left to force it to a given size, with the result being
put into a new string

see also: strcomma{f|n}{new} strcomma{u}< i | l >









page 228 The Hobbit House String Library



COMANW.C file date: 03/13/93 page 2 of 2 COMANW.C




usage example: compiled/executed/verified on 12/17/92

char Astring[80] = " 1234567890 ";
char Bstring[80];
strcommannew(Bstring, Astring, 15);
printf("-->%s<--", Bstring);

--> 1,234,567,890<--


Hobbit House Software
*/








































The Hobbit House String Library page 229



COMATOI.C file date: 03/13/93 page 1 of 1 COMATOI.C


/* strcommatoi
Hobbit House Software

copyright(c) 1992, 1993

function: strcommatoi (STRing with COMMAs to Integer)

KWIC: convert a string with %commas to an %integer

syntax: #include
#include "hhstring.h"
int strcommatoi(char *inpstring)

description: convert inpstring to an integer, ignoring leading
whitespace and all commas, but handling a minus sign
if there is one

returns: the integer value

comments: it is not a problem if inpstring has no commas

keywords: string, commas, convert, ASCII, decimal, integer, numeric

key sentence: converts an ASCII-decimal string with commas to an integer

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 12/17/92

char *Astring = " -12,345";
printf("%d", strcommatoi(Astring));

-12345


Hobbit House Software
*/

















page 230 The Hobbit House String Library



COMATOL.C file date: 03/13/93 page 1 of 1 COMATOL.C


/* strcommatol
Hobbit House Software

copyright(c) 1992, 1993

function: strcommatol (STRing with COMMAs to Long)

KWIC: convert a string with %commas to a %long

syntax: #include "hhstring.h"
long int strcommatol(char *inpstring)

description: convert inpstring to a long integer, ignoring leading
whitespace and all commas but handling a minus sign if
there is one

returns: the long value

comments: it is not a problem if inpstring has no commas

keywords: string, commas, convert, ASCII, decimal, long

key sentence: converts an ASCII-decimal string with commas to a
long value

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 12/17/92

char *Astring = " -1,000,000,000";
char *Bstring = " 1,000,000,000";
printf("\n%ld", strcommatol(Astring));
printf("\n%ld", strcommatol(Bstring));

-1000000000
1000000000


Hobbit House Software
*/














The Hobbit House String Library page 231



COMATOUI.C file date: 03/13/93 page 1 of 1 COMATOUI.C


/* strcommatoui
Hobbit House Software

copyright(c) 1992, 1993

function: strcommatoui (STRing with COMMAs to Unsigned Integer)

KWIC: convert a string with %commas to an unsigned %integer

syntax: #include
#include "hhstring.h"
unsigned int strcommatoui(char *inpstring)

description: convert inpstring to an unsigned integer, ignoring any
leading whitespace and all commas

returns: the unsigned integer

comments: it is not a problem if inpstring has no commas

keywords: string, commas, convert, ASCII, decimal, integer

key sentence: converts an ASCII-decimal string with commas to an
unsigned integer

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 12/17/92

char *Astring = " 60,000";
printf("\n%u", strcommatoui(Astring));

60000


Hobbit House Software
*/

















page 232 The Hobbit House String Library



COMATOUL.C file date: 03/13/93 page 1 of 1 COMATOUL.C


/* strcommatoul
Hobbit House Software

copyright(c) 1992, 1993

function: strcommatoul (STRing with COMMAs to Unsigned Long)

KWIC: convert a string with %commas to an unsigned %long

syntax: #include "hhstring.h"
unsigned long int strcommatoul(char *inpstring)

description: convert inpstring to an unsigned long, ignoring any
whitespace and all commas

returns: the unsigned long value

comments: it is not a problem if inpstring has no commas

keywords: string, commas, convert, ASCII, decimal, long

key sentence: converts an ASCII-decimal string with commas to an
unsigned long value

see also: strcomma{f|n}{new} strcomma{u}< i | l >

usage example: compiled/executed/verified on 12/17/92

char *Astring = " 4,000,000,000";
printf("\n%lu", strcommatol(Astring));

4000000000


Hobbit House Software
*/


















The Hobbit House String Library page 233



DATE1.C file date: 03/13/93 page 1 of 1 DATE1.C


/* strdate1
Hobbit House Software

copyright(c) 1992, 1993

function: strdate1 (STRing, create DATE string, format #1)

KWIC: create a string containing today's %date in format #1

syntax: #include "hhstring.h"
char *strdate1(char *date_string)

description: date_string is filled with a string containing today's
date in format #1

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



keywords: date

key sentence: creates a string containing today's date in format #1
(mm/dd/yy)

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad

usage example: compiled/executed/verified on 1/1/93

see the file TESTDATE.C


Hobbit House Software
*/











page 234 The Hobbit House String Library



DATE2.C file date: 03/13/93 page 1 of 1 DATE2.C


/* strdate2
Hobbit House Software

copyright(c) 1992, 1993

function: strdate2 (STRing, create DATE string, format #2)

KWIC: create a string containing today's %date in format #2

syntax: #include "hhstring.h"
char *strdate2(char *date_string)

description: date_string is filled with a string containing today's
date in format #2

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



keywords: date

key sentence: creates a string containing today's date in format #2
(mm-dd-yy)


see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad

usage example: compiled/executed/verified on 1/1/93

see the file TESTDATE.C


Hobbit House Software
*/










The Hobbit House String Library page 235



DATE3.C file date: 03/13/93 page 1 of 1 DATE3.C


/* strdate3
Hobbit House Software

copyright(c) 1992, 1993

function: strdate3 (STRing, create DATE string, format #3)

KWIC: create a string containing today's %date in format #3

syntax: #include "hhstring.h"
char *strdate3(char *date_string)

description: date_string is filled with a string containing today's
date in format #3

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



keywords: date

key sentence: creates a string containing today's date in format #3
( m/ d/yy)

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad

usage example: compiled/executed/verified on 1/1/93

see the file TESTDATE.C


Hobbit House Software
*/











page 236 The Hobbit House String Library



DATE4.C file date: 03/13/93 page 1 of 1 DATE4.C


/* strdate4
Hobbit House Software

copyright(c) 1992, 1993

function: strdate4 (STRing, create DATE string, format #4)

KWIC: create a string containing today's %date in format #4

syntax: #include "hhstring.h"
char *strdate4(char *date_string)

description: date_string is filled with a string containing today's
date in format #4

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



keywords: date

key sentence: creates a string containing today's date in format #4
( m- d-yy)

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad

usage example: compiled/executed/verified on 1/1/93

see the file TESTDATE.C


Hobbit House Software
*/











The Hobbit House String Library page 237



DATE5.C file date: 03/13/93 page 1 of 1 DATE5.C


/* strdate5
Hobbit House Software

copyright(c) 1992, 1993

function: strdate5 (STRing, create DATE string, format #5)

KWIC: create a string containing today's %date in format #5

syntax: #include "hhstring.h"
char *strdate5(char *date_string)

description: date_string is filled with a string containing today's
date in format #5

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



keywords: date

key sentence: creates a string containing today's date in format #5
(m/d/yy)

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad

usage example: compiled/executed/verified on 1/1/93

see the file TESTDATE.C


Hobbit House Software
*/











page 238 The Hobbit House String Library



DATE6.C file date: 03/13/93 page 1 of 1 DATE6.C


/* strdate6
Hobbit House Software

copyright(c) 1992, 1993

function: strdate6 (STRing, create DATE string, format #6)

KWIC: create a string containing today's %date in format #6

syntax: #include "hhstring.h"
char *strdate6(char *date_string)

description: date_string is filled with a string containing today's
date in format #6

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



keywords: date

key sentence: creates a string containing today's date in format #6
(m-d-yy)

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad

usage example: compiled/executed/verified on 1/1/93

see the file TESTDATE.C


Hobbit House Software
*/











The Hobbit House String Library page 239



DATE7.C file date: 03/13/93 page 1 of 1 DATE7.C


/* strdate7
Hobbit House Software

copyright(c) 1992, 1993

function: strdate7 (STRing, create DATE string, format #7)

KWIC: create a string containing today's %date in format #7

syntax: #include "hhstring.h"
char *strdate7(char *date_string)

description: date_string is filled with a string containing today's
date in format #7

returns: a pointer to date_string

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



keywords: date

key sentence: creates a string containing today's date in format #7
(yy/mm/dd)

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad

usage example: compiled/executed/verified on 1/1/93

see the file TESTDATE.C


Hobbit House Software
*/











page 240 The Hobbit House String Library



DATECNV.C file date: 03/13/93 page 1 of 1 DATECNV.C


/* strdateconv
Hobbit House Software

copyright(c) 1992, 1993

function: strdateconv --- (STRing, DATE, CONVert format)

KWIC: %convert a %date string, in any specified format, to any
other specified format (see comments, below)

syntax: #include
#include
#include "hhstring.h"
char *strdateconv(char *date_string, int intype,
int outtype)

description: date_string is converted from the intype format to the
outtype format

returns: a pointer to date_string (or a NULL if the intype or
outtype parameters are illegal)

comments:

Since there are no standards for the various data
formats handled by the HHSTRING library "strdaten"
and "strdatecnv" functions, the numbering system
used is purely arbitrary. It is explained in the
file DATEINFO.DOC, which accompanies the library.



keywords: date, convert

key sentence: converts a date string from one format to another

see also: strdate< 1 | 2 | 3 | 4 | 5 | 6 | 7 > strdateconv
date_without make_date_without
date_withpad make_date_withpad

usage example: compiled/executed/verified on 2/25/93


see the file TESTDATE.C



Hobbit House Software
*/





The Hobbit House String Library page 241



END.C file date: 03/13/93 page 1 of 1 END.C


/* strend
Hobbit House Software

copyright(c) 1992, 1993

function: strend (get STRing END)

KWIC: get a pointer to the %end of the string (the '\0')

syntax: #include "hhstring.h"
char *strend(char *instring)

description: returns a pointer to the string terminator

returns: a pointer to the string terminator

comments: none

keywords: string, end

key sentence: gets the pointer to the end of a string (that is, to the
terminating '\0' of the string)

see also: --- no related functions ---

usage example: compiled/executed/verified on 12/13/92

char *Astring = "first string\0second string";
printf("%s", strend(Astring) + 1);

second string


Hobbit House Software
*/



















page 242 The Hobbit House String Library



EOS.C file date: 03/13/93 page 1 of 1 EOS.C


/* streos
Hobbit House Software

copyright(c) 1992, 1993

function: streos (STRing, set to all End-Of-String)

KWIC: set a string to all binary %zeros

syntax: #include "hhstring.h"
char *streos(char *instring)

description: takes a string which has a terminating '\0' and fills it
with '\0' characters

returns: a pointer to the string

comments: this is a macro defined in hhstring.h as:

#define streos(s) strset(s, '\0')

keywords: string, character, set

key sentence: sets a string to all binary zeros (EOSs)

see also: str< blank | eos | set | zero >

usage example: compiled/executed/verified on 12/13/92

int ii;
char *instring = "this string";
streos(instring);
for (ii = 0; ii < 11; ii++)
printf("%d ", instring[ii]);

0 0 0 0 0 0 0 0 0 0 0


Hobbit House Software
*/














The Hobbit House String Library page 243



FROMC.C file date: 03/13/93 page 1 of 2 FROMC.C


/* strfromc
Hobbit House Software

copyright(c) 1992, 1993

function: strfromc (STRing FROM C-sequence string)

KWIC: %convert a string containing %C-sequence format characters
to a string having only normal (non-C) format characters

syntax: #include "hhstring.h"
int strfromc(char *instring)

description: a string which contains C-sequence "characters" (see the
full list with the function strchrfromc) is converted to
a string which has only single-character representations
of the same information. That is, if the input string
contains, for example, the C language representation of
backslash ('\t') then the converted string will have a
backslash character (hex 5C) in place of the 2-character
C language representation.

returns: the number of characters in the converted string


comments: note that the conversion is done "in place" so no new
string space is required. The primary work of this
function is the performed by the function strchrfromc.

keywords: string, convert, C-sequence

key sentence: converts a string containing C-sequence format characters
to a string having only normal (non-C) format characters

see also: str{chr}c




















page 244 The Hobbit House String Library



FROMC.C file date: 03/13/93 page 2 of 2 FROMC.C




usage example: compiled/executed/verified on 12/13/92

char str[80] = "a\\t\\142";
int ii;
strfromc(str);
printf("\n\n");
for (ii = 0; ii < 4; ii++)
printf("%d ", str[ii]);

97 9 98 0 note: a TAB b


Hobbit House Software
*/






































The Hobbit House String Library page 245



INDEX.C file date: 03/13/93 page 1 of 1 INDEX.C


/* strindex
Hobbit House Software

copyright(c) 1992, 1993

function: strindex (STRing function, get the INDEX of a pointer)

KWIC: get the %index of a pointer in a string

syntax: #include "hhstring.h"
int strindex(char *ptr, char *str)

description: str is incremented until it equals ptr; the number of
increments required is the return value of the function.
This is, of course, the index of ptr from str.

returns: the index

comments: if ptr precedes str, then this function will count until
the incremented str wraps all the way around and
eventually becomes equal to ptr

keywords: string, index

key sentence: gets the index of a pointer inside a string

see also: --- no related functions ---

usage example: compiled/executed/verified on 2/21/93

char Astring[80];
printf("\n%d", strindex(Astring + 15, Astring));
printf("\n%d", strindex(Astring, Astring + 15));

15
-15


Hobbit House Software
*/














page 246 The Hobbit House String Library



INSERT.C file date: 03/13/93 page 1 of 1 INSERT.C


/* strinsert
Hobbit House Software

copyright(c) 1992, 1993

function: strinsert (STRing, INSERT one string into another)

KWIC: %insert one string into another string

syntax: #include "hhstring.h"
char *strinsert(char *instring, int putplace,
char *putstring)

description: inserts putstring into instring at position putplace

returns: a pointer to instring

comments: instring has to include enough memory space to accommodate
the insertion of putstring, else there be dragons

putplace is 0-origin, so to insert the new string
entirely in front of the existing string, use putplace = 0

if putplace points at the terminating EOS, this function
acts like a concatenate.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, insert

key sentence: inserts one string into another string

see also: strinsert{new}

usage example: compiled/executed/verified on 12/13/92

char str[80] = "This is the original string";
strinsert(str, 8, "not ");
printf("%s", str);

This is not the original string


Hobbit House Software
*/







The Hobbit House String Library page 247



INSERTW.C file date: 03/13/93 page 1 of 2 INSERTW.C


/* strinsertnew
Hobbit House Software

copyright(c) 1992, 1993

function: strinsertnew (STRing, INSERT one string into another and
put the result in a NEW string)

KWIC: %insert one string into another string

syntax: #include "hhstring.h"
char *strinsertnew(char *newstring, char *instring,
int putplace, char *putstring)

description: copies instring, up to putplace, into newstring, then
concatenates putstring onto newstring, then concatenates
the rest of instring onto newstring.

returns: a pointer to newstring

comments: newstring has to include enough memory space to
accommodate the instring plus putstring, else there
be dragons

putplace is 0-origin, so to insert the new string
entirely in front of the existing string, use putplace = 0

if putplace points at the terminating EOS, this function
acts like a concatenate.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, insert, new

key sentence: inserts one string into another string and puts the result
into a new string

see also: strinsert{new}














page 248 The Hobbit House String Library



INSERTW.C file date: 03/13/93 page 2 of 2 INSERTW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = "This is the original string";
char Bstring[80];
strinsertnew(Bstring, Astring, 8, "not ");
printf("%s", Bstring);

This is not the original string


Hobbit House Software
*/








































The Hobbit House String Library page 249



ISEMPTY.C file date: 03/13/93 page 1 of 2 ISEMPTY.C


/* strisempty
Hobbit House Software

copyright(c) 1992, 1993

function: strisempty (STRing IS it an EMPTY string?)

KWIC: report on whether or not a string is %empty

That is, whether or not it is either a NULL string or has
only characters from the following set:
' ' blank
'\n' line feed (aka "end of line")
'\t' tab (horizontal)
'\v' vertical tab
'\f' form feed
'\r' carriage return

syntax: #include "hhstring.h"
int strisempty(char *instring)

description: instring is scanned for any of the characters show above
under "purpose" and the return specifies whether or not
any OTHER characters were found.

returns: non-zero if string is empty or contains only the
specified "empty" characters

comments: note the difference between this function and
striswhite, which only checks for blanks and tabs

keywords: string, is, character

key sentence: tells whether or not a string is empty (i.e. contains no
characters or only characters from the C-sequence set
" \n\t\v\f\r")

see also: stris< empty | white >
















page 250 The Hobbit House String Library



ISEMPTY.C file date: 03/13/93 page 2 of 2 ISEMPTY.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = " \t \v \n";
char *Bstring = "";
char *Cstring = "not empty";
printf("\n%d", strisempty(Astring));
printf("\n%d", strisempty(Bstring));
printf("\n%d", strisempty(Cstring));

1
1
0



Hobbit House Software
*/



































The Hobbit House String Library page 251



ISWHITE.C file date: 03/13/93 page 1 of 1 ISWHITE.C


/* striswhite
Hobbit House Software

copyright(c) 1992, 1993

function: striswhite (STRing IS it a WHITE string?)

KWIC: report on whether or not a string is "white" (contains
only %whitespace, or is NULL)

syntax: #include "hhstring.h"
int striswhite(char *instring)

description: instring is scanned for any non-whitespace characters

returns: non-zero if string is NULL or contains only whitespace,
0 otherwise.

comments: to check for truly empty lines, use strisempty. In
particular, lines with nothing but a '\n' in them are
NOT white but they are empty

keywords: string, is, character, whitespace, blank, tab

key sentence: tells whether or not a string is "white" (contains only
whitespace) or is NULL

see also: stris< empty | white >

usage example: compiled/executed/verified on 12/13/92

char *Astring = " \t ";
char *Bstring = "\n";
char *Cstring = "not empty";
printf("\n%d", striswhite(Astring));
printf("\n%d", striswhite(Bstring));
printf("\n%d", striswhite(Cstring));

1
0
0


Hobbit House Software
*/









page 252 The Hobbit House String Library



LEFT.C file date: 03/13/93 page 1 of 1 LEFT.C


/* strleft
Hobbit House Software

copyright(c) 1992, 1993

function: strleft (STRing LEFT)

KWIC: get n characters from the %left side of a string

syntax: #include "hhstring.h"
char *strleft(char *instring, int nchar)

description: modify the position of the terminating EOS of instring, so
that instring effectively contains only the nchar
characters from the left side of the original instring. If
the original instring is shorter than nchars, then it
remains unchanged

returns: a pointer to instring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, truncate

key sentence: truncates a string by deleting all but the leftmost n
characters, and returns a pointer to the modified string

see also: strleft{new} strmid{new}
strright{new} strmidn{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "name size date other";
strleft(Astring, 9);
printf("%s", Astring);

name size


Hobbit House Software
*/











The Hobbit House String Library page 253



LEFTW.C file date: 03/13/93 page 1 of 1 LEFTW.C


/* strleftnew
Hobbit House Software

copyright(c) 1992, 1993

function: strleftnew (STRing LEFT to NEW string)

KWIC: get n chars from the %left side of a string

syntax: #include "hhstring.h"
char *strleftnew(char *newstring, char *instring,
int nchar)

description: move the nchar characters on the left side of instring to
newstring. If nchar is larger than instring, then
newstring will be the same as instring. In any case,
instring is unchanged.

returns: a pointer to newstring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, left, new, truncate

key sentence: creates a string which consist of the leftmost n
characters from a given string, and returns a pointer to
the new string

see also: strleft{new} strmid{new}
strright{new} strmidn{new}

usage example: compiled/executed/verified on 1/19/93

char *Astring = "name size date other";
char Newstring[80];
strleftnew(Newstring, Astring, 9);
printf("%s", Newstring);

name size


Hobbit House Software
*/





page 254 The Hobbit House String Library



LENMAX.C file date: 03/13/93 page 1 of 1 LENMAX.C


/* strlenmax
Hobbit House Software

copyright(c) 1992, 1993

function: strlenmax (STRing LENgth MAXimum function)

KWIC: get the %larger of a number and the %length of a string

syntax: #include "hhstring.h"
int strlenmax(char *string, int number);

description: given a string and a number, this function returns the
larger of the number and the length of the string

returns: the larger integer value (string length or input number)

comments: none

keywords: string, length

key sentence: gets the larger of a number or the length of a string

see also: strl< max | min >

usage example: compiled/executed/verified on 12/13/92

printf ("\n%d", strlenmax("this string", 8));
printf ("\n%d", strlenmax("this string", 20));

11
20


Hobbit House Software
*/


















The Hobbit House String Library page 255



LENMIN.C file date: 03/13/93 page 1 of 1 LENMIN.C


/* strlenmin
Hobbit House Software

copyright(c) 1992, 1993

function: strlenmin (STRing LENgth MINimum function)

KWIC: get the %smaller of a number and the %length of a string

syntax: #include "hhstring.h"
int strlenmin(char *string, int number);

description: given a string and a number, this function returns the
smaller of the number and the length of the string

returns: the smaller integer value (string length or input number)

comments: none

keywords: string, length

key sentence: gets the smaller of a number or the length of a string

see also: strl< max | min >

usage example: compiled/executed/verified on 12/13/92

printf ("\n%d", strlenmin("this string", 8));
printf ("\n%d", strlenmin("this string", 20));

8
11


Hobbit House Software
*/


















page 256 The Hobbit House String Library



LEFTDEL.C file date: 03/13/93 page 1 of 1 LEFTDEL.C


/* strlfdel
Hobbit House Software

copyright(c) 1992, 1993

function: strlfdel (STRing LeFt DELete)

KWIC: %delete characters on the %left side of a string

syntax: #include "hhstring.h"
char *strlfdel (char *instring, int nchar)

description: modifies instring so that the leftmost nchar characters
are truncated from the string

returns: a pointer to instring

comments: If nchar is greater than the length of instring, then this
function sets instring to a null string and does not
disturb the rest of memory.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, delete, truncate

key sentence: truncates a string by deleting the leftmost n characters,
and returns a pointer to the modified string

see also: str< lf | mid | rt >del{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "this is Astring";
strlfdel(Astring, 5);
printf("%s", Astring);

is Astring


Hobbit House Software
*/











The Hobbit House String Library page 257



LEFTDELW.C file date: 03/13/93 page 1 of 1 LEFTDELW.C


/* strlfdelnew
Hobbit House Software

copyright(c) 1992, 1993

function: strlfdelnew (STRing LeFt DELete to NEW string)

KWIC: %delete characters on the %left side of a string

syntax: #include "hhstring.h"
char *strlfdelnew(char *newstring, char *instring,
int nchar)

description: creates newstring which is identical to instring
except that the leftmost nchar characters of instring
are not included in newstring

returns: a pointer to newstring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, left, delete, new, truncate

key sentence: creates a new string from a given string by deleting the
leftmost n characters, and returns a pointer to the new
string

see also: str< lf | mid | rt >del{new}

usage example: compiled/executed/verified on 12/13/92

char NEWstring[80];
char instring[80] = "this is the input string";
strlfdelnew(NEWstring, instring, 8);
printf("%s", NEWstring);

the input string


Hobbit House Software
*/







page 258 The Hobbit House String Library



LEFTJUS.C file date: 03/13/93 page 1 of 1 LEFTJUS.C


/* strlfjust
Hobbit House Software

copyright(c) 1992, 1993

function: strlfjust (STRing LeFt JUSTify)

KWIC: %left %justify a string

syntax: #include "hhstring.h"
char *strlfjust(char *instring)

description: the contents of instring are shifted left to remove any
whitespace (blanks or TABs) on the left side. Blanks are
shifted in on the right to replace the characters shifted
out to the left.

returns: a pointer to instring

comments: note that only one blank is shifted in on the right to
replace a TAB that is deleted from the left side of the
string.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, justify

key sentence: moves any leading blanks in a string to the right side
(note that TABs are not well handled), and returns a
pointer to the string

see also: str< lf | rt >just{new} strcenter{n}{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = " Left Justify this string";
strlfjust(Astring);
printf("-->%s<--", Astring);

-->Left Justify this string <--


Hobbit House Software
*/









The Hobbit House String Library page 259



LEFTJUSW.C file date: 03/13/93 page 1 of 2 LEFTJUSW.C


/* strlfjustnew
Hobbit House Software

copyright(c) 1992, 1993

function: strlfjustnew (STRing LeFt JUStify to NEW string)

KWIC: %left %justify a string

syntax: #include "hhstring.h"
char *strlfjustnew(char *newstring, char *instring)

description: the contents of instring are shifted left to remove any
whitespace (blanks or TABs) on the left side. Blanks are
shifted in on the right to replace the characters shifted
out to the left. The results go to the newstring. instring
is not changed.

returns: a pointer to newstring

comments: note that only one blank is shifted in on the right for
each TAB that is deleted from the left side of the string.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may not
work so if you must overlap, do it cautiously.

keywords: string, left, justify, new

key sentence: creates a string which is the same as a given string
except that any leading blanks are moved to the right side
of the string (note that TABs are not well handled), and
returns a pointer to the new string

see also: str< lf | rt >just{new} strcenter{n}{new}















page 260 The Hobbit House String Library



LEFTJUSW.C file date: 03/13/93 page 2 of 2 LEFTJUSW.C




usage example: compiled/executed/verified on 12/13/92

char Astring[80]= " Left Justify this string";
char Bstring[80];
strlfjustnew(Bstring, Astring);
printf("-->%s<--", Bstring);

-->Left Justify this string <--


Hobbit House Software
*/








































The Hobbit House String Library page 261



LEFTPAD.C file date: 03/13/93 page 1 of 1 LEFTPAD.C


/* strlfpad
Hobbit House Software

copyright(c) 1992, 1993

function: strlfpad (STRing LeFt PAD)

KWIC: %pad a string on the %left

syntax: #include "hhstring.h"
char *strlfpad(char *instring, int nchars, char PadChar)

description: instring is moved to a new memory location nchars
beyond the one it used to occupy and then the first
nchars locations are filled with PadChar.

returns: a pointer to instring

comments: the input string MUST have enough memory space to allow an
increase in size to accommodate the inserted blanks. This
function cannot verify that, so must assume it. If it
isn't true, this function will destroy whatever is in the
memory space following the input string. WATCH OUT !!!

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, pad, size

key sentence: changes the size of a string by padding it on the left
with
n occurrences of the character c, and returns a pointer to
the modified string

see also: str< lf | mid | rt >pad{new}

usage example: compiled/executed/verified on 12/13/92

char Astring[80];
strcpy(Astring, "put this in Astring");
strlfpad(Astring, 5, ' ');
strlfpad(Astring, 5, 'x');
printf("%s", Astring);

xxxxx put this in Astring


Hobbit House Software
*/




page 262 The Hobbit House String Library



LEFTPADW.C file date: 03/13/93 page 1 of 1 LEFTPADW.C


/* strlfpadnew
Hobbit House Software

copyright(c) 1992, 1993

function: strlfpadnew (STRing LeFt PAD to NEW string)

KWIC: %pad a string on the %left

syntax: #include "hhstring.h"
char *strlfpadnew(char *newstring, char *instring,
int nchars, char PadChar)

description: create newstring, consisting of nchars occurrences of
PadChar, followed by instring

returns: a pointer to newstring.

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring will not work
in general although it will may work in some special
cases. Analyse the source code if you need more details.

keywords: string, left, pad, new, size

key sentence: creates a new string which has a specified number of a
specified pad character, on the left, followed by a given
string, and returns a pointer to the new string

see also: str< lf | mid | rt >pad{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "this is Astring";
char Bstring[80];
strlfpadnew(Bstring, Astring, 5, 'x');
printf("%s", Bstring);

xxxxxthis is Astring


Hobbit House Software
*/







The Hobbit House String Library page 263



LEFTROT.C file date: 03/13/93 page 1 of 1 LEFTROT.C


/* strlfrot
Hobbit House Software

copyright(c) 1992, 1993

function: strlfrot (STRing LeFt ROTate)

KWIC: %rotate a string to the %left

syntax: #include (malloc.h for Microsoft)
#include "hhstring.h"
char *strlfrot(char *instring, int nchar)

description: rotates instring left nchar places.

returns: a pointer to instring

comments: if nchar is greater than the length of the string, then
it is taken MODULO the string length prior to the rotate,
so that long rotates are handled properly

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, rotate

key sentence: rotates a string, left, n places, and returns a pointer to
the string

see also: str< lf | rt >sh{new} str< lf | rt >rot{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "---This is the string to rotate";
strlfrot(Astring, 3);
printf("%s", Astring);

This is the string to rotate---


Hobbit House Software
*/











page 264 The Hobbit House String Library



LEFTROTW.C file date: 03/13/93 page 1 of 1 LEFTROTW.C


/* strlfrotnew
Hobbit House Software

copyright(c) 1992, 1993

function: strlfrotnew (STRing LeFt ROTate to NEW string)

KWIC: %rotate a string to the %left

syntax: #include "hhstring.h"
char *strlfrotnew(char *newstring, char *instring,
int nchar)

description: creates newstring as a left rotate, by nchar places, of
instring

returns: a pointer to newstring

comments: If nchar is bigger than the length of the string, it will
be taken MODULO the length of the string before the rotate
is performed, so that long rotates are performed correctly

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, left, rotate, new

key sentence: creates a new string as a left rotate, n places, of a
given string, and returns a pointer to the new string

see also: str< lf | rt >sh{new} str< lf | rt >rot{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "---This is the string to rotate";
char Bstring[80];
strlfrotnew(Bstring, Astring, 3);
printf("%s", Bstring);

This is the string to rotate---


Hobbit House Software
*/





The Hobbit House String Library page 265



LEFTSET.C file date: 03/13/93 page 1 of 1 LEFTSET.C


/* strlfset
Hobbit House Software

copyright(c) 1992, 1993

function: strlfset (STRing LeFt SET)

KWIC: %set the %left side of a string

syntax: #include "hhstring.h"
char *strlfset(char *instring, int nchar, char setchar)

description: sets the leftmost nchar characters of instring to setchar

returns: a pointer to instring

comments: if nchar is longer than the string, overflow will NOT be
allowed but the entire string will be set to setchar

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, set

key sentence: sets the leftmost n characters of a string to the
character c, and returns a pointer to the string

see also: str{ lf | mid | rt }set{new}

usage example: compiled/executed/verified on 2/4/93

char *Astring = "This is the string";
strlfset(Astring, 4, 'x');
printf("%s", Astring);

xxxx is the string


Hobbit House Software
*/













page 266 The Hobbit House String Library



LEFTSETW.C file date: 03/13/93 page 1 of 2 LEFTSETW.C


/* strlfsetnew
Hobbit House Software

copyright(c) 1992, 1993

function: strlfsetnew (STRing LeFt SET to NEW string)

KWIC: %set the %left side of a string

syntax: #include "hhstring.h"
char *strlfsetnew(char *newstring, char *instring,
int nchar, char setchar)

description: creates a new string which is instring but with the
leftmost nchar characters set to setchar

returns: a pointer to newstring

comments: if nchar is longer than instring, then newstring will be
the same length as instring, but will be completely set to
setchar

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this

function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, left, set, new

key sentence: creates a string which is the same as a given string
except that the leftmost n characters are set to the
character c, and returns a pointer to the new string

see also: str{ lf | mid | rt }set{new}

















The Hobbit House String Library page 267



LEFTSETW.C file date: 03/13/93 page 2 of 2 LEFTSETW.C




usage example: compiled/executed/verified on 2/4/93

char Astring[80] = "this is the string to set";
char Bstring[80];
strlfsetnew(Bstring, Astring, 7, '-');
printf("%s", Bstring);

------- the string to set


Hobbit House Software
*/








































page 268 The Hobbit House String Library



LEFTSHF.C file date: 03/13/93 page 1 of 1 LEFTSHF.C


/* strlfsh
Hobbit House Software

copyright(c) 1992, 1993

function: strlfsh (STRing LeFt SHift)

KWIC: %shift a string to the %left

syntax: #include "hhstring.h"
char *strlfsh (char *instring, int nchar)

description: shift instring left by nchar places and fill with blanks
on the right

returns: a pointer to instring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, shift

key sentence: shifts a string n characters to the left, shifting in
blanks on the right, and returns a pointer to the string

see also: str< lf | rt >sh{new} str< lf | rt >rot{new}

usage example: compiled/executed/verified on 12/13/92

char *string1 = "this is string1";
printf("\n->%s<-", string1);
strlfsh(string1, 5);
printf("\n->%s<-", string1);

->this is string1<-
->is string1 <-


Hobbit House Software
*/













The Hobbit House String Library page 269



LEFTSHFW.C file date: 03/13/93 page 1 of 1 LEFTSHFW.C


/* strlfshnew
Hobbit House Software

copyright(c) 1992, 1993

function: strlfshnew (STRing LeFt SHift to NEW string)

KWIC: %shift a string to the %left

syntax: #include "hhstring.h"
char *strlfshnew(char *newstring, char *instring,
int nchar)

description: create newstring as instring shifted to the left by nchar
places and filled with blanks on the right

returns: a pointer to newstring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, left, shift, new

key sentence: creates a new string, which is a given string shifted n
characters to the left, with blanks filling in on the
right, and returns a pointer to the new string

see also: str< lf | rt >sh{new} str< lf | rt >rot{new}

usage example: compiled/executed/verified on 12/13/92

char newstring[80];
char *string1 = "this is string1";
printf("\n->%s<-", string1);
strlfshnew(newstring, string1, 5);
printf("\n->%s<-", newstring);

->this is string1<-
->is string1 <-


Hobbit House Software
*/






page 270 The Hobbit House String Library



LEFTSIZ.C file date: 03/13/93 page 1 of 1 LEFTSIZ.C


/* strlfsize
Hobbit House Software

copyright(c) 1992, 1993

function: strlfsize (STRing, pad/truncate on LeFt to force SIZE)

KWIC: force a string to a fixed %size

syntax: #include "hhstring.h"
char *strlfsize(char *instring, int size)

description: force instring to be size characters long by padding it
on the left with blanks or truncating it on the left

returns: a pointer to instring

comments: this function necessarily assumes that the string space
is big enough to hold any string expansion requested. If
this is not the case then memory locations will be wiped
out and the results will be unpredictable.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, size, truncate, delete

key sentence: pads a string on the left with blanks, or truncates it on
the left, as necessary to achieve a specified size, and
returns a pointer to the modified string

see also: str< lf | rt >size{new}

usage example: compiled/executed/verified on 12/13/92

char Astring[80] = "This is the first string";
char Bstring[80] = "second string";
strlfsize(Astring, 16);
strlfsize(Bstring, 16);
printf("%s\n%s", Astring, Bstring);

the first string
second string


Hobbit House Software
*/






The Hobbit House String Library page 271



LEFTSIZW.C file date: 03/13/93 page 1 of 2 LEFTSIZW.C


/* strlfsizenew
Hobbit House Software

copyright(c) 1992, 1993

function: strlfsizenew (STRing, pad/truncate on LeFt to force SIZE
to NEW string)

KWIC: force a string to a fixed %size

syntax: #include "hhstring.h"
char *strlfsizenew(char *newstring, char *instring,
int size)

description: create newstring which is size characters long and
consists of instring either padded on the left with
blanks or truncated on the left

returns: a pointer to newstring

comments: this function necessarily assumes that the new string
space is big enough to hold any string expansion
requested. If this is not the case then memory locations
will be wiped out and the results will be unpredictable.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, size, new, truncate, delete

key sentence: creates a string which consists of a specified string
either padded on the left with blanks, or truncated on the
left, to achieve a specified size, and returns a pointer
to the new string

see also: str< lf | rt >size{new}

















page 272 The Hobbit House String Library



LEFTSIZW.C file date: 03/13/93 page 2 of 2 LEFTSIZW.C




usage example: compiled/executed/verified on 1/19/93

char Astring[80] = "This is the first string";
char Bstring[80] = "second string";
char Cstring[80];
strlfsizenew(Cstring, Astring, 16);
printf("\n%s", Cstring);
printf("\n%s", strlfsizenew(Cstring, Bstring, 16));

the first string
second string


Hobbit House Software
*/





































The Hobbit House String Library page 273



LEFTTRM.C file date: 03/13/93 page 1 of 1 LEFTTRM.C


/* strlftrim
Hobbit House Software

copyright(c) 1992, 1993

function: strlftrim (STRing LeFt TRIM whitespace)

KWIC: %delete leading %whitespace (blanks and tabs) from a
string

syntax: #include "hhstring.h"
char *strlftrim(char *instring)

description: removes blanks and tabs from the left side of instring

returns: a pointer to instring

comments: if the string consists of nothing but whitespace, then it
will end up as a null string

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, left, trim, whitespace, blank, tab, truncate,
delete

key sentence: deletes any leading whitespace from a string and returns
a pointer to the string

see also: str{ lf | rt }trim{new}

usage example: compiled/executed/verified on 12/13/92

char Astring[80] = " This line has 3 leading blanks";
strlftrim(Astring);
printf("\n%s\n", Astring);

This line has 3 leading blanks


Hobbit House Software
*/











page 274 The Hobbit House String Library



LEFTTRMW.C file date: 03/13/93 page 1 of 1 LEFTTRMW.C


/* strlftrimnew
Hobbit House Software

copyright(c) 1992, 1993

function: strlftrimnew (STRing LeFt TRIM whitespace to NEW string)

KWIC: %delete leading %whitespace (blanks and tabs) from a
string

syntax: #include "hhstring.h"
char *strlftrimnew(char *newstring, char *instring)

description: trims blanks and tabs from the left side of instring and
puts the results into newstring

returns: a pointer to newstring

comments: if the string consists of nothing but whitespace, then
the new string will be a null string.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, left, trim, whitespace, blank, tab, new, truncate,
delete

key sentence: creates a string by copying in a given string, exclusive
of any leading blanks and tabs, and returns a pointer to
the new string

see also: str{ lf | rt }trim{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = " This line has 3 leading blanks";
char Bstring[80];
strlftrimnew(Bstring, Astring);
printf("%s", Bstring);

This line has 3 leading blanks


Hobbit House Software
*/




The Hobbit House String Library page 275



MID.C file date: 03/13/93 page 1 of 1 MID.C


/* strmid
Hobbit House Software

copyright(c) 1992, 1993

function: strmid (STRing MIDdle)

KWIC: get the %middle characters from a string

syntax: #include "hhstring.h"
char *strmid(char *instring, int start)

NOTE: "start" is ZERO-origin. That is, to start with the
very first element of a string, specify a start of
0, not 1.

description: modify instring so that it becomes only the characters
starting at start

returns: a pointer to the "new" string, which will use the same
memory space as did the original input string. If the
specified "start" is at or beyond the end of the string,
the string is set to a NULL string.

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, middle

key sentence: modifies a string so that it becomes only those characters
in the original string from a specified start to the end
of the string

see also: strleft{new} strmid{new}
strright{new} strmidn{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "name size date other";
strmid(Astring, 15);
printf("%s", Astring);

other


Hobbit House Software
*/






page 276 The Hobbit House String Library



MIDDEL.C file date: 03/13/93 page 1 of 1 MIDDEL.C


/* strmiddel
Hobbit House Software

copyright(c) 1992, 1993

function: strmiddel (STRing MIDdle DELete)

KWIC: %delete the %middle of a string

syntax: #include "hhstring.h"
char *strmiddel(char *instring, int start, int nchar)

description: for the specified string, all of the characters from start
to start+nchar are deleted

returns: a pointer to the string

comments: if start is beyond the end of the string, then nothing is
deleted. If start+nchar is greater than the length of the
string, then only those characters from start to the end
of the string are deleted

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, middle, delete, truncate

key sentence: deletes a specified number of characters from a string
starting at a specified point in the string

see also: str< lf | mid | rt >del{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "this is the sample string";
strmiddel(Astring, 12, 7);
printf("%s", Astring);

this is the string


Hobbit House Software
*/










The Hobbit House String Library page 277



MIDDELW.C file date: 03/13/93 page 1 of 2 MIDDELW.C


/* strmiddelnew
Hobbit House Software

copyright(c) 1992, 1993

function: strmiddelnew (STRing MIDdle DELete to NEW string)

KWIC: %delete the %middle of a string

syntax: #include "hhstring.h"
char *strmiddelnew(char *newstring, char *instring,
int start, int nchar)

description: a new string is created which consists on the first string
but without the specified middle set of characters.

returns: a pointer to the new string

comments: if start is beyond the end of the string, then the new
string is the same as the old string (nothing is deleted).
If start+nchar is greater than the length of the string,
then only those characters from start to the end of the
string are deleted from the input string to create the
new string.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, middle, delete, new, truncate

key sentence: deletes a specified number of characters from a string
starting at a specified point in the string and puts the
result into a new string

see also: str< lf | mid | rt >del{new}














page 278 The Hobbit House String Library



MIDDELW.C file date: 03/13/93 page 2 of 2 MIDDELW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = "this is the SAMPLE string";
char Bstring[80];
strmiddelnew(Bstring, Astring, 12, 7);
printf("%s", Bstring);

this is the string


Hobbit House Software
*/








































The Hobbit House String Library page 279



MIDN.C file date: 03/13/93 page 1 of 2 MIDN.C


/* strmidn
Hobbit House Software

copyright(c) 1992, 1993

function: strmidn (STRing, get MIDdle N characters)

KWIC: get the %middle n characters of a string

syntax: #include "hhstring.h"
char *strmidn(char *instring, int start, int nchars)

NOTE: "start" is ZERO-origin. That is, to start with the
10th element of a string, specify a start of 9,
not 10.

description: modify instring so that it becomes only the nchars
characters starting at start

returns: a pointer to the "new" string, which will use the same
memory space as did the original input string. If the
specified "start" is at or beyond the end of the string,
the string is set to a NULL string. If the combination of
"start" + "nchar" would go beyond the end of the string
then overflow is not allowed; only the string up to the
end is included in final string.

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, middle

key sentence: modifies a string so that it becomes only the n characters
starting at a specified start in the original string

see also: strleft{new} strmid{new}
strright{new} strmidn{new}
















page 280 The Hobbit House String Library



MIDN.C file date: 03/13/93 page 2 of 2 MIDN.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = "name size date other";
strmidn(Astring, 10, 4);
printf("%s", Astring);

date


Hobbit House Software
*/










































The Hobbit House String Library page 281



MIDW.C file date: 03/13/93 page 1 of 2 MIDW.C


/* strmidnew
Hobbit House Software

copyright(c) 1992, 1993

function: strmidnew (STRing MIDdle to NEW string)

KWIC: get the %middle of a string

syntax: #include "hhstring.h"
char *strmidnew(char *newstring, char *instring,
int start)

NOTE: "start" is ZERO-origin. That is, to start with the
very first element of a string, specify a start of
0, not 1.

description: create a new string which is the input string starting at
"start" characters from the beginning.

returns: a pointer to the "new" string. If "start" goes beyond the
end of the string, then the new string is set to a NULL.

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may not
work so if you must overlap, do it cautiously.

keywords: string, middle, new

key sentence: copies a string, starting at a specified point, to a new
string

see also: strleft{new} strmid{new}
strright{new} strmidn{new}
















page 282 The Hobbit House String Library



MIDW.C file date: 03/13/93 page 2 of 2 MIDW.C




usage example: compiled/executed/verified on 12/13/92

char Astring[80] = "name size date other";
char Bstring[80] = "name size date several others";
char Newstring[80];
strmidnew(Newstring, Astring, 15);
printf("\n%s", Newstring);
strmidnew(Newstring, Bstring, 15);
printf("\n%s", Newstring);

other
several others


Hobbit House Software
*/




































The Hobbit House String Library page 283



MIDNW.C file date: 03/13/93 page 1 of 2 MIDNW.C


/* strmidnnew
Hobbit House Software

copyright(c) 1992, 1993

function: strmidnnew (STRing, get MIDdle N characters, to NEW)

KWIC: get the %middle n characters of a string

syntax: #include "hhstring.h"
char *strmidnnew(char *newstring, char *instring,
int start, int nchars)

NOTE: "start" is ZERO-origin. That is, to start with the
10th element of a string, specify a start of 9,
not 10.

description: Create a new string which consists of the characters from
an old string, starting at "start" and ending at "start" +
"nchars".

returns: a pointer to the new string. If the specified "start" is
at or beyond the end of the string, "newstring" is set to
a NULL. If the combination of "start" + "nchar" would go
beyond the end of the input string, then overflow is not
allowed; only the string up to the end is included in the
new string.

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, middle, new

key sentence: creates a new string which is a specified number of
characters of a first string, starting at a specified
point in the first string

see also: strleft{new} strmid{new}
strright{new} strmidn{new}










page 284 The Hobbit House String Library



MIDNW.C file date: 03/13/93 page 2 of 2 MIDNW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = "name size date other";
char Newstring[80];
strmidnnew (Newstring, Astring,5,4);
printf("%s", Newstring);

size


Hobbit House Software
*/








































The Hobbit House String Library page 285



MIDPAD.C file date: 03/13/93 page 1 of 2 MIDPAD.C


/* strmidpad
Hobbit House Software

copyright(c) 1992, 1993

function: strmidpad (STRing MIDdle PAD)

KWIC: %pad a string in the %middle

syntax: #include "hhstring.h"
char *strmidpad(char *instring, int where, int nchar,
char padchar)

description: instring is opened at where and nchar padchars are
inserted.

WARNING: the input string MUST have enough memory space beyond its
terminating 0 to accommodate the extra characters. This
function necessarily assumes that the space is available.
If the space is not available, this function will destroy
whatever is in the memory space following the input
string.

returns: a pointer to the string

comments: The input string MUST have enough extra memory space to
allow for the insertion of the new characters, else
subsequent memory will be destroyed.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, middle, pad, size

key sentence: changes the size of a string by opening it up at a
specified
point and inserting n copies of the character c into it,
and
returns a pointer to the modifited string

see also: str< lf | mid | rt >pad{new}












page 286 The Hobbit House String Library



MIDPAD.C file date: 03/13/93 page 2 of 2 MIDPAD.C




usage example: compiled/executed/verified on 12/13/92

char Astring[80] = "This is it; the sample";
strmidpad(Astring, 12, 3, '-');
printf("%s", Astring);

This is it; ---the sample


Hobbit House Software
*/









































The Hobbit House String Library page 287



MIDPADW.C file date: 03/13/93 page 1 of 2 MIDPADW.C


/* strmidpadnew
Hobbit House Software

copyright(c) 1992, 1993

function: strmidpadnew (STRing MIDdle PAD to NEW string)

KWIC: %pad a string in the %middle

syntax: #include "hhstring.h"
char *strmidpadnew(char *newstring, char *instring,
int where, int nchar, char padchar)

description: "instring"is opened up at "where" and "nchar" "padchar"s
are inserted, with the result going to "newstring"

returns: a pointer to the new string

comments: The new string MUST have enough memory space to allow for
instring plus the inserted characters, else subsequent
memory will be destroyed.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, middle, pad, new, size

key sentence: copies a given string into a new string and inserts n
copies
of the character c at a specified location in the new
string
and returns a pointer to the new string

see also: str< lf | mid | rt >pad{new}















page 288 The Hobbit House String Library



MIDPADW.C file date: 03/13/93 page 2 of 2 MIDPADW.C




usage example: compiled/executed/verified on 12/13/92

char Astring[80] = "This is it; the sample";
char Bstring[80];
strmidpadnew(Bstring, Astring, 12, 3, '-');
printf("%s", Bstring);

This is it; ---the sample


Hobbit House Software
*/








































The Hobbit House String Library page 289



MIDSET.C file date: 03/13/93 page 1 of 1 MIDSET.C


/* strmidset
Hobbit House Software

copyright(c) 1992, 1993

function: strmidset (STRing MIDdle SET)

KWIC: %set the %middle of a string to a given character

syntax: #include "hhstring.h"
char *strmidset(char *instring, int start,
int nchar, char setchar)

description: set instring from "start" characters beyond the beginning
to "start"+"nchar" characters beyond the beginning to
setchar

returns: a pointer to the string

comments: if start+nchar would go beyond the end of the string,
overflow will NOT be allowed and the set will terminate
in front of the final 0 of the string. If start itself
would start beyond the end of the string, then the string
remains unchanged.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, middle, set

key sentence: changes a specified number of characters in a string,
starting at a specified point, to a specified set
character

see also: str{ lf | mid | rt }set{new}

usage example: compiled/executed/verified on 2/4/93

char *Astring = "This is the string";
strmidset(Astring, 8, 3, '-');
printf("%s", Astring);

This is --- string


Hobbit House Software
*/






page 290 The Hobbit House String Library



MIDSETW.C file date: 03/13/93 page 1 of 2 MIDSETW.C


/* strmidsetnew
Hobbit House Software

copyright(c) 1992, 1993

function: strmidsetnew (STRing MIDdle SET to NEW string)

KWIC: %set the %middle of a string to a given character

syntax: #include "hhstring.h"
char *strmidsetnew(char *newstring, char *instring,
int start, int nchar, char setchar)

description: create newstring equal to instring except that from
"start" characters beyond the beginning to "start" +
"nchar" characters beyond the beginning, newstring
consists of "setchar".

returns: a pointer to newstring

comments: if start+nchar would go beyond the end of instring, the
entire right side of newstring will consist of setchar,
but newstring will have the same length as instring. If
start itself would start beyond the end of the instring,
then newstring will be identical to instring.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring will not work
in general although in some special cases it will. Analyse
the source code if you need more details.

keywords: string, middle, set, new

key sentence: changes a specified number of characters in a string,
starting at a specified point in the string, to a
specified set character, and puts the results into a
new string

see also: str{ lf | mid | rt }set{new}











The Hobbit House String Library page 291



MIDSETW.C file date: 03/13/93 page 2 of 2 MIDSETW.C




usage example: compiled/executed/verified on 2/4/93

char Bstring[80];
char *Astring = "Name Date Amount Number";
strmidsetnew(Bstring, Astring, 10, 6, '-');
printf("%s", Bstring);

Name Date ------ Number


Hobbit House Software
*/








































page 292 The Hobbit House String Library



REPEAT.C file date: 03/13/93 page 1 of 1 REPEAT.C


/* strrepeat
Hobbit House Software

copyright(c) 1992, 1993

function: strrepeat (STRing REPEAT into another string)

KWIC: create a string by %repeating a shorter string into it

syntax: #include "hhstring.h"
char *strrepeat(char *newstring, char *instring, int n);

description: repeats instring into newstring, n times

returns: a pointer to newstring

comments: The new string must have enough room to contain n
repetitions of instring, else there be dragons

keywords: string, repeat

key sentence: creates a string by repeating a shorter string into it
a specified number of times

see also: strrepeat{n}

usage example: compiled/executed/verified on 12/13/92

char makeit[80];
char *msg = "do it now --- ";
strrepeat(makeit, msg, 3);
printf("%s", makeit);

do it now --- do it now --- do it now ---


Hobbit House Software
*/
















The Hobbit House String Library page 293



REPEATN.C file date: 03/13/93 page 1 of 2 REPEATN.C


/* strrepeatn
Hobbit House Software

copyright(c) 1992, 1993

function: strrepeatn (STRing, REPEAT into another string,
with N-char limit)

KWIC: create a string by %repeating a shorter string into it and
limit the output to a specified %size

syntax: #include "hhstring.h"
char *strrepeatn(char *newstring, char *instring,
int ntimes, nchars);

description: repeats instring into newstring, ntimes times but limits
the created string to nchars characters. If nchars is
reached, a '\0' is put into the newstring at the "nchar"th
position. Note that if the character limit is not reached,
there is automatically a '\0' in the output string from
the last strcat function and the output string will be
shorter than nchars.

returns: a pointer to newstring

comments: The new string must have enough room to contain nchars
characters.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, repeat, size

key sentence: creates a string by repeating a shorter string into it a
specified number of times but limits the final string
length to a specified size

see also: strrepeat{n}















page 294 The Hobbit House String Library



REPEATN.C file date: 03/13/93 page 2 of 2 REPEATN.C




usage example: compiled/executed/verified on 2/25/93

char msg[80] = "do it now --- ";

char makeit[80];
strrepeatn(makeit, msg, 3, 33);
printf("-->%s<--", makeit);

-->do it now --- do it now --- do it<--


Hobbit House Software
*/








































The Hobbit House String Library page 295



REVERSE.C file date: 03/13/93 page 1 of 1 REVERSE.C


/* strreverse
Hobbit House Software

copyright(c) 1992, 1993

function: strreverse (STRing REVERSE)

KWIC: %reverse the contents of a string

syntax: #include "hhstring.h"
char *strreverse(char *instring)

description: reverses the contents of instring

returns: a pointer to the string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, reverse

key sentence: reverses the contents of a string, end to end

see also: strreverse{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "abcdef0123456789";
strreverse(Astring);
printf("%s", Astring);

9876543210fedcba


Hobbit House Software
*/

















page 296 The Hobbit House String Library



REVERSEW.C file date: 03/13/93 page 1 of 1 REVERSEW.C


/* strreversenew
Hobbit House Software

copyright(c) 1992, 1993

function: strreversenew (STRing REVERSE to NEW string)

KWIC: %reverse the contents of a string

syntax: #include "hhstring.h"
char *strreversenew(char *newstring, char *instring)

description: creates newstring as the reverse of instring

returns: a pointer to the new string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring WILL NOT WORK with this
function nor will overlapping newstring with instring by
even one character. You could create some interesting
results by overlapping but they would NOT be pure string
reversal.

keywords: string, reverse, new

key sentence: reverses the contents of a string, end to end, and puts
the result into a new string

see also: strreverse{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "abcdef0123456789";
char Bstring[80];
strreversenew(Bstring, Astring);
printf("%s", Bstring);

9876543210fedcba


Hobbit House Software
*/









The Hobbit House String Library page 297



RIT.C file date: 03/13/93 page 1 of 1 RIT.C


/* strright
Hobbit House Software

copyright(c) 1992, 1993

function: strright (STRing RIGHT)

KWIC: get n characters from the %right side of a string

syntax: #include "hhstring.h"
char *strright(char *instring, int nchar)

description: modify instring so that it contains only the "n"
character on the right side of the original string.
If the instring is shorter than nchar, then it
remains unchanged.

returns: a pointer to instring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right

key sentence: modifies a string so that it consist of only its rightmost
original n characters

see also: strleft{new} strmid{new}
strright{new} strmidn{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "name size date other";
strright(Astring, 5);
printf("%s", Astring);

other

Hobbit House Software
*/













page 298 The Hobbit House String Library



RITW.C file date: 03/13/93 page 1 of 2 RITW.C


/* strrightnew
Hobbit House Software

copyright(c) 1992, 1993

function: strrightnew (STRing RIGHT to NEW string)

KWIC: get n characters from the %right side of a string

syntax: #include "hhstring.h"
char *strrightnew(char *newstring, char *instring, int n)

description: move the "n" characters on the right side of instring to
newstring. If the requested substring is larger than
instring, then newstring will be the same as instring.
In any case, instring is unchanged.

returns: a pointer to newstring

comments: The user passes the newstring pointer to the function
which then fills up newstring with the appropriate
characters from the old string (possibly including ALL of
them).

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, right, new

key sentence: copies the rightmost n characters from a string into a
new string

see also: strleft{new} strmid{new}
strright{new} strmidn{new}















The Hobbit House String Library page 299



RITW.C file date: 03/13/93 page 2 of 2 RITW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = "name size date other";
char Newstring[80];
strrightnew(Newstring, Astring, 5);
printf("%s", Newstring);

other

Hobbit House Software
*/









































page 300 The Hobbit House String Library



RITDEL.C file date: 03/13/93 page 1 of 1 RITDEL.C


/* strrtdel
Hobbit House Software

copyright(c) 1992, 1993

function: strrtdel (STRing RighT DELete)

KWIC: %delete characters from the %right side of a string

syntax: #include "hhstring.h"
char *strrtdel(char *instring, int nchar)

description: move the terminating 0 for instring so as to delete the
rightmost nchar characters

returns: a pointer to instring

comments: If nchar is greater than the length of instring, then
instring will be set to a null string and the rest of
memory will not be disturbed.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, delete, truncate

key sentence: deletes the rightmost n characters from a string

see also: str< lf | mid | rt >del{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "this is the input string";
strrtdel(Astring, 7);
printf("%s", Astring);

this is the input


Hobbit House Software
*/












The Hobbit House String Library page 301



RITDELW.C file date: 03/13/93 page 1 of 1 RITDELW.C


/* strrtdelnew
Hobbit House Software

copyright(c) 1992, 1993

function: strrtdelnew (STRing RighT DELete to NEW string)

KWIC: %delete characters from the %right side of a string

syntax: #include "hhstring.h"
char *strrtdelnew(char *newstring, char *instring,
int nchar)

description: newstring is created identical to instring except that
the rightmost n characters of instring are not included
in instring.

returns: a pointer to newstring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, right, delete, new, truncate

key sentence: creates a new string which is the same as a given string
except that the rightmost n characters are not included in
the new string

see also: str< lf | mid | rt >del{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "this is the input string";
char Bstring[90];
strrtdelnew(Bstring, Astring, 7);
printf("%s", Bstring);

this is the input


Hobbit House Software
*/







page 302 The Hobbit House String Library



RITJUS.C file date: 03/13/93 page 1 of 1 RITJUS.C


/* strrtjust
Hobbit House Software

copyright(c) 1992, 1993

function: strrtjust (STRing RighT JUStify)

KWIC: %right %justify a string

syntax: #include "hhstring.h"
char *strrtjust(char *instring)

description: the contents of instring are shifted right to remove any
whitespace (blanks or TABs) on the right side. Blanks are
shifted in on the left to replace the characters shifted
out to the right.

returns: a pointer to instring

comments: note that only one blank is shifted in on the right for
each TAB that is shifted out on the left

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, justify

key sentence: right justifies a string

see also: str< lf | rt >just{new} strcenter{n}{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "Right Justify this string ";
strrtjust(Astring);
printf("-->%s<--", Astring);

--> Right Justify this string<--


Hobbit House Software
*/











The Hobbit House String Library page 303



RITJUSW.C file date: 03/13/93 page 1 of 2 RITJUSW.C


/* strrtjustnew
Hobbit House Software

copyright(c) 1992, 1993

function: strrtjustnew (STRing RighT JUStify to NEW string)

KWIC: %right %justify a string

syntax: #include "hhstring.h"
char *strrtjustnew(char *newstring, char *instring)

description: the contents of a string are shifted right to remove any
whitespace (blanks or TABs) on the right side. Blanks are
shifted in on the left to replace the characters shifted
out to the right. The results go to newstring. instring
is not changed.

returns: a pointer to newstring

comments: NOTE that only one blank is shifted in on the left to
replace a TAB that is deleted from the right side of the
string.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, right, justify, new

key sentence: right justifies a string with the results going to a
new string

see also: str< lf | rt >just{new} strcenter{n}{new}
















page 304 The Hobbit House String Library



RITJUSW.C file date: 03/13/93 page 2 of 2 RITJUSW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = "Right Justify this string ";
char Bstring[80];
strrtjustnew(Bstring, Astring);
printf("-->%s<--", Bstring);

--> Right Justify this string<--


Hobbit House Software
*/








































The Hobbit House String Library page 305



RITPAD.C file date: 03/13/93 page 1 of 1 RITPAD.C


/* strrtpad
Hobbit House Software

copyright(c) 1992, 1993

function: strrtpad (STRing RighT PAD)

KWIC: %pad a string on the %right

syntax: #include "hhstring.h"
char *strrtpad(char *instring, int nchar, char PadChar)

description: pads instring on the right with nchar occurrences of
PadChar

WARNING: the input string MUST have enough memory space beyond its
terminating 0 to accommodate the extra characters. This
function necessarily assumes that the space is available.
If the space is not available, this function will destroy
whatever is in the memory space following the input
string.

returns: a pointer to instring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, pad, size

key sentence: changes the size of a string by adding n copies of a pad
character onto its right side

see also: str< lf | mid | rt >pad{new}

usage example: compiled/executed/verified on 12/13/92

char Astring[80] = "this is Astring";
strrtpad(Astring, 5, 'x');
printf("%s", Astring);

this is Astringxxxxx


Hobbit House Software
*/








page 306 The Hobbit House String Library



RITPADW.C file date: 03/13/93 page 1 of 1 RITPADW.C


/* strrtpadnew
Hobbit House Software

copyright(c) 1992, 1993

function: strrtpadnew (STRing RighT PAD to NEW string)

KWIC: %pad a string on the %right

syntax: #include "hhstring.h"
char *strrtpadnew(char *newstring, char *instring,
int nchar, char PadChar)

description: creates newstring which has instring as its left side and
is padded on the right with nchar occurrences of PadChar

returns: a pointer to newstring.

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, right, pad, new, size

key sentence: changes the size of a string by adding n copies of a pad
character to the right side, puts the result into a new
string, and returns a pointer to the new string

see also: str< lf | mid | rt >pad{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "this is Astring";
char Bstring[80];
strrtpadnew(Bstring, Astring, 5, 'x');
printf("%s", Bstring);

this is Astringxxxxx


Hobbit House Software
*/








The Hobbit House String Library page 307



RITROT.C file date: 03/13/93 page 1 of 1 RITROT.C


/* strrtrot
Hobbit House Software

copyright(c) 1992, 1993

function: strrtrot (STRing RighT ROTate)

KWIC: %rotate a string to the %right

syntax: #include
#include "hhstring.h"
char *strrtrot(char *instring, int nchar)

description: rotates instring right by nchar places

returns: a pointer to instring

comments: if nchar is greater than the length of the string, then it
is taken MODULO the string length prior to the rotate, so
the rotate is correct.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, rotate

key sentence: rotates a string right n places

see also: str< lf | rt >sh{new} str< lf | rt >rot{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "This is the string to rotate---";
strrtrot(Astring, 3);
printf("%s", Astring);

---This is the string to rotate


Hobbit House Software
*/












page 308 The Hobbit House String Library



RITROTW.C file date: 03/13/93 page 1 of 1 RITROTW.C


/* strrtrotnew
Hobbit House Software

copyright(c) 1992, 1993

function: strrtrotnew (STRing RighT ROTate to NEW string)

KWIC: %rotate a string to the %right

syntax: #include "hhstring.h"
char *strrtrotnew(char *newstring, char *instring,
int nchar)

description: newstring is created by rotating instring nchar places to
the right.

returns: a pointer to newstring

comments: if nchar is greater than the length of the string, then
it is taken MODULO the length of the string before the
rotate is done, so the rotate is correct

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, right, rotate, new

key sentence: rotates a string right n places and puts the result
into a new string

see also: str< lf | rt >sh{new} str< lf | rt >rot{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "This is the string to rotate---";
char Bstring[80];
strrtrotnew(Bstring, Astring, 3);
printf("%s", Bstring);

---This is the string to rotate


Hobbit House Software
*/





The Hobbit House String Library page 309



RITSET.C file date: 03/13/93 page 1 of 1 RITSET.C


/* strrtset
Hobbit House Software

copyright(c) 1992, 1993

function: strrtset (STRing RighT SET)

KWIC: %set the %right side of a string to a given character

syntax: #include "hhstring.h"
char *strrtset(char *instring, int nchar, char setchar)

description: setchar is put into the rightmost nchar characters of
instring

returns: a pointer to instring.

comments: if nchar is greater than the length of the string,
overflow will NOT be allowed, but the entire string will
be set to setchar

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, set

key sentence: sets the rightmost n characters of a string with a given
set character

see also: str{ lf | mid | rt }set{new}

usage example: compiled/executed/verified on 2/4/93

char *Astring = "This is the string";
strrtset(Astring, 6, '/');
printf("%s", Astring);

This is the //////


Hobbit House Software
*/











page 310 The Hobbit House String Library



RITSETW.C file date: 03/13/93 page 1 of 1 RITSETW.C


/* strrtsetnew
Hobbit House Software

copyright(c) 1992, 1993

function: strrtsetnew (STRing RighT SET to NEW string)

KWIC: %set the %right side of a string

syntax: #include "hhstring.h"
char *strrtsetnew(char *newstring, char *instring,
int nchar, char setchar)

description: setchar is put into the rightmost nchar characters of
newstring and the remaining (if any) leftmost portion
of newstring is filled from instring

returns: a pointer to newstring.

comments: if nchar is greater than the length of instring,
newstring will be entirely set to setchar

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, right, set, new

key sentence: sets the rightmost n characters of a string with a
given set character and puts the results into a new string

see also: str{ lf | mid | rt }set{new}

usage example: compiled/executed/verified on 2/4/93

char *Astring = "This is the string";
char Bstring[80];
strrtsetnew(Bstring, Astring, 6, '+');
printf("%s", Bstring);

This is the ++++++


Hobbit House Software
*/





The Hobbit House String Library page 311



RITSHF.C file date: 03/13/93 page 1 of 1 RITSHF.C


/* strrtsh
Hobbit House Software

copyright(c) 1992, 1993

function: strrtsh (STRing RighT SHift)

KWIC: %shift a string to the %right

syntax: #include "hhstring.h"
char *strrtsh (char *instring, int nchar)

description: shift instring to the right nchar places and put blanks on
the left to replace the characters shifted out

returns: a pointer to instring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, shift

key sentence: shifts a string right n places, shifting blanks in on the
left

see also: str< lf | rt >sh{new} str< lf | rt >rot{new}

usage example: compiled/executed/verified on 12/13/92

char *string1 = "this is string #1";
printf("\n->%s<-", string1);
strrtsh(string1, 3);
printf("\n->%s<-", string1);

->this is string #1<-
-> this is string<-


Hobbit House Software
*/













page 312 The Hobbit House String Library



RITSHFW.C file date: 03/13/93 page 1 of 1 RITSHFW.C


/* strrtshnew
Hobbit House Software

copyright(c) 1992, 1993

function: strrtshnew (STRing RighT SHift to NEW string)

KWIC: %shift a string to the %right

syntax: #include "hhstring.h"
char *strrtshnew(char *newstring, char *instring,
int nchar)

description: newstring is filled with the characters from instring such
that newstring is instring shifted right nchar places and
filled with blanks on the left to replace the characters
shifted right

returns: a pointer to newstring

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring WILL NOT WORK with this
function and overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, right, shift, new

key sentence: shifts a string n places to the right, shifting blanks in
on the left, with the result going to a new string

see also: str< lf | rt >sh{new} str< lf | rt >rot{new}

usage example: compiled/executed/verified on 12/13/92

char Astring[80] = "this is string1";
char Bstring[80];
strrtshnew(Bstring, Astring, 8);
printf("->%s<-\n->%s<-", Astring, Bstring);

->this is string1<-
-> this is<-


Hobbit House Software
*/






The Hobbit House String Library page 313



RITSIZ.C file date: 03/13/93 page 1 of 1 RITSIZ.C


/* strrtsize
Hobbit House Software

copyright(c) 1992, 1993

function: strrtsize (STRing, pad/truncate on RighT to force SIZE)

KWIC: modify the %right side of a string to force a fixed %size

syntax: #include "hhstring.h"
char *strrtsize(char *instring, int size)

description: instring is padded on the right with blanks or truncated
on the right, to force it to size characters

returns: a pointer to instring

comments: this function necessarily assumes that the string space
is big enough to hold any string expansion requested.
If this is not the case then memory locations will be
wiped out and the results will be unpredictable.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, size, truncate

key sentence: pads or truncates a string on the right to force it to a
given size

see also: str< lf | rt >size{new}

usage example: compiled/executed/verified on 12/13/92

char Astring[80] = "This is the first string";
char Bstring[80] = "second";
strrtsize(Astring, 11);
strrtsize(Bstring, 11);
printf("\n%s<--", Astring);
printf("\n%s<--", Bstring);

This is the<--
second <--


Hobbit House Software
*/






page 314 The Hobbit House String Library



RITSIZW.C file date: 03/13/93 page 1 of 2 RITSIZW.C


/* strrtsizenew
Hobbit House Software

copyright(c) 1992, 1993

function: strrtsizenew (STRing, pad/truncate on RighT to force
SIZE to NEW string)

KWIC: modify the %right side of a string to force a fixed %size

syntax: #include "hhstring.h"
char *strrtsizenew(char *newstring, char *instring,
int size)

description: if the string is to be made bigger, then it is padded on
the right with blanks. If it is to be made smaller, then
it is truncated on the right. The result is put into the
new string.

returns: a pointer to newstring

comments: this function necessarily assumes that the new string
space is big enough to hold any string expansion
requested. If this is not the case then memory locations
will be wiped out and the results will be unpredictable.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, size, new, truncate

key sentence: pads or truncates a string on the right to force a given
size, with the result going to a new string

see also: str< lf | rt >size{new}


















The Hobbit House String Library page 315



RITSIZW.C file date: 03/13/93 page 2 of 2 RITSIZW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = "This is the first string";
char *Bstring = "second";
char Cstring[80];
char Dstring[80];
strrtsizenew(Cstring, Astring, 11);
strrtsizenew(Dstring, Bstring, 11);
printf("\n%s<--", Cstring);
printf("\n%s<--", Dstring);

This is the<--
second <--


Hobbit House Software
*/



































page 316 The Hobbit House String Library



RITTRM.C file date: 03/13/93 page 1 of 1 RITTRM.C


/* strrttrim
Hobbit House Software

copyright(c) 1992, 1993

function: strrttrim (STRing RighT TRIM whitespace)

KWIC: %trim %whitespace (blanks and tabs) from the %right side
of a string

syntax: #include "hhstring.h"
char *strrttrim(char *instring)

description: trims blanks and tabs from the right side of a string

returns: a pointer to instring

comments: if the string consists of nothing but whitespace, then it
will end up as a null string

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, right, trim, whitespace, blank, tab, truncate

key sentence: trims whitespace (blanks and tabs) from the right side of
a string

see also: str{ lf | rt }trim{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "This string has 3 trailing blanks ";
strrttrim(Astring);
printf("%s<---", Astring);

This string has 3 trailing blanks<---



Hobbit House Software
*/











The Hobbit House String Library page 317



RITTRMW.C file date: 03/13/93 page 1 of 1 RITTRMW.C


/* strrttrimnew
Hobbit House Software

copyright(c) 1992, 1993

function: strrttrimnew (STRing RighT TRIM whitespace to NEW string)

KWIC: %trim %whitespace (blanks and tabs) from the %right side
of a string

syntax: #include "hhstring.h"
char *strrttrimnew(char *newstring, char *instring)

description: trims blanks and tabs from the right side of instring and
puts the results into newstring

returns: a pointer to newstring

comments: if the string consists of nothing but whitespace, then
the new string will be a null string.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, right, trim, whitespace, blank, tab, new, truncate

key sentence: trims whitespace (tabs and blanks) from the right side of
a string and puts the result into a new string

see also: str{ lf | rt }trim{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "This string has 3 trailing blanks ";
char Bstring[80];
strrttrimnew(Bstring, Astring);
printf("%s<---", Bstring);

This string has 3 trailing blanks<---


Hobbit House Software
*/






page 318 The Hobbit House String Library



SUBCNT.C file date: 03/13/93 page 1 of 1 SUBCNT.C


/* strsubcount
Hobbit House Software

copyright(c) 1992, 1993

function: strsubcount (STRing, SUBstring, COUNT # of occurrences)

KWIC: return the %count of occurrences of a %substring in a
string

syntax: #include "hhstring.h"
int strsubcount (char *instring, char *substring)

description: the number of occurrences of substring in instring is
returned

returns: the number of occurrences of substring

comments: this function "counts" substring occurrences in a way such
that one occurrence is not counted as part of the string
when searching for the next occurrence. Thus the string:

"one one one one one one"

when examined for the substring "one one", will find not
5 occurrences, but 3 occurrences.

keywords: string, substring, count

key sentence: gives the number of occurrences of a substring in a string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/18/92

char *Astring = "This, that, and the other";
char *Bstring = "This one one one, that one one one";
printf("\n%d", strsubcount(Astring, "th"));
printf("\n%d", strsubcount(Bstring, "one one"));

3
2


Hobbit House Software
*/







The Hobbit House String Library page 319



SUBCNTI.C file date: 03/13/93 page 1 of 1 SUBCNTI.C


/* strsubcounti
Hobbit House Software

copyright(c) 1992, 1993

function: strsubcounti (STRing, SUBstring, COUNT number of
case-Independant occurrences)

KWIC: return the %count of occurrences, %independant of case,
of a %substring in a string

syntax: #include "hhstring.h"
int strsubcounti(char *instring, char *substring)

description: the number of case-independent occurrences of substring
in instring is returned

returns: the number of case-independent occurrences of substring

comments: none

keywords: string, substring, count, case-independent

key sentence: gives the number of case-independent occurrences of a
substring in a string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/19/92

char *Astring = "This, that, and the other";
char *Bstring = "This one one one, that one one one";
printf("\n%d", strsubcounti(Astring, "th"));
printf("\n%d", strsubcounti(Bstring, "ONE one"));

4
2


Hobbit House Software
*/












page 320 The Hobbit House String Library



SUBDL.C file date: 03/13/93 page 1 of 1 SUBDL.C


/* strsubdel
Hobbit House Software

copyright(c) 1992, 1993

function: strsubdel (STRing, SUBstring DELete)

KWIC: %delete a %substring from a string

syntax: #include "hhstring.h"
char *strsubdel(char *instring, char *substring)

description: the first occurrence of substring is deleted from instring

returns: a pointer to instring

comments: none

keywords: string, substring, delete

key sentence: deletes the first occurrence in a string of a given
substring

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/15/92

char *Astring = "This is the Sample String";
strsubdel(Astring, "Sample ");
printf("\n%s", Astring);
printf("\n%s", strsubdel(Astring, "the "));

This is the String
This is String


Hobbit House Software
*/















The Hobbit House String Library page 321



SUBDLA.C file date: 03/13/93 page 1 of 1 SUBDLA.C


/* strsubdelall
Hobbit House Software

copyright(c) 1992, 1993

function: strsubdelall (STRing SUBstring DELete ALL occurrences)

KWIC: %delete %all occurrences of a %substring in a string

syntax: #include "hhstring.h"
char *strsubdelall(char *instring, char *substring)

description: all occurrences of substring in instring are deleted

returns: a pointer to instring

comments: none

keywords: string, substring, delete, all

key sentence: deletes all occurrences in a string of a given substring

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/18/92

char *Astring = "This one and that one and the other one";
strsubdelall(Astring, "one");
printf("\n%s", Astring);
printf("\n%s", strsubdelall(Astring, "th"));

This and that and the other
This and at and e oer


Hobbit House Software
*/
















page 322 The Hobbit House String Library



SUBDLAW.C file date: 03/13/93 page 1 of 1 SUBDLAW.C


/* strsubdelallnew
Hobbit House Software

copyright(c) 1992, 1993

function: strsubdelallnew (STRing SUBstring DELete ALL occurrences,
to NEW string)

KWIC: %delete %all occurrences of a %substring in a string

syntax: #include "hhstring.h"
char *strsubdelallnew(char *newstring, char *instring,
char *substring)

description: all occurrences of substring in instring are deleted, but
the result goes to newstring, not instring

returns: a pointer to newstring

comments: none

keywords: string, substring, delete, all, new

key sentence: deletes all occurrences in a string of a given substring,
and puts the result into a new string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 2/19/93

char *Astring = "This one and that one and the other one";
char Bstring[80];
char Cstring[80];
strsubdelallnew(Bstring, Astring, "one");
printf("\n%s", Bstring);
printf("\n%s", strsubdelallnew(Cstring, Bstring, "th"));

This and that and the other
This and at and e oer


Hobbit House Software
*/










The Hobbit House String Library page 323



SUBDLI.C file date: 03/13/93 page 1 of 1 SUBDLI.C


/* strsubdeli
Hobbit House Software

copyright(c) 1992, 1993

function: strsubdeli (STRing, SUBstring DELete, case-Independant)

KWIC: %delete a %substring, %independant of case, from a string

syntax: #include "hhstring.h"
char *strsubdeli(char *instring, char *substring)

description: the first case-independent occurrence of substring is
deleted from instring

returns: a pointer to instring

comments: dealing with case independence causes this function to
be significantly larger and slower than the case-
dependant version (strsubdel)

keywords: string, substring, delete, case-independent

key sentence: deletes from a string the first case-independent
occurrence
of a given substring

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 2/25/93

char *Astring = "This is the Sample String";
strsubdeli(Astring, "SAMPLE ");
printf("\n%s", Astring);
printf("\n%s", strsubdeli(Astring, "THE "));

This is the String
This is String


Hobbit House Software
*/











page 324 The Hobbit House String Library



SUBDLIA.C file date: 03/13/93 page 1 of 1 SUBDLIA.C


/* strsubdeliall
Hobbit House Software

copyright(c) 1992, 1993

function: strsubdeliall (STRing, SUBstring DELete, case-Independant,
All occurrences)

KWIC: %delete %all occurrences, %independant of case, of a
%substring from a string

syntax: #include
#include "hhstring.h"
char *strsubdeliall(char *instring, char *substring)

description: all occurrences of substring, independent of case, in
instring are deleted

returns: a pointer to instring

comments: dealing with case independence causes this function to
be significantly larger and slower than the case-
dependant version (strsubdelall)

keywords: string, substring, delete, all, case-independent

key sentence: deletes from a string all case-independent occurrences
of a given substring

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/31/92

char *Astring = "This one and that one and the other one";
strsubdeliall(Astring, "one");
printf("\n%s", Astring);
printf("\n%s", strsubdeliall(Astring, "th"));

This and that and the other
is and at and e oer


Hobbit House Software
*/









The Hobbit House String Library page 325



SUBDLIAW.C file date: 03/13/93 page 1 of 1 SUBDLIAW.C


/* strsubdeliallnew
Hobbit House Software

copyright(c) 1992, 1993

function: strsubdeliallnew (STRing SUBstring DELete ALL occurrences,
Independant of case, to NEW string)

KWIC: %delete %all occurrences, %independant of case, of a
%substring in a string

syntax: #include "hhstring.h"
char *strsubdeliallnew(char *newstring, char *instring,
char *substring)

description: all occurrences of substring in instring, independent of
case, are deleted, with the result going to newstring

returns: a pointer to newstring

comments: none

keywords: string, substring, delete, all, new, case-independent

key sentence: deletes from a string all case-independent occurrences of
a given substring and puts the result into a new string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 2/19/93

char *Astring = "This one and that one and the other one";
char Bstring[80];
char Cstring[80];
strsubdeliallnew(Bstring, Astring, "one");
printf("\n%s", Bstring);
printf("\n%s", strsubdeliallnew(Cstring, Bstring, "th"));

This and that and the other
is and at and e oer


Hobbit House Software
*/









page 326 The Hobbit House String Library



SUBDLIW.C file date: 03/13/93 page 1 of 1 SUBDLIW.C


/* strsubdelinew
Hobbit House Software

copyright(c) 1992, 1993

function: strsubdelinew (STRing, SUBstring DELete, case-Independant,
to NEW string)

KWIC: %delete a %substring from a string, %independent of case

syntax: #include "hhstring.h"
char *strsubdelinew(char *newstring, char *instring,
char *substring)

description: the first occurrence of substring in instring is deleted,
with the resulting string going to newstring, not back
into instring

returns: a pointer to newstring

comments: none

keywords: string, substring, delete, case-independent, new

key sentence: deletes from a string the first occurrence of a given
substring and puts the result into a new string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/19/92

char *Astring = "This is the Sample String";
char Bstring[80];
char Cstring[80];
strsubdelinew(Bstring, Astring, "SAMPLE ");
printf("\n%s", Bstring);
printf("\n%s", strsubdelinew(Cstring, Bstring, "THE "));

This is the String
This is String


Hobbit House Software
*/









The Hobbit House String Library page 327



SUBDLW.C file date: 03/13/93 page 1 of 1 SUBDLW.C


/* strsubdelnew
Hobbit House Software

copyright(c) 1992, 1993

function: strsubdelnew (STRing, SUBstring DELete, to NEW string)

KWIC: %delete a %substring from a string

syntax: #include "hhstring.h"
char *strsubdelnew(char *newstring, char *instring,
char *substring)

description: the first occurrence of substring in instring is deleted,
with the result going to newstring

returns: a pointer to newstring

comments: none

keywords: string, substring, delete, new

key sentence: deletes from a string the first occurrence of a given
substring and puts the result into a new string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/19/92

char *Astring = "This is the Sample String";
char Bstring[80];
char Cstring[80];
strsubdelnew(Bstring, Astring, "Sample ");
printf("\n%s", Bstring);
printf("\n%s", strsubdelnew(Cstring, Bstring, "the "));

This is the String
This is String


Hobbit House Software
*/











page 328 The Hobbit House String Library



SUBRP.C file date: 03/13/93 page 1 of 1 SUBRP.C


/* strsubrpl
Hobbit House Software

copyright(c) 1992, 1993

function: strsubrpl (STRing, SUBstring RePLace)

KWIC: %replace one %substring with another

syntax: #include "hhstring.h"
char *strsubrpl(char *instring, char *fromstr,
char *tostr)

description: the first occurrence of fromstr in instring is replaced
with tostr.

returns: pointer to the character in the modified instring which
follows the inserted tostr. If fromstr doesn't occur in
instring, then the return is a NULL.

comments: if tostr is larger that fromstr, then instring must be
large enough to accommodate the extra characters, else
there be dragons

keywords: string, substring, replace

key sentence: replaces, in a string, the first occurrence of one
substring with another substring

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/15/92

char Astring[80] = "this that and the other that was";
strsubrpl(Astring, "that", "those");
printf("\n%s", Astring);
printf("\n%s", strsubrpl(Astring, "and the", "which"));
printf("\n%s", Astring);

this those and the other that was
other that was
this those which other that was


Hobbit House Software
*/







The Hobbit House String Library page 329



SUBRPA.C file date: 03/13/93 page 1 of 2 SUBRPA.C


/* strsubrplall
Hobbit House Software

copyright(c) 1992, 1993

function: strsubrplall (STRing, SUBstring RePLace ALL occurrences)

KWIC: %replace %all occurrences of one %substring with another

syntax: #include "hhstring.h"
int strsubrplall(char *instring, char *fromstr,
char *tostr)


description: all occurrences of fromstr in instring are replaced with
tostr

returns: The number of times fromstr was found and replaced. If
fromstr doesn't occur in instring, then the return is 0.

comments: if tostr is larger that fromstr, then instring must be
large enough to accommodate the extra characters, else
there be dragons

The implementation starts each replace operation where
the last one left off, both for efficiency and so that
if tostr and fromstr are the same, function will not
hang up in an endless loop. This also has an impact on
how the function deals with situations where the
insertion of the substring creates a new occurrence of
fromstr. To wit: the result of

char Astring[80] = "the one one";
strsubrplall(Astring, "the one", "one the");

is "one the one", not "one one the"

keywords: string, substring, replace, all

key sentence: replaces, in a string, all occurrences of a one substring
with another substring

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}










page 330 The Hobbit House String Library



SUBRPA.C file date: 03/13/93 page 2 of 2 SUBRPA.C




usage example: compiled/executed/verified on 12/20/92

char Astring[80] = "This one, that one, the other one";
int num;
num = strsubrplall(Astring, "one", "thing");
printf("\n%d: %s", num, Astring);
num = strsubrplall(Astring, "th", "/");
printf("\n%d: %s", num, Astring);

3: This thing, that thing, the other thing
6: This /ing, /at /ing, /e o/er /ing


Hobbit House Software
*/





































The Hobbit House String Library page 331



SUBRPAW.C file date: 03/13/93 page 1 of 2 SUBRPAW.C


/* strsubrplallnew
Hobbit House Software

copyright(c) 1992, 1993

function: strsubrplallnew (STRing, SUBstring RePLace ALL occurrences
to NEW string)

KWIC: %replace %all occurrences of one %substring with another

syntax: #include "hhstring.h"
int strsubrplallnew(char *newstring, char *instring,
char *fromstr, char *tostr)

description: all occurrences of fromstr in instring are replaced with
tostr with the result going to newstring, not instring.
If there are no occurrences, instring is just copied to
newstring.

returns: The number of times fromstr was found and replaced. If
fromstr doesn't occur in instring, then the return is 0.

comments: Because of the implementation technique used, newstring
must
be at least as large as instring, and if tostr is larger
than
fromstr, then newstring must be large enough to
accommodate
the additional characters as well.

keywords: string, substring, replace, all, new

key sentence: replaces, in a string, all occurrences of one substring
with another substring and puts the result into a new
string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/20/92

char Astring[80] = "This one, that one, the other one";
char Bstring[80];
int num;
num = strsubrplallnew(Bstring, Astring, "one", "thing");
printf("\n%d: %s", num, Bstring);
num = strsubrplallnew(Astring, Bstring, "th", "/");
printf("\n%d: %s", num, Astring);

3: This thing, that thing, the other thing
6: This /ing, /at /ing, /e o/er /ing



page 332 The Hobbit House String Library



SUBRPAW.C file date: 03/13/93 page 2 of 2 SUBRPAW.C


Hobbit House Software
*/




















































The Hobbit House String Library page 333



SUBRPI.C file date: 03/13/93 page 1 of 1 SUBRPI.C


/* strsubrpli
Hobbit House Software

copyright(c) 1992, 1993

function: strsubrpli (STRing, SUBstring, RePLace, case-Independant)

KWIC: %replace an occurrence, %independant of case, of one
%substring with another substring

syntax: #include "hhstring.h"
char *strsubrpli(char *instring, char *oldsub,
char *newsub)

description: the first case-independent occurrence of oldsub in
instring
is replaced by newsub

returns: pointer to the character in the modified instring which
follows the inserted newsub. If oldsub doesn't occur in
instring, then the return is a NULL.

comments: none

keywords: string, substring, replace, case-independent

key sentence: replaces, in a string, the first case-independent
occurrence of one substring with another substring

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/16/92

char Astring[80] = "this that and the other that was";
strsubrpli(Astring, "THAT", "those");
printf("\n%s", Astring);
printf("\n%s", strsubrpli(Astring, "AND the", "which"));
printf("\n%s", Astring);

this those and the other that was
other that was
this those which other that was


Hobbit House Software
*/







page 334 The Hobbit House String Library



SUBRPIA.C file date: 03/13/93 page 1 of 2 SUBRPIA.C


/* strsubrpliall
Hobbit House Software

copyright(c) 1992, 1993

function: strsubrpliall (STRing, SUBstring RePLace, case-
Independant, ALL occurrences)

KWIC: %replace %all occurrences, %independent of case, of one
%substring with another

syntax: #include "hhstring.h"
int strsubrpliall(char *instring, char *fromstr,
char *tostr)


description: all occurrences of fromstr in instring, independent of
case, are replaced with tostr

returns: The number of times fromstr was found and replaced. If
fromstr doesn't occur in instring, then the return is 0.

comments: if tostr is larger that fromstr, then instring must be
large enough to accommodate the extra characters, else
there be dragons

The implementation starts each replace operation where
the last one left off, both for efficiency and so that
if tostr and fromstr are the same, function will not
hang up in an endless loop. This also has an impact on
how the function deals with situations where the
insertion of the substring creates a new occurrence of
fromstr. To wit: the result of

char Astring[80] = "the one one";
strsubrplall(Astring, "the one", "one the");

is "one the one", not "one one the"

keywords: string, substring, replace, all, case-independent

key sentence: replaces, in a string, all case-independent occurrences of
a substring with another substring

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}








The Hobbit House String Library page 335



SUBRPIA.C file date: 03/13/93 page 2 of 2 SUBRPIA.C




usage example: compiled/executed/verified on 12/20/92

char Astring[80] = "This one, that one, the other one";
int num;
num = strsubrpliall(Astring, "ONE", "thing");
printf("\n%d: %s", num, Astring);
num = strsubrpliall(Astring, "th", "/");
printf("\n%d: %s", num, Astring);

3: This thing, that thing, the other thing
7: /is /ing, /at /ing, /e o/er /ing


Hobbit House Software
*/





































page 336 The Hobbit House String Library



SUBRPIAW.C file date: 03/13/93 page 1 of 2 SUBRPIAW.C


/* strsubrpliallnew
Hobbit House Software

copyright(c) 1992, 1993

function: strsubrpliallnew (STRing, SUBstring RePLace, case-
Independant, ALL occurrences to NEW)

KWIC: %replace %all occurrences, %independant of case, of one
%substring with another

syntax: #include "hhstring.h"
int strsubrpliallnew(char *newstring, char *instring,
char *fromstr, char *tostr)

description: all occurrences of fromstr in instring, independent of
case, are replaced with tostr with the result going to
newstring, not to instring. If there are no occurrences,
instring is just copied to newstring.

returns: The number of times fromstr was found and replaced. If
fromstr doesn't occur in instring, then the return is 0.

comments: Because of the implementation technique used, newstring
must
be at least as large as instring, and if tostr is larger
than
fromstr, then newstring must be large enough to
accommodate
the additional characters as well.

keywords: string, substring, replace, all, new, case-independent

key sentence: replaces, in a string, all case-independent occurrences of
one substring with another substring and puts the result
into a new string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}

usage example: compiled/executed/verified on 12/20/92

char Astring[80] = "This one, that one, the other one";
char Bstring[80];
int num;
num = strsubrpliallnew(Bstring, Astring, "one", "thing");
printf("\n%d: %s", num, Bstring);
num = strsubrpliallnew(Astring, Bstring, "th", "/");
printf("\n%d: %s", num, Astring);

3: This thing, that thing, the other thing
7: /is /ing, /at /ing, /e o/er /ing


The Hobbit House String Library page 337



SUBRPIAW.C file date: 03/13/93 page 2 of 2 SUBRPIAW.C



Hobbit House Software
*/



















































page 338 The Hobbit House String Library



SUBRPIW.C file date: 03/13/93 page 1 of 2 SUBRPIW.C


/* strsubrplinew
Hobbit House Software

copyright(c) 1992, 1993

function: strsubrplinew (STRing, SUBstring, RePLace, case-
Independant, to NEW string)

KWIC: %replace an occurrence, %indpendant of case, of one
%substring with another substring

syntax: #include "hhstring.h"
char *strsubrplinew (char *newstring, char *instring,
char *oldsub, char *newsub)

description: all case-independent occurrences of oldsub in instring
are replaced with newsub, with the result going to
newstring

returns: pointer to the character in the modified instring which
follows the inserted newsub. If oldsub doesn't occur in
instring, then the return is a NULL.

comments: Because of the implementation technique used, newstring
must
be at least as large as instring, and if tostr is larger
than
fromstr, then newstring must be large enough to
accommodate
the additional characters as well.

keywords: string, substring, replace, new, case-independent

key sentence: replaces, in a string, all case-independent occurrences of
a substring with another substring and puts the result
into a new string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}















The Hobbit House String Library page 339



SUBRPIW.C file date: 03/13/93 page 2 of 2 SUBRPIW.C




usage example: compiled/executed/verified on 12/20/92

char Astring[80] = "this that and the other that was";
char Bstring[80];
char Cstring[80];
strsubrplinew(Bstring, Astring, "THAT", "those");
printf("\n%s", Bstring);
printf("\n%s", strsubrplinew(Cstring, Bstring,
"AND the", "which"));
printf("\n%s", Cstring);

this those and the other that was
other that was
this those which other that was


Hobbit House Software
*/


































page 340 The Hobbit House String Library



SUBRPW.C file date: 03/13/93 page 1 of 2 SUBRPW.C


/* strsubrplnew
Hobbit House Software

copyright(c) 1992, 1993

function: strsubrplnew (STRing, SUBstring RePLace, to NEW)

KWIC: %replace one %substring with another

syntax: #include "hhstring.h"
char *strsubrplnew(char *newstring, char *instring,
char *fromstr, char *tostr)

description: the first occurrence of fromstr in instring is replaced
with tostr, with the result going to newstring. If fromstr
doesn't occur in instring, then newstring is just a copy
of instring.

returns: if the fromstr is found, then the return is a pointer
to the new string, otherwise instring is copied into
newstring, but the return is NULL.

comments: Because of the implementation technique used, newstring
must
be at least as large as instring, and if tostr is larger
than
fromstr, then newstring must be large enough to
accommodate
the additional characters as well.

keywords: string, substring, replace, new

key sentence: replaces, in a string, the first occurrence of one
substring with another substring and puts the results
into a new string

see also: strsubcount{i} strsubdel< {i} | {i}all >{new}
strsubrpl< {i} | {i}all >{new}
















The Hobbit House String Library page 341



SUBRPW.C file date: 03/13/93 page 2 of 2 SUBRPW.C




usage example: compiled/executed/verified on 12/20/92

char Astring[80] = "this that and the other that was";
char Bstring[80];
char Cstring[80];
strsubrplnew(Bstring, Astring, "that", "those");
printf("\n%s", Bstring);
printf("\n%s", strsubrplnew(Cstring, Bstring,
"and the", "which"));
printf("\n%s", strsubrplnew(Bstring, Astring,
"not there", "none"));

this those and the other that was
this those which other that was
(null)


Hobbit House Software
*/

































page 342 The Hobbit House String Library



TAB2BLK.C file date: 03/13/93 page 1 of 2 TAB2BLK.C


/* strtabtoblank
Hobbit House Software

copyright(c) 1992, 1993

function: strtabtoblank (STRing TAB TO BLANK expansion)

KWIC: %expand %TABs to %blanks

syntax: #include "hhstring.h"
char *strtabtoblank(char *inpline, int tabspace)

description: tabs are expanded to every "tabspace" characters. If
tabspace is zero or if the string is more than 256
characters long, then the string remains unmodified.

returns: a pointer to the string

comments: the required memory space must be available in inpline
else
memory contents beyond inpline will be destroyed.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, blank, tab, convert

key sentence: expands tabs to blanks using a specified tab space
(including
strings inside quotes, so be careful)

see also: strtabtoblank strblanktotab

usage example: compiled/executed/verified on 2/21/93

char Astring[80];

strcpy(Astring, "This is \tthe \tsample line");
strtabtoblank(Astring, 8);
printf("\n12345678123456781234567812345678");
printf("\n%s", Astring);

strcpy(Astring, "This is \tthe \tsample line");
strtabtoblank(Astring, 4);
printf("\n\n12341234123412341234123412341234");
printf("\n%s", Astring);







The Hobbit House String Library page 343



TAB2BLK.C file date: 03/13/93 page 2 of 2 TAB2BLK.C



12345678123456781234567812345678
This is the sample line";

12341234123412341234123412341234
This is the sample line";


Hobbit House Software
*/












































page 344 The Hobbit House String Library



TEXTFIR.C file date: 03/13/93 page 1 of 2 TEXTFIR.C


/* strtextfirst
Hobbit House Software

copyright(c) 1992, 1993

function: strtextfirst (STRing, get TEXT, FIRST)

KWIC: %get the %first %text word in a string

syntax: #include "hhstring.h"
char *strtextfirst(char *firsttext, char *instring)

description: the first text word in instring is copied into firsttext

returns: a pointer to firsttext or NULL if there isn't a text word

comments: a "text word" is a grammatical, or linguistic construct
as opposed to a "word" which is simply a conglomeration
of characters. Actually, the only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however may also
be terminated by any of these punctuation marks: .!?:;,

leading blanks and tabs will be skipped in the search for
the first text word.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, text, word, first

key sentence: copies the first text word in a string to another string

see also: strtext< first | get | last | next | prev | this >


















The Hobbit House String Library page 345



TEXTFIR.C file date: 03/13/93 page 2 of 2 TEXTFIR.C




usage example: compiled/executed/verified on 2/21/93

char *Astring = " not this; ";
char *Bstring = "ended. And then";
char Cstring[80];
strtextfirst(Cstring, Astring);
printf("\n%s", Cstring);
printf("\n%s", strtextfirst(Cstring, Bstring));
printf("\n%s", strtextfirst(Cstring, " \n\f\t "));

not
ended
(null)


Hobbit House Software
*/



































page 346 The Hobbit House String Library



TEXTGET.C file date: 03/13/93 page 1 of 2 TEXTGET.C


/* strtextget
Hobbit House Software

copyright(c) 1992, 1993

function: strtextget (STRing TEXT GET)

KWIC: %get the %text word starting at a given pointer

syntax: #include "hhstring.h"
char *strtextget(char *text, char *ptr)

description: the text word pointed to by ptr is transferred to text,
one character at a time, until a text terminator is found,
at which point text is terminated.

returns: a pointer to text

comments: a "text word" is a grammatical, or linguistic construct
as opposed to a "word" which is simply a conglomeration
of characters. Actually, the only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however may also
be terminated by any of these punctuation marks: .!?:;,


This is primarily a support function for use by the other
text functions listed below in "see also".

Unlike strtextthis, strtextget does NOT scan backwards
looking for the beginning of a text. It takes the pointer
that it is given as the beginning of the desired text.

if the input pointer points to a text terminator, then
text will be set to NULL

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, text, word

key sentence: copies the text word starting at a given pointer into a
specified string

see also: strtext< first | get | last | next | prev | this >







The Hobbit House String Library page 347



TEXTGET.C file date: 03/13/93 page 2 of 2 TEXTGET.C




usage example: compiled/executed/verified on 1/15/93

char *string = "this. And then";
char text[80];
strtextget(text, string);
printf("\n%s", text);
printf("\n%s", strtextget(text, string + 1));
printf("\n%s", strtextget(text, string + 5));

this
his
(null)


Hobbit House Software
*/




































page 348 The Hobbit House String Library



TEXTLAST.C file date: 03/13/93 page 1 of 2 TEXTLAST.C


/* strtextlast
Hobbit House Software

copyright(c) 1992, 1993

function: strtextlast (STRing, get TEXT, LAST)

KWIC: %get the %last %text word in a string

syntax: #include "hhstring.h"
char *strtextlast(char *lasttext, char *instring)

description: the last text word in instring is copied to lasttext.
Trailing text terminators are ignored.

returns: a pointer to lasttext or a NULL of none found

comments: a "text word" is a grammatical, or linguistic construct
as opposed to a "word" which is simply a conglomeration
of characters. Actually, the only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however may also
be terminated by any of these punctuation marks: .!?:;,

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

If the string is empty or white, lasttext will be empty
and the return will be NULL

keywords: string, text, word, last

key sentence: copies the last text word in a string to another string

see also: strtext< first | get | last | next | prev | this >

















The Hobbit House String Library page 349



TEXTLAST.C file date: 03/13/93 page 2 of 2 TEXTLAST.C




usage example: compiled/executed/verified on 2/21/93

char *Astring = "this is the sample string.\n";
char *Bstring = "and another one: ";
char Cstring[80];
strtextlast(Cstring, Astring);
printf("\n%s", Cstring);
printf("\n%s", strtextlast(Cstring, Bstring));
printf("\n%s", strtextlast(Cstring, "thisone!"));
printf("\n%s", strtextlast(Cstring, " \t.? "));
printf("\n%s", strtextlast(Cstring, ""));

string
one
thisone
(null)
(null)


Hobbit House Software
*/































page 350 The Hobbit House String Library



TEXTNEXT.C file date: 03/13/93 page 1 of 2 TEXTNEXT.C


/* strtextnext
Hobbit House Software

copyright(c) 1992, 1993

function: strtextnext (STRing, get TEXT word, NEXT)

KWIC: %get the %next %text word in a string

syntax: #include "hhstring.h"
char *strtextnext(char *nexttext, char *ptr)

description: scans from ptr for the next text word terminator (to
assure that the current text, if any, is bypassed) and
then searches for the next non-text-terminator as the
start of the next text. At that point, it begins copying
the characters into nexttext until a text terminator is
encountered, at which point, it terminates nexttext

If EOS is found before a text word is found, nexttext
will be empty and the return will be NULL

returns: a pointer to nexttext or NULL if none found

comments: a "text word" is a grammatical, or linguistic construct
as opposed to a "word" which is simply a conglomeration
of characters. Actually, the only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however may also
be terminated by any of these punctuation marks: .!?:;,

This function handles text words at the end of a line by
dealing with '\n' and '\0' termination characters. This
does mean that if one creates a string with embedded '\n'
characters, this function will terminate before the
string ends. The function is designed to work with lines,
as a text processor (including a human) thinks of lines,
not strings in the more general sense.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, text, word, next

key sentence: copies the next text in a string to another string

see also: strtext< first | get | last | next | prev | this >





The Hobbit House String Library page 351



TEXTNEXT.C file date: 03/13/93 page 2 of 2 TEXTNEXT.C




usage example: compiled/executed/verified on 2/21/93

char *line = "not this, he said!";
char Next[20];
strtextnext(Next, line);
printf("\n%s", Next);
printf("\n%s", strtextnext(Next, line + 12));
printf("\n%s", strtextnext(Next, line + 13));
printf("\n%s", strtextnext(Next, " \t "));
printf("\n%s", strtextnext(Next, "thisword"));
printf("\n%s", strtextnext(Next, ""));

this
said
(null)
(null)
(null)
(null)


Hobbit House Software
*/






























page 352 The Hobbit House String Library



TEXTPREV.C file date: 03/13/93 page 1 of 2 TEXTPREV.C


/* strtextprev
Hobbit House Software

copyright(c) 1992, 1993

function: strtextprev (STRing, get TEXT, PREVious)

KWIC: %get the %previous %text word from a given pointer

syntax: #include "hhstring.h"
char *strtextprev(char *prevtext, char *ptr)

description: scans backwards from ptr for whitespace, then scans
backward for non-whitespace and non-text-word-terminators,
then scans backward for whitespace again and returns the
text word following that whitespace. Think of it this way;
given a pointer to any point in a sentence, this function
returns the text word preceding the one pointed to. If
the pointer points at a word terminator or a text word
terminator, this function returns the text word which
precedes the whitespace or text word terminator.

returns: a pointer to prevtext

comments: a "text word" is a grammatical, or linguistic construct
as opposed to a "word" which is simply a conglomeration
of characters. Actually, the only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however may also
be terminated by any of these punctuation marks: .!?:;,


If the input pointer points to the first text word in a
string, prevtext will NOT be that text word but will be
that text word preceded by all of the characters which
precede it in memory up to and including the previous
text word. Be careful!

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, text, word, previous

key sentence: copies the text word found previous to a given pointer
into a specified string

see also: strtext< first | get | last | next | prev | this >





The Hobbit House String Library page 353



TEXTPREV.C file date: 03/13/93 page 2 of 2 TEXTPREV.C




usage example: compiled/executed/verified on 2/9/93

char *stringptr = " ended? And so on.";
char prevtext[80];
strtextprev(prevtext, stringptr+11);
printf("\n%s", prevtext);
printf("\n%s", strtextprev(prevtext, stringptr+8));
printf("\n%s", strtextprev(prevtext, " this, . " + 9));

ended
ended
this


Hobbit House Software
*/




































page 354 The Hobbit House String Library



TEXTTHIS.C file date: 03/13/93 page 1 of 2 TEXTTHIS.C


/* strtextthis
Hobbit House Software

copyright(c) 1992, 1993

function: strtextthis (STRing, get TEXT, THIS)

KWIC: %get %this %text word (regardless of what character in the
word is pointed to)

syntax: #include "hhstring.h"
char *strtextthis(char *thistext, char *inptr)

description: scans backward from inptr until whitespace is encountered
and then moves the text word following the whitespace into
thistext. If the input pointer points at a word terminator
or a text terminator, then thistext will be NULL.

returns: a pointer to thistext

comments: a "text word" is a grammatical, or linguistic construct
as opposed to a "word" which is simply a conglomeration
of characters. Actually, the only distinction made by
this function library is in the terminator. "Words" are
terminated by a blank, a tab, an ASCII End-Of-Line (EOL)
or an End-Of-String (EOS). "Text words", however may also
be terminated by any of these punctuation marks: .!?:;,


If the input pointer points to the first text word in a
string, thistext will NOT be that text word but will be
that text word preceded by all of the characters which
precede it in memory up to and including the previous
text word. Be careful!

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, text, word, this

key sentence: copies the text word pointed to, regardless of what
character in the word is pointed to, to another string

see also: strtext< first | get | last | next | prev | this >









The Hobbit House String Library page 355



TEXTTHIS.C file date: 03/13/93 page 2 of 2 TEXTTHIS.C




usage example: compiled/executed/verified on 2/21/93

char *string = "And.so.on. Then";
char thistext[80];
strtextthis(thistext, string+7);
printf("\n%s", thistext);
printf("\n%s", strtextthis(thistext, string+4));
printf("\n%s", strtextthis(thistext, string+3));

on
so
(null)


Hobbit House Software
*/




































page 356 The Hobbit House String Library



TOC.C file date: 03/13/93 page 1 of 1 TOC.C


/* strtoc
Hobbit House Software

copyright(c) 1992, 1993

function: strtoc (STRing TO C format)

KWIC: %convert a string to %C-sequence format

syntax: #include "hhstring.h"
char *strtoc(char *tostring, char *instring)


description: converts a string to a form which uses the C language
standard for representing certain special characters. A
complete list of these characters is given with the
function strchrtoc (which is the function that actually
does most of the work for this function). Normal
characters
are not changed

returns: a pointer to the destination string, which has been
filled with the converted string.

comments: note that characters requiring numerical conversion
are be put in the hex format in output string.

keywords: string, convert, C-sequence

key sentence: converts a string to C-sequence format

see also: str{chr}c

usage example: compiled/executed/verified on 12/13/92

char str[80] = "a\5\t\142";
char dst[80];
printf("%s", strtoc(dst, str));

a\x05\tb

Hobbit House Software
*/












The Hobbit House String Library page 357



TOLOWER.C file date: 03/13/93 page 1 of 1 TOLOWER.C


/* strtolower
Hobbit House Software

copyright(c) 1992, 1993

function: strtolower (STRing TO LOWER case)

KWIC: %convert all upper %case letters in a string to lower case

syntax: #include "hhstring.h"
char *strtolower(char *instring)

description: all of the upper case letters in the input string are
converted to lower case

returns: a pointer to the string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, convert, case

key sentence: converts all upper case letters in a string to lower case

see also: strtolower{new} strtoupper{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "STRing TO all LOWER case letters";
strtolower(Astring);
printf("%s", Astring);

string to all lower case letters


Hobbit House Software
*/
















page 358 The Hobbit House String Library



TOLOWERW.C file date: 03/13/93 page 1 of 1 TOLOWERW.C


/* strtolowernew
Hobbit House Software

copyright(c) 1992, 1993

function: strtolowernew (STRing TO LOWER case to NEW string)

KWIC: %convert all upper %case letters in a string to lower case

syntax: #include "hhstring.h"
char *strtolowernew(char *newstring, char *instring)

description: all of the upper case letters in the input string are
converted to lower case and put into the new string

returns: a pointer to the new string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, convert, case, new

key sentence: converts all upper case letters in a string to lower case
and puts the result into a new string

see also: strtolower{new} strtoupper{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "STRing TO all LOWER case letters";
char Bstring[80];
strtolowernew(Bstring, Astring);
printf("%s", Bstring);

string to all lower case letters


Hobbit House Software
*/










The Hobbit House String Library page 359



TOUPPER.C file date: 03/13/93 page 1 of 1 TOUPPER.C


/* strtoupper
Hobbit House Software

copyright(c) 1992, 1993

function: strtoupper (STRing TO UPPER case)

KWIC: %convert all lower %case letters in a string to upper case

syntax: #include "hhstring.h"
char *strtoupper(char *instring)

description: all of the lower case letters in the input string are
converted to upper case

returns: a pointer to the string

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, convert, case

key sentence: converts all lower case letters in a string to upper case

see also: strtolower{new} strtoupper{new}

usage example: compiled/executed/verified on 12/13/92

char *Astring = "STRing TO all UPPER case letters";
strtoupper(Astring);
printf("%s", Astring);

STRING TO ALL UPPER CASE LETTERS


Hobbit House Software
*/
















page 360 The Hobbit House String Library



TRIM.C file date: 03/13/93 page 1 of 1 TRIM.C


/* strtrim
Hobbit House Software

copyright(c) 1992, 1993

function: strtrim (STRing TRIM whitespace)

KWIC: %trim whitespace from both ends of a string

syntax: #include "hhstring.h"
char *strtrim(char *instring)

description: all of the contiguous whitespace (blanks and tabs) is
deleted from both sides of a string. Internal whitespace
is not disturbed.

returns: a pointer to the string

comments: if the string starts off containing nothing but whitespace
then it will end up as a null string

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, trim, whitespace, blank, tab

key sentence: trims whitespace (blanks and tabs) from both ends of a
string

see also: strtrim strlftrim strrttrim
strtrimnew strlftrimnew strrttrimnew

usage example: compiled/executed/verified on 12/13/92

char *Astring = " 3 leading and 3 trailing blanks ";
strtrim(Astring);
printf("-->%s<--", Astring);

-->3 leading and 3 trailing blanks<--


Hobbit House Software
*/










The Hobbit House String Library page 361



TRIMW.C file date: 03/13/93 page 1 of 2 TRIMW.C


/* strtrimnew
Hobbit House Software

copyright(c) 1992, 1993

function: strtrimnew (STRing TRIM whitespace to NEW string)

KWIC: %trim %whitespace from both ends of a string

syntax: #include "hhstring.h"
char *strtrimnew(char *newstring, char *instring)

description: creates a string which is identical to a specified string
except that all contiguous whitespace on each end of the
specified string is deleted from the new string

returns: a pointer to the new sting

comments: if the input string contains nothing but whitespace then
the new string will be a null string. Note that this
version requires that the new string have enough room to
take the input string with only the left side trimmed,
since the right side isn't trimmed until after the input
string is put into the new string.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

Setting newstring = instring will work OK with this
function but overlapping newstring/instring may or may
not work so if you must overlap, do it cautiously.

keywords: string, trim, whitespace, blank, tab, new

key sentence: trims whitespace (blanks and tabs) from both ends of a
string and puts the results into a new string

see also: strtrim strlftrim strrttrim
strtrimnew strlftrimnew strrttrimnew














page 362 The Hobbit House String Library



TRIMW.C file date: 03/13/93 page 2 of 2 TRIMW.C




usage example: compiled/executed/verified on 12/13/92

char *Astring = " 3 leading and 5 trailing blanks ";
char Bstring[80];
strtrimnew(Bstring, Astring);
printf("-->%s<--", Bstring);

-->3 leading and 5 trailing blanks<--


Hobbit House Software
*/








































The Hobbit House String Library page 363



WORDFIR.C file date: 03/13/93 page 1 of 1 WORDFIR.C


/* strwordfirst
Hobbit House Software

copyright(c) 1992, 1993

function: strwordfirst (STRing, get WORD, FIRST)

KWIC: %get the %first %word in a string

syntax: #include "hhstring.h"
char *strwordfirst(char *firstword, char *instring)

description: the first word in instring is copied into firstword

returns: a pointer to firstword

comments: leading blanks and tabs will be skipped in the search for
the first word.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, word, first

key sentence: copies the first word in a string to another string

see also: strword< first | get | last | next | prev | this >

usage example: compiled/executed/verified on 2/21/93

char *Astring = " This is the sample string";
char *Bstring = "That was it";
char Cstring[80];
strwordfirst(Cstring, Astring);
printf("\n%s", Cstring);
printf("\n%s", strwordfirst(Cstring, Bstring));
printf("\n%s", strwordfirst(Cstring, " \t\n\f "));

This
That
(null)


Hobbit House Software
*/








page 364 The Hobbit House String Library



WORDGET.C file date: 03/13/93 page 1 of 2 WORDGET.C


/* strwordget
Hobbit House Software

copyright(c) 1992, 1993

function: strwordget (STRing WORD GET)

KWIC: %get the %word starting at a given pointer

syntax: #include "hhstring.h"
char *strwordget(char *word, char *ptr)

description: the word pointed to by ptr is transferred to word, one
character at a time, until a word terminator is found,
at which point word is terminated.

returns: a pointer to word

comments: This is primarily a support function for use by the other
functions listed below in "see also".

Unlike strwordthis, strwordget does NOT scan backwards
looking for the beginning of a word. It takes the pointer
that it is given as the beginning of the desired word.

if the input pointer points to a word terminator, then
word will be set to NULL

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, word

key sentence: copies the word starting at a given pointer into a
specified string

see also: strword< first | get | last | next | prev | this >
















The Hobbit House String Library page 365



WORDGET.C file date: 03/13/93 page 2 of 2 WORDGET.C




usage example: compiled/executed/verified on 1/15/93

char *string = "this that and the other";
char word[80];
strwordget(word, string);
printf("\n%s", word);
printf("\n%s", strwordget(word, string + 6));
printf("\n%s", strwordget(word, string + 4));

this
hat
(null)


Hobbit House Software
*/




































page 366 The Hobbit House String Library



WORDLAST.C file date: 03/13/93 page 1 of 1 WORDLAST.C


/* strwordlast
Hobbit House Software

copyright(c) 1992, 1993

function: strwordlast (STRing, get WORD, LAST)

KWIC: %get the %last %word in a string

syntax: #include "hhstring.h"
char *strwordlast(char *lastword, char *instring)

description: the last word in instring is copied to lastword. Trailing
word terminators are ignored.

returns: a pointer to lastword or NULL if none found

comments: The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

If the string is empty or white, lastword will be empty
and the return will be NULL

keywords: string, word, last

key sentence: copies the last word in a string to another string

see also: strword< first | get | last | next | prev | this >

usage example: compiled/executed/verified on 2/21/93

char *Astring = "this is the sample string.\n";
char *Bstring = "another one";
char Dstring[80];
strwordlast(Dstring, Astring);
printf("\n%s", Dstring);
printf("\n%s", strwordlast(Dstring, Bstring));
printf("\n%s", strwordlast(Dstring, " \t\n "));
printf("\n%s", strwordlast(Dstring, ""));

string.
one
(null)
(null)


Hobbit House Software
*/





The Hobbit House String Library page 367



WORDNEXT.C file date: 03/13/93 page 1 of 2 WORDNEXT.C


/* strwordnext
Hobbit House Software

copyright(c) 1992, 1993

function: strwordnext (STRing, get WORD, NEXT)

KWIC: %get the %next %word in a string

syntax: #include "hhstring.h"
char *strwordnext(char *nextword, char *ptr)

description: scans from ptr for the next word terminator (to assure
that the current word, if any, is bypassed) and then
searches for the next non-word-terminator as the start of
the next word. At that point, it begins copying the
characters into nextword until a word terminator is
encountered, at which point, it terminates nextword

If EOS is found before a word is found, nextword will
be empty and the return will be NULL

returns: a pointer to nextword or NULL if none found

comments: This function handles words at the end of a line by
dealing with '\n' and '\0' termination characters. This
does mean that if one creates a string with embedded '\n'
characters, this function will terminate before the
string ends. The function is designed to work with lines,
as a word processor (including a human) thinks of lines,
not strings in the more general sense.

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, word, next

key sentence: copies the next word in a string to another string

see also: strword< first | get | last | next | prev | this >













page 368 The Hobbit House String Library



WORDNEXT.C file date: 03/13/93 page 2 of 2 WORDNEXT.C




usage example: compiled/executed/verified on 2/21/93

char *line = "This is\tthe line";
char Next[20];
strwordnext(Next, line);
printf("\n%s", Next);
printf("\n%s", strwordnext(Next, line + 4));
printf("\n%s", strwordnext(Next, line + 13));
printf("\n%s", strwordnext(Next, " \t "));
printf("\n%s", strwordnext(Next, ""));

is
is
(null)
(null)
(null)


Hobbit House Software
*/
































The Hobbit House String Library page 369



WORDPREV.C file date: 03/13/93 page 1 of 2 WORDPREV.C


/* strwordprev
Hobbit House Software

copyright(c) 1992, 1993

function: strwordprev (STRing, get WORD, PREVious)

KWIC: %get the %previous %word from a given pointer

syntax: #include "hhstring.h"
char *strwordprev(char *prevword, char *ptr)

description: scans backwards from ptr for whitespace, then scans
backward for non-whitespace, then scans backward for
whitespace again and returns the word following that
whitespace. Think of it this way; given a pointer to any
point in a sentence, this function returns the word
preceding the one pointed to. If the pointer points at
whitespace, this function returns the word which precedes
the whitespace.

returns: a pointer to prevword

comments: If the input pointer points to the first word in a string,
prevword will NOT be that word but will be that word
preceded by all of the characters which precede it in
memory up to and including the previous word. Be careful!

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, word, previous

key sentence: copies the word previous to a given pointer into a
specified string

see also: strword< first | get | last | next | prev | this >
















page 370 The Hobbit House String Library



WORDPREV.C file date: 03/13/93 page 2 of 2 WORDPREV.C




usage example: compiled/executed/verified on 12/14/92

char *stringptr = "time date size other";
char prevword[80];
strwordprev(prevword, stringptr+11);
printf("\n%s", prevword);
printf("\n%s", strwordprev(prevword, stringptr+20));

date
other


Hobbit House Software
*/






































The Hobbit House String Library page 371



WORDTHIS.C file date: 03/13/93 page 1 of 2 WORDTHIS.C


/* strwordthis
Hobbit House Software

copyright(c) 1992, 1993

function: strwordthis (STRing, get WORD, THIS)

KWIC: %get %this %word (regardless of what character in the word
is pointed to)

syntax: #include "hhstring.h"
char *strwordthis(char *thisword, char *inptr)

description: scans backward from inptr until whitespace is encountered
and then moves the word following the whitespace into
thisword. If the input pointer points at whitespace or a
word terminator, then thisword will be empty and the
return will be NULL

returns: a pointer to thisword or NULL if inptr points to a word
terminator

comments: If the input pointer points to the first word in a string,
thisword will NOT be that word but will be that word
preceded by all of the characters which precede it in
memory up to and including the previous word. Be careful!

The string pointed to by the return value of this function
is in the calling function's space. The return value is
provided as a convenience, not a necessity.

keywords: string, word, this

key sentence: copies the word pointed to, regardless of what character
in the word is pointed to, to another string

see also: strword< first | get | last | next | prev | this >

















page 372 The Hobbit House String Library



WORDTHIS.C file date: 03/13/93 page 2 of 2 WORDTHIS.C




usage example: compiled/executed/verified on 2/21/93

char *string = "time date size other";
char thisword[80];
strwordthis(thisword, string+13);
printf("\n%s", thisword);
printf("\n%s", strwordthis(thisword, string+5));
printf("\n%s", strwordthis(thisword, string+4));

size
date
(null)


Hobbit House Software
*/




































The Hobbit House String Library page 373



XCAT.C file date: 03/13/93 page 1 of 1 XCAT.C


/* strxcat
Hobbit House Software

copyright(c) 1992, 1993

function: strxcat (STRing eXtended conCATenate function)

KWIC: %concatenate %multiple strings

syntax: #include
#include
#include "hhstring.h"
char *strxcat(char *instring, ... )

note: ... is a variable list of string pointers which,
for this function, must be terminated by a
pointer to a NULL string

description: concatenates a variable number of strings onto the
input string

returns: a pointer to the input string

comments: The input string must have enough memory allocated to
handle all of the concatenation, else there be dragons.

keywords: string, concatenate

key sentence: concatenates multiple strings

see also: strxcat{n}

usage example: compiled/executed/verified on 12/13/92

char str1[80] = "....";
strxcat(str1, " this,", " that,",
" and the other", NULL);
printf("\n%s", str1);

.... this, that, and the other


Hobbit House Software
*/










page 374 The Hobbit House String Library



XCATN.C file date: 03/13/93 page 1 of 2 XCATN.C


/* strxcatn
Hobbit House Software

copyright(c) 1992, 1993

function: strxcatn (STRing eXtended conCATenate, N-char limit)

KWIC: %concatenate %multiple strings but limit the %size of the
result to n characters

syntax: #include
#include
#include "hhstring.h"
char *strxcatn(char *instring, int len, ... )

note: ... is a variable list of string pointers which,
for this function, must be terminated with a pointer to
a NULL string. The constant NULL is recommended; see the
code example below.

description: concatenates a variable number of strings onto the
input string, up to n characters. If the n chars are
reached, then a terminating '\0' is placed on the string
at the nth position.

returns: a pointer to the input string

comments: The input string must have enough memory allocated to
handle all of the concatenation, else there be dragons.

keywords: string, concatenate, size

key sentence: concatenates multiple strings but limits the result to a
fixed size

see also: strxcat{n}


















The Hobbit House String Library page 375



XCATN.C file date: 03/13/93 page 2 of 2 XCATN.C




usage example: compiled/executed/verified on 2/25/93

char str1[80] = "";
char stra[10] = "this, ";
char strb[10] = "that, ";
char strc[20] = "and the other";
strxcatn(str1, 20, stra, strb, strc, NULL);
printf("\n%s<--", str1);

this, that, and the <-- (note 20-char size limit)


Hobbit House Software
*/






































page 376 The Hobbit House String Library



ZERO.C file date: 03/13/93 page 1 of 1 ZERO.C


/* strzero
Hobbit House Software

copyright(c) 1992, 1993

function: strzero (STRing, set to all ZEROs)

KWIC: set a string to all ASCII %zeros

syntax: #include "hhstring.h"
char *strzero(char *instring)

description: takes a string which has a terminating '\0' and fills it
with ASCII zero characters (i.e. '0')

returns: a pointer to the string

comments: this is a macro which is defined in hhstring.h as:

#define strzero(s) strset(s, '0')

keywords: string, character, set

key sentence: sets a string to all ASCII zeros

see also: str< blank | eos | set | zero >

usage example: compiled/executed/verified on 1/19/93

char *instring = "this string";
strzero(instring);
printf("%s%d", instring, strlen(instring));

0000000000011


Hobbit House Software
*/
















The Hobbit House String Library page 377



 December 7, 2017  Add comments

Leave a Reply