BUG in input.c

Menaka Lashitha Bandara lashi@optusnet.com.au
29 Jul 2002 18:06:23 +1000


--=-qUxTRmjxoOEm3k4NIxi3
Content-Type: multipart/mixed; boundary="=-nRN25A9DI1lyltXsCNEt"


--=-nRN25A9DI1lyltXsCNEt
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hi Guys,

Here's a patch for a bug that was uncovered on my machine. Hugs did work
for some time, and then suddenly stopped working (ie, wouldn't Parse
Prelude.hs, and eats up CPU). Basically, lineBuffer in input.c was
declared type (char), and EOF on my machine is -1, so it's outside the
range of (char). The bug occurs line 516 of input.c (original). It works
ok on x86, so I've put a little preprocessor routine to adapt depending
on the value of EOF. There's one of my comments there, and if you feel
that it taints hugs code, feel free to remove it.

Take care, keep up the good work :).

\LaShI


--=20
Debian GNU/Linux 3.0 (Sid) (ibook2,powerpc), kernel 2.4.18-benh-xfs

<lashi@optusnet.com.au>=20
1874 5597 C754 5209 0A7D  4DA6 9112 5D0E CC1F 67BC

--=-nRN25A9DI1lyltXsCNEt
Content-Disposition: attachment; filename=patch-hugs-bug
Content-Type: text/x-patch; name=patch-hugs-bug; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

diff -u ../hugs98-Dec2001/src/input.c src/input.c
--- ../hugs98-Dec2001/src/input.c	2002-07-15 03:21:03.000000000 +1000
+++ src/input.c	2002-07-29 17:47:18.000000000 +1000
@@ -309,11 +309,22 @@
     return isIn(c,LARGE);
 }
=20
+/* BUGFIX: Menaka Lashitha Bandara <lashi@optusnet.com.au>
+ * 	   <lashi@lashitha.org> -- doesn't work at the moment, but preffered.
+ * (char) *lineBuffer causes a comparison lineBuffer [lineLength] =3D=3D E=
OF to
+ * always be false, thereby not being able to Parse files on some machines=
. */
+
+#if EOF < 0
+#define LINE_BUFFER_SIZE_TYPE	signed char
+#else
+#define LINE_BUFFER_SIZE_TYPE 	char
+#endif
+
 #if HAVE_GETDELIM_H
-static char *lineBuffer =3D NULL;   /* getline() does the initial allocati=
on */
+static LINE_BUFFER_SIZE_TYPE *lineBuffer =3D NULL;   /* getline() does the=
 initial allocation */
 #else
 #define LINEBUFFER_SIZE 1000
-static char lineBuffer[LINEBUFFER_SIZE];
+static LINE_BUFFER_SIZE_TYPE lineBuffer[LINEBUFFER_SIZE];
 #endif
 static int lineLength =3D 0;
 static int inCodeBlock =3D FALSE; /* Inside \begin{code}..\end{code} */

--=-nRN25A9DI1lyltXsCNEt--

--=-qUxTRmjxoOEm3k4NIxi3
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQA9RPd/kRJdDswfZ7wRAmL7AKCyDDuzDcNvmBY/p2h+3ZpRI9HoswCg1fmP
KKAOHZPftu608Q9YNsYYaIg=
=esP3
-----END PGP SIGNATURE-----

--=-qUxTRmjxoOEm3k4NIxi3--