mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-08-29 01:24:51 +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:
+2
-2
@@ -269,9 +269,9 @@ CmdPlot(w, cmd)
|
||||
|
||||
#if defined(HAVE_LIBCAIRO) && defined(MAGIC_WRAPPER)
|
||||
case PLOTSVG:
|
||||
if (cmd->tx_argc > 3)
|
||||
if (cmd->tx_argc != 3)
|
||||
{
|
||||
TxError("Too many arguments:\n plot %s\n",
|
||||
TxError("Wrong number of arguments:\n plot %s\n",
|
||||
cmdPlotOption[PLOTSVG]);
|
||||
return;
|
||||
}
|
||||
|
||||
+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