Removed trimmed_string function and callers, and for now, use (left_|right_)adjust

This commit is contained in:
2013-10-23 12:46:36 +02:00
parent ddd19023b0
commit 4dd1731e60
2 changed files with 12 additions and 27 deletions

View File

@@ -12,30 +12,19 @@ inherit
feature {NONE} -- Helpers feature {NONE} -- Helpers
entity_value (a_str: READABLE_STRING_8): READABLE_STRING_8 entity_value (a_str: READABLE_STRING_8): STRING_8
-- `s' with any trailing parameters stripped -- `s' with any trailing parameters stripped
local local
p: INTEGER p: INTEGER
do do
p := a_str.index_of (';', 1) p := a_str.index_of (';', 1)
if p > 0 then if p > 0 then
Result := trimmed_string (a_str.substring (1, p - 1)) create Result.make_from_string (a_str.substring (1, p - 1))
else else
Result := trimmed_string (a_str.string) create Result.make_from_string (a_str)
end end
end
trimmed_string (a_string: READABLE_STRING_8): STRING_8
-- trim whitespace from the beginning and end of a string
-- `a_string'
require
valid_argument : a_string /= Void
do
create Result.make_from_string (a_string)
Result.left_adjust Result.left_adjust
Result.right_adjust Result.right_adjust
ensure
result_trimmed: a_string.has_substring (Result)
end end
note note

View File

@@ -30,15 +30,21 @@ feature {NONE} -- Initialization
-- necessary. -- necessary.
local local
i: INTEGER i: INTEGER
s: STRING
do do
fixme (generator + ".make_from_string: improve code!!!") fixme (generator + ".make_from_string: improve code!!!")
i := a_accept_language_item.index_of (';', 1) i := a_accept_language_item.index_of (';', 1)
if i > 0 then if i > 0 then
make_with_language (trimmed_string (a_accept_language_item.substring (1, i - 1))) create s.make_from_string (a_accept_language_item.substring (1, i - 1))
else
create s.make_from_string (a_accept_language_item)
end
s.left_adjust
s.right_adjust
make_with_language (s)
if i > 0 then
create parameters.make_from_substring (a_accept_language_item, i + 1, a_accept_language_item.count) create parameters.make_from_substring (a_accept_language_item, i + 1, a_accept_language_item.count)
check attached parameters as l_params and then not l_params.has_error end check attached parameters as l_params and then not l_params.has_error end
else
make_with_language (trimmed_string (a_accept_language_item))
end end
check quality_initialized_to_1: quality = 1.0 end check quality_initialized_to_1: quality = 1.0 end
@@ -222,16 +228,6 @@ feature {NONE} -- Implementation
end end
end end
feature {NONE} -- Helper
trimmed_string (s: READABLE_STRING_8): STRING_8
-- Copy of `s', where whitespace were stripped from the beginning and end of the string
do
create Result.make_from_string (s)
Result.left_adjust
Result.right_adjust
end
invariant invariant
valid_quality: 0.0 <= quality and quality <= 1.0 valid_quality: 0.0 <= quality and quality <= 1.0