Fwd: Re: broken strings compiled-in into mutt

2015-08-05 Thread Matthias Apitz
- Forwarded message from Matthias Apitz g...@unixarea.de -

Date: Wed, 5 Aug 2015 08:15:29 +0200
From: Matthias Apitz g...@unixarea.de
To: freebsd-po...@freebsd.org
Subject: Re: broken strings compiled-in into mutt

El día Tuesday, August 04, 2015 a las 09:48:24PM +0200, Kurt Jaeger escribió:

 Hi!
 
  Hello Udo (as maintainer),
  
  Maybe it's a FreeBSD issue, rather than a mutt one?
 
 I see similar effects on 10.1-amd64.
 
 Mutt 1.5.23 (2014-03-12)
 Copyright (C) 1996-2009 Michael R. Elkins and others.
 Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
 Mutt is free software, and you are welcome to redistribute it
 under certain conditions; type `mutt -vv' for details.
 
 System: FreeBSD 10.2-RC2 (amd64)
 ncurses: ncurses 5.7.20081102 (compiled with 5.7)
 libiconv: 1.14
 libidn: 1.31 (compiled with 1.29)
 
 Compiler:
 F
 eeBSD clang ve
 ...

Hello,

I digged into this and the reason is in the source tree of mutt itself.

The option (...) strings get punched into a file conststrings.c and if you 
build mutt
with 'make' it gives an error due to a gmake'ish construct in the Makefile /
Makefile.in:

# make conststrings.c 
cc -I/usr/local/include -o txt2c 
cc: error: no input files
*** Error code 1 (ignored)
(  cc -I/usr/local/include -v ||  cc -I/usr/local/include --version ||
cc -I/usr/local/include -V ||  echo unknown compiler;  ) 21 |
./txt2c.sh cc_version conststrings_c
echo -pipe   -DLIBICONV_PLUG -g -fno-strict-aliasing | ./txt2c.sh
cc_cflags conststrings_c
grep ac_cs_config= config.status |  cut -d= -f2- |  sed -e 's/^//' -e
's/$//' | ./txt2c.sh configure_options conststrings_c
mv -f conststrings_c conststrings.c

i.e. because it can not build txt2c from txt2c.c it falles back to use
some shell script txt2c.sh; this, in turn, has another error: it
contains a sed pipeline and among others it does (here as an example
with some string):

$ echo FreeBSD is the better system | sed -e 's/\t/\\t/'g -e 's/\r/\\r/g'
F\reeBSD is \the be\t\te\r sys\tem

The workaround is to make mutt with gmake (the default on Linux);

The bugs should be fixed im mutt, ofc.

matthias


-- 
Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/  ☎ +49-176-38902045
No! Nein! ¡No! Όχι! -- Ευχαριστούμε!

- End forwarded message -


Re: Fwd: broken strings compiled-in into mutt

2015-08-05 Thread Christian Brabandt

Matthias Apitz schrieb am Mittwoch, den 05. August 2015:

 I digged into this and the reason is in the source tree of mutt itself.
 
 The option (...) strings get punched into a file conststrings.c and if you 
 build mutt
 with 'make' it gives an error due to a gmake'ish construct in the Makefile /
 Makefile.in:
 
 # make conststrings.c 
 cc -I/usr/local/include -o txt2c 
 cc: error: no input files
 *** Error code 1 (ignored)
 (  cc -I/usr/local/include -v ||  cc -I/usr/local/include --version ||
 cc -I/usr/local/include -V ||  echo unknown compiler;  ) 21 |
 ./txt2c.sh cc_version conststrings_c
 echo -pipe   -DLIBICONV_PLUG -g -fno-strict-aliasing | ./txt2c.sh
 cc_cflags conststrings_c
 grep ac_cs_config= config.status |  cut -d= -f2- |  sed -e 's/^//' -e
 's/$//' | ./txt2c.sh configure_options conststrings_c
 mv -f conststrings_c conststrings.c
 
 i.e. because it can not build txt2c from txt2c.c it falles back to use
 some shell script txt2c.sh; this, in turn, has another error: it
 contains a sed pipeline and among others it does (here as an example
 with some string):
 
 $ echo FreeBSD is the better system | sed -e 's/\t/\\t/'g -e 's/\r/\\r/g'
 F\reeBSD is \the be\t\te\r sys\tem
 
 The workaround is to make mutt with gmake (the default on Linux);
 
 The bugs should be fixed im mutt, ofc.

Yeah, the sed script is not portable. Better to replace it by perl 
(patch attached)

regards,
Christian
diff --git a/txt2c.sh b/txt2c.sh
--- a/txt2c.sh
+++ b/txt2c.sh
@@ -10,15 +10,14 @@ txt2c_fallback () {
 	# or odd-looking sequences.  The result is a sequence of quote-bounded
 	# C strings, which the compiler concatenates into a single C string.
 	tr -c '\011\012\015\040[!-~]' '?' |
-	sed \
-	-e 's/\\//g' \
-	-e 's//\\/g' \
-	-e 's/??/\?\?/g' \
-	-e 's/\t/\\t/'g \
-	-e 's/\r/\\r/g' \
-	-e 's/^/	/g' \
-	-e 's/$/\\n/g'
-	echo ;
+	perl -p \
+	-e 's/\\//g;' \
+	-e 's/\t/\\t/g;' \
+	-e 's/\r/\\r/g;' \
+	-e 's//\\/g;' \
+	-e 's/^/	\/g;' \
+	-e 's/$/\\n\/;'
+	echo ; /* generated by txt2c.sh */
 }
 
 ./txt2c test /dev/null /dev/null 21