mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-08-29 09:30:46 +02:00
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:
+9
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user