From owner-freebsd-hackers@FreeBSD.ORG Sun May 1 14:45:22 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BD72106564A for ; Sun, 1 May 2011 14:45:22 +0000 (UTC) (envelope-from moeller.akt@googlemail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id B561A8FC08 for ; Sun, 1 May 2011 14:45:21 +0000 (UTC) Received: by bwz12 with SMTP id 12so5867058bwz.13 for ; Sun, 01 May 2011 07:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:user-agent:date:subject:from:to:cc:message-id :thread-topic:thread-index:in-reply-to:mime-version:content-type :content-transfer-encoding; bh=2Ekuba4gVifDCJBi07BiMc4b3qmRdCZwdcIdn4TVKcw=; b=vKUyL0KCM5ZjVJpvNNJOpvi8KLoEXl60vz8ihZX15+q6ZuIzBELlVIBbO5PecjqAma 2RB5Q14fFBGixWHyosMPeYL6TC5MmVT9RM40KM6eg95Zeys78r34hzH/oaclBGGgU6XM lze7/ZAdsM5CtPnQ8GYR4BXGI0k9qemMXrQLQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=user-agent:date:subject:from:to:cc:message-id:thread-topic :thread-index:in-reply-to:mime-version:content-type :content-transfer-encoding; b=YdfPs8zqF2F591o1R6FsBrpZN4PvK0lJVZWo+qFVDojezvvnLyA8zeMDgijfebvInn M8XFQr8lcH8uhdaYuiIrr6Cen37F4dY0CiN/SpFdEMEZO4kKg8K6wnSUMFC+XOkzb9y2 3y1dJdjmnZcokwqA3Eisert/6ZeGi3hJ2/1hw= Received: by 10.204.139.199 with SMTP id f7mr5833158bku.23.1304261120349; Sun, 01 May 2011 07:45:20 -0700 (PDT) Received: from [192.168.0.108] (p5B24E7F5.dip.t-dialin.net [91.36.231.245]) by mx.google.com with ESMTPS id d11sm2724739bka.7.2011.05.01.07.45.18 (version=SSLv3 cipher=OTHER); Sun, 01 May 2011 07:45:19 -0700 (PDT) User-Agent: Microsoft-Entourage/12.0.0.071130 Date: Sun, 01 May 2011 16:45:14 +0200 From: Martin =?ISO-8859-1?B?TfZsbGVy?= To: Daniel O'Connor Message-ID: Thread-Topic: [LIBC] Modfied Version of sscanf Thread-Index: AcwIDmEvE7dfJmzaSRq3U7kWysP1SQ== In-Reply-To: <6ACFC545-73B5-49FA-A97F-BC500F9AFE40@gsoft.com.au> Mime-version: 1.0 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: [LIBC] Modfied Version of sscanf X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 May 2011 14:45:22 -0000 Am 01.05.11 00:53 schrieb "Daniel O'Connor" unter : Thanks for your reply. Ok, another example. I try to parse a request, coming from a client in the form: GET HTTP/1.1. It is expected that can contain space characters (even if its not the case in reality). How would you do that with sscanf ? With regards, Martin >=20 > On 01/05/2011, at 2:14, Martin M=F6ller wrote: >> outputs total garbage on my FreeBSD-7.0-RELEASE #0 amd64. >> Is there already a way to do this or should we release a new version of >> sscanf, e.g. called sscanfWS. >>=20 >> This modified version would output: Test 2->Test 3. >=20 > I think it does what it should.. %s is supposed to stop at whitespace. >=20 > You probably really want.. >=20 > #include > #include > #include >=20 > int > main(int argc, char **argv) { > char name [20], value [20]; > int i; >=20 > i =3D sscanf("Test 2->Test 3", "%[^-]->%[^-]", name, value); > printf("%d %s->%s\n", i, name, value); >=20 > exit(0); > } >=20 > -- > Daniel O'Connor software and network engineer > for Genesis Software - http://www.gsoft.com.au > "The nice thing about standards is that there > are so many of them to choose from." > -- Andrew Tanenbaum > GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C >=20 >=20 >=20 >=20 >=20 >=20