From: Tom Rini <trini@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 0/11] Add Regular Expressions Support
Date: Thu, 2 May 2013 12:06:47 -0400 [thread overview]
Message-ID: <20130502160647.GA22334@bill-the-cat> (raw)
In-Reply-To: <1364118638-17088-1-git-send-email-wd@denx.de>
On Sun, Mar 24, 2013 at 10:50:27AM +0100, Wolfgang Denk wrote:
> The following patch series adds the SLRE "Super Light Regular
> Expression" library and uses this to add regex support for
> the "env grep" (aka "grepenv") command, and new functions (or
> operators?) "gsub" and "sub" to the "setexpr" command.
>
> The rework to "env grep" also fixed a few bugs (which caused it to
> dump always _all_ environment variables on some systems), and adds
> the capability to grep in either the variable name, or the value, or
> in both (the old version always did the latter). Instead of special
> functions we now use common code (i. e. hexport_r()) for the variable
> look-up, which gives us sorted output as a free additional benefit.
>
> This allows to do things like
>
> - print all MAC addresses:
>
> => env grep -e eth.*addr
> eth1addr=00:10:ec:80:c5:15
> ethaddr=00:10:ec:00:c5:15
>
> - print all variables that have at least 2 colons in their value:
>
> => env grep -v -e :.*:
> addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
> eth1addr=00:10:ec:80:c5:15
> ethaddr=00:10:ec:00:c5:15
> ver=U-Boot 2013.04-rc1-00289-g497746b-dirty (Mar 22 2013 - 12:50:25)
>
> - Generate broadcast address by substituting the last two numbers of
> the IP address by "255.255":
>
> => print ipaddr
> ipaddr=192.168.1.104
> => setexpr broadcast sub "(.*\\.).*\\..*" "\\1255.255" $ipaddr
> broadcast=192.168.255.255
>
> - Depending on keyboard configuration (German vs. US keyboard) a
> bar code scanner may initialize the MAC address as C0:E5:4E:02:06:DC
> or as C0>E5>4E>02>06>DC. Make sure we always have a correct value:
>
> => print ethaddr
> ethaddr=C0>E5>4E>02>06>DC
> => setexpr ethaddr gsub > :
> ethaddr=C0:E5:4E:02:06:DC
>
> etc.
>
> Regex support can be enabled by defining CONFIG_REGEX in the board
> config file.
>
> Notes:
>
> - This patch series has been compile-tested (and found to be clean
> with ELDK v5.3) on all of the following boards:
>
> ARM: m28evk
>
> PPC4xx: acadia bamboo bluestone bubinga canyonlands dlvision-10g
> dlvision ebony gdppc440etx icon intip io io64 iocon katmai kilauea
> luan makalu neo ocotea redwood sequoia t3corp taihu taishan walnut
> yosemite yucca
>
> - Runtime / functional testing has been done mostly on PPC (Sequoia
> board).
>
>
> Changes in v2:
> - fixed trailing whitespace errors
> - Note 1: The "line over 80 characters" warning will NOT be fixed due
> to the "never break user-visible strings" rule.
> - Note 2: The "Alignment should match open parenthesis" check will NOT
> be fixed due to the "indent by TABs only" rule.
> - Fix ERROR: "foo * bar" should be "foo *bar" errors
> - Fix trailing whitespace error
> - Note: the "Alignment should match open parenthesis" check will not
> be fixed due to the "indent always byy TABs" rule.
> - no changes; most of this is imported code and is intentionally left
> as is
> - the "Alignment should match open parenthesis" check is left due to
> the "indent only by TABs" rule
> - the "line over 80 characters" warning is left due to the "never
> break user-visible strings" rule
> - Fix trailing whitespace error
> - fix "No space is necessary after a cast" checks
> - fix "space prohibited before semicolon" and "space required after
> that ';'" errors (but I onsider the result less readable :-( )
> - Note: the remaining warnings ("line over 80 characters") and checks
> ("Alignment should match open parenthesis") are intentionally left
> as is.
> - Do the white space cleanup globally, and as separate patch
>
> Wolfgang Denk (11):
> hashtable: preparations to use hexport_r() for "env grep"
> "env grep" - reimplement command using hexport_r()
> "env grep" - add options to grep in name, value, or both.
> Add SLRE - Super Light Regular Expression library
> "env grep" - add support for regular expression matches
> setexpr: simplify code, improve help message
> setexpr: add regex substring matching and substitution
> m28evk: white space cleanup
> m28evk: enable "env grep" and regexp support
> amcc-common.h: minor white space cleanup
> amcc-common.h: enable support for "env grep", "setexpr", and regex.
>
> README | 7 +
> common/cmd_nvedit.c | 87 +++--
> common/cmd_setexpr.c | 296 ++++++++++++++++-
> include/configs/amcc-common.h | 9 +-
> include/configs/m28evk.h | 259 +++++++--------
> include/search.h | 15 +-
> include/slre.h | 100 ++++++
> lib/Makefile | 1 +
> lib/hashtable.c | 93 ++++--
> lib/slre.c | 724 ++++++++++++++++++++++++++++++++++++++++++
> 10 files changed, 1391 insertions(+), 200 deletions(-)
> create mode 100644 include/slre.h
> create mode 100644 lib/slre.c
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130502/a7aa76a2/attachment.pgp>
prev parent reply other threads:[~2013-05-02 16:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-24 9:50 [U-Boot] [PATCH v2 0/11] Add Regular Expressions Support Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 01/11] hashtable: preparations to use hexport_r() for "env grep" Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 02/11] "env grep" - reimplement command using hexport_r() Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 03/11] "env grep" - add options to grep in name, value, or both Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 04/11] Add SLRE - Super Light Regular Expression library Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 05/11] "env grep" - add support for regular expression matches Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 06/11] setexpr: simplify code, improve help message Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 07/11] setexpr: add regex substring matching and substitution Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 08/11] m28evk: white space cleanup Wolfgang Denk
2013-03-24 12:08 ` Marek Vasut
2013-03-24 9:50 ` [U-Boot] [PATCH v2 09/11] m28evk: enable "env grep" and regexp support Wolfgang Denk
2013-03-24 9:50 ` [U-Boot] [PATCH v2 10/11] amcc-common.h: minor white space cleanup Wolfgang Denk
2013-04-02 7:34 ` Stefan Roese
2013-03-24 9:50 ` [U-Boot] [PATCH v2 11/11] amcc-common.h: enable support for "env grep", "setexpr", and regex Wolfgang Denk
2013-04-02 7:34 ` Stefan Roese
2013-05-02 16:06 ` Tom Rini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130502160647.GA22334@bill-the-cat \
--to=trini@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox