diff options
Diffstat (limited to 'src/lib/libc/string/strcspn.3')
| -rw-r--r-- | src/lib/libc/string/strcspn.3 | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/src/lib/libc/string/strcspn.3 b/src/lib/libc/string/strcspn.3 index cc9e5c2fe3..21c727344d 100644 --- a/src/lib/libc/string/strcspn.3 +++ b/src/lib/libc/string/strcspn.3 | |||
| @@ -13,11 +13,7 @@ | |||
| 13 | .\" 2. Redistributions in binary form must reproduce the above copyright | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| 14 | .\" notice, this list of conditions and the following disclaimer in the | 14 | .\" notice, this list of conditions and the following disclaimer in the |
| 15 | .\" documentation and/or other materials provided with the distribution. | 15 | .\" documentation and/or other materials provided with the distribution. |
| 16 | .\" 3. All advertising materials mentioning features or use of this software | 16 | .\" 3. Neither the name of the University nor the names of its contributors |
| 17 | .\" must display the following acknowledgement: | ||
| 18 | .\" This product includes software developed by the University of | ||
| 19 | .\" California, Berkeley and its contributors. | ||
| 20 | .\" 4. Neither the name of the University nor the names of its contributors | ||
| 21 | .\" may be used to endorse or promote products derived from this software | 17 | .\" may be used to endorse or promote products derived from this software |
| 22 | .\" without specific prior written permission. | 18 | .\" without specific prior written permission. |
| 23 | .\" | 19 | .\" |
| @@ -33,10 +29,9 @@ | |||
| 33 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 34 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
| 35 | .\" | 31 | .\" |
| 36 | .\" from: @(#)strcspn.3 5.3 (Berkeley) 6/29/91 | 32 | .\" $OpenBSD: strcspn.3,v 1.9 2007/08/08 07:20:45 ray Exp $ |
| 37 | .\" $Id: strcspn.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ | ||
| 38 | .\" | 33 | .\" |
| 39 | .Dd June 29, 1991 | 34 | .Dd $Mdocdate: August 8 2007 $ |
| 40 | .Dt STRCSPN 3 | 35 | .Dt STRCSPN 3 |
| 41 | .Os | 36 | .Os |
| 42 | .Sh NAME | 37 | .Sh NAME |
| @@ -49,27 +44,48 @@ | |||
| 49 | .Sh DESCRIPTION | 44 | .Sh DESCRIPTION |
| 50 | The | 45 | The |
| 51 | .Fn strcspn | 46 | .Fn strcspn |
| 52 | function | 47 | function spans the initial part of the NUL-terminated string |
| 53 | spans the initial part of the null-terminated string | ||
| 54 | .Fa s | 48 | .Fa s |
| 55 | as long as the characters from | 49 | as long as the characters from |
| 56 | .Fa s | 50 | .Fa s |
| 57 | do not occur in string | 51 | do not occur in string |
| 58 | .Fa charset | 52 | .Fa charset |
| 59 | (it | 53 | (it spans the |
| 60 | spans the | ||
| 61 | .Em complement | 54 | .Em complement |
| 62 | of | 55 | of |
| 63 | .Fa charset ) . | 56 | .Fa charset ) . |
| 64 | .Sh RETURN VALUES | 57 | .Sh RETURN VALUES |
| 65 | The | 58 | The |
| 66 | .Fn strcspn | 59 | .Fn strcspn |
| 67 | function | 60 | function returns the number of characters spanned. |
| 68 | returns the number of characters spanned. | 61 | .Sh EXAMPLES |
| 62 | The following call to | ||
| 63 | .Fn strcspn | ||
| 64 | will return 3, since the first three characters of string | ||
| 65 | .Fa s | ||
| 66 | do not occur in string | ||
| 67 | .Fa charset : | ||
| 68 | .Bd -literal -offset indent | ||
| 69 | char *s = "foobar"; | ||
| 70 | char *charset = "bar"; | ||
| 71 | size_t span; | ||
| 72 | |||
| 73 | span = strcspn(s, charset); | ||
| 74 | .Ed | ||
| 75 | .Pp | ||
| 76 | The following removes the first (if any) newline character from string | ||
| 77 | .Fa line . | ||
| 78 | This is useful for trimming the newline after a | ||
| 79 | .Xr fgets 3 | ||
| 80 | call. | ||
| 81 | .Bd -literal -offset indent | ||
| 82 | char line[BUFSIZ]; | ||
| 83 | |||
| 84 | if (fgets(line, sizeof(line), fp) != NULL) | ||
| 85 | line[strcspn(line, "\en")] = '\e0'; | ||
| 86 | .Ed | ||
| 69 | .Sh SEE ALSO | 87 | .Sh SEE ALSO |
| 70 | .Xr index 3 , | ||
| 71 | .Xr memchr 3 , | 88 | .Xr memchr 3 , |
| 72 | .Xr rindex 3 , | ||
| 73 | .Xr strchr 3 , | 89 | .Xr strchr 3 , |
| 74 | .Xr strpbrk 3 , | 90 | .Xr strpbrk 3 , |
| 75 | .Xr strrchr 3 , | 91 | .Xr strrchr 3 , |
| @@ -80,6 +96,5 @@ returns the number of characters spanned. | |||
| 80 | .Sh STANDARDS | 96 | .Sh STANDARDS |
| 81 | The | 97 | The |
| 82 | .Fn strcspn | 98 | .Fn strcspn |
| 83 | function | 99 | function conforms to |
| 84 | conforms to | ||
| 85 | .St -ansiC . | 100 | .St -ansiC . |
