Hi,

On Sat, Mar 28, 2009 at 2:32 AM, Lech Lorens <[email protected]> wrote:
> Improved version of patch is attached. I took into consideration most of
> the suggestions. I will be grateful for any more comments.
>
> --
> Cheers,
> Lech
>
>
>
> Index: src/hardcopy.c
> ===================================================================
> --- src/hardcopy.c      (revision 1425)
> +++ src/hardcopy.c      (working copy)
> @@ -568,6 +568,8 @@
>     long_u             bytes_to_print = 0;
>     int                        page_line;
>     int                        jobsplit;
> +    char_u             *bname = NULL;
> +    int                        do_return = FALSE;
>
>     memset(&settings, 0, sizeof(prt_settings_T));
>     settings.has_color = TRUE;
> @@ -599,11 +601,15 @@
>      */
>     if (mch_print_init(&settings,
>                        curbuf->b_fname == NULL
> -                           ? (char_u *)buf_spname(curbuf)
> +                           ? (bname = (char_u *)buf_spname(curbuf))

For maintainability reasons, it is better to assign the bname variable
outside of this
function call.

>                            : curbuf->b_sfname == NULL
>                                ? curbuf->b_fname
>                                : curbuf->b_sfname,
>                        eap->forceit) == FAIL)
> +       do_return = TRUE;
> +
> +    vim_free(bname);
> +    if (do_return)
>        return;
>
>  #ifdef FEAT_SYN_HL
> Index: src/ex_docmd.c
> ===================================================================
> --- src/ex_docmd.c      (revision 1425)
> +++ src/ex_docmd.c      (working copy)
> @@ -7285,6 +7285,7 @@
>     tabpage_T  *tp;
>     win_T      *wp;
>     int                tabcount = 1;
> +    char_u     *bname;
>
>     msg_start();
>     msg_scroll = TRUE;
> @@ -7307,8 +7308,11 @@
>            msg_putchar(' ');
>            msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');
>            msg_putchar(' ');
> -           if (buf_spname(wp->w_buffer) != NULL)
> -               STRCPY(IObuff, buf_spname(wp->w_buffer));
> +           if ((bname = (char_u *)buf_spname(wp->w_buffer)) != NULL)
>

Same here. It is better to assign the bame variable outside the if statement.
This comment also applies to other places in this diff.

- Yegappan

> +           {
> +               vim_strncpy(IOSIZE, bname, IOSIZE - 1);
> +               vim_free(bname);
> +           }
>            else
>                home_replace(wp->w_buffer, wp->w_buffer->b_fname,
>                                                        IObuff, IOSIZE, TRUE);

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui