Browse Source

removed regexp_matched

Nicolas Cannasse 9 years ago
parent
commit
d7bf55758b
2 changed files with 5 additions and 18 deletions
  1. 1 11
      genhl.ml
  2. 4 7
      std/hl/_std/EReg.hx

+ 1 - 11
genhl.ml

@@ -5142,16 +5142,6 @@ let interp code =
 					| None -> to_int (-1)
 					| None -> to_int (-1)
 					| Some (pos,pend) -> regs.(rlen) <- to_int (pend - pos); to_int pos)
 					| Some (pos,pend) -> regs.(rlen) <- to_int (pend - pos); to_int pos)
 				| _ -> assert false)
 				| _ -> assert false)
-			| "regexp_matched" ->
-				(function
-				| [VAbstract (AReg r); VInt n; VRef (regs,rlen,HI32)] ->
-					let n = int n in
-					(match (try r.r_groups.(n) with _ -> failwith ("Invalid group " ^ string_of_int n)) with
-					| None -> VNull
-					| Some (pos,pend) ->
-						regs.(rlen) <- to_int (pend - pos);
-						VBytes (caml_to_hl (String.sub r.r_string pos (pend - pos))))
-				| _ -> assert false)
 			| _ ->
 			| _ ->
 				unresolved())
 				unresolved())
 		| _ ->
 		| _ ->
@@ -5829,7 +5819,7 @@ let write_c version ch (code:code) =
 			let c = String.get s i in
 			let c = String.get s i in
 			string_of_int (int_of_char c) :: loop (i+1)
 			string_of_int (int_of_char c) :: loop (i+1)
 		in
 		in
-		sexpr "static vbyte string$%d[] = {%s} /* %s */" i (String.concat "," (loop 0)) (String.concat "* /" (ExtString.String.nsplit str "*/"))
+		sexpr "static vbyte string$%d[] = {%s} /* %s */" i (String.concat "," (loop 0)) (String.escaped (String.concat "* /" (ExtString.String.nsplit str "*/")))
 	) code.strings;
 	) code.strings;
 
 
 	let type_value t =
 	let type_value t =

+ 4 - 7
std/hl/_std/EReg.hx

@@ -47,9 +47,9 @@ private typedef ERegValue = hl.types.NativeAbstract<"ereg">;
 	}
 	}
 
 
 	public function matched( n : Int ) : String {
 	public function matched( n : Int ) : String {
-		var size = 0;
-		var m = regexp_matched(r,n,size);
-		return (m == null) ? null : String.__alloc__(m, size);
+		var len = 0;
+		var m = regexp_matched_pos(r,n,len);
+		return m < 0 ? null : last.substr(m, len);
 	}
 	}
 
 
 	public function matchedLeft() : String {
 	public function matchedLeft() : String {
@@ -67,6 +67,7 @@ private typedef ERegValue = hl.types.NativeAbstract<"ereg">;
 	public function matchedPos() : { pos : Int, len : Int } {
 	public function matchedPos() : { pos : Int, len : Int } {
 		var len = 0;
 		var len = 0;
 		var p = regexp_matched_pos(r, 0, len);
 		var p = regexp_matched_pos(r, 0, len);
+		if( p < 0 ) return null;
 		return { pos : p, len : len };
 		return { pos : p, len : len };
 	}
 	}
 
 
@@ -192,10 +193,6 @@ private typedef ERegValue = hl.types.NativeAbstract<"ereg">;
 		return false;
 		return false;
 	}
 	}
 
 
-	@:hlNative("regexp", "regexp_matched") static function regexp_matched( r : ERegValue, n : Int, size : hl.types.Ref<Int> ) : hl.types.Bytes {
-		return null;
-	}
-
 	@:hlNative("regexp", "regexp_matched_pos") static function regexp_matched_pos( r : ERegValue, n : Int, size : hl.types.Ref<Int> ) : Int {
 	@:hlNative("regexp", "regexp_matched_pos") static function regexp_matched_pos( r : ERegValue, n : Int, size : hl.types.Ref<Int> ) : Int {
 		return 0;
 		return 0;
 	}
 	}