On Sat, 15 Oct 2011 05:56:27 -0700
"Enlightenment SVN" <no-re...@enlightenment.org> wrote:

> Log:
> eina: add eina_strbuf_trim/rtrim/ltrim()
> 
> Author:       billiob
> Date:         2011-10-15 05:56:27 -0700 (Sat, 15 Oct 2011)
> New Revision: 64098
> Trac:         http://trac.enlightenment.org/e/changeset/64098
> 
> Modified:
>   trunk/eina/src/include/eina_strbuf.h trunk/eina/src/lib/eina_strbuf.c 
> 
> Modified: trunk/eina/src/include/eina_strbuf.h
> ===================================================================
> --- trunk/eina/src/include/eina_strbuf.h      2011-10-15 09:51:26 UTC (rev
> 64097) +++ trunk/eina/src/include/eina_strbuf.h       2011-10-15 12:56:27
> UTC (rev 64098) @@ -564,6 +564,33 @@
>  EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const
> char *with) EINA_ARG_NONNULL(1, 2, 3); 
>  /**
> + * @brief Trim the string buffer
> +
> + * @param buf the string buffer to work with.
> + *
> + * This function skips whitespaces in the beginning and the end of the
> buffer.
> + */
> +EAPI void eina_strbuf_trim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
> +
> +/**
> + * @brief Left trim the string buffer
> +
> + * @param buf the string buffer to work with.
> + *
> + * This function skips whitespaces in the beginning of the buffer.
> + */
> +EAPI void eina_strbuf_ltrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
> +
> +/**
> + * @brief Right trim the string buffer
> +
> + * @param buf the string buffer to work with.
> + *
> + * This function skips whitespaces in the end of the buffer.
> + */
> +EAPI void eina_strbuf_rtrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
> +
> +/**
>   * @}
>   */
>  
> 
> Modified: trunk/eina/src/lib/eina_strbuf.c
> ===================================================================
> --- trunk/eina/src/lib/eina_strbuf.c  2011-10-15 09:51:26 UTC (rev
> 64097) +++ trunk/eina/src/lib/eina_strbuf.c   2011-10-15 12:56:27 UTC
> (rev 64098) @@ -4,6 +4,7 @@
>  
>  #include <stdio.h>
>  #include <string.h>
> +#include <ctype.h>
>  
>  #ifdef HAVE_EVIL
>  # include <Evil.h>
> @@ -158,6 +159,44 @@
>     return ret;
>  }
>  
> +EAPI void
> +eina_strbuf_trim(Eina_Strbuf *buf)
> +{
> +   char *c = buf->buf;
> +
> +   while (buf->len > 0 && isspace(((unsigned char*)(buf->buf))[buf->len -
> 1]))
> +     buf->len--;
> +   while (buf->len > 0 && isspace(*c))
> +     {
> +        c++;
> +        buf->len--;
> +     }
> +   memmove(buf->buf, c, buf->len);
> +   ((unsigned char *)buf->buf)[buf->len] = '\0';
> +}
> +
> +EAPI void
> +eina_strbuf_ltrim(Eina_Strbuf *buf)
> +{
> +   char *c = buf->buf;
> +
> +   while (buf->len > 0 && isspace(*c))
> +     {
> +        c++;
> +        buf->len--;
> +     }
> +   memmove(buf->buf, c, buf->len);
> +   ((unsigned char *)buf->buf)[buf->len] = '\0';
> +}
> +
> +EAPI void
> +eina_strbuf_rtrim(Eina_Strbuf *buf)
> +{
> +   while (buf->len > 0 && isspace(((unsigned char*)(buf->buf))[buf->len -
> 1]))
> +     buf->len--;
> +   ((unsigned char *)buf->buf)[buf->len] = '\0';
> +}
> +
>  /* Unicode */
>  
>  #include "eina_strbuf_template_c.x"
> 
> 
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2d-oct
> _______________________________________________
> enlightenment-svn mailing list
> enlightenment-...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
@since, changelog

-- 
Mike Blumenkrantz
Zentific: Coding in binary since '10.

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to