Skip to content

Commit

Permalink
* src/lens.c: Do not require that keys and labels not match '/'
Browse files Browse the repository at this point in the history
The '/' is only important in translating a string containing a path
expression to the internal data structure we use to match it against a
tree. It has no special meaning in the lens language

See hercules-team#668 for more detail
  • Loading branch information
lutter committed Jun 12, 2020
1 parent 1511eee commit 3cb0f4e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 38 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Add Dockerfile (Nicolas Gif) (Issue #650)
* augtool: Improved readline integration to handle quoting issues
(Pino Toscano)
* typechecker: Allow including '/' in keys and labels. Thanks to
felixdoerre for pointing out that this restriction was
unnecessary. See issue #668 for the discussion.
- Lens changes/additions
* Authinfo2: new lens to parse Authinfo2 format (Nicolas Gif) (Issue #649)
* Cmdline: New lens to parse /proc/cmdline (Thomas Weißschuh)
Expand Down
27 changes: 1 addition & 26 deletions src/lens.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,32 +571,7 @@ typecheck_prim(enum lens_tag tag, struct info *info,
struct value *exn = NULL;

/* Typecheck */
if (tag == L_KEY) {
exn = str_to_fa(info, "(.|\n)*/(.|\n)*", &fa_slash, regexp->nocase);
if (exn != NULL)
goto error;

exn = regexp_to_fa(regexp, &fa_key);
if (exn != NULL)
goto error;

fa_isect = fa_intersect(fa_slash, fa_key);
if (! fa_is_basic(fa_isect, FA_EMPTY)) {
exn = make_exn_value(info,
"The key regexp /%s/ matches a '/' which is used to separate nodes.", regexp->pattern->str);
goto error;
}
fa_free(fa_isect);
fa_free(fa_key);
fa_free(fa_slash);
fa_isect = fa_key = fa_slash = NULL;
} else if (tag == L_LABEL) {
if (strchr(string->str, SEP) != NULL) {
exn = make_exn_value(info,
"The label string \"%s\" contains a '/'", string->str);
goto error;
}
} else if (tag == L_DEL && string != NULL) {
if (tag == L_DEL && string != NULL) {
int cnt;
const char *dflt = string->str;
cnt = regexp_match(regexp, dflt, strlen(dflt), 0, NULL);
Expand Down
6 changes: 0 additions & 6 deletions tests/modules/fail_key_slash.aug

This file was deleted.

6 changes: 0 additions & 6 deletions tests/modules/fail_label_slash.aug

This file was deleted.

0 comments on commit 3cb0f4e

Please sign in to comment.