[clinfo] 78/148: Skip leading whitespaces in strings

Andreas Beckmann anbe at moszumanska.debian.org
Mon Nov 17 14:09:48 UTC 2014


This is an automated email from the git hooks/post-receive script.

anbe pushed a commit to branch clinfo
in repository clinfo.

commit acad10eda691af35780838a0d2e71ab49184639a
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date:   Thu Oct 16 09:06:05 2014 +0200

    Skip leading whitespaces in strings
---
 src/clinfo.c |  2 +-
 src/strbuf.h | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/clinfo.c b/src/clinfo.c
index 6482825..6a19ec2 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -60,7 +60,7 @@ size_t wgm[NUM_KERNELS];
 #define I2_STR "    %-44s  "
 
 #define STR_PRINT(name, str) \
-	printf(I1_STR "%s\n", name, str)
+	printf(I1_STR "%s\n", name, skip_leading_ws(str))
 
 #define SHOW_STRING(cmd, param, name, ...) do { \
 	GET_STRING(cmd, param, #param, __VA_ARGS__); \
diff --git a/src/strbuf.h b/src/strbuf.h
index 35dc6b2..427086c 100644
--- a/src/strbuf.h
+++ b/src/strbuf.h
@@ -1,6 +1,9 @@
 /* multi-purpose string strbuf, will be initialized to be
  * at least 1024 bytes long.
  */
+
+#include <ctype.h>
+
 char *strbuf;
 size_t bufsz, nusz;
 
@@ -15,4 +18,11 @@ size_t bufsz, nusz;
 	REPORT_ERROR("get " param_str); \
 } while (0)
 
+/* Skip leading whitespace in a string */
+static inline const char* skip_leading_ws(const char *str)
+{
+	const char *ret = str;
+	while (isspace(*ret)) ++ret;
+	return ret;
+}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/clinfo.git



More information about the Pkg-opencl-commits mailing list