diff --git a/pica-path/src/lib.rs b/pica-path/src/lib.rs index a0175478d..1ab9a8cb2 100644 --- a/pica-path/src/lib.rs +++ b/pica-path/src/lib.rs @@ -174,8 +174,8 @@ fn parse_path_simple(i: &[u8]) -> ParseResult { )(i) } -fn parse_path_depricated(i: &[u8]) -> ParseResult { - map( +fn parse_path_deprecated(i: &[u8]) -> ParseResult { + let (i, path) = map( delimited( multispace0, tuple(( @@ -204,7 +204,13 @@ fn parse_path_depricated(i: &[u8]) -> ParseResult { subfield_matcher: m, codes: c, }, - )(i) + )(i)?; + + if path.subfield_matcher.is_some() { + eprintln!("WARNING: Specifying subfield matcher in the first position of an path expression is deprecated. Please use the set-builder notation instead."); + } + + Ok((i, path)) } fn parse_path_curly(i: &[u8]) -> ParseResult { @@ -253,7 +259,7 @@ fn parse_path_curly(i: &[u8]) -> ParseResult { } pub fn parse_path(i: &[u8]) -> ParseResult { - alt((parse_path_simple, parse_path_curly, parse_path_depricated))(i) + alt((parse_path_simple, parse_path_curly, parse_path_deprecated))(i) } pub trait PathExt> { diff --git a/pica-toolkit/tests/snapshot/frequency/023-frequency-subfield-matcher.toml b/pica-toolkit/tests/snapshot/frequency/023-frequency-subfield-matcher.toml index 29768ca15..739fb1ba5 100644 --- a/pica-toolkit/tests/snapshot/frequency/023-frequency-subfield-matcher.toml +++ b/pica-toolkit/tests/snapshot/frequency/023-frequency-subfield-matcher.toml @@ -2,4 +2,4 @@ bin.name = "pica" args = "frequency -s \"065R{4 =^ 'ort', 9}\" dump.dat.gz" status = "success" stdout = "041178548,2\n040660095,1\n040787044,1\n" -stderr = "" +stderr = "WARNING: Specifying subfield matcher in the first position of an path expression is deprecated. Please use the set-builder notation instead.\n" diff --git a/pica-toolkit/tests/snapshot/frequency/024-frequency-subfield-matcher-ci.toml b/pica-toolkit/tests/snapshot/frequency/024-frequency-subfield-matcher-ci.toml index 41095b1c0..64958904b 100644 --- a/pica-toolkit/tests/snapshot/frequency/024-frequency-subfield-matcher-ci.toml +++ b/pica-toolkit/tests/snapshot/frequency/024-frequency-subfield-matcher-ci.toml @@ -2,4 +2,4 @@ bin.name = "pica" args = "frequency -s -i \"065R{4 =^ 'ORT', 9}\" dump.dat.gz" status = "success" stdout = "041178548,2\n040660095,1\n040787044,1\n" -stderr = "" +stderr = "WARNING: Specifying subfield matcher in the first position of an path expression is deprecated. Please use the set-builder notation instead.\n" diff --git a/pica-toolkit/tests/snapshot/frequency/586-frequency-translit-path1.toml b/pica-toolkit/tests/snapshot/frequency/586-frequency-translit-path1.toml index 8ed6f1935..eb72bfde5 100644 --- a/pica-toolkit/tests/snapshot/frequency/586-frequency-translit-path1.toml +++ b/pica-toolkit/tests/snapshot/frequency/586-frequency-translit-path1.toml @@ -2,4 +2,4 @@ bin.name = "pica" args = "-c Pica.toml frequency \"029@{a =^ 'Städtische', a}\"" status = "success" stdout = "Sta\u0308dtische Pressestelle,1\n" -stderr = "" +stderr = "WARNING: Specifying subfield matcher in the first position of an path expression is deprecated. Please use the set-builder notation instead.\n" diff --git a/pica-toolkit/tests/snapshot/frequency/586-frequency-translit-path2.toml b/pica-toolkit/tests/snapshot/frequency/586-frequency-translit-path2.toml index d384ea164..04bb4dedb 100644 --- a/pica-toolkit/tests/snapshot/frequency/586-frequency-translit-path2.toml +++ b/pica-toolkit/tests/snapshot/frequency/586-frequency-translit-path2.toml @@ -2,4 +2,4 @@ bin.name = "pica" args = "frequency \"029@{a =^ 'Städtische', a}\"" status = "success" stdout = "" -stderr = "" +stderr = "WARNING: Specifying subfield matcher in the first position of an path expression is deprecated. Please use the set-builder notation instead.\n" diff --git a/pica-toolkit/tests/snapshot/select/586-select-translit-selector1.toml b/pica-toolkit/tests/snapshot/select/586-select-translit-selector1.toml index 2f661f2b7..58217690e 100644 --- a/pica-toolkit/tests/snapshot/select/586-select-translit-selector1.toml +++ b/pica-toolkit/tests/snapshot/select/586-select-translit-selector1.toml @@ -2,4 +2,4 @@ bin.name = "pica" args = "-c Pica.toml select -s \"003@.0, 029@{a =^ 'Städtische', a}\"" status = "success" stdout = "040181189,Sta\u0308dtische Pressestelle\n" -stderr = "" +stderr = "WARNING: Specifying subfield matcher in the first position of an path expression is deprecated. Please use the set-builder notation instead.\n" diff --git a/pica-toolkit/tests/snapshot/select/586-select-translit-selector2.toml b/pica-toolkit/tests/snapshot/select/586-select-translit-selector2.toml index 3f6bc6861..8597d4bbd 100644 --- a/pica-toolkit/tests/snapshot/select/586-select-translit-selector2.toml +++ b/pica-toolkit/tests/snapshot/select/586-select-translit-selector2.toml @@ -2,4 +2,5 @@ bin.name = "pica" args = "select -s \"003@.0, 029@{a =^ 'Städtische', a}\"" status = "success" stdout = "040181189,\n" -stderr = "" +stderr = "WARNING: Specifying subfield matcher in the first position of an path expression is deprecated. Please use the set-builder notation instead.\n" + diff --git a/pica-toolkit/tests/snapshot/select/605-false-positives-regex.toml b/pica-toolkit/tests/snapshot/select/605-false-positives-regex.toml index 24a4fbea2..e0a095caf 100644 --- a/pica-toolkit/tests/snapshot/select/605-false-positives-regex.toml +++ b/pica-toolkit/tests/snapshot/select/605-false-positives-regex.toml @@ -3,4 +3,4 @@ args = "select -s \"044K{!9? && a !~ '^:[zf]', a}\"" status = "success" stdin = "044K \u001fbckw\u001fa:z Geschichte 2005-2017\u001fEa\u001fHstwgnd\u001fK1\u001fD2022-07-15\u001e\n" stdout = "" -stderr = "" +stderr = "WARNING: Specifying subfield matcher in the first position of an path expression is deprecated. Please use the set-builder notation instead.\n"