let eval_executable status (mathviewer:MatitaTypes.mathViewer) urichooser
-user_goal parsed_text script ex =
+ask_confirmation user_goal parsed_text script ex =
let module TA = TacticAst in
let module TAPp = TacticAstPp in
let module MD = MatitaDisambiguator in
let parsed_text_length = String.length parsed_text in
match ex with
| TA.Command (loc, _) | TA.Tactical (loc, _) ->
- eval_with_engine status user_goal parsed_text
- (TA.Executable (loc, ex))
+ (match MatitacleanLib.baseuri_of_baseuri_decl (TA.Executable (loc,ex))with
+ | None -> ()
+ | Some u ->
+ if not (MatitacleanLib.is_empty u) then
+ match
+ ask_confirmation
+ ~title:"Baseuri redefinition"
+ ~message:(
+ "Baseuri " ^ u ^ " already exists.\n" ^
+ "Do you want to redefine the corresponding "^
+ "part of the library?")
+ with
+ | `YES -> MatitacleanLib.clean_baseuris [u]
+ | `NO -> ()
+ | `CANCEL -> raise MatitaTypes.Cancel);
+ eval_with_engine status user_goal parsed_text (TA.Executable (loc, ex))
| TA.Macro (_,mac) ->
eval_macro status mathviewer urichooser parsed_text script mac
-let rec eval_statement status (mathviewer:MatitaTypes.mathViewer)
- urichooser user_goal script s
-=
+let rec eval_statement status (mathviewer:MatitaTypes.mathViewer) urichooser
+ask_confirmation user_goal script s =
if Pcre.pmatch ~rex:only_dust_RE s then raise Margin;
let st = CicTextualParser2.parse_statement (Stream.of_string s) in
let text_of_loc loc =
let remain_len = String.length s - parsed_text_length in
let s = String.sub s parsed_text_length remain_len in
let s,len =
- eval_statement status mathviewer urichooser user_goal script s
+ eval_statement status
+ mathviewer urichooser ask_confirmation user_goal script s
in
(match s with
| (status, text) :: tl ->
| [] -> [], 0)
| TacticAst.Executable (loc, ex) ->
let parsed_text, parsed_text_length = text_of_loc loc in
- eval_executable status mathviewer urichooser user_goal
- parsed_text script ex
+ eval_executable
+ status mathviewer urichooser ask_confirmation
+ user_goal parsed_text script ex
let fresh_script_id =
let i = ref 0 in
class script ~(buffer: GText.buffer) ~(init: MatitaTypes.status)
~(mathviewer: MatitaTypes.mathViewer)
~set_star
+ ~ask_confirmation
~urichooser () =
object (self)
val mutable filename = None
let s = match statement with Some s -> s | None -> self#getFuture in
MatitaLog.debug ("evaluating: " ^ first_line s ^ " ...");
let (entries, parsed_len) =
- eval_statement self#status mathviewer urichooser userGoal self s in
+ eval_statement self#status
+ mathviewer urichooser ask_confirmation userGoal self s
+ in
let (new_statuses, new_statements) = List.split entries in
(*
prerr_endline "evalStatement returned";
let _script = ref None
-let script ~buffer ~init ~mathviewer ~urichooser ~set_star () =
- let s = new script ~buffer ~init ~mathviewer ~urichooser ~set_star () in
+let script ~buffer ~init ~mathviewer ~urichooser ~ask_confirmation ~set_star ()
+=
+ let s = new script
+ ~buffer ~init ~mathviewer ~ask_confirmation ~urichooser ~set_star ()
+ in
_script := Some s;
s
module HGT = Http_getter_types;;
module HG = Http_getter;;
+module HGM = Http_getter_misc;;
module UM = UriManager;;
module TA = TacticAst;;
+let baseuri_of_baseuri_decl st =
+ let module TA = TacticAst in
+ match st with
+ | TA.Executable (_, TA.Command (_, TA.Set (_, "baseuri", buri))) ->
+ Some buri
+ | _ -> None
+
let cache_of_processed_baseuri = Hashtbl.create 1024
let one_step_depend suri =
let buri = Mysql.escape buri in
let obj_tbl = MetadataTypes.obj_tbl () in
Printf.sprintf
- "SELECT source FROM %s WHERE h_occurrence LIKE '%s%%'" obj_tbl buri
+ "SELECT source, h_occurrence FROM %s WHERE h_occurrence LIKE '%s%%'" obj_tbl buri
in
try
let rc = Mysql.exec (MatitaDb.instance ()) query in
let l = ref [] in
- Mysql.iter rc (fun a -> match a.(0) with None ->()|Some a -> l:=a:: !l);
+ Mysql.iter rc (
+ fun row ->
+ match row.(0), row.(1) with
+ | Some uri, Some occ when Filename.dirname occ = buri ->
+ l := uri :: !l
+ | _ -> ());
let l = List.sort Pervasives.compare !l in
MatitaMisc.list_uniq l
with
close_in ic;
let uri = ref "" in
List.iter
- (function
- | TA.Executable (_, TA.Command (_, TA.Set (_, "baseuri", buri))) ->
- uri := MatitaMisc.strip_trailing_slash buri
- | _ -> ())
+ (fun stm ->
+ match baseuri_of_baseuri_decl stm with
+ | Some buri -> uri := MatitaMisc.strip_trailing_slash buri
+ | None -> ())
stms;
!uri
| l -> let uris, next = close_uri_list l in fix uris next @ uris
let clean_baseuris buris =
+ let buris = List.map HGM.strip_trailing_slash buris in
+(* List.iter prerr_endline buris;*)
let l = fix [] buris in
let l = MatitaMisc.list_uniq (List.fast_sort Pervasives.compare l) in
let l = List.map UriManager.uri_of_string l in
List.iter MatitaSync.remove l
+let is_empty buri = HG.ls (HGM.strip_trailing_slash buri ^ "/") = []
+