summaryrefslogtreecommitdiff
path: root/utils/hp2ps
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2010-05-05 19:19:21 +0000
committerIan Lynagh <igloo@earth.li>2010-05-05 19:19:21 +0000
commit52584954ef6bd07031adfce9dd4c3a5d564c878f (patch)
treedf775c21e7dc839355a058db3c7be03f2ee6686b /utils/hp2ps
parent2f7dc066ab1812a945c1cd6bc7b9a3e3011432b8 (diff)
downloadhaskell-52584954ef6bd07031adfce9dd4c3a5d564c878f.tar.gz
Fix hp2ps when the .hp file has large string literals
Diffstat (limited to 'utils/hp2ps')
-rw-r--r--utils/hp2ps/HpFile.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/utils/hp2ps/HpFile.c b/utils/hp2ps/HpFile.c
index 9db94977df..1f2bf2d8d0 100644
--- a/utils/hp2ps/HpFile.c
+++ b/utils/hp2ps/HpFile.c
@@ -404,15 +404,24 @@ GetString(infp)
FILE *infp;
{
unsigned int i;
- char stringbuffer[5000];
+ char *stringbuffer;
+ size_t stringbuffersize;
ASSERT(ch == '\"');
+ stringbuffersize = 5000;
+ stringbuffer = xmalloc(stringbuffersize);
+
ch = getc(infp); /* skip the '\"' that begins the string */
- for (i = 0; i < (sizeof stringbuffer)-1 && ch != '\"'; i++) {
- stringbuffer[ i ] = ch;
- ch = getc(infp);
+ i = 0;
+ while (ch != '\"') {
+ if (i == stringbuffersize - 1) {
+ stringbuffersize = 2 * stringbuffersize;
+ stringbuffer = xrealloc(stringbuffer, stringbuffersize);
+ }
+ stringbuffer[ i++ ] = ch;
+ ch = getc(infp);
}
stringbuffer[i] = '\0';