comp.lang.ada
 help / color / mirror / Atom feed
From: lutz@iks-jena.de (Lutz Donnerhacke)
Subject: Re: Regex and/or LaTeX
Date: 26 Feb 2001 11:48:06 GMT
Date: 2001-02-26T11:48:06+00:00	[thread overview]
Message-ID: <slrn99kgea.lt.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: 978ke2$4pi$2@drcomp.erfurt.thur.de

* Adrian Knoth wrote:
>   procedure texstring (ausdruck : in out ustring) is
>      tmp : string := To_string(ausdruck);
>      hs : ustring := To_Ustring("");
>   begin
>      ausdruck := To_ustring("");
>      for I in tmp'range loop
>         case tmp(I) is
>            when '&' => hs := To_Ustring("\&");
>            when '%' => hs := To_Ustring("\%");
>            when others => hs := To_Ustring(tmp(I) & "");
>         end case;
>         ausdruck := ausdruck & hs;
>      end loop;
>   end texstring;

This seems to be Perl Style.

function texify (ausdruck      : String;
                 escape_char   : Character := '\\';
                 to_be_escaped : String    := "\\{}[]%^_") return String is
   pattern : Ada.Strings.Maps.Character_Set :=
             Ada.Strings.Maps.To_Set (to_be_escaped);
   i       : Ada.Strings.Fixed.Index (ausdruck, pattern);
begin
   if i = 0 then
      return ausdruck;
   elsif i = ausdruck'Last then
      return ausdruck (ausdruck'First .. i - 1) & escape_char & ausdruck (i);
   else
      return ausdruck (ausdruck'First .. i - 1) & escape_char & ausdruck (i) &
             texify (ausdruck (i + 1 .. ausdruck'Last),
                     escape_char, to_be_escaped);
   end if;
end texify;



  parent reply	other threads:[~2001-02-26 11:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-22 11:01 Regex and/or LaTeX Adrian Knoth
2001-02-23  8:13 ` Lutz Donnerhacke
2001-02-23  9:41 ` Florian Weimer
2001-02-24  2:59 ` Rajagopalan Srinivasan
2001-02-24 15:36   ` Adrian Knoth
2001-02-26 11:41     ` Lutz Donnerhacke
2001-02-26 11:48     ` Lutz Donnerhacke [this message]
2001-02-26 20:15       ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox