Commits

"Rör...@gmail.com>"  committed 64eb3be

insert_ref doesn't return the new n anymore.

  • Participants
  • Parent commits ca36e33

Comments (0)

Files changed (1)

File footnotes.ml

       else malformed_foot l;
       process_foots inc process_foot malformed_foot
 
-(* insert a new reference for old_n into refs and return the new n *)
+(* insert a new reference for old_n into refs *)
 let insert_ref refs old_n =
-  let n = Hashtbl.length refs + 1 in
-  Hashtbl.add refs old_n n;
-  n
+  Hashtbl.add refs old_n (Hashtbl.length refs + 1)
 
 (* renumber and reorder the footnotes by their appearance in the body *)
 let renumber_by_body inc outc =
   let refs = Hashtbl.create 1000000 in
-  let new_ref old_n = ref_of_int (insert_ref refs old_n) in
+  let new_ref old_n =
+    insert_ref refs old_n;
+    ref_of_int (Hashtbl.find refs old_n) in
   process_body inc outc refs new_ref;
   let foots = Array.make (Hashtbl.length refs) None in
   let add_foot l old_n =
   while input_line inc <> sep_line do () done; (* skip the body *)
   let refs = Hashtbl.create 1000000 in
   let add_foot_ref _ old_n =
-    if not (Hashtbl.mem refs old_n) then
-      ignore (insert_ref refs old_n) in
+    if not (Hashtbl.mem refs old_n) then insert_ref refs old_n in
   process_foots inc add_foot_ref ignore;
   seek_in inc 0;			(* back to beginning *)
   process_body inc outc refs (function _ -> "[?]");