-/* Parses O's value as a string and returns it as a malloc'd string that the
- caller is responsible for freeing.
+static char *
+default_chart_file_name (const char *file_name)
+{
+ if (strcmp (file_name, "-"))
+ {
+ const char *extension = strrchr (file_name, '.');
+ int stem_length = extension ? extension - file_name : strlen (file_name);
+ return xasprintf ("%.*s-#.png", stem_length, file_name);
+ }
+ else
+ return NULL;
+}
+
+/* Parses and returns a chart file name, or NULL if no charts should be output.
+ If a nonnull string is returned, it will contain at least one '#' character,
+ which the client will presumably replace by a number as part of writing
+ charts to separate files.
+
+ If O->value is "none", then this function returns NULL.