@@ -33,6 +33,8 @@ open CHPretty
3333
3434(* chutil *)
3535open CHPrettyUtil
36+ open CHTraceResult
37+
3638
3739exception CHIOFailure of string
3840
@@ -242,7 +244,7 @@ let absolute_name (s: string): string =
242244 s
243245
244246
245- let rec normalize_path (s : string ): string =
247+ let rec normalize_path (s : string ): string traceresult =
246248 let has_directory_dot s =
247249 (String. contains s '.' )
248250 && (let dotindex = String. index s '.' in
@@ -252,7 +254,7 @@ let rec normalize_path (s: string): string =
252254 || ((slashindex - dotindex = 2 ) && String. get s (dotindex+ 1 ) = '.' ))) in
253255 let len = String. length s in
254256 if len < = 1 then
255- s
257+ Ok s
256258 else
257259 if has_directory_dot s then
258260 let dotindex = String. index s '.' in
@@ -268,16 +270,16 @@ let rec normalize_path (s: string): string =
268270 normalize_path (String. concat " " [s1; s2])
269271 else if slsindex > 0 then
270272 normalize_path (String. sub s (dotindex + 3 ) (len - (dotindex + 3 )))
271- else (* no second slash found *)
272- raise ( CHFailure ( LBLOCK [ STR " Error in normalize_path: " ; STR s]))
273+ else (* no second slash found *)
274+ Error [ " normalize_path: " ^ s ^ " ; expected second slash " ]
273275 else (* no first slash found *)
274- raise ( CHFailure ( LBLOCK [ STR " Error in normalize_path: " ; STR s]))
276+ Error [ " normalize_path: " ^ s ^ " ; expected a slash " ]
275277 else (* just one dot *)
276278 if dotindex + 1 < len && String. get s (dotindex+ 1 ) = '/' then
277279 let s1 = String. sub s 0 dotindex in
278280 let s2 = String. sub s (dotindex + 2 ) (len - (dotindex + 2 )) in
279281 normalize_path (String. concat " " [s1; s2])
280282 else
281- raise ( CHFailure ( LBLOCK [ STR " Error in normalize_path: " ; STR s]))
283+ Error [ " normalize_path: " ^ s ^ " ; multiple dots " ]
282284 else (* no dots *)
283- s
285+ Ok s
0 commit comments