Browse Source

Fix encoding of empty strings

git-svn-id: https://klish.googlecode.com/svn/trunk@487 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
224f0f4ae2
2 changed files with 4 additions and 2 deletions
  1. 1 1
      clish/shell/shell_var.c
  2. 3 1
      lub/string/string_escape.c

+ 1 - 1
clish/shell/shell_var.c

@@ -208,7 +208,7 @@ static char *expand_nextsegment(const char **string, const char *escape_chars,
 			for (q = strtok_r(text, ":", &saveptr);
 				q; q = strtok_r(NULL, ":", &saveptr)) {
 				char *var;
-				int mod_quote = 0; /* quoute modifier */
+				int mod_quote = 0; /* quote modifier */
 				int mod_esc = 0; /* escape modifier */
 				char *space;
 

+ 3 - 1
lub/string/string_escape.c

@@ -70,7 +70,9 @@ char *lub_string_encode(const char *string, const char *escape_chars)
 	const char *p;
 
 	if (!escape_chars)
-		lub_string_dup(string);
+		return lub_string_dup(string);
+	if (string && !(*string)) /* Empty string */
+		return lub_string_dup(string);
 
 	for (p = string; p && *p; p++) {
 		/* find any special characters and prefix them with '\' */