text stringlengths 0 234 |
|---|
end if; |
if In_A_File then |
if Listing then |
Ada.Text_IO.Put_Line (" " & Unsigned_32'Image (Total_File_Size) & " bytes"); |
end if; |
Total_File_Size := 0; |
In_A_File := False; |
else |
if Working_Dir /= Base_Dir then -- Don't go up from start dir |
declare lastSlash : constant Natural := Ada.Strings.Unbounded.Index (Working_Dir, "/", Ada.Strings.Backward); |
begin |
Working_Dir := Head (Working_Dir, lastSlash - 1); |
Function Definition: procedure Ada_Split is |
Function Body: src : File_Type; |
max_recurse_depth : Constant := 10; |
recurse_depth : Integer := 0; |
src_file_name : String := read_command_arg ('i',"<no-source>"); |
out_file_name : String := read_command_arg ('o',"<no-output>"); |
type tag_type is (beg_tag, end_tag, neither); |
function Path_Exists (the_path_name : string) return boolean renames Ada.Directories.Exists; |
function File_Exists (the_file_name : string) return boolean renames Ada.Directories.Exists; |
procedure write_file |
(parent : String; -- " -- beg03: foo/bah/cat.tex" |
child : String) -- " --- beg04: foo/bah/moo/cow/dog.tex" |
is |
re_beg_tag : String := "^[\t ]*(--|#|%) beg[0-9]{2}:"; |
re_end_tag : String := "^[\t ]*(--|#|%) end[0-9]{2}:"; |
function full_dir (text : String) return String is -- text := " -- beg01: ./foo/bah/cat.tex" |
re_dirname : String := "([_a-zA-Z0-9./-]*\/)"; -- as per dirname in bash |
begin |
return grep (text,re_dirname,1,fail => ""); -- returns "./foo/bah/" |
end full_dir; |
function full_file (text : String) return String is -- text := " -- beg01: ./foo/bah/cat.tex" |
re_file : String := re_beg_tag & " (.+)"; |
begin |
return grep (text,re_file,2,fail => ""); -- returns "./foo/bah/cat.tex" |
end full_file; |
function relative_path |
(parent : String; -- " -- beg03: foo/bah/cat.tex" |
child : String) -- " -- beg04: foo/bah/moo/cow/dog.tex" |
Return String -- relative path of the child to the parent, e.g., "moo/cow/dog.tex" |
is |
re_dirname : String := "([_a-zA-Z0-9./-]*\/)"; -- as per dirname in bash |
re_basename : String := re_beg_tag & " " &re_dirname & "(.+)"; -- as per basename in bash |
parent_dir : String := trim ( grep (parent,re_dirname,1,fail => "./") ); -- "foo/bah/" |
child_dir : String := trim ( grep (child,re_dirname,1,fail => "./") ); -- "foo/bah/moo/cow/" |
child_file : String := trim ( grep (child,re_basename,3,fail => "??.txt") ); -- "dog.tex" |
begin |
-- strip parent_directory from front of child |
return trim ( child_dir(child_dir'first+get_strlen(parent_dir)..child_dir'last)&str(child_file) ); -- "moo/cow/dog.tex" |
end relative_path; |
function absolute_indent (text : String) return Integer is |
indent : Integer; |
begin |
indent := 0; |
for i in text'Range loop |
if text (i) /= ' ' then |
indent := max(0,i-1); |
exit; |
end if; |
end loop; |
return indent; |
end absolute_indent; |
function relative_indent |
(parent : String; |
child : String) |
Return Integer |
is |
begin |
return absolute_indent(child) - absolute_indent(parent); |
end relative_indent; |
function classify (the_line : String) return tag_type is |
begin |
if grep (the_line,re_beg_tag) then return beg_tag; |
elsif grep (the_line,re_end_tag) then return end_tag; |
else return neither; |
end if; |
end classify; |
begin |
recurse_depth := recurse_depth + 1; |
if recurse_depth > max_recurse_depth then |
Put_Line ("> split-mrg: Recursion limit reached (max = "&str(max_recurse_depth)&"), exit"); |
halt(1); |
end if; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.