From 47a73b5d8591f5405691f45ee0c5884807ea7471 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 7 Dec 2010 15:18:41 +0000 Subject: [PATCH] do not trim in split_quoted, that's expensive, and the caller can do it if his input is not clean git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9068 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/xbt/xbt_str.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xbt/xbt_str.c b/src/xbt/xbt_str.c index 6e520bcc43..36002e5074 100644 --- a/src/xbt/xbt_str.c +++ b/src/xbt/xbt_str.c @@ -319,9 +319,10 @@ xbt_dynar_t xbt_str_split_str(const char *s, const char *sep) /** @brief Splits a string into a dynar of strings, taking quotes into account * * It basically does the same argument separation than the shell, where white - * spaces can be escaped and where arguments are never splitted within a + * spaces can be escaped and where arguments are never split within a * quote group. * Several subsequent spaces are ignored (unless within quotes, of course). + * You may want to trim the input string, if you want to avoid empty entries * */ @@ -338,8 +339,7 @@ xbt_dynar_t xbt_str_split_quoted(const char *s) return res; beg = str_to_free = xbt_strdup(s); - /* trim leading spaces */ - xbt_str_ltrim(beg, " "); + /* do not trim leading spaces: caller responsability to clean his cruft */ end = beg; while (!done) { @@ -403,7 +403,9 @@ xbt_dynar_t xbt_str_split_quoted(const char *s) } beg = ++end; - xbt_str_ltrim(beg, " "); + /* trim within the string, manually to speed things up */ + while (*beg == ' ') + beg++; end = beg; } break; -- 2.20.1