comp.lang.ada
 help / color / mirror / Atom feed
* Easiest way to use regular expressions?
@ 2020-12-27  8:14 reinert
  0 siblings, 0 replies; only message in thread
From: reinert @ 2020-12-27  8:14 UTC (permalink / raw)


Hello,

I made the following hack to match a string with a regular expression
(using a named pipe and grep under linux):

   procedure to_os (str : String) is
     package c renames Interfaces.C;
     procedure system_rk (source : in c.char_array);
     pragma Import (c, system_rk, "system");
   begin
     system_rk (Interfaces.C.To_C (str));
   end to_os;

   function match1(S : String; P : String) return boolean is
     cfile1 : constant String := "regexp_pipe0";
     file1  : File_Type;
     str1   : constant String := "echo " & S & "| grep -ic " & P;
   begin
     to_os(str1 & " > regexp_pipe0 &" );
     Open(file1,In_File,cfile1);
     return b : constant boolean := Natural'Value(get_line(file1)) > 0 do
        Close(file1);
     end return;
   end match1;
-----------------------------------------
OK, I assume it somehow breaks the philosophy on Ada and security/reliability. Could someone therefore show a better and more simple way to do this? gnat.expect?

reinert

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-27  8:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-27  8:14 Easiest way to use regular expressions? reinert

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