@@ -215,7 +215,7 @@ let iter_on_format_args fmt add_conv add_char =
215
215
and scan_conv skip i =
216
216
if i > lim then incomplete_format fmt else
217
217
match Sformat. unsafe_get fmt i with
218
- | '%' | '!' -> succ i
218
+ | '%' | '!' | ',' -> succ i
219
219
| 's' | 'S' | '[' -> add_conv skip i 's'
220
220
| 'c' | 'C' -> add_conv skip i 'c'
221
221
| 'd' | 'i' | 'o' | 'u' | 'x' | 'X' | 'N' -> add_conv skip i 'i'
@@ -431,8 +431,6 @@ let get_index spec n =
431
431
(* Format a float argument as a valid Caml lexeme. *)
432
432
let format_float_lexeme =
433
433
434
- let lexeme_buff = Buffer. create 32 in
435
-
436
434
(* To be revised: this procedure should be a unique loop that performs the
437
435
validity check and the string lexeme modification at the same time.
438
436
Otherwise, it is too difficult to handle the strange padding facilities
@@ -446,35 +444,12 @@ let format_float_lexeme =
446
444
*)
447
445
448
446
let make_valid_float_lexeme s =
449
- let l = String. length s in
450
- (* This should never occur. *)
451
- if l = 0 then " nan" else
452
-
453
- let add_dot s i =
454
- let rec add_dot_loop i =
455
- if i > = l then Buffer. add_char lexeme_buff '.' else
456
- match s.[i] with
457
- | '+' ->
458
- (* Depending of the ``style'' this should be a space or a 0.
459
- Let start by using a space. *)
460
- Buffer. add_char lexeme_buff ' ' ;
461
- add_dot_loop (i + 1 )
462
- | c ->
463
- Buffer. add_char lexeme_buff c;
464
- add_dot_loop (i + 1 ) in
465
- add_dot_loop i in
466
-
467
447
(* Check if s is already a valid lexeme:
468
448
in this case do nothing (we should still remove a leading +!),
469
449
otherwise turn s into a valid Caml lexeme. *)
450
+ let l = String. length s in
470
451
let rec valid_float_loop i =
471
- if i > = l then begin
472
- Buffer. clear lexeme_buff;
473
- add_dot s 0 ;
474
- let res = Buffer. contents lexeme_buff in
475
- Buffer. clear lexeme_buff;
476
- res
477
- end else
452
+ if i > = l then s ^ " ." else
478
453
match s.[i] with
479
454
(* Sure, this is already a valid float lexeme. *)
480
455
| '.' | 'e' | 'E' -> s
@@ -598,6 +573,7 @@ let scan_format fmt args n pos cont_s cont_a cont_t cont_f cont_m =
598
573
let s = format_int (extract_format_int 'n' fmt pos i widths) x in
599
574
cont_s (next_index spec n) s (succ i)
600
575
end
576
+ | ',' -> cont_s n " " (succ i)
601
577
| '!' -> cont_f n (succ i)
602
578
| '{' | '(' as conv (* ')' '}' *) ->
603
579
let (xf : ('a, 'b, 'c, 'd, 'e, 'f) format6 ) = get_arg spec n in
0 commit comments