|
|
1.1 root 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: .\" Redistribution and use in source and binary forms are permitted
8: .\" provided that: (1) source distributions retain this entire copyright
9: .\" notice and comment, and (2) distributions including binaries display
10: .\" the following acknowledgement: ``This product includes software
11: .\" developed by the University of California, Berkeley and its contributors''
12: .\" in the documentation or other materials provided with the distribution
13: .\" and in all advertising materials mentioning features or use of this
14: .\" software. Neither the name of the University nor the names of its
15: .\" contributors may be used to endorse or promote products derived
16: .\" from this software without specific prior written permission.
17: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18: .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20: .\"
21: .\" @(#)strsep.3 5.1 (Berkeley) 5/15/90
22: .\"
23: .TH STRSEP 3 "May 15, 1990"
24: .UC 7
25: .SH NAME
26: strsep \- separate strings
27: .SH SYNOPSIS
28: .nf
29: .ft B
30: #include <string.h>
31:
32: char *
33: strsep(char **stringp, char *delim);
34: .ft R
35: .fi
36: .SH DESCRIPTION
37: .B Strsep
38: locates in the null-terminated string at
39: .I *stringp
40: the first occurence of any character in
41: .I delim
42: and replaces this with a '\e0',
43: records the location of the immediate following character in
44: .IR *stringp ,
45: then returns the original value of
46: .IR *stringp .
47: If no delimiter characters are found,
48: .B strsep
49: sets
50: .I *stringp
51: to NULL;
52: if
53: .I *stringp
54: is initially NULL,
55: .B strsep
56: returns NULL.
57: .SH EXAMPLES
58: The following uses
59: .I strsep
60: to parse strings containing runs of white space,
61: making up an argument vector:
62: .sp
63: .nf
64: .RS
65: char inputstring[100];
66: char **argv[51], **ap = argv, *p, *val;
67: .I "/* set up inputstring */"
68: for (p = inputstring; p != NULL; ) {
69: while ((val = strsep(&p, " \et")) != NULL && *val == '\e0');
70: *ap++ = val;
71: }
72: *ap = 0;
73: .RE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.