introduce signed intptr and %z format modifier for formating uintptr and intptr

This commit is contained in:
cinap_lenrek 2016-01-07 04:39:09 +01:00
parent 59245c73f0
commit 3e38194d72
17 changed files with 35 additions and 0 deletions

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long long intptr;
typedef unsigned long long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -7,6 +7,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long long intptr;
typedef unsigned long long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -6,6 +6,7 @@ typedef unsigned int uint;
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;

View file

@ -194,6 +194,14 @@ extern Rune* runefmtstrflush(Fmt*);
#pragma varargck type "lo" ulong
#pragma varargck type "lx" ulong
#pragma varargck type "lb" ulong
#pragma varargck type "zd" intptr
#pragma varargck type "zo" intptr
#pragma varargck type "zx" intptr
#pragma varargck type "zb" intptr
#pragma varargck type "zd" uintptr
#pragma varargck type "zo" uintptr
#pragma varargck type "zx" uintptr
#pragma varargck type "zb" uintptr
#pragma varargck type "d" int
#pragma varargck type "o" int
#pragma varargck type "x" int

View file

@ -98,6 +98,14 @@ extern int sprint(char*, char*, ...);
#pragma varargck type "lb" ulong
#pragma varargck type "ld" ulong
#pragma varargck type "lx" ulong
#pragma varargck type "zd" intptr
#pragma varargck type "zo" intptr
#pragma varargck type "zx" intptr
#pragma varargck type "zb" intptr
#pragma varargck type "zd" uintptr
#pragma varargck type "zo" uintptr
#pragma varargck type "zx" uintptr
#pragma varargck type "zb" uintptr
#pragma varargck type "b" int
#pragma varargck type "d" int
#pragma varargck type "x" int

View file

@ -165,6 +165,7 @@ arginit(void)
argflag('*', Fstar);
argflag('l', Fl);
argflag('z', ewidth[TVLONG]==ewidth[TIND] ? Fvl : Fl);
argflag('o', Fverb);
flagbits['x'] = flagbits['o'];

View file

@ -504,6 +504,11 @@ _flagfmt(Fmt *f)
f->flags |= FmtVLong;
f->flags |= FmtLong;
break;
case 'z':
f->flags |= FmtLong;
if(sizeof(uintptr) == sizeof(uvlong))
f->flags |= FmtVLong;
break;
}
return 1;
}

View file

@ -48,6 +48,7 @@ static Convfmt knownfmt[] = {
's', _strfmt,
'u', _flagfmt,
'x', _ifmt,
'z', _flagfmt,
0, nil,
};