@@ -19,8 +19,8 @@ DRAFT: Synopsis 32: Setting Library - Str
19
19
20
20
Created: 19 Mar 2009 extracted from S29-functions.pod
21
21
22
- Last Modified: 2012-03-26
23
- Version: 7
22
+ Last Modified: 2012-07-05
23
+ Version: 8
24
24
25
25
The document is a draft.
26
26
@@ -402,13 +402,12 @@ The C<$format> is scanned for C<%> characters. Any C<%> introduces a
402
402
format token. Format tokens have the following grammar:
403
403
404
404
grammar Str::SprintfFormat {
405
- regex format_token { '%': <index>? <precision>? <modifier>? < directive> }
405
+ regex format_token { '%': <index>? <precision>? <directive> }
406
406
token index { \d+ '$' }
407
407
token precision { <flags>? <vector>? <precision_count> }
408
408
token flags { <[ \x20 + 0 \# \- ]>+ }
409
409
token precision_count { [ <[1..9]>\d* | '*' ]? [ '.' [ \d* | '*' ] ]? }
410
410
token vector { '*'? v }
411
- token modifier { < ll l h m V q L > }
412
411
token directive { < % c s d u o x e f g X E G b p n i D U O F > }
413
412
}
414
413
@@ -421,47 +420,31 @@ The directives are:
421
420
% a literal percent sign
422
421
c a character with the given codepoint
423
422
s a string
424
- d a signed integer, in decimal
425
- u an unsigned integer, in decimal
426
- o an unsigned integer, in octal
427
- x an unsigned integer, in hexadecimal
423
+ d an integer, in decimal
424
+ b an integer, in binary
425
+ o an integer, in octal
426
+ x an integer, in hexadecimal
427
+ X like x, but using uppercase letters
428
428
e a floating-point number, in scientific notation
429
429
f a floating-point number, in fixed decimal notation
430
430
g a floating-point number, in %e or %f notation
431
- X like x, but using uppercase letters
432
431
E like e, but using an uppercase "E"
433
432
G like g, but with an uppercase "E" (if applicable)
434
- b an unsigned integer, in binary
435
433
436
434
Compatibility:
437
435
438
436
i a synonym for %d
439
- D a synonym for %ld
440
- U a synonym for %lu
441
- O a synonym for %lo
437
+ u a synonum for %d
438
+ D a synonym for %d
439
+ U a synonym for %u
440
+ O a synonym for %o
442
441
F a synonym for %f
443
442
444
443
Perl 5 (non-)compatibility:
445
444
446
445
n produces a runtime exception
447
446
p produces a runtime exception
448
447
449
- Modifiers change the meaning of format directives. At the moment
450
- these are recognized primarily for compatibility with C<printf>
451
- from other languages (notably C and Perl 5), but their exact semantics
452
- are still conjectural.
453
-
454
- h interpret integer as native "short" (typically int16)
455
- l interpret integer as native "long" (typically int32 or int64)
456
- ll interpret integer as native "long long" (typically int64)
457
- L interpret integer as native "long long" (typically uint64)
458
- q interpret integer as native "quads" (typically int64 or larger)
459
-
460
- Examples:
461
-
462
- sprintf "%ld a big number, %lld a bigger number\n",
463
- 4294967295, 4294967296;
464
-
465
448
=item fmt
466
449
467
450
multi method fmt( Scalar $scalar: Str $format = '%s' --> Str )
0 commit comments