From 4fed302df0df875a1959e72ca1e747ed30ceb4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 25 Jun 2011 11:09:17 -0300 Subject: [PATCH] Properly fix line break in strings. --- lib/string.ex | 2 +- test/elixir/string_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/string.ex b/lib/string.ex index 0dc29cdb91..8a91e849bc 100644 --- a/lib/string.ex +++ b/lib/string.ex @@ -169,7 +169,7 @@ module String def inspect list = Erlang.binary_to_list(self) if Erlang.io_lib.printable_unicode_list(list) - <<$\", gsub(~r{("|#|\n|\r)}, "\\\\\\1")|binary, $\">> + <<$\", gsub(~r{("|#)}, "\\\\\\1").gsub(~r{\n}, "\\\\n")|binary, $\">> else Erlang.io_lib.format($"~w", [self]).to_bin end diff --git a/test/elixir/string_test.exs b/test/elixir/string_test.exs index 65afc505ba..d01ba49310 100644 --- a/test/elixir/string_test.exs +++ b/test/elixir/string_test.exs @@ -97,7 +97,7 @@ three "<<1,2,3>>" = <<1,2,3>>.inspect "\"f\\\"o\\\"o\"" = "f\"o\"o".inspect "\"f\\\#o\"" = "f#o".inspect - "\"f\\\no\"" = "f\no".inspect + "\"f\\no\"" = "f\no".inspect end def to_atom_test