This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] po2test.sed is not valid sed
- From: Paolo Bonzini <paolo dot bonzini at polimi dot it>
- To: libc-alpha at sources dot redhat dot com
- Date: Mon, 24 Mar 2003 11:52:41 +0100
- Subject: [PATCH] po2test.sed is not valid sed
- Reply-to: bonzini at gnu dot org
po2test.sed uses two times the same label. This AFAICT is undefined behavior
according to POSIX, and besides it works only by chance (because the two
bodies of code for msgid and msgstr are the same).
I also intend to find out whether it is fine to make this a hard error and do
that in future GNU sed releases, so it's time to fix these.
This patch fixes the problem by putting the loop out of { }.
While looking at it, I also found that the second substitution in the loop is
never done.
--
|_ _ _ __
|_)(_)| ) ;'_.
*** po2test.sed.bad Mon Mar 24 10:55:41 2003
--- po2test.sed Mon Mar 24 11:47:05 2003
***************
*** 16,70 ****
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# We copy the original message as a comment into the .msg file. But enclose
# them with INPUT ( ).
#
! /^msgid/ {
! s/msgid[ ]*"\(.*\)"/INPUT ("\1")/
! # Clear flag from last substitution.
! tb
! # Append the next line.
! :b
! N
! # Look whether second part is a continuation line.
! s/\(.*\)")\(\n\)"\(.*\)"/\1\\\2\3")/
! # Yes, then branch.
! ta
! P
! D
! # Note that `D' includes a jump to the start!!
! # We found a continuation line. But before printing insert '\'.
! :a
! s/\(.*\)")\(\n.*\)/\1\\\2/
! P
! # We cannot use the sed command `D' here
! s/.*\n\(.*\)/\1/
! tb
! }
#
# Copy the translations as well and enclose them with OUTPUT ( ).
#
! /^msgstr/ {
! s/msgstr[ ]*"\(.*\)"/OUTPUT ("\1")/
! # Clear flag from last substitution.
! tb
# Append the next line.
! :b
! N
! # Look whether second part is a continuation line.
! s/\(.*\)")\(\n\)"\(.*\)"/\1\\\2\3")/
! # Yes, then branch.
! ta
! P
! D
! # Note that `D' includes a jump to the start!!
! # We found a continuation line. But before printing insert '\'.
! :a
! s/\(.*\)")\(\n.*\)/\1\\\2/
! P
# We cannot use the sed command `D' here
! s/.*\n\(.*\)/\1/
! tb
! }
! d
--- 16,52 ----
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
+
#
# We copy the original message as a comment into the .msg file. But enclose
# them with INPUT ( ).
#
! s/msgid[ ]*"\(.*\)"/INPUT ("\1")/
! # Clear flag from last substitution and jump if matching
! tb
!
#
# Copy the translations as well and enclose them with OUTPUT ( ).
#
! s/msgstr[ ]*"\(.*\)"/OUTPUT ("\1")/
! # Clear flag from last substitution and jump if matching
! tb
!
! d
!
! :b
# Append the next line.
! $!N
! # Check whether second part is a continuation line. If so, before printing
! # insert '\'.
! s/\(.*\)")\(\n\)"\(.*\)"/\1\\\2\3")/
! P
! ta
! # No, go to the top and process it. Note that `D' includes a jump to the start!!
! D
! # Yes, we found a continuation line.
! :a
# We cannot use the sed command `D' here
! s/[^\n]*\n//
! # Clear the substitution flag and do the next line.
! tb