commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r804671 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_sbuf.h shared/sbuf.c
Date Sun, 16 Aug 2009 11:44:51 GMT
Author: mturk
Date: Sun Aug 16 11:44:50 2009
New Revision: 804671

URL: http://svn.apache.org/viewvc?rev=804671&view=rev
Log:
Add sbuf_ltim

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h
    commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h?rev=804671&r1=804670&r2=804671&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h Sun Aug 16 11:44:50 2009
@@ -80,7 +80,8 @@
 int      acr_sbuf_printf(acr_sbuf_t *, const char *, ...);
 int      acr_sbuf_vprintf(acr_sbuf_t *, const char *, va_list);
 int      acr_sbuf_putc(acr_sbuf_t *, int);
-int      acr_acr_sbuf_trim(acr_sbuf_t *);
+int      acr_sbuf_rtrim(acr_sbuf_t *);
+char    *acr_sbuf_ltrim(acr_sbuf_t *);
 int      acr_sbuf_overflowed(acr_sbuf_t *);
 void     acr_sbuf_finish(acr_sbuf_t *);
 char    *acr_sbuf_data(acr_sbuf_t *);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c?rev=804671&r1=804670&r2=804671&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c Sun Aug 16 11:44:50 2009
@@ -379,7 +379,7 @@
  * Trim whitespace characters from end of an sbuf.
  */
 int
-acr_sbuf_trim(acr_sbuf_t *s)
+acr_sbuf_rtrim(acr_sbuf_t *s)
 {
 
     assert_sbuf_integrity(s);
@@ -395,6 +395,29 @@
 }
 
 /*
+ * Return pointer to the first non white space character
+ * in sbuf. The acr_sbuf_finish must be called before this
+ * function
+ */
+char *
+acr_sbuf_ltrim(acr_sbuf_t *s)
+{
+
+    char *p = s->s_buf;
+    assert_sbuf_integrity(s);
+    assert_sbuf_state(s, 0);
+
+    if (SBUF_HASOVERFLOWED(s))
+        return NULL;
+    if (!SBUF_ISFINISHED(s))
+        return p;
+    while (*p && acr_isspace(*p))
+        p++;
+
+    return p;
+}
+
+/*
  * Check if an sbuf overflowed
  */
 int



Mime
View raw message