don't truncate lines, don't allow tabs to back up (I think this is tested!)
[unix-history] / usr / src / lib / libc / string / strsep.3
CommitLineData
3da2bc7c
KB
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\"
7.\" %sccs.include.redist.man%
8.\"
9.\" @(#)strsep.3 5.1 (Berkeley) %G%
10.\"
11.TH STRSEP 3 ""
12.UC 7
13.SH NAME
14strsep \- separate strings
15.SH SYNOPSIS
16.nf
17.ft B
18#include <string.h>
19
20char *
21strsep(char **stringp, char *delim);
22.ft R
23.fi
24.SH DESCRIPTION
25.B Strsep
26locates in the null-terminated string at
27.I *stringp
28the first occurence of any character in
29.I delim
30and replaces this with a '\e0',
31records the location of the immediate following character in
32.IR *stringp ,
33then returns the original value of
34.IR *stringp .
35If no delimiter characters are found,
36.B strsep
37sets
38.I *stringp
39to NULL;
40if
41.I *stringp
42is initially NULL,
43.B strsep
44returns NULL.
45.SH EXAMPLES
46The following uses
47.I strsep
48to parse strings containing runs of white space,
49making up an argument vector:
50.sp
51.nf
52.RS
53char inputstring[100];
54char **argv[51], **ap = argv, *p, *val;
55.I "/* set up inputstring */"
56for (p = inputstring; p != NULL; ) {
57 while ((val = strsep(&p, " \et")) != NULL && *val == '\e0');
58 *ap++ = val;
59}
60*ap = 0;
61.RE