summaryrefslogtreecommitdiff
path: root/src/system.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-09-14 17:37:58 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-09-16 18:23:49 -0700
commitdfff75a432eec187e4c5f2c6ce99ebdadb1089c8 (patch)
treef3407af0d4030ecda8303e93bb8fb09a0c2f99f7 /src/system.h
parent6e319a818ed7b15b452ed2baab2f6a38d42fd1fe (diff)
downloadgrep-dfff75a432eec187e4c5f2c6ce99ebdadb1089c8.tar.gz
grep: use mbclen cache more effectively
* src/grep.c (buffer_textbin, contains_encoding_error): Use mb_clen for speed. (buffer_textbin): Bypass mb_clen in unibyte locales. (main): Always initialize the cache, since it's sometimes used in unibyte locales now. Initialize it before contains_encoding_error might be called. * src/search.h (SEARCH_INLINE): New macro. (mbclen_cache): Now extern decl. (mb_clen): New inline function. * src/searchutils.c (SEARCH_INLINE, SYSTEM_INLINE): Define. (mbclen_cache): Now extern. (build_mbclen_cache): Put 1 into the cache when mbrlen returns 0. (mb_goback): Use mb_len for speed, and rely on it returning nonzero. * src/system.h (SYSTEM_INLINE): New macro. (to_uchar): Use it.
Diffstat (limited to 'src/system.h')
-rw-r--r--src/system.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/system.h b/src/system.h
index 7da1d8d7..bac26239 100644
--- a/src/system.h
+++ b/src/system.h
@@ -49,15 +49,22 @@ enum { EXIT_TROUBLE = 2 };
#include "unlocked-io.h"
+_GL_INLINE_HEADER_BEGIN
+#ifndef SYSTEM_INLINE
+# define SYSTEM_INLINE _GL_INLINE
+#endif
+
#define STREQ(a, b) (strcmp (a, b) == 0)
/* Convert a possibly-signed character to an unsigned character. This is
a bit safer than casting to unsigned char, since it catches some type
errors that the cast doesn't. */
-static inline unsigned char
+SYSTEM_INLINE unsigned char
to_uchar (char ch)
{
return ch;
}
+_GL_INLINE_HEADER_END
+
#endif