[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Complex Sliding-Window Problem - Compare "stripped" duplicates of patter
From: |
Eric Marceau |
Subject: |
Complex Sliding-Window Problem - Compare "stripped" duplicates of pattern and file window |
Date: |
Sat, 4 Feb 2023 21:31:46 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
Hello everyone,
This is my first "serious attempt" at mastering and applying sed, after
limiting my usage to truly simplistic cases during 25 years of
unix/linux involvement (now retired).
I hope you will hear me out as I take on this journey.
I managed to modify a sed script (*blockrep.sed*)...
... intended to replace all instances of a *multi-line text segment* (a
C program function) and replace it by a replacement text (a "vastly"
modified C program function) ...
... and made that work.
All details and final results (/working version/) are documented here [
https://stackoverflow.com/questions/75305074/trying-to-get-generic-sed-multi-line-pattern-match-and-substitution-script-to-wo/75331049?noredirect=1#comment132942453_75331049
].
As noted in one of my comments ...
... As long as all source code files are standardized, and elements were
copy+pasted, the above solution would cover everything.
Now, I would like to generalize that beyond matching of cookie-cutter
templates and add logic to
- strip leading whitespaces,
- strip trailing whitespaces, and
- map multiple-whitespaces to a single-space
for both
... the *specified match pattern*,
... and the edited file "*evaluation buffer*",
to allow for random format of manually entered copies, to ensure no
cases are overlooked.
Thinking about how to achieve that revamping of the embedded ...
blockrep.sed ... script, I visualized creating a duplicate of the input
buffer, which would match the sliding-window, and apply all massaging to
that second copy and use that for comparison with a similarly duplicated
and massaged copy of the text segment that is trying to be located (in
the file that is being edited).
Then, upon locating and triggering that match condition, the
non-massaged text in the file being edited would be replaced by the text
segment specified in ... ${fileReplPat} ... which was mapped in the
transformation specification file ... findrep.txt .
Not truly understanding if it is possible to have 4 (or 5) buffers open
at the same time, with 2 pairs of "synchronized" buffers (excuse my
misuse of that description because only one of each pair is "stripped"),
I was thinking that those could associated each with its own "marker"
(or numbered register) ...
... and do the line-by line
copy+swap/strip/compare/adjust/swap-back/adjust/reposition/repeat cycle ...
Is such a thing possible?
I would really like guidance at a high-level (abstract) so I have a
concrete feel for the "components" and their relationships before trying
to tackle the actual coding.
Does that make sense ?
Is that even possible ?
Your suggestions and ideas would be really appreciated.
Thank you, everyone.
Eric Marceau
https://stackoverflow.com/users/9716110/eric-marceau?tab=profile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Complex Sliding-Window Problem - Compare "stripped" duplicates of pattern and file window,
Eric Marceau <=