bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug occurring with a script parsing a Changelog


From: Vincent Belaïche
Subject: Bug occurring with a script parsing a Changelog
Date: Sun, 11 Jul 2010 11:21:32 +0200

Dear GAWK maintainers,

I came accross a bug with a script which I wrote to convert a list of
Changelog entries (generated with key binding `C-x 4 a' under emacs)
into a sequence of CVS commands. I am sorry that I do not provide a kind
of minimal example: I have used this script quite a number of times
successfully, and therefore I doubt that it is quite easy to make a
minimal example. So I provide the very raw example which I came accross.

My awk version is the following MSYS port (the latest release on MSYS)
(début=beginning, fin=end, coupez ici=cut here):

--8<-------------coupez ici--------------début-------------->8---
awk --version
GNU Awk 3.1.7
Copyright (C) 1989, 1991-2009 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
--8<-------------coupez ici---------------fin--------------->8---

I attached all the bug evidences as a gzipped tar.

The file ChangeLog_to_cvs_script.log is what I get on my machine (an
MSWindows XP PC) by typing the the following command in a current
directory where all other files are placed:


--8<-------------coupez ici--------------début-------------->8---
echo 2 | ./ChangeLog_to_cvs_script.sh > ChangeLog_to_cvs_script.log
--8<-------------coupez ici---------------fin--------------->8---

Note that I used an MSYS shell console under emacs to do this.

The principle of this ChangeLog_to_cvs_script.sh script is that it
parses the file Changelog with the help of ChangeLog_to_cvs_script.awk
in order to produce another script, namely
ChangeLog_to_cvs_script.cvs_commands, which is a list of CVS commands
used to remove/add/commit files for which a Changelog entry has been
found during parse of Changelog. This way of working allows me to

1. Be sure that all changes have a Changelog
2. Commit only once I feel that the goal of the the changes is reached.

Now I will describe the bug. Please first note that the
ChangeLog_to_cvs_script.awk script has been made verbous by setting AWK
variables debug and debug_trace to 1 --- this is to view where the bug
happens. The principle of the script is that for each log entry
deserving a commit, an entry to arrays cvs_commit and cvs_commit_target
is added, the full CVS command being the concatenation of

--8<-------------coupez ici--------------début-------------->8---
cvs_commit[i] cvs_commit_target[i]
--8<-------------coupez ici---------------fin--------------->8---

When several different Changelog entries correspond to the same file,
only the cvs_commit[i] is updated, because cvs_commit_target[i] is the
target file name.

Now at lines 762 and 763 of ChangeLog_to_cvs_script.log, the trace shows
that lines 208 and 209 of Changelog are read.

At line 764 of ChangeLog_to_cvs_script.log, the trace shows that line
210 of Changelog is empty (all what is going to happen now therefore
extends up to line 773 of ChangeLog_to_cvs_script.log). As line 210 of
Changelog is empty, the lines 208 and 209 of Changelog are detected as
forming together a single Changelog entry with value:

--8<-------------coupez ici--------------début-------------->8---
* jpicedt/jpicedt/util/math/Polynomial.java: Mise à jour URL de
  l'en-tête de fichier (http://www.jpicedt.org/)
--8<-------------coupez ici---------------fin--------------->8---

This Changelog entry is hereinafter referred to as "the current
Changelog entry"

At lines 765 and 766 of ChangeLog_to_cvs_script.log the trace, shows
then that the current Changelog entry has been decomposed into a
filename and a command, the filename as the following value:


--8<-------------coupez ici--------------début-------------->8---
jpicedt/jpicedt/util/math/Polynomial.java
--8<-------------coupez ici---------------fin--------------->8---

and the comment has the following value:

--8<-------------coupez ici--------------début-------------->8---
<2010-07-06> Mise à jour URL de l'en-tête de fichier (http://www.jpicedt.org/)
--8<-------------coupez ici---------------fin--------------->8---

Line 767 and 768 of ChangeLog_to_cvs_script.log shows that the AWK user
function push_cvs_commit is called where filename and
comment have the same values as previously decomposed for the current
Changelog entry.

Now, line 769 of ChangeLog_to_cvs_script.log shows that the file
`jpicedt/jpicedt/util/math/Polynomial.java' had already an entry in
cvs_commit and cvs_commit_target arrays, which is entry number 9. By
looking backward in the ChangeLog_to_cvs_script.log trace, one can see
that the last event on entry number 9 of cvs_commit and
cvs_commit_target is traced at lines 105--107 of
ChangeLog_to_cvs_script.log, and that this was an entry creation. At
this stage the cvs command under construction had the following value:

--8<-------------coupez ici--------------début-------------->8---
cvs commit -m '<2010-07-06> mise à jour java-doc (@author avec hyperlien)' 
jpicedt/jpicedt/util/math/Polynomial.java
--8<-------------coupez ici---------------fin--------------->8---

*NOW HERE IS THE BUG MANIFESTATION*, at line 770 of
ChangeLog_to_cvs_script.log, the entry number 9 of cvs_commit and
cvs_commit_target is traced after update, and the trace shows the
following:

--8<-------------coupez ici--------------début-------------->8---
cvs commit -m '<2010-07-10> (ConvexPolygonalZoneBoundaryFactory::getBoundary)  
correction sur la base du cas du rectangle'"
"'<2010-07-06> Mise à jour URL de l'"'"'en-tête de fichier 
(http://www.jpicedt.org/)' 
jpicedt/jpicedt/graphic/util/ConvexPolygonalZoneBoundaryFactory.java 
--8<-------------coupez ici---------------fin--------------->8---

This is not was was expected, it should have been the following

--8<-------------coupez ici--------------début-------------->8---
cvs commit -m '<2010-07-06> mise à jour java-doc (@author avec hyperlien)'"
"'<2010-07-06> Mise à jour URL de l'"'"'en-tête de fichier 
(http://www.jpicedt.org/)' jpicedt/jpicedt/util/math/Polynomial.java
--8<-------------coupez ici---------------fin--------------->8---

The bug is therefore that entry number 9 of arrays cvs_commit and
cvs_commit_target has been overwritten between intant corresponding to
line 107 of ChangeLog_to_cvs_script.log (ie creation of this entry), and
instant corresponding to line 769 of ChangeLog_to_cvs_script.log.

Sorry for the length of this mail. I hope that you can easily reproduce
the bug and solve it.

BR,
   Vincent Belaïche.

Attachment: ChangeLog_to_cvs_script.tgz
Description: Files to reproduce the bug


reply via email to

[Prev in Thread] Current Thread [Next in Thread]