Re: [PATCH 5/4] Rewrite my_basename() as inline function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/23/09, Andreas Robinson <andr345@xxxxxxxxx> wrote:
> On Thu, 2009-04-23 at 18:15 +0100, Alan Jenkins wrote:
>
>> Sorry, I didn't explain myself very well.  When I objected to the
>> macro, what I really disliked was the way it was compressed into one
>> line.  I think the original 3-line my_basename() function was much
>> clearer.
>
> Ah, ok. I need to kill some of my darlings it seems...
> Is this patch better?
>
> >From 8f80cd791a9008387c1c457d551bca73277c18e9 Mon Sep 17 00:00:00 2001
> From: Andreas Robinson <andr345@xxxxxxxxx>
> Date: Thu, 23 Apr 2009 19:49:16 +0200
> Subject: [PATCH] Rewrite my_basename() for clarity
>
> ---
>  util.c |   12 ++++++++++++
>  util.h |    2 +-
>  2 files changed, 13 insertions(+), 1 deletions(-)
>
> diff --git a/util.c b/util.c
> index 0ee6064..577718a 100644
> --- a/util.c
> +++ b/util.c
> @@ -114,6 +114,18 @@ char *underscores(char *string)
>  }
>
>  /*
> + * Get the basename in a pathname.
> + * Unlike the standard implementation, this does not copy the string.
> + */
> +char *my_basename(const char *path)
> +{
> +	const char *base = strrchr(path, '/');
> +	if (base)
> +		return (char *) base + 1;
> +	return (char *) path;
> +}

That's fine.
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux