From owner-svn-src-head@FreeBSD.ORG Fri Dec 5 15:50:59 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2B71106564A; Fri, 5 Dec 2008 15:50:59 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B14AC8FC1E; Fri, 5 Dec 2008 15:50:59 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mB5FoxPa062500; Fri, 5 Dec 2008 15:50:59 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mB5FoxGg062499; Fri, 5 Dec 2008 15:50:59 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <200812051550.mB5FoxGg062499@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Fri, 5 Dec 2008 15:50:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185641 - head/lib/libc/string X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2008 15:50:59 -0000 Author: pjd Date: Fri Dec 5 15:50:59 2008 New Revision: 185641 URL: http://svn.freebsd.org/changeset/base/185641 Log: Add an easier example. Reviewed by: trasz Modified: head/lib/libc/string/strsep.3 Modified: head/lib/libc/string/strsep.3 ============================================================================== --- head/lib/libc/string/strsep.3 Fri Dec 5 15:31:51 2008 (r185640) +++ head/lib/libc/string/strsep.3 Fri Dec 5 15:50:59 2008 (r185641) @@ -31,7 +31,7 @@ .\" @(#)strsep.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd June 9, 1993 +.Dd December 5, 2008 .Dt STRSEP 3 .Os .Sh NAME @@ -81,6 +81,21 @@ returns .Sh EXAMPLES The following uses .Fn strsep +to parse a string, and prints each token in separate line: +.Bd -literal -offset indent +char *token, *string, *tofree; + +tofree = string = strdup("abc,def,ghi"); +assert(string != NULL); + +while ((token = strsep(&string, ",")) != NULL) + printf("%s\en", token); + +free(tofree); +.Ed +.Pp +The following uses +.Fn strsep to parse a string, containing tokens delimited by white space, into an argument vector: .Bd -literal -offset indent