diff options
| author | Bruce Momjian | 2005-05-25 21:40:43 +0000 |
|---|---|---|
| committer | Bruce Momjian | 2005-05-25 21:40:43 +0000 |
| commit | b492c3acccb3f8c97559ddfc2a25f25953a026d2 (patch) | |
| tree | a9c42aa2bd86a88a849ffaa005766ffe3dee762a /contrib/tsearch2/tsvector.h | |
| parent | 13b729ca5267b58005f1ca9c873a86c2b0db3591 (diff) | |
Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
Diffstat (limited to 'contrib/tsearch2/tsvector.h')
| -rw-r--r-- | contrib/tsearch2/tsvector.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/contrib/tsearch2/tsvector.h b/contrib/tsearch2/tsvector.h index 358ec570b69..e2fd0b6faef 100644 --- a/contrib/tsearch2/tsvector.h +++ b/contrib/tsearch2/tsvector.h @@ -37,7 +37,7 @@ typedef struct typedef uint16 WordEntryPos; #define WEP_GETWEIGHT(x) ( (x) >> 14 ) -#define WEP_GETPOS(x) ( (x) & 0x3fff ) +#define WEP_GETPOS(x) ( (x) & 0x3fff ) #define WEP_SETWEIGHT(x,v) (x) = ( (v) << 14 ) | ( (x) & 0x3fff ) #define WEP_SETPOS(x,v) (x) = ( (x) & 0xc000 ) | ( (v) & 0x3fff ) @@ -54,11 +54,11 @@ typedef struct char data[1]; } tsvector; -#define DATAHDRSIZE (sizeof(int4)*2) -#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr ) -#define ARRPTR(x) ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) ) -#define STRPTR(x) ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((tsvector*)x)->size ) ) -#define STRSIZE(x) ( ((tsvector*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((tsvector*)x)->size ) ) +#define DATAHDRSIZE (sizeof(int4) * 2) +#define CALCDATASIZE(x, lenstr) ( (x) * sizeof(WordEntry) + DATAHDRSIZE + (lenstr) ) +#define ARRPTR(x) ( (WordEntry*) ( (char*)(x) + DATAHDRSIZE ) ) +#define STRPTR(x) ( (char*)(x) + DATAHDRSIZE + ( sizeof(WordEntry) * ((tsvector*)(x))->size ) ) +#define STRSIZE(x) ( ((tsvector*)(x))->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((tsvector*)(x))->size ) ) #define _POSDATAPTR(x,e) (STRPTR(x)+((WordEntry*)(e))->pos+SHORTALIGN(((WordEntry*)(e))->len)) #define POSDATALEN(x,e) ( ( ((WordEntry*)(e))->haspos ) ? (*(uint16*)_POSDATAPTR(x,e)) : 0 ) #define POSDATAPTR(x,e) ( (WordEntryPos*)( _POSDATAPTR(x,e)+sizeof(uint16) ) ) |
