[07/17] avstring: Add locale independent versions of some ctype.h functions

Message ID 1362578206-2806-7-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö March 6, 2013, 1:56 p.m.
From: Reimar Döffinger <Reimar.Doeffinger@gmx.de>

---
 doc/APIchanges       |    3 +++
 libavutil/avstring.h |   34 ++++++++++++++++++++++++++++++++++
 libavutil/version.h  |    2 +-
 3 files changed, 38 insertions(+), 1 deletion(-)

Comments

Luca Barbato March 6, 2013, 2:41 p.m. | #1
On 06/03/13 14:56, Martin Storsjö wrote:
> From: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
> 
> ---
>  doc/APIchanges       |    3 +++
>  libavutil/avstring.h |   34 ++++++++++++++++++++++++++++++++++
>  libavutil/version.h  |    2 +-
>  3 files changed, 38 insertions(+), 1 deletion(-)
> 

Ok.

lu

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index b58f4da..d7d95df 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@  libavutil:     2012-10-22
 
 API changes, most recent first:
 
+2013-xx-xx - xxxxxxx - lavu 52.8.0 - avstring.h
+  Add av_isdigit, av_isgraph, av_isspace, av_isxdigit.
+
 2013-xx-xx - xxxxxxx - lavfi 3.4.0 - avfiltergraph.h
   Add resample_lavr_opts to AVFilterGraph for setting libavresample options
   for auto-inserted resample filters.
diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index e0e6ed2..6fbb519 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -152,6 +152,31 @@  char *av_d2str(double d);
 char *av_get_token(const char **buf, const char *term);
 
 /**
+ * Locale-independent conversion of ASCII isdigit.
+ */
+static inline int av_isdigit(int c)
+{
+    return c >= '0' && c <= '9';
+}
+
+/**
+ * Locale-independent conversion of ASCII isgraph.
+ */
+static inline int av_isgraph(int c)
+{
+    return c > 32 && c < 127;
+}
+
+/**
+ * Locale-independent conversion of ASCII isspace.
+ */
+static inline int av_isspace(int c)
+{
+    return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' ||
+           c == '\v';
+}
+
+/**
  * Locale-independent conversion of ASCII characters to uppercase.
  */
 static inline int av_toupper(int c)
@@ -171,6 +196,15 @@  static inline int av_tolower(int c)
     return c;
 }
 
+/**
+ * Locale-independent conversion of ASCII isxdigit.
+ */
+static inline int av_isxdigit(int c)
+{
+    c = av_tolower(c);
+    return av_isdigit(c) || (c >= 'a' && c <= 'z');
+}
+
 /*
  * Locale-independent case-insensitive compare.
  * @note This means only ASCII-range characters are case-insensitive
diff --git a/libavutil/version.h b/libavutil/version.h
index 8d7e378..38b11a4 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -37,7 +37,7 @@ 
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR  7
+#define LIBAVUTIL_VERSION_MINOR  8
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \