From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Length of unbounded_string.
Date: Tue, 25 Oct 2011 10:57:53 -0700
Date: 2011-10-25T10:57:53-07:00 [thread overview]
Message-ID: <j871dj$9td$1@tornado.tornevall.net> (raw)
In-Reply-To: <4ea68441$0$8041$703f8584@textnews.kpn.nl>
On 10/25/2011 02:37 AM, ldries46 wrote:
> I just found the following extra relevant points:
> Instead of <Str := Str & " " & Next_Line;> I put in the line <Str := Str & "x "
> & Next_Line;>
> This showed that with Str := "str," en Next_Line := "Next" the output became
> "str x Next"
> When I changed Str to Str := "strx" the output changed to "strxx Next"
> This looks like the comma has a special meaning within an Unbounded String
No Character has a special meaning in a String or an Unbounded_String. This
appears to be a problem with the way you're viewing the contents.
with Ada.Strings.Unbounded;
with Ada.Text_IO;
procedure US_Test is
use Ada.Strings.Unbounded;
Str_Start : constant Unbounded_String := To_Unbounded_String ("str,");
Next_Line : constant Unbounded_String := To_Unbounded_String ("Next");
Str : Unbounded_String := Str_Start;
begin -- US_Test
Str := Str & " " & Next_Line;
Ada.Text_IO.Put_Line (Item => '>' & To_String (Str) & '<');
Str := Str_Start;
Str := Str & "x " & Next_Line;
Ada.Text_IO.Put_Line (Item => '>' & To_String (Str) & '<');
Str := To_Unbounded_String ("strx");
Str := Str & "x " & Next_Line;
Ada.Text_IO.Put_Line (Item => '>' & To_String (Str) & '<');
end US_Test;
jrcarter@jrcarter-gateway-1:~/Code$ gnatmake -gnaton -O2 -j2 us_test.adb
gcc-4.4 -c -gnaton -O2 us_test.adb
gnatbind -x us_test.ali
gnatlink us_test.ali
jrcarter@jrcarter-gateway-1:~/Code$ ./us_test
>str, Next<
>str,x Next<
>strxx Next<
This is GNAT 4.4.5 on Ubuntu 11.04. If this program gives different results on
your system, let us know.
--
Jeff Carter
"Blessed are they who convert their neighbors'
oxen, for they shall inhibit their girth."
Monty Python's Life of Brian
83
next prev parent reply other threads:[~2011-10-25 17:57 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-25 9:37 Length of unbounded_string ldries46
2011-10-25 17:57 ` Jeffrey Carter [this message]
2011-10-28 2:54 ` ldries46
2011-10-28 4:55 ` Jeffrey Carter
2011-10-25 20:23 ` Vadim Godunko
2011-10-25 21:28 ` Simon Wright
2011-10-26 4:41 ` Simon Wright
2011-10-26 22:47 ` Randy Brukardt
2011-10-27 8:05 ` AdaMagica
2011-10-27 8:56 ` Simon Wright
2011-10-27 11:05 ` Brian Drummond
2011-10-28 3:12 ` ldries46
[not found] ` <4eafc489$0$3081$703f8584@textnews.kpn.nl>
2011-11-01 18:22 ` Jeffrey Carter
2011-10-27 11:28 ` Georg Bauhaus
2011-10-27 12:17 ` Dmitry A. Kazakov
2011-10-27 13:31 ` Georg Bauhaus
2011-10-27 14:34 ` Dmitry A. Kazakov
-- strict thread matches above, loose matches on Subject: below --
2011-10-16 8:48 ldries46
2011-10-16 9:59 ` Niklas Holsti
2011-10-16 12:06 ` ldries46
2011-10-16 12:52 ` ldries46
2011-10-16 13:00 ` Niklas Holsti
2011-10-17 7:39 ` ldries46
2011-10-17 19:49 ` Niklas Holsti
2011-10-18 11:47 ` ldries46
2011-10-18 17:54 ` Niklas Holsti
2011-10-19 2:38 ` ldries46
2011-10-19 6:07 ` Niklas Holsti
2011-10-24 15:10 ` ldries46
2011-10-19 6:37 ` Simon Wright
2011-10-19 14:48 ` Alex Mentis
2011-10-24 17:04 ` ldries46
2011-10-16 10:14 ` Vinzent Hoefler
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox