Remove l10n_debug cruft, expand tabs, eliminate else-after-break, don't invade the standard C namespace with leading _ in identifiers, etc. (173827, r=scole@planetweb.com).

This commit is contained in:
brendan%mozilla.org 2002-11-13 22:59:15 +00:00
Родитель 38eb10228e
Коммит 9258804a58
1 изменённых файлов: 583 добавлений и 618 удалений

Просмотреть файл

@ -85,9 +85,6 @@ struct NumArgState{
va_list ap; /* point to the corresponding position on ap */
};
static JSBool l10n_debug_init = JS_FALSE;
static JSBool l10n_debug = JS_FALSE;
#define NAS_DEFAULT_NUM 20 /* default number of NumberedArgumentState array */
@ -104,11 +101,11 @@ static JSBool l10n_debug = JS_FALSE;
#define TYPE_INTSTR 10
#define TYPE_UNKNOWN 20
#define _LEFT 0x1
#define _SIGNED 0x2
#define _SPACED 0x4
#define _ZEROS 0x8
#define _NEG 0x10
#define FLAG_LEFT 0x1
#define FLAG_SIGNED 0x2
#define FLAG_SPACED 0x4
#define FLAG_ZEROS 0x8
#define FLAG_NEG 0x10
/*
** Fill into the buffer using the data in src
@ -120,8 +117,8 @@ static int fill2(SprintfState *ss, const char *src, int srclen, int width,
int rv;
width -= srclen;
if ((width > 0) && ((flags & _LEFT) == 0)) { /* Right adjusting */
if (flags & _ZEROS) {
if ((width > 0) && ((flags & FLAG_LEFT) == 0)) { /* Right adjusting */
if (flags & FLAG_ZEROS) {
space = '0';
}
while (--width >= 0) {
@ -138,7 +135,7 @@ static int fill2(SprintfState *ss, const char *src, int srclen, int width,
return rv;
}
if ((width > 0) && ((flags & _LEFT) != 0)) { /* Left adjusting */
if ((width > 0) && ((flags & FLAG_LEFT) != 0)) { /* Left adjusting */
while (--width >= 0) {
rv = (*ss->stuff)(ss, &space, 1);
if (rv < 0) {
@ -165,13 +162,13 @@ static int fill_n(SprintfState *ss, const char *src, int srclen, int width,
char sign;
if ((type & 1) == 0) {
if (flags & _NEG) {
if (flags & FLAG_NEG) {
sign = '-';
signwidth = 1;
} else if (flags & _SIGNED) {
} else if (flags & FLAG_SIGNED) {
sign = '+';
signwidth = 1;
} else if (flags & _SPACED) {
} else if (flags & FLAG_SPACED) {
sign = ' ';
signwidth = 1;
}
@ -185,14 +182,14 @@ static int fill_n(SprintfState *ss, const char *src, int srclen, int width,
}
}
if ((flags & _ZEROS) && (prec < 0)) {
if ((flags & FLAG_ZEROS) && (prec < 0)) {
if (width > cvtwidth) {
zerowidth = width - cvtwidth; /* Zero filling */
cvtwidth += zerowidth;
}
}
if (flags & _LEFT) {
if (flags & FLAG_LEFT) {
if (width > cvtwidth) {
/* Space filling on the right (i.e. left adjusting) */
rightspaces = width - cvtwidth;
@ -407,20 +404,6 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
struct NumArgState* nas;
/*
** set the l10n_debug flag
** this routine should be executed only once
** 'cause getenv does take time
*/
if( !l10n_debug_init ){
l10n_debug_init = JS_TRUE;
p = getenv( "NETSCAPE_LOCALIZATION_DEBUG" );
if( ( p != NULL ) && ( *p == '1' ) ){
l10n_debug = JS_TRUE;
}
}
/*
** first pass:
** detemine how many legal % I have got, then allocate space
@ -440,23 +423,17 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
if( c == '$' ){ /* numbered argument csae */
if( i > 0 ){
*rv = -1;
if( l10n_debug )
printf( "either no *OR* all arguments are numbered \"%s\"\n", fmt );
return NULL;
}
number++;
break;
} else{ /* non-numbered argument case */
} else { /* non-numbered argument case */
if( number > 0 ){
if( l10n_debug )
printf( "either no *OR* all arguments are numbered \"%s\"\n", fmt );
*rv = -1;
return NULL;
}
i = 1;
break;
}
break;
}
c = *p++;
@ -472,8 +449,6 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
nas = (struct NumArgState*)malloc( number * sizeof( struct NumArgState ) );
if( !nas ){
*rv = -1;
if( l10n_debug )
printf( "malloc() error for \"%s\"\n", fmt );
return NULL;
}
} else {
@ -504,8 +479,6 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
if( !c || cn < 1 || cn > number ){
*rv = -1;
if( l10n_debug )
printf( "invalid argument number (valid range [1, %d]), \"%s\"\n", number, fmt );
break;
}
@ -520,30 +493,26 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
if (c == '*') {
/* not supported feature, for the argument is not numbered */
*rv = -1;
if( l10n_debug )
printf( "* width specifier not support for numbered arguments \"%s\"\n", fmt );
break;
} else {
}
while ((c >= '0') && (c <= '9')) {
c = *p++;
}
}
/* precision */
if (c == '.') {
c = *p++;
if (c == '*') {
/* not supported feature, for the argument is not numbered */
if( l10n_debug )
printf( "* precision specifier not support for numbered arguments \"%s\"\n", fmt );
*rv = -1;
break;
} else {
}
while ((c >= '0') && (c <= '9')) {
c = *p++;
}
}
}
/* size */
nas[cn].type = TYPE_INTN;
@ -618,8 +587,6 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
/* get a legal para. */
if( nas[ cn ].type == TYPE_UNKNOWN ){
if( l10n_debug )
printf( "unknown type \"%s\"\n", fmt );
*rv = -1;
break;
}
@ -753,8 +720,6 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
}
if( nas[i-1].type == TYPE_UNKNOWN ){
if( l10n_debug )
printf( "numbered argument type unknown\n" );
if( nas && ( nas != nasArray ) )
JS_DELETE( nas );
return -1;
@ -773,14 +738,14 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
* on this feature.
*/
while ((c == '-') || (c == '+') || (c == ' ') || (c == '0')) {
if (c == '-') flags |= _LEFT;
if (c == '+') flags |= _SIGNED;
if (c == ' ') flags |= _SPACED;
if (c == '0') flags |= _ZEROS;
if (c == '-') flags |= FLAG_LEFT;
if (c == '+') flags |= FLAG_SIGNED;
if (c == ' ') flags |= FLAG_SPACED;
if (c == '0') flags |= FLAG_ZEROS;
c = *fmt++;
}
if (flags & _SIGNED) flags &= ~_SPACED;
if (flags & _LEFT) flags &= ~_ZEROS;
if (flags & FLAG_SIGNED) flags &= ~FLAG_SPACED;
if (flags & FLAG_LEFT) flags &= ~FLAG_ZEROS;
/* width */
if (c == '*') {
@ -862,7 +827,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
u.l = va_arg(ap, int);
if (u.l < 0) {
u.l = -u.l;
flags |= _NEG;
flags |= FLAG_NEG;
}
goto do_long;
case TYPE_UINT16:
@ -872,7 +837,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
u.l = va_arg(ap, int);
if (u.l < 0) {
u.l = -u.l;
flags |= _NEG;
flags |= FLAG_NEG;
}
goto do_long;
case TYPE_UINTN:
@ -883,7 +848,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
u.l = va_arg(ap, JSInt32);
if (u.l < 0) {
u.l = -u.l;
flags |= _NEG;
flags |= FLAG_NEG;
}
goto do_long;
case TYPE_UINT32:
@ -899,7 +864,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
u.ll = va_arg(ap, JSInt64);
if (!JSLL_GE_ZERO(u.ll)) {
JSLL_NEG(u.ll, u.ll);
flags |= _NEG;
flags |= FLAG_NEG;
}
goto do_longlong;
case TYPE_UINT64:
@ -935,7 +900,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
case 'c':
u.ch = va_arg(ap, int);
if ((flags & _LEFT) == 0) {
if ((flags & FLAG_LEFT) == 0) {
while (width-- > 1) {
rv = (*ss->stuff)(ss, " ", 1);
if (rv < 0) {
@ -947,7 +912,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
if (rv < 0) {
return rv;
}
if (flags & _LEFT) {
if (flags & FLAG_LEFT) {
while (width-- > 1) {
rv = (*ss->stuff)(ss, " ", 1);
if (rv < 0) {