fmt changes from Google
This commit is contained in:
parent
8d7133308d
commit
85231fd8cd
41 changed files with 507 additions and 505 deletions
|
|
@ -34,6 +34,18 @@ struct Fmt{
|
||||||
int width;
|
int width;
|
||||||
int prec;
|
int prec;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
char *decimal; /* decimal point; cannot be "" */
|
||||||
|
|
||||||
|
/* For %'d */
|
||||||
|
char *thousands; /* separator for thousands */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Each char is an integer indicating #digits before next separator. Values:
|
||||||
|
* \xFF: no more grouping (or \x7F; defined to be CHAR_MAX in POSIX)
|
||||||
|
* \x00: repeat previous indefinitely
|
||||||
|
* \x**: count that many
|
||||||
|
*/
|
||||||
|
char *grouping; /* descriptor of separator placement */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum{
|
enum{
|
||||||
|
|
@ -43,7 +55,8 @@ enum{
|
||||||
FmtSharp = FmtPrec << 1,
|
FmtSharp = FmtPrec << 1,
|
||||||
FmtSpace = FmtSharp << 1,
|
FmtSpace = FmtSharp << 1,
|
||||||
FmtSign = FmtSpace << 1,
|
FmtSign = FmtSpace << 1,
|
||||||
FmtZero = FmtSign << 1,
|
FmtApost = FmtSign << 1,
|
||||||
|
FmtZero = FmtApost << 1,
|
||||||
FmtUnsigned = FmtZero << 1,
|
FmtUnsigned = FmtZero << 1,
|
||||||
FmtShort = FmtUnsigned << 1,
|
FmtShort = FmtUnsigned << 1,
|
||||||
FmtLong = FmtShort << 1,
|
FmtLong = FmtShort << 1,
|
||||||
|
|
@ -64,6 +77,8 @@ double fmtcharstod(int(*f)(void*), void *vp);
|
||||||
int fmtfdflush(Fmt *f);
|
int fmtfdflush(Fmt *f);
|
||||||
int fmtfdinit(Fmt *f, int fd, char *buf, int size);
|
int fmtfdinit(Fmt *f, int fd, char *buf, int size);
|
||||||
int fmtinstall(int c, int (*f)(Fmt*));
|
int fmtinstall(int c, int (*f)(Fmt*));
|
||||||
|
int fmtnullinit(Fmt*);
|
||||||
|
void fmtlocaleinit(Fmt*, char*, char*, char*);
|
||||||
int fmtprint(Fmt *f, char *fmt, ...);
|
int fmtprint(Fmt *f, char *fmt, ...);
|
||||||
int fmtrune(Fmt *f, int r);
|
int fmtrune(Fmt *f, int r);
|
||||||
int fmtrunestrcpy(Fmt *f, Rune *s);
|
int fmtrunestrcpy(Fmt *f, Rune *s);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
* The authors of this software are Rob Pike and Ken Thompson,
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
* with contributions from Mike Burrows and Sean Dorward.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2006 by Lucent Technologies.
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
* purpose without fee is hereby granted, provided that this entire notice
|
||||||
* is included in all copies of any software which is or includes a copy
|
* is included in all copies of any software which is or includes a copy
|
||||||
|
|
@ -14,6 +16,5 @@
|
||||||
|
|
||||||
This is a Unix port of the Plan 9 formatted I/O package.
|
This is a Unix port of the Plan 9 formatted I/O package.
|
||||||
|
|
||||||
Please send comments about the packaging
|
Please send comments about the packaging to Russ Cox <rsc@swtch.com>.
|
||||||
to Russ Cox <rsc@post.harvard.edu>.
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -97,7 +85,7 @@ __fmtflush(Fmt *f, void *t, int len)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* put a formatted block of memory sz bytes long of n runes into the output buffer,
|
* put a formatted block of memory sz bytes long of n runes into the output buffer,
|
||||||
* left/right justified in a field of at least f->width charactes
|
* left/right justified in a field of at least f->width characters (if FmtWidth is set)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
__fmtpad(Fmt *f, int n)
|
__fmtpad(Fmt *f, int n)
|
||||||
|
|
@ -139,8 +127,10 @@ __fmtcpy(Fmt *f, const void *vm, int n, int sz)
|
||||||
|
|
||||||
m = (char*)vm;
|
m = (char*)vm;
|
||||||
me = m + sz;
|
me = m + sz;
|
||||||
w = f->width;
|
|
||||||
fl = f->flags;
|
fl = f->flags;
|
||||||
|
w = 0;
|
||||||
|
if(fl & FmtWidth)
|
||||||
|
w = f->width;
|
||||||
if((fl & FmtPrec) && n > f->prec)
|
if((fl & FmtPrec) && n > f->prec)
|
||||||
n = f->prec;
|
n = f->prec;
|
||||||
if(f->runes){
|
if(f->runes){
|
||||||
|
|
@ -194,8 +184,10 @@ __fmtrcpy(Fmt *f, const void *vm, int n)
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
m = (Rune*)vm;
|
m = (Rune*)vm;
|
||||||
w = f->width;
|
|
||||||
fl = f->flags;
|
fl = f->flags;
|
||||||
|
w = 0;
|
||||||
|
if(fl & FmtWidth)
|
||||||
|
w = f->width;
|
||||||
if((fl & FmtPrec) && n > f->prec)
|
if((fl & FmtPrec) && n > f->prec)
|
||||||
n = f->prec;
|
n = f->prec;
|
||||||
if(f->runes){
|
if(f->runes){
|
||||||
|
|
@ -324,10 +316,14 @@ __percentfmt(Fmt *f)
|
||||||
int
|
int
|
||||||
__ifmt(Fmt *f)
|
__ifmt(Fmt *f)
|
||||||
{
|
{
|
||||||
char buf[70], *p, *conv;
|
char buf[140], *p, *conv;
|
||||||
|
/* 140: for 64 bits of binary + 3-byte sep every 4 digits */
|
||||||
uvlong vu;
|
uvlong vu;
|
||||||
ulong u;
|
ulong u;
|
||||||
int neg, base, i, n, fl, w, isv;
|
int neg, base, i, n, fl, w, isv;
|
||||||
|
int ndig, len, excess, bytelen;
|
||||||
|
char *grouping;
|
||||||
|
char *thousands;
|
||||||
|
|
||||||
neg = 0;
|
neg = 0;
|
||||||
fl = f->flags;
|
fl = f->flags;
|
||||||
|
|
@ -339,11 +335,11 @@ __ifmt(Fmt *f)
|
||||||
* Unsigned verbs for ANSI C
|
* Unsigned verbs for ANSI C
|
||||||
*/
|
*/
|
||||||
switch(f->r){
|
switch(f->r){
|
||||||
|
case 'o':
|
||||||
|
case 'p':
|
||||||
|
case 'u':
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X':
|
||||||
case 'o':
|
|
||||||
case 'u':
|
|
||||||
case 'p':
|
|
||||||
fl |= FmtUnsigned;
|
fl |= FmtUnsigned;
|
||||||
fl &= ~(FmtSign|FmtSpace);
|
fl &= ~(FmtSign|FmtSpace);
|
||||||
break;
|
break;
|
||||||
|
|
@ -381,21 +377,25 @@ __ifmt(Fmt *f)
|
||||||
u = va_arg(f->args, int);
|
u = va_arg(f->args, int);
|
||||||
}
|
}
|
||||||
conv = "0123456789abcdef";
|
conv = "0123456789abcdef";
|
||||||
|
grouping = "\4"; /* for hex, octal etc. (undefined by spec but nice) */
|
||||||
|
thousands = f->thousands;
|
||||||
switch(f->r){
|
switch(f->r){
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'u':
|
case 'u':
|
||||||
base = 10;
|
base = 10;
|
||||||
break;
|
grouping = f->grouping;
|
||||||
case 'x':
|
|
||||||
base = 16;
|
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
base = 16;
|
|
||||||
conv = "0123456789ABCDEF";
|
conv = "0123456789ABCDEF";
|
||||||
|
/* fall through */
|
||||||
|
case 'x':
|
||||||
|
base = 16;
|
||||||
|
thousands = ":";
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
base = 2;
|
base = 2;
|
||||||
|
thousands = ":";
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
base = 8;
|
base = 8;
|
||||||
|
|
@ -413,7 +413,11 @@ __ifmt(Fmt *f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = buf + sizeof buf - 1;
|
p = buf + sizeof buf - 1;
|
||||||
n = 0;
|
n = 0; /* in runes */
|
||||||
|
excess = 0; /* number of bytes > number runes */
|
||||||
|
ndig = 0;
|
||||||
|
len = utflen(thousands);
|
||||||
|
bytelen = strlen(thousands);
|
||||||
if(isv){
|
if(isv){
|
||||||
while(vu){
|
while(vu){
|
||||||
i = vu % base;
|
i = vu % base;
|
||||||
|
|
@ -422,6 +426,12 @@ __ifmt(Fmt *f)
|
||||||
*p-- = ',';
|
*p-- = ',';
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
if((fl & FmtApost) && __needsep(&ndig, &grouping)){
|
||||||
|
n += len;
|
||||||
|
excess += bytelen - len;
|
||||||
|
p -= bytelen;
|
||||||
|
memmove(p+1, thousands, bytelen);
|
||||||
|
}
|
||||||
*p-- = conv[i];
|
*p-- = conv[i];
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
@ -433,6 +443,12 @@ __ifmt(Fmt *f)
|
||||||
*p-- = ',';
|
*p-- = ',';
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
if((fl & FmtApost) && __needsep(&ndig, &grouping)){
|
||||||
|
n += len;
|
||||||
|
excess += bytelen - len;
|
||||||
|
p -= bytelen;
|
||||||
|
memmove(p+1, thousands, bytelen);
|
||||||
|
}
|
||||||
*p-- = conv[i];
|
*p-- = conv[i];
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
@ -440,9 +456,19 @@ __ifmt(Fmt *f)
|
||||||
if(n == 0){
|
if(n == 0){
|
||||||
*p-- = '0';
|
*p-- = '0';
|
||||||
n = 1;
|
n = 1;
|
||||||
|
if(fl & FmtApost)
|
||||||
|
__needsep(&ndig, &grouping);
|
||||||
|
fl &= ~FmtSharp; /* ??? */
|
||||||
|
}
|
||||||
|
for(w = f->prec; n < w && p > buf+3; n++){
|
||||||
|
if((fl & FmtApost) && __needsep(&ndig, &grouping)){
|
||||||
|
n += len;
|
||||||
|
excess += bytelen - len;
|
||||||
|
p -= bytelen;
|
||||||
|
memmove(p+1, thousands, bytelen);
|
||||||
}
|
}
|
||||||
for(w = f->prec; n < w && p > buf+3; n++)
|
|
||||||
*p-- = '0';
|
*p-- = '0';
|
||||||
|
}
|
||||||
if(neg || (fl & (FmtSign|FmtSpace)))
|
if(neg || (fl & (FmtSign|FmtSpace)))
|
||||||
n++;
|
n++;
|
||||||
if(fl & FmtSharp){
|
if(fl & FmtSharp){
|
||||||
|
|
@ -456,9 +482,19 @@ __ifmt(Fmt *f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((fl & FmtZero) && !(fl & (FmtLeft|FmtPrec))){
|
if((fl & FmtZero) && !(fl & (FmtLeft|FmtPrec))){
|
||||||
for(w = f->width; n < w && p > buf+3; n++)
|
w = 0;
|
||||||
|
if(fl & FmtWidth)
|
||||||
|
w = f->width;
|
||||||
|
for(; n < w && p > buf+3; n++){
|
||||||
|
if((fl & FmtApost) && __needsep(&ndig, &grouping)){
|
||||||
|
n += len;
|
||||||
|
excess += bytelen - len;
|
||||||
|
p -= bytelen;
|
||||||
|
memmove(p+1, thousands, bytelen);
|
||||||
|
}
|
||||||
*p-- = '0';
|
*p-- = '0';
|
||||||
f->width = 0;
|
}
|
||||||
|
f->flags &= ~FmtWidth;
|
||||||
}
|
}
|
||||||
if(fl & FmtSharp){
|
if(fl & FmtSharp){
|
||||||
if(base == 16)
|
if(base == 16)
|
||||||
|
|
@ -473,7 +509,7 @@ __ifmt(Fmt *f)
|
||||||
else if(fl & FmtSpace)
|
else if(fl & FmtSpace)
|
||||||
*p-- = ' ';
|
*p-- = ' ';
|
||||||
f->flags &= ~FmtPrec;
|
f->flags &= ~FmtPrec;
|
||||||
return __fmtcpy(f, p + 1, n, n);
|
return __fmtcpy(f, p + 1, n, n + excess);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -514,6 +550,9 @@ __flagfmt(Fmt *f)
|
||||||
case '#':
|
case '#':
|
||||||
f->flags |= FmtSharp;
|
f->flags |= FmtSharp;
|
||||||
break;
|
break;
|
||||||
|
case '\'':
|
||||||
|
f->flags |= FmtApost;
|
||||||
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
f->flags |= FmtSpace;
|
f->flags |= FmtSpace;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -19,6 +7,7 @@
|
||||||
|
|
||||||
/* format the output into f->to and return the number of characters fmted */
|
/* format the output into f->to and return the number of characters fmted */
|
||||||
|
|
||||||
|
/* BUG: THIS FILE IS NOT UPDATED TO THE NEW SPEC */
|
||||||
int
|
int
|
||||||
dorfmt(Fmt *f, const Rune *fmt)
|
dorfmt(Fmt *f, const Rune *fmt)
|
||||||
{
|
{
|
||||||
|
|
@ -30,8 +19,8 @@ dorfmt(Fmt *f, const Rune *fmt)
|
||||||
nfmt = f->nfmt;
|
nfmt = f->nfmt;
|
||||||
for(;;){
|
for(;;){
|
||||||
if(f->runes){
|
if(f->runes){
|
||||||
rt = f->to;
|
rt = (Rune*)f->to;
|
||||||
rs = f->stop;
|
rs = (Rune*)f->stop;
|
||||||
while((r = *fmt++) && r != '%'){
|
while((r = *fmt++) && r != '%'){
|
||||||
FMTRCHAR(f, rt, rs, r);
|
FMTRCHAR(f, rt, rs, r);
|
||||||
}
|
}
|
||||||
|
|
@ -41,8 +30,8 @@ dorfmt(Fmt *f, const Rune *fmt)
|
||||||
return f->nfmt - nfmt;
|
return f->nfmt - nfmt;
|
||||||
f->stop = rs;
|
f->stop = rs;
|
||||||
}else{
|
}else{
|
||||||
t = f->to;
|
t = (char*)f->to;
|
||||||
s = f->stop;
|
s = (char*)f->stop;
|
||||||
while((r = *fmt++) && r != '%'){
|
while((r = *fmt++) && r != '%'){
|
||||||
FMTRUNE(f, t, f->stop, r);
|
FMTRUNE(f, t, f->stop, r);
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +42,7 @@ dorfmt(Fmt *f, const Rune *fmt)
|
||||||
f->stop = s;
|
f->stop = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt = __fmtdispatch(f, (Rune*)fmt, 1);
|
fmt = (Rune*)__fmtdispatch(f, (Rune*)fmt, 1);
|
||||||
if(fmt == nil)
|
if(fmt == nil)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -29,7 +17,7 @@ struct Convfmt
|
||||||
volatile Fmts fmt; /* for spin lock in fmtfmt; avoids race due to write order */
|
volatile Fmts fmt; /* for spin lock in fmtfmt; avoids race due to write order */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct
|
static struct
|
||||||
{
|
{
|
||||||
/* lock by calling __fmtlock, __fmtunlock */
|
/* lock by calling __fmtlock, __fmtunlock */
|
||||||
int nfmt;
|
int nfmt;
|
||||||
|
|
@ -40,6 +28,7 @@ static Convfmt knownfmt[] = {
|
||||||
' ', __flagfmt,
|
' ', __flagfmt,
|
||||||
'#', __flagfmt,
|
'#', __flagfmt,
|
||||||
'%', __percentfmt,
|
'%', __percentfmt,
|
||||||
|
'\'', __flagfmt,
|
||||||
'+', __flagfmt,
|
'+', __flagfmt,
|
||||||
',', __flagfmt,
|
',', __flagfmt,
|
||||||
'-', __flagfmt,
|
'-', __flagfmt,
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
|
|
||||||
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dofmt -- format to a buffer
|
* dofmt -- format to a buffer
|
||||||
|
|
@ -66,9 +54,9 @@ int __strfmt(Fmt *f);
|
||||||
#define FMTCHAR(f, t, s, c)\
|
#define FMTCHAR(f, t, s, c)\
|
||||||
do{\
|
do{\
|
||||||
if(t + 1 > (char*)s){\
|
if(t + 1 > (char*)s){\
|
||||||
t = __fmtflush(f, t, 1);\
|
t = (char*)__fmtflush(f, t, 1);\
|
||||||
if(t != nil)\
|
if(t != nil)\
|
||||||
s = f->stop;\
|
s = (char*)f->stop;\
|
||||||
else\
|
else\
|
||||||
return -1;\
|
return -1;\
|
||||||
}\
|
}\
|
||||||
|
|
@ -78,9 +66,9 @@ int __strfmt(Fmt *f);
|
||||||
#define FMTRCHAR(f, t, s, c)\
|
#define FMTRCHAR(f, t, s, c)\
|
||||||
do{\
|
do{\
|
||||||
if(t + 1 > (Rune*)s){\
|
if(t + 1 > (Rune*)s){\
|
||||||
t = __fmtflush(f, t, sizeof(Rune));\
|
t = (Rune*)__fmtflush(f, t, sizeof(Rune));\
|
||||||
if(t != nil)\
|
if(t != nil)\
|
||||||
s = f->stop;\
|
s = (Rune*)f->stop;\
|
||||||
else\
|
else\
|
||||||
return -1;\
|
return -1;\
|
||||||
}\
|
}\
|
||||||
|
|
@ -92,9 +80,9 @@ int __strfmt(Fmt *f);
|
||||||
Rune _rune;\
|
Rune _rune;\
|
||||||
int _runelen;\
|
int _runelen;\
|
||||||
if(t + UTFmax > (char*)s && t + (_runelen = runelen(r)) > (char*)s){\
|
if(t + UTFmax > (char*)s && t + (_runelen = runelen(r)) > (char*)s){\
|
||||||
t = __fmtflush(f, t, _runelen);\
|
t = (char*)__fmtflush(f, t, _runelen);\
|
||||||
if(t != nil)\
|
if(t != nil)\
|
||||||
s = f->stop;\
|
s = (char*)f->stop;\
|
||||||
else\
|
else\
|
||||||
return -1;\
|
return -1;\
|
||||||
}\
|
}\
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -41,6 +29,8 @@ fmtfdinit(Fmt *f, int fd, char *buf, int size)
|
||||||
f->stop = buf + size;
|
f->stop = buf + size;
|
||||||
f->flush = __fmtFdFlush;
|
f->flush = __fmtFdFlush;
|
||||||
f->farg = (void*)(uintptr_t)fd;
|
f->farg = (void*)(uintptr_t)fd;
|
||||||
|
f->flags = 0;
|
||||||
f->nfmt = 0;
|
f->nfmt = 0;
|
||||||
|
fmtlocaleinit(f, nil, nil, nil);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
56
src/lib9/fmt/fmtlocale.c
Normal file
56
src/lib9/fmt/fmtlocale.c
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "plan9.h"
|
||||||
|
#include "fmt.h"
|
||||||
|
#include "fmtdef.h"
|
||||||
|
|
||||||
|
/* XXX GOOGLE COPYRIGHT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fill in the internationalization stuff in the State structure.
|
||||||
|
* For nil arguments, provide the sensible defaults:
|
||||||
|
* decimal is a period
|
||||||
|
* thousands separator is a comma
|
||||||
|
* thousands are marked every three digits
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
fmtlocaleinit(Fmt *f, char *decimal, char *thousands, char *grouping)
|
||||||
|
{
|
||||||
|
if(decimal == nil || decimal[0] == '\0')
|
||||||
|
decimal = ".";
|
||||||
|
if(thousands == nil)
|
||||||
|
thousands = ",";
|
||||||
|
if(grouping == nil)
|
||||||
|
grouping = "\3";
|
||||||
|
f->decimal = decimal;
|
||||||
|
f->thousands = thousands;
|
||||||
|
f->grouping = grouping;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We are about to emit a digit in e.g. %'d. If that digit would
|
||||||
|
* overflow a thousands (e.g.) grouping, tell the caller to emit
|
||||||
|
* the thousands separator. Always advance the digit counter
|
||||||
|
* and pointer into the grouping descriptor.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
__needsep(int *ndig, const char **grouping)
|
||||||
|
{
|
||||||
|
int group;
|
||||||
|
|
||||||
|
(*ndig)++;
|
||||||
|
group = *(unsigned char*)*grouping;
|
||||||
|
/* CHAR_MAX means no further grouping. \0 means we got the empty string */
|
||||||
|
if(group == 0xFF || group == 0x7f || group == 0x00)
|
||||||
|
return 0;
|
||||||
|
if(*ndig > group){
|
||||||
|
/* if we're at end of string, continue with this grouping; else advance */
|
||||||
|
if((*grouping)[1] != '\0')
|
||||||
|
(*grouping)++;
|
||||||
|
*ndig = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -120,8 +108,10 @@ qstrfmt(char *sin, Rune *rin, Quoteinfo *q, Fmt *f)
|
||||||
rm = rin;
|
rm = rin;
|
||||||
rme = rm + q->nrunesin;
|
rme = rm + q->nrunesin;
|
||||||
|
|
||||||
w = f->width;
|
|
||||||
fl = f->flags;
|
fl = f->flags;
|
||||||
|
w = 0;
|
||||||
|
if(fl & FmtWidth)
|
||||||
|
w = f->width;
|
||||||
if(f->runes){
|
if(f->runes){
|
||||||
if(!(fl & FmtLeft) && __rfmtpad(f, w - q->nrunesout) < 0)
|
if(!(fl & FmtLeft) && __rfmtpad(f, w - q->nrunesout) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -23,5 +11,6 @@ fmtstrflush(Fmt *f)
|
||||||
if(f->start == nil)
|
if(f->start == nil)
|
||||||
return nil;
|
return nil;
|
||||||
*(char*)f->to = '\0';
|
*(char*)f->to = '\0';
|
||||||
|
f->to = f->start;
|
||||||
return (char*)f->start;
|
return (char*)f->start;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -23,5 +11,6 @@ runefmtstrflush(Fmt *f)
|
||||||
if(f->start == nil)
|
if(f->start == nil)
|
||||||
return nil;
|
return nil;
|
||||||
*(Rune*)f->to = '\0';
|
*(Rune*)f->to = '\0';
|
||||||
|
f->to = f->start;
|
||||||
return f->start;
|
return f->start;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
* Plan 9 port version must include libc.h in order to
|
* Plan 9 port version must include libc.h in order to
|
||||||
* get Plan 9 debugging malloc, which sometimes returns
|
* get Plan 9 debugging malloc, which sometimes returns
|
||||||
|
|
@ -69,6 +57,7 @@ runefmtstrinit(Fmt *f)
|
||||||
f->flush = runeFmtStrFlush;
|
f->flush = runeFmtStrFlush;
|
||||||
f->farg = (void*)(uintptr)n;
|
f->farg = (void*)(uintptr)n;
|
||||||
f->nfmt = 0;
|
f->nfmt = 0;
|
||||||
|
fmtlocaleinit(f, nil, nil, nil);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -32,6 +20,7 @@ runevsnprint(Rune *buf, int len, char *fmt, va_list args)
|
||||||
f.farg = nil;
|
f.farg = nil;
|
||||||
f.nfmt = 0;
|
f.nfmt = 0;
|
||||||
VA_COPY(f.args,args);
|
VA_COPY(f.args,args);
|
||||||
|
fmtlocaleinit(&f, nil, nil, nil);
|
||||||
dofmt(&f, fmt);
|
dofmt(&f, fmt);
|
||||||
VA_END(f.args);
|
VA_END(f.args);
|
||||||
*(Rune*)f.to = '\0';
|
*(Rune*)f.to = '\0';
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <fmt.h>
|
#include <fmt.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
@ -239,7 +227,7 @@ fmtstrtod(const char *as, char **aas)
|
||||||
/* close approx by naive conversion */
|
/* close approx by naive conversion */
|
||||||
mid[0] = 0;
|
mid[0] = 0;
|
||||||
mid[1] = 1;
|
mid[1] = 1;
|
||||||
for(i=0; c=a[i]; i++) {
|
for(i=0; (c=a[i]) != '\0'; i++) {
|
||||||
mid[0] = mid[0]*10 + (c-'0');
|
mid[0] = mid[0]*10 + (c-'0');
|
||||||
mid[1] = mid[1]*10;
|
mid[1] = mid[1]*10;
|
||||||
if(i >= 8)
|
if(i >= 8)
|
||||||
|
|
@ -521,7 +509,7 @@ xcmp(char *a, char *b)
|
||||||
{
|
{
|
||||||
int c1, c2;
|
int c1, c2;
|
||||||
|
|
||||||
while(c1 = *b++) {
|
while((c1 = *b++) != '\0') {
|
||||||
c2 = *a++;
|
c2 = *a++;
|
||||||
if(isupper(c2))
|
if(isupper(c2))
|
||||||
c2 = tolower(c2);
|
c2 = tolower(c2);
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <utf.h>
|
#include <utf.h>
|
||||||
|
|
@ -40,5 +28,24 @@ main(int argc, char *argv[])
|
||||||
print("%d\n", 23);
|
print("%d\n", 23);
|
||||||
print("%i\n", 23);
|
print("%i\n", 23);
|
||||||
print("%0.10d\n", 12345);
|
print("%0.10d\n", 12345);
|
||||||
|
|
||||||
|
/* test %4$d formats */
|
||||||
|
print("%3$d %4$06d %2$d %1$d\n", 444, 333, 111, 222);
|
||||||
|
print("%3$d %4$06d %2$d %1$d\n", 444, 333, 111, 222);
|
||||||
|
print("%3$d %4$*5$06d %2$d %1$d\n", 444, 333, 111, 222, 20);
|
||||||
|
print("%3$hd %4$*5$06d %2$d %1$d\n", 444, 333, (short)111, 222, 20);
|
||||||
|
print("%3$lld %4$*5$06d %2$d %1$d\n", 444, 333, 111LL, 222, 20);
|
||||||
|
|
||||||
|
/* test %'d formats */
|
||||||
|
print("%'d %'d %'d\n", 1, 2222, 33333333);
|
||||||
|
print("%'019d\n", 0);
|
||||||
|
print("%08d %08d %08d\n", 1, 2222, 33333333);
|
||||||
|
print("%'08d %'08d %'08d\n", 1, 2222, 33333333);
|
||||||
|
print("%'x %'X %'b\n", 0x11111111, 0xabcd1234, 12345);
|
||||||
|
print("%'lld %'lld %'lld\n", 1LL, 222222222LL, 3333333333333LL);
|
||||||
|
print("%019lld %019lld %019lld\n", 1LL, 222222222LL, 3333333333333LL);
|
||||||
|
print("%'019lld %'019lld %'019lld\n", 1LL, 222222222LL, 3333333333333LL);
|
||||||
|
print("%'020lld %'020lld %'020lld\n", 1LL, 222222222LL, 3333333333333LL);
|
||||||
|
print("%'llx %'llX %'llb\n", 0x111111111111LL, 0xabcd12345678LL, 112342345LL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
* Plan 9 port version must include libc.h in order to
|
* Plan 9 port version must include libc.h in order to
|
||||||
* get Plan 9 debugging malloc, which sometimes returns
|
* get Plan 9 debugging malloc, which sometimes returns
|
||||||
|
|
@ -69,6 +57,7 @@ fmtstrinit(Fmt *f)
|
||||||
f->flush = fmtStrFlush;
|
f->flush = fmtStrFlush;
|
||||||
f->farg = (void*)(uintptr)n;
|
f->farg = (void*)(uintptr)n;
|
||||||
f->nfmt = 0;
|
f->nfmt = 0;
|
||||||
|
fmtlocaleinit(f, nil, nil, nil);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
/*
|
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
|
||||||
* The authors of this software are Rob Pike and Ken Thompson.
|
|
||||||
* Copyright (c) 2002 by Lucent Technologies.
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose without fee is hereby granted, provided that this entire notice
|
|
||||||
* is included in all copies of any software which is or includes a copy
|
|
||||||
* or modification of this software and in all copies of the supporting
|
|
||||||
* documentation for such software.
|
|
||||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
|
|
||||||
* ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
|
||||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "plan9.h"
|
#include "plan9.h"
|
||||||
|
|
@ -32,6 +20,7 @@ vsnprint(char *buf, int len, char *fmt, va_list args)
|
||||||
f.farg = nil;
|
f.farg = nil;
|
||||||
f.nfmt = 0;
|
f.nfmt = 0;
|
||||||
VA_COPY(f.args,args);
|
VA_COPY(f.args,args);
|
||||||
|
fmtlocaleinit(&f, nil, nil, nil);
|
||||||
dofmt(&f, fmt);
|
dofmt(&f, fmt);
|
||||||
VA_END(f.args);
|
VA_END(f.args);
|
||||||
*(char*)f.to = '\0';
|
*(char*)f.to = '\0';
|
||||||
|
|
|
||||||
166
src/lib9/testfltfmt.c
Normal file
166
src/lib9/testfltfmt.c
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* try all combination of flags and float conversions
|
||||||
|
* with some different widths & precisions
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define Njust 2
|
||||||
|
#define Nplus 3
|
||||||
|
#define Nalt 2
|
||||||
|
#define Nzero 2
|
||||||
|
#define Nspec 5
|
||||||
|
#define Nwidth 5
|
||||||
|
#define Nprec 5
|
||||||
|
|
||||||
|
static double fmtvals[] = {
|
||||||
|
3.1415925535897932e15,
|
||||||
|
3.1415925535897932e14,
|
||||||
|
3.1415925535897932e13,
|
||||||
|
3.1415925535897932e12,
|
||||||
|
3.1415925535897932e11,
|
||||||
|
3.1415925535897932e10,
|
||||||
|
3.1415925535897932e9,
|
||||||
|
3.1415925535897932e8,
|
||||||
|
3.1415925535897932e7,
|
||||||
|
3.1415925535897932e6,
|
||||||
|
3.1415925535897932e5,
|
||||||
|
3.1415925535897932e4,
|
||||||
|
3.1415925535897932e3,
|
||||||
|
3.1415925535897932e2,
|
||||||
|
3.1415925535897932e1,
|
||||||
|
3.1415925535897932e0,
|
||||||
|
3.1415925535897932e-1,
|
||||||
|
3.1415925535897932e-2,
|
||||||
|
3.1415925535897932e-3,
|
||||||
|
3.1415925535897932e-4,
|
||||||
|
3.1415925535897932e-5,
|
||||||
|
3.1415925535897932e-6,
|
||||||
|
3.1415925535897932e-7,
|
||||||
|
3.1415925535897932e-8,
|
||||||
|
3.1415925535897932e-9,
|
||||||
|
3.1415925535897932e-10,
|
||||||
|
3.1415925535897932e-11,
|
||||||
|
3.1415925535897932e-12,
|
||||||
|
3.1415925535897932e-13,
|
||||||
|
3.1415925535897932e-14,
|
||||||
|
3.1415925535897932e-15,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* are the numbers close?
|
||||||
|
* used to compare long numbers where the last few digits are garbage
|
||||||
|
* due to precision problems
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
numclose(char *num1, char *num2)
|
||||||
|
{
|
||||||
|
int ndig;
|
||||||
|
enum { MAXDIG = 15 };
|
||||||
|
|
||||||
|
ndig = 0;
|
||||||
|
while (*num1) {
|
||||||
|
if (*num1 >= '0' && *num1 <= '9') {
|
||||||
|
ndig++;
|
||||||
|
if (ndig > MAXDIG) {
|
||||||
|
if (!(*num2 >= '0' && *num2 <= '9')) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else if (*num1 != *num2) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else if (*num1 != *num2) {
|
||||||
|
return 0;
|
||||||
|
} else if (*num1 == 'e' || *num1 == 'E') {
|
||||||
|
ndig = 0;
|
||||||
|
}
|
||||||
|
num1++;
|
||||||
|
num2++;
|
||||||
|
}
|
||||||
|
if (*num1 || !num2)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
doit(int just, int plus, int alt, int zero, int width, int prec, int spec)
|
||||||
|
{
|
||||||
|
char format[256];
|
||||||
|
char *p;
|
||||||
|
const char *s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
p = format;
|
||||||
|
*p++ = '%';
|
||||||
|
if (just > 0)
|
||||||
|
*p++ = "-"[just - 1];
|
||||||
|
if (plus > 0)
|
||||||
|
*p++ = "+ "[plus - 1];
|
||||||
|
if (alt > 0)
|
||||||
|
*p++ = "#"[alt - 1];
|
||||||
|
if (zero > 0)
|
||||||
|
*p++ = "0"[zero - 1];
|
||||||
|
|
||||||
|
s = "";
|
||||||
|
switch (width) {
|
||||||
|
case 1: s = "1"; break;
|
||||||
|
case 2: s = "5"; break;
|
||||||
|
case 3: s = "10"; break;
|
||||||
|
case 4: s = "15"; break;
|
||||||
|
}
|
||||||
|
strcpy(p, s);
|
||||||
|
|
||||||
|
s = "";
|
||||||
|
switch (prec) {
|
||||||
|
case 1: s = ".0"; break;
|
||||||
|
case 2: s = ".2"; break;
|
||||||
|
case 3: s = ".5"; break;
|
||||||
|
case 4: s = ".15"; break;
|
||||||
|
}
|
||||||
|
strcat(p, s);
|
||||||
|
|
||||||
|
p = strchr(p, '\0');
|
||||||
|
*p++ = "efgEG"[spec];
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(fmtvals) / sizeof(fmtvals[0]); i++) {
|
||||||
|
char ref[256], buf[256];
|
||||||
|
Rune rbuf[256];
|
||||||
|
|
||||||
|
sprintf(ref, format, fmtvals[i]);
|
||||||
|
snprint(buf, sizeof(buf), format, fmtvals[i]);
|
||||||
|
if (strcmp(ref, buf) != 0
|
||||||
|
&& !numclose(ref, buf)) {
|
||||||
|
fprintf(stderr, "%s: ref='%s' fmt='%s'\n", format, ref, buf);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check again with output to rune string */
|
||||||
|
runesnprint(rbuf, 256, format, fmtvals[i]);
|
||||||
|
snprint(buf, sizeof(buf), "%S", rbuf);
|
||||||
|
if (strcmp(ref, buf) != 0
|
||||||
|
&& !numclose(ref, buf)) {
|
||||||
|
fprintf(stderr, "%s: rune ref='%s' fmt='%s'\n", format, ref, buf);
|
||||||
|
exits("oops");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int just, plus, alt, zero, width, prec, spec;
|
||||||
|
|
||||||
|
for (just = 0; just < Njust; just++)
|
||||||
|
for (plus = 0; plus < Nplus; plus++)
|
||||||
|
for (alt = 0; alt < Nalt; alt++)
|
||||||
|
for (zero = 0; zero < Nzero; zero++)
|
||||||
|
for (width = 0; width < Nwidth; width++)
|
||||||
|
for (prec = 0; prec < Nprec; prec++)
|
||||||
|
for (spec = 0; spec < Nspec; spec++)
|
||||||
|
doit(just, plus, alt, zero, width, prec, spec);
|
||||||
|
|
||||||
|
exits(0);
|
||||||
|
}
|
||||||
114
src/lib9/testfmt.c
Normal file
114
src/lib9/testfmt.c
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int failed;
|
||||||
|
|
||||||
|
/* Consume argument and ignore it */
|
||||||
|
int
|
||||||
|
Zflag(Fmt* f)
|
||||||
|
{
|
||||||
|
if(va_arg(f->args, int))
|
||||||
|
;
|
||||||
|
return 1; /* it's a flag */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
verify(char *s, char *t)
|
||||||
|
{
|
||||||
|
if(strcmp(s, t) != 0){
|
||||||
|
failed = 1;
|
||||||
|
fprintf(stderr, "error: (%s) != (%s)\n", s, t);
|
||||||
|
}
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rune lightsmiley = 0x263a;
|
||||||
|
Rune darksmiley = 0x263b;
|
||||||
|
|
||||||
|
/* Test printer that loads unusual decimal point and separator */
|
||||||
|
char*
|
||||||
|
mysmprint(char *fmt, ...)
|
||||||
|
{
|
||||||
|
Fmt f;
|
||||||
|
|
||||||
|
if(fmtstrinit(&f) < 0)
|
||||||
|
return 0;
|
||||||
|
va_start(f.args, fmt);
|
||||||
|
f.decimal = smprint("%C", lightsmiley);
|
||||||
|
f.thousands = smprint("%C", darksmiley);
|
||||||
|
f.grouping = "\1\2\3\4";
|
||||||
|
if(dofmt(&f, fmt) < 0)
|
||||||
|
return 0;
|
||||||
|
va_end(f.args);
|
||||||
|
return fmtstrflush(&f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
quotefmtinstall();
|
||||||
|
fmtinstall('Z', Zflag);
|
||||||
|
fmtinstall(L'\x263a', Zflag);
|
||||||
|
|
||||||
|
verify(smprint("hello world"), "hello world");
|
||||||
|
#ifdef PLAN9PORT
|
||||||
|
verify(smprint("x: %ux", 0x87654321), "x: 87654321");
|
||||||
|
#else
|
||||||
|
verify(smprint("x: %x", 0x87654321), "x: 87654321");
|
||||||
|
#endif
|
||||||
|
verify(smprint("d: %d", 0x87654321), "d: -2023406815");
|
||||||
|
verify(smprint("s: %s", "hi there"), "s: hi there");
|
||||||
|
verify(smprint("q: %q", "hi i'm here"), "q: 'hi i''m here'");
|
||||||
|
verify(smprint("c: %c", '!'), "c: !");
|
||||||
|
verify(smprint("g: %g %g %g", 3.14159, 3.14159e10, 3.14159e-10), "g: 3.14159 3.14159e+10 3.14159e-10");
|
||||||
|
verify(smprint("e: %e %e %e", 3.14159, 3.14159e10, 3.14159e-10), "e: 3.141590e+00 3.141590e+10 3.141590e-10");
|
||||||
|
verify(smprint("f: %f %f %f", 3.14159, 3.14159e10, 3.14159e-10), "f: 3.141590 31415900000.000000 0.000000");
|
||||||
|
verify(smprint("smiley: %C", (Rune)0x263a), "smiley: \xe2\x98\xba");
|
||||||
|
verify(smprint("%g %.18g", 2e25, 2e25), "2e+25 2e+25");
|
||||||
|
verify(smprint("%2.18g", 1.0), " 1");
|
||||||
|
verify(smprint("%f", 3.1415927/4), "0.785398");
|
||||||
|
verify(smprint("%d", 23), "23");
|
||||||
|
verify(smprint("%i", 23), "23");
|
||||||
|
verify(smprint("%Zi", 1234, 23), "23");
|
||||||
|
|
||||||
|
/* test $ reorderings */
|
||||||
|
verify(smprint("%3$d %4$06d %2$d %1$d", 444, 333, 111, 222), "111 000222 333 444");
|
||||||
|
verify(smprint("%3$Zd %5$06d %2$d %1$d", 444, 333, 555, 111, 222), "111 000222 333 444");
|
||||||
|
verify(smprint("%3$d %4$*5$06d %2$d %1$d", 444, 333, 111, 222, 20), "111 000222 333 444");
|
||||||
|
verify(smprint("%3$hd %4$*5$06d %2$d %1$d", 444, 333, (short)111, 222, 20), "111 000222 333 444");
|
||||||
|
verify(smprint("%3$\xe2\x98\xba""d %5$06d %2$d %1$d", 444, 333, 555, 111, 222), "111 000222 333 444");
|
||||||
|
|
||||||
|
/* test %'d formats */
|
||||||
|
verify(smprint("%'d %'d %'d", 1, 2222, 33333333), "1 2,222 33,333,333");
|
||||||
|
verify(smprint("%'019d", 0), "000,000,000,000,000");
|
||||||
|
verify(smprint("%'08d %'08d %'08d", 1, 2222, 33333333), "0,000,001 0,002,222 33,333,333");
|
||||||
|
#ifdef PLAN9PORT
|
||||||
|
verify(smprint("%'ux %'uX %'ub", 0x11111111, 0xabcd1234, 12345), "1111:1111 ABCD:1234 11:0000:0011:1001");
|
||||||
|
#else
|
||||||
|
verify(smprint("%'x %'X %'b", 0x11111111, 0xabcd1234, 12345), "1111:1111 ABCD:1234 11:0000:0011:1001");
|
||||||
|
#endif
|
||||||
|
verify(smprint("%'lld %'lld %'lld", 1LL, 222222222LL, 3333333333333LL), "1 222,222,222 3,333,333,333,333");
|
||||||
|
verify(smprint("%'019lld %'019lld %'019lld", 1LL, 222222222LL, 3333333333333LL), "000,000,000,000,001 000,000,222,222,222 003,333,333,333,333");
|
||||||
|
#ifdef PLAN9PORT
|
||||||
|
verify(smprint("%'llux %'lluX %'llub", 0x111111111111LL, 0xabcd12345678LL, 112342345LL), "1111:1111:1111 ABCD:1234:5678 110:1011:0010:0011:0101:0100:1001");
|
||||||
|
#else
|
||||||
|
verify(smprint("%'llx %'llX %'llb", 0x111111111111LL, 0xabcd12345678LL, 112342345LL), "1111:1111:1111 ABCD:1234:5678 110:1011:0010:0011:0101:0100:1001");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* test %'d with custom (utf-8!) separators */
|
||||||
|
/* x and b still use : */
|
||||||
|
verify(mysmprint("%'d %'d %'d", 1, 2222, 33333333), "1 2\xe2\x98\xbb""22\xe2\x98\xbb""2 33\xe2\x98\xbb""333\xe2\x98\xbb""33\xe2\x98\xbb""3");
|
||||||
|
#ifdef PLAN9PORT
|
||||||
|
verify(mysmprint("%'ux %'uX %'ub", 0x11111111, 0xabcd1234, 12345), "1111:1111 ABCD:1234 11:0000:0011:1001");
|
||||||
|
#else
|
||||||
|
verify(mysmprint("%'x %'X %'b", 0x11111111, 0xabcd1234, 12345), "1111:1111 ABCD:1234 11:0000:0011:1001");
|
||||||
|
#endif
|
||||||
|
verify(mysmprint("%'lld %'lld %'lld", 1LL, 222222222LL, 3333333333333LL), "1 222\xe2\x98\xbb""222\xe2\x98\xbb""22\xe2\x98\xbb""2 333\xe2\x98\xbb""3333\xe2\x98\xbb""333\xe2\x98\xbb""33\xe2\x98\xbb""3");
|
||||||
|
verify(mysmprint("%'llx %'llX %'llb", 0x111111111111LL, 0xabcd12345678LL, 112342345LL), "1111:1111:1111 ABCD:1234:5678 110:1011:0010:0011:0101:0100:1001");
|
||||||
|
|
||||||
|
if(failed)
|
||||||
|
sysfatal("tests failed");
|
||||||
|
exits(0);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue