2 things:

Don't use the include eina safety in there, it will undef
EINA_ARG_NONNULL(), thus bad for a public header

Instead of do the non-inline with underscore, fix the function name:
get_next -> next_get, then deprecate the old one with EINA_DEPRECATED
macro.

On Monday, January 21, 2013, Enlightenment SVN wrote:

> Log:
> efl: inline eina_unicode_utf8_get_next.
>
>
> Author:       cedric
> Date:         2013-01-21 01:37:14 -0800 (Mon, 21 Jan 2013)
> New Revision: 83035
> Trac:         http://trac.enlightenment.org/e/changeset/83035
>
> Added:
>   trunk/efl/src/lib/eina/eina_abi.c
> trunk/efl/src/lib/eina/eina_inline_unicode.x
> Modified:
>   trunk/efl/src/Makefile_Eina.am trunk/efl/src/lib/eina/eina_unicode.c
> trunk/efl/src/lib/eina/eina_unicode.h
>
> Modified: trunk/efl/src/Makefile_Eina.am
> ===================================================================
> --- trunk/efl/src/Makefile_Eina.am      2013-01-21 09:36:19 UTC (rev 83034)
> +++ trunk/efl/src/Makefile_Eina.am      2013-01-21 09:37:14 UTC (rev 83035)
> @@ -78,7 +78,8 @@
>  lib/eina/eina_inline_lock_barrier.x \
>  lib/eina/eina_tmpstr.h \
>  lib/eina/eina_alloca.h \
> -lib/eina/eina_cow.h
> +lib/eina/eina_cow.h \
> +lib/eina/eina_inline_unicode.x
>
>  # Will be back for developper after 1.2.
>  # lib/eina/eina_model.h
> @@ -142,7 +143,8 @@
>  lib/eina/eina_private.h \
>  lib/eina/eina_strbuf_common.h \
>  lib/eina/eina_tmpstr.c \
> -lib/eina/eina_cow.c
> +lib/eina/eina_cow.c \
> +lib/eina/eina_abi.c
>
>  # Will be back for developper after 1.2
>  # lib/eina/eina_model.c \
>
> Added: trunk/efl/src/lib/eina/eina_abi.c
> ===================================================================
> --- trunk/efl/src/lib/eina/eina_abi.c                           (rev 0)
> +++ trunk/efl/src/lib/eina/eina_abi.c   2013-01-21 09:37:14 UTC (rev 83035)
> @@ -0,0 +1,86 @@
> +/* EINA - EFL data type library
> + * Copyright (C) 2013 Cedric Bail
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library;
> + * if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +# include "config.h"
> +#endif
> +
> +#include "eina_config.h"
> +#include "eina_private.h"
> +#include "eina_safety_checks.h"
> +
> +#if EINA_SIZEOF_WCHAR_T >= 4
> +# include <wchar.h>
> +typedef wchar_t Eina_Unicode;
> +#else
> +# include <inttypes.h>
> +typedef uint32_t Eina_Unicode;
> +#endif
> +
> +EAPI Eina_Unicode
> +_eina_unicode_utf8_get_next(int ind,
> +                           unsigned char d,
> +                           const char *buf,
> +                           int *iindex);
> +
> +#define ERROR_REPLACEMENT_BASE  0xDC80
> +#define EINA_IS_INVALID_BYTE(x)      ((x == 192) || (x == 193) || (x >=
> 245))
> +#define EINA_IS_CONTINUATION_BYTE(x) ((x & 0xC0) == 0x80)
> +
> +EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex)
> +{
> +   int ind;
> +   Eina_Unicode r;
> +   unsigned char d;
> +
> +   EINA_SAFETY_ON_NULL_RETURN_VAL(buf, 0);
> +   EINA_SAFETY_ON_NULL_RETURN_VAL(iindex, 0);
> +
> +   ind = *iindex;
> +
> +   /* if this char is the null terminator, exit */
> +   if ((d = buf[ind++]) == 0) return 0;
> +
> +   if ((d & 0x80) == 0)
> +     { // 1 byte (7bit) - 0xxxxxxx
> +        *iindex = ind;
> +        return d;
> +     }
> +
> +   if ((d & 0xe0) == 0xc0)
> +     { // 2 byte (11bit) - 110xxxxx 10xxxxxx
> +        r  = (d & 0x1f) << 6;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
> +        r |= (d & 0x3f);
> +        if (r <= 0x7F) goto error;
> +        *iindex = ind;
> +        return r;
> +     }
> +
> +   return _eina_unicode_utf8_get_next(ind, d, buf, iindex);
> +
> +/* Gets here where there was an error and we want to replace the char
> + * we just use the invalid unicode codepoints 8 lower bits represent
> + * the original char */
> +error:
> +   d = buf[*iindex];
> +   (*iindex)++;
> +   return ERROR_REPLACEMENT_BASE | d;
> +}
> +
>
> Added: trunk/efl/src/lib/eina/eina_inline_unicode.x
> ===================================================================
> --- trunk/efl/src/lib/eina/eina_inline_unicode.x
>      (rev 0)
> +++ trunk/efl/src/lib/eina/eina_inline_unicode.x        2013-01-21
> 09:37:14 UTC (rev 83035)
> @@ -0,0 +1,76 @@
> +/* EINA - EFL data type library
> + * Copyright (C) 2013 Cedric Bail
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library;
> + * if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef EINA_INLINE_UNICODE_
> +# define EINA_INLINE_UNICODE_
> +
> +#include "eina_safety_checks.h"
> +
> +EAPI Eina_Unicode _eina_unicode_utf8_get_next(int ind,
> +                                             unsigned char d,
> +                                             const char *buf,
> +                                             int *iindex);
> +
> +#define ERROR_REPLACEMENT_BASE  0xDC80
> +#define EINA_IS_INVALID_BYTE(x)      ((x == 192) || (x == 193) || (x >=
> 245))
> +#define EINA_IS_CONTINUATION_BYTE(x) ((x & 0xC0) == 0x80)
> +
> +static inline Eina_Unicode
> +eina_unicode_utf8_get_next(const char *buf, int *iindex)
> +{
> +   int ind;
> +   Eina_Unicode r;
> +   unsigned char d;
> +
> +   EINA_SAFETY_ON_NULL_RETURN_VAL(buf, 0);
> +   EINA_SAFETY_ON_NULL_RETURN_VAL(iindex, 0);
> +
> +   ind = *iindex;
> +
> +   /* if this char is the null terminator, exit */
> +   if ((d = buf[ind++]) == 0) return 0;
> +
> +   if ((d & 0x80) == 0)
> +     { // 1 byte (7bit) - 0xxxxxxx
> +        *iindex = ind;
> +        return d;
> +     }
> +
> +   if ((d & 0xe0) == 0xc0)
> +     { // 2 byte (11bit) - 110xxxxx 10xxxxxx
> +        r  = (d & 0x1f) << 6;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
> +        r |= (d & 0x3f);
> +        if (r <= 0x7F) goto error;
> +        *iindex = ind;
> +        return r;
> +     }
> +
> +   return _eina_unicode_utf8_get_next(ind, d, buf, iindex);
> +
> +/* Gets here where there was an error and we want to replace the char
> + * we just use the invalid unicode codepoints 8 lower bits represent
> + * the original char */
> +error:
> +   d = buf[*iindex];
> +   (*iindex)++;
> +   return ERROR_REPLACEMENT_BASE | d;
> +}
> +
> +#endif
>
> Modified: trunk/efl/src/lib/eina/eina_unicode.c
> ===================================================================
> --- trunk/efl/src/lib/eina/eina_unicode.c       2013-01-21 09:36:19 UTC
> (rev 83034)
> +++ trunk/efl/src/lib/eina/eina_unicode.c       2013-01-21 09:37:14 UTC
> (rev 83035)
> @@ -185,49 +185,24 @@
>
>  #define EINA_UNICODE_UTF8_BYTES_PER_CHAR 6
>  /* The replacement range that will be used for bad utf8 chars. */
> -#define ERROR_REPLACEMENT_BASE  0xDC80
>  #define ERROR_REPLACEMENT_END   0xDCFF
> -#define IS_INVALID_BYTE(x)      ((x == 192) || (x == 193) || (x >= 245))
> -#define IS_CONTINUATION_BYTE(x) ((x & 0xC0) == 0x80)
>
>  EAPI Eina_Unicode
> -eina_unicode_utf8_get_next(const char *buf, int *iindex)
> +_eina_unicode_utf8_get_next(int ind,
> +                            unsigned char d,
> +                            const char *buf,
> +                           int *iindex)
>  {
> -   int ind;
>     Eina_Unicode r;
> -   unsigned char d;
>
> -   EINA_SAFETY_ON_NULL_RETURN_VAL(buf, 0);
> -   EINA_SAFETY_ON_NULL_RETURN_VAL(iindex, 0);
> -
> -   ind = *iindex;
> -
> -   /* if this char is the null terminator, exit */
> -   if ((d = buf[ind++]) == 0) return 0;
> -
> -   if ((d & 0x80) == 0)
> -     { // 1 byte (7bit) - 0xxxxxxx
> -        *iindex = ind;
> -        return d;
> -     }
> -   if ((d & 0xe0) == 0xc0)
> -     { // 2 byte (11bit) - 110xxxxx 10xxxxxx
> -        r  = (d & 0x1f) << 6;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> -        r |= (d & 0x3f);
> -        if (r <= 0x7F) goto error;
> -        *iindex = ind;
> -        return r;
> -     }
>     if ((d & 0xf0) == 0xe0)
>       { // 3 byte (16bit) - 1110xxxx 10xxxxxx 10xxxxxx
>          r  = (d & 0x0f) << 12;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 6;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f);
>          if (r <= 0x7FF) goto error;
>          *iindex = ind;
> @@ -236,14 +211,14 @@
>     if ((d & 0xf8) == 0xf0)
>       { // 4 byte (21bit) - 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
>          r  = (d & 0x07) << 18;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 12;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 6;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f);
>          if (r <= 0xFFFF) goto error;
>          *iindex = ind;
> @@ -252,17 +227,17 @@
>     if ((d & 0xfc) == 0xf8)
>       { // 5 byte (26bit) - 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
>          r  = (d & 0x03) << 24;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 18;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 12;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 6;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f);
>          if (r <= 0x1FFFFF) goto error;
>          *iindex = ind;
> @@ -271,20 +246,20 @@
>     if ((d & 0xfe) == 0xfc)
>       { // 6 byte (31bit) - 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
> 10xxxxxx
>          r  = (d & 0x01) << 30;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 24;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 18;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 12;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f) << 6;
> -        if (((d = buf[ind++]) == 0) || IS_INVALID_BYTE(d) ||
> -            !IS_CONTINUATION_BYTE(d)) goto error;
> +        if (((d = buf[ind++]) == 0) || EINA_IS_INVALID_BYTE(d) ||
> +            !EINA_IS_CONTINUATION_BYTE(d)) goto error;
>          r |= (d & 0x3f);
>          if (r <= 0x3FFFFFF) goto error;
>          *iindex = ind;
>
> Modified: trunk/efl/src/lib/eina/eina_unicode.h
> ===================================================================
> --- trunk/efl/src/lib/eina/eina_unicode.h       2013-01-21 09:36:19 UTC
> (rev 83034)
> +++ trunk/efl/src/lib/eina/eina_unicode.h       2013-01-21 09:37:14 UTC
> (rev 83035)
> @@ -124,7 +124



-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to