Two small tweaks on plot filename behavior: (1) "plot svg" without

a filename causes an error instead of generating a trash filename
or crashing, while (2) "plot pnm" with a filename that has the ".pnm"
extension does not add another ".pnm" extension to the end of it.
This commit is contained in:
Tim Edwards
2023-10-17 20:01:39 -04:00
parent fdcc178bcd
commit 98f3b39dc2
3 changed files with 25 additions and 4 deletions
+9 -1
View File
@@ -755,6 +755,12 @@ PlotPNM(fileName, scx, layers, xMask, width)
}
fileName = tempFile;
}
else if (strchr(fileName, '.') == NULL)
{
/* Add extention ".pnm" if the filename does not have an extension */
sprintf(tempFile, "%s.pnm", fileName);
fileName = tempFile;
}
rtl_args.outfile = PaOpen(fileName, "w", (char *)NULL, ".",
(char *)NULL, (char **)NULL);
if (rtl_args.outfile == NULL)
@@ -807,7 +813,9 @@ PlotPNM(fileName, scx, layers, xMask, width)
{
/* open PNM file */
fp = PaOpen (fileName, "w", ".pnm", ".", NULL, NULL);
fp = PaOpen (fileName, "w",
(strchr(fileName, '.') == NULL) ? ".pnm" : NULL,
".", NULL, NULL);
if (fp == NULL)
{
TxError ("Could not open file `%s' for writing\n", fileName);