projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2f7dc06
)
Fix hp2ps when the .hp file has large string literals
author
Ian Lynagh
<igloo@earth.li>
Wed, 5 May 2010 19:19:21 +0000
(19:19 +0000)
committer
Ian Lynagh
<igloo@earth.li>
Wed, 5 May 2010 19:19:21 +0000
(19:19 +0000)
utils/hp2ps/HpFile.c
patch
|
blob
|
history
diff --git
a/utils/hp2ps/HpFile.c
b/utils/hp2ps/HpFile.c
index
9db9497
..
1f2bf2d
100644
(file)
--- a/
utils/hp2ps/HpFile.c
+++ b/
utils/hp2ps/HpFile.c
@@
-404,15
+404,24
@@
GetString(infp)
FILE *infp;
{
unsigned int i;
FILE *infp;
{
unsigned int i;
- char stringbuffer[5000];
+ char *stringbuffer;
+ size_t stringbuffersize;
ASSERT(ch == '\"');
ASSERT(ch == '\"');
+ stringbuffersize = 5000;
+ stringbuffer = xmalloc(stringbuffersize);
+
ch = getc(infp); /* skip the '\"' that begins the string */
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';
}
stringbuffer[i] = '\0';