|
8 | 8 | # |
9 | 9 | # |
10 | 10 | # IDENTIFICATION |
11 | | -# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.12 1998/10/28 19:38:47 tgl Exp $ |
| 11 | +# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $ |
12 | 12 | # |
13 | 13 | # NOTES |
14 | 14 | # Passes any -D options on to cpp prior to generating the list |
@@ -83,7 +83,7 @@ cat > $HFILE <<FuNkYfMgRsTuFf |
83 | 83 | * |
84 | 84 | * Copyright (c) 1994, Regents of the University of California |
85 | 85 | * |
86 | | - *$Id: Gen_fmgrtab.sh.in,v 1.12 1998/10/28 19:38:47 tgl Exp $ |
| 86 | + *$Id: Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $ |
87 | 87 | * |
88 | 88 | * NOTES |
89 | 89 | ******************************* |
@@ -197,7 +197,7 @@ cat > $TABCFILE <<FuNkYfMgRtAbStUfF |
197 | 197 | * |
198 | 198 | * |
199 | 199 | * IDENTIFICATION |
200 | | - *$Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.12 1998/10/28 19:38:47 tgl Exp $ |
| 200 | + *$Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $ |
201 | 201 | * |
202 | 202 | * NOTES |
203 | 203 | * |
@@ -250,36 +250,38 @@ cat >> $TABCFILE <<FuNkYfMgRtAbStUfF |
250 | 250 | #endif /* WIN32 */ |
251 | 251 | }; |
252 | 252 |
|
253 | | -static int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrCall)) - 1; |
| 253 | +/* Note FMGR_NBUILTINS excludes the guardian entry, which is probably |
| 254 | + * not really needed at all ... |
| 255 | + */ |
| 256 | +#define FMGR_NBUILTINS ((sizeof(fmgr_builtins) / sizeof(FmgrCall)) - 1) |
254 | 257 |
|
255 | 258 | FmgrCall *fmgr_isbuiltin(Oid id) |
256 | 259 | { |
257 | | - register int i = 0; |
258 | 260 | intlow = 0; |
259 | | - inthigh =fmgr_nbuiltins; |
260 | | -
|
261 | | - low= 0; |
262 | | - high= fmgr_nbuiltins; |
263 | | -while (low <= high) { |
264 | | -i =low+ (high - low) / 2; |
265 | | -if (id == fmgr_builtins[i].proid) |
266 | | - break; |
267 | | -elseif (id> fmgr_builtins[i].proid) |
268 | | - low = i + 1; |
269 | | -else |
270 | | - high= i- 1; |
271 | | - } |
272 | | - if (id == fmgr_builtins[i].proid) |
273 | | -return(&fmgr_builtins[i]); |
274 | | -return((FmgrCall *) NULL); |
| 261 | + inthigh =FMGR_NBUILTINS - 1; |
| 262 | +
|
| 263 | +/* Loop invariant:lowis the first index that could contain target |
| 264 | + * entry, andhighis the last index that could contain it. |
| 265 | + */ |
| 266 | +while (low<=high) { |
| 267 | +int i = (high + low) / 2; |
| 268 | +FmgrCall * ptr = &fmgr_builtins[i]; |
| 269 | +if (id== ptr->proid) |
| 270 | +return ptr; |
| 271 | +else if (id > ptr->proid) |
| 272 | +low= i+ 1; |
| 273 | +else |
| 274 | +high = i - 1; |
| 275 | +} |
| 276 | +return (FmgrCall *) NULL; |
275 | 277 | } |
276 | 278 |
|
277 | 279 | func_ptr fmgr_lookupByName(char *name) |
278 | 280 | { |
279 | 281 | int i; |
280 | | - for (i=0;i<fmgr_nbuiltins;i++) { |
281 | | -if (strcmp(name,fmgr_builtins[i].funcName) == 0) |
282 | | -return(fmgr_builtins[i].func); |
| 282 | + for (i=0; i<FMGR_NBUILTINS;i++) { |
| 283 | +if (strcmp(name,fmgr_builtins[i].funcName) == 0) |
| 284 | +return(fmgr_builtins[i].func); |
283 | 285 | } |
284 | 286 | return((func_ptr) NULL); |
285 | 287 | } |
|