[Libreoffice] Test script patch review request (1)
yfjiang at novell.com
Mon Jan 3 22:01:39 PST 2011
Thanks a lot for reviewing and the comments, I haven't even known the
'(un)expand' until you told :) To make it concise, do you think it is enough
to replace 'Inital' Tabs with 4 space characters, while change other tabs with
1 space character. In addition the trailing spaces could be removed at the
same time as the final step.
Here is the method I intend to update the patch, your further comments are
appreciated, thank you!
step 1. Replace Initial tabs with 4 space characters:
$ cat /tmp/tabfile | while read fn ; do expand -i -t 4 $fn > /tmp/no_initabfile; mv /tmp/no_initabfile $fn; done
step 2. Replace all tabs in the middle/at the end of code with 1 space character:
$ cat /tmp/tabfile | while read fn; do expand -t 1 $fn > /tmp/no_tabfile; mv /tmp/no_tabfile $fn; done
step 3. Remove all trailing spaces stepping through inc and bas files:
$ find | grep -e bas$ -e inc$ | while read fn; do sed -r 's/ +$//' $fn > /tmp/no_trailingspaces ; mv /tmp/no_trailingspaces $fn; done
On Mon, Jan 03, 2011 at 04:51:28AM -0700, Tor Lillqvist wrote:
> > cat /tmp/tabfile | sed 's/ / /' > /tmp/notabfile;
> Sorry, but just replacing every TAB character with a fixed number (in this case, four) of SPACE characters is incorrect. To properly expand TAB characters, each TAB needs to be replaced with a variable number of SPACE characters, depending on which column the TAB is in.
> For instance if you have a line:
> foo bar
> (i.e. "foo", a TAB, and "bar"), the TAB should be replaced with just one SPACE. (Assuming the intended tab width is four columns, as it is in OOo/LO. Note that traditionally the tab width is eight columns.)
> (Also, you would want to use the "g" modifier in the sed 's' command to replace every TAB on each line, not just the first.)
> Anyway, the "expand" command is the right tool to expand tabs.
> P.S. Your script can be written much simpler, no need to use "cat" so much:
> while read fn </tmp/tabs.auto.filelist.txt; do
> sed 's/ / /g' < $fn > /tmp/notabfile
> mv /tmp/notabfile $fn
> (Here still incorrectly using "sed" and not "expand".)
More information about the LibreOffice