[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Writing journal and output file to current directory
From: |
Ben Pfaff |
Subject: |
Re: Writing journal and output file to current directory |
Date: |
Fri, 17 Oct 2008 09:33:02 -0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
John Darrington <address@hidden> writes:
> How about the attached patch? It shouldn't make any difference for
> non-windows systems, but hopefully it'll sort out the current default
> dir for the rest.
I was planning to make a gnulib module for finding one's home
directory portably, but your patch is fine until then. A few
comments:
> diff --git a/src/libpspp/misc.h b/src/libpspp/misc.h
> index 3b02515..1fc75e9 100644
> --- a/src/libpspp/misc.h
> +++ b/src/libpspp/misc.h
> @@ -77,4 +77,6 @@ maximize (double *dest, double src)
> *dest = src;
> }
>
> -#endif /* libpspp/misc.h */
> +const char * default_output_path (void);
> +
> +#endif
I think we have a source file with file-name functions already.
Ah yes, src/data/file-name.c. I hate adding anything to misc.h
(I've been trying to kill off that file for years) so could you
consider putting it in file-name.c?
> - journal_file_name = xstrdup ("pspp.jnl");
> + {
> + const char *output_path = default_output_path ();
> + journal_file_name = xmalloc (1 + strlen (output_path) + strlen
> ("pspp.jnl"));
> + strcpy (journal_file_name, output_path);
> + strcat (journal_file_name, "pspp.jnl");
> + }
You can simplify this slightly as:
journal_file_name = xasprintf ("%s%s", "pspp.jnl");
> diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c
> index 1007ff9..d7ff89f 100644
> --- a/src/ui/gui/helper.c
> +++ b/src/ui/gui/helper.c
> @@ -344,3 +344,6 @@ clone_list_store (const GtkListStore *src)
> }
>
>
> +
> +
> +
I don't think adding blank lines to a file is a valuable change
:-)
> +const char *
> +output_file_name (void)
> +{
> + const char *dir = default_output_path ();
> + static char *filename = NULL;
> +
> + if ( NULL == filename )
> + {
> + filename = xmalloc (1 + strlen (OUTPUT_FILE_NAME) + strlen (dir));
> +
> + strcpy (filename, dir);
> + strcat (filename, OUTPUT_FILE_NAME);
> + }
Ditto with xasprintf() here.
--
Ben Pfaff
http://benpfaff.org
- News about pspp for windows, Michel Boaventura, 2008/10/15
- Message not available
- Writing journal and output file to current directory, John Darrington, 2008/10/15
- Re: Writing journal and output file to current directory, John Darrington, 2008/10/17
- Re: Writing journal and output file to current directory,
Ben Pfaff <=
- Re: Writing journal and output file to current directory, John Darrington, 2008/10/17
- Re: Writing journal and output file to current directory, Ben Pfaff, 2008/10/17
- Re: Writing journal and output file to current directory, John Darrington, 2008/10/17
relocation of .glade files, John Darrington, 2008/10/15
- Re: relocation of .glade files, Michel Boaventura, 2008/10/15
- Re: relocation of .glade files, John Darrington, 2008/10/15
- Re: relocation of .glade files, Michel Boaventura, 2008/10/15
- Re: relocation of .glade files, John Darrington, 2008/10/15
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Re: relocation of .glade files, John Darrington, 2008/10/16
- Re: relocation of .glade files, Ben Pfaff, 2008/10/16