Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qrencode produces invalid XPM data. #193

Open
PCDbeeip opened this issue Feb 14, 2022 · 2 comments
Open

qrencode produces invalid XPM data. #193

PCDbeeip opened this issue Feb 14, 2022 · 2 comments

Comments

@PCDbeeip
Copy link

fprintf(fp, "\"%s\"%s\n", row, y < (size - 1) ? "," : "};");

with margin != 1
XPM data is not valid C code (although correctly processed by most image viewers)

# echo "83c36da7" | qrencode -s1 -m2 -M -t XPM -o QR.xpm
# g++ -c -x c QR.xpm -o QR.o 
QR.xpm:27:1: error: expected identifier or ‘(’ before string constant
   27 | "BBBBBBBBBBBBBBBBBBB"};
      | ^~~~~~~~~~~~~~~~~~~~~
@PCDbeeip
Copy link
Author

suggested patch

diff --git a/qrenc.c b/qrenc.c
index c09c4ab..d26b0d2 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -724,9 +724,11 @@ static int writeXPM(const QRcode *qrcode, const char *outfile)
        }
 
        for (y = 0; y < realmargin; y++) {
-               fprintf(fp, "\"%s\"%s\n", row, y < (size - 1) ? "," : "};");
+               fprintf(fp, "\"%s\",\n", row);
        }
 
+    fputs("};\n", fp);
+
        free(row);
        fclose(fp);

@PCDbeeip
Copy link
Author

same as issue #188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant