At 11/07/2016 06:20 PM, David Sterba wrote:
On Thu, Nov 03, 2016 at 12:07:31PM +0800, Qu Wenruo wrote:
Introduce new function, escape_string_inplace(), to escape specified
characters in place.

Signed-off-by: Qu Wenruo <quwen...@cn.fujitsu.com>
---
 utils.c | 24 ++++++++++++++++++++++++
 utils.h | 14 ++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/utils.c b/utils.c
index 3f54245..3c50d84 100644
--- a/utils.c
+++ b/utils.c
@@ -4251,3 +4251,27 @@ unsigned int rand_range(unsigned int upper)
         */
        return (unsigned int)(jrand48(rand_seed) % upper);
 }
+
+static void escape_one_char(char *restrict string, char escape)
+{
+       int i = 0;
+       int j = 0;
+
+       while (string[j] != '\0') {
+               if (string[j] != escape) {
+                       string[i] = string[j];
+                       i++;
+               }

So how does this actually escape the characters? I don't see anything
inserted. I think we don't have a common understanding of what's
supposed to be done here. I mean C-string-like escaping. And this cannot
be done inplace, as it increases string length. I've implemented it in a
different way, so this patch is left out. The final stream dump output
is preserved.


And further more.

The new string escaping is screwing up original output.

Operation lile mkfile lacks the final '\n'.
String over the width will lack the ending ' ' to seperate later key=value pairs.

It would be better to output the escaped string into a buffer and still use printf() format to output them out as it used to be.

Thanks,
Qu


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to