Add Regular Expressions Support
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest9 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | hashtable: preparations to use hexport_r() for "env grep"common/ include/ lib/ | +38 | 0 replies | |
| 2/9 | "env grep" - reimplement command using hexport_r()common/ include/ lib/ | +40 | 0 replies | |
| 3/9 | "env grep" - add options to grep in name, value, or both.common/ | +33 | 0 replies | |
| 4/9 | Add SLRE - Super Light Regular Expression libraryREADME include/ lib/ +1 more | +832 | 0 replies | |
| 5/9 | "env grep" - add support for regular expression matchescommon/ include/ lib/ | +52 | 0 replies | |
| 6/9 | setexpr: simplify code, improve help messagecommon/ | +11 | 0 replies | |
| 7/9 | setexpr: add regex substring matching and substitutioncommon/ | +277 | 1 reply | |
| 7/9 | setexpr: add regex substring matching and substitution | +0 | 0 replies | |
| 8/9 | m28evk: enable "env grep" and regexp supportinclude/ | +3 | 0 replies | |
| 9/9 | amcc-common.h: enable support for "env grep", "setexpr", and regex.include/ | +6 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [U-Boot] [PATCH 0/9] Add Regular Expressions Support
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 cuased it to dump always _all_ environment varioables on some systems), and adds the capability to grep in either the variable name, or the value, or in both (the old version olways did the latter). Instead of special functions we now use common code (i. e. hexport_r()) for the variable lookup, 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 barcode 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.
Wolfgang Denk (9):
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: enable "env grep" and regexp support 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 | 3 + include/search.h | 15 +- include/slre.h | 100 ++++++ lib/Makefile | 1 + lib/hashtable.c | 93 ++++-- lib/slre.c | 724 ++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 1263 insertions(+), 72 deletions(-) create mode 100644 include/slre.h create mode 100644 lib/slre.c
Signature · 1 line
1.8.1.4