aboutsummaryrefslogtreecommitdiff
path: root/src/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/printf.c b/src/printf.c
index ab88e23fa..eafe842a1 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -414,6 +414,13 @@ static void vxprintf(
}
bufpt = &buf[etBUFSIZE-1];
if( xtype==etORDINAL ){
+ static const char zOrd[] = "thstndrd";
+ int x = longvalue % 10;
+ if( x>=4 || (longvalue/10)%10==1 ){
+ x = 0;
+ }
+ buf[etBUFSIZE-3] = zOrd[x*2];
+ buf[etBUFSIZE-2] = zOrd[x*2+1];
bufpt -= 2;
}
{
@@ -426,13 +433,6 @@ static void vxprintf(
longvalue = longvalue/base;
}while( longvalue>0 );
}
- if( xtype==etORDINAL ){
- static const char zOrd[] = "thstndrd";
- int x = buf[etBUFSIZE-4] - '0';
- if( x>=4 ) x = 0;
- buf[etBUFSIZE-3] = zOrd[x*2];
- buf[etBUFSIZE-2] = zOrd[x*2+1];
- }
length = &buf[etBUFSIZE-1]-bufpt;
for(idx=precision-length; idx>0; idx--){
*(--bufpt) = '0'; /* Zero pad */