[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnulib-tool-py] Rewrite files
From: |
Bruno Haible |
Subject: |
Re: [gnulib-tool-py] Rewrite files |
Date: |
Sun, 22 Jul 2012 11:45:10 +0200 (CEST) |
Hi Dmitriy,
> 4615--4633: what means '%REWRITTEN%' in sed_rewrite_old_files and
> sed_rewrite_new_files? Is this just a part of name? If yes, why can not we
> just add suffix like '.tmp' instead of prefix that contains special symbols?
The purpose of this marker is to perform the substitutions in parallel. Suppose
you want to replace
m4/ -> lib/gl/m4/
lib/ -> lib/gl/lib/
tests/ -> lib/gl/tests
If you write it as a sequence of 3 's' commands in sed, due to sequential
execution, what
you will actually get is
m4/ -> lib/gl/lib/gl/m4/
lib/ -> lib/gl/lib/
tests/ -> lib/gl/tests
In other words, an unwanted side effect. To fix this, I add the %REWRITTEN%
marker
to each right-hand-side, which stops the execution of the following replacement
rules on that line.
If you have another way to avoid the unintended effect, go for it.
> 4635--4653: we echo directories which were specified by user. $sourcebase,
> $m4base and $auxdir are the necessary directories. $docbase will be echoed
> only if we have at least one file which name starts with 'doc/'. $testsbase
> will be echoed only if we have at least one testflag enabled. But what happens
> at lines 4649--4652?
The purpose of these lines is to create the directories into which files will
have to put. What is, generally, the most economic way to create the directories
for a set of files?
1. You collect the file names.
2. You remove the last component of each file name (like 'dirname' does),
3. You sort the result, removing duplicates.
4. Iterate over the resulting list and do 'mkdir' for each.
That's what this code does.
> 4670--4685: as I understand here we just save tables of files. However, to
> understand this table I need your explanations on lines 4615--4633 (see
> above).
>
These tables are input to the 'join' program, IIRC. In Python, you will do the
list-of-modules processing without calling 'join', therefore choose an
appropriate data structure (maybe a list of pairs of strings?).
> 4687--4699: we take first column from each file (see 4670--4685) and combine
> these two lists into one big list. Then from this big we delete duplicated
> files.
>
Yes, the code computes the set of all old file names that are not among the set
of new files names, then removes these files.
Bruno