X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmbsrchr.c;h=8d6c020e7e584c3772de011d8d20deecd9109c46;hb=7ef6c64e210ac0979d7e8ac69bc5b5208c2405ab;hp=679f9a48f47178a802c2616ce80e5cf036e92cd2;hpb=57fdfd3f8ec62b105c53bcdf6f127c35c7fe7391;p=gnulib.git diff --git a/lib/mbsrchr.c b/lib/mbsrchr.c index 679f9a48f..8d6c020e7 100644 --- a/lib/mbsrchr.c +++ b/lib/mbsrchr.c @@ -1,5 +1,5 @@ /* Searching a string for the last occurrence of a character. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2014 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -20,34 +20,30 @@ /* Specification. */ #include -#if HAVE_MBRTOWC -# include "mbuiter.h" -#endif +#include "mbuiter.h" /* Locate the last single-byte character C in the character string STRING, and return a pointer to it. Return NULL if C is not found in STRING. */ char * mbsrchr (const char *string, int c) { -#if HAVE_MBRTOWC if (MB_CUR_MAX > 1 /* Optimization: We know that ASCII characters < 0x30 don't occur as - part of multibyte characters longer than 1 byte. Hence, if c < 0x30, - the faster unibyte loop can be used. */ + part of multibyte characters longer than 1 byte. Hence, if c < 0x30, + the faster unibyte loop can be used. */ && (unsigned char) c >= 0x30) { const char *result = NULL; mbui_iterator_t iter; for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter)) - { - if (mb_len (mbui_cur (iter)) == 1 - && (unsigned char) * mbui_cur_ptr (iter) == (unsigned char) c) - result = mbui_cur_ptr (iter); - } + { + if (mb_len (mbui_cur (iter)) == 1 + && (unsigned char) * mbui_cur_ptr (iter) == (unsigned char) c) + result = mbui_cur_ptr (iter); + } return (char *) result; } else -#endif return strrchr (string, c); }