From 4dd1731e60a700c74249c3043064f3e2638b7cad Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 23 Oct 2013 12:46:36 +0200 Subject: [PATCH] Removed trimmed_string function and callers, and for now, use (left_|right_)adjust --- .../src/parsers/http_header_utilities.e | 17 +++----------- .../src/results/http_accept_language.e | 22 ++++++++----------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/library/network/protocol/content_negotiation/src/parsers/http_header_utilities.e b/library/network/protocol/content_negotiation/src/parsers/http_header_utilities.e index 9f739088..99879284 100644 --- a/library/network/protocol/content_negotiation/src/parsers/http_header_utilities.e +++ b/library/network/protocol/content_negotiation/src/parsers/http_header_utilities.e @@ -12,30 +12,19 @@ inherit 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 local p: INTEGER do p := a_str.index_of (';', 1) 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 - Result := trimmed_string (a_str.string) + create Result.make_from_string (a_str) 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.right_adjust - ensure - result_trimmed: a_string.has_substring (Result) end note diff --git a/library/network/protocol/content_negotiation/src/results/http_accept_language.e b/library/network/protocol/content_negotiation/src/results/http_accept_language.e index 9b6b9be9..5c9b6638 100644 --- a/library/network/protocol/content_negotiation/src/results/http_accept_language.e +++ b/library/network/protocol/content_negotiation/src/results/http_accept_language.e @@ -30,15 +30,21 @@ feature {NONE} -- Initialization -- necessary. local i: INTEGER + s: STRING do fixme (generator + ".make_from_string: improve code!!!") i := a_accept_language_item.index_of (';', 1) 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) 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 check quality_initialized_to_1: quality = 1.0 end @@ -222,16 +228,6 @@ feature {NONE} -- Implementation 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 valid_quality: 0.0 <= quality and quality <= 1.0