Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
fde8edaf
Commit
fde8edaf
authored
Oct 25, 2001
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add do { ... } while (0) to more bad macros.
parent
b4a57b06
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
89 additions
and
42 deletions
+89
-42
contrib/fuzzystrmatch/fuzzystrmatch.c
contrib/fuzzystrmatch/fuzzystrmatch.c
+2
-2
contrib/pgcrypto/md5.c
contrib/pgcrypto/md5.c
+13
-9
contrib/pgcrypto/sha1.c
contrib/pgcrypto/sha1.c
+7
-5
contrib/tsearch/query.c
contrib/tsearch/query.c
+3
-1
contrib/tsearch/txtidx.c
contrib/tsearch/txtidx.c
+6
-2
src/backend/port/dynloader/bsdi.h
src/backend/port/dynloader/bsdi.h
+5
-1
src/backend/port/dynloader/linux.h
src/backend/port/dynloader/linux.h
+8
-3
src/backend/regex/engine.c
src/backend/regex/engine.c
+6
-1
src/backend/regex/regexec.c
src/backend/regex/regexec.c
+13
-4
src/backend/utils/adt/pg_lzcompress.c
src/backend/utils/adt/pg_lzcompress.c
+13
-9
src/interfaces/odbc/convert.c
src/interfaces/odbc/convert.c
+6
-3
src/interfaces/odbc/iodbc.h
src/interfaces/odbc/iodbc.h
+5
-1
src/tools/find_baddefs
src/tools/find_baddefs
+2
-1
No files found.
contrib/fuzzystrmatch/fuzzystrmatch.c
View file @
fde8edaf
...
@@ -280,9 +280,9 @@ char Lookahead(char * word, int how_far) {
...
@@ -280,9 +280,9 @@ char Lookahead(char * word, int how_far) {
/* phonize one letter */
/* 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 */
/* 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? */
/* How long is the phoned word? */
#define Phone_Len (p_idx)
#define Phone_Len (p_idx)
...
...
contrib/pgcrypto/md5.c
View file @
fde8edaf
/* $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 $ */
/* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */
/*
/*
...
@@ -41,29 +41,33 @@
...
@@ -41,29 +41,33 @@
#define H(X, Y, Z) ((X) ^ (Y) ^ (Z))
#define H(X, Y, Z) ((X) ^ (Y) ^ (Z))
#define I(X, Y, Z) ((Y) ^ ((X) | (~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) = (a) + F((b), (c), (d)) + X[(k)] + T[(i)]; \
(a) = SHIFT((a), (s)); \
(a) = SHIFT((a), (s)); \
(a) = (b) + (a); \
(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) = (a) + G((b), (c), (d)) + X[(k)] + T[(i)]; \
(a) = SHIFT((a), (s)); \
(a) = SHIFT((a), (s)); \
(a) = (b) + (a); \
(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) = (a) + H((b), (c), (d)) + X[(k)] + T[(i)]; \
(a) = SHIFT((a), (s)); \
(a) = SHIFT((a), (s)); \
(a) = (b) + (a); \
(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) = (a) + I((b), (c), (d)) + X[(k)] + T[(i)]; \
(a) = SHIFT((a), (s)); \
(a) = SHIFT((a), (s)); \
(a) = (b) + (a); \
(a) = (b) + (a); \
}
}
while (0)
#define Sa 7
#define Sa 7
#define Sb 12
#define Sb 12
...
...
contrib/pgcrypto/sha1.c
View file @
fde8edaf
/* $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 $ */
/* $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};
...
@@ -65,22 +65,24 @@ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
#define BCOUNT (ctxt->c.b64[0] / 8)
#define BCOUNT (ctxt->c.b64[0] / 8)
#define W(n) (ctxt->m.b32[(n)])
#define W(n) (ctxt->m.b32[(n)])
#define PUTBYTE(x) { \
#define PUTBYTE(x) \
do { \
ctxt->m.b8[(COUNT % 64)] = (x); \
ctxt->m.b8[(COUNT % 64)] = (x); \
COUNT++; \
COUNT++; \
COUNT %= 64; \
COUNT %= 64; \
ctxt->c.b64[0] += 8; \
ctxt->c.b64[0] += 8; \
if (COUNT % 64 == 0) \
if (COUNT % 64 == 0) \
sha1_step(ctxt); \
sha1_step(ctxt); \
}
} while (0)
#define PUTPAD(x) { \
#define PUTPAD(x) \
do { \
ctxt->m.b8[(COUNT % 64)] = (x); \
ctxt->m.b8[(COUNT % 64)] = (x); \
COUNT++; \
COUNT++; \
COUNT %= 64; \
COUNT %= 64; \
if (COUNT % 64 == 0) \
if (COUNT % 64 == 0) \
sha1_step(ctxt); \
sha1_step(ctxt); \
}
} while (0)
static
void
sha1_step
(
struct
sha1_ctxt
*
);
static
void
sha1_step
(
struct
sha1_ctxt
*
);
...
...
contrib/tsearch/query.c
View file @
fde8edaf
...
@@ -555,7 +555,9 @@ typedef struct {
...
@@ -555,7 +555,9 @@ typedef struct {
int4
buflen
;
int4
buflen
;
}
INFIX
;
}
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; \
int4 len = inf->cur - inf->buf; \
inf->buflen *= 2; \
inf->buflen *= 2; \
inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \
inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \
...
...
contrib/tsearch/txtidx.c
View file @
fde8edaf
...
@@ -88,12 +88,16 @@ uniqueentry( WordEntry* a, int4 l, char *buf, int4 *outbuflen ) {
...
@@ -88,12 +88,16 @@ uniqueentry( WordEntry* a, int4 l, char *buf, int4 *outbuflen ) {
#define WAITNEXTCHAR 3
#define WAITNEXTCHAR 3
#define WAITENDCMPLX 4
#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; \
int4 clen = state->curpos - state->word; \
state->len *= 2; \
state->len *= 2; \
state->word = (char*)repalloc( (void*)state->word, state->len ); \
state->word = (char*)repalloc( (void*)state->word, state->len ); \
state->curpos = state->word + clen; \
state->curpos = state->word + clen; \
}
} \
} while (0)
int4
int4
gettoken_txtidx
(
TI_IN_STATE
*
state
)
{
gettoken_txtidx
(
TI_IN_STATE
*
state
)
{
...
...
src/backend/port/dynloader/bsdi.h
View file @
fde8edaf
...
@@ -27,7 +27,11 @@
...
@@ -27,7 +27,11 @@
#else
/* not HAVE_DLOPEN */
#else
/* not HAVE_DLOPEN */
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
#define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); })
#define pg_dlclose(handle) \
do { \
dld_unlink_by_file(handle, 1); \
free(handle); \
} while (0)
#endif
/* not HAVE_DLOPEN */
#endif
/* not HAVE_DLOPEN */
...
...
src/backend/port/dynloader/linux.h
View file @
fde8edaf
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: linux.h,v 1.1
2 2001/05/14 21:45:53 petere
Exp $
* $Id: linux.h,v 1.1
3 2001/10/25 01:29:37 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -23,10 +23,15 @@
...
@@ -23,10 +23,15 @@
#ifndef HAVE_DLD_H
#ifndef HAVE_DLD_H
#define pg_dlsym(handle, funcname) (NULL)
#define pg_dlsym(handle, funcname) (NULL)
#define pg_dlclose(handle)
({})
#define pg_dlclose(handle)
{}
#else
#else
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
#define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); })
#define pg_dlclose(handle) \
do { \
dld_unlink_by_file(handle, 1); \
free(handle); \
} while (0)
#endif
#endif
#else
/* HAVE_DLOPEN */
#else
/* HAVE_DLOPEN */
...
...
src/backend/regex/engine.c
View file @
fde8edaf
...
@@ -129,7 +129,12 @@ static int pg_isprint(int c);
...
@@ -129,7 +129,12 @@ static int pg_isprint(int c);
#ifdef REDEBUG
#ifdef REDEBUG
#define SP(t, s, c) print(m, t, s, c, stdout)
#define SP(t, s, c) print(m, t, s, c, stdout)
#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); }
#define NOTE(str) \
do { \
if (m->eflags®_TRACE) \
printf("=%s\n", (str)); \
} while (0)
#else
#else
#define SP(t, s, c)
/* nothing */
#define SP(t, s, c)
/* nothing */
#define AT(t, p1, p2, s1, s2)
/* nothing */
#define AT(t, p1, p2, s1, s2)
/* nothing */
...
...
src/backend/regex/regexec.c
View file @
fde8edaf
...
@@ -114,10 +114,19 @@ static int nope = 0; /* for use in asserts; shuts lint up */
...
@@ -114,10 +114,19 @@ static int nope = 0; /* for use in asserts; shuts lint up */
#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
#define STATEVARS int vn; char *space
#define STATEVARS int vn; char *space
#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
#define STATESETUP(m, nv) \
if ((m)->space == NULL) return(REG_ESPACE); \
do { \
(m)->vn = 0; }
(m)->space = malloc((nv)*(m)->g->nstates); \
#define STATETEARDOWN(m) { free((m)->space); }
if ((m)->space == NULL) \
return(REG_ESPACE); \
(m)->vn = 0; \
} while (0)
#define STATETEARDOWN(m) \
do { \
free((m)->space); \
} while (0)
#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
#define onestate int
#define onestate int
#define INIT(o, n) ((o) = (n))
#define INIT(o, n) ((o) = (n))
...
...
src/backend/utils/adt/pg_lzcompress.c
View file @
fde8edaf
/* ----------
/* ----------
* pg_lzcompress.c -
* pg_lzcompress.c -
*
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.1
1 2001/03/22 06:16:1
7 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.1
2 2001/10/25 01:29:3
7 momjian Exp $
*
*
* This is an implementation of LZ compression for PostgreSQL.
* This is an implementation of LZ compression for PostgreSQL.
* It uses a simple history table and generates 2-3 byte tags
* It uses a simple history table and generates 2-3 byte tags
...
@@ -283,7 +283,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
...
@@ -283,7 +283,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
* Adds a new entry to the history table.
* Adds a new entry to the history table.
* ----------
* ----------
*/
*/
#define pglz_hist_add(_hs,_he,_hn,_s,_e) { \
#define pglz_hist_add(_hs,_he,_hn,_s,_e) \
do { \
int __hindex = pglz_hist_idx((_s),(_e)); \
int __hindex = pglz_hist_idx((_s),(_e)); \
if ((_he)[(_hn)].prev == NULL) { \
if ((_he)[(_hn)].prev == NULL) { \
(_hs)[__hindex] = (_he)[(_hn)].next; \
(_hs)[__hindex] = (_he)[(_hn)].next; \
...
@@ -303,7 +304,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
...
@@ -303,7 +304,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
if (++(_hn) >= PGLZ_HISTORY_SIZE) { \
if (++(_hn) >= PGLZ_HISTORY_SIZE) { \
(_hn) = 0; \
(_hn) = 0; \
} \
} \
}
} while (0)
/* ----------
/* ----------
...
@@ -312,7 +313,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
...
@@ -312,7 +313,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
* Outputs the last and allocates a new control byte if needed.
* Outputs the last and allocates a new control byte if needed.
* ----------
* ----------
*/
*/
#define pglz_out_ctrl(__ctrlp,__ctrlb,__ctrl,__buf) { \
#define pglz_out_ctrl(__ctrlp,__ctrlb,__ctrl,__buf) \
do { \
if ((__ctrl & 0xff) == 0) \
if ((__ctrl & 0xff) == 0) \
{ \
{ \
*__ctrlp = __ctrlb; \
*__ctrlp = __ctrlb; \
...
@@ -320,7 +322,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
...
@@ -320,7 +322,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
__ctrlb = 0; \
__ctrlb = 0; \
__ctrl = 1; \
__ctrl = 1; \
} \
} \
}
}
while (0)
/* ----------
/* ----------
...
@@ -330,11 +332,12 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
...
@@ -330,11 +332,12 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
* appropriate control bit.
* appropriate control bit.
* ----------
* ----------
*/
*/
#define pglz_out_literal(_ctrlp,_ctrlb,_ctrl,_buf,_byte) { \
#define pglz_out_literal(_ctrlp,_ctrlb,_ctrl,_buf,_byte) \
do { \
pglz_out_ctrl(_ctrlp,_ctrlb,_ctrl,_buf); \
pglz_out_ctrl(_ctrlp,_ctrlb,_ctrl,_buf); \
*_buf++ = (unsigned char)(_byte); \
*_buf++ = (unsigned char)(_byte); \
_ctrl <<= 1; \
_ctrl <<= 1; \
}
}
while (0)
/* ----------
/* ----------
...
@@ -345,7 +348,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
...
@@ -345,7 +348,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
* appropriate control bit.
* appropriate control bit.
* ----------
* ----------
*/
*/
#define pglz_out_tag(_ctrlp,_ctrlb,_ctrl,_buf,_len,_off) { \
#define pglz_out_tag(_ctrlp,_ctrlb,_ctrl,_buf,_len,_off) \
do { \
pglz_out_ctrl(_ctrlp,_ctrlb,_ctrl,_buf); \
pglz_out_ctrl(_ctrlp,_ctrlb,_ctrl,_buf); \
_ctrlb |= _ctrl; \
_ctrlb |= _ctrl; \
_ctrl <<= 1; \
_ctrl <<= 1; \
...
@@ -360,7 +364,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
...
@@ -360,7 +364,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
_buf[1] = (unsigned char)((_off) & 0xff); \
_buf[1] = (unsigned char)((_off) & 0xff); \
_buf += 2; \
_buf += 2; \
} \
} \
}
}
while (0)
/* ----------
/* ----------
...
...
src/interfaces/odbc/convert.c
View file @
fde8edaf
...
@@ -817,7 +817,10 @@ do { \
...
@@ -817,7 +817,10 @@ do { \
* Terminate the stmt_with_params string with NULL.
* Terminate the stmt_with_params string with NULL.
*----------
*----------
*/
*/
#define CVT_TERMINATE { new_statement[npos] = '\0'; }
#define CVT_TERMINATE \
do { \
new_statement[npos] = '\0'; \
} while (0)
/*----------
/*----------
* Append a data.
* Append a data.
...
@@ -1434,7 +1437,7 @@ copy_statement_with_parameters(StatementClass *stmt)
...
@@ -1434,7 +1437,7 @@ copy_statement_with_parameters(StatementClass *stmt)
/* error */
/* error */
stmt
->
errormsg
=
"Unrecognized C_parameter type in copy_statement_with_parameters"
;
stmt
->
errormsg
=
"Unrecognized C_parameter type in copy_statement_with_parameters"
;
stmt
->
errornumber
=
STMT_NOT_IMPLEMENTED_ERROR
;
stmt
->
errornumber
=
STMT_NOT_IMPLEMENTED_ERROR
;
CVT_TERMINATE
/* just in case */
CVT_TERMINATE
;
/* just in case */
SC_log_error
(
func
,
""
,
stmt
);
SC_log_error
(
func
,
""
,
stmt
);
return
SQL_ERROR
;
return
SQL_ERROR
;
}
}
...
@@ -1684,7 +1687,7 @@ copy_statement_with_parameters(StatementClass *stmt)
...
@@ -1684,7 +1687,7 @@ copy_statement_with_parameters(StatementClass *stmt)
}
/* end, for */
}
/* end, for */
/* make sure new_statement is always null-terminated */
/* make sure new_statement is always null-terminated */
CVT_TERMINATE
CVT_TERMINATE
;
if
(
conn
->
DriverToDataSource
!=
NULL
)
if
(
conn
->
DriverToDataSource
!=
NULL
)
{
{
...
...
src/interfaces/odbc/iodbc.h
View file @
fde8edaf
...
@@ -8,7 +8,11 @@
...
@@ -8,7 +8,11 @@
#include <sys/types.h>
#include <sys/types.h>
#define MEM_ALLOC(size) (malloc((size_t)(size)))
#define MEM_ALLOC(size) (malloc((size_t)(size)))
#define MEM_FREE(ptr) {if(ptr) free(ptr);}
#define MEM_FREE(ptr) \
do { \
if(ptr) \
free(ptr); \
} while (0)
#define STRCPY(t, s) (strcpy((char*)(t), (char*)(s)))
#define STRCPY(t, s) (strcpy((char*)(t), (char*)(s)))
#define STRNCPY(t,s,n) (strncpy((char*)(t), (char*)(s), (size_t)(n)))
#define STRNCPY(t,s,n) (strncpy((char*)(t), (char*)(s), (size_t)(n)))
...
...
src/tools/find_baddefs
View file @
fde8edaf
...
@@ -14,6 +14,7 @@ do
...
@@ -14,6 +14,7 @@ do
was_define = "Y"
was_define = "Y"
else
else
was_define = "N"
was_define = "N"
}'
$FILE
}'
"
$FILE
"
grep
-on
'^#define.*{'
"
$FILE
"
|
grep
-v
'do[ ]*{'
done
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment