Skip to content

Commit 3db27cd

Browse files
committed
Simplify, update Changes
1 parent caf8ef1 commit 3db27cd

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Changes

+6-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ Working version
4747
(Sébastien Briais, review by Daniel Buenzli, Alain Frisch and
4848
Gabriel Scherer)
4949

50+
- PR#7515, GPR#1147: Arg.align now optionally uses the tab character '\t' to
51+
separate the "unaligned" and "aligned" parts of the documentation string. If
52+
tab is not present, then space is used as a fallback. Allows to have spaces in
53+
the unaligned part, which is useful for Tuple options.
54+
(Nicolas Ojeda Bar, review by Alain Frisch and Gabriel Scherer)
55+
5056
- GPR#1034: Add List.init
5157
(Richard Degenne, review by David Allsopp, Thomas Braibant, Florian
5258
Angeletti, Gabriel Scherer, Nathan Moreau, Alain Frisch)
@@ -61,11 +67,6 @@ Working version
6167

6268
- Resurrect tabulation boxes in module Format. Rewrite/extend documentation
6369
of tabulation boxes.
64-
- PR#7515, GPR#1147: Arg.align now optionally uses the tab character '\t' to
65-
separate the "unaligned" and "aligned" parts of the documentation string. If
66-
tab is not present, then space is used as a fallback. Allows to have spaces in the
67-
unaligned part, which is useful for Tuple options.
68-
(Nicolas Ojeda Bar, review by ...)
6970

7071
### Compiler user-interface and warnings:
7172

stdlib/arg.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ let second_word s =
313313
| n -> loop (n+1)
314314
| exception Not_found ->
315315
begin match String.index s ' ' with
316-
| n -> loop n
316+
| n -> loop (n+1)
317317
| exception Not_found -> len
318318
end
319319

@@ -324,9 +324,9 @@ let max_arg_len cur (kwd, spec, doc) =
324324
| _ -> max cur (String.length kwd + second_word doc)
325325

326326

327-
let replace_leading_tab s n =
327+
let replace_leading_tab s =
328328
let seen = ref false in
329-
String.init n (fun i -> match s.[i] with '\t' when not !seen -> seen := true; ' ' | c -> c)
329+
String.map (function '\t' when not !seen -> seen := true; ' ' | c -> c) s
330330

331331
let add_padding len ksd =
332332
match ksd with
@@ -337,16 +337,16 @@ let add_padding len ksd =
337337
| (kwd, (Symbol _ as spec), msg) ->
338338
let cutcol = second_word msg in
339339
let spaces = String.make ((max 0 (len - cutcol)) + 3) ' ' in
340-
(kwd, spec, "\n" ^ spaces ^ replace_leading_tab msg (String.length msg))
340+
(kwd, spec, "\n" ^ spaces ^ replace_leading_tab msg)
341341
| (kwd, spec, msg) ->
342342
let cutcol = second_word msg in
343343
let kwd_len = String.length kwd in
344344
let diff = len - kwd_len - cutcol in
345345
if diff <= 0 then
346-
(kwd, spec, replace_leading_tab msg (String.length msg))
346+
(kwd, spec, replace_leading_tab msg)
347347
else
348348
let spaces = String.make diff ' ' in
349-
let prefix = replace_leading_tab msg cutcol in
349+
let prefix = String.sub (replace_leading_tab msg) 0 cutcol in
350350
let suffix = String.sub msg cutcol (String.length msg - cutcol) in
351351
(kwd, spec, prefix ^ spaces ^ suffix)
352352

0 commit comments

Comments
 (0)