Date: Tue, 20 Nov 2001 17:18:28 +0100 (CET)
From: Jean Delvare <delvare@serianet.com>
To: aaron@ardiri.com
Subject: patch for PilRC v2.8 patch 7


Hello

I found a (minor) bug in PilRC v2.8 patch 7. The error display in text
mode would fail is the error contains a '%' character. Here comes a patch
that fixes the problem, making the error output more reliable (and a bit
faster I think).

The reason why I went into the problem is that I was looking for a way to
catenate strings in my .rcp file. I tries "foo"##"bar" and "foo"%%"bar"
just in case. Of course, it doesn't work, but it made the bug obvious.

The patch also enhance the src2unix.sh script, making it somehow faster
and safer, and also introducting timestamp protection. Hope you like it.

Is there a way of catenating two strings in a .rcp file? My problem is
that the version of my program appears twice in the file (once for the
version itself, once for the "About" form). I was looking for a clean way
of having to change it only once. This would require either to be able to
programmatically request the program's version, which I don't know how to
do (is it even doable?), or to run pilrc with -DVERSION=\"X\" and then use
VERSION twice. The problem with this second possibility is that the
program version is "X.Y" but it appears as "v. X.Y" in the "About" form. I
guess I'm not the first one not the only one to encounter the problem. My
solution would have been something like "v. "##VERSION, where ## would be
the catenation operator. But, since it looks like catenation doesn't exist
for pilrc, it's not possible.

Would you have any suggestion?

Also, what about releasing pilrc 2.9? I think it's a good idea that the
version on the download page compiles and works - which is not the case
with 2.8 IIRC.

--
Jean "Khali" Delvare
mail: delvare@serianet.com
http://www.ensicaen.ismra.fr/~delvare/

====
diff -ruN pilrc-2.8p7/src2unix.sh pilrc-2.8p7-khali/src2unix.sh
--- pilrc-2.8p7/src2unix.sh	Thu Aug  9 16:40:36 2001
+++ pilrc-2.8p7-khali/src2unix.sh	Tue Nov 20 15:40:58 2001
@@ -2,9 +2,9 @@
 
 stripcr_inplace ()
 {
-    cat $1 | tr -d '\r' > $1.unx_
-    cat $1.unx_ > $1
-    rm $1.unx_
+    tr -d '\r' < "$1" > "$1.unx_"
+    touch -r "$1" "$1.unx_"
+    mv -f "$1.unx_" "$1"
 }
 
 for file in *.c *.h *.spec *.dsp doc/*.html; do
diff -ruN pilrc-2.8p7/util.c pilrc-2.8p7-khali/util.c
--- pilrc-2.8p7/util.c	Thu Aug  9 16:52:32 2001
+++ pilrc-2.8p7-khali/util.c	Tue Nov 20 15:34:52 2001
@@ -118,9 +118,7 @@
   else
 #endif
   {
-    fprintf(stderr, "\n");
-    fprintf(stderr, sz);
-    fprintf(stderr, "\n");
+    fprintf(stderr, "\n%s\n", sz);
     exit(1);
   }
 }

