Browse Source

Don't duplicate ^ and $ on regular exprs

Serj Kalichev 9 years ago
parent
commit
96fd88698a
2 changed files with 8 additions and 3 deletions
  1. 4 2
      clish/ptype/ptype.c
  2. 4 1
      clish/shell/shell_dump.c

+ 4 - 2
clish/ptype/ptype.c

@@ -482,9 +482,11 @@ clish_ptype__set_pattern(clish_ptype_t * this,
 		int result;
 
 		/* only the expression is allowed */
-		lub_string_cat(&this->pattern, "^");
+		if (pattern[0] != '^')
+			lub_string_cat(&this->pattern, "^");
 		lub_string_cat(&this->pattern, pattern);
-		lub_string_cat(&this->pattern, "$");
+		if (pattern[strlen(this->pattern) - 1] != '$')
+			lub_string_cat(&this->pattern, "$");
 
 		/* compile the regular expression for later use */
 		result = regcomp(&this->u.regexp, this->pattern,

+ 4 - 1
clish/shell/shell_dump.c

@@ -92,6 +92,9 @@ void clish_shell_xml2c(clish_shell_t *this)
 	}
 #endif
 
-	printf("\n}\n");
+	printf("\n"
+		"return 0;\n"
+		"}\n"
+		);
 }