From patchwork Wed Jun 29 10:13:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Goregaokar X-Patchwork-Id: 13467 Received: (qmail 13823 invoked by alias); 29 Jun 2016 10:14:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 13804 invoked by uid 89); 29 Jun 2016 10:14:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=U*manish, D*mozilla.com, sk:manish@, manish@mozilla.com X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 29 Jun 2016 10:14:04 +0000 Received: by mail-wm0-f49.google.com with SMTP id v199so173910117wmv.0 for ; Wed, 29 Jun 2016 03:14:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YO9VUDe9xPgbzHSR3hk6RxBpLhISU8ykQxwWdTZF5i4=; b=SA+hA5ONr6OzBfPdin7gIzeYqPDnctj1RQc60klQ7RMiUBzjKUvUMRb4flogzfj77z gq+B8RIG0DED98oFxjFnqqpqD93dL3HrNPjpaKctlsGXD1x/uBi32aZtrrs0f7QErlq4 dVm2zS65OJkUWP5X+i4M96LrbkJ3XZ0z0f6kcpERPGTVj0zY4HZYOtqSm+L4c7URGAbM tm5dWj0EwVGJMgB648yPjpOavDNgDwnXsJcBuR3RhHBmGaXOLAucYM+XMHAAh5RT/VuU e+D3pC7NlG6AQTqUsqUDpaLkVL2bP2g3SgfmET7E2bRNUmi9G/UzCGgJPQSi38Hxozhw lMmA== X-Gm-Message-State: ALyK8tLjKqYz3CeW1avfCTdKu8S6T8WQ1D52vUbdW0YMjjXvrK5byz1XUwva+rSRFWEZbB5N2jIrUuaokw6+jGeh X-Received: by 10.194.82.161 with SMTP id j1mr8371646wjy.65.1467195241709; Wed, 29 Jun 2016 03:14:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.36.215 with HTTP; Wed, 29 Jun 2016 03:13:58 -0700 (PDT) From: Manish Goregaokar Date: Wed, 29 Jun 2016 15:43:58 +0530 Message-ID: Subject: [PATCH] Use strtok_r instead of strsep in rust_get_disr_info To: gdb-patches@sourceware.org, Tom Tromey X-IsSubscribed: yes strsep doesn't exist on windows 2016-06-29 Manish Goregaokar gdb/ChangeLog: * rust-lang.c (rust_get_disr_info): Use strtok_r instead of strsep --- gdb/rust-lang.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) LONGEST value; @@ -138,6 +138,8 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, cleanup = make_cleanup (xfree, name); tail = name + strlen (RUST_ENUM_PREFIX); + token = strtok_r (tail, "$", &last); + /* The location of the value that doubles as a discriminant is stored in the name of the field, as RUST$ENCODED$ENUM$$$...$ @@ -145,7 +147,7 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, traversed in order to find the field (which may be several fields deep) and the variantname is the name of the variant of the case when the field is zero. */ - while ((token = strsep (&tail, "$")) != NULL) + do { if (sscanf (token, "%lu", &fieldno) != 1) { @@ -159,10 +161,8 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, embedded_offset += TYPE_FIELD_BITPOS (member_type, fieldno) / 8; member_type = TYPE_FIELD_TYPE (member_type, fieldno); - } + } while ((token = strtok_r (NULL, "$", &last)) != NULL); - if (token >= name + strlen (TYPE_FIELD_NAME (type, 0))) - error (_("Invalid form for %s"), RUST_ENUM_PREFIX); value = unpack_long (member_type, valaddr + embedded_offset); if (value == 0) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 23ddd5a..961fdca 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -121,7 +121,7 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, if (strncmp (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX, strlen (RUST_ENUM_PREFIX)) == 0) { - char *name, *tail, *token; + char *tail, *token, *name, *last = NULL; unsigned long fieldno; struct type *member_type;