comp.lang.ada
 help / color / mirror / Atom feed
From: reinert <reinkor@gmail.com>
Subject: Easiest way to use regular expressions?
Date: Sun, 27 Dec 2020 00:14:35 -0800 (PST)	[thread overview]
Message-ID: <a24a0644-0441-4e12-af87-c6b6217b786dn@googlegroups.com> (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

                 reply	other threads:[~2020-12-27  8:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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