Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ strrchr(3C) — DG/UX 5.4R3.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

gcc(1)

reentrant(3)

ffs(3C)

malloc(3C)

setlocale(3C)

str(3G)

strxfrm(3C)



string(3C)                     DG/UX 5.4R3.00                     string(3C)


NAME
       string: strcat, strdup, strncat, strcmp, strncmp, strcpy, strncpy,
       strlen, strchr, strrchr, strpbrk, strspn, strcspn, strtok, strtokr,
       strstr - string operations

SYNOPSIS
       #include <string.h>

       char *strcat (char *s1, const char *s2);

       char *strdup (const char *s1);

       char *strncat (char *s1, const char *s2, sizet n);

       int strcmp (const char *s1, const char *s2);

       int strncmp (const char *s1, const char *s2, sizet n);

       char *strcpy (char *s1, const char *s2);

       char *strncpy (char *s1, const char *s2, sizet n);

       sizet strlen (const char *s);

       char *strchr (const char *s, int c);

       char *strrchr (const char *s, int c);

       char *strpbrk (const char *s1, const char *s2);

       sizet strspn (const char *s1, const char *s2);

       sizet strcspn (const char *s1, const char *s2);

       char *strtok (char *s1, const char *s2);

       char *strtokr (char *s1, const char *s2, **lasts);

       char *strstr (const char *s1, const char *s2);

DESCRIPTION
       The arguments s, s1, and s2 point to strings (arrays of characters
       terminated by a null character).  The functions strcat, strncat,
       strcpy, strncpy, strtok, and strtokr all alter s1.  These functions
       do not check for overflow of the array pointed to by s1.

       strcat appends a copy of string s2, including the terminating null
       character, to the end of string s1.  strncat appends at most n
       characters.  Each returns a pointer to the null-terminated result.
       The initial character of s2 overrides the null character at the end
       of s1.

       strcmp compares its arguments and returns an integer less than, equal
       to, or greater than 0, based upon whether s1 is lexicographically



Licensed material--property of copyright holder(s)                         1




string(3C)                     DG/UX 5.4R3.00                     string(3C)


       less than, equal to, or greater than s2.  strncmp makes the same
       comparison but looks at at most n characters.  Characters following a
       null character are not compared.

       strcpy copies string s2 to s1 including the terminating null
       character, stopping after the null character has been copied.
       strncpy copies exactly n characters, truncating s2 or adding null
       characters to s1 if necessary.  The result will not be null-
       terminated if the length of s2 is n or more.  Each function returns
       s1.

       strdup returns a pointer to a new string which is a duplicate of the
       string pointed to by s1.  The space for the new string is obtained
       using malloc(3C).  If the new string can not be created, a NULL
       pointer is returned.

       strlen returns the number of characters in s, not including the
       terminating null character.

       strchr (or strrchr) returns a pointer to the first (last) occurrence
       of c (converted to a char) in string s, or a NULL pointer if c does
       not occur in the string.  The null character terminating a string is
       considered to be part of the string.

       strpbrk returns a pointer to the first occurrence in string s1 of any
       character from string s2, or a NULL pointer if no character from s2
       exists in s1.

       strspn (or strcspn) returns the length of the initial segment of
       string s1 which consists entirely of characters from (not from)
       string s2.

       strtok considers the string s1 to consist of a sequence of zero or
       more text tokens separated by spans of one or more characters from
       the separator string s2.  The first call (with pointer s1 specified)
       returns a pointer to the first character of the first token, and will
       have written a null character into s1 immediately following the
       returned token. The function keeps track of its position in the
       string between separate calls, so that subsequent calls (which must
       be made with the first argument a NULL pointer) will work through the
       string s1 immediately following that token.  In this way subsequent
       calls will work through the string s1 until no tokens remain.  The
       separator string s2 may be different from call to call.  When no
       token remains in s1, a NULL pointer is returned.

       strtokr works like strtok with the added ability of keeping track of
       the current string position between calls in the argument, lasts.  If
       the value of lasts is NULL and the value of s1 is not NULL, strtokr
       starts scanning at the initial character of the string.

       strstr locates the first occurrence in string s1 of the sequence of
       characters (excluding the terminating null character) in string s2.
       strstr returns a pointer to the located string, or a null pointer if
       the string is not found. If s2 points to a string with zero length



Licensed material--property of copyright holder(s)                         2




string(3C)                     DG/UX 5.4R3.00                     string(3C)


       (i.e., the string ""), the function returns s1.


   Considerations for Threads Programming
                     +---------+-----------------------------+
                     |         |                      async- |
                     |function | reentrant   cancel   cancel |
                     |         |              point    safe  |
                     +---------+-----------------------------+
                     |strcat   |     Y          N        N   |
                     |strchr   |     Y          N        N   |
                     |strcmp   |     Y          N        N   |
                     |strcpy   |     Y          N        N   |
                     |strcspn  |     Y          N        N   |
                     |strdup   |     Y          N        N   |
                     |strlen   |     Y          N        N   |
                     |strncat  |     Y          N        N   |
                     |strncmp  |     Y          N        N   |
                     |strncpy  |     Y          N        N   |
                     |strpbrk  |     Y          N        N   |
                     |strrchr  |     Y          N        N   |
                     |strspn   |     Y          N        N   |
                     |strstr   |     Y          N        N   |
                     |strtok   |     N          -        -   |
                     |strtokr |     Y          N        N   |
                     +---------+-----------------------------+
       The above functions should be called when the other threads in a
       process are not changing locale information.  See the setlocale(3C)
       man page for more information.


SEE ALSO
       cc(1), gcc(1), reentrant(3), ffs(3C), malloc(3C), setlocale(3C),
       str(3G), strxfrm(3C).

NOTES
       The function strtokr is available only in the shared library,
       libc.so.

       All of these functions assume the default locale ``C.''  For some
       locales, strxfrm should be applied to the strings before they are
       passed to the functions.

       When STDC is not defined during compilation (see the cc(1) and/or
       gcc(1)man pages), the return types of strlen, strspn and strcspn are
       int, not sizet as stated above.  This is done to comply with the
       traditional/transitional compilation mode.










Licensed material--property of copyright holder(s)                         3


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026