[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/4] gui: Factor out duplicated code for executing and pastin
From: |
Ben Pfaff |
Subject: |
Re: [PATCH 4/4] gui: Factor out duplicated code for executing and pasting syntax. |
Date: |
Sun, 05 Dec 2010 06:46:26 -0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
John Darrington <address@hidden> writes:
> On Sat, Dec 04, 2010 at 11:37:38AM -0800, Ben Pfaff wrote:
>
> Reducing code duplication is good on its own. This will also make it
> easier in upcoming patches to swap out "getl_interface" with a new
> structure, by eliminating most of the references to getl_interface.
>
> +/* Executes null-terminated string SYNTAX as syntax.
> + Returns SYNTAX. */
> +gchar *
> +execute_syntax_string (gchar *syntax)
> +{
> + struct getl_interface *sss = create_syntax_string_source (syntax);
> + execute_syntax (sss);
> + return syntax;
> +}
> +
> +/* Executes null-terminated string SYNTAX as syntax.
> + Returns SYNTAX. */
> +const gchar *
> +execute_const_syntax_string (const gchar *syntax)
> +{
> + return execute_syntax_string (CONST_CAST (gchar *, syntax));
> +}
>
> These functions can be written as:
>
> /* Executes null-terminated string SYNTAX as syntax.
> Returns SYNTAX. */
> gchar *
> execute_syntax_string (gchar *syntax)
> {
> execute_const_syntax_string (syntax);
> return syntax;
> }
>
> /* Executes null-terminated string SYNTAX as syntax.
> Returns SYNTAX. */
> const gchar *
> execute_const_syntax_string (const gchar *syntax)
> {
> execute_syntax (create_syntax_string_source (syntax));
> return syntax;
> }
>
>
> .. which avoids the CONST_CAST, and a reference to getl_interface.
> Optionally, you could make the second function return void, since
> nowhere is its return value used.
That's much better, thanks. I folded both changes into this
commit.
Should I wait for other comments on these changes, or are you
satisfied with them?
Thanks,
Ben.
--
"Because computer source code is an expressive means for the exchange
of information and ideas about computer programming, we hold that it
is protected by the First Amendment."
--Hon. Boyce F. Martin, Jr., for the 6th Circuit Court, Junger vs. Daley
- [PATCH 0/4] More preparation for lexer replacment, Ben Pfaff, 2010/12/04
- [PATCH 3/4] command: Don't allow SORT as an abbreviation for SORT CASES., Ben Pfaff, 2010/12/04
- [PATCH 2/4] Remove the PROMPT, CPROMPT, and DPROMPT settings., Ben Pfaff, 2010/12/04
- [PATCH 1/4] Remove the NULLINE and ENDCMD settings., Ben Pfaff, 2010/12/04
- [PATCH 4/4] gui: Factor out duplicated code for executing and pasting syntax., Ben Pfaff, 2010/12/04