summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPaul Gardiner <paul@glidos.net>2012-07-17 12:57:24 +0100
committerPaul Gardiner <paul@glidos.net>2012-07-17 12:57:24 +0100
commitee93773f786228f8f199cf547f7af6e456a90741 (patch)
treefb4aff8f1bd715b5f84fd344404aebf1978ef8d9 /scripts
parent4499536d9678608bf2f1da36e2768ad84ce9980b (diff)
downloadmupdf-ee93773f786228f8f199cf547f7af6e456a90741.tar.xz
Fix a couple of bugs in c-string generator
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cquote.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/scripts/cquote.c b/scripts/cquote.c
index 0363574d..6383f80f 100644
--- a/scripts/cquote.c
+++ b/scripts/cquote.c
@@ -24,6 +24,7 @@ main(int argc, char **argv)
char name[256];
char *realname;
int i, c;
+ int bol = 1;
if (argc < 3)
{
@@ -68,12 +69,17 @@ main(int argc, char **argv)
fprintf(fo, "\n/* %s */\n\n", name);
- fputc('\"', fo);
c = fgetc(fi);
while (c != EOF)
{
int eol = 0;
+ if (bol)
+ {
+ fputc('\"', fo);
+ bol = 0;
+ }
+
switch (c)
{
case '\"':
@@ -96,9 +102,10 @@ main(int argc, char **argv)
if (eol)
{
- fprintf(fo, "\\n\"\n\"");
+ fprintf(fo, "\\n\"\n");
while ((c = fgetc(fi)) == '\r' || c == '\n')
;
+ bol = 1;
}
else
{
@@ -106,11 +113,12 @@ main(int argc, char **argv)
}
}
- fprintf(fo, "\\n\"\n");
+ if (!bol)
+ fprintf(fi, "\\n\"\n");
- if (fclose(fo))
+ if (fclose(fi))
{
- fprintf(stderr, "cmapdump: could not close output file '%s'\n", argv[1]);
+ fprintf(stderr, "cquote: could not close input file '%s'\n", argv[i]);
return 1;
}
@@ -118,7 +126,7 @@ main(int argc, char **argv)
if (fclose(fo))
{
- fprintf(stderr, "cmapdump: could not close output file '%s'\n", argv[1]);
+ fprintf(stderr, "cquote: could not close output file '%s'\n", argv[1]);
return 1;
}