1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Add do { ... } while (0) to more bad macros.

This commit is contained in:
Bruce Momjian
2001-10-25 01:29:37 +00:00
parent b4a57b0648
commit fde8edaf53
13 changed files with 89 additions and 42 deletions

View File

@ -280,9 +280,9 @@ char Lookahead(char * word, int how_far) {
/* phonize one letter */
#define Phonize(c) {(*phoned_word)[p_idx++] = c;}
#define Phonize(c) do {(*phoned_word)[p_idx++] = c;} while (0)
/* Slap a null character on the end of the phoned word */
#define End_Phoned_Word {(*phoned_word)[p_idx] = '\0';}
#define End_Phoned_Word do {(*phoned_word)[p_idx] = '\0';} while (0)
/* How long is the phoned word? */
#define Phone_Len (p_idx)

View File

@ -1,4 +1,4 @@
/* $Id: md5.c,v 1.6 2001/08/21 00:42:41 momjian Exp $ */
/* $Id: md5.c,v 1.7 2001/10/25 01:29:37 momjian Exp $ */
/* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */
/*
@ -41,29 +41,33 @@
#define H(X, Y, Z) ((X) ^ (Y) ^ (Z))
#define I(X, Y, Z) ((Y) ^ ((X) | (~Z)))
#define ROUND1(a, b, c, d, k, s, i) { \
#define ROUND1(a, b, c, d, k, s, i) \
do { \
(a) = (a) + F((b), (c), (d)) + X[(k)] + T[(i)]; \
(a) = SHIFT((a), (s)); \
(a) = (b) + (a); \
}
} while (0)
#define ROUND2(a, b, c, d, k, s, i) { \
#define ROUND2(a, b, c, d, k, s, i) \
do { \
(a) = (a) + G((b), (c), (d)) + X[(k)] + T[(i)]; \
(a) = SHIFT((a), (s)); \
(a) = (b) + (a); \
}
} while (0)
#define ROUND3(a, b, c, d, k, s, i) { \
#define ROUND3(a, b, c, d, k, s, i) \
do { \
(a) = (a) + H((b), (c), (d)) + X[(k)] + T[(i)]; \
(a) = SHIFT((a), (s)); \
(a) = (b) + (a); \
}
} while (0)
#define ROUND4(a, b, c, d, k, s, i) { \
#define ROUND4(a, b, c, d, k, s, i) \
do { \
(a) = (a) + I((b), (c), (d)) + X[(k)] + T[(i)]; \
(a) = SHIFT((a), (s)); \
(a) = (b) + (a); \
}
} while (0)
#define Sa 7
#define Sb 12

View File

@ -1,4 +1,4 @@
/* $Id: sha1.c,v 1.6 2001/08/21 00:42:41 momjian Exp $ */
/* $Id: sha1.c,v 1.7 2001/10/25 01:29:37 momjian Exp $ */
/* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
/*
@ -65,22 +65,24 @@ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
#define BCOUNT (ctxt->c.b64[0] / 8)
#define W(n) (ctxt->m.b32[(n)])
#define PUTBYTE(x) { \
#define PUTBYTE(x) \
do { \
ctxt->m.b8[(COUNT % 64)] = (x); \
COUNT++; \
COUNT %= 64; \
ctxt->c.b64[0] += 8; \
if (COUNT % 64 == 0) \
sha1_step(ctxt); \
}
} while (0)
#define PUTPAD(x) { \
#define PUTPAD(x) \
do { \
ctxt->m.b8[(COUNT % 64)] = (x); \
COUNT++; \
COUNT %= 64; \
if (COUNT % 64 == 0) \
sha1_step(ctxt); \
}
} while (0)
static void sha1_step(struct sha1_ctxt *);

View File

@ -555,7 +555,9 @@ typedef struct {
int4 buflen;
} INFIX;
#define RESIZEBUF(inf,addsize) while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) { \
#define RESIZEBUF(inf,addsize) \
while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \
{ \
int4 len = inf->cur - inf->buf; \
inf->buflen *= 2; \
inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \

View File

@ -88,12 +88,16 @@ uniqueentry( WordEntry* a, int4 l, char *buf, int4 *outbuflen ) {
#define WAITNEXTCHAR 3
#define WAITENDCMPLX 4
#define RESIZEPRSBUF if ( state->curpos - state->word == state->len ) { \
#define RESIZEPRSBUF \
do { \
if ( state->curpos - state->word == state->len ) \
{ \
int4 clen = state->curpos - state->word; \
state->len *= 2; \
state->word = (char*)repalloc( (void*)state->word, state->len ); \
state->curpos = state->word + clen; \
}
} \
} while (0)
int4
gettoken_txtidx( TI_IN_STATE *state ) {