Complex Sliding-Window Problem - Compare "stripped" duplicates of pattern and file window
Eric Marceau <[email protected]> Sat, 4 Feb 2023 18:12:59 -0800 (PST)
| Newsgroups | alt.comp.lang.sed |
|---|---|
| Message-ID | <[email protected]> |
I managed to modify a sed script (blockrep.sed)...=20
... intended to replace all instances of a multi-line text segment (a C pro=
gram function) and replace it by a replacement text (a "vastly" modified C =
program function) ...
... and made that work. All details and final results are documented here =
[ https://stackoverflow.com/questions/75305074/trying-to-get-generic-sed-mu=
lti-line-pattern-match-and-substitution-script-to-wo/75331049?noredirect=3D=
1#comment132942453_75331049 ].
As noted in one of my comments ...
... As long as all source code files are standardized, and elements were co=
py+pasted, the above solution will cover everything.
Now, I would like to generalize that beyond matching of cookie-cutter templ=
ates and add logic to
- strip leading whitespaces,=20
- trailing whitespaces, and=20
- map multiple-whitespaces to a single-space
... for both the match pattern,=20
... and the edited file "evaluation buffer",=20
to allow for random format of manually entered copies, to ensure no cases a=
re overlooked.
Thinking about how to achieve that revamping of the embedded ... blockrep.s=
ed ... script, I visualized creating a duplicate of the input buffer, which=
would match the sliding-window, and apply all massaging to that second cop=
y and use that for comparison with a similarly duplicated and massaged copy=
of the text segment that is trying to be located.
Then, upon locating and triggering that match condition, the non-massaged t=
ext in the file being edited would be replaced by the text segment specifie=
d in ... ${fileReplPat} ... which was mapped in the transformation specific=
ation 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), I was thinking that those maybe 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 concret=
e 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.