STRING C-3

NAME

strbcmp, strbcpy, strzcpy - perform string operations

SYNOPSIS

strbcmp (s1, s2, n)

char *s1;

char *s2;

int n;

strbcpy (s1, s2, n)

char *s1;

char *s2;

int n;

strzcpy (s1, s2, n)

char *s1;

char *s2;

int n;

DESCRIPTION

Strbcmp compares two strings either of which can be either nullterminated or blank padded. Strbcmp returns an integer greater than, equal to or less than 0 according to whether s1 is lexicographically greater than, equal to or less than s2. Strbcmp compares at most n bytes. If either string is null-terminated, that string is treated as if it were blank padded for the purposes of comparison. This function is roughly equivalent to strncmp but is designed to also handle blank padded strings that do not have null byte terminators.

Strbcpy copies n bytes from s2 to s1. If the source string s2 is less than n bytes, the destination string s1 is blank filled. In no case is a null terminator added to the destination string. This function is roughly equivalent to strncpy, but it pads strings with blanks rather than nulls.

Strzcpy copies a blank padded or null terminated string converting it to a string that is null terminated. It copies at most n bytes from s2 to s1 and converts any trailing blanks to nulls. A null terminator is always added to the destination string. This function is roughly equivalent to strncpy, but it strips trailing blanks from the source string and always guarantees that there is a null terminator on the destination string. It is intended for converting blank padded strings to null terminated strings.

NOTES

Strbcpy and strzcpy do not check for overflow of the receiving string. Strbcpy needs n bytes, and strzcpy needs at most n+1 bytes.

Strbcmp uses native character comparison that is signed on PDP 11's and may be either signed or unsigned on other machines.