From f594540f2d6667eaf8a653e92003e584e354fbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Fri, 10 Jan 2025 15:23:56 +0100 Subject: [PATCH] Describe the algorithm that `Specfile.update_value()` uses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nikola Forró --- posts/specfile-advanced/index.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/posts/specfile-advanced/index.md b/posts/specfile-advanced/index.md index 44b5f1a51..61e5f2f1f 100644 --- a/posts/specfile-advanced/index.md +++ b/posts/specfile-advanced/index.md @@ -245,6 +245,21 @@ within a spec file in the same manner, trying to preserve macro substitutions an macro definitions (or even tag values in case of e.g. `%{version}`) if possible. It is up to you to replace the original string with the result (that can but doesn't have to be exactly the same). +::: info + +The algorithm first tokenizes the string to be updated. Then it determines which macro substitutions +within the string can be affected by modifying bodies of preceding macro definitions or values +of preceding tags. Then it identifies substrings that are deemed modifiable (that could be for example +a sequence of numbers between two dots) and constructs a regular expression in which the modifiable +macro substitutions and the modifiable substrings are capturing groups. +If the requested new string is a not match to this regular expression, nothing happens and the requested +new string is returned unchanged. If it is a match though, the captured groups corresponding to modifiable +macro substitutions are then processed, recursively, starting with tokenization once again. +The requested new string is then updated with corresponding macro substitutions from the original string +and returned. + +::: + ## More info and links Are you interested in more details, trying the library out or even contributing?