From patchwork Wed Apr 16 18:51:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 579 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id AC01B36007A for ; Wed, 16 Apr 2014 11:51:50 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 6C49C40FCC650; Wed, 16 Apr 2014 11:51:50 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id ED3A7411515A0 for ; Wed, 16 Apr 2014 11:51:48 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :content-type; q=dns; s=default; b=Wty/87UcOa8p5FoOx5vsHfvWO9lCF R+9HgVk4zUG9tlFrFoRrsR7ZBs3tcSZSvjGLd9T/vawdC2s80M4q/f3cDSkg4QRp /2xQrbj4VrdoKwLUwkS0Iq6+tPcRjFIPnBtQdF+zbUVS/Oiy76qW8hNS0hxuxm6A /UFLkd20fAXxC8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :content-type; s=default; bh=U9PE2J6PArn2IxhDsXpw9wnuEb8=; b=AYM KEl/ieku01eOEV4nKtoH864UuS8g2G2hE1MqN7zMwjwrtM8wJ2A1zLyGcGYql6O2 R+HKWLvm2Og2DEl5+havJqiaXnYu9ZKUMqcwcufv8qIV5djt9AKMrS9V7JZfWoGk h/P69GnOzv8Q8AuaAfU/AM5Bnyi6Tgwjg5EF24+M= Received: (qmail 32161 invoked by alias); 16 Apr 2014 18:51:47 -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 32149 invoked by uid 89); 16 Apr 2014 18:51:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Apr 2014 18:51:46 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3GIpiTw006300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 16 Apr 2014 14:51:45 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3GIpiTv027498 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Wed, 16 Apr 2014 14:51:44 -0400 Message-ID: <534ED140.3010103@redhat.com> Date: Wed, 16 Apr 2014 11:51:44 -0700 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: "gdb-patches@sourceware.org ml" Subject: [RFA testsuite 2/5] Introduce build_kv_pairs X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hi, This patch is a simple utility function to build lists of key/value pairs. It is used by subsequent patches. Keith testsuite/ChangeLog 2014-04-15 Keith Seitz * lib/mi-support.exp (mi_build_kv_pairs): New procedure. diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 7c234c0..abbcd8d 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -2354,3 +2354,25 @@ proc mi_walk_varobj_tree {language tree \ mi_varobj_tree_test_children_callback}} { ::varobj_tree::walk_tree $language $tree $callback } + +# Build a list of key-value pairs given by the list ATTR_LIST. Flatten +# this list using the optional JOINER, a comma by default. +# +# The list must contain an even number of elements, which are the key-value +# pairs. Each value will be surrounded by quotes, according to the grammar, +# except if the value starts with \[ or \{, when the quotes will be omitted. +# +# Example: mi_build_kv_pairs {a b c d e f g \[.*\]} +# returns a=\"b\",c=\"d\",e=\"f\",g=\[.*\] +proc mi_build_kv_pairs {attr_list {joiner ,}} { + set l {} + foreach {var value} $attr_list { + if {[string range $value 0 1] == "\\\[" + || [string range $value 0 1] == "\\\{"} { + lappend l "$var=$value" + } else { + lappend l "$var=\"$value\"" + } + } + return "[join $l $joiner]" +}