_ABBRV - check for valid abbreviation.

(Not in the ANSI standard)

Usage:

#include <sdgstd.h>
score = _abbrv( pattern, string );

Where:

char *pattern;
points to a string that contains a word that may be abbreviated. Letters that appear in upper case in the pattern MUST be present in an abbreviation for the abbreviation to be valid. Letters that appear in lower case may be omitted in a valid abbreviation. Non-alphabetic characters except '_' in the pattern must always be present in an abbreviation for the abbreviation to be valid.
char *string;
points to a string that may or may not be a valid abbreviation of the given pattern. When checking the validity of the abbreviation, "_abbrv" ignores whether the letters of "string" are in upper or lower case.
int score;
indicates whether or not the abbreviation is valid. Invalid abbreviations are given a score of -1; valid ones are given a positive number that indicates how close the abbreviation is to the actual word (see below for details). The higher the score, the better the match.

Description:

"_abbrv" is used to determine if "string" is a valid abbreviation of "pattern". A valid abbreviation is a string containing all the necessary (upper case) characters in the correct order; other (lower case) characters in the "pattern" may appear in the abbreviation, but characters which are not in the "pattern" may not appear.

The score function (for a valid abbreviation) gives one point for each lower case character matched. The score function gives 1024 points for each upper case or non-alphabetic character matched. For the pattern "eXtract" (note the upper and lower cases) the following results would be obtained.

string     score
"x"         1024
"ex"        1025
"extr"      1027
"extrat"    1029
"xtrt"      1027
"extract"   1030
"e"         -1
"tract"     -1
"xtray"     -1

Copyright © 1996, Thinkage Ltd.