diff options
Diffstat (limited to 'src/backend/port')
89 files changed, 11788 insertions, 0 deletions
diff --git a/src/backend/port/BSD44_derived/Makefile.inc b/src/backend/port/BSD44_derived/Makefile.inc new file mode 100644 index 00000000000..9ef7ffc463d --- /dev/null +++ b/src/backend/port/BSD44_derived/Makefile.inc @@ -0,0 +1,28 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/BSD44_derived (for OSs derived from 4.4-lite BSD) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/BSD44_derived/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:41 scrappy Exp $ +# +#------------------------------------------------------------------------- + +CFLAGS+= -DUSE_POSIX_TIME + +# +# 4.4-lite BSD-derived OSs require that the lex library be included, +# in case yywrap is defined +# +LDADD+= -ll + +# +# 4.4-lite BSD-derived OSs have a little trouble with partially-implemented +# dynamic loading soutines. See the comments in port-protos.h. +# +SUBSRCS= dl.c + +HEADERS+= float.h machine.h port-protos.h diff --git a/src/backend/port/BSD44_derived/README b/src/backend/port/BSD44_derived/README new file mode 100644 index 00000000000..acfd1e66af1 --- /dev/null +++ b/src/backend/port/BSD44_derived/README @@ -0,0 +1,4 @@ +The NetBSD port was done by Alistair G. Crooks (agc@uts.amdahl.com). + +It was extended to cover Operating Systems derived from the 4.4-lite +BSD release by Alistair G. Crooks. diff --git a/src/backend/port/BSD44_derived/dl.c b/src/backend/port/BSD44_derived/dl.c new file mode 100644 index 00000000000..394fb8a2e0a --- /dev/null +++ b/src/backend/port/BSD44_derived/dl.c @@ -0,0 +1,88 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <nlist.h> +#include <link.h> + +#include <stdio.h> +#include <stdlib.h> + +static char error_message[BUFSIZ]; + +char * +BSD44_derived_dlerror(void) +{ + static char ret[BUFSIZ]; + + (void) strcpy(ret, error_message); + error_message[0] = 0; + return((ret[0] == 0) ? (char *) NULL : ret); +} + +void * +BSD44_derived_dlopen(char *file, int num) +{ + void *vp; + + if ((vp = dlopen(file, num)) == (void *) NULL) { + (void) sprintf(error_message, "dlopen (%s) failed", file); + } + return(vp); +} + +void * +BSD44_derived_dlsym(void *handle, char *name) +{ + void *vp; + char buf[BUFSIZ]; + + if (*name != '_') { + (void) sprintf(buf, "_%s", name); + name = buf; + } + if ((vp = dlsym(handle, name)) == (void *) NULL) { + (void) sprintf(error_message, "dlsym (%s) failed", name); + } + return(vp); +} + +void +BSD44_derived_dlclose(void *handle) +{ + dlclose(handle); +} diff --git a/src/backend/port/BSD44_derived/float.h b/src/backend/port/BSD44_derived/float.h new file mode 100644 index 00000000000..f1348bf9eaf --- /dev/null +++ b/src/backend/port/BSD44_derived/float.h @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + * + * float.h-- + * definitions for ANSI floating point + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: float.h,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $ + * + * NOTES + * These come straight out of ANSI X3.159-1989 (p.18) and + * would be unnecessary if SunOS 4 were ANSI-compliant. + * + * This is only a partial listing because I'm lazy to type + * the whole thing in. + * + *------------------------------------------------------------------------- + */ +#ifndef FLOAT_H +#define FLOAT_H + +#define FLT_DIG 6 +#define FLT_MIN ((float) 1.17549435e-38) +#define FLT_MAX ((float) 3.40282347e+38) +#define DBL_DIG 15 +#define DBL_MIN 2.2250738585072014e-308 +#define DBL_MAX 1.7976931348623157e+308 + +#endif /* FLOAT_H */ diff --git a/src/backend/port/BSD44_derived/machine.h b/src/backend/port/BSD44_derived/machine.h new file mode 100644 index 00000000000..3d4e7656609 --- /dev/null +++ b/src/backend/port/BSD44_derived/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/BSD44_derived/port-protos.h b/src/backend/port/BSD44_derived/port-protos.h new file mode 100644 index 00000000000..d397b4d3ed8 --- /dev/null +++ b/src/backend/port/BSD44_derived/port-protos.h @@ -0,0 +1,41 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for NetBSD 1.0 + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include <sys/types.h> +#include <nlist.h> +#include <link.h> + +#include "fmgr.h" /* for func_ptr */ +#include "utils/dynamic_loader.h" + +/* dynloader.c */ +/* + * Dynamic Loader on NetBSD 1.0. + * + * this dynamic loader uses the system dynamic loading interface for shared + * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared + * library as the file to be dynamically loaded. + * + * agc - I know this is all a bit crufty, but it does work, is fairly + * portable, and works (the stipulation that the d.l. function must + * begin with an underscore is fairly tricky, and some versions of + * NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.) + */ +#define pg_dlopen(f) BSD44_derived_dlopen(f, 1) +#define pg_dlsym BSD44_derived_dlsym +#define pg_dlclose BSD44_derived_dlclose +#define pg_dlerror BSD44_derived_dlerror + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/Makefile.inc b/src/backend/port/Makefile.inc new file mode 100644 index 00000000000..a21fd46968f --- /dev/null +++ b/src/backend/port/Makefile.inc @@ -0,0 +1,21 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for the port module (for code specific to various UNIX +# platforms) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:41 scrappy Exp $ +# +#------------------------------------------------------------------------- + +portdir= $(CURDIR)/port/$(PORTNAME) +VPATH:= $(VPATH):$(portdir) + +SUBSRCS= +include $(portdir)/Makefile.inc +SRCS_PORT:= $(SUBSRCS) + diff --git a/src/backend/port/aix/Makefile.inc b/src/backend/port/aix/Makefile.inc new file mode 100644 index 00000000000..6954174c7d2 --- /dev/null +++ b/src/backend/port/aix/Makefile.inc @@ -0,0 +1,40 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/aix (AIX specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/aix/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:41 scrappy Exp $ +# +#------------------------------------------------------------------------- + +# +# aix has fast linkers and don't need the BIGOBJ stuff. +# +BIGOBJS=false + +CFLAGS+= -DCLASS_CONFLICT -DDISABLE_XOPEN_NLS -DNEED_ISINF + +LDFLAGS+= -bE:$(objdir)/$(PROG).exp + +LDADD+= -ll -lld + +HEADERS+= dlfcn.h machine.h port-protos.h + +SUBSRCS+= dlfcn.c + +${PROG}.exp: ${PROG}.noexp + mv -f $(objdir)/${PROG}.noexp $(objdir)/${PROG} + $(CURDIR)/port/aix/mkldexport.sh $(objdir)/${PROG} ${BINDIR} > $(objdir)/${PROG}.exp + mv -f $(objdir)/${PROG} $(objdir)/${PROG}.noexp + +${PROG}.noexp: ${OBJS} + touch -f $(objdir)/${PROG}.exp + ${CC} ${LDFLAGS} -o $(objdir)/${PROG}.noexp ${OBJS} ${LDADD} + +EXPORTS= ${PROG}.exp + +CLEANFILES+= ${PROG}.noexp ${PROG}.exp diff --git a/src/backend/port/aix/README.dlfcn b/src/backend/port/aix/README.dlfcn new file mode 100644 index 00000000000..f64446d49b5 --- /dev/null +++ b/src/backend/port/aix/README.dlfcn @@ -0,0 +1,167 @@ +Copyright (c) 1992,1993,1995, Jens-Uwe Mager, Helios Software GmbH +Not derived from licensed software. + +Permission is granted to freely use, copy, modify, and redistribute +this software, provided that no attempt is made to gain profit from it, +the author is not construed to be liable for any results of using the +software, alterations are clearly marked as such, and this notice is +not modified. + +libdl.a +------- + +This is an emulation library to emulate the SunOS/System V.4 functions +to access the runtime linker. The functions are emulated by using the +AIX load() function and by reading the .loader section of the loaded +module to find the exports. The to be loaded module should be linked as +follows (if using AIX 3): + + cc -o module.so -bM:SRE -bE:module.exp -e _nostart $(OBJS) + +For AIX 4: + + cc -o module.so -bM:SRE -bE:module.exp -bnoentry $(OBJS) + +The module export file contains the symbols to be exported. Because +this library uses the loader section, the final module.so file can be +stripped. C++ users should build their shared objects using the script +makeC++SharedLib (part of the IBM C++ compiler), this will make sure +that constructors and destructors for static and global objects will be +called upon loading and unloading the module. + +Usage +----- + +void *dlopen(const char *path, int mode); + +This routine loads the module pointed to by path and reads its export +table. If the path does not contain a '/' character, dlopen will search +for the module using the LIBPATH environment variable. It returns an +opaque handle to the module or NULL on error. The mode parameter can be +either RTLD_LAZY (for lazy function binding) or RTLD_NOW for immediate +function binding. The AIX implementation currently does treat RTLD_NOW +the same as RTLD_LAZY. The flag RTLD_GLOBAL might be or'ed into the +mode parameter to allow loaded modules to bind to global variables or +functions in other loaded modules loaded by dlopen(). If RTLD_GLOBAL is +not specified, only globals from the main part of the executable or +shared libraries are used to look for undefined symbols in loaded +modules. + + +void *dlsym(void *handle, const char *symbol); + +This routine searches for the symbol in the module referred to by +handle and returns its address. If the symbol could not be found, the +function returns NULL. The return value must be casted to a proper +function pointer before it can be used. SunOS/System V.4 allow handle +to be a NULL pointer to refer to the module the call is made from, this +is not implemented. + +int dlclose(void *handle); + +This routine unloads the module referred to by the handle and disposes +of any local storage. this function returns -1 on failure. + +char *dlerror(void); + +This routine can be used to retrieve a text message describing the most +recent error that occured on on of the above routines. This function +returns NULL if there is not error information. + +Initialization and termination handlers +--------------------------------------- + +The emulation provides for an initialization and a termination +handler. The dlfcn.h file contains a structure declaration named +dl_info with following members: + + void (*init)(void); + void (*fini)(void); + +The init function is called upon first referencing the library. The +fini function is called at dlclose() time or when the process exits. +The module should declare a variable named dl_info that contains this +structure which must be exported. These functions correspond to the +documented _init() and _fini() functions of SunOS 4.x, but these are +appearently not implemented in SunOS. When using SunOS 5.0, these +correspond to #pragma init and #pragma fini respectively. At the same +time any static or global C++ object's constructors or destructors will +be called. + +Jens-Uwe Mager + +HELIOS Software GmbH +Lavesstr. 80 +30159 Hannover +Germany + +Phone: +49 511 36482-0 +FAX: +49 511 36482-69 +AppleLink: helios.de Attn: Jens-Uwe Mager +Internet: jum@helios.de + +Revison History +--------------- + +SCCS/s.dlfcn.h: + +D 1.4 95/04/25 09:36:52 jum 4 3 00018/00004/00028 +MRs: +COMMENTS: +added RTLD_GLOBAL, include and C++ guards + +D 1.3 92/12/27 20:58:32 jum 3 2 00001/00001/00031 +MRs: +COMMENTS: +we always have prototypes on RS/6000 + +D 1.2 92/08/16 17:45:11 jum 2 1 00009/00000/00023 +MRs: +COMMENTS: +added dl_info structure to implement initialize and terminate functions + +D 1.1 92/08/02 18:08:45 jum 1 0 00023/00000/00000 +MRs: +COMMENTS: +Erstellungsdatum und -uhrzeit 92/08/02 18:08:45 von jum + +SCCS/s.dlfcn.c: + +D 1.7 95/08/14 19:08:38 jum 8 6 00026/00004/00502 +MRs: +COMMENTS: +Integrated the fixes from Kirk Benell (kirk@rsinc.com) to allow loading of +shared objects generated under AIX 4. Fixed bug that symbols with exactly +8 characters would use garbage characters from the following symbol value. + +D 1.6 95/04/25 09:38:03 jum 6 5 00046/00006/00460 +MRs: +COMMENTS: +added handling of C++ static constructors and destructors, added RTLD_GLOBAL to bind against other loaded modules + +D 1.5 93/02/14 20:14:17 jum 5 4 00002/00000/00464 +MRs: +COMMENTS: +added path to dlopen error message to make clear where there error occured. + +D 1.4 93/01/03 19:13:56 jum 4 3 00061/00005/00403 +MRs: +COMMENTS: +to allow calling symbols in the main module call load with L_NOAUTODEFER and +do a loadbind later with the main module. + +D 1.3 92/12/27 20:59:55 jum 3 2 00066/00008/00342 +MRs: +COMMENTS: +added search by L_GETINFO if module got loaded by LIBPATH + +D 1.2 92/08/16 17:45:43 jum 2 1 00074/00006/00276 +MRs: +COMMENTS: +implemented initialize and terminate functions, added reference counting to avoid multiple loads of the same library + +D 1.1 92/08/02 18:08:45 jum 1 0 00282/00000/00000 +MRs: +COMMENTS: +Erstellungsdatum und -uhrzeit 92/08/02 18:08:45 von jum + diff --git a/src/backend/port/aix/dlfcn.c b/src/backend/port/aix/dlfcn.c new file mode 100644 index 00000000000..9ae113ce06e --- /dev/null +++ b/src/backend/port/aix/dlfcn.c @@ -0,0 +1,528 @@ +/* + * @(#)dlfcn.c 1.7 revision of 95/08/14 19:08:38 + * This is an unpublished work copyright (c) 1992 HELIOS Software GmbH + * 30159 Hannover, Germany + */ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/ldr.h> +#include <a.out.h> +#include <ldfcn.h> +#include "dlfcn.h" + +/* + * We simulate dlopen() et al. through a call to load. Because AIX has + * no call to find an exported symbol we read the loader section of the + * loaded module and build a list of exported symbols and their virtual + * address. + */ + +typedef struct { + char *name; /* the symbols's name */ + void *addr; /* its relocated virtual address */ +} Export, *ExportPtr; + +/* + * xlC uses the following structure to list its constructors and + * destructors. This is gleaned from the output of munch. + */ +typedef struct { + void (*init)(void); /* call static constructors */ + void (*term)(void); /* call static destructors */ +} Cdtor, *CdtorPtr; + +/* + * The void * handle returned from dlopen is actually a ModulePtr. + */ +typedef struct Module { + struct Module *next; + char *name; /* module name for refcounting */ + int refCnt; /* the number of references */ + void *entry; /* entry point from load */ + struct dl_info *info; /* optional init/terminate functions */ + CdtorPtr cdtors; /* optional C++ constructors */ + int nExports; /* the number of exports found */ + ExportPtr exports; /* the array of exports */ +} Module, *ModulePtr; + +/* + * We keep a list of all loaded modules to be able to call the fini + * handlers and destructors at atexit() time. + */ +static ModulePtr modList; + +/* + * The last error from one of the dl* routines is kept in static + * variables here. Each error is returned only once to the caller. + */ +static char errbuf[BUFSIZ]; +static int errvalid; + +extern char *strdup(const char *); +static void caterr(char *); +static int readExports(ModulePtr); +static void terminate(void); +static void *findMain(void); + +void *dlopen(const char *path, int mode) +{ + register ModulePtr mp; + static void *mainModule; + + /* + * Upon the first call register a terminate handler that will + * close all libraries. Also get a reference to the main module + * for use with loadbind. + */ + if (!mainModule) { + if ((mainModule = findMain()) == NULL) + return NULL; + atexit(terminate); + } + /* + * Scan the list of modules if we have the module already loaded. + */ + for (mp = modList; mp; mp = mp->next) + if (strcmp(mp->name, path) == 0) { + mp->refCnt++; + return mp; + } + if ((mp = (ModulePtr)calloc(1, sizeof(*mp))) == NULL) { + errvalid++; + strcpy(errbuf, "calloc: "); + strcat(errbuf, strerror(errno)); + return NULL; + } + if ((mp->name = strdup(path)) == NULL) { + errvalid++; + strcpy(errbuf, "strdup: "); + strcat(errbuf, strerror(errno)); + free(mp); + return NULL; + } + /* + * load should be declared load(const char *...). Thus we + * cast the path to a normal char *. Ugly. + */ + if ((mp->entry = (void *)load((char *)path, L_NOAUTODEFER, NULL)) == NULL) { + free(mp->name); + free(mp); + errvalid++; + strcpy(errbuf, "dlopen: "); + strcat(errbuf, path); + strcat(errbuf, ": "); + /* + * If AIX says the file is not executable, the error + * can be further described by querying the loader about + * the last error. + */ + if (errno == ENOEXEC) { + char *tmp[BUFSIZ/sizeof(char *)]; + if (loadquery(L_GETMESSAGES, tmp, sizeof(tmp)) == -1) + strcpy(errbuf, strerror(errno)); + else { + char **p; + for (p = tmp; *p; p++) + caterr(*p); + } + } else + strcat(errbuf, strerror(errno)); + return NULL; + } + mp->refCnt = 1; + mp->next = modList; + modList = mp; + if (loadbind(0, mainModule, mp->entry) == -1) { + dlclose(mp); + errvalid++; + strcpy(errbuf, "loadbind: "); + strcat(errbuf, strerror(errno)); + return NULL; + } + /* + * If the user wants global binding, loadbind against all other + * loaded modules. + */ + if (mode & RTLD_GLOBAL) { + register ModulePtr mp1; + for (mp1 = mp->next; mp1; mp1 = mp1->next) + if (loadbind(0, mp1->entry, mp->entry) == -1) { + dlclose(mp); + errvalid++; + strcpy(errbuf, "loadbind: "); + strcat(errbuf, strerror(errno)); + return NULL; + } + } + if (readExports(mp) == -1) { + dlclose(mp); + return NULL; + } + /* + * If there is a dl_info structure, call the init function. + */ + if (mp->info = (struct dl_info *)dlsym(mp, "dl_info")) { + if (mp->info->init) + (*mp->info->init)(); + } else + errvalid = 0; + /* + * If the shared object was compiled using xlC we will need + * to call static constructors (and later on dlclose destructors). + */ + if (mp->cdtors = (CdtorPtr)dlsym(mp, "__cdtors")) { + while (mp->cdtors->init) { + (*mp->cdtors->init)(); + mp->cdtors++; + } + } else + errvalid = 0; + return mp; +} + +/* + * Attempt to decipher an AIX loader error message and append it + * to our static error message buffer. + */ +static void caterr(char *s) +{ + register char *p = s; + + while (*p >= '0' && *p <= '9') + p++; + switch(atoi(s)) { + case L_ERROR_TOOMANY: + strcat(errbuf, "to many errors"); + break; + case L_ERROR_NOLIB: + strcat(errbuf, "can't load library"); + strcat(errbuf, p); + break; + case L_ERROR_UNDEF: + strcat(errbuf, "can't find symbol"); + strcat(errbuf, p); + break; + case L_ERROR_RLDBAD: + strcat(errbuf, "bad RLD"); + strcat(errbuf, p); + break; + case L_ERROR_FORMAT: + strcat(errbuf, "bad exec format in"); + strcat(errbuf, p); + break; + case L_ERROR_ERRNO: + strcat(errbuf, strerror(atoi(++p))); + break; + default: + strcat(errbuf, s); + break; + } +} + +void *dlsym(void *handle, const char *symbol) +{ + register ModulePtr mp = (ModulePtr)handle; + register ExportPtr ep; + register int i; + + /* + * Could speed up the search, but I assume that one assigns + * the result to function pointers anyways. + */ + for (ep = mp->exports, i = mp->nExports; i; i--, ep++) + if (strcmp(ep->name, symbol) == 0) + return ep->addr; + errvalid++; + strcpy(errbuf, "dlsym: undefined symbol "); + strcat(errbuf, symbol); + return NULL; +} + +char *dlerror(void) +{ + if (errvalid) { + errvalid = 0; + return errbuf; + } + return NULL; +} + +int dlclose(void *handle) +{ + register ModulePtr mp = (ModulePtr)handle; + int result; + register ModulePtr mp1; + + if (--mp->refCnt > 0) + return 0; + if (mp->info && mp->info->fini) + (*mp->info->fini)(); + if (mp->cdtors) + while (mp->cdtors->term) { + (*mp->cdtors->term)(); + mp->cdtors++; + } + result = unload(mp->entry); + if (result == -1) { + errvalid++; + strcpy(errbuf, strerror(errno)); + } + if (mp->exports) { + register ExportPtr ep; + register int i; + for (ep = mp->exports, i = mp->nExports; i; i--, ep++) + if (ep->name) + free(ep->name); + free(mp->exports); + } + if (mp == modList) + modList = mp->next; + else { + for (mp1 = modList; mp1; mp1 = mp1->next) + if (mp1->next == mp) { + mp1->next = mp->next; + break; + } + } + free(mp->name); + free(mp); + return result; +} + +static void terminate(void) +{ + while (modList) + dlclose(modList); +} + +/* + * Build the export table from the XCOFF .loader section. + */ +static int readExports(ModulePtr mp) +{ + LDFILE *ldp = NULL; + SCNHDR sh, shdata; + LDHDR *lhp; + char *ldbuf; + LDSYM *ls; + int i; + ExportPtr ep; + + if ((ldp = ldopen(mp->name, ldp)) == NULL) { + struct ld_info *lp; + char *buf; + int size = 4*1024; + if (errno != ENOENT) { + errvalid++; + strcpy(errbuf, "readExports: "); + strcat(errbuf, strerror(errno)); + return -1; + } + /* + * The module might be loaded due to the LIBPATH + * environment variable. Search for the loaded + * module using L_GETINFO. + */ + if ((buf = malloc(size)) == NULL) { + errvalid++; + strcpy(errbuf, "readExports: "); + strcat(errbuf, strerror(errno)); + return -1; + } + while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) { + free(buf); + size += 4*1024; + if ((buf = malloc(size)) == NULL) { + errvalid++; + strcpy(errbuf, "readExports: "); + strcat(errbuf, strerror(errno)); + return -1; + } + } + if (i == -1) { + errvalid++; + strcpy(errbuf, "readExports: "); + strcat(errbuf, strerror(errno)); + free(buf); + return -1; + } + /* + * Traverse the list of loaded modules. The entry point + * returned by load() does actually point to the data + * segment origin. + */ + lp = (struct ld_info *)buf; + while (lp) { + if (lp->ldinfo_dataorg == mp->entry) { + ldp = ldopen(lp->ldinfo_filename, ldp); + break; + } + if (lp->ldinfo_next == 0) + lp = NULL; + else + lp = (struct ld_info *)((char *)lp + lp->ldinfo_next); + } + free(buf); + if (!ldp) { + errvalid++; + strcpy(errbuf, "readExports: "); + strcat(errbuf, strerror(errno)); + return -1; + } + } + if (TYPE(ldp) != U802TOCMAGIC) { + errvalid++; + strcpy(errbuf, "readExports: bad magic"); + while(ldclose(ldp) == FAILURE) + ; + return -1; + } + /* + * Get the padding for the data section. This is needed for + * AIX 4.1 compilers. This is used when building the final + * function pointer to the exported symbol. + */ + if (ldnshread(ldp, _DATA, &shdata) != SUCCESS) { + errvalid++; + strcpy(errbuf, "readExports: cannot read data section header"); + while(ldclose(ldp) == FAILURE) + ; + return -1; + } + if (ldnshread(ldp, _LOADER, &sh) != SUCCESS) { + errvalid++; + strcpy(errbuf, "readExports: cannot read loader section header"); + while(ldclose(ldp) == FAILURE) + ; + return -1; + } + /* + * We read the complete loader section in one chunk, this makes + * finding long symbol names residing in the string table easier. + */ + if ((ldbuf = (char *)malloc(sh.s_size)) == NULL) { + errvalid++; + strcpy(errbuf, "readExports: "); + strcat(errbuf, strerror(errno)); + while(ldclose(ldp) == FAILURE) + ; + return -1; + } + if (FSEEK(ldp, sh.s_scnptr, BEGINNING) != OKFSEEK) { + errvalid++; + strcpy(errbuf, "readExports: cannot seek to loader section"); + free(ldbuf); + while(ldclose(ldp) == FAILURE) + ; + return -1; + } + if (FREAD(ldbuf, sh.s_size, 1, ldp) != 1) { + errvalid++; + strcpy(errbuf, "readExports: cannot read loader section"); + free(ldbuf); + while(ldclose(ldp) == FAILURE) + ; + return -1; + } + lhp = (LDHDR *)ldbuf; + ls = (LDSYM *)(ldbuf+LDHDRSZ); + /* + * Count the number of exports to include in our export table. + */ + for (i = lhp->l_nsyms; i; i--, ls++) { + if (!LDR_EXPORT(*ls)) + continue; + mp->nExports++; + } + if ((mp->exports = (ExportPtr)calloc(mp->nExports, sizeof(*mp->exports))) == NULL) { + errvalid++; + strcpy(errbuf, "readExports: "); + strcat(errbuf, strerror(errno)); + free(ldbuf); + while(ldclose(ldp) == FAILURE) + ; + return -1; + } + /* + * Fill in the export table. All entries are relative to + * the entry point we got from load. + */ + ep = mp->exports; + ls = (LDSYM *)(ldbuf+LDHDRSZ); + for (i = lhp->l_nsyms; i; i--, ls++) { + char *symname; + char tmpsym[SYMNMLEN+1]; + if (!LDR_EXPORT(*ls)) + continue; + if (ls->l_zeroes == 0) + symname = ls->l_offset+lhp->l_stoff+ldbuf; + else { + /* + * The l_name member is not zero terminated, we + * must copy the first SYMNMLEN chars and make + * sure we have a zero byte at the end. + */ + strncpy(tmpsym, ls->l_name, SYMNMLEN); + tmpsym[SYMNMLEN] = '\0'; + symname = tmpsym; + } + ep->name = strdup(symname); + ep->addr = (void *)((unsigned long)mp->entry + + ls->l_value - shdata.s_vaddr); + ep++; + } + free(ldbuf); + while(ldclose(ldp) == FAILURE) + ; + return 0; +} + +/* + * Find the main modules entry point. This is used as export pointer + * for loadbind() to be able to resolve references to the main part. + */ +static void * findMain(void) +{ + struct ld_info *lp; + char *buf; + int size = 4*1024; + int i; + void *ret; + + if ((buf = malloc(size)) == NULL) { + errvalid++; + strcpy(errbuf, "findMain: "); + strcat(errbuf, strerror(errno)); + return NULL; + } + while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) { + free(buf); + size += 4*1024; + if ((buf = malloc(size)) == NULL) { + errvalid++; + strcpy(errbuf, "findMain: "); + strcat(errbuf, strerror(errno)); + return NULL; + } + } + if (i == -1) { + errvalid++; + strcpy(errbuf, "findMain: "); + strcat(errbuf, strerror(errno)); + free(buf); + return NULL; + } + /* + * The first entry is the main module. The entry point + * returned by load() does actually point to the data + * segment origin. + */ + lp = (struct ld_info *)buf; + ret = lp->ldinfo_dataorg; + free(buf); + return ret; +} diff --git a/src/backend/port/aix/dlfcn.h b/src/backend/port/aix/dlfcn.h new file mode 100644 index 00000000000..5671e9caa3a --- /dev/null +++ b/src/backend/port/aix/dlfcn.h @@ -0,0 +1,46 @@ +/* + * @(#)dlfcn.h 1.4 revision of 95/04/25 09:36:52 + * This is an unpublished work copyright (c) 1992 HELIOS Software GmbH + * 30159 Hannover, Germany + */ + +#ifndef __dlfcn_h__ +#define __dlfcn_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Mode flags for the dlopen routine. + */ +#define RTLD_LAZY 1 /* lazy function call binding */ +#define RTLD_NOW 2 /* immediate function call binding */ +#define RTLD_GLOBAL 0x100 /* allow symbols to be global */ + +/* + * To be able to intialize, a library may provide a dl_info structure + * that contains functions to be called to initialize and terminate. + */ +struct dl_info { + void (*init)(void); + void (*fini)(void); +}; + +#if __STDC__ || defined(_IBMR2) +void *dlopen(const char *path, int mode); +void *dlsym(void *handle, const char *symbol); +char *dlerror(void); +int dlclose(void *handle); +#else +void *dlopen(); +void *dlsym(); +char *dlerror(); +int dlclose(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __dlfcn_h__ */ diff --git a/src/backend/port/aix/machine.h b/src/backend/port/aix/machine.h new file mode 100644 index 00000000000..e05a1346495 --- /dev/null +++ b/src/backend/port/aix/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:41 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/aix/mkldexport.sh b/src/backend/port/aix/mkldexport.sh new file mode 100755 index 00000000000..378baf92626 --- /dev/null +++ b/src/backend/port/aix/mkldexport.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# +# mkldexport +# create an AIX exports file from an object file +# +# Usage: +# mkldexport objectfile [location] +# where +# objectfile is the current location of the object file. +# location is the eventual (installed) location of the +# object file (if different from the current +# working directory). +# +# [This file comes from the Postgres 4.2 distribution. - ay 7/95] +# +# Header: /usr/local/devel/postgres/src/tools/mkldexport/RCS/mkldexport.sh,v 1.2 1994/03/13 04:59:12 aoki Exp +# + +# setting this to nm -B might be better +NM = /usr/ucb/nm + +CMDNAME=`basename $0` +if [ -z "$1" ]; then + echo "Usage: $CMDNAME object [location]" + exit 1 +fi +OBJNAME=`basename $1` +if [ "`basename $OBJNAME`" != "`basename $OBJNAME .o`" ]; then + OBJNAME=`basename $OBJNAME .o`.so +fi +if [ -z "$2" ]; then + echo '#!' +else + echo '#!' $2/$OBJNAME +fi +$NM -g $1 | \ + egrep ' [TD] ' | \ + sed -e 's/.* //' | \ + egrep -v '\$' | \ + sed -e 's/^[.]//' | \ + sort | \ + uniq diff --git a/src/backend/port/aix/port-protos.h b/src/backend/port/aix/port-protos.h new file mode 100644 index 00000000000..986e5bd7d48 --- /dev/null +++ b/src/backend/port/aix/port-protos.h @@ -0,0 +1,25 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for AIX + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:41 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include "dlfcn.h" /* this is from jum's libdl package */ + +/* dynloader.c */ + +#define pg_dlopen(f) dlopen(filename, RTLD_LAZY) +#define pg_dlsym(h,f) dlsym(h, f) +#define pg_dlclose(h) dlclose(h) +#define pg_dlerror() dlerror() + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/alpha/Makefile.inc b/src/backend/port/alpha/Makefile.inc new file mode 100644 index 00000000000..52ebfe486f7 --- /dev/null +++ b/src/backend/port/alpha/Makefile.inc @@ -0,0 +1,27 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/alpha (Alpha OSF/1 specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/alpha/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $ +# +#------------------------------------------------------------------------- + +CFLAGS+= -DUSE_POSIX_TIME -DDISABLE_XOPEN_NLS -DNEED_ISINF -DHAS_LONG_LONG + +LDADD+= -lln + +# +# The YACC grammar is too big.. +# +#.if !defined(CDEBUG) +##CFLAGS+= -Olimit 2000 +#.endif + +HEADERS+= machine.h port-protos.h + +SUBSRCS= port.c diff --git a/src/backend/port/alpha/machine.h b/src/backend/port/alpha/machine.h new file mode 100644 index 00000000000..3d4e7656609 --- /dev/null +++ b/src/backend/port/alpha/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/alpha/port-protos.h b/src/backend/port/alpha/port-protos.h new file mode 100644 index 00000000000..3bd8d454a5e --- /dev/null +++ b/src/backend/port/alpha/port-protos.h @@ -0,0 +1,39 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * prototypes for OSF/1-specific routines + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include <dlfcn.h> +#include "utils/dynamic_loader.h" + +/* dynloader.c */ + +/* + * Dynamic Loader on Alpha OSF/1.x + * + * this dynamic loader uses the system dynamic loading interface for shared + * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared + * library as the file to be dynamically loaded. + * + */ +#define pg_dlopen(f) dlopen(f, RTLD_LAZY) +#define pg_dlsym(h, f) ((func_ptr)dlsym(h, f)) +#define pg_dlclose(h) dlclose(h) +#define pg_dlerror() dlerror() + +/* port.c */ + +extern void init_address_fixup(void); + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/alpha/port.c b/src/backend/port/alpha/port.c new file mode 100644 index 00000000000..d7c17b0a5ba --- /dev/null +++ b/src/backend/port/alpha/port.c @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * OSF/1-specific routines + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/alpha/Attic/port.c,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include <sys/types.h> +#include <sys/sysinfo.h> +#include <sys/proc.h> +#include "c.h" +#include "utils/elog.h" + +void +init_address_fixup() +{ +#ifdef NOFIXADE + int buffer[] = { SSIN_UACPROC, UAC_SIGBUS }; +#endif /* NOFIXADE */ +#ifdef NOPRINTADE + int buffer[] = { SSIN_UACPROC, UAC_NOPRINT }; +#endif /* NOPRINTADE */ + + if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL, + (unsigned long) NULL) < 0) { + elog(NOTICE, "setsysinfo failed: %d\n", errno); + } +} diff --git a/src/backend/port/bsdi/Makefile.inc b/src/backend/port/bsdi/Makefile.inc new file mode 100644 index 00000000000..96eb2c5fc43 --- /dev/null +++ b/src/backend/port/bsdi/Makefile.inc @@ -0,0 +1,15 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/bsdi +# +# NOTES +# The BSD/OS port is included here by courtesy of Kurt Lidl. +# +# (5) 1994, Kurt Lidl, lidl@pix.com +# +#------------------------------------------------------------------------- + +CFLAGS+=-DUSE_POSIX_TIME -DNEED_CBRT +LDADD+= -ldld -lipc +SUBSRCS= dynloader.c diff --git a/src/backend/port/bsdi/dynloader.c b/src/backend/port/bsdi/dynloader.c new file mode 100644 index 00000000000..c167a01897e --- /dev/null +++ b/src/backend/port/bsdi/dynloader.c @@ -0,0 +1,93 @@ +/*------------------------------------------------------------------------- + * + * dynloader.c-- + * Dynamic Loader for Postgres for Linux, generated from those for + * Ultrix. + * + * You need to install the dld library on your Linux system! + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * /usr/local/devel/pglite/cvs/src/backend/port/linux/dynloader.c,v 1.1.1.1 1994/11/07 05:19:37 andrew Exp + * + *------------------------------------------------------------------------- + */ +#include <stdio.h> +#include <dld.h> +#include "postgres.h" +#include "port-protos.h" +#include "utils/elog.h" +#include "fmgr.h" + +extern char pg_pathname[]; + +void * +pg_dlopen(char *filename) +{ + static int dl_initialized= 0; + + /* + * initializes the dynamic loader with the executable's pathname. + * (only needs to do this the first time pg_dlopen is called.) + */ + if (!dl_initialized) { + if (dld_init (dld_find_executable (pg_pathname))) { + return NULL; + } + /* + * if there are undefined symbols, we want dl to search from the + * following libraries also. + */ + dl_initialized= 1; + } + + /* + * link the file, then check for undefined symbols! + */ + if (dld_link(filename)) { + return NULL; + } + + /* + * If undefined symbols: try to link with the C and math libraries! + * This could be smarter, if the dynamic linker was able to handle + * shared libs! + */ + if(dld_undefined_sym_count > 0) { + if (dld_link("/usr/lib/libc.a")) { + elog(NOTICE, "dld: Cannot link C library!"); + return NULL; + } + if(dld_undefined_sym_count > 0) { + if (dld_link("/usr/lib/libm.a")) { + elog(NOTICE, "dld: Cannot link math library!"); + return NULL; + } + if(dld_undefined_sym_count > 0) { + int count = dld_undefined_sym_count; + char **list= dld_list_undefined_sym(); + + /* list the undefined symbols, if any */ + elog(NOTICE, "dld: Undefined:"); + do { + elog(NOTICE, " %s", *list); + list++; + count--; + } while(count > 0); + + dld_unlink_by_file(filename, 1); + return NULL; + } + } + } + + return (void *) strdup(filename); +} + +char * +pg_dlerror() +{ + return dld_strerror(dld_errno); +} diff --git a/src/backend/port/bsdi/machine.h b/src/backend/port/bsdi/machine.h new file mode 100644 index 00000000000..d53defbfd4c --- /dev/null +++ b/src/backend/port/bsdi/machine.h @@ -0,0 +1,18 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * machine.h,v 1.1.1.1 1994/11/07 05:19:37 andrew Exp + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif diff --git a/src/backend/port/bsdi/port-protos.h b/src/backend/port/bsdi/port-protos.h new file mode 100644 index 00000000000..6583571d356 --- /dev/null +++ b/src/backend/port/bsdi/port-protos.h @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for SunOS 4 + * + * + * Copyright (c) 1994, Regents of the University of California + * + * port-protos.h,v 1.2 1995/05/25 22:51:03 andrew Exp + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include "fmgr.h" /* for func_ptr */ +#include "utils/dynamic_loader.h" + +/* dynloader.c */ + +#ifndef LINUX_ELF +#define pg_dlsym(handle, funcname) ((func_ptr) dld_get_func((funcname))) +#define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); }) +#else +#define pg_dlopen(f) dlopen(f, 1) +#define pg_dlsym dlsym +#define pg_dlclose dlclose +#define pg_dlerror dlerror +#endif + +/* port.c */ + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/bsdi/port.c b/src/backend/port/bsdi/port.c new file mode 100644 index 00000000000..8819b1a6481 --- /dev/null +++ b/src/backend/port/bsdi/port.c @@ -0,0 +1,13 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * Linux-specific routines + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * /usr/local/devel/pglite/cvs/src/backend/port/linux/port.c,v 1.1.1.1 1994/11/07 05:19:38 andrew Exp + * + *------------------------------------------------------------------------- + */ diff --git a/src/backend/port/hpux/Makefile.inc b/src/backend/port/hpux/Makefile.inc new file mode 100644 index 00000000000..4ff60d20195 --- /dev/null +++ b/src/backend/port/hpux/Makefile.inc @@ -0,0 +1,68 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/hpux (HP-UX specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:43 scrappy Exp $ +# +#------------------------------------------------------------------------- + +# +# HP-UX needs: +# -W l,-E export symbols for linking with the shared libraries +# dynamic loader +# -W p,-H400000 expand cpp #define table size so the Nodes files don't +# break it +# +# -W p,-H400000 +ifeq ($(CC), cc) +CFLAGS+= -W l,-E +LDFLAGS+= -W l,-E +LDADD+= -ll -ldld +else +ifeq ($(CC), gcc) +LDADD+= -ll /usr/lib/libdld.sl +endif +endif + +CFLAGS+= -DUSE_POSIX_TIME + +# +# cbrt(3m) and rint(3m) are missing from 8.07. +# cbrt(3m) and rint(3m) are broken in 9.01. +# cbrt(3m) seems to be missing on 9.00 even though it is documented. +# +CFLAGS+= -DNEED_RINT -DNEED_CBRT + +# +# The #pragma trick required on 8.07 no longer works -- the #pragma +# is thoroughly broken. However, the +u flag has been extended to +# handle alignment requirement arguments (defaulting to 2) for things +# other than struct references, so the #pragma is no longer needed. +# + +# +# (1) The YACC grammar is too big.. +# (HP-UX 9.0x, x<2, added basic block limits for +O2; 9.0x, x>=2, changed +# the syntax to something else.) +# +# (2) The 9.00 optimizer chokes on some of our source. +# +#.if (${HPUX_MAJOR} == "09") +#. if !defined(CDEBUG) +#. if (${HPUX_MINOR} == "00" || ${HPUX_MINOR} == "01") +#CFLAGS+= +Obb600 +#CFLAGS+= -DWEAK_C_OPTIMIZER +#. else +#CFLAGS+= +Onolimit +#. endif +#. endif +#.endif + +HEADERS+= fixade.h machine.h port-protos.h + +SUBSRCS+= dynloader.c port.c tas.s diff --git a/src/backend/port/hpux/dynloader.c b/src/backend/port/hpux/dynloader.c new file mode 100644 index 00000000000..deea2e1dc29 --- /dev/null +++ b/src/backend/port/hpux/dynloader.c @@ -0,0 +1,57 @@ +/*------------------------------------------------------------------------- + * + * dynloader.c-- + * dynamic loader for HP-UX using the shared library mechanism + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/dynloader.c,v 1.1.1.1 1996/07/09 06:21:43 scrappy Exp $ + * + * NOTES + * all functions are defined here -- it's impossible to trace the + * shl_* routines from the bundled HP-UX debugger. + * + *------------------------------------------------------------------------- + */ +/* System includes */ +#include <stdio.h> +#include <a.out.h> +#include <dl.h> +#include "c.h" +#include "fmgr.h" +#include "utils/dynamic_loader.h" +#include "port-protos.h" + +void * +pg_dlopen(char *filename) +{ + shl_t handle = shl_load(filename, BIND_DEFERRED, 0); + + return((void *) handle); +} + +func_ptr +pg_dlsym(void *handle, char *funcname) +{ + func_ptr f; + + if (shl_findsym((shl_t *) &handle, funcname, TYPE_PROCEDURE, &f) == -1) { + f = (func_ptr) NULL; + } + return(f); +} + +void +pg_dlclose(void *handle) +{ + shl_unload((shl_t) handle); +} + +char * +pg_dlerror() +{ + static char errmsg[]= "shl_load failed"; + return errmsg; +} diff --git a/src/backend/port/hpux/fixade.h b/src/backend/port/hpux/fixade.h new file mode 100644 index 00000000000..62324eb05d7 --- /dev/null +++ b/src/backend/port/hpux/fixade.h @@ -0,0 +1,63 @@ +/*------------------------------------------------------------------------- + * + * fixade.h-- + * compiler tricks to make things work while POSTGRES does non-native + * dereferences on PA-RISC. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: fixade.h,v 1.1.1.1 1996/07/09 06:21:43 scrappy Exp $ + * + * NOTES + * This must be included in EVERY source file. + * + *------------------------------------------------------------------------- + */ +#ifndef FIXADE_H +#define FIXADE_H + +#if !defined(NOFIXADE) + +#if defined(HP_S500_ALIGN) +/* ---------------- + * This cheesy hack turns ON unaligned-access fixup on H-P PA-RISC; + * the resulting object files contain code that explicitly handles + * realignment on reference, so it slows memory access down by a + * considerable factor. It must be used in conjunction with the +u + * flag to cc. The #pragma is included in c.h to be safe since EVERY + * source file that performs unaligned access must contain the #pragma. + * ---------------- + */ +#pragma HP_ALIGN HPUX_NATURAL_S500 + +#if defined(BROKEN_STRUCT_INIT) +/* ---------------- + * This is so bogus. The HP-UX 9.01 compiler has totally broken + * struct initialization code. It actually length-checks ALL + * array initializations within structs against the FIRST one that + * it sees (when #pragma HP_ALIGN HPUX_NATURAL_S500 is defined).. + * we have to throw in this unused structure before struct varlena + * is defined. + * + * XXX guess you don't need the #pragma anymore after all :-) + * since no one looks at this except me i think i'll just leave + * this here for now.. + * ---------------- + */ +struct HP_WAY_BOGUS { + char hpwb_bogus[8192]; +}; +struct HP_TOO_BOGUS { + int hptb_bogus[8192]; +}; +#endif /* BROKEN_STRUCT_INIT */ +#endif /* HP_S500_ALIGN */ + +#if defined(WEAK_C_OPTIMIZER) +#pragma OPT_LEVEL 1 +#endif /* WEAK_C_OPTIMIZER */ + +#endif /* !NOFIXADE */ + +#endif /* FIXADE_H */ diff --git a/src/backend/port/hpux/machine.h b/src/backend/port/hpux/machine.h new file mode 100644 index 00000000000..b178a621726 --- /dev/null +++ b/src/backend/port/hpux/machine.h @@ -0,0 +1,18 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:43 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif diff --git a/src/backend/port/hpux/port-protos.h b/src/backend/port/hpux/port-protos.h new file mode 100644 index 00000000000..16206bb2509 --- /dev/null +++ b/src/backend/port/hpux/port-protos.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for HP-UX + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:43 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include <sys/resource.h> /* for struct rusage */ +#include <dl.h> /* for shl_t */ + +#include "utils/dynamic_loader.h" + +/* dynloader.c */ + +/* pg_dl{open,close,sym} prototypes are in utils/dynamic_loader.h */ + +/* port.c */ + +extern int init_address_fixup(void); +extern double rint(double x); +extern double cbrt(double x); +extern long random(void); +extern void srandom(int seed); +extern int getrusage(int who, struct rusage *ru); + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/hpux/port.c b/src/backend/port/hpux/port.c new file mode 100644 index 00000000000..eccf3dc5c12 --- /dev/null +++ b/src/backend/port/hpux/port.c @@ -0,0 +1,47 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * port-specific routines for HP-UX + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/port.c,v 1.1.1.1 1996/07/09 06:21:43 scrappy Exp $ + * + * NOTES + * For the most part, this file gets around some non-POSIX calls + * in POSTGRES. + * + *------------------------------------------------------------------------- + */ +#include <unistd.h> /* for rand()/srand() prototypes */ +#include <math.h> /* for pow() prototype */ +#include <sys/syscall.h> /* for syscall #defines */ + +#include "c.h" + +void +init_address_fixup() +{ + /* + * On PA-RISC, unaligned access fixup is handled by the compiler, + * not by the kernel. + */ +} + +long +random() +{ + return(lrand48()); +} + +void srandom(int seed) +{ + srand48((long int) seed); +} + +getrusage(int who, struct rusage *ru) +{ + return(syscall(SYS_GETRUSAGE, who, ru)); +} diff --git a/src/backend/port/hpux/tas.c.template b/src/backend/port/hpux/tas.c.template new file mode 100644 index 00000000000..3ab37eb966e --- /dev/null +++ b/src/backend/port/hpux/tas.c.template @@ -0,0 +1,36 @@ +/* + * To generate tas.s using this template: + * 1. cc +O2 -S -c tas.c + * 2. edit tas.s: + * - replace the LDW with LDCWX + * For details about the LDCWX instruction, see the "Precision + * Architecture and Instruction Reference Manual" (09740-90014 of June + * 1987), p. 5-38. + */ + +int +tas(lock) + int *lock; /* LDCWX is a word instruction */ +{ + /* + * LDCWX requires that we align the "semaphore" to a 16-byte + * boundary. The actual datum is a single word (4 bytes). + */ + lock = ((long) lock + 15) & ~15; + + /* + * The LDCWX instruction atomically clears the target word and + * returns the previous value. Hence, if the instruction returns + * 0, someone else has already acquired the lock before we tested + * it (i.e., we have failed). + * + * Notice that this means that we actually clear the word to set + * the lock and set the word to clear the lock. This is the + * opposite behavior from the SPARC LDSTUB instruction. For some + * reason everything that H-P does is rather baroque... + */ + if (*lock) { /* this generates the LDW */ + return(0); /* success */ + } + return(1); /* failure */ +} diff --git a/src/backend/port/hpux/tas.s b/src/backend/port/hpux/tas.s new file mode 100644 index 00000000000..d978a7cb030 --- /dev/null +++ b/src/backend/port/hpux/tas.s @@ -0,0 +1,28 @@ + + .SPACE $TEXT$,SORT=8 + .SUBSPA $CODE$,QUAD=0,ALIGN=4,ACCESS=44,CODE_ONLY,SORT=24 +tas + .PROC + .CALLINFO CALLER,FRAME=0,ENTRY_SR=3 + .ENTRY + LDO 15(%r26),%r31 ;offset 0x0 + DEPI 0,31,4,%r31 ;offset 0x4 + LDCWX 0(0,%r31),%r23 ;offset 0x8 + COMICLR,= 0,%r23,%r0 ;offset 0xc + DEP,TR %r0,31,32,%r28 ;offset 0x10 +$00000001 + LDI 1,%r28 ;offset 0x14 +$L0 + .EXIT + BV,N %r0(%r2) ;offset 0x18 + .PROCEND ;in=26;out=28; + + + .SPACE $TEXT$ + .SUBSPA $CODE$ + .SPACE $PRIVATE$,SORT=16 + .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=16 + .SPACE $TEXT$ + .SUBSPA $CODE$ + .EXPORT tas,ENTRY,PRIV_LEV=3,ARGW0=GR,RTNVAL=GR + .END diff --git a/src/backend/port/irix5/Makefile.inc b/src/backend/port/irix5/Makefile.inc new file mode 100644 index 00000000000..40527b3b1fc --- /dev/null +++ b/src/backend/port/irix5/Makefile.inc @@ -0,0 +1,20 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/irix5 (IRIX 5 specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# /usr/local/devel/pglite/cvs/src/backend/port/sparc_solaris/Makefile.inc,v 1.3 1995/03/21 06:51:21 andrew Exp +# +#------------------------------------------------------------------------- + +CFLAGS+= -DUSE_POSIX_TIME -DNEED_ISINF -DNO_EMPTY_STMTS + +LDADD+= -ll + +SUBSRCS+= port.c + +HEADERS+= machine.h port-protos.h diff --git a/src/backend/port/irix5/README b/src/backend/port/irix5/README new file mode 100644 index 00000000000..2c66463018c --- /dev/null +++ b/src/backend/port/irix5/README @@ -0,0 +1,2 @@ +The IRIX 5 port was contributed by + Paul 'Shag' Walmsley <ccshag@everest.cclabs.missouri.edu> diff --git a/src/backend/port/irix5/machine.h b/src/backend/port/irix5/machine.h new file mode 100644 index 00000000000..fd1f22c8a93 --- /dev/null +++ b/src/backend/port/irix5/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * machine.h,v 1.1.1.1 1994/11/07 05:19:38 andrew Exp + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/irix5/port-protos.h b/src/backend/port/irix5/port-protos.h new file mode 100644 index 00000000000..7313e49c138 --- /dev/null +++ b/src/backend/port/irix5/port-protos.h @@ -0,0 +1,36 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for Irix 5 + * + * + * Copyright (c) 1994, Regents of the University of California + * + * port-protos.h,v 1.2 1995/03/17 06:40:18 andrew Exp + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include "fmgr.h" /* for func_ptr */ +#include "utils/dynamic_loader.h" + +/* dynloader.c */ +/* + * Dynamic Loader on SunOS 4. + * + * this dynamic loader uses the system dynamic loading interface for shared + * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared + * library as the file to be dynamically loaded. + * + */ +#define pg_dlopen(f) dlopen(f,1) +#define pg_dlsym dlsym +#define pg_dlclose dlclose +#define pg_dlerror dlerror + +/* port.c */ +extern long random(void); + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/irix5/port.c b/src/backend/port/irix5/port.c new file mode 100644 index 00000000000..82303ed7fcb --- /dev/null +++ b/src/backend/port/irix5/port.c @@ -0,0 +1,16 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * Irix5-specific routines + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * /usr/local/devel/pglite/cvs/src/backend/port/sparc_solaris/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp + * + *------------------------------------------------------------------------- + */ +#include <math.h> /* for pow() prototype */ + +#include <errno.h> diff --git a/src/backend/port/linux/Makefile.inc b/src/backend/port/linux/Makefile.inc new file mode 100644 index 00000000000..cc35929a260 --- /dev/null +++ b/src/backend/port/linux/Makefile.inc @@ -0,0 +1,36 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/linux (Linux specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ +# +# NOTES +# The Linux port is included here by courtesy of Kai Petzke. +# +# (C) 1994, Kai Petzke, wpp@marie.physik.tu-berlin.de +# +#------------------------------------------------------------------------- + +# +# linux has fast linkers and don't need the BIGOBJ stuff. +# +BIGOBJS= false + + +ifdef LINUX_ELF +CC=gcc +LDADD+= -ldl +CFLAGS+= -DLINUX_ELF +else +LDADD+= -ldld +SUBSRCS+= dynloader.c +endif + +HEADERS+= machine.h port-protos.h +CFLAGS+= -DNEED_CBRT + diff --git a/src/backend/port/linux/dynloader.c b/src/backend/port/linux/dynloader.c new file mode 100644 index 00000000000..ebf0625dd73 --- /dev/null +++ b/src/backend/port/linux/dynloader.c @@ -0,0 +1,93 @@ +/*------------------------------------------------------------------------- + * + * dynloader.c-- + * Dynamic Loader for Postgres for Linux, generated from those for + * Ultrix. + * + * You need to install the dld library on your Linux system! + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/dynloader.c,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include <stdio.h> +#include <dld.h> +#include "postgres.h" +#include "port-protos.h" +#include "utils/elog.h" +#include "fmgr.h" + +extern char pg_pathname[]; + +void * +pg_dlopen(char *filename) +{ + static int dl_initialized= 0; + + /* + * initializes the dynamic loader with the executable's pathname. + * (only needs to do this the first time pg_dlopen is called.) + */ + if (!dl_initialized) { + if (dld_init (dld_find_executable (pg_pathname))) { + return NULL; + } + /* + * if there are undefined symbols, we want dl to search from the + * following libraries also. + */ + dl_initialized= 1; + } + + /* + * link the file, then check for undefined symbols! + */ + if (dld_link(filename)) { + return NULL; + } + + /* + * If undefined symbols: try to link with the C and math libraries! + * This could be smarter, if the dynamic linker was able to handle + * shared libs! + */ + if(dld_undefined_sym_count > 0) { + if (dld_link("/usr/lib/libc.a")) { + elog(NOTICE, "dld: Cannot link C library!"); + return NULL; + } + if(dld_undefined_sym_count > 0) { + if (dld_link("/usr/lib/libm.a")) { + elog(NOTICE, "dld: Cannot link math library!"); + return NULL; + } + if(dld_undefined_sym_count > 0) { + int count = dld_undefined_sym_count; + char **list= dld_list_undefined_sym(); + + /* list the undefined symbols, if any */ + elog(NOTICE, "dld: Undefined:"); + do { + elog(NOTICE, " %s", *list); + list++; + count--; + } while(count > 0); + + dld_unlink_by_file(filename, 1); + return NULL; + } + } + } + + return (void *) strdup(filename); +} + +char * +pg_dlerror() +{ + return dld_strerror(dld_errno); +} diff --git a/src/backend/port/linux/machine.h b/src/backend/port/linux/machine.h new file mode 100644 index 00000000000..90458810e98 --- /dev/null +++ b/src/backend/port/linux/machine.h @@ -0,0 +1,18 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif diff --git a/src/backend/port/linux/port-protos.h b/src/backend/port/linux/port-protos.h new file mode 100644 index 00000000000..f80cd62d424 --- /dev/null +++ b/src/backend/port/linux/port-protos.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for SunOS 4 + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include "fmgr.h" /* for func_ptr */ +#include "utils/dynamic_loader.h" +#ifdef LINUX_ELF +#include "dlfcn.h" +#endif + +/* dynloader.c */ + +#ifndef LINUX_ELF +#define pg_dlsym(handle, funcname) ((func_ptr) dld_get_func((funcname))) +#define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); }) +#else +/* #define pg_dlopen(f) dlopen(f, 1) */ +#define pg_dlopen(f) dlopen(f, 2) +#define pg_dlsym dlsym +#define pg_dlclose dlclose +#define pg_dlerror dlerror +#endif + +/* port.c */ + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/linux/port.c b/src/backend/port/linux/port.c new file mode 100644 index 00000000000..e4c5edfb9e5 --- /dev/null +++ b/src/backend/port/linux/port.c @@ -0,0 +1,13 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * Linux-specific routines + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/port.c,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ diff --git a/src/backend/port/sparc/Makefile.inc b/src/backend/port/sparc/Makefile.inc new file mode 100644 index 00000000000..3b102fa3249 --- /dev/null +++ b/src/backend/port/sparc/Makefile.inc @@ -0,0 +1,23 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/sparc (SPARC/SunOS 4 specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/sparc/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ +# +#------------------------------------------------------------------------- + +CFLAGS+= -DUSE_POSIX_TIME + +LDADD+= -lln -ldl + +# +# SunOS 4 strtol is broken -- doesn't report overflow using errno. +# +SUBSRCS= strtol.c + +HEADERS+= float.h machine.h port-protos.h diff --git a/src/backend/port/sparc/float.h b/src/backend/port/sparc/float.h new file mode 100644 index 00000000000..13e284571fe --- /dev/null +++ b/src/backend/port/sparc/float.h @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + * + * float.h-- + * definitions for ANSI floating point + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: float.h,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ + * + * NOTES + * These come straight out of ANSI X3.159-1989 (p.18) and + * would be unnecessary if SunOS 4 were ANSI-compliant. + * + * This is only a partial listing because I'm lazy to type + * the whole thing in. + * + *------------------------------------------------------------------------- + */ +#ifndef FLOAT_H +#define FLOAT_H + +#define FLT_DIG 6 +#define FLT_MIN ((float) 1.17549435e-38) +#define FLT_MAX ((float) 3.40282347e+38) +#define DBL_DIG 15 +#define DBL_MIN 2.2250738585072014e-308 +#define DBL_MAX 1.7976931348623157e+308 + +#endif /* FLOAT_H */ diff --git a/src/backend/port/sparc/machine.h b/src/backend/port/sparc/machine.h new file mode 100644 index 00000000000..d34b65ff333 --- /dev/null +++ b/src/backend/port/sparc/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/sparc/port-protos.h b/src/backend/port/sparc/port-protos.h new file mode 100644 index 00000000000..2765c9307a9 --- /dev/null +++ b/src/backend/port/sparc/port-protos.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for SunOS 4 + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include <dlfcn.h> +#include "fmgr.h" /* for func_ptr */ +#include "utils/dynamic_loader.h" + +/* dynloader.c */ +/* + * Dynamic Loader on SunOS 4. + * + * this dynamic loader uses the system dynamic loading interface for shared + * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared + * library as the file to be dynamically loaded. + * + */ +#define pg_dlopen(f) dlopen(f, 1) +#define pg_dlsym dlsym +#define pg_dlclose dlclose +#define pg_dlerror dlerror + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/sparc/strtol.c b/src/backend/port/sparc/strtol.c new file mode 100644 index 00000000000..5850848e66a --- /dev/null +++ b/src/backend/port/sparc/strtol.c @@ -0,0 +1,130 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91"; +#endif /* LIBC_SCCS and not lint */ + +#include <limits.h> +#include <ctype.h> +#include <errno.h> +#include <stdlib.h> + +#define const + +/* + * Convert a string to a long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long +strtol(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LONG_MIN : LONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? s - 1 : (char *)nptr; + return (acc); +} diff --git a/src/backend/port/sparc_solaris/Makefile.inc b/src/backend/port/sparc_solaris/Makefile.inc new file mode 100644 index 00000000000..ee4a8f82f02 --- /dev/null +++ b/src/backend/port/sparc_solaris/Makefile.inc @@ -0,0 +1,20 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/sparc_solaris (SPARC/Solaris 2.x specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/sparc_solaris/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ +# +#------------------------------------------------------------------------- + +CFLAGS+= -DUSE_POSIX_TIME -DNEED_ISINF -DNEED_RUSAGE -DNO_EMPTY_STMTS + +LDADD+= -ll -ldl + +SUBSRCS+= port.c tas.s + +HEADERS+= machine.h port-protos.h rusagestub.h diff --git a/src/backend/port/sparc_solaris/machine.h b/src/backend/port/sparc_solaris/machine.h new file mode 100644 index 00000000000..35fe7afe61e --- /dev/null +++ b/src/backend/port/sparc_solaris/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/sparc_solaris/port-protos.h b/src/backend/port/sparc_solaris/port-protos.h new file mode 100644 index 00000000000..777e66310f4 --- /dev/null +++ b/src/backend/port/sparc_solaris/port-protos.h @@ -0,0 +1,38 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for SunOS 4 + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include <dlfcn.h> +#include "fmgr.h" /* for func_ptr */ +#include "utils/dynamic_loader.h" + +/* dynloader.c */ +/* + * Dynamic Loader on SunOS 4. + * + * this dynamic loader uses the system dynamic loading interface for shared + * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared + * library as the file to be dynamically loaded. + * + */ +#define pg_dlopen(f) dlopen(f,1) +#define pg_dlsym dlsym +#define pg_dlclose dlclose +#define pg_dlerror dlerror + +/* port.c */ +extern long random(void); +extern void srandom(int seed); + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/sparc_solaris/port.c b/src/backend/port/sparc_solaris/port.c new file mode 100644 index 00000000000..f3c6b8a7943 --- /dev/null +++ b/src/backend/port/sparc_solaris/port.c @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * SunOS5-specific routines + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/sparc_solaris/Attic/port.c,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include <math.h> /* for pow() prototype */ + +#include <errno.h> +#include "rusagestub.h" + +long +random() +{ + return(lrand48()); +} + +void +srandom(int seed) +{ + srand48((long int) seed); +} + +int +getrusage(int who, struct rusage *rusage) +{ + struct tms tms; + register int tick_rate = CLK_TCK; /* ticks per second */ + clock_t u, s; + + if (rusage == (struct rusage *) NULL) { + errno = EFAULT; + return(-1); + } + if (times(&tms) < 0) { + /* errno set by times */ + return(-1); + } + switch (who) { + case RUSAGE_SELF: + u = tms.tms_utime; + s = tms.tms_stime; + break; + case RUSAGE_CHILDREN: + u = tms.tms_cutime; + s = tms.tms_cstime; + break; + default: + errno = EINVAL; + return(-1); + } +#define TICK_TO_SEC(T, RATE) ((T)/(RATE)) +#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE) + rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate); + rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate); + rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate); + rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate); + return(0); +} diff --git a/src/backend/port/sparc_solaris/rusagestub.h b/src/backend/port/sparc_solaris/rusagestub.h new file mode 100644 index 00000000000..5e413bd0d9a --- /dev/null +++ b/src/backend/port/sparc_solaris/rusagestub.h @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + * + * rusagestub.h-- + * Stubs for getrusage(3). + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: rusagestub.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef RUSAGESTUB_H +#define RUSAGESTUB_H + +#include <sys/time.h> /* for struct timeval */ +#include <sys/times.h> /* for struct tms */ +#include <limits.h> /* for CLK_TCK */ + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN -1 + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ +}; + +extern int getrusage(int who, struct rusage *rusage); + +#endif /* RUSAGESTUB_H */ diff --git a/src/backend/port/sparc_solaris/tas.s b/src/backend/port/sparc_solaris/tas.s new file mode 100644 index 00000000000..e09c2d4ad3c --- /dev/null +++ b/src/backend/port/sparc_solaris/tas.s @@ -0,0 +1,50 @@ + !! + !! $Header: /cvsroot/pgsql/src/backend/port/sparc_solaris/Attic/tas.s,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + !! + !! this would be a piece of inlined assembler but it appears + !! to be easier to just write the assembler than to try to + !! figure out how to make sure that in/out registers are kept + !! straight in the asm's. + !! + .file "tas.c" +.section ".text" + .align 4 + .global tas + .type tas,#function + .proc 04 +tas: + !! + !! this is a leaf procedure - no need to save windows and + !! diddle the CWP. + !! + !#PROLOGUE# 0 + !#PROLOGUE# 1 + + !! + !! write 0xFF into the lock address, saving the old value in %o0. + !! this is an atomic action, even on multiprocessors. + !! + ldstub [%o0],%o0 + + !! + !! if it was already set when we set it, somebody else already + !! owned the lock -- return 1. + !! + cmp %o0,0 + bne .LL2 + mov 1,%o0 + + !! + !! otherwise, it was clear and we now own the lock -- return 0. + !! + mov 0,%o0 +.LL2: + !! + !! this is a leaf procedure - no need to restore windows and + !! diddle the CWP. + !! + retl + nop +.LLfe1: + .size tas,.LLfe1-tas + .ident "GCC: (GNU) 2.5.8" diff --git a/src/backend/port/ultrix4/Makefile.inc b/src/backend/port/ultrix4/Makefile.inc new file mode 100644 index 00000000000..fca568f5d5d --- /dev/null +++ b/src/backend/port/ultrix4/Makefile.inc @@ -0,0 +1,27 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/ultrix (Ultrix4.x specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ +# +#------------------------------------------------------------------------- + +CFLAGS+= -DNEED_ISINF -DUSE_POSIX_TIME + +LDADD+= -ldl -lln + +# +# The YACC grammar is too big.. +# +#.if !defined(CDEBUG) +#CFLAGS+= -Olimit 2000 +#.endif + +HEADERS+= dl.h machine.h port-protos.h + +SUBSRCS+= dynloader.c port.c strdup.c diff --git a/src/backend/port/ultrix4/dl.h b/src/backend/port/ultrix4/dl.h new file mode 100644 index 00000000000..bca3602a21c --- /dev/null +++ b/src/backend/port/ultrix4/dl.h @@ -0,0 +1,117 @@ +/*------------------------------------------------------------------------- + * + * dl.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: dl.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +/* + * Ultrix 4.x Dynamic Loader Library Version 1.0 + * + * dl.h-- + * header file for the Dynamic Loader Library + * + * + * Copyright (c) 1993 Andrew K. Yu, University of California at Berkeley + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for educational, research, and non-profit purposes and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation. Permission + * to incorporate this software into commercial products can be obtained + * from the author. The University of California and the author make + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ +#ifndef _DL_HEADER_ +#define _DL_HEADER_ + +#include <filehdr.h> +#include <syms.h> +#include <ldfcn.h> +#include <reloc.h> +#include <scnhdr.h> + + +typedef long CoreAddr; + + +typedef struct ScnInfo { + CoreAddr addr; /* starting address of the section */ + SCNHDR hdr; /* section header */ + RELOC *relocEntries; /* relocation entries */ +} ScnInfo; + +typedef enum { + DL_NEEDRELOC, /* still need relocation */ + DL_RELOCATED, /* no relocation necessary */ + DL_INPROG /* relocation in progress */ +} dlRStatus; + +typedef struct JmpTbl { + char *block; /* the jump table memory block */ + struct JmpTbl *next; /* next block */ +} JmpTbl; + +typedef struct dlFile { + char *filename; /* file name of the object file */ + + int textSize; /* used by mprotect */ + CoreAddr textAddress; /* start addr of text section */ + long textVaddr; /* vaddr of text section in obj file */ + CoreAddr rdataAddress; /* start addr of rdata section */ + long rdataVaddr; /* vaddr of text section in obj file */ + CoreAddr dataAddress; /* start addr of data section */ + long dataVaddr; /* vaddr of text section in obj file */ + CoreAddr bssAddress; /* start addr of bss section */ + long bssVaddr; /* vaddr of text section in obj file */ + + int nsect; /* number of sections */ + ScnInfo *sect; /* details of each section (array) */ + + int issExtMax; /* size of string space */ + char *extss; /* extern sym string space (in core) */ + int iextMax; /* maximum number of Symbols */ + pEXTR extsyms; /* extern syms */ + + dlRStatus relocStatus; /* what relocation needed? */ + int needReloc; + + JmpTbl *jmptable; /* the jump table for R_JMPADDR */ + + struct dlFile *next; /* next member of the archive */ +} dlFile; + +typedef struct dlSymbol { + char *name; /* name of the symbol */ + long addr; /* address of the symbol */ + dlFile *objFile; /* from which file */ +} dlSymbol; + +/* + * prototypes for the dl* interface + */ +extern void *dl_open(/* char *filename, int mode */); +extern void *dl_sym(/* void *handle, char *name */); +extern void dl_close(/* void *handle */); +extern char *dl_error(/* void */); + +#define DL_LAZY 0 /* lazy resolution */ +#define DL_NOW 1 /* immediate resolution */ + +/* + * Miscellaneous utility routines: + */ +extern char **dl_undefinedSymbols(/* int *count */); +extern void dl_printAllSymbols(/* void *handle */); +extern void dl_setLibraries(/* char *libs */); + +#endif _DL_HEADER_ diff --git a/src/backend/port/ultrix4/dynloader.c b/src/backend/port/ultrix4/dynloader.c new file mode 100644 index 00000000000..887dff44abd --- /dev/null +++ b/src/backend/port/ultrix4/dynloader.c @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- + * + * dynloader.c-- + * This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x. + * (Note that pg_dlsym and pg_dlclose are actually macros defined in + * "port-protos.h".) + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/dynloader.c,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include <stdio.h> +#include "dl.h" +#include "c.h" +#include "fmgr.h" +#include "port-protos.h" +#include "utils/elog.h" + +extern char pg_pathname[]; + +void * +pg_dlopen(char *filename) +{ + static int dl_initialized= 0; + void *handle; + + /* + * initializes the dynamic loader with the executable's pathname. + * (only needs to do this the first time pg_dlopen is called.) + */ + if (!dl_initialized) { + if (!dl_init(pg_pathname)) { + return NULL; + } + /* + * if there are undefined symbols, we want dl to search from the + * following libraries also. + */ + dl_setLibraries("/usr/lib/libm_G0.a:/usr/lib/libc_G0.a"); + dl_initialized= 1; + } + + /* + * open the file. We do the symbol resolution right away so that we + * will know if there are undefined symbols. (This is in fact the + * same semantics as "ld -A". ie. you cannot have undefined symbols. + */ + if ((handle=dl_open(filename, DL_NOW))==NULL) { + int count; + char **list= dl_undefinedSymbols(&count); + + /* list the undefined symbols, if any */ + if(count) { + elog(NOTICE, "dl: Undefined:"); + while(*list) { + elog(NOTICE, " %s", *list); + list++; + } + } + } + + return (void *)handle; +} + diff --git a/src/backend/port/ultrix4/machine.h b/src/backend/port/ultrix4/machine.h new file mode 100644 index 00000000000..35fe7afe61e --- /dev/null +++ b/src/backend/port/ultrix4/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/ultrix4/port-protos.h b/src/backend/port/ultrix4/port-protos.h new file mode 100644 index 00000000000..ed055dd19c0 --- /dev/null +++ b/src/backend/port/ultrix4/port-protos.h @@ -0,0 +1,36 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * prototypes for Ultrix-specific routines + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PORTOS_H +#define PORT_PORTOS_H + +#include "utils/dynamic_loader.h" +#include "dl.h" + +/* dynloader.c */ +/* + * New dynamic loader. + * + * This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x. + * (Note that pg_dlsym and pg_dlclose are actually macros defined in + * "port-protos.h".) + */ + +#define pg_dlsym(h, f) ((func_ptr)dl_sym(h, f)) +#define pg_dlclose(h) dl_close(h) +#define pg_dlerror() dl_error() + +/* port.c */ + +extern void init_address_fixup(void); + +#endif /* PORT_PORTOS_H */ diff --git a/src/backend/port/ultrix4/port.c b/src/backend/port/ultrix4/port.c new file mode 100644 index 00000000000..6ece3210ec1 --- /dev/null +++ b/src/backend/port/ultrix4/port.c @@ -0,0 +1,25 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * Ultrix-specific routines + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/port.c,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include <sys/syscall.h> +#include <sys/sysmips.h> + +#include "c.h" + +void +init_address_fixup() +{ +#ifdef NOFIXADE + syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL); +#endif /* NOFIXADE */ +} diff --git a/src/backend/port/ultrix4/strdup.c b/src/backend/port/ultrix4/strdup.c new file mode 100644 index 00000000000..f140711226e --- /dev/null +++ b/src/backend/port/ultrix4/strdup.c @@ -0,0 +1,23 @@ +/*------------------------------------------------------------------------- + * + * strdup.c-- + * copies a null-terminated string. + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/strdup.c,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include <string.h> + +char * +strdup(char *string) +{ + char *nstr; + + nstr = strcpy((char *)palloc(strlen(string)+1), string); + return nstr; +} diff --git a/src/backend/port/win32/machine.h b/src/backend/port/win32/machine.h new file mode 100644 index 00000000000..43e40574966 --- /dev/null +++ b/src/backend/port/win32/machine.h @@ -0,0 +1,2 @@ +#define BLCKSZ 8192 +#define NOFILE 100 diff --git a/src/backend/port/win32/nt.c b/src/backend/port/win32/nt.c new file mode 100644 index 00000000000..b5940051045 --- /dev/null +++ b/src/backend/port/win32/nt.c @@ -0,0 +1,625 @@ +#include <windows.h> +#include <time.h> +#include "postgres.h" +#include "storage/ipc.h" + +/* The name of the Postgres 95 ipc file mapping object */ +#define IPC_NAME "PG95_IPC" + +/* The name of the Postgres 95 ipc file mapping object semaphore */ +#define IPC_SEM_NAME "PG95_IPC_SEM" + +/* The maximum length of a shared memory object name */ +#define IPC_MAX_SHMEM_NAME 32 + +/* The maximum number of emulated Unix shared memory segments */ +#define IPC_NMAXSHM 10 + +/* The Maximum number of elements in a semaphore set. Note that this +** is just a guess. +*/ +#define IPC_NMAXSEMGRP 7 + +/* The various states of a semaphore */ +#define SIGNALED 1 +#define UNSIGNALED 0 +#define UNUSED -1 + +/* The security attribute structure necessary for handles to be inhereted */ +SECURITY_ATTRIBUTES sec_attrib = { sizeof (LPSECURITY_ATTRIBUTES), + NULL, TRUE}; + +/* +Postgres95 uses semaphores and shared memory. Both are provided by +Unix and NT, although NT uses a different method for referencing +them. Rather than changing the function calls used by Postgres95 +to use NT system services, we've written code to emulate the Unix +system calls. We deliberately don't do a complete emulation of the +Unix calls, partly because it doesn't appear possible, but also +because only a few options of the Unix calls are actually used by +Postgres95. + +The most noticable difference between the way Unix and NT use semaphores +is that the central entity on Unix is a semaphore set consisting of +potientially many actual semaphores whereas on NT a semaphore handle +represents just one actual semaphore. Furthermore, a Unix semaphore set +is identified by one semaphore id no matter how many elements there +are in the set. Given a Unix semaphore id, the Unix API provides a way +to index into the set to reference a specific semaphore. + +You might think that since both a semaphore id and a semaphore handle +is just an integer there won't be any changes necessary to the Postgres95 +code to deal with NT semaphores. If it weren't for the existence of +multi-semaphore semaphore sets this would be true. + +To handle semaphore sets a fixed-size table, whose size is partially +based on the sum of the maximum number of semaphores times the maximum +number of semaphores per semaphore set, is created and kept in shared +memory that is visable to every backend started by the Postmaster. + +Each semaphore set entry consists of an arbitrary key value, which serves +to identify the semaphore set, and IPC_NMAXSEMGRP array elements to +store the NT semaphore handles representing the NT semaphore used for +the semaphore set. Semaphore IDs are just indices into this table. +In order to distinguish occupied entries in this table -1 is always +considered an invalid semaphore ID. + +This table is also used to store information about shared memory +segments. Fortunately, there is a one-to-one mapping between Unix +shared memory IDs and NT shared memory handles so the code to emulate +Unix shared memory is simple. +*/ + +/* We need one of these for each emulated semaphore set */ +struct Pg_sem +{ + key_t Pg_sem_key; + HANDLE Pg_sem_handle[IPC_NMAXSEMGRP]; + int Pg_sem_nsems; +}; + +/* We need one of these for each emulated shared memory segment */ +struct Pg_shm +{ + key_t Pg_shm_key; + HANDLE Pg_shm_handle; +}; + +/* This structure is what's stored in shared memory. Note that +** since both the shared memory and semaphore data is in the same +** table, and the table is protected by a single NT semaphore, there's +** a chance that semaphore manipulation could be slowed down by +** shared memory manipulation, and vice versa. But, since both are +** allocated primarily when the Postmaster starts up, which isn't time +** critical, I don't think this will prove to be a problem. +*/ + +static struct Pg_shared +{ + int Pg_next_sem; + int Pg_next_shm; + struct Pg_sem Pg_sem[IPC_NMAXSEM]; + struct Pg_shm Pg_shm[IPC_NMAXSHM]; +} *Pg_shared_ptr; + +/* The semaphore that protects the shared memory table */ +HANDLE Pg_shared_hnd; + +/* +** Perform a semaphore operation. We're passed a semaphore set id, +** a pointer to an array of sembuf structures, and the number +** of elements in the array. Each element in the sembuf structure +** describes a specific semaphore within the semaphore set and the +** operation to perform on it. +*/ + +int +semop(int semid, struct sembuf *sops, u_int nsops) +{ + u_int i; + int result; + HANDLE hndl; + + /* Go through all the sops structures */ + for (i = 0; i < nsops; i++) + { + struct sembuf *sptr; + int semval; + int av_sem_op; + + sptr = &sops[i]; + /* + printf("performing %d in sem # %d\n", sptr->sem_op, sptr->sem_num); + */ + + /* + ** Postgres95 uses -255 to represent a lock request + ** and 255 to show a lock release. Changing these values + ** to -1 and 1 make it easier to keep track of the state + ** of the semaphore. + */ + if (sptr->sem_op == -255) + sptr->sem_op = -1; + else if (sptr->sem_op == 255) + sptr->sem_op = 1; + else + printf("invalid sem_op %d\n", sptr->sem_op); + + _get_ipc_sem(); + hndl = Pg_shared_ptr->Pg_sem[semid].Pg_sem_handle[sptr->sem_num]; + _rel_ipc_sem(); + semval = _get_sem_val(hndl); + + if (sptr->sem_op == 0) + { + if (semval == UNSIGNALED) + return(semval); + else + { + if (sptr->sem_flg & IPC_NOWAIT) + return(SIGNALED); + else + result = WaitForSingleObject(hndl, 5000); + } + } + + av_sem_op = abs(sptr->sem_op); + + /* If a lock is being attempted */ + if (sptr->sem_op < 0) + { + if (semval >= av_sem_op) + { + semval -= av_sem_op; + if (semval <= UNSIGNALED) + result = WaitForSingleObject(hndl, 5000); + } + else + { + if (sptr->sem_flg & IPC_NOWAIT) + return(SIGNALED); + else + result = WaitForSingleObject(hndl, 5000); + } + } + + /* If a lock is being released */ + if (sptr->sem_op > 0) + { + semval += av_sem_op; + if (semval > 0) + ReleaseSemaphore(hndl, 1, NULL); + } + } +} + +int +semget(key_t key, int nsems, int semflg) +{ + int id, new_sem, ret_val; + + /* If nmsems is 0 then assume that we're just checking whether + ** the semaphore identified by key exists. Assume that + ** if key is IPC_PRIVATE that this should always fail. + */ + if (nsems == 0) + { + if (key == IPC_PRIVATE) + ret_val = -1; + else + { + _get_ipc_sem(); + id = _get_sem_id(key); + _rel_ipc_sem(); + ret_val = id; + } + return(ret_val); + } + + /* See if there's already a semaphore with the key. + ** If not, record the key, allocate enough space for the + ** handles of the semaphores, and then create the semaphores. + */ + _get_ipc_sem(); + id = _get_sem_id(key); + if (id == UNUSED) + { + register int i; + struct Pg_sem *pg_ptr; + + new_sem = Pg_shared_ptr->Pg_next_sem++; + + pg_ptr = &(Pg_shared_ptr->Pg_sem[new_sem]); + pg_ptr->Pg_sem_key = key; + pg_ptr->Pg_sem_nsems = nsems; + + for (i = 0; i < nsems; i++) + pg_ptr->Pg_sem_handle[i] = CreateSemaphore(&sec_attrib, 1, 255, NULL); + ret_val = new_sem; + } + else + ret_val = id; + _rel_ipc_sem(); + return(ret_val); +} + +/* These next two functions could be written as one function, although +** doing so would require some additional logic. +*/ + +/* Given a semaphore key, return the corresponding id. +** This function assumes that the shared memory table is being +** protected by the shared memory table semaphore. +*/ +_get_sem_id(key_t key) +{ + register int i; + + /* Go through the shared memory table looking for a semaphore + ** whose key matches what we're looking for + */ + for (i = 0; i < Pg_shared_ptr->Pg_next_sem; i++) + if (Pg_shared_ptr->Pg_sem[i].Pg_sem_key == key) + return(i); + + /* Return UNUSED if we didn't find a match */ + return(UNUSED); +} + +/* Given a shared memory key, return the corresponding id +** This function assumes that the shared memory table is being +** protected by the shared memory table semaphore. +*/ +_get_shm_id(key_t key) +{ + register int i; + + /* Go through the shared memory table looking for a semaphore + ** whose key matches what we're looking for + */ + for (i = 0; i < Pg_shared_ptr->Pg_next_shm; i++) + if (Pg_shared_ptr->Pg_shm[i].Pg_shm_key == key) + return(i); + + /* Return UNUSED if we didn't find a match */ + return(UNUSED); +} + +int +semctl(int semid, int semnum, int cmd, void *y) +{ + int old_val; + HANDLE hndl; + + switch (cmd) + { + case SETALL: + case SETVAL: + /* We can't change the value of a semaphore under + ** NT except by releasing it or waiting for it. + */ + return(0); + + case GETVAL: + _get_ipc_sem(); + hndl = Pg_shared_ptr->Pg_sem[semid].Pg_sem_handle[semnum]; + _rel_ipc_sem(); + old_val = _get_sem_val(hndl); + return(old_val); + } +} + +/* Get the current value of the semaphore whose handle is passed in hnd +** This function does NOT assume that the shared memory table is being +** protected by the shared memory table semaphore. +*/ + +int +_get_sem_val(HANDLE hnd) +{ + DWORD waitresult; + + /* Try to get the semaphore */ + waitresult = WaitForSingleObject(hnd, 0L); + + /* Check what the value of the semaphore was */ + switch(waitresult) + { + /* The semaphore was signaled so we just got it. + ** Since we don't really want to keep it, since we just + ** wanted to test its value, go ahead and release it. + */ + case WAIT_OBJECT_0: + ReleaseSemaphore(hnd, 1, NULL); + return(SIGNALED); + + /* The semaphore was non-signaled meaning someone else had it. */ + case WAIT_TIMEOUT: + return(UNSIGNALED); + } +} + +int +shmget(key_t key, uint32 size, int flags) +{ + HANDLE hnd; + char name[IPC_MAX_SHMEM_NAME]; + int id; + + /* Get the handle for the key, if any. */ + _get_ipc_sem(); + id = _get_shm_id(key); + _rel_ipc_sem(); + + /* If we're really going to create a new mapping */ + if (flags != 0) + { + /* if the key is already being used return an error */ + if (id != UNUSED) + return(-1); + + /* convert the key to a character string */ + sprintf(name, "%d", key); + + hnd = CreateFileMapping((HANDLE)0xffffffff, + &sec_attrib, PAGE_READWRITE, + 0, size, name); + + if (hnd == NULL) + return(-1); + else + { + int new_ipc; + struct Pg_shm *pg_ptr; + + _get_ipc_sem(); + new_ipc = Pg_shared_ptr->Pg_next_shm++; + + pg_ptr = &(Pg_shared_ptr->Pg_shm[new_ipc]); + pg_ptr->Pg_shm_key = key; + pg_ptr->Pg_shm_handle = hnd; + _rel_ipc_sem(); + return(new_ipc); + } + } + + /* flags is 0 so we just want the id for the existing mapping */ + else + return(id); +} + +shmdt(char *shmaddr) +{ + UnmapViewOfFile(shmaddr); +} + +int +shmctl(IpcMemoryId shmid, int cmd, struct shmid_ds *buf) +{ + int x = 0; + + if (cmd == IPC_RMID) + { + _get_ipc_sem(); + CloseHandle(Pg_shared_ptr->Pg_shm[shmid].Pg_shm_handle); + _rel_ipc_sem(); + return(0); + } + x = x / x; +} + +/* Attach to the already created shared memory segment */ +LPVOID * +shmat(int shmid, void *shmaddr, int shmflg) +{ + LPVOID *ret_addr; + + _get_ipc_sem(); + ret_addr = MapViewOfFile(Pg_shared_ptr->Pg_shm[shmid].Pg_shm_handle, + FILE_MAP_ALL_ACCESS, 0, 0, 0); + _rel_ipc_sem(); + if (ret_addr == NULL) + { + int jon; + + jon = GetLastError(); + } + return(ret_addr); +} + +/* This is the function that is called when the postmaster starts up. +** It is here that the shared memory table is created. Also, create +** the semaphore that will be used to protect the shared memory table. +** TODO - do something with the return value. +*/ +_nt_init() +{ + HANDLE hnd; + int size = sizeof (struct Pg_shared); + + /* Create the file mapping for the shared memory to be + ** used to store the ipc table. + */ + hnd = CreateFileMapping((HANDLE)0xffffffff, + &sec_attrib, PAGE_READWRITE, + 0, size, IPC_NAME); + + if (hnd == NULL) + { + size = GetLastError(); + return(-1); + } + + Pg_shared_hnd = CreateSemaphore(&sec_attrib, 1, 255, IPC_SEM_NAME); + if (Pg_shared_hnd == NULL) + { + size = GetLastError(); + return(-1); + } +} + +/* This function gets called by every backend at startup time. Its +** main duty is to put the address of the shared memory table pointed +** to by Pg_shared_ptr. There's no need to get the IPC_SEM_NAME semaphore +** because this function is called before we start manipulating the +** shared memory table. +*/ +void +_nt_attach() +{ + HANDLE hnd; + + /* Get a handle to the shared memory table */ + hnd = OpenFileMapping(FILE_MAP_ALL_ACCESS, + FALSE, IPC_NAME); + + /* Map the ipc shared memory table into the address space + ** of this process at an address returned by MapViewOfFile + */ + Pg_shared_ptr = (struct Pg_shared *) MapViewOfFile(hnd, + FILE_MAP_ALL_ACCESS, 0, 0, 0); + + if (Pg_shared_ptr == NULL) + { + hnd = GetLastError(); + return(-1); + } +} + +_get_ipc_sem() +{ + WaitForSingleObject(Pg_shared_hnd, 5000); +} + +_rel_ipc_sem() +{ + ReleaseSemaphore(Pg_shared_hnd, 1, NULL); +} + +pg_dlerror(void) +{ + int x = 0; + x = x / x; +} + +pg_dlclose(void *handle) +{ + FreeLibrary(handle); +} + +void * +pg_dlopen(char *filename) +{ + HINSTANCE hinstlib; + + hinstlib = LoadLibrary(filename); + return (hinstlib); +} + +void * +pg_dlsym(void *handle, char *funcname) +{ + void *proc; + + proc = GetProcAddress(handle, funcname); + return (proc); +} + +void +ftruncate(int fd, int offset) +{ + HANDLE hnd; + + _lseek(fd, offset, SEEK_SET); + hnd = _get_osfhandle(fd); + SetEndOfFile(hnd); +} + +/* The rest are just stubs that are intended to serve as place holders +** in case we want to set breakpoints to see what's happening when +** these routines are called. They'll eventually have to be filled +** in but they're not necessary to get Postgres95 going. +*/ +setuid(int i) +{ + int x = 1; + x = x / x; +} + +setsid() +{ + int x = 1; + x = x / x; +} + +vfork(void) +{ + int x = 0; + x = x / x; +} + +ttyname(int y) +{ + int x = 0; + x = x / x; +} + +step(char *string, char *expbuf) +{ + int x = 0; + x = x / x; +} + +siglongjmp(int env, int value) +{ + int x = 0; + x = x / x; +} + +pause(void) +{ + int x = 0; + x = x / x; +} + +kill(int process, int signal) +{ + int x = 1; + x = x / x; +} + +getuid(void) +{ + int x = 1; + x = x / x; +} + +geteuid( void ) +{ + int x = 1; + x = x / x; +} + +int +fsync(int filedes) +{ +} + +fork(void) +{ + int x = 0; + x = x / x; +} + +char * +compile(char *instring,char *expbuf,char *endbuf,int eof) +{ + int x = 0; + x = x / x; +} + +beginRecipe(char *s) +{ + int x = 0; + x = x / x; +} diff --git a/src/backend/port/win32/nt.h b/src/backend/port/win32/nt.h new file mode 100644 index 00000000000..abe3519ab5c --- /dev/null +++ b/src/backend/port/win32/nt.h @@ -0,0 +1,54 @@ +typedef char * caddr_t; +typedef unsigned long u_long; +typedef unsigned int u_int; +typedef unsigned short u_short; +typedef unsigned char u_char; +typedef unsigned int mode_t; + +typedef u_int uid_t; +typedef u_int gid_t; +typedef int key_t; +#define IPC_PRIVATE ((key_t)0) + +/* Common IPC operation flag definitions. We'll use +** the Unix values unless we find a reason not to. +*/ +#define IPC_CREAT 0001000 /* create entry if key doesn't exist */ +#define IPC_EXCL 0002000 /* fail if key exists */ +#define IPC_NOWAIT 0004000 /* error if request must wait */ + + +struct sembuf +{ + u_short sem_num; + short sem_op; + short sem_flg; +}; + +#define USE_POSIX_TIME +#define NEED_RINT + +#define MAXHOSTNAMELEN 12 /* where is the official definition of this? */ +#define MAXPATHLEN _MAX_PATH /* in winsock.h */ +#define POSTPORT "5432" + +/* NT has stricmp not strcasecmp. Which is ANSI? */ +#define strcasecmp(a,b) _stricmp(a,b) + +#define isascii(a) __isascii(a) + +#define random() rand() + +/* These are bogus values used so that we can compile ipc.c */ +#define SETALL 2 +#define SETVAL 3 +#define IPC_RMID 4 +#define GETNCNT 5 +#define GETVAL 6 + +/* for float.c */ +#define NEED_CBRT +#define NEED_ISINF + +#define POSTGRESDIR "d:\\pglite" +#define PGDATADIR "d:\\pglite\\data" diff --git a/src/backend/port/win32/pglite.mak b/src/backend/port/win32/pglite.mak new file mode 100644 index 00000000000..c922191c5df --- /dev/null +++ b/src/backend/port/win32/pglite.mak @@ -0,0 +1,3323 @@ +# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +!IF "$(CFG)" == "" +CFG=Win32 Debug +!MESSAGE No configuration specified. Defaulting to Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pglite.mak" CFG="Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "Win32 Debug" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "WinRel" +# PROP BASE Intermediate_Dir "WinRel" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "g:\users\forrest\pglite" +# PROP Intermediate_Dir "g:\users\forrest\pglite" +OUTDIR=g:\users\forrest\pglite +INTDIR=g:\users\forrest\pglite + +ALL : $(OUTDIR)/pglite.exe $(OUTDIR)/pglite.bsc + +$(OUTDIR) : + if not exist $(OUTDIR)/nul mkdir $(OUTDIR) + +# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c +# ADD CPP /nologo /W3 /GX /YX /Od /I "g:\pglite\src\backend\include" /I "g:\pglite\src\backend" /I "g:\pglite\src\backend\port\win32" /I "g:\pglite\src\backend\obj" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "__STDC__" /D "_POSIX_" /c +# SUBTRACT CPP /Fr +CPP_PROJ=/nologo /W3 /GX /YX /Od /I "g:\pglite\src\backend\include" /I\ + "g:\pglite\src\backend" /I "g:\pglite\src\backend\port\win32" /I\ + "g:\pglite\src\backend\obj" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "__STDC__"\ + /Fp$(OUTDIR)/"pglite.pch" /Fo$(INTDIR)/ /D "_POSIX_" /c +CPP_OBJS=g:\users\forrest\pglite/ +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o$(OUTDIR)/"pglite.bsc" +BSC32_SBRS= \ + + +$(OUTDIR)/pglite.bsc : $(OUTDIR) $(BSC32_SBRS) +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386 +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no\ + /PDB:$(OUTDIR)/"pglite.pdb" /MACHINE:I386 /OUT:$(OUTDIR)/"pglite.exe" +DEF_FILE= +LINK32_OBJS= \ + $(INTDIR)/scankey.obj \ + $(INTDIR)/printtup.obj \ + $(INTDIR)/indexvalid.obj \ + $(INTDIR)/heaptuple.obj \ + $(INTDIR)/tupdesc.obj \ + $(INTDIR)/indextuple.obj \ + $(INTDIR)/heapvalid.obj \ + $(INTDIR)/hashinsert.obj \ + $(INTDIR)/hashstrat.obj \ + $(INTDIR)/hashutil.obj \ + $(INTDIR)/hashpage.obj \ + $(INTDIR)/hashsearch.obj \ + $(INTDIR)/hashscan.obj \ + $(INTDIR)/hashfunc.obj \ + $(INTDIR)/hash.obj \ + $(INTDIR)/hashovfl.obj \ + $(INTDIR)/bootstrap.obj \ + $(INTDIR)/genam.obj \ + $(INTDIR)/creatinh.obj \ + $(INTDIR)/nodeSeqscan.obj \ + $(INTDIR)/nodeUnique.obj \ + $(INTDIR)/rename.obj \ + $(INTDIR)/transsup.obj \ + $(INTDIR)/transam.obj \ + $(INTDIR)/define.obj \ + $(INTDIR)/execMain.obj \ + $(INTDIR)/xid.obj \ + $(INTDIR)/nodeAgg.obj \ + $(INTDIR)/nbtpage.obj \ + $(INTDIR)/execScan.obj \ + $(INTDIR)/nbtree.obj \ + $(INTDIR)/rtscan.obj \ + $(INTDIR)/indexam.obj \ + $(INTDIR)/execQual.obj \ + $(INTDIR)/nodeHash.obj \ + $(INTDIR)/nbtscan.obj \ + $(INTDIR)/hio.obj \ + $(INTDIR)/pg_proc.obj \ + $(INTDIR)/stats.obj \ + $(INTDIR)/nodeMaterial.obj \ + $(INTDIR)/varsup.obj \ + $(INTDIR)/copy.obj \ + $(INTDIR)/rtproc.obj \ + $(INTDIR)/functions.obj \ + $(INTDIR)/nodeHashjoin.obj \ + $(INTDIR)/catalog.obj \ + $(INTDIR)/nbtinsert.obj \ + $(INTDIR)/rtree.obj \ + $(INTDIR)/version.obj \ + $(INTDIR)/async.obj \ + $(INTDIR)/nbtutils.obj \ + $(INTDIR)/vacuum.obj \ + $(INTDIR)/rtstrat.obj \ + $(INTDIR)/execFlatten.obj \ + $(INTDIR)/nodeTee.obj \ + $(INTDIR)/nodeIndexscan.obj \ + $(INTDIR)/remove.obj \ + $(INTDIR)/indexing.obj \ + $(INTDIR)/command.obj \ + $(INTDIR)/nbtsearch.obj \ + $(INTDIR)/heapam.obj \ + $(INTDIR)/nodeSort.obj \ + $(INTDIR)/execProcnode.obj \ + $(INTDIR)/nodeResult.obj \ + $(INTDIR)/index.obj \ + $(INTDIR)/xact.obj \ + $(INTDIR)/nodeMergejoin.obj \ + $(INTDIR)/pg_operator.obj \ + $(INTDIR)/execJunk.obj \ + $(INTDIR)/pg_aggregate.obj \ + $(INTDIR)/istrat.obj \ + $(INTDIR)/execUtils.obj \ + $(INTDIR)/purge.obj \ + $(INTDIR)/heap.obj \ + $(INTDIR)/nbtstrat.obj \ + $(INTDIR)/execAmi.obj \ + $(INTDIR)/execTuples.obj \ + $(INTDIR)/pg_type.obj \ + $(INTDIR)/view.obj \ + $(INTDIR)/nodeAppend.obj \ + $(INTDIR)/defind.obj \ + $(INTDIR)/nodeNestloop.obj \ + $(INTDIR)/nbtcompare.obj \ + $(INTDIR)/rtget.obj \ + $(INTDIR)/catalog_utils.obj \ + $(INTDIR)/setrefs.obj \ + $(INTDIR)/mergeutils.obj \ + $(INTDIR)/oset.obj \ + $(INTDIR)/arrayutils.obj \ + $(INTDIR)/nodeFuncs.obj \ + $(INTDIR)/rewriteSupport.obj \ + $(INTDIR)/bufpage.obj \ + $(INTDIR)/fd.obj \ + $(INTDIR)/clauseinfo.obj \ + $(INTDIR)/nabstime.obj \ + $(INTDIR)/mcxt.obj \ + $(INTDIR)/ipci.obj \ + $(INTDIR)/qsort.obj \ + $(INTDIR)/outfuncs.obj \ + $(INTDIR)/tqual.obj \ + $(INTDIR)/keys.obj \ + $(INTDIR)/clauses.obj \ + $(INTDIR)/print.obj \ + $(INTDIR)/postinit.obj \ + $(INTDIR)/oidchar16.obj \ + $(INTDIR)/name.obj \ + $(INTDIR)/tid.obj \ + $(INTDIR)/"be-fsstubs.obj" \ + $(INTDIR)/elog.obj \ + $(INTDIR)/bufmgr.obj \ + $(INTDIR)/portalbuf.obj \ + $(INTDIR)/psort.obj \ + $(INTDIR)/syscache.obj \ + $(INTDIR)/exc.obj \ + $(INTDIR)/selfuncs.obj \ + $(INTDIR)/var.obj \ + $(INTDIR)/oid.obj \ + $(INTDIR)/"be-pqexec.obj" \ + $(INTDIR)/ordering.obj \ + $(INTDIR)/inv_api.obj \ + $(INTDIR)/buf_table.obj \ + $(INTDIR)/acl.obj \ + $(INTDIR)/costsize.obj \ + $(INTDIR)/catcache.obj \ + $(INTDIR)/rewriteRemove.obj \ + $(INTDIR)/parse_query.obj \ + $(INTDIR)/excabort.obj \ + $(INTDIR)/lmgr.obj \ + $(INTDIR)/excid.obj \ + $(INTDIR)/int.obj \ + $(INTDIR)/auth.obj \ + $(INTDIR)/regexp.obj \ + $(INTDIR)/proc.obj \ + $(INTDIR)/dbcommands.obj \ + $(INTDIR)/dynahash.obj \ + $(INTDIR)/shmem.obj \ + $(INTDIR)/relnode.obj \ + $(INTDIR)/fstack.obj \ + $(INTDIR)/smgr.obj \ + $(INTDIR)/magic.obj \ + $(INTDIR)/relcache.obj \ + $(INTDIR)/varlena.obj \ + $(INTDIR)/allpaths.obj \ + $(INTDIR)/portalmem.obj \ + $(INTDIR)/bit.obj \ + $(INTDIR)/readfuncs.obj \ + $(INTDIR)/nodes.obj \ + $(INTDIR)/chunk.obj \ + $(INTDIR)/datum.obj \ + $(INTDIR)/analyze.obj \ + $(INTDIR)/oidint4.obj \ + $(INTDIR)/hasht.obj \ + $(INTDIR)/numutils.obj \ + $(INTDIR)/pqcomm.obj \ + $(INTDIR)/indxpath.obj \ + $(INTDIR)/lispsort.obj \ + $(INTDIR)/arrayfuncs.obj \ + $(INTDIR)/copyfuncs.obj \ + $(INTDIR)/planmain.obj \ + $(INTDIR)/makefuncs.obj \ + $(INTDIR)/lsyscache.obj \ + $(INTDIR)/multi.obj \ + $(INTDIR)/freelist.obj \ + $(INTDIR)/aclchk.obj \ + $(INTDIR)/initsplan.obj \ + $(INTDIR)/prune.obj \ + $(INTDIR)/sinvaladt.obj \ + $(INTDIR)/orindxpath.obj \ + $(INTDIR)/joinrels.obj \ + $(INTDIR)/rewriteManip.obj \ + $(INTDIR)/itemptr.obj \ + $(INTDIR)/s_lock.obj \ + $(INTDIR)/miscinit.obj \ + $(INTDIR)/postgres.obj \ + $(INTDIR)/parser.obj \ + $(INTDIR)/tlist.obj \ + $(INTDIR)/dt.obj \ + $(INTDIR)/sinval.obj \ + $(INTDIR)/pqpacket.obj \ + $(INTDIR)/assert.obj \ + $(INTDIR)/utility.obj \ + $(INTDIR)/bool.obj \ + $(INTDIR)/md.obj \ + $(INTDIR)/pqsignal.obj \ + $(INTDIR)/globals.obj \ + $(INTDIR)/postmaster.obj \ + $(INTDIR)/joinpath.obj \ + $(INTDIR)/fastpath.obj \ + $(INTDIR)/archive.obj \ + $(INTDIR)/fcache.obj \ + $(INTDIR)/mm.obj \ + $(INTDIR)/createplan.obj \ + $(INTDIR)/read.obj \ + $(INTDIR)/stringinfo.obj \ + $(INTDIR)/hashfn.obj \ + $(INTDIR)/regproc.obj \ + $(INTDIR)/main.obj \ + $(INTDIR)/enbl.obj \ + $(INTDIR)/prepunion.obj \ + $(INTDIR)/prepqual.obj \ + $(INTDIR)/planner.obj \ + $(INTDIR)/clausesel.obj \ + $(INTDIR)/portal.obj \ + $(INTDIR)/spin.obj \ + $(INTDIR)/lock.obj \ + $(INTDIR)/single.obj \ + $(INTDIR)/io.obj \ + $(INTDIR)/"geo-ops.obj" \ + $(INTDIR)/dest.obj \ + $(INTDIR)/rewriteDefine.obj \ + $(INTDIR)/keywords.obj \ + $(INTDIR)/hashutils.obj \ + $(INTDIR)/format.obj \ + $(INTDIR)/scanner.obj \ + $(INTDIR)/aset.obj \ + $(INTDIR)/"geo-selfuncs.obj" \ + $(INTDIR)/float.obj \ + $(INTDIR)/pquery.obj \ + $(INTDIR)/"be-dumpdata.obj" \ + $(INTDIR)/filename.obj \ + $(INTDIR)/misc.obj \ + $(INTDIR)/pathnode.obj \ + $(INTDIR)/inval.obj \ + $(INTDIR)/smgrtype.obj \ + $(INTDIR)/joininfo.obj \ + $(INTDIR)/lselect.obj \ + $(INTDIR)/rel.obj \ + $(INTDIR)/internal.obj \ + $(INTDIR)/preptlist.obj \ + $(INTDIR)/joinutils.obj \ + $(INTDIR)/shmqueue.obj \ + $(INTDIR)/date.obj \ + $(INTDIR)/locks.obj \ + $(INTDIR)/not_in.obj \ + $(INTDIR)/char.obj \ + $(INTDIR)/rewriteHandler.obj \ + $(INTDIR)/sets.obj \ + $(INTDIR)/palloc.obj \ + $(INTDIR)/indexnode.obj \ + $(INTDIR)/equalfuncs.obj \ + $(INTDIR)/oidint2.obj \ + $(INTDIR)/list.obj \ + $(INTDIR)/plancat.obj \ + $(INTDIR)/fmgr.obj \ + $(INTDIR)/fmgrtab.obj \ + $(INTDIR)/dllist.obj \ + $(INTDIR)/nodeGroup.obj \ + $(INTDIR)/localbuf.obj \ + $(INTDIR)/cluster.obj \ + $(INTDIR)/ipc.obj \ + $(INTDIR)/nt.obj \ + $(INTDIR)/getopt.obj \ + $(INTDIR)/bootscanner.obj \ + $(INTDIR)/scan.obj \ + $(INTDIR)/bootparse.obj \ + $(INTDIR)/gram.obj \ + $(INTDIR)/findbe.obj \ + $(INTDIR)/regerror.obj \ + $(INTDIR)/regfree.obj \ + $(INTDIR)/regcomp.obj \ + $(INTDIR)/regexec.obj \ + $(INTDIR)/nbtsort.obj \ + $(INTDIR)/buf_init.obj \ + $(INTDIR)/dfmgr.obj + +$(OUTDIR)/pglite.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "WinDebug" +# PROP BASE Intermediate_Dir "WinDebug" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "d:\local\forrest\pglite" +# PROP Intermediate_Dir "d:\local\forrest\pglite" +OUTDIR=d:\local\forrest\pglite +INTDIR=d:\local\forrest\pglite + +ALL : $(OUTDIR)/pglite.exe $(OUTDIR)/pglite.bsc + +$(OUTDIR) : + if not exist $(OUTDIR)/nul mkdir $(OUTDIR) + +# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c +# ADD CPP /nologo /G5 /W3 /GX /Zi /YX /Od /I "g:\pglite\src\backend" /I "g:\pglite\src\backend\port\win32" /I "g:\pglite\src\backend\obj" /I "g:\pglite\src\backend\include" /I "g:\pglite\src\backend\port/win32/regex" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "__STDC__" /D "_POSIX_" /D "_NTSDK" /D "NO_SECURITY" /D "NEED_RUSAGE" /FR /c +CPP_PROJ=/nologo /G5 /W3 /GX /Zi /YX /Od /I "g:\pglite\src\backend" /I\ + "g:\pglite\src\backend\port\win32" /I "g:\pglite\src\backend\obj" /I\ + "g:\pglite\src\backend\include" /I "g:\pglite\src\backend\port/win32/regex" /D\ + "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "__STDC__" /D "_POSIX_" /D "_NTSDK" /D\ + "NO_SECURITY" /D "NEED_RUSAGE" /FR$(INTDIR)/ /Fp$(OUTDIR)/"pglite.pch"\ + /Fo$(INTDIR)/ /Fd$(OUTDIR)/"pglite.pdb" /c +CPP_OBJS=d:\local\forrest\pglite/ +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o$(OUTDIR)/"pglite.bsc" +BSC32_SBRS= \ + $(INTDIR)/scankey.sbr \ + $(INTDIR)/printtup.sbr \ + $(INTDIR)/indexvalid.sbr \ + $(INTDIR)/heaptuple.sbr \ + $(INTDIR)/tupdesc.sbr \ + $(INTDIR)/indextuple.sbr \ + $(INTDIR)/heapvalid.sbr \ + $(INTDIR)/hashinsert.sbr \ + $(INTDIR)/hashstrat.sbr \ + $(INTDIR)/hashutil.sbr \ + $(INTDIR)/hashpage.sbr \ + $(INTDIR)/hashsearch.sbr \ + $(INTDIR)/hashscan.sbr \ + $(INTDIR)/hashfunc.sbr \ + $(INTDIR)/hash.sbr \ + $(INTDIR)/hashovfl.sbr \ + $(INTDIR)/bootstrap.sbr \ + $(INTDIR)/genam.sbr \ + $(INTDIR)/creatinh.sbr \ + $(INTDIR)/nodeSeqscan.sbr \ + $(INTDIR)/nodeUnique.sbr \ + $(INTDIR)/rename.sbr \ + $(INTDIR)/transsup.sbr \ + $(INTDIR)/transam.sbr \ + $(INTDIR)/define.sbr \ + $(INTDIR)/execMain.sbr \ + $(INTDIR)/xid.sbr \ + $(INTDIR)/nodeAgg.sbr \ + $(INTDIR)/nbtpage.sbr \ + $(INTDIR)/execScan.sbr \ + $(INTDIR)/nbtree.sbr \ + $(INTDIR)/rtscan.sbr \ + $(INTDIR)/indexam.sbr \ + $(INTDIR)/execQual.sbr \ + $(INTDIR)/nodeHash.sbr \ + $(INTDIR)/nbtscan.sbr \ + $(INTDIR)/hio.sbr \ + $(INTDIR)/pg_proc.sbr \ + $(INTDIR)/stats.sbr \ + $(INTDIR)/nodeMaterial.sbr \ + $(INTDIR)/varsup.sbr \ + $(INTDIR)/copy.sbr \ + $(INTDIR)/rtproc.sbr \ + $(INTDIR)/functions.sbr \ + $(INTDIR)/nodeHashjoin.sbr \ + $(INTDIR)/catalog.sbr \ + $(INTDIR)/nbtinsert.sbr \ + $(INTDIR)/rtree.sbr \ + $(INTDIR)/version.sbr \ + $(INTDIR)/async.sbr \ + $(INTDIR)/nbtutils.sbr \ + $(INTDIR)/vacuum.sbr \ + $(INTDIR)/rtstrat.sbr \ + $(INTDIR)/execFlatten.sbr \ + $(INTDIR)/nodeTee.sbr \ + $(INTDIR)/nodeIndexscan.sbr \ + $(INTDIR)/remove.sbr \ + $(INTDIR)/indexing.sbr \ + $(INTDIR)/command.sbr \ + $(INTDIR)/nbtsearch.sbr \ + $(INTDIR)/heapam.sbr \ + $(INTDIR)/nodeSort.sbr \ + $(INTDIR)/execProcnode.sbr \ + $(INTDIR)/nodeResult.sbr \ + $(INTDIR)/index.sbr \ + $(INTDIR)/xact.sbr \ + $(INTDIR)/nodeMergejoin.sbr \ + $(INTDIR)/pg_operator.sbr \ + $(INTDIR)/execJunk.sbr \ + $(INTDIR)/pg_aggregate.sbr \ + $(INTDIR)/istrat.sbr \ + $(INTDIR)/execUtils.sbr \ + $(INTDIR)/purge.sbr \ + $(INTDIR)/heap.sbr \ + $(INTDIR)/nbtstrat.sbr \ + $(INTDIR)/execAmi.sbr \ + $(INTDIR)/execTuples.sbr \ + $(INTDIR)/pg_type.sbr \ + $(INTDIR)/view.sbr \ + $(INTDIR)/nodeAppend.sbr \ + $(INTDIR)/defind.sbr \ + $(INTDIR)/nodeNestloop.sbr \ + $(INTDIR)/nbtcompare.sbr \ + $(INTDIR)/rtget.sbr \ + $(INTDIR)/catalog_utils.sbr \ + $(INTDIR)/setrefs.sbr \ + $(INTDIR)/mergeutils.sbr \ + $(INTDIR)/oset.sbr \ + $(INTDIR)/arrayutils.sbr \ + $(INTDIR)/nodeFuncs.sbr \ + $(INTDIR)/rewriteSupport.sbr \ + $(INTDIR)/bufpage.sbr \ + $(INTDIR)/fd.sbr \ + $(INTDIR)/clauseinfo.sbr \ + $(INTDIR)/nabstime.sbr \ + $(INTDIR)/mcxt.sbr \ + $(INTDIR)/ipci.sbr \ + $(INTDIR)/qsort.sbr \ + $(INTDIR)/outfuncs.sbr \ + $(INTDIR)/tqual.sbr \ + $(INTDIR)/keys.sbr \ + $(INTDIR)/clauses.sbr \ + $(INTDIR)/print.sbr \ + $(INTDIR)/postinit.sbr \ + $(INTDIR)/oidchar16.sbr \ + $(INTDIR)/name.sbr \ + $(INTDIR)/tid.sbr \ + $(INTDIR)/"be-fsstubs.sbr" \ + $(INTDIR)/elog.sbr \ + $(INTDIR)/bufmgr.sbr \ + $(INTDIR)/portalbuf.sbr \ + $(INTDIR)/psort.sbr \ + $(INTDIR)/syscache.sbr \ + $(INTDIR)/exc.sbr \ + $(INTDIR)/selfuncs.sbr \ + $(INTDIR)/var.sbr \ + $(INTDIR)/oid.sbr \ + $(INTDIR)/"be-pqexec.sbr" \ + $(INTDIR)/ordering.sbr \ + $(INTDIR)/inv_api.sbr \ + $(INTDIR)/buf_table.sbr \ + $(INTDIR)/acl.sbr \ + $(INTDIR)/costsize.sbr \ + $(INTDIR)/catcache.sbr \ + $(INTDIR)/rewriteRemove.sbr \ + $(INTDIR)/parse_query.sbr \ + $(INTDIR)/excabort.sbr \ + $(INTDIR)/lmgr.sbr \ + $(INTDIR)/excid.sbr \ + $(INTDIR)/int.sbr \ + $(INTDIR)/auth.sbr \ + $(INTDIR)/regexp.sbr \ + $(INTDIR)/proc.sbr \ + $(INTDIR)/dbcommands.sbr \ + $(INTDIR)/dynahash.sbr \ + $(INTDIR)/shmem.sbr \ + $(INTDIR)/relnode.sbr \ + $(INTDIR)/fstack.sbr \ + $(INTDIR)/smgr.sbr \ + $(INTDIR)/magic.sbr \ + $(INTDIR)/relcache.sbr \ + $(INTDIR)/varlena.sbr \ + $(INTDIR)/allpaths.sbr \ + $(INTDIR)/portalmem.sbr \ + $(INTDIR)/bit.sbr \ + $(INTDIR)/readfuncs.sbr \ + $(INTDIR)/nodes.sbr \ + $(INTDIR)/chunk.sbr \ + $(INTDIR)/datum.sbr \ + $(INTDIR)/analyze.sbr \ + $(INTDIR)/oidint4.sbr \ + $(INTDIR)/hasht.sbr \ + $(INTDIR)/numutils.sbr \ + $(INTDIR)/pqcomm.sbr \ + $(INTDIR)/indxpath.sbr \ + $(INTDIR)/lispsort.sbr \ + $(INTDIR)/arrayfuncs.sbr \ + $(INTDIR)/copyfuncs.sbr \ + $(INTDIR)/planmain.sbr \ + $(INTDIR)/makefuncs.sbr \ + $(INTDIR)/lsyscache.sbr \ + $(INTDIR)/multi.sbr \ + $(INTDIR)/freelist.sbr \ + $(INTDIR)/aclchk.sbr \ + $(INTDIR)/initsplan.sbr \ + $(INTDIR)/prune.sbr \ + $(INTDIR)/sinvaladt.sbr \ + $(INTDIR)/orindxpath.sbr \ + $(INTDIR)/joinrels.sbr \ + $(INTDIR)/rewriteManip.sbr \ + $(INTDIR)/itemptr.sbr \ + $(INTDIR)/s_lock.sbr \ + $(INTDIR)/miscinit.sbr \ + $(INTDIR)/postgres.sbr \ + $(INTDIR)/parser.sbr \ + $(INTDIR)/tlist.sbr \ + $(INTDIR)/dt.sbr \ + $(INTDIR)/sinval.sbr \ + $(INTDIR)/pqpacket.sbr \ + $(INTDIR)/assert.sbr \ + $(INTDIR)/utility.sbr \ + $(INTDIR)/bool.sbr \ + $(INTDIR)/md.sbr \ + $(INTDIR)/pqsignal.sbr \ + $(INTDIR)/globals.sbr \ + $(INTDIR)/postmaster.sbr \ + $(INTDIR)/joinpath.sbr \ + $(INTDIR)/fastpath.sbr \ + $(INTDIR)/archive.sbr \ + $(INTDIR)/fcache.sbr \ + $(INTDIR)/mm.sbr \ + $(INTDIR)/createplan.sbr \ + $(INTDIR)/read.sbr \ + $(INTDIR)/stringinfo.sbr \ + $(INTDIR)/hashfn.sbr \ + $(INTDIR)/regproc.sbr \ + $(INTDIR)/main.sbr \ + $(INTDIR)/enbl.sbr \ + $(INTDIR)/prepunion.sbr \ + $(INTDIR)/prepqual.sbr \ + $(INTDIR)/planner.sbr \ + $(INTDIR)/clausesel.sbr \ + $(INTDIR)/portal.sbr \ + $(INTDIR)/spin.sbr \ + $(INTDIR)/lock.sbr \ + $(INTDIR)/single.sbr \ + $(INTDIR)/io.sbr \ + $(INTDIR)/"geo-ops.sbr" \ + $(INTDIR)/dest.sbr \ + $(INTDIR)/rewriteDefine.sbr \ + $(INTDIR)/keywords.sbr \ + $(INTDIR)/hashutils.sbr \ + $(INTDIR)/format.sbr \ + $(INTDIR)/scanner.sbr \ + $(INTDIR)/aset.sbr \ + $(INTDIR)/"geo-selfuncs.sbr" \ + $(INTDIR)/float.sbr \ + $(INTDIR)/pquery.sbr \ + $(INTDIR)/"be-dumpdata.sbr" \ + $(INTDIR)/filename.sbr \ + $(INTDIR)/misc.sbr \ + $(INTDIR)/pathnode.sbr \ + $(INTDIR)/inval.sbr \ + $(INTDIR)/smgrtype.sbr \ + $(INTDIR)/joininfo.sbr \ + $(INTDIR)/lselect.sbr \ + $(INTDIR)/rel.sbr \ + $(INTDIR)/internal.sbr \ + $(INTDIR)/preptlist.sbr \ + $(INTDIR)/joinutils.sbr \ + $(INTDIR)/shmqueue.sbr \ + $(INTDIR)/date.sbr \ + $(INTDIR)/locks.sbr \ + $(INTDIR)/not_in.sbr \ + $(INTDIR)/char.sbr \ + $(INTDIR)/rewriteHandler.sbr \ + $(INTDIR)/sets.sbr \ + $(INTDIR)/palloc.sbr \ + $(INTDIR)/indexnode.sbr \ + $(INTDIR)/equalfuncs.sbr \ + $(INTDIR)/oidint2.sbr \ + $(INTDIR)/list.sbr \ + $(INTDIR)/plancat.sbr \ + $(INTDIR)/fmgr.sbr \ + $(INTDIR)/fmgrtab.sbr \ + $(INTDIR)/dllist.sbr \ + $(INTDIR)/nodeGroup.sbr \ + $(INTDIR)/localbuf.sbr \ + $(INTDIR)/cluster.sbr \ + $(INTDIR)/ipc.sbr \ + $(INTDIR)/nt.sbr \ + $(INTDIR)/getopt.sbr \ + $(INTDIR)/bootscanner.sbr \ + $(INTDIR)/scan.sbr \ + $(INTDIR)/bootparse.sbr \ + $(INTDIR)/gram.sbr \ + $(INTDIR)/findbe.sbr \ + $(INTDIR)/regerror.sbr \ + $(INTDIR)/regfree.sbr \ + $(INTDIR)/regcomp.sbr \ + $(INTDIR)/regexec.sbr \ + $(INTDIR)/nbtsort.sbr \ + $(INTDIR)/buf_init.sbr \ + $(INTDIR)/dfmgr.sbr + +$(OUTDIR)/pglite.bsc : $(OUTDIR) $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386 +# SUBTRACT LINK32 /PDB:none +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib wsock32.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes\ + /PDB:$(OUTDIR)/"pglite.pdb" /DEBUG /MACHINE:I386 /OUT:$(OUTDIR)/"pglite.exe" +DEF_FILE= +LINK32_OBJS= \ + $(INTDIR)/scankey.obj \ + $(INTDIR)/printtup.obj \ + $(INTDIR)/indexvalid.obj \ + $(INTDIR)/heaptuple.obj \ + $(INTDIR)/tupdesc.obj \ + $(INTDIR)/indextuple.obj \ + $(INTDIR)/heapvalid.obj \ + $(INTDIR)/hashinsert.obj \ + $(INTDIR)/hashstrat.obj \ + $(INTDIR)/hashutil.obj \ + $(INTDIR)/hashpage.obj \ + $(INTDIR)/hashsearch.obj \ + $(INTDIR)/hashscan.obj \ + $(INTDIR)/hashfunc.obj \ + $(INTDIR)/hash.obj \ + $(INTDIR)/hashovfl.obj \ + $(INTDIR)/bootstrap.obj \ + $(INTDIR)/genam.obj \ + $(INTDIR)/creatinh.obj \ + $(INTDIR)/nodeSeqscan.obj \ + $(INTDIR)/nodeUnique.obj \ + $(INTDIR)/rename.obj \ + $(INTDIR)/transsup.obj \ + $(INTDIR)/transam.obj \ + $(INTDIR)/define.obj \ + $(INTDIR)/execMain.obj \ + $(INTDIR)/xid.obj \ + $(INTDIR)/nodeAgg.obj \ + $(INTDIR)/nbtpage.obj \ + $(INTDIR)/execScan.obj \ + $(INTDIR)/nbtree.obj \ + $(INTDIR)/rtscan.obj \ + $(INTDIR)/indexam.obj \ + $(INTDIR)/execQual.obj \ + $(INTDIR)/nodeHash.obj \ + $(INTDIR)/nbtscan.obj \ + $(INTDIR)/hio.obj \ + $(INTDIR)/pg_proc.obj \ + $(INTDIR)/stats.obj \ + $(INTDIR)/nodeMaterial.obj \ + $(INTDIR)/varsup.obj \ + $(INTDIR)/copy.obj \ + $(INTDIR)/rtproc.obj \ + $(INTDIR)/functions.obj \ + $(INTDIR)/nodeHashjoin.obj \ + $(INTDIR)/catalog.obj \ + $(INTDIR)/nbtinsert.obj \ + $(INTDIR)/rtree.obj \ + $(INTDIR)/version.obj \ + $(INTDIR)/async.obj \ + $(INTDIR)/nbtutils.obj \ + $(INTDIR)/vacuum.obj \ + $(INTDIR)/rtstrat.obj \ + $(INTDIR)/execFlatten.obj \ + $(INTDIR)/nodeTee.obj \ + $(INTDIR)/nodeIndexscan.obj \ + $(INTDIR)/remove.obj \ + $(INTDIR)/indexing.obj \ + $(INTDIR)/command.obj \ + $(INTDIR)/nbtsearch.obj \ + $(INTDIR)/heapam.obj \ + $(INTDIR)/nodeSort.obj \ + $(INTDIR)/execProcnode.obj \ + $(INTDIR)/nodeResult.obj \ + $(INTDIR)/index.obj \ + $(INTDIR)/xact.obj \ + $(INTDIR)/nodeMergejoin.obj \ + $(INTDIR)/pg_operator.obj \ + $(INTDIR)/execJunk.obj \ + $(INTDIR)/pg_aggregate.obj \ + $(INTDIR)/istrat.obj \ + $(INTDIR)/execUtils.obj \ + $(INTDIR)/purge.obj \ + $(INTDIR)/heap.obj \ + $(INTDIR)/nbtstrat.obj \ + $(INTDIR)/execAmi.obj \ + $(INTDIR)/execTuples.obj \ + $(INTDIR)/pg_type.obj \ + $(INTDIR)/view.obj \ + $(INTDIR)/nodeAppend.obj \ + $(INTDIR)/defind.obj \ + $(INTDIR)/nodeNestloop.obj \ + $(INTDIR)/nbtcompare.obj \ + $(INTDIR)/rtget.obj \ + $(INTDIR)/catalog_utils.obj \ + $(INTDIR)/setrefs.obj \ + $(INTDIR)/mergeutils.obj \ + $(INTDIR)/oset.obj \ + $(INTDIR)/arrayutils.obj \ + $(INTDIR)/nodeFuncs.obj \ + $(INTDIR)/rewriteSupport.obj \ + $(INTDIR)/bufpage.obj \ + $(INTDIR)/fd.obj \ + $(INTDIR)/clauseinfo.obj \ + $(INTDIR)/nabstime.obj \ + $(INTDIR)/mcxt.obj \ + $(INTDIR)/ipci.obj \ + $(INTDIR)/qsort.obj \ + $(INTDIR)/outfuncs.obj \ + $(INTDIR)/tqual.obj \ + $(INTDIR)/keys.obj \ + $(INTDIR)/clauses.obj \ + $(INTDIR)/print.obj \ + $(INTDIR)/postinit.obj \ + $(INTDIR)/oidchar16.obj \ + $(INTDIR)/name.obj \ + $(INTDIR)/tid.obj \ + $(INTDIR)/"be-fsstubs.obj" \ + $(INTDIR)/elog.obj \ + $(INTDIR)/bufmgr.obj \ + $(INTDIR)/portalbuf.obj \ + $(INTDIR)/psort.obj \ + $(INTDIR)/syscache.obj \ + $(INTDIR)/exc.obj \ + $(INTDIR)/selfuncs.obj \ + $(INTDIR)/var.obj \ + $(INTDIR)/oid.obj \ + $(INTDIR)/"be-pqexec.obj" \ + $(INTDIR)/ordering.obj \ + $(INTDIR)/inv_api.obj \ + $(INTDIR)/buf_table.obj \ + $(INTDIR)/acl.obj \ + $(INTDIR)/costsize.obj \ + $(INTDIR)/catcache.obj \ + $(INTDIR)/rewriteRemove.obj \ + $(INTDIR)/parse_query.obj \ + $(INTDIR)/excabort.obj \ + $(INTDIR)/lmgr.obj \ + $(INTDIR)/excid.obj \ + $(INTDIR)/int.obj \ + $(INTDIR)/auth.obj \ + $(INTDIR)/regexp.obj \ + $(INTDIR)/proc.obj \ + $(INTDIR)/dbcommands.obj \ + $(INTDIR)/dynahash.obj \ + $(INTDIR)/shmem.obj \ + $(INTDIR)/relnode.obj \ + $(INTDIR)/fstack.obj \ + $(INTDIR)/smgr.obj \ + $(INTDIR)/magic.obj \ + $(INTDIR)/relcache.obj \ + $(INTDIR)/varlena.obj \ + $(INTDIR)/allpaths.obj \ + $(INTDIR)/portalmem.obj \ + $(INTDIR)/bit.obj \ + $(INTDIR)/readfuncs.obj \ + $(INTDIR)/nodes.obj \ + $(INTDIR)/chunk.obj \ + $(INTDIR)/datum.obj \ + $(INTDIR)/analyze.obj \ + $(INTDIR)/oidint4.obj \ + $(INTDIR)/hasht.obj \ + $(INTDIR)/numutils.obj \ + $(INTDIR)/pqcomm.obj \ + $(INTDIR)/indxpath.obj \ + $(INTDIR)/lispsort.obj \ + $(INTDIR)/arrayfuncs.obj \ + $(INTDIR)/copyfuncs.obj \ + $(INTDIR)/planmain.obj \ + $(INTDIR)/makefuncs.obj \ + $(INTDIR)/lsyscache.obj \ + $(INTDIR)/multi.obj \ + $(INTDIR)/freelist.obj \ + $(INTDIR)/aclchk.obj \ + $(INTDIR)/initsplan.obj \ + $(INTDIR)/prune.obj \ + $(INTDIR)/sinvaladt.obj \ + $(INTDIR)/orindxpath.obj \ + $(INTDIR)/joinrels.obj \ + $(INTDIR)/rewriteManip.obj \ + $(INTDIR)/itemptr.obj \ + $(INTDIR)/s_lock.obj \ + $(INTDIR)/miscinit.obj \ + $(INTDIR)/postgres.obj \ + $(INTDIR)/parser.obj \ + $(INTDIR)/tlist.obj \ + $(INTDIR)/dt.obj \ + $(INTDIR)/sinval.obj \ + $(INTDIR)/pqpacket.obj \ + $(INTDIR)/assert.obj \ + $(INTDIR)/utility.obj \ + $(INTDIR)/bool.obj \ + $(INTDIR)/md.obj \ + $(INTDIR)/pqsignal.obj \ + $(INTDIR)/globals.obj \ + $(INTDIR)/postmaster.obj \ + $(INTDIR)/joinpath.obj \ + $(INTDIR)/fastpath.obj \ + $(INTDIR)/archive.obj \ + $(INTDIR)/fcache.obj \ + $(INTDIR)/mm.obj \ + $(INTDIR)/createplan.obj \ + $(INTDIR)/read.obj \ + $(INTDIR)/stringinfo.obj \ + $(INTDIR)/hashfn.obj \ + $(INTDIR)/regproc.obj \ + $(INTDIR)/main.obj \ + $(INTDIR)/enbl.obj \ + $(INTDIR)/prepunion.obj \ + $(INTDIR)/prepqual.obj \ + $(INTDIR)/planner.obj \ + $(INTDIR)/clausesel.obj \ + $(INTDIR)/portal.obj \ + $(INTDIR)/spin.obj \ + $(INTDIR)/lock.obj \ + $(INTDIR)/single.obj \ + $(INTDIR)/io.obj \ + $(INTDIR)/"geo-ops.obj" \ + $(INTDIR)/dest.obj \ + $(INTDIR)/rewriteDefine.obj \ + $(INTDIR)/keywords.obj \ + $(INTDIR)/hashutils.obj \ + $(INTDIR)/format.obj \ + $(INTDIR)/scanner.obj \ + $(INTDIR)/aset.obj \ + $(INTDIR)/"geo-selfuncs.obj" \ + $(INTDIR)/float.obj \ + $(INTDIR)/pquery.obj \ + $(INTDIR)/"be-dumpdata.obj" \ + $(INTDIR)/filename.obj \ + $(INTDIR)/misc.obj \ + $(INTDIR)/pathnode.obj \ + $(INTDIR)/inval.obj \ + $(INTDIR)/smgrtype.obj \ + $(INTDIR)/joininfo.obj \ + $(INTDIR)/lselect.obj \ + $(INTDIR)/rel.obj \ + $(INTDIR)/internal.obj \ + $(INTDIR)/preptlist.obj \ + $(INTDIR)/joinutils.obj \ + $(INTDIR)/shmqueue.obj \ + $(INTDIR)/date.obj \ + $(INTDIR)/locks.obj \ + $(INTDIR)/not_in.obj \ + $(INTDIR)/char.obj \ + $(INTDIR)/rewriteHandler.obj \ + $(INTDIR)/sets.obj \ + $(INTDIR)/palloc.obj \ + $(INTDIR)/indexnode.obj \ + $(INTDIR)/equalfuncs.obj \ + $(INTDIR)/oidint2.obj \ + $(INTDIR)/list.obj \ + $(INTDIR)/plancat.obj \ + $(INTDIR)/fmgr.obj \ + $(INTDIR)/fmgrtab.obj \ + $(INTDIR)/dllist.obj \ + $(INTDIR)/nodeGroup.obj \ + $(INTDIR)/localbuf.obj \ + $(INTDIR)/cluster.obj \ + $(INTDIR)/ipc.obj \ + $(INTDIR)/nt.obj \ + $(INTDIR)/getopt.obj \ + $(INTDIR)/bootscanner.obj \ + $(INTDIR)/scan.obj \ + $(INTDIR)/bootparse.obj \ + $(INTDIR)/gram.obj \ + $(INTDIR)/findbe.obj \ + $(INTDIR)/regerror.obj \ + $(INTDIR)/regfree.obj \ + $(INTDIR)/regcomp.obj \ + $(INTDIR)/regexec.obj \ + $(INTDIR)/nbtsort.obj \ + $(INTDIR)/buf_init.obj \ + $(INTDIR)/dfmgr.obj + +$(OUTDIR)/pglite.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ENDIF + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +################################################################################ +# Begin Group "Source Files" + +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\common\scankey.c + +$(INTDIR)/scankey.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\common\printtup.c + +$(INTDIR)/printtup.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\common\indexvalid.c + +$(INTDIR)/indexvalid.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\common\heaptuple.c + +$(INTDIR)/heaptuple.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\common\tupdesc.c + +$(INTDIR)/tupdesc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\common\indextuple.c + +$(INTDIR)/indextuple.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\common\heapvalid.c + +$(INTDIR)/heapvalid.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hashinsert.c + +$(INTDIR)/hashinsert.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hashstrat.c + +$(INTDIR)/hashstrat.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hashutil.c + +$(INTDIR)/hashutil.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hashpage.c + +$(INTDIR)/hashpage.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hashsearch.c + +$(INTDIR)/hashsearch.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hashscan.c + +$(INTDIR)/hashscan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hashfunc.c + +$(INTDIR)/hashfunc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hash.c + +$(INTDIR)/hash.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\hash\hashovfl.c + +$(INTDIR)/hashovfl.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\bootstrap\bootstrap.c + +$(INTDIR)/bootstrap.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\index\genam.c + +$(INTDIR)/genam.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\creatinh.c + +$(INTDIR)/creatinh.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeSeqscan.c + +$(INTDIR)/nodeSeqscan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeUnique.c + +$(INTDIR)/nodeUnique.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\rename.c + +$(INTDIR)/rename.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\transam\transsup.c + +$(INTDIR)/transsup.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\transam\transam.c + +$(INTDIR)/transam.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\define.c + +$(INTDIR)/define.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execMain.c + +$(INTDIR)/execMain.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\transam\xid.c + +$(INTDIR)/xid.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeAgg.c + +$(INTDIR)/nodeAgg.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtpage.c + +$(INTDIR)/nbtpage.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execScan.c + +$(INTDIR)/execScan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtree.c + +$(INTDIR)/nbtree.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\rtree\rtscan.c + +$(INTDIR)/rtscan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\index\indexam.c + +$(INTDIR)/indexam.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execQual.c + +$(INTDIR)/execQual.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeHash.c + +$(INTDIR)/nodeHash.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtscan.c + +$(INTDIR)/nbtscan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\heap\hio.c + +$(INTDIR)/hio.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\catalog\pg_proc.c + +$(INTDIR)/pg_proc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\heap\stats.c + +$(INTDIR)/stats.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeMaterial.c + +$(INTDIR)/nodeMaterial.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\transam\varsup.c + +$(INTDIR)/varsup.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\copy.c + +$(INTDIR)/copy.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\rtree\rtproc.c + +$(INTDIR)/rtproc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\functions.c + +$(INTDIR)/functions.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeHashjoin.c + +$(INTDIR)/nodeHashjoin.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\catalog\catalog.c + +$(INTDIR)/catalog.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtinsert.c + +$(INTDIR)/nbtinsert.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\rtree\rtree.c + +$(INTDIR)/rtree.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\version.c + +$(INTDIR)/version.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\async.c + +$(INTDIR)/async.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtutils.c + +$(INTDIR)/nbtutils.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\vacuum.c + +$(INTDIR)/vacuum.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\rtree\rtstrat.c + +$(INTDIR)/rtstrat.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execFlatten.c + +$(INTDIR)/execFlatten.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeTee.c + +$(INTDIR)/nodeTee.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeIndexscan.c + +$(INTDIR)/nodeIndexscan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\remove.c + +$(INTDIR)/remove.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\catalog\indexing.c + +$(INTDIR)/indexing.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\command.c + +$(INTDIR)/command.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtsearch.c + +$(INTDIR)/nbtsearch.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\heap\heapam.c + +$(INTDIR)/heapam.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeSort.c + +$(INTDIR)/nodeSort.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execProcnode.c + +$(INTDIR)/execProcnode.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeResult.c + +$(INTDIR)/nodeResult.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\catalog\index.c + +$(INTDIR)/index.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\transam\xact.c + +$(INTDIR)/xact.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeMergejoin.c + +$(INTDIR)/nodeMergejoin.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\catalog\pg_operator.c + +$(INTDIR)/pg_operator.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execJunk.c + +$(INTDIR)/execJunk.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\catalog\pg_aggregate.c + +$(INTDIR)/pg_aggregate.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\index\istrat.c + +$(INTDIR)/istrat.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execUtils.c + +$(INTDIR)/execUtils.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\purge.c + +$(INTDIR)/purge.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\catalog\heap.c + +$(INTDIR)/heap.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtstrat.c + +$(INTDIR)/nbtstrat.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execAmi.c + +$(INTDIR)/execAmi.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\execTuples.c + +$(INTDIR)/execTuples.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\catalog\pg_type.c + +$(INTDIR)/pg_type.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\view.c + +$(INTDIR)/view.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeAppend.c + +$(INTDIR)/nodeAppend.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\defind.c + +$(INTDIR)/defind.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeNestloop.c + +$(INTDIR)/nodeNestloop.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtcompare.c + +$(INTDIR)/nbtcompare.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\rtree\rtget.c + +$(INTDIR)/rtget.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\parser\catalog_utils.c + +$(INTDIR)/catalog_utils.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\plan\setrefs.c + +$(INTDIR)/setrefs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\mergeutils.c + +$(INTDIR)/mergeutils.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\mmgr\oset.c + +$(INTDIR)/oset.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\arrayutils.c + +$(INTDIR)/arrayutils.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\nodeFuncs.c + +$(INTDIR)/nodeFuncs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\rewrite\rewriteSupport.c + +$(INTDIR)/rewriteSupport.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\page\bufpage.c + +$(INTDIR)/bufpage.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\file\fd.c + +$(INTDIR)/fd.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\clauseinfo.c + +$(INTDIR)/clauseinfo.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\nabstime.c + +$(INTDIR)/nabstime.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\mmgr\mcxt.c + +$(INTDIR)/mcxt.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\ipc\ipci.c + +$(INTDIR)/ipci.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\lib\qsort.c + +$(INTDIR)/qsort.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\outfuncs.c + +$(INTDIR)/outfuncs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\time\tqual.c + +$(INTDIR)/tqual.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\keys.c + +$(INTDIR)/keys.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\clauses.c + +$(INTDIR)/clauses.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\print.c + +$(INTDIR)/print.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\init\postinit.c + +$(INTDIR)/postinit.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\oidchar16.c + +$(INTDIR)/oidchar16.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\name.c + +$(INTDIR)/name.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\tid.c + +$(INTDIR)/tid.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="G:\pglite\src\backend\libpq\be-fsstubs.c" + +$(INTDIR)/"be-fsstubs.obj" : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\error\elog.c + +$(INTDIR)/elog.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\buffer\bufmgr.c + +$(INTDIR)/bufmgr.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\libpq\portalbuf.c + +$(INTDIR)/portalbuf.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\sort\psort.c + +$(INTDIR)/psort.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\cache\syscache.c + +$(INTDIR)/syscache.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\error\exc.c + +$(INTDIR)/exc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\selfuncs.c + +$(INTDIR)/selfuncs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\var.c + +$(INTDIR)/var.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\oid.c + +$(INTDIR)/oid.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="G:\pglite\src\backend\libpq\be-pqexec.c" + +$(INTDIR)/"be-pqexec.obj" : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\ordering.c + +$(INTDIR)/ordering.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\large_object\inv_api.c + +$(INTDIR)/inv_api.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\buffer\buf_table.c + +$(INTDIR)/buf_table.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\acl.c + +$(INTDIR)/acl.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\costsize.c + +$(INTDIR)/costsize.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\cache\catcache.c + +$(INTDIR)/catcache.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\rewrite\rewriteRemove.c + +$(INTDIR)/rewriteRemove.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\parser\parse_query.c + +$(INTDIR)/parse_query.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\error\excabort.c + +$(INTDIR)/excabort.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\lmgr\lmgr.c + +$(INTDIR)/lmgr.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\error\excid.c + +$(INTDIR)/excid.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\int.c + +$(INTDIR)/int.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\libpq\auth.c + +$(INTDIR)/auth.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\regexp.c + +$(INTDIR)/regexp.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\lmgr\proc.c + +$(INTDIR)/proc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\parser\dbcommands.c + +$(INTDIR)/dbcommands.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\hash\dynahash.c + +$(INTDIR)/dynahash.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\ipc\shmem.c + +$(INTDIR)/shmem.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\relnode.c + +$(INTDIR)/relnode.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\lib\fstack.c + +$(INTDIR)/fstack.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\smgr\smgr.c + +$(INTDIR)/smgr.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\init\magic.c + +$(INTDIR)/magic.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\cache\relcache.c + +$(INTDIR)/relcache.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\varlena.c + +$(INTDIR)/varlena.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\allpaths.c + +$(INTDIR)/allpaths.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\mmgr\portalmem.c + +$(INTDIR)/portalmem.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\lib\bit.c + +$(INTDIR)/bit.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\readfuncs.c + +$(INTDIR)/readfuncs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\nodes.c + +$(INTDIR)/nodes.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\chunk.c + +$(INTDIR)/chunk.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\datum.c + +$(INTDIR)/datum.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\parser\analyze.c + +$(INTDIR)/analyze.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\oidint4.c + +$(INTDIR)/oidint4.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\lib\hasht.c + +$(INTDIR)/hasht.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\numutils.c + +$(INTDIR)/numutils.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\libpq\pqcomm.c + +$(INTDIR)/pqcomm.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\indxpath.c + +$(INTDIR)/indxpath.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\lib\lispsort.c + +$(INTDIR)/lispsort.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\arrayfuncs.c + +$(INTDIR)/arrayfuncs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\copyfuncs.c + +$(INTDIR)/copyfuncs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\plan\planmain.c + +$(INTDIR)/planmain.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\makefuncs.c + +$(INTDIR)/makefuncs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\cache\lsyscache.c + +$(INTDIR)/lsyscache.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\lmgr\multi.c + +$(INTDIR)/multi.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\buffer\freelist.c + +$(INTDIR)/freelist.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\tcop\aclchk.c + +$(INTDIR)/aclchk.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\plan\initsplan.c + +$(INTDIR)/initsplan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\prune.c + +$(INTDIR)/prune.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\ipc\sinvaladt.c + +$(INTDIR)/sinvaladt.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\orindxpath.c + +$(INTDIR)/orindxpath.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\joinrels.c + +$(INTDIR)/joinrels.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\rewrite\rewriteManip.c + +$(INTDIR)/rewriteManip.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\page\itemptr.c + +$(INTDIR)/itemptr.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\ipc\s_lock.c + +$(INTDIR)/s_lock.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\init\miscinit.c + +$(INTDIR)/miscinit.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\tcop\postgres.c + +$(INTDIR)/postgres.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\parser\parser.c + +$(INTDIR)/parser.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\tlist.c + +$(INTDIR)/tlist.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\dt.c + +$(INTDIR)/dt.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\ipc\sinval.c + +$(INTDIR)/sinval.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\libpq\pqpacket.c + +$(INTDIR)/pqpacket.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\error\assert.c + +$(INTDIR)/assert.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\tcop\utility.c + +$(INTDIR)/utility.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\bool.c + +$(INTDIR)/bool.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\smgr\md.c + +$(INTDIR)/md.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\libpq\pqsignal.c + +$(INTDIR)/pqsignal.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\init\globals.c + +$(INTDIR)/globals.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\postmaster\postmaster.c + +$(INTDIR)/postmaster.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\joinpath.c + +$(INTDIR)/joinpath.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\tcop\fastpath.c + +$(INTDIR)/fastpath.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\prep\archive.c + +$(INTDIR)/archive.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\cache\fcache.c + +$(INTDIR)/fcache.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\smgr\mm.c + +$(INTDIR)/mm.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\plan\createplan.c + +$(INTDIR)/createplan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\read.c + +$(INTDIR)/read.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\lib\stringinfo.c + +$(INTDIR)/stringinfo.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\hash\hashfn.c + +$(INTDIR)/hashfn.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\regproc.c + +$(INTDIR)/regproc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\main\main.c + +$(INTDIR)/main.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\init\enbl.c + +$(INTDIR)/enbl.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\prep\prepunion.c + +$(INTDIR)/prepunion.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\prep\prepqual.c + +$(INTDIR)/prepqual.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\plan\planner.c + +$(INTDIR)/planner.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\clausesel.c + +$(INTDIR)/clausesel.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\libpq\portal.c + +$(INTDIR)/portal.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\ipc\spin.c + +$(INTDIR)/spin.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\lmgr\lock.c + +$(INTDIR)/lock.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\lmgr\single.c + +$(INTDIR)/single.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\parser\io.c + +$(INTDIR)/io.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="G:\pglite\src\backend\utils\adt\geo-ops.c" + +$(INTDIR)/"geo-ops.obj" : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\tcop\dest.c + +$(INTDIR)/dest.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\rewrite\rewriteDefine.c + +$(INTDIR)/rewriteDefine.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\parser\keywords.c + +$(INTDIR)/keywords.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\hashutils.c + +$(INTDIR)/hashutils.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\error\format.c + +$(INTDIR)/format.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\parser\scanner.c + +$(INTDIR)/scanner.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\mmgr\aset.c + +$(INTDIR)/aset.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="G:\pglite\src\backend\utils\adt\geo-selfuncs.c" + +$(INTDIR)/"geo-selfuncs.obj" : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\float.c + +$(INTDIR)/float.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\tcop\pquery.c + +$(INTDIR)/pquery.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE="G:\pglite\src\backend\libpq\be-dumpdata.c" + +$(INTDIR)/"be-dumpdata.obj" : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\filename.c + +$(INTDIR)/filename.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\misc.c + +$(INTDIR)/misc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\pathnode.c + +$(INTDIR)/pathnode.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\cache\inval.c + +$(INTDIR)/inval.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\smgr\smgrtype.c + +$(INTDIR)/smgrtype.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\joininfo.c + +$(INTDIR)/joininfo.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\sort\lselect.c + +$(INTDIR)/lselect.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\cache\rel.c + +$(INTDIR)/rel.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\internal.c + +$(INTDIR)/internal.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\prep\preptlist.c + +$(INTDIR)/preptlist.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\path\joinutils.c + +$(INTDIR)/joinutils.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\ipc\shmqueue.c + +$(INTDIR)/shmqueue.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\date.c + +$(INTDIR)/date.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\rewrite\locks.c + +$(INTDIR)/locks.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\not_in.c + +$(INTDIR)/not_in.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\char.c + +$(INTDIR)/char.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\rewrite\rewriteHandler.c + +$(INTDIR)/rewriteHandler.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\sets.c + +$(INTDIR)/sets.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\mmgr\palloc.c + +$(INTDIR)/palloc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\indexnode.c + +$(INTDIR)/indexnode.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\equalfuncs.c + +$(INTDIR)/equalfuncs.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\adt\oidint2.c + +$(INTDIR)/oidint2.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\nodes\list.c + +$(INTDIR)/list.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\optimizer\util\plancat.c + +$(INTDIR)/plancat.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\fmgr\fmgr.c + +$(INTDIR)/fmgr.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\obj\fmgrtab.c + +$(INTDIR)/fmgrtab.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\lib\dllist.c + +$(INTDIR)/dllist.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\executor\nodeGroup.c + +$(INTDIR)/nodeGroup.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\buffer\localbuf.c + +$(INTDIR)/localbuf.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\commands\cluster.c + +$(INTDIR)/cluster.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\ipc\ipc.c + +$(INTDIR)/ipc.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\port\win32\nt.c + +$(INTDIR)/nt.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\port\win32\getopt.c + +$(INTDIR)/getopt.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\obj\bootscanner.c + +$(INTDIR)/bootscanner.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\obj\scan.c + +$(INTDIR)/scan.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\obj\bootparse.c + +$(INTDIR)/bootparse.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\obj\gram.c + +$(INTDIR)/gram.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\init\findbe.c + +$(INTDIR)/findbe.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\port\win32\regex\regerror.c + +$(INTDIR)/regerror.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\port\win32\regex\regfree.c + +$(INTDIR)/regfree.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\port\win32\regex\regcomp.c + +$(INTDIR)/regcomp.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\port\win32\regex\regexec.c + +$(INTDIR)/regexec.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\access\nbtree\nbtsort.c + +$(INTDIR)/nbtsort.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\storage\buffer\buf_init.c + +$(INTDIR)/buf_init.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=G:\pglite\src\backend\utils\fmgr\dfmgr.c + +$(INTDIR)/dfmgr.obj : $(SOURCE) $(INTDIR) + $(CPP) $(CPP_PROJ) $(SOURCE) + +# End Source File +# End Group +# End Project +################################################################################ diff --git a/src/backend/port/win32/port-protos.h b/src/backend/port/win32/port-protos.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/backend/port/win32/port-protos.h @@ -0,0 +1 @@ + diff --git a/src/backend/port/win32/pwd.h b/src/backend/port/win32/pwd.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/backend/port/win32/pwd.h @@ -0,0 +1 @@ + diff --git a/src/backend/port/win32/regex/COPYRIGHT b/src/backend/port/win32/regex/COPYRIGHT new file mode 100644 index 00000000000..574f6bcec6c --- /dev/null +++ b/src/backend/port/win32/regex/COPYRIGHT @@ -0,0 +1,56 @@ +Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved. +This software is not subject to any license of the American Telephone +and Telegraph Company or of the Regents of the University of California. + +Permission is granted to anyone to use this software for any purpose on +any computer system, and to alter it and redistribute it, subject +to the following restrictions: + +1. The author is not responsible for the consequences of use of this + software, no matter how awful, even if they arise from flaws in it. + +2. The origin of this software must not be misrepresented, either by + explicit claim or by omission. Since few users ever read sources, + credits must appear in the documentation. + +3. Altered versions must be plainly marked as such, and must not be + misrepresented as being the original software. Since few users + ever read sources, credits must appear in the documentation. + +4. This notice may not be removed or altered. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94 + */ diff --git a/src/backend/port/win32/regex/Makefile.inc b/src/backend/port/win32/regex/Makefile.inc new file mode 100644 index 00000000000..f9853f31ce2 --- /dev/null +++ b/src/backend/port/win32/regex/Makefile.inc @@ -0,0 +1,14 @@ +# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 + +# regex sources +.PATH: ${.CURDIR}/regex + +CFLAGS+=-DPOSIX_MISTAKE + +SRCS+= regcomp.c regerror.c regexec.c regfree.c + +MAN3+= regex.0 +MAN7+= re_format.0 + +MLINKS+=regex.3 regcomp.3 regex.3 regexec.3 regex.3 regerror.3 +MLINKS+=regexec.3 regfree.3 diff --git a/src/backend/port/win32/regex/WHATSNEW b/src/backend/port/win32/regex/WHATSNEW new file mode 100644 index 00000000000..f4301d300dd --- /dev/null +++ b/src/backend/port/win32/regex/WHATSNEW @@ -0,0 +1,94 @@ +# @(#)WHATSNEW 8.3 (Berkeley) 3/18/94 + +New in alpha3.4: The complex bug alluded to below has been fixed (in a +slightly kludgey temporary way that may hurt efficiency a bit; this is +another "get it out the door for 4.4" release). The tests at the end of +the tests file have accordingly been uncommented. The primary sign of +the bug was that something like a?b matching ab matched b rather than ab. +(The bug was essentially specific to this exact situation, else it would +have shown up earlier.) + +New in alpha3.3: The definition of word boundaries has been altered +slightly, to more closely match the usual programming notion that "_" +is an alphabetic. Stuff used for pre-ANSI systems is now in a subdir, +and the makefile no longer alludes to it in mysterious ways. The +makefile has generally been cleaned up some. Fixes have been made +(again!) so that the regression test will run without -DREDEBUG, at +the cost of weaker checking. A workaround for a bug in some folks' +<assert.h> has been added. And some more things have been added to +tests, including a couple right at the end which are commented out +because the code currently flunks them (complex bug; fix coming). +Plus the usual minor cleanup. + +New in alpha3.2: Assorted bits of cleanup and portability improvement +(the development base is now a BSDI system using GCC instead of an ancient +Sun system, and the newer compiler exposed some glitches). Fix for a +serious bug that affected REs using many [] (including REG_ICASE REs +because of the way they are implemented), *sometimes*, depending on +memory-allocation patterns. The header-file prototypes no longer name +the parameters, avoiding possible name conflicts. The possibility that +some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is +now handled gracefully. "uchar" is no longer used as an internal type +name (too many people have the same idea). Still the same old lousy +performance, alas. + +New in alpha3.1: Basically nothing, this release is just a bookkeeping +convenience. Stay tuned. + +New in alpha3.0: Performance is no better, alas, but some fixes have been +made and some functionality has been added. (This is basically the "get +it out the door in time for 4.4" release.) One bug fix: regfree() didn't +free the main internal structure (how embarrassing). It is now possible +to put NULs in either the RE or the target string, using (resp.) a new +REG_PEND flag and the old REG_STARTEND flag. The REG_NOSPEC flag to +regcomp() makes all characters ordinary, so you can match a literal +string easily (this will become more useful when performance improves!). +There are now primitives to match beginnings and ends of words, although +the syntax is disgusting and so is the implementation. The REG_ATOI +debugging interface has changed a bit. And there has been considerable +internal cleanup of various kinds. + +New in alpha2.3: Split change list out of README, and moved flags notes +into Makefile. Macro-ized the name of regex(7) in regex(3), since it has +to change for 4.4BSD. Cleanup work in engine.c, and some new regression +tests to catch tricky cases thereof. + +New in alpha2.2: Out-of-date manpages updated. Regerror() acquires two +small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges +in my own test program and might be useful to others for similar purposes. +The regression test will now compile (and run) without REDEBUG. The +BRE \$ bug is fixed. Most uses of "uchar" are gone; it's all chars now. +Char/uchar parameters are now written int/unsigned, to avoid possible +portability problems with unpromoted parameters. Some unsigned casts have +been introduced to minimize portability problems with shifting into sign +bits. + +New in alpha2.1: Lots of little stuff, cleanup and fixes. The one big +thing is that regex.h is now generated, using mkh, rather than being +supplied in the distribution; due to circularities in dependencies, +you have to build regex.h explicitly by "make h". The two known bugs +have been fixed (and the regression test now checks for them), as has a +problem with assertions not being suppressed in the absence of REDEBUG. +No performance work yet. + +New in alpha2: Backslash-anything is an ordinary character, not an +error (except, of course, for the handful of backslashed metacharacters +in BREs), which should reduce script breakage. The regression test +checks *where* null strings are supposed to match, and has generally +been tightened up somewhat. Small bug fixes in parameter passing (not +harmful, but technically errors) and some other areas. Debugging +invoked by defining REDEBUG rather than not defining NDEBUG. + +New in alpha+3: full prototyping for internal routines, using a little +helper program, mkh, which extracts prototypes given in stylized comments. +More minor cleanup. Buglet fix: it's CHAR_BIT, not CHAR_BITS. Simple +pre-screening of input when a literal string is known to be part of the +RE; this does wonders for performance. + +New in alpha+2: minor bits of cleanup. Notably, the number "32" for the +word width isn't hardwired into regexec.c any more, the public header +file prototypes the functions if __STDC__ is defined, and some small typos +in the manpages have been fixed. + +New in alpha+1: improvements to the manual pages, and an important +extension, the REG_STARTEND option to regexec(). diff --git a/src/backend/port/win32/regex/cclass.h b/src/backend/port/win32/regex/cclass.h new file mode 100644 index 00000000000..a29a92ee9c4 --- /dev/null +++ b/src/backend/port/win32/regex/cclass.h @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cclass.h 8.3 (Berkeley) 3/20/94 + */ + +/* character-class table */ +static struct cclass { + char *name; + char *chars; + char *multis; +} cclasses[] = { + "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789", "", + "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", + "", + "blank", " \t", "", + "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ +\25\26\27\30\31\32\33\34\35\36\37\177", "", + "digit", "0123456789", "", + "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", + "", + "lower", "abcdefghijklmnopqrstuvwxyz", + "", + "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", + "", + "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", + "", + "space", "\t\n\v\f\r ", "", + "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + "", + "xdigit", "0123456789ABCDEFabcdef", + "", + NULL, 0, "" +}; diff --git a/src/backend/port/win32/regex/cname.h b/src/backend/port/win32/regex/cname.h new file mode 100644 index 00000000000..c1632ebb1f5 --- /dev/null +++ b/src/backend/port/win32/regex/cname.h @@ -0,0 +1,141 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cname.h 8.3 (Berkeley) 3/20/94 + */ + +/* character-name table */ +static struct cname { + char *name; + char code; +} cnames[] = { + "NUL", '\0', + "SOH", '\001', + "STX", '\002', + "ETX", '\003', + "EOT", '\004', + "ENQ", '\005', + "ACK", '\006', + "BEL", '\007', + "alert", '\007', + "BS", '\010', + "backspace", '\b', + "HT", '\011', + "tab", '\t', + "LF", '\012', + "newline", '\n', + "VT", '\013', + "vertical-tab", '\v', + "FF", '\014', + "form-feed", '\f', + "CR", '\015', + "carriage-return", '\r', + "SO", '\016', + "SI", '\017', + "DLE", '\020', + "DC1", '\021', + "DC2", '\022', + "DC3", '\023', + "DC4", '\024', + "NAK", '\025', + "SYN", '\026', + "ETB", '\027', + "CAN", '\030', + "EM", '\031', + "SUB", '\032', + "ESC", '\033', + "IS4", '\034', + "FS", '\034', + "IS3", '\035', + "GS", '\035', + "IS2", '\036', + "RS", '\036', + "IS1", '\037', + "US", '\037', + "space", ' ', + "exclamation-mark", '!', + "quotation-mark", '"', + "number-sign", '#', + "dollar-sign", '$', + "percent-sign", '%', + "ampersand", '&', + "apostrophe", '\'', + "left-parenthesis", '(', + "right-parenthesis", ')', + "asterisk", '*', + "plus-sign", '+', + "comma", ',', + "hyphen", '-', + "hyphen-minus", '-', + "period", '.', + "full-stop", '.', + "slash", '/', + "solidus", '/', + "zero", '0', + "one", '1', + "two", '2', + "three", '3', + "four", '4', + "five", '5', + "six", '6', + "seven", '7', + "eight", '8', + "nine", '9', + "colon", ':', + "semicolon", ';', + "less-than-sign", '<', + "equals-sign", '=', + "greater-than-sign", '>', + "question-mark", '?', + "commercial-at", '@', + "left-square-bracket", '[', + "backslash", '\\', + "reverse-solidus", '\\', + "right-square-bracket", ']', + "circumflex", '^', + "circumflex-accent", '^', + "underscore", '_', + "low-line", '_', + "grave-accent", '`', + "left-brace", '{', + "left-curly-bracket", '{', + "vertical-line", '|', + "right-brace", '}', + "right-curly-bracket", '}', + "tilde", '~', + "DEL", '\177', + NULL, 0, +}; diff --git a/src/backend/port/win32/regex/engine.c b/src/backend/port/win32/regex/engine.c new file mode 100644 index 00000000000..02c841afa46 --- /dev/null +++ b/src/backend/port/win32/regex/engine.c @@ -0,0 +1,1091 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)engine.c 8.5 (Berkeley) 3/20/94 + */ + +/* + * The matching engine and friends. This file is #included by regexec.c + * after suitable #defines of a variety of macros used herein, so that + * different state representations can be used without duplicating masses + * of code. + */ + +#ifdef SNAMES +#define matcher smatcher +#define fast sfast +#define slow sslow +#define dissect sdissect +#define backref sbackref +#define step sstep +#define print sprint +#define at sat +#define match smat +#endif +#ifdef LNAMES +#define matcher lmatcher +#define fast lfast +#define slow lslow +#define dissect ldissect +#define backref lbackref +#define step lstep +#define print lprint +#define at lat +#define match lmat +#endif + +/* another structure passed up and down to avoid zillions of parameters */ +struct match { + struct re_guts *g; + int eflags; + regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ + char *offp; /* offsets work from here */ + char *beginp; /* start of string -- virtual NUL precedes */ + char *endp; /* end of string -- virtual NUL here */ + char *coldp; /* can be no match starting before here */ + char **lastpos; /* [nplus+1] */ + STATEVARS; + states st; /* current states */ + states fresh; /* states for a fresh start */ + states tmp; /* temporary */ + states empty; /* empty set of states */ +}; + +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === engine.c === */ +static int matcher __P((struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags)); +static char *dissect __P((struct match *m, char *start, char *stop, sopno startst, sopno stopst)); +static char *backref __P((struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev)); +static char *fast __P((struct match *m, char *start, char *stop, sopno startst, sopno stopst)); +static char *slow __P((struct match *m, char *start, char *stop, sopno startst, sopno stopst)); +static states step __P((struct re_guts *g, sopno start, sopno stop, states bef, int ch, states aft)); +#define BOL (OUT+1) +#define EOL (BOL+1) +#define BOLEOL (BOL+2) +#define NOTHING (BOL+3) +#define BOW (BOL+4) +#define EOW (BOL+5) +#define CODEMAX (BOL+5) /* highest code used */ +#define NONCHAR(c) ((c) > CHAR_MAX) +#define NNONCHAR (CODEMAX-CHAR_MAX) +#ifdef REDEBUG +static void print __P((struct match *m, char *caption, states st, int ch, FILE *d)); +#endif +#ifdef REDEBUG +static void at __P((struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst)); +#endif +#ifdef REDEBUG +static char *pchar __P((int ch)); +#endif + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ + +#ifdef REDEBUG +#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 NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); } +#else +#define SP(t, s, c) /* nothing */ +#define AT(t, p1, p2, s1, s2) /* nothing */ +#define NOTE(s) /* nothing */ +#endif + +/* + - matcher - the actual matching engine + == static int matcher(register struct re_guts *g, char *string, \ + == size_t nmatch, regmatch_t pmatch[], int eflags); + */ +static int /* 0 success, REG_NOMATCH failure */ +matcher(g, string, nmatch, pmatch, eflags) +register struct re_guts *g; +char *string; +size_t nmatch; +regmatch_t pmatch[]; +int eflags; +{ + register char *endp; + register int i; + struct match mv; + register struct match *m = &mv; + register char *dp; + const register sopno gf = g->firststate+1; /* +1 for OEND */ + const register sopno gl = g->laststate; + char *start; + char *stop; + + /* simplify the situation where possible */ + if (g->cflags®_NOSUB) + nmatch = 0; + if (eflags®_STARTEND) { + start = string + pmatch[0].rm_so; + stop = string + pmatch[0].rm_eo; + } else { + start = string; + stop = start + strlen(start); + } + if (stop < start) + return(REG_INVARG); + + /* prescreening; this does wonders for this rather slow code */ + if (g->must != NULL) { + for (dp = start; dp < stop; dp++) + if (*dp == g->must[0] && stop - dp >= g->mlen && + memcmp(dp, g->must, (size_t)g->mlen) == 0) + break; + if (dp == stop) /* we didn't find g->must */ + return(REG_NOMATCH); + } + + /* match struct setup */ + m->g = g; + m->eflags = eflags; + m->pmatch = NULL; + m->lastpos = NULL; + m->offp = string; + m->beginp = start; + m->endp = stop; + STATESETUP(m, 4); + SETUP(m->st); + SETUP(m->fresh); + SETUP(m->tmp); + SETUP(m->empty); + CLEAR(m->empty); + + /* this loop does only one repetition except for backrefs */ + for (;;) { + endp = fast(m, start, stop, gf, gl); + if (endp == NULL) { /* a miss */ + STATETEARDOWN(m); + return(REG_NOMATCH); + } + if (nmatch == 0 && !g->backrefs) + break; /* no further info needed */ + + /* where? */ + assert(m->coldp != NULL); + for (;;) { + NOTE("finding start"); + endp = slow(m, m->coldp, stop, gf, gl); + if (endp != NULL) + break; + assert(m->coldp < m->endp); + m->coldp++; + } + if (nmatch == 1 && !g->backrefs) + break; /* no further info needed */ + + /* oh my, he wants the subexpressions... */ + if (m->pmatch == NULL) + m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * + sizeof(regmatch_t)); + if (m->pmatch == NULL) { + STATETEARDOWN(m); + return(REG_ESPACE); + } + for (i = 1; i <= m->g->nsub; i++) + m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1; + if (!g->backrefs && !(m->eflags®_BACKR)) { + NOTE("dissecting"); + dp = dissect(m, m->coldp, endp, gf, gl); + } else { + if (g->nplus > 0 && m->lastpos == NULL) + m->lastpos = (char **)malloc((g->nplus+1) * + sizeof(char *)); + if (g->nplus > 0 && m->lastpos == NULL) { + free(m->pmatch); + STATETEARDOWN(m); + return(REG_ESPACE); + } + NOTE("backref dissect"); + dp = backref(m, m->coldp, endp, gf, gl, (sopno)0); + } + if (dp != NULL) + break; + + /* uh-oh... we couldn't find a subexpression-level match */ + assert(g->backrefs); /* must be back references doing it */ + assert(g->nplus == 0 || m->lastpos != NULL); + for (;;) { + if (dp != NULL || endp <= m->coldp) + break; /* defeat */ + NOTE("backoff"); + endp = slow(m, m->coldp, endp-1, gf, gl); + if (endp == NULL) + break; /* defeat */ + /* try it on a shorter possibility */ +#ifndef NDEBUG + for (i = 1; i <= m->g->nsub; i++) { + assert(m->pmatch[i].rm_so == -1); + assert(m->pmatch[i].rm_eo == -1); + } +#endif + NOTE("backoff dissect"); + dp = backref(m, m->coldp, endp, gf, gl, (sopno)0); + } + assert(dp == NULL || dp == endp); + if (dp != NULL) /* found a shorter one */ + break; + + /* despite initial appearances, there is no match here */ + NOTE("false alarm"); + start = m->coldp + 1; /* recycle starting later */ + assert(start <= stop); + } + + /* fill in the details if requested */ + if (nmatch > 0) { + pmatch[0].rm_so = m->coldp - m->offp; + pmatch[0].rm_eo = endp - m->offp; + } + if (nmatch > 1) { + assert(m->pmatch != NULL); + for (i = 1; i < nmatch; i++) + if (i <= m->g->nsub) + pmatch[i] = m->pmatch[i]; + else { + pmatch[i].rm_so = -1; + pmatch[i].rm_eo = -1; + } + } + + if (m->pmatch != NULL) + free((char *)m->pmatch); + if (m->lastpos != NULL) + free((char *)m->lastpos); + STATETEARDOWN(m); + return(0); +} + +/* + - dissect - figure out what matched what, no back references + == static char *dissect(register struct match *m, char *start, \ + == char *stop, sopno startst, sopno stopst); + */ +static char * /* == stop (success) always */ +dissect(m, start, stop, startst, stopst) +register struct match *m; +char *start; +char *stop; +sopno startst; +sopno stopst; +{ + register int i; + register sopno ss; /* start sop of current subRE */ + register sopno es; /* end sop of current subRE */ + register char *sp; /* start of string matched by it */ + register char *stp; /* string matched by it cannot pass here */ + register char *rest; /* start of rest of string */ + register char *tail; /* string unmatched by rest of RE */ + register sopno ssub; /* start sop of subsubRE */ + register sopno esub; /* end sop of subsubRE */ + register char *ssp; /* start of string matched by subsubRE */ + register char *sep; /* end of string matched by subsubRE */ + register char *oldssp; /* previous ssp */ + register char *dp; + + AT("diss", start, stop, startst, stopst); + sp = start; + for (ss = startst; ss < stopst; ss = es) { + /* identify end of subRE */ + es = ss; + switch (OP(m->g->strip[es])) { + case OPLUS_: + case OQUEST_: + es += OPND(m->g->strip[es]); + break; + case OCH_: + while (OP(m->g->strip[es]) != O_CH) + es += OPND(m->g->strip[es]); + break; + } + es++; + + /* figure out what it matched */ + switch (OP(m->g->strip[ss])) { + case OEND: + assert(nope); + break; + case OCHAR: + sp++; + break; + case OBOL: + case OEOL: + case OBOW: + case OEOW: + break; + case OANY: + case OANYOF: + sp++; + break; + case OBACK_: + case O_BACK: + assert(nope); + break; + /* cases where length of match is hard to find */ + case OQUEST_: + stp = stop; + for (;;) { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = es - 1; + /* did innards match? */ + if (slow(m, sp, rest, ssub, esub) != NULL) { + dp = dissect(m, sp, rest, ssub, esub); + assert(dp == rest); + } else /* no */ + assert(sp == rest); + sp = rest; + break; + case OPLUS_: + stp = stop; + for (;;) { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = es - 1; + ssp = sp; + oldssp = ssp; + for (;;) { /* find last match of innards */ + sep = slow(m, ssp, rest, ssub, esub); + if (sep == NULL || sep == ssp) + break; /* failed or matched null */ + oldssp = ssp; /* on to next try */ + ssp = sep; + } + if (sep == NULL) { + /* last successful match */ + sep = ssp; + ssp = oldssp; + } + assert(sep == rest); /* must exhaust substring */ + assert(slow(m, ssp, sep, ssub, esub) == rest); + dp = dissect(m, ssp, sep, ssub, esub); + assert(dp == sep); + sp = rest; + break; + case OCH_: + stp = stop; + for (;;) { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = ss + OPND(m->g->strip[ss]) - 1; + assert(OP(m->g->strip[esub]) == OOR1); + for (;;) { /* find first matching branch */ + if (slow(m, sp, rest, ssub, esub) == rest) + break; /* it matched all of it */ + /* that one missed, try next one */ + assert(OP(m->g->strip[esub]) == OOR1); + esub++; + assert(OP(m->g->strip[esub]) == OOR2); + ssub = esub + 1; + esub += OPND(m->g->strip[esub]); + if (OP(m->g->strip[esub]) == OOR2) + esub--; + else + assert(OP(m->g->strip[esub]) == O_CH); + } + dp = dissect(m, sp, rest, ssub, esub); + assert(dp == rest); + sp = rest; + break; + case O_PLUS: + case O_QUEST: + case OOR1: + case OOR2: + case O_CH: + assert(nope); + break; + case OLPAREN: + i = OPND(m->g->strip[ss]); + assert(0 < i && i <= m->g->nsub); + m->pmatch[i].rm_so = sp - m->offp; + break; + case ORPAREN: + i = OPND(m->g->strip[ss]); + assert(0 < i && i <= m->g->nsub); + m->pmatch[i].rm_eo = sp - m->offp; + break; + default: /* uh oh */ + assert(nope); + break; + } + } + + assert(sp == stop); + return(sp); +} + +/* + - backref - figure out what matched what, figuring in back references + == static char *backref(register struct match *m, char *start, \ + == char *stop, sopno startst, sopno stopst, sopno lev); + */ +static char * /* == stop (success) or NULL (failure) */ +backref(m, start, stop, startst, stopst, lev) +register struct match *m; +char *start; +char *stop; +sopno startst; +sopno stopst; +sopno lev; /* PLUS nesting level */ +{ + register int i; + register sopno ss; /* start sop of current subRE */ + register char *sp; /* start of string matched by it */ + register sopno ssub; /* start sop of subsubRE */ + register sopno esub; /* end sop of subsubRE */ + register char *ssp; /* start of string matched by subsubRE */ + register char *dp; + register size_t len; + register int hard; + register sop s; + register regoff_t offsave; + register cset *cs; + + AT("back", start, stop, startst, stopst); + sp = start; + + /* get as far as we can with easy stuff */ + hard = 0; + for (ss = startst; !hard && ss < stopst; ss++) + switch (OP(s = m->g->strip[ss])) { + case OCHAR: + if (sp == stop || *sp++ != (char)OPND(s)) + return(NULL); + break; + case OANY: + if (sp == stop) + return(NULL); + sp++; + break; + case OANYOF: + cs = &m->g->sets[OPND(s)]; + if (sp == stop || !CHIN(cs, *sp++)) + return(NULL); + break; + case OBOL: + if ( (sp == m->beginp && !(m->eflags®_NOTBOL)) || + (sp < m->endp && *(sp-1) == '\n' && + (m->g->cflags®_NEWLINE)) ) + { /* yes */ } + else + return(NULL); + break; + case OEOL: + if ( (sp == m->endp && !(m->eflags®_NOTEOL)) || + (sp < m->endp && *sp == '\n' && + (m->g->cflags®_NEWLINE)) ) + { /* yes */ } + else + return(NULL); + break; + case OBOW: + if (( (sp == m->beginp && !(m->eflags®_NOTBOL)) || + (sp < m->endp && *(sp-1) == '\n' && + (m->g->cflags®_NEWLINE)) || + (sp > m->beginp && + !ISWORD(*(sp-1))) ) && + (sp < m->endp && ISWORD(*sp)) ) + { /* yes */ } + else + return(NULL); + break; + case OEOW: + if (( (sp == m->endp && !(m->eflags®_NOTEOL)) || + (sp < m->endp && *sp == '\n' && + (m->g->cflags®_NEWLINE)) || + (sp < m->endp && !ISWORD(*sp)) ) && + (sp > m->beginp && ISWORD(*(sp-1))) ) + { /* yes */ } + else + return(NULL); + break; + case O_QUEST: + break; + case OOR1: /* matches null but needs to skip */ + ss++; + s = m->g->strip[ss]; + do { + assert(OP(s) == OOR2); + ss += OPND(s); + } while (OP(s = m->g->strip[ss]) != O_CH); + /* note that the ss++ gets us past the O_CH */ + break; + default: /* have to make a choice */ + hard = 1; + break; + } + if (!hard) { /* that was it! */ + if (sp != stop) + return(NULL); + return(sp); + } + ss--; /* adjust for the for's final increment */ + + /* the hard stuff */ + AT("hard", sp, stop, ss, stopst); + s = m->g->strip[ss]; + switch (OP(s)) { + case OBACK_: /* the vilest depths */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + if (m->pmatch[i].rm_eo == -1) + return(NULL); + assert(m->pmatch[i].rm_so != -1); + len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; + assert(stop - m->beginp >= len); + if (sp > stop - len) + return(NULL); /* not enough left to match */ + ssp = m->offp + m->pmatch[i].rm_so; + if (memcmp(sp, ssp, len) != 0) + return(NULL); + while (m->g->strip[ss] != SOP(O_BACK, i)) + ss++; + return(backref(m, sp+len, stop, ss+1, stopst, lev)); + break; + case OQUEST_: /* to null or not */ + dp = backref(m, sp, stop, ss+1, stopst, lev); + if (dp != NULL) + return(dp); /* not */ + return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev)); + break; + case OPLUS_: + assert(m->lastpos != NULL); + assert(lev+1 <= m->g->nplus); + m->lastpos[lev+1] = sp; + return(backref(m, sp, stop, ss+1, stopst, lev+1)); + break; + case O_PLUS: + if (sp == m->lastpos[lev]) /* last pass matched null */ + return(backref(m, sp, stop, ss+1, stopst, lev-1)); + /* try another pass */ + m->lastpos[lev] = sp; + dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev); + if (dp == NULL) + return(backref(m, sp, stop, ss+1, stopst, lev-1)); + else + return(dp); + break; + case OCH_: /* find the right one, if any */ + ssub = ss + 1; + esub = ss + OPND(s) - 1; + assert(OP(m->g->strip[esub]) == OOR1); + for (;;) { /* find first matching branch */ + dp = backref(m, sp, stop, ssub, esub, lev); + if (dp != NULL) + return(dp); + /* that one missed, try next one */ + if (OP(m->g->strip[esub]) == O_CH) + return(NULL); /* there is none */ + esub++; + assert(OP(m->g->strip[esub]) == OOR2); + ssub = esub + 1; + esub += OPND(m->g->strip[esub]); + if (OP(m->g->strip[esub]) == OOR2) + esub--; + else + assert(OP(m->g->strip[esub]) == O_CH); + } + break; + case OLPAREN: /* must undo assignment if rest fails */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + offsave = m->pmatch[i].rm_so; + m->pmatch[i].rm_so = sp - m->offp; + dp = backref(m, sp, stop, ss+1, stopst, lev); + if (dp != NULL) + return(dp); + m->pmatch[i].rm_so = offsave; + return(NULL); + break; + case ORPAREN: /* must undo assignment if rest fails */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + offsave = m->pmatch[i].rm_eo; + m->pmatch[i].rm_eo = sp - m->offp; + dp = backref(m, sp, stop, ss+1, stopst, lev); + if (dp != NULL) + return(dp); + m->pmatch[i].rm_eo = offsave; + return(NULL); + break; + default: /* uh oh */ + assert(nope); + break; + } + + /* "can't happen" */ + assert(nope); + /* NOTREACHED */ +} + +/* + - fast - step through the string at top speed + == static char *fast(register struct match *m, char *start, \ + == char *stop, sopno startst, sopno stopst); + */ +static char * /* where tentative match ended, or NULL */ +fast(m, start, stop, startst, stopst) +register struct match *m; +char *start; +char *stop; +sopno startst; +sopno stopst; +{ + register states st = m->st; + register states fresh = m->fresh; + register states tmp = m->tmp; + register char *p = start; + register int c = (start == m->beginp) ? OUT : *(start-1); + register int lastc; /* previous c */ + register int flagch; + register int i; + register char *coldp; /* last p after which no match was underway */ + + CLEAR(st); + SET1(st, startst); + st = step(m->g, startst, stopst, st, NOTHING, st); + ASSIGN(fresh, st); + SP("start", st, *p); + coldp = NULL; + for (;;) { + /* next character */ + lastc = c; + c = (p == m->endp) ? OUT : *p; + if (EQ(st, fresh)) + coldp = p; + + /* is there an EOL and/or BOL between lastc and c? */ + flagch = '\0'; + i = 0; + if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || + (lastc == OUT && !(m->eflags®_NOTBOL)) ) { + flagch = BOL; + i = m->g->nbol; + } + if ( (c == '\n' && m->g->cflags®_NEWLINE) || + (c == OUT && !(m->eflags®_NOTEOL)) ) { + flagch = (flagch == BOL) ? BOLEOL : EOL; + i += m->g->neol; + } + if (i != 0) { + for (; i > 0; i--) + st = step(m->g, startst, stopst, st, flagch, st); + SP("boleol", st, c); + } + + /* how about a word boundary? */ + if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) && + (c != OUT && ISWORD(c)) ) { + flagch = BOW; + } + if ( (lastc != OUT && ISWORD(lastc)) && + (flagch == EOL || (c != OUT && !ISWORD(c))) ) { + flagch = EOW; + } + if (flagch == BOW || flagch == EOW) { + st = step(m->g, startst, stopst, st, flagch, st); + SP("boweow", st, c); + } + + /* are we done? */ + if (ISSET(st, stopst) || p == stop) + break; /* NOTE BREAK OUT */ + + /* no, we must deal with this character */ + ASSIGN(tmp, st); + ASSIGN(st, fresh); + assert(c != OUT); + st = step(m->g, startst, stopst, tmp, c, st); + SP("aft", st, c); + assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); + p++; + } + + assert(coldp != NULL); + m->coldp = coldp; + if (ISSET(st, stopst)) + return(p+1); + else + return(NULL); +} + +/* + - slow - step through the string more deliberately + == static char *slow(register struct match *m, char *start, \ + == char *stop, sopno startst, sopno stopst); + */ +static char * /* where it ended */ +slow(m, start, stop, startst, stopst) +register struct match *m; +char *start; +char *stop; +sopno startst; +sopno stopst; +{ + register states st = m->st; + register states empty = m->empty; + register states tmp = m->tmp; + register char *p = start; + register int c = (start == m->beginp) ? OUT : *(start-1); + register int lastc; /* previous c */ + register int flagch; + register int i; + register char *matchp; /* last p at which a match ended */ + + AT("slow", start, stop, startst, stopst); + CLEAR(st); + SET1(st, startst); + SP("sstart", st, *p); + st = step(m->g, startst, stopst, st, NOTHING, st); + matchp = NULL; + for (;;) { + /* next character */ + lastc = c; + c = (p == m->endp) ? OUT : *p; + + /* is there an EOL and/or BOL between lastc and c? */ + flagch = '\0'; + i = 0; + if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || + (lastc == OUT && !(m->eflags®_NOTBOL)) ) { + flagch = BOL; + i = m->g->nbol; + } + if ( (c == '\n' && m->g->cflags®_NEWLINE) || + (c == OUT && !(m->eflags®_NOTEOL)) ) { + flagch = (flagch == BOL) ? BOLEOL : EOL; + i += m->g->neol; + } + if (i != 0) { + for (; i > 0; i--) + st = step(m->g, startst, stopst, st, flagch, st); + SP("sboleol", st, c); + } + + /* how about a word boundary? */ + if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) && + (c != OUT && ISWORD(c)) ) { + flagch = BOW; + } + if ( (lastc != OUT && ISWORD(lastc)) && + (flagch == EOL || (c != OUT && !ISWORD(c))) ) { + flagch = EOW; + } + if (flagch == BOW || flagch == EOW) { + st = step(m->g, startst, stopst, st, flagch, st); + SP("sboweow", st, c); + } + + /* are we done? */ + if (ISSET(st, stopst)) + matchp = p; + if (EQ(st, empty) || p == stop) + break; /* NOTE BREAK OUT */ + + /* no, we must deal with this character */ + ASSIGN(tmp, st); + ASSIGN(st, empty); + assert(c != OUT); + st = step(m->g, startst, stopst, tmp, c, st); + SP("saft", st, c); + assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); + p++; + } + + return(matchp); +} + + +/* + - step - map set of states reachable before char to set reachable after + == static states step(register struct re_guts *g, sopno start, sopno stop, \ + == register states bef, int ch, register states aft); + == #define BOL (OUT+1) + == #define EOL (BOL+1) + == #define BOLEOL (BOL+2) + == #define NOTHING (BOL+3) + == #define BOW (BOL+4) + == #define EOW (BOL+5) + == #define CODEMAX (BOL+5) // highest code used + == #define NONCHAR(c) ((c) > CHAR_MAX) + == #define NNONCHAR (CODEMAX-CHAR_MAX) + */ +static states +step(g, start, stop, bef, ch, aft) +register struct re_guts *g; +sopno start; /* start state within strip */ +sopno stop; /* state after stop state within strip */ +register states bef; /* states reachable before */ +int ch; /* character or NONCHAR code */ +register states aft; /* states already known reachable after */ +{ + register cset *cs; + register sop s; + register sopno pc; + register onestate here; /* note, macros know this name */ + register sopno look; + register int i; + + for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) { + s = g->strip[pc]; + switch (OP(s)) { + case OEND: + assert(pc == stop-1); + break; + case OCHAR: + /* only characters can match */ + assert(!NONCHAR(ch) || ch != (char)OPND(s)); + if (ch == (char)OPND(s)) + FWD(aft, bef, 1); + break; + case OBOL: + if (ch == BOL || ch == BOLEOL) + FWD(aft, bef, 1); + break; + case OEOL: + if (ch == EOL || ch == BOLEOL) + FWD(aft, bef, 1); + break; + case OBOW: + if (ch == BOW) + FWD(aft, bef, 1); + break; + case OEOW: + if (ch == EOW) + FWD(aft, bef, 1); + break; + case OANY: + if (!NONCHAR(ch)) + FWD(aft, bef, 1); + break; + case OANYOF: + cs = &g->sets[OPND(s)]; + if (!NONCHAR(ch) && CHIN(cs, ch)) + FWD(aft, bef, 1); + break; + case OBACK_: /* ignored here */ + case O_BACK: + FWD(aft, aft, 1); + break; + case OPLUS_: /* forward, this is just an empty */ + FWD(aft, aft, 1); + break; + case O_PLUS: /* both forward and back */ + FWD(aft, aft, 1); + i = ISSETBACK(aft, OPND(s)); + BACK(aft, aft, OPND(s)); + if (!i && ISSETBACK(aft, OPND(s))) { + /* oho, must reconsider loop body */ + pc -= OPND(s) + 1; + INIT(here, pc); + } + break; + case OQUEST_: /* two branches, both forward */ + FWD(aft, aft, 1); + FWD(aft, aft, OPND(s)); + break; + case O_QUEST: /* just an empty */ + FWD(aft, aft, 1); + break; + case OLPAREN: /* not significant here */ + case ORPAREN: + FWD(aft, aft, 1); + break; + case OCH_: /* mark the first two branches */ + FWD(aft, aft, 1); + assert(OP(g->strip[pc+OPND(s)]) == OOR2); + FWD(aft, aft, OPND(s)); + break; + case OOR1: /* done a branch, find the O_CH */ + if (ISSTATEIN(aft, here)) { + for (look = 1; + OP(s = g->strip[pc+look]) != O_CH; + look += OPND(s)) + assert(OP(s) == OOR2); + FWD(aft, aft, look); + } + break; + case OOR2: /* propagate OCH_'s marking */ + FWD(aft, aft, 1); + if (OP(g->strip[pc+OPND(s)]) != O_CH) { + assert(OP(g->strip[pc+OPND(s)]) == OOR2); + FWD(aft, aft, OPND(s)); + } + break; + case O_CH: /* just empty */ + FWD(aft, aft, 1); + break; + default: /* ooooops... */ + assert(nope); + break; + } + } + + return(aft); +} + +#ifdef REDEBUG +/* + - print - print a set of states + == #ifdef REDEBUG + == static void print(struct match *m, char *caption, states st, \ + == int ch, FILE *d); + == #endif + */ +static void +print(m, caption, st, ch, d) +struct match *m; +char *caption; +states st; +int ch; +FILE *d; +{ + register struct re_guts *g = m->g; + register int i; + register int first = 1; + + if (!(m->eflags®_TRACE)) + return; + + fprintf(d, "%s", caption); + if (ch != '\0') + fprintf(d, " %s", pchar(ch)); + for (i = 0; i < g->nstates; i++) + if (ISSET(st, i)) { + fprintf(d, "%s%d", (first) ? "\t" : ", ", i); + first = 0; + } + fprintf(d, "\n"); +} + +/* + - at - print current situation + == #ifdef REDEBUG + == static void at(struct match *m, char *title, char *start, char *stop, \ + == sopno startst, sopno stopst); + == #endif + */ +static void +at(m, title, start, stop, startst, stopst) +struct match *m; +char *title; +char *start; +char *stop; +sopno startst; +sopno stopst; +{ + if (!(m->eflags®_TRACE)) + return; + + printf("%s %s-", title, pchar(*start)); + printf("%s ", pchar(*stop)); + printf("%ld-%ld\n", (long)startst, (long)stopst); +} + +#ifndef PCHARDONE +#define PCHARDONE /* never again */ +/* + - pchar - make a character printable + == #ifdef REDEBUG + == static char *pchar(int ch); + == #endif + * + * Is this identical to regchar() over in debug.c? Well, yes. But a + * duplicate here avoids having a debugging-capable regexec.o tied to + * a matching debug.o, and this is convenient. It all disappears in + * the non-debug compilation anyway, so it doesn't matter much. + */ +static char * /* -> representation */ +pchar(ch) +int ch; +{ + static char pbuf[10]; + + if (isprint(ch) || ch == ' ') + sprintf(pbuf, "%c", ch); + else + sprintf(pbuf, "\\%o", ch); + return(pbuf); +} +#endif +#endif + +#undef matcher +#undef fast +#undef slow +#undef dissect +#undef backref +#undef step +#undef print +#undef at +#undef match diff --git a/src/backend/port/win32/regex/re_format.7 b/src/backend/port/win32/regex/re_format.7 new file mode 100644 index 00000000000..db2f6349c45 --- /dev/null +++ b/src/backend/port/win32/regex/re_format.7 @@ -0,0 +1,269 @@ +.\" Copyright (c) 1992, 1993, 1994 Henry Spencer. +.\" Copyright (c) 1992, 1993, 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Henry Spencer. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94 +.\" +.TH RE_FORMAT 7 "March 20, 1994" +.SH NAME +re_format \- POSIX 1003.2 regular expressions +.SH DESCRIPTION +Regular expressions (``RE''s), +as defined in POSIX 1003.2, come in two forms: +modern REs (roughly those of +.IR egrep ; +1003.2 calls these ``extended'' REs) +and obsolete REs (roughly those of +.IR ed ; +1003.2 ``basic'' REs). +Obsolete REs mostly exist for backward compatibility in some old programs; +they will be discussed at the end. +1003.2 leaves some aspects of RE syntax and semantics open; +`\(dg' marks decisions on these aspects that +may not be fully portable to other 1003.2 implementations. +.PP +A (modern) RE is one\(dg or more non-empty\(dg \fIbranches\fR, +separated by `|'. +It matches anything that matches one of the branches. +.PP +A branch is one\(dg or more \fIpieces\fR, concatenated. +It matches a match for the first, followed by a match for the second, etc. +.PP +A piece is an \fIatom\fR possibly followed +by a single\(dg `*', `+', `?', or \fIbound\fR. +An atom followed by `*' matches a sequence of 0 or more matches of the atom. +An atom followed by `+' matches a sequence of 1 or more matches of the atom. +An atom followed by `?' matches a sequence of 0 or 1 matches of the atom. +.PP +A \fIbound\fR is `{' followed by an unsigned decimal integer, +possibly followed by `,' +possibly followed by another unsigned decimal integer, +always followed by `}'. +The integers must lie between 0 and RE_DUP_MAX (255\(dg) inclusive, +and if there are two of them, the first may not exceed the second. +An atom followed by a bound containing one integer \fIi\fR +and no comma matches +a sequence of exactly \fIi\fR matches of the atom. +An atom followed by a bound +containing one integer \fIi\fR and a comma matches +a sequence of \fIi\fR or more matches of the atom. +An atom followed by a bound +containing two integers \fIi\fR and \fIj\fR matches +a sequence of \fIi\fR through \fIj\fR (inclusive) matches of the atom. +.PP +An atom is a regular expression enclosed in `()' (matching a match for the +regular expression), +an empty set of `()' (matching the null string)\(dg, +a \fIbracket expression\fR (see below), `.' +(matching any single character), `^' (matching the null string at the +beginning of a line), `$' (matching the null string at the +end of a line), a `\e' followed by one of the characters +`^.[$()|*+?{\e' +(matching that character taken as an ordinary character), +a `\e' followed by any other character\(dg +(matching that character taken as an ordinary character, +as if the `\e' had not been present\(dg), +or a single character with no other significance (matching that character). +A `{' followed by a character other than a digit is an ordinary +character, not the beginning of a bound\(dg. +It is illegal to end an RE with `\e'. +.PP +A \fIbracket expression\fR is a list of characters enclosed in `[]'. +It normally matches any single character from the list (but see below). +If the list begins with `^', +it matches any single character +(but see below) \fInot\fR from the rest of the list. +If two characters in the list are separated by `\-', this is shorthand +for the full \fIrange\fR of characters between those two (inclusive) in the +collating sequence, +e.g. `[0-9]' in ASCII matches any decimal digit. +It is illegal\(dg for two ranges to share an +endpoint, e.g. `a-c-e'. +Ranges are very collating-sequence-dependent, +and portable programs should avoid relying on them. +.PP +To include a literal `]' in the list, make it the first character +(following a possible `^'). +To include a literal `\-', make it the first or last character, +or the second endpoint of a range. +To use a literal `\-' as the first endpoint of a range, +enclose it in `[.' and `.]' to make it a collating element (see below). +With the exception of these and some combinations using `[' (see next +paragraphs), all other special characters, including `\e', lose their +special significance within a bracket expression. +.PP +Within a bracket expression, a collating element (a character, +a multi-character sequence that collates as if it were a single character, +or a collating-sequence name for either) +enclosed in `[.' and `.]' stands for the +sequence of characters of that collating element. +The sequence is a single element of the bracket expression's list. +A bracket expression containing a multi-character collating element +can thus match more than one character, +e.g. if the collating sequence includes a `ch' collating element, +then the RE `[[.ch.]]*c' matches the first five characters +of `chchcc'. +.PP +Within a bracket expression, a collating element enclosed in `[=' and +`=]' is an equivalence class, standing for the sequences of characters +of all collating elements equivalent to that one, including itself. +(If there are no other equivalent collating elements, +the treatment is as if the enclosing delimiters were `[.' and `.]'.) +For example, if o and \o'o^' are the members of an equivalence class, +then `[[=o=]]', `[[=\o'o^'=]]', and `[o\o'o^']' are all synonymous. +An equivalence class may not\(dg be an endpoint +of a range. +.PP +Within a bracket expression, the name of a \fIcharacter class\fR enclosed +in `[:' and `:]' stands for the list of all characters belonging to that +class. +Standard character class names are: +.PP +.RS +.nf +.ta 3c 6c 9c +alnum digit punct +alpha graph space +blank lower upper +cntrl print xdigit +.fi +.RE +.PP +These stand for the character classes defined in +.IR ctype (3). +A locale may provide others. +A character class may not be used as an endpoint of a range. +.PP +There are two special cases\(dg of bracket expressions: +the bracket expressions `[[:<:]]' and `[[:>:]]' match the null string at +the beginning and end of a word respectively. +A word is defined as a sequence of +word characters +which is neither preceded nor followed by +word characters. +A word character is an +.I alnum +character (as defined by +.IR ctype (3)) +or an underscore. +This is an extension, +compatible with but not specified by POSIX 1003.2, +and should be used with +caution in software intended to be portable to other systems. +.PP +In the event that an RE could match more than one substring of a given +string, +the RE matches the one starting earliest in the string. +If the RE could match more than one substring starting at that point, +it matches the longest. +Subexpressions also match the longest possible substrings, subject to +the constraint that the whole match be as long as possible, +with subexpressions starting earlier in the RE taking priority over +ones starting later. +Note that higher-level subexpressions thus take priority over +their lower-level component subexpressions. +.PP +Match lengths are measured in characters, not collating elements. +A null string is considered longer than no match at all. +For example, +`bb*' matches the three middle characters of `abbbc', +`(wee|week)(knights|nights)' matches all ten characters of `weeknights', +when `(.*).*' is matched against `abc' the parenthesized subexpression +matches all three characters, and +when `(a*)*' is matched against `bc' both the whole RE and the parenthesized +subexpression match the null string. +.PP +If case-independent matching is specified, +the effect is much as if all case distinctions had vanished from the +alphabet. +When an alphabetic that exists in multiple cases appears as an +ordinary character outside a bracket expression, it is effectively +transformed into a bracket expression containing both cases, +e.g. `x' becomes `[xX]'. +When it appears inside a bracket expression, all case counterparts +of it are added to the bracket expression, so that (e.g.) `[x]' +becomes `[xX]' and `[^x]' becomes `[^xX]'. +.PP +No particular limit is imposed on the length of REs\(dg. +Programs intended to be portable should not employ REs longer +than 256 bytes, +as an implementation can refuse to accept such REs and remain +POSIX-compliant. +.PP +Obsolete (``basic'') regular expressions differ in several respects. +`|', `+', and `?' are ordinary characters and there is no equivalent +for their functionality. +The delimiters for bounds are `\e{' and `\e}', +with `{' and `}' by themselves ordinary characters. +The parentheses for nested subexpressions are `\e(' and `\e)', +with `(' and `)' by themselves ordinary characters. +`^' is an ordinary character except at the beginning of the +RE or\(dg the beginning of a parenthesized subexpression, +`$' is an ordinary character except at the end of the +RE or\(dg the end of a parenthesized subexpression, +and `*' is an ordinary character if it appears at the beginning of the +RE or the beginning of a parenthesized subexpression +(after a possible leading `^'). +Finally, there is one new type of atom, a \fIback reference\fR: +`\e' followed by a non-zero decimal digit \fId\fR +matches the same sequence of characters +matched by the \fId\fRth parenthesized subexpression +(numbering subexpressions by the positions of their opening parentheses, +left to right), +so that (e.g.) `\e([bc]\e)\e1' matches `bb' or `cc' but not `bc'. +.SH SEE ALSO +regex(3) +.PP +POSIX 1003.2, section 2.8 (Regular Expression Notation). +.SH BUGS +Having two kinds of REs is a botch. +.PP +The current 1003.2 spec says that `)' is an ordinary character in +the absence of an unmatched `('; +this was an unintentional result of a wording error, +and change is likely. +Avoid relying on it. +.PP +Back references are a dreadful botch, +posing major problems for efficient implementations. +They are also somewhat vaguely defined +(does +`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?). +Avoid using them. +.PP +1003.2's specification of case-independent matching is vague. +The ``one case implies all cases'' definition given above +is current consensus among implementors as to the right interpretation. +.PP +The syntax for word boundaries is incredibly ugly. diff --git a/src/backend/port/win32/regex/regcomp.c b/src/backend/port/win32/regex/regcomp.c new file mode 100644 index 00000000000..feb24ecced3 --- /dev/null +++ b/src/backend/port/win32/regex/regcomp.c @@ -0,0 +1,1698 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regcomp.c 8.5 (Berkeley) 3/20/94 + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> +#include <stdlib.h> +#include <regex.h> + +#include "utils.h" +#include "regex2.h" + +#include "cclass.h" +#include "cname.h" + +/* + * parse structure, passed up and down to avoid global variables and + * other clumsinesses + */ +struct parse { + char *next; /* next character in RE */ + char *end; /* end of string (-> NUL normally) */ + int error; /* has an error been seen? */ + sop *strip; /* malloced strip */ + sopno ssize; /* malloced strip size (allocated) */ + sopno slen; /* malloced strip length (used) */ + int ncsalloc; /* number of csets allocated */ + struct re_guts *g; +# define NPAREN 10 /* we need to remember () 1-9 for back refs */ + sopno pbegin[NPAREN]; /* -> ( ([0] unused) */ + sopno pend[NPAREN]; /* -> ) ([0] unused) */ +}; + +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === regcomp.c === */ +static void p_ere __P((struct parse *p, int stop)); +static void p_ere_exp __P((struct parse *p)); +static void p_str __P((struct parse *p)); +static void p_bre __P((struct parse *p, int end1, int end2)); +static int p_simp_re __P((struct parse *p, int starordinary)); +static int p_count __P((struct parse *p)); +static void p_bracket __P((struct parse *p)); +static void p_b_term __P((struct parse *p, cset *cs)); +static void p_b_cclass __P((struct parse *p, cset *cs)); +static void p_b_eclass __P((struct parse *p, cset *cs)); +static char p_b_symbol __P((struct parse *p)); +static char p_b_coll_elem __P((struct parse *p, int endc)); +static char othercase __P((int ch)); +static void bothcases __P((struct parse *p, int ch)); +static void ordinary __P((struct parse *p, int ch)); +static void nonnewline __P((struct parse *p)); +static void repeat __P((struct parse *p, sopno start, int from, int to)); +static int seterr __P((struct parse *p, int e)); +static cset *allocset __P((struct parse *p)); +static void freeset __P((struct parse *p, cset *cs)); +static int freezeset __P((struct parse *p, cset *cs)); +static int firstch __P((struct parse *p, cset *cs)); +static int nch __P((struct parse *p, cset *cs)); +static void mcadd __P((struct parse *p, cset *cs, char *cp)); +static void mcsub __P((cset *cs, char *cp)); +static int mcin __P((cset *cs, char *cp)); +static char *mcfind __P((cset *cs, char *cp)); +static void mcinvert __P((struct parse *p, cset *cs)); +static void mccase __P((struct parse *p, cset *cs)); +static int isinsets __P((struct re_guts *g, int c)); +static int samesets __P((struct re_guts *g, int c1, int c2)); +static void categorize __P((struct parse *p, struct re_guts *g)); +static sopno dupl __P((struct parse *p, sopno start, sopno finish)); +static void doemit __P((struct parse *p, sop op, size_t opnd)); +static void doinsert __P((struct parse *p, sop op, size_t opnd, sopno pos)); +static void dofwd __P((struct parse *p, sopno pos, sop value)); +static void enlarge __P((struct parse *p, sopno size)); +static void stripsnug __P((struct parse *p, struct re_guts *g)); +static void findmust __P((struct parse *p, struct re_guts *g)); +static sopno pluscount __P((struct parse *p, struct re_guts *g)); + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ + +static char nuls[10]; /* place to point scanner in event of error */ + +/* + * macros for use with parse structure + * BEWARE: these know that the parse structure is named `p' !!! + */ +#define PEEK() (*p->next) +#define PEEK2() (*(p->next+1)) +#define MORE() (p->next < p->end) +#define MORE2() (p->next+1 < p->end) +#define SEE(c) (MORE() && PEEK() == (c)) +#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b)) +#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0) +#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0) +#define NEXT() (p->next++) +#define NEXT2() (p->next += 2) +#define NEXTn(n) (p->next += (n)) +#define GETNEXT() (*p->next++) +#define SETERROR(e) seterr(p, (e)) +#define REQUIRE(co, e) ((co) || SETERROR(e)) +#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e)) +#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e)) +#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e)) +#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd)) +#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos) +#define AHEAD(pos) dofwd(p, pos, HERE()-(pos)) +#define ASTERN(sop, pos) EMIT(sop, HERE()-pos) +#define HERE() (p->slen) +#define THERE() (p->slen - 1) +#define THERETHERE() (p->slen - 2) +#define DROP(n) (p->slen -= (n)) + +#ifndef NDEBUG +static int never = 0; /* for use in asserts; shuts lint up */ +#else +#define never 0 /* some <assert.h>s have bugs too */ +#endif + +/* + - regcomp - interface for parser and compilation + = extern int regcomp(regex_t *, const char *, int); + = #define REG_BASIC 0000 + = #define REG_EXTENDED 0001 + = #define REG_ICASE 0002 + = #define REG_NOSUB 0004 + = #define REG_NEWLINE 0010 + = #define REG_NOSPEC 0020 + = #define REG_PEND 0040 + = #define REG_DUMP 0200 + */ +int /* 0 success, otherwise REG_something */ +regcomp(preg, pattern, cflags) +regex_t *preg; +const char *pattern; +int cflags; +{ + struct parse pa; + register struct re_guts *g; + register struct parse *p = &pa; + register int i; + register size_t len; +#ifdef REDEBUG +# define GOODFLAGS(f) (f) +#else +# define GOODFLAGS(f) ((f)&~REG_DUMP) +#endif + + cflags = GOODFLAGS(cflags); + if ((cflags®_EXTENDED) && (cflags®_NOSPEC)) + return(REG_INVARG); + + if (cflags®_PEND) { + if (preg->re_endp < pattern) + return(REG_INVARG); + len = preg->re_endp - pattern; + } else + len = strlen((char *)pattern); + + /* do the mallocs early so failure handling is easy */ + g = (struct re_guts *)malloc(sizeof(struct re_guts) + + (NC-1)*sizeof(cat_t)); + if (g == NULL) + return(REG_ESPACE); + p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */ + p->strip = (sop *)malloc(p->ssize * sizeof(sop)); + p->slen = 0; + if (p->strip == NULL) { + free((char *)g); + return(REG_ESPACE); + } + + /* set things up */ + p->g = g; + p->next = (char *)pattern; /* convenience; we do not modify it */ + p->end = p->next + len; + p->error = 0; + p->ncsalloc = 0; + for (i = 0; i < NPAREN; i++) { + p->pbegin[i] = 0; + p->pend[i] = 0; + } + g->csetsize = NC; + g->sets = NULL; + g->setbits = NULL; + g->ncsets = 0; + g->cflags = cflags; + g->iflags = 0; + g->nbol = 0; + g->neol = 0; + g->must = NULL; + g->mlen = 0; + g->nsub = 0; + g->ncategories = 1; /* category 0 is "everything else" */ + g->categories = &g->catspace[-(CHAR_MIN)]; + (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t)); + g->backrefs = 0; + + /* do it */ + EMIT(OEND, 0); + g->firststate = THERE(); + if (cflags®_EXTENDED) + p_ere(p, OUT); + else if (cflags®_NOSPEC) + p_str(p); + else + p_bre(p, OUT, OUT); + EMIT(OEND, 0); + g->laststate = THERE(); + + /* tidy up loose ends and fill things in */ + categorize(p, g); + stripsnug(p, g); + findmust(p, g); + g->nplus = pluscount(p, g); + g->magic = MAGIC2; + preg->re_nsub = g->nsub; + preg->re_g = g; + preg->re_magic = MAGIC1; +#ifndef REDEBUG + /* not debugging, so can't rely on the assert() in regexec() */ + if (g->iflags&BAD) + SETERROR(REG_ASSERT); +#endif + + /* win or lose, we're done */ + if (p->error != 0) /* lose */ + regfree(preg); + return(p->error); +} + +/* + - p_ere - ERE parser top level, concatenation and alternation + == static void p_ere(register struct parse *p, int stop); + */ +static void +p_ere(p, stop) +register struct parse *p; +int stop; /* character this ERE should end at */ +{ + register char c; + register sopno prevback; + register sopno prevfwd; + register sopno conc; + register int first = 1; /* is this the first alternative? */ + + for (;;) { + /* do a bunch of concatenated expressions */ + conc = HERE(); + while (MORE() && (c = PEEK()) != '|' && c != stop) + p_ere_exp(p); + REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */ + + if (!EAT('|')) + break; /* NOTE BREAK OUT */ + + if (first) { + INSERT(OCH_, conc); /* offset is wrong */ + prevfwd = conc; + prevback = conc; + first = 0; + } + ASTERN(OOR1, prevback); + prevback = THERE(); + AHEAD(prevfwd); /* fix previous offset */ + prevfwd = HERE(); + EMIT(OOR2, 0); /* offset is very wrong */ + } + + if (!first) { /* tail-end fixups */ + AHEAD(prevfwd); + ASTERN(O_CH, prevback); + } + + assert(!MORE() || SEE(stop)); +} + +/* + - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op + == static void p_ere_exp(register struct parse *p); + */ +static void +p_ere_exp(p) +register struct parse *p; +{ + register char c; + register sopno pos; + register int count; + register int count2; + register sopno subno; + int wascaret = 0; + + assert(MORE()); /* caller should have ensured this */ + c = GETNEXT(); + + pos = HERE(); + switch (c) { + case '(': + REQUIRE(MORE(), REG_EPAREN); + p->g->nsub++; + subno = p->g->nsub; + if (subno < NPAREN) + p->pbegin[subno] = HERE(); + EMIT(OLPAREN, subno); + if (!SEE(')')) + p_ere(p, ')'); + if (subno < NPAREN) { + p->pend[subno] = HERE(); + assert(p->pend[subno] != 0); + } + EMIT(ORPAREN, subno); + MUSTEAT(')', REG_EPAREN); + break; +#ifndef POSIX_MISTAKE + case ')': /* happens only if no current unmatched ( */ + /* + * You may ask, why the ifndef? Because I didn't notice + * this until slightly too late for 1003.2, and none of the + * other 1003.2 regular-expression reviewers noticed it at + * all. So an unmatched ) is legal POSIX, at least until + * we can get it fixed. + */ + SETERROR(REG_EPAREN); + break; +#endif + case '^': + EMIT(OBOL, 0); + p->g->iflags |= USEBOL; + p->g->nbol++; + wascaret = 1; + break; + case '$': + EMIT(OEOL, 0); + p->g->iflags |= USEEOL; + p->g->neol++; + break; + case '|': + SETERROR(REG_EMPTY); + break; + case '*': + case '+': + case '?': + SETERROR(REG_BADRPT); + break; + case '.': + if (p->g->cflags®_NEWLINE) + nonnewline(p); + else + EMIT(OANY, 0); + break; + case '[': + p_bracket(p); + break; + case '\\': + REQUIRE(MORE(), REG_EESCAPE); + c = GETNEXT(); + ordinary(p, c); + break; + case '{': /* okay as ordinary except if digit follows */ + REQUIRE(!MORE() || !isdigit(PEEK()), REG_BADRPT); + /* FALLTHROUGH */ + default: + ordinary(p, c); + break; + } + + if (!MORE()) + return; + c = PEEK(); + /* we call { a repetition if followed by a digit */ + if (!( c == '*' || c == '+' || c == '?' || + (c == '{' && MORE2() && isdigit(PEEK2())) )) + return; /* no repetition, we're done */ + NEXT(); + + REQUIRE(!wascaret, REG_BADRPT); + switch (c) { + case '*': /* implemented as +? */ + /* this case does not require the (y|) trick, noKLUDGE */ + INSERT(OPLUS_, pos); + ASTERN(O_PLUS, pos); + INSERT(OQUEST_, pos); + ASTERN(O_QUEST, pos); + break; + case '+': + INSERT(OPLUS_, pos); + ASTERN(O_PLUS, pos); + break; + case '?': + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, pos); /* offset slightly wrong */ + ASTERN(OOR1, pos); /* this one's right */ + AHEAD(pos); /* fix the OCH_ */ + EMIT(OOR2, 0); /* offset very wrong... */ + AHEAD(THERE()); /* ...so fix it */ + ASTERN(O_CH, THERETHERE()); + break; + case '{': + count = p_count(p); + if (EAT(',')) { + if (isdigit(PEEK())) { + count2 = p_count(p); + REQUIRE(count <= count2, REG_BADBR); + } else /* single number with comma */ + count2 = INFINITY; + } else /* just a single number */ + count2 = count; + repeat(p, pos, count, count2); + if (!EAT('}')) { /* error heuristics */ + while (MORE() && PEEK() != '}') + NEXT(); + REQUIRE(MORE(), REG_EBRACE); + SETERROR(REG_BADBR); + } + break; + } + + if (!MORE()) + return; + c = PEEK(); + if (!( c == '*' || c == '+' || c == '?' || + (c == '{' && MORE2() && isdigit(PEEK2())) ) ) + return; + SETERROR(REG_BADRPT); +} + +/* + - p_str - string (no metacharacters) "parser" + == static void p_str(register struct parse *p); + */ +static void +p_str(p) +register struct parse *p; +{ + REQUIRE(MORE(), REG_EMPTY); + while (MORE()) + ordinary(p, GETNEXT()); +} + +/* + - p_bre - BRE parser top level, anchoring and concatenation + == static void p_bre(register struct parse *p, register int end1, \ + == register int end2); + * Giving end1 as OUT essentially eliminates the end1/end2 check. + * + * This implementation is a bit of a kludge, in that a trailing $ is first + * taken as an ordinary character and then revised to be an anchor. The + * only undesirable side effect is that '$' gets included as a character + * category in such cases. This is fairly harmless; not worth fixing. + * The amount of lookahead needed to avoid this kludge is excessive. + */ +static void +p_bre(p, end1, end2) +register struct parse *p; +register int end1; /* first terminating character */ +register int end2; /* second terminating character */ +{ + register sopno start = HERE(); + register int first = 1; /* first subexpression? */ + register int wasdollar = 0; + + if (EAT('^')) { + EMIT(OBOL, 0); + p->g->iflags |= USEBOL; + p->g->nbol++; + } + while (MORE() && !SEETWO(end1, end2)) { + wasdollar = p_simp_re(p, first); + first = 0; + } + if (wasdollar) { /* oops, that was a trailing anchor */ + DROP(1); + EMIT(OEOL, 0); + p->g->iflags |= USEEOL; + p->g->neol++; + } + + REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */ +} + +/* + - p_simp_re - parse a simple RE, an atom possibly followed by a repetition + == static int p_simp_re(register struct parse *p, int starordinary); + */ +static int /* was the simple RE an unbackslashed $? */ +p_simp_re(p, starordinary) +register struct parse *p; +int starordinary; /* is a leading * an ordinary character? */ +{ + register int c; + register int count; + register int count2; + register sopno pos; + register int i; + register sopno subno; +# define BACKSL (1<<CHAR_BIT) + + pos = HERE(); /* repetion op, if any, covers from here */ + + assert(MORE()); /* caller should have ensured this */ + c = GETNEXT(); + if (c == '\\') { + REQUIRE(MORE(), REG_EESCAPE); + c = BACKSL | (unsigned char)GETNEXT(); + } + switch (c) { + case '.': + if (p->g->cflags®_NEWLINE) + nonnewline(p); + else + EMIT(OANY, 0); + break; + case '[': + p_bracket(p); + break; + case BACKSL|'{': + SETERROR(REG_BADRPT); + break; + case BACKSL|'(': + p->g->nsub++; + subno = p->g->nsub; + if (subno < NPAREN) + p->pbegin[subno] = HERE(); + EMIT(OLPAREN, subno); + /* the MORE here is an error heuristic */ + if (MORE() && !SEETWO('\\', ')')) + p_bre(p, '\\', ')'); + if (subno < NPAREN) { + p->pend[subno] = HERE(); + assert(p->pend[subno] != 0); + } + EMIT(ORPAREN, subno); + REQUIRE(EATTWO('\\', ')'), REG_EPAREN); + break; + case BACKSL|')': /* should not get here -- must be user */ + case BACKSL|'}': + SETERROR(REG_EPAREN); + break; + case BACKSL|'1': + case BACKSL|'2': + case BACKSL|'3': + case BACKSL|'4': + case BACKSL|'5': + case BACKSL|'6': + case BACKSL|'7': + case BACKSL|'8': + case BACKSL|'9': + i = (c&~BACKSL) - '0'; + assert(i < NPAREN); + if (p->pend[i] != 0) { + assert(i <= p->g->nsub); + EMIT(OBACK_, i); + assert(p->pbegin[i] != 0); + assert(OP(p->strip[p->pbegin[i]]) == OLPAREN); + assert(OP(p->strip[p->pend[i]]) == ORPAREN); + (void) dupl(p, p->pbegin[i]+1, p->pend[i]); + EMIT(O_BACK, i); + } else + SETERROR(REG_ESUBREG); + p->g->backrefs = 1; + break; + case '*': + REQUIRE(starordinary, REG_BADRPT); + /* FALLTHROUGH */ + default: + ordinary(p, c &~ BACKSL); + break; + } + + if (EAT('*')) { /* implemented as +? */ + /* this case does not require the (y|) trick, noKLUDGE */ + INSERT(OPLUS_, pos); + ASTERN(O_PLUS, pos); + INSERT(OQUEST_, pos); + ASTERN(O_QUEST, pos); + } else if (EATTWO('\\', '{')) { + count = p_count(p); + if (EAT(',')) { + if (MORE() && isdigit(PEEK())) { + count2 = p_count(p); + REQUIRE(count <= count2, REG_BADBR); + } else /* single number with comma */ + count2 = INFINITY; + } else /* just a single number */ + count2 = count; + repeat(p, pos, count, count2); + if (!EATTWO('\\', '}')) { /* error heuristics */ + while (MORE() && !SEETWO('\\', '}')) + NEXT(); + REQUIRE(MORE(), REG_EBRACE); + SETERROR(REG_BADBR); + } + } else if (c == (unsigned char)'$') /* $ (but not \$) ends it */ + return(1); + + return(0); +} + +/* + - p_count - parse a repetition count + == static int p_count(register struct parse *p); + */ +static int /* the value */ +p_count(p) +register struct parse *p; +{ + register int count = 0; + register int ndigits = 0; + + while (MORE() && isdigit(PEEK()) && count <= DUPMAX) { + count = count*10 + (GETNEXT() - '0'); + ndigits++; + } + + REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR); + return(count); +} + +/* + - p_bracket - parse a bracketed character list + == static void p_bracket(register struct parse *p); + * + * Note a significant property of this code: if the allocset() did SETERROR, + * no set operations are done. + */ +static void +p_bracket(p) +register struct parse *p; +{ + register char c; + register cset *cs = allocset(p); + register int invert = 0; + + /* Dept of Truly Sickening Special-Case Kludges */ + if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) { + EMIT(OBOW, 0); + NEXTn(6); + return; + } + if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) { + EMIT(OEOW, 0); + NEXTn(6); + return; + } + + if (EAT('^')) + invert++; /* make note to invert set at end */ + if (EAT(']')) + CHadd(cs, ']'); + else if (EAT('-')) + CHadd(cs, '-'); + while (MORE() && PEEK() != ']' && !SEETWO('-', ']')) + p_b_term(p, cs); + if (EAT('-')) + CHadd(cs, '-'); + MUSTEAT(']', REG_EBRACK); + + if (p->error != 0) /* don't mess things up further */ + return; + + if (p->g->cflags®_ICASE) { + register int i; + register int ci; + + for (i = p->g->csetsize - 1; i >= 0; i--) + if (CHIN(cs, i) && isalpha(i)) { + ci = othercase(i); + if (ci != i) + CHadd(cs, ci); + } + if (cs->multis != NULL) + mccase(p, cs); + } + if (invert) { + register int i; + + for (i = p->g->csetsize - 1; i >= 0; i--) + if (CHIN(cs, i)) + CHsub(cs, i); + else + CHadd(cs, i); + if (p->g->cflags®_NEWLINE) + CHsub(cs, '\n'); + if (cs->multis != NULL) + mcinvert(p, cs); + } + + assert(cs->multis == NULL); /* xxx */ + + if (nch(p, cs) == 1) { /* optimize singleton sets */ + ordinary(p, firstch(p, cs)); + freeset(p, cs); + } else + EMIT(OANYOF, freezeset(p, cs)); +} + +/* + - p_b_term - parse one term of a bracketed character list + == static void p_b_term(register struct parse *p, register cset *cs); + */ +static void +p_b_term(p, cs) +register struct parse *p; +register cset *cs; +{ + register char c; + register char start, finish; + register int i; + + /* classify what we've got */ + switch ((MORE()) ? PEEK() : '\0') { + case '[': + c = (MORE2()) ? PEEK2() : '\0'; + break; + case '-': + SETERROR(REG_ERANGE); + return; /* NOTE RETURN */ + break; + default: + c = '\0'; + break; + } + + switch (c) { + case ':': /* character class */ + NEXT2(); + REQUIRE(MORE(), REG_EBRACK); + c = PEEK(); + REQUIRE(c != '-' && c != ']', REG_ECTYPE); + p_b_cclass(p, cs); + REQUIRE(MORE(), REG_EBRACK); + REQUIRE(EATTWO(':', ']'), REG_ECTYPE); + break; + case '=': /* equivalence class */ + NEXT2(); + REQUIRE(MORE(), REG_EBRACK); + c = PEEK(); + REQUIRE(c != '-' && c != ']', REG_ECOLLATE); + p_b_eclass(p, cs); + REQUIRE(MORE(), REG_EBRACK); + REQUIRE(EATTWO('=', ']'), REG_ECOLLATE); + break; + default: /* symbol, ordinary character, or range */ +/* xxx revision needed for multichar stuff */ + start = p_b_symbol(p); + if (SEE('-') && MORE2() && PEEK2() != ']') { + /* range */ + NEXT(); + if (EAT('-')) + finish = '-'; + else + finish = p_b_symbol(p); + } else + finish = start; +/* xxx what about signed chars here... */ + REQUIRE(start <= finish, REG_ERANGE); + for (i = start; i <= finish; i++) + CHadd(cs, i); + break; + } +} + +/* + - p_b_cclass - parse a character-class name and deal with it + == static void p_b_cclass(register struct parse *p, register cset *cs); + */ +static void +p_b_cclass(p, cs) +register struct parse *p; +register cset *cs; +{ + register char *sp = p->next; + register struct cclass *cp; + register size_t len; + register char *u; + register char c; + + while (MORE() && isalpha(PEEK())) + NEXT(); + len = p->next - sp; + for (cp = cclasses; cp->name != NULL; cp++) + if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0') + break; + if (cp->name == NULL) { + /* oops, didn't find it */ + SETERROR(REG_ECTYPE); + return; + } + + u = cp->chars; + while ((c = *u++) != '\0') + CHadd(cs, c); + for (u = cp->multis; *u != '\0'; u += strlen(u) + 1) + MCadd(p, cs, u); +} + +/* + - p_b_eclass - parse an equivalence-class name and deal with it + == static void p_b_eclass(register struct parse *p, register cset *cs); + * + * This implementation is incomplete. xxx + */ +static void +p_b_eclass(p, cs) +register struct parse *p; +register cset *cs; +{ + register char c; + + c = p_b_coll_elem(p, '='); + CHadd(cs, c); +} + +/* + - p_b_symbol - parse a character or [..]ed multicharacter collating symbol + == static char p_b_symbol(register struct parse *p); + */ +static char /* value of symbol */ +p_b_symbol(p) +register struct parse *p; +{ + register char value; + + REQUIRE(MORE(), REG_EBRACK); + if (!EATTWO('[', '.')) + return(GETNEXT()); + + /* collating symbol */ + value = p_b_coll_elem(p, '.'); + REQUIRE(EATTWO('.', ']'), REG_ECOLLATE); + return(value); +} + +/* + - p_b_coll_elem - parse a collating-element name and look it up + == static char p_b_coll_elem(register struct parse *p, int endc); + */ +static char /* value of collating element */ +p_b_coll_elem(p, endc) +register struct parse *p; +int endc; /* name ended by endc,']' */ +{ + register char *sp = p->next; + register struct cname *cp; + register int len; + register char c; + + while (MORE() && !SEETWO(endc, ']')) + NEXT(); + if (!MORE()) { + SETERROR(REG_EBRACK); + return(0); + } + len = p->next - sp; + for (cp = cnames; cp->name != NULL; cp++) + if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0') + return(cp->code); /* known name */ + if (len == 1) + return(*sp); /* single character */ + SETERROR(REG_ECOLLATE); /* neither */ + return(0); +} + +/* + - othercase - return the case counterpart of an alphabetic + == static char othercase(int ch); + */ +static char /* if no counterpart, return ch */ +othercase(ch) +int ch; +{ + assert(isalpha(ch)); + if (isupper(ch)) + return(tolower(ch)); + else if (islower(ch)) + return(toupper(ch)); + else /* peculiar, but could happen */ + return(ch); +} + +/* + - bothcases - emit a dualcase version of a two-case character + == static void bothcases(register struct parse *p, int ch); + * + * Boy, is this implementation ever a kludge... + */ +static void +bothcases(p, ch) +register struct parse *p; +int ch; +{ + register char *oldnext = p->next; + register char *oldend = p->end; + char bracket[3]; + + assert(othercase(ch) != ch); /* p_bracket() would recurse */ + p->next = bracket; + p->end = bracket+2; + bracket[0] = ch; + bracket[1] = ']'; + bracket[2] = '\0'; + p_bracket(p); + assert(p->next == bracket+2); + p->next = oldnext; + p->end = oldend; +} + +/* + - ordinary - emit an ordinary character + == static void ordinary(register struct parse *p, register int ch); + */ +static void +ordinary(p, ch) +register struct parse *p; +register int ch; +{ + register cat_t *cap = p->g->categories; + + if ((p->g->cflags®_ICASE) && isalpha(ch) && othercase(ch) != ch) + bothcases(p, ch); + else { + EMIT(OCHAR, (unsigned char)ch); + if (cap[ch] == 0) + cap[ch] = p->g->ncategories++; + } +} + +/* + - nonnewline - emit REG_NEWLINE version of OANY + == static void nonnewline(register struct parse *p); + * + * Boy, is this implementation ever a kludge... + */ +static void +nonnewline(p) +register struct parse *p; +{ + register char *oldnext = p->next; + register char *oldend = p->end; + char bracket[4]; + + p->next = bracket; + p->end = bracket+3; + bracket[0] = '^'; + bracket[1] = '\n'; + bracket[2] = ']'; + bracket[3] = '\0'; + p_bracket(p); + assert(p->next == bracket+3); + p->next = oldnext; + p->end = oldend; +} + +/* + - repeat - generate code for a bounded repetition, recursively if needed + == static void repeat(register struct parse *p, sopno start, int from, int to); + */ +static void +repeat(p, start, from, to) +register struct parse *p; +sopno start; /* operand from here to end of strip */ +int from; /* repeated from this number */ +int to; /* to this number of times (maybe INFINITY) */ +{ + register sopno finish = HERE(); +# define N 2 +# define INF 3 +# define REP(f, t) ((f)*8 + (t)) +# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N) + register sopno copy; + + if (p->error != 0) /* head off possible runaway recursion */ + return; + + assert(from <= to); + + switch (REP(MAP(from), MAP(to))) { + case REP(0, 0): /* must be user doing this */ + DROP(finish-start); /* drop the operand */ + break; + case REP(0, 1): /* as x{1,1}? */ + case REP(0, N): /* as x{1,n}? */ + case REP(0, INF): /* as x{1,}? */ + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, start); /* offset is wrong... */ + repeat(p, start+1, 1, to); + ASTERN(OOR1, start); + AHEAD(start); /* ... fix it */ + EMIT(OOR2, 0); + AHEAD(THERE()); + ASTERN(O_CH, THERETHERE()); + break; + case REP(1, 1): /* trivial case */ + /* done */ + break; + case REP(1, N): /* as x?x{1,n-1} */ + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, start); + ASTERN(OOR1, start); + AHEAD(start); + EMIT(OOR2, 0); /* offset very wrong... */ + AHEAD(THERE()); /* ...so fix it */ + ASTERN(O_CH, THERETHERE()); + copy = dupl(p, start+1, finish+1); + assert(copy == finish+4); + repeat(p, copy, 1, to-1); + break; + case REP(1, INF): /* as x+ */ + INSERT(OPLUS_, start); + ASTERN(O_PLUS, start); + break; + case REP(N, N): /* as xx{m-1,n-1} */ + copy = dupl(p, start, finish); + repeat(p, copy, from-1, to-1); + break; + case REP(N, INF): /* as xx{n-1,INF} */ + copy = dupl(p, start, finish); + repeat(p, copy, from-1, to); + break; + default: /* "can't happen" */ + SETERROR(REG_ASSERT); /* just in case */ + break; + } +} + +/* + - seterr - set an error condition + == static int seterr(register struct parse *p, int e); + */ +static int /* useless but makes type checking happy */ +seterr(p, e) +register struct parse *p; +int e; +{ + if (p->error == 0) /* keep earliest error condition */ + p->error = e; + p->next = nuls; /* try to bring things to a halt */ + p->end = nuls; + return(0); /* make the return value well-defined */ +} + +/* + - allocset - allocate a set of characters for [] + == static cset *allocset(register struct parse *p); + */ +static cset * +allocset(p) +register struct parse *p; +{ + register int no = p->g->ncsets++; + register size_t nc; + register size_t nbytes; + register cset *cs; + register size_t css = (size_t)p->g->csetsize; + register int i; + + if (no >= p->ncsalloc) { /* need another column of space */ + p->ncsalloc += CHAR_BIT; + nc = p->ncsalloc; + assert(nc % CHAR_BIT == 0); + nbytes = nc / CHAR_BIT * css; + if (p->g->sets == NULL) + p->g->sets = (cset *)malloc(nc * sizeof(cset)); + else + p->g->sets = (cset *)realloc((char *)p->g->sets, + nc * sizeof(cset)); + if (p->g->setbits == NULL) + p->g->setbits = (uch *)malloc(nbytes); + else { + p->g->setbits = (uch *)realloc((char *)p->g->setbits, + nbytes); + /* xxx this isn't right if setbits is now NULL */ + for (i = 0; i < no; i++) + p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT); + } + if (p->g->sets != NULL && p->g->setbits != NULL) + (void) memset((char *)p->g->setbits + (nbytes - css), + 0, css); + else { + no = 0; + SETERROR(REG_ESPACE); + /* caller's responsibility not to do set ops */ + } + } + + assert(p->g->sets != NULL); /* xxx */ + cs = &p->g->sets[no]; + cs->ptr = p->g->setbits + css*((no)/CHAR_BIT); + cs->mask = 1 << ((no) % CHAR_BIT); + cs->hash = 0; + cs->smultis = 0; + cs->multis = NULL; + + return(cs); +} + +/* + - freeset - free a now-unused set + == static void freeset(register struct parse *p, register cset *cs); + */ +static void +freeset(p, cs) +register struct parse *p; +register cset *cs; +{ + register int i; + register cset *top = &p->g->sets[p->g->ncsets]; + register size_t css = (size_t)p->g->csetsize; + + for (i = 0; i < css; i++) + CHsub(cs, i); + if (cs == top-1) /* recover only the easy case */ + p->g->ncsets--; +} + +/* + - freezeset - final processing on a set of characters + == static int freezeset(register struct parse *p, register cset *cs); + * + * The main task here is merging identical sets. This is usually a waste + * of time (although the hash code minimizes the overhead), but can win + * big if REG_ICASE is being used. REG_ICASE, by the way, is why the hash + * is done using addition rather than xor -- all ASCII [aA] sets xor to + * the same value! + */ +static int /* set number */ +freezeset(p, cs) +register struct parse *p; +register cset *cs; +{ + register uch h = cs->hash; + register int i; + register cset *top = &p->g->sets[p->g->ncsets]; + register cset *cs2; + register size_t css = (size_t)p->g->csetsize; + + /* look for an earlier one which is the same */ + for (cs2 = &p->g->sets[0]; cs2 < top; cs2++) + if (cs2->hash == h && cs2 != cs) { + /* maybe */ + for (i = 0; i < css; i++) + if (!!CHIN(cs2, i) != !!CHIN(cs, i)) + break; /* no */ + if (i == css) + break; /* yes */ + } + + if (cs2 < top) { /* found one */ + freeset(p, cs); + cs = cs2; + } + + return((int)(cs - p->g->sets)); +} + +/* + - firstch - return first character in a set (which must have at least one) + == static int firstch(register struct parse *p, register cset *cs); + */ +static int /* character; there is no "none" value */ +firstch(p, cs) +register struct parse *p; +register cset *cs; +{ + register int i; + register size_t css = (size_t)p->g->csetsize; + + for (i = 0; i < css; i++) + if (CHIN(cs, i)) + return((char)i); + assert(never); + return(0); /* arbitrary */ +} + +/* + - nch - number of characters in a set + == static int nch(register struct parse *p, register cset *cs); + */ +static int +nch(p, cs) +register struct parse *p; +register cset *cs; +{ + register int i; + register size_t css = (size_t)p->g->csetsize; + register int n = 0; + + for (i = 0; i < css; i++) + if (CHIN(cs, i)) + n++; + return(n); +} + +/* + - mcadd - add a collating element to a cset + == static void mcadd(register struct parse *p, register cset *cs, \ + == register char *cp); + */ +static void +mcadd(p, cs, cp) +register struct parse *p; +register cset *cs; +register char *cp; +{ + register size_t oldend = cs->smultis; + + cs->smultis += strlen(cp) + 1; + if (cs->multis == NULL) + cs->multis = malloc(cs->smultis); + else + cs->multis = realloc(cs->multis, cs->smultis); + if (cs->multis == NULL) { + SETERROR(REG_ESPACE); + return; + } + + (void) strcpy(cs->multis + oldend - 1, cp); + cs->multis[cs->smultis - 1] = '\0'; +} + +/* + - mcsub - subtract a collating element from a cset + == static void mcsub(register cset *cs, register char *cp); + */ +static void +mcsub(cs, cp) +register cset *cs; +register char *cp; +{ + register char *fp = mcfind(cs, cp); + register size_t len = strlen(fp); + + assert(fp != NULL); + (void) memmove(fp, fp + len + 1, + cs->smultis - (fp + len + 1 - cs->multis)); + cs->smultis -= len; + + if (cs->smultis == 0) { + free(cs->multis); + cs->multis = NULL; + return; + } + + cs->multis = realloc(cs->multis, cs->smultis); + assert(cs->multis != NULL); +} + +/* + - mcin - is a collating element in a cset? + == static int mcin(register cset *cs, register char *cp); + */ +static int +mcin(cs, cp) +register cset *cs; +register char *cp; +{ + return(mcfind(cs, cp) != NULL); +} + +/* + - mcfind - find a collating element in a cset + == static char *mcfind(register cset *cs, register char *cp); + */ +static char * +mcfind(cs, cp) +register cset *cs; +register char *cp; +{ + register char *p; + + if (cs->multis == NULL) + return(NULL); + for (p = cs->multis; *p != '\0'; p += strlen(p) + 1) + if (strcmp(cp, p) == 0) + return(p); + return(NULL); +} + +/* + - mcinvert - invert the list of collating elements in a cset + == static void mcinvert(register struct parse *p, register cset *cs); + * + * This would have to know the set of possibilities. Implementation + * is deferred. + */ +static void +mcinvert(p, cs) +register struct parse *p; +register cset *cs; +{ + assert(cs->multis == NULL); /* xxx */ +} + +/* + - mccase - add case counterparts of the list of collating elements in a cset + == static void mccase(register struct parse *p, register cset *cs); + * + * This would have to know the set of possibilities. Implementation + * is deferred. + */ +static void +mccase(p, cs) +register struct parse *p; +register cset *cs; +{ + assert(cs->multis == NULL); /* xxx */ +} + +/* + - isinsets - is this character in any sets? + == static int isinsets(register struct re_guts *g, int c); + */ +static int /* predicate */ +isinsets(g, c) +register struct re_guts *g; +int c; +{ + register uch *col; + register int i; + register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; + register unsigned uc = (unsigned char)c; + + for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) + if (col[uc] != 0) + return(1); + return(0); +} + +/* + - samesets - are these two characters in exactly the same sets? + == static int samesets(register struct re_guts *g, int c1, int c2); + */ +static int /* predicate */ +samesets(g, c1, c2) +register struct re_guts *g; +int c1; +int c2; +{ + register uch *col; + register int i; + register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; + register unsigned uc1 = (unsigned char)c1; + register unsigned uc2 = (unsigned char)c2; + + for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) + if (col[uc1] != col[uc2]) + return(0); + return(1); +} + +/* + - categorize - sort out character categories + == static void categorize(struct parse *p, register struct re_guts *g); + */ +static void +categorize(p, g) +struct parse *p; +register struct re_guts *g; +{ + register cat_t *cats = g->categories; + register int c; + register int c2; + register cat_t cat; + + /* avoid making error situations worse */ + if (p->error != 0) + return; + + for (c = CHAR_MIN; c <= CHAR_MAX; c++) + if (cats[c] == 0 && isinsets(g, c)) { + cat = g->ncategories++; + cats[c] = cat; + for (c2 = c+1; c2 <= CHAR_MAX; c2++) + if (cats[c2] == 0 && samesets(g, c, c2)) + cats[c2] = cat; + } +} + +/* + - dupl - emit a duplicate of a bunch of sops + == static sopno dupl(register struct parse *p, sopno start, sopno finish); + */ +static sopno /* start of duplicate */ +dupl(p, start, finish) +register struct parse *p; +sopno start; /* from here */ +sopno finish; /* to this less one */ +{ + register sopno ret = HERE(); + register sopno len = finish - start; + + assert(finish >= start); + if (len == 0) + return(ret); + enlarge(p, p->ssize + len); /* this many unexpected additions */ + assert(p->ssize >= p->slen + len); + (void) memcpy((char *)(p->strip + p->slen), + (char *)(p->strip + start), (size_t)len*sizeof(sop)); + p->slen += len; + return(ret); +} + +/* + - doemit - emit a strip operator + == static void doemit(register struct parse *p, sop op, size_t opnd); + * + * It might seem better to implement this as a macro with a function as + * hard-case backup, but it's just too big and messy unless there are + * some changes to the data structures. Maybe later. + */ +static void +doemit(p, op, opnd) +register struct parse *p; +sop op; +size_t opnd; +{ + /* avoid making error situations worse */ + if (p->error != 0) + return; + + /* deal with oversize operands ("can't happen", more or less) */ + assert(opnd < 1<<OPSHIFT); + + /* deal with undersized strip */ + if (p->slen >= p->ssize) + enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */ + assert(p->slen < p->ssize); + + /* finally, it's all reduced to the easy case */ + p->strip[p->slen++] = SOP(op, opnd); +} + +/* + - doinsert - insert a sop into the strip + == static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos); + */ +static void +doinsert(p, op, opnd, pos) +register struct parse *p; +sop op; +size_t opnd; +sopno pos; +{ + register sopno sn; + register sop s; + register int i; + + /* avoid making error situations worse */ + if (p->error != 0) + return; + + sn = HERE(); + EMIT(op, opnd); /* do checks, ensure space */ + assert(HERE() == sn+1); + s = p->strip[sn]; + + /* adjust paren pointers */ + assert(pos > 0); + for (i = 1; i < NPAREN; i++) { + if (p->pbegin[i] >= pos) { + p->pbegin[i]++; + } + if (p->pend[i] >= pos) { + p->pend[i]++; + } + } + + memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos], + (HERE()-pos-1)*sizeof(sop)); + p->strip[pos] = s; +} + +/* + - dofwd - complete a forward reference + == static void dofwd(register struct parse *p, sopno pos, sop value); + */ +static void +dofwd(p, pos, value) +register struct parse *p; +register sopno pos; +sop value; +{ + /* avoid making error situations worse */ + if (p->error != 0) + return; + + assert(value < 1<<OPSHIFT); + p->strip[pos] = OP(p->strip[pos]) | value; +} + +/* + - enlarge - enlarge the strip + == static void enlarge(register struct parse *p, sopno size); + */ +static void +enlarge(p, size) +register struct parse *p; +register sopno size; +{ + register sop *sp; + + if (p->ssize >= size) + return; + + sp = (sop *)realloc(p->strip, size*sizeof(sop)); + if (sp == NULL) { + SETERROR(REG_ESPACE); + return; + } + p->strip = sp; + p->ssize = size; +} + +/* + - stripsnug - compact the strip + == static void stripsnug(register struct parse *p, register struct re_guts *g); + */ +static void +stripsnug(p, g) +register struct parse *p; +register struct re_guts *g; +{ + g->nstates = p->slen; + g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop)); + if (g->strip == NULL) { + SETERROR(REG_ESPACE); + g->strip = p->strip; + } +} + +/* + - findmust - fill in must and mlen with longest mandatory literal string + == static void findmust(register struct parse *p, register struct re_guts *g); + * + * This algorithm could do fancy things like analyzing the operands of | + * for common subsequences. Someday. This code is simple and finds most + * of the interesting cases. + * + * Note that must and mlen got initialized during setup. + */ +static void +findmust(p, g) +struct parse *p; +register struct re_guts *g; +{ + register sop *scan; + sop *start; + register sop *newstart; + register sopno newlen; + register sop s; + register char *cp; + register sopno i; + + /* avoid making error situations worse */ + if (p->error != 0) + return; + + /* find the longest OCHAR sequence in strip */ + newlen = 0; + scan = g->strip + 1; + do { + s = *scan++; + switch (OP(s)) { + case OCHAR: /* sequence member */ + if (newlen == 0) /* new sequence */ + newstart = scan - 1; + newlen++; + break; + case OPLUS_: /* things that don't break one */ + case OLPAREN: + case ORPAREN: + break; + case OQUEST_: /* things that must be skipped */ + case OCH_: + scan--; + do { + scan += OPND(s); + s = *scan; + /* assert() interferes w debug printouts */ + if (OP(s) != O_QUEST && OP(s) != O_CH && + OP(s) != OOR2) { + g->iflags |= BAD; + return; + } + } while (OP(s) != O_QUEST && OP(s) != O_CH); + /* fallthrough */ + default: /* things that break a sequence */ + if (newlen > g->mlen) { /* ends one */ + start = newstart; + g->mlen = newlen; + } + newlen = 0; + break; + } + } while (OP(s) != OEND); + + if (g->mlen == 0) /* there isn't one */ + return; + + /* turn it into a character string */ + g->must = malloc((size_t)g->mlen + 1); + if (g->must == NULL) { /* argh; just forget it */ + g->mlen = 0; + return; + } + cp = g->must; + scan = start; + for (i = g->mlen; i > 0; i--) { + while (OP(s = *scan++) != OCHAR) + continue; + assert(cp < g->must + g->mlen); + *cp++ = (char)OPND(s); + } + assert(cp == g->must + g->mlen); + *cp++ = '\0'; /* just on general principles */ +} + +/* + - pluscount - count + nesting + == static sopno pluscount(register struct parse *p, register struct re_guts *g); + */ +static sopno /* nesting depth */ +pluscount(p, g) +struct parse *p; +register struct re_guts *g; +{ + register sop *scan; + register sop s; + register sopno plusnest = 0; + register sopno maxnest = 0; + + if (p->error != 0) + return(0); /* there may not be an OEND */ + + scan = g->strip + 1; + do { + s = *scan++; + switch (OP(s)) { + case OPLUS_: + plusnest++; + break; + case O_PLUS: + if (plusnest > maxnest) + maxnest = plusnest; + plusnest--; + break; + } + } while (OP(s) != OEND); + if (plusnest != 0) + g->iflags |= BAD; + return(maxnest); +} diff --git a/src/backend/port/win32/regex/regerror.c b/src/backend/port/win32/regex/regerror.c new file mode 100644 index 00000000000..a8d09454199 --- /dev/null +++ b/src/backend/port/win32/regex/regerror.c @@ -0,0 +1,180 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regerror.c 8.4 (Berkeley) 3/20/94 + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> +#include <stdlib.h> +#include <regex.h> + +#include "utils.h" + +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === regerror.c === */ +static char *regatoi __P((const regex_t *preg, char *localbuf)); + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ +/* + = #define REG_NOMATCH 1 + = #define REG_BADPAT 2 + = #define REG_ECOLLATE 3 + = #define REG_ECTYPE 4 + = #define REG_EESCAPE 5 + = #define REG_ESUBREG 6 + = #define REG_EBRACK 7 + = #define REG_EPAREN 8 + = #define REG_EBRACE 9 + = #define REG_BADBR 10 + = #define REG_ERANGE 11 + = #define REG_ESPACE 12 + = #define REG_BADRPT 13 + = #define REG_EMPTY 14 + = #define REG_ASSERT 15 + = #define REG_INVARG 16 + = #define REG_ATOI 255 // convert name to number (!) + = #define REG_ITOA 0400 // convert number to name (!) + */ +static struct rerr { + int code; + char *name; + char *explain; +} rerrs[] = { + REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match", + REG_BADPAT, "REG_BADPAT", "invalid regular expression", + REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element", + REG_ECTYPE, "REG_ECTYPE", "invalid character class", + REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)", + REG_ESUBREG, "REG_ESUBREG", "invalid backreference number", + REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced", + REG_EPAREN, "REG_EPAREN", "parentheses not balanced", + REG_EBRACE, "REG_EBRACE", "braces not balanced", + REG_BADBR, "REG_BADBR", "invalid repetition count(s)", + REG_ERANGE, "REG_ERANGE", "invalid character range", + REG_ESPACE, "REG_ESPACE", "out of memory", + REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid", + REG_EMPTY, "REG_EMPTY", "empty (sub)expression", + REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug", + REG_INVARG, "REG_INVARG", "invalid argument to regex routine", + 0, "", "*** unknown regexp error code ***", +}; + +/* + - regerror - the interface to error numbers + = extern size_t regerror(int, const regex_t *, char *, size_t); + */ +/* ARGSUSED */ +size_t +regerror(errcode, preg, errbuf, errbuf_size) +int errcode; +const regex_t *preg; +char *errbuf; +size_t errbuf_size; +{ + register struct rerr *r; + register size_t len; + register int target = errcode &~ REG_ITOA; + register char *s; + char convbuf[50]; + + if (errcode == REG_ATOI) + s = regatoi(preg, convbuf); + else { + for (r = rerrs; r->code != 0; r++) + if (r->code == target) + break; + + if (errcode®_ITOA) { + if (r->code != 0) + (void) strcpy(convbuf, r->name); + else + sprintf(convbuf, "REG_0x%x", target); + assert(strlen(convbuf) < sizeof(convbuf)); + s = convbuf; + } else + s = r->explain; + } + + len = strlen(s) + 1; + if (errbuf_size > 0) { + if (errbuf_size > len) + (void) strcpy(errbuf, s); + else { + (void) strncpy(errbuf, s, errbuf_size-1); + errbuf[errbuf_size-1] = '\0'; + } + } + + return(len); +} + +/* + - regatoi - internal routine to implement REG_ATOI + == static char *regatoi(const regex_t *preg, char *localbuf); + */ +static char * +regatoi(preg, localbuf) +const regex_t *preg; +char *localbuf; +{ + register struct rerr *r; + register size_t siz; + register char *p; + + for (r = rerrs; r->code != 0; r++) + if (strcmp(r->name, preg->re_endp) == 0) + break; + if (r->code == 0) + return("0"); + + sprintf(localbuf, "%d", r->code); + return(localbuf); +} diff --git a/src/backend/port/win32/regex/regex.3 b/src/backend/port/win32/regex/regex.3 new file mode 100644 index 00000000000..66a7285d86d --- /dev/null +++ b/src/backend/port/win32/regex/regex.3 @@ -0,0 +1,538 @@ +.\" Copyright (c) 1992, 1993, 1994 Henry Spencer. +.\" Copyright (c) 1992, 1993, 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Henry Spencer. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)regex.3 8.4 (Berkeley) 3/20/94 +.\" +.TH REGEX 3 "March 20, 1994" +.de ZR +.\" one other place knows this name: the SEE ALSO section +.IR re_format (7) \\$1 +.. +.SH NAME +regcomp, regexec, regerror, regfree \- regular-expression library +.SH SYNOPSIS +.ft B +.\".na +#include <sys/types.h> +.br +#include <regex.h> +.HP 10 +int regcomp(regex_t\ *preg, const\ char\ *pattern, int\ cflags); +.HP +int\ regexec(const\ regex_t\ *preg, const\ char\ *string, +size_t\ nmatch, regmatch_t\ pmatch[], int\ eflags); +.HP +size_t\ regerror(int\ errcode, const\ regex_t\ *preg, +char\ *errbuf, size_t\ errbuf_size); +.HP +void\ regfree(regex_t\ *preg); +.\".ad +.ft +.SH DESCRIPTION +These routines implement POSIX 1003.2 regular expressions (``RE''s); +see +.ZR . +.I Regcomp +compiles an RE written as a string into an internal form, +.I regexec +matches that internal form against a string and reports results, +.I regerror +transforms error codes from either into human-readable messages, +and +.I regfree +frees any dynamically-allocated storage used by the internal form +of an RE. +.PP +The header +.I <regex.h> +declares two structure types, +.I regex_t +and +.IR regmatch_t , +the former for compiled internal forms and the latter for match reporting. +It also declares the four functions, +a type +.IR regoff_t , +and a number of constants with names starting with ``REG_''. +.PP +.I Regcomp +compiles the regular expression contained in the +.I pattern +string, +subject to the flags in +.IR cflags , +and places the results in the +.I regex_t +structure pointed to by +.IR preg . +.I Cflags +is the bitwise OR of zero or more of the following flags: +.IP REG_EXTENDED \w'REG_EXTENDED'u+2n +Compile modern (``extended'') REs, +rather than the obsolete (``basic'') REs that +are the default. +.IP REG_BASIC +This is a synonym for 0, +provided as a counterpart to REG_EXTENDED to improve readability. +.IP REG_NOSPEC +Compile with recognition of all special characters turned off. +All characters are thus considered ordinary, +so the ``RE'' is a literal string. +This is an extension, +compatible with but not specified by POSIX 1003.2, +and should be used with +caution in software intended to be portable to other systems. +REG_EXTENDED and REG_NOSPEC may not be used +in the same call to +.IR regcomp . +.IP REG_ICASE +Compile for matching that ignores upper/lower case distinctions. +See +.ZR . +.IP REG_NOSUB +Compile for matching that need only report success or failure, +not what was matched. +.IP REG_NEWLINE +Compile for newline-sensitive matching. +By default, newline is a completely ordinary character with no special +meaning in either REs or strings. +With this flag, +`[^' bracket expressions and `.' never match newline, +a `^' anchor matches the null string after any newline in the string +in addition to its normal function, +and the `$' anchor matches the null string before any newline in the +string in addition to its normal function. +.IP REG_PEND +The regular expression ends, +not at the first NUL, +but just before the character pointed to by the +.I re_endp +member of the structure pointed to by +.IR preg . +The +.I re_endp +member is of type +.IR const\ char\ * . +This flag permits inclusion of NULs in the RE; +they are considered ordinary characters. +This is an extension, +compatible with but not specified by POSIX 1003.2, +and should be used with +caution in software intended to be portable to other systems. +.PP +When successful, +.I regcomp +returns 0 and fills in the structure pointed to by +.IR preg . +One member of that structure +(other than +.IR re_endp ) +is publicized: +.IR re_nsub , +of type +.IR size_t , +contains the number of parenthesized subexpressions within the RE +(except that the value of this member is undefined if the +REG_NOSUB flag was used). +If +.I regcomp +fails, it returns a non-zero error code; +see DIAGNOSTICS. +.PP +.I Regexec +matches the compiled RE pointed to by +.I preg +against the +.IR string , +subject to the flags in +.IR eflags , +and reports results using +.IR nmatch , +.IR pmatch , +and the returned value. +The RE must have been compiled by a previous invocation of +.IR regcomp . +The compiled form is not altered during execution of +.IR regexec , +so a single compiled RE can be used simultaneously by multiple threads. +.PP +By default, +the NUL-terminated string pointed to by +.I string +is considered to be the text of an entire line, minus any terminating +newline. +The +.I eflags +argument is the bitwise OR of zero or more of the following flags: +.IP REG_NOTBOL \w'REG_STARTEND'u+2n +The first character of +the string +is not the beginning of a line, so the `^' anchor should not match before it. +This does not affect the behavior of newlines under REG_NEWLINE. +.IP REG_NOTEOL +The NUL terminating +the string +does not end a line, so the `$' anchor should not match before it. +This does not affect the behavior of newlines under REG_NEWLINE. +.IP REG_STARTEND +The string is considered to start at +\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_so\fR +and to have a terminating NUL located at +\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_eo\fR +(there need not actually be a NUL at that location), +regardless of the value of +.IR nmatch . +See below for the definition of +.IR pmatch +and +.IR nmatch . +This is an extension, +compatible with but not specified by POSIX 1003.2, +and should be used with +caution in software intended to be portable to other systems. +Note that a non-zero \fIrm_so\fR does not imply REG_NOTBOL; +REG_STARTEND affects only the location of the string, +not how it is matched. +.PP +See +.ZR +for a discussion of what is matched in situations where an RE or a +portion thereof could match any of several substrings of +.IR string . +.PP +Normally, +.I regexec +returns 0 for success and the non-zero code REG_NOMATCH for failure. +Other non-zero error codes may be returned in exceptional situations; +see DIAGNOSTICS. +.PP +If REG_NOSUB was specified in the compilation of the RE, +or if +.I nmatch +is 0, +.I regexec +ignores the +.I pmatch +argument (but see below for the case where REG_STARTEND is specified). +Otherwise, +.I pmatch +points to an array of +.I nmatch +structures of type +.IR regmatch_t . +Such a structure has at least the members +.I rm_so +and +.IR rm_eo , +both of type +.I regoff_t +(a signed arithmetic type at least as large as an +.I off_t +and a +.IR ssize_t ), +containing respectively the offset of the first character of a substring +and the offset of the first character after the end of the substring. +Offsets are measured from the beginning of the +.I string +argument given to +.IR regexec . +An empty substring is denoted by equal offsets, +both indicating the character following the empty substring. +.PP +The 0th member of the +.I pmatch +array is filled in to indicate what substring of +.I string +was matched by the entire RE. +Remaining members report what substring was matched by parenthesized +subexpressions within the RE; +member +.I i +reports subexpression +.IR i , +with subexpressions counted (starting at 1) by the order of their opening +parentheses in the RE, left to right. +Unused entries in the array\(emcorresponding either to subexpressions that +did not participate in the match at all, or to subexpressions that do not +exist in the RE (that is, \fIi\fR\ > \fIpreg\fR\->\fIre_nsub\fR)\(emhave both +.I rm_so +and +.I rm_eo +set to \-1. +If a subexpression participated in the match several times, +the reported substring is the last one it matched. +(Note, as an example in particular, that when the RE `(b*)+' matches `bbb', +the parenthesized subexpression matches each of the three `b's and then +an infinite number of empty strings following the last `b', +so the reported substring is one of the empties.) +.PP +If REG_STARTEND is specified, +.I pmatch +must point to at least one +.I regmatch_t +(even if +.I nmatch +is 0 or REG_NOSUB was specified), +to hold the input offsets for REG_STARTEND. +Use for output is still entirely controlled by +.IR nmatch ; +if +.I nmatch +is 0 or REG_NOSUB was specified, +the value of +.IR pmatch [0] +will not be changed by a successful +.IR regexec . +.PP +.I Regerror +maps a non-zero +.I errcode +from either +.I regcomp +or +.I regexec +to a human-readable, printable message. +If +.I preg +is non-NULL, +the error code should have arisen from use of +the +.I regex_t +pointed to by +.IR preg , +and if the error code came from +.IR regcomp , +it should have been the result from the most recent +.I regcomp +using that +.IR regex_t . +.RI ( Regerror +may be able to supply a more detailed message using information +from the +.IR regex_t .) +.I Regerror +places the NUL-terminated message into the buffer pointed to by +.IR errbuf , +limiting the length (including the NUL) to at most +.I errbuf_size +bytes. +If the whole message won't fit, +as much of it as will fit before the terminating NUL is supplied. +In any case, +the returned value is the size of buffer needed to hold the whole +message (including terminating NUL). +If +.I errbuf_size +is 0, +.I errbuf +is ignored but the return value is still correct. +.PP +If the +.I errcode +given to +.I regerror +is first ORed with REG_ITOA, +the ``message'' that results is the printable name of the error code, +e.g. ``REG_NOMATCH'', +rather than an explanation thereof. +If +.I errcode +is REG_ATOI, +then +.I preg +shall be non-NULL and the +.I re_endp +member of the structure it points to +must point to the printable name of an error code; +in this case, the result in +.I errbuf +is the decimal digits of +the numeric value of the error code +(0 if the name is not recognized). +REG_ITOA and REG_ATOI are intended primarily as debugging facilities; +they are extensions, +compatible with but not specified by POSIX 1003.2, +and should be used with +caution in software intended to be portable to other systems. +Be warned also that they are considered experimental and changes are possible. +.PP +.I Regfree +frees any dynamically-allocated storage associated with the compiled RE +pointed to by +.IR preg . +The remaining +.I regex_t +is no longer a valid compiled RE +and the effect of supplying it to +.I regexec +or +.I regerror +is undefined. +.PP +None of these functions references global variables except for tables +of constants; +all are safe for use from multiple threads if the arguments are safe. +.SH IMPLEMENTATION CHOICES +There are a number of decisions that 1003.2 leaves up to the implementor, +either by explicitly saying ``undefined'' or by virtue of them being +forbidden by the RE grammar. +This implementation treats them as follows. +.PP +See +.ZR +for a discussion of the definition of case-independent matching. +.PP +There is no particular limit on the length of REs, +except insofar as memory is limited. +Memory usage is approximately linear in RE size, and largely insensitive +to RE complexity, except for bounded repetitions. +See BUGS for one short RE using them +that will run almost any system out of memory. +.PP +A backslashed character other than one specifically given a magic meaning +by 1003.2 (such magic meanings occur only in obsolete [``basic''] REs) +is taken as an ordinary character. +.PP +Any unmatched [ is a REG_EBRACK error. +.PP +Equivalence classes cannot begin or end bracket-expression ranges. +The endpoint of one range cannot begin another. +.PP +RE_DUP_MAX, the limit on repetition counts in bounded repetitions, is 255. +.PP +A repetition operator (?, *, +, or bounds) cannot follow another +repetition operator. +A repetition operator cannot begin an expression or subexpression +or follow `^' or `|'. +.PP +`|' cannot appear first or last in a (sub)expression or after another `|', +i.e. an operand of `|' cannot be an empty subexpression. +An empty parenthesized subexpression, `()', is legal and matches an +empty (sub)string. +An empty string is not a legal RE. +.PP +A `{' followed by a digit is considered the beginning of bounds for a +bounded repetition, which must then follow the syntax for bounds. +A `{' \fInot\fR followed by a digit is considered an ordinary character. +.PP +`^' and `$' beginning and ending subexpressions in obsolete (``basic'') +REs are anchors, not ordinary characters. +.SH SEE ALSO +grep(1), re_format(7) +.PP +POSIX 1003.2, sections 2.8 (Regular Expression Notation) +and +B.5 (C Binding for Regular Expression Matching). +.SH DIAGNOSTICS +Non-zero error codes from +.I regcomp +and +.I regexec +include the following: +.PP +.nf +.ta \w'REG_ECOLLATE'u+3n +REG_NOMATCH regexec() failed to match +REG_BADPAT invalid regular expression +REG_ECOLLATE invalid collating element +REG_ECTYPE invalid character class +REG_EESCAPE \e applied to unescapable character +REG_ESUBREG invalid backreference number +REG_EBRACK brackets [ ] not balanced +REG_EPAREN parentheses ( ) not balanced +REG_EBRACE braces { } not balanced +REG_BADBR invalid repetition count(s) in { } +REG_ERANGE invalid character range in [ ] +REG_ESPACE ran out of memory +REG_BADRPT ?, *, or + operand invalid +REG_EMPTY empty (sub)expression +REG_ASSERT ``can't happen''\(emyou found a bug +REG_INVARG invalid argument, e.g. negative-length string +.fi +.SH HISTORY +Originally written by Henry Spencer. +Altered for inclusion in the 4.4BSD distribution. +.SH BUGS +This is an alpha release with known defects. +Please report problems. +.PP +There is one known functionality bug. +The implementation of internationalization is incomplete: +the locale is always assumed to be the default one of 1003.2, +and only the collating elements etc. of that locale are available. +.PP +The back-reference code is subtle and doubts linger about its correctness +in complex cases. +.PP +.I Regexec +performance is poor. +This will improve with later releases. +.I Nmatch +exceeding 0 is expensive; +.I nmatch +exceeding 1 is worse. +.I Regexec +is largely insensitive to RE complexity \fIexcept\fR that back +references are massively expensive. +RE length does matter; in particular, there is a strong speed bonus +for keeping RE length under about 30 characters, +with most special characters counting roughly double. +.PP +.I Regcomp +implements bounded repetitions by macro expansion, +which is costly in time and space if counts are large +or bounded repetitions are nested. +An RE like, say, +`((((a{1,100}){1,100}){1,100}){1,100}){1,100}' +will (eventually) run almost any existing machine out of swap space. +.PP +There are suspected problems with response to obscure error conditions. +Notably, +certain kinds of internal overflow, +produced only by truly enormous REs or by multiply nested bounded repetitions, +are probably not handled well. +.PP +Due to a mistake in 1003.2, things like `a)b' are legal REs because `)' is +a special character only in the presence of a previous unmatched `('. +This can't be fixed until the spec is fixed. +.PP +The standard's definition of back references is vague. +For example, does +`a\e(\e(b\e)*\e2\e)*d' match `abbbd'? +Until the standard is clarified, +behavior in such cases should not be relied on. +.PP +The implementation of word-boundary matching is a bit of a kludge, +and bugs may lurk in combinations of word-boundary matching and anchoring. diff --git a/src/backend/port/win32/regex/regex.h b/src/backend/port/win32/regex/regex.h new file mode 100644 index 00000000000..1611d4b8792 --- /dev/null +++ b/src/backend/port/win32/regex/regex.h @@ -0,0 +1,106 @@ +/*- + * Copyright (c) 1992 Henry Spencer. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer of the University of Toronto. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regex.h 8.2 (Berkeley) 1/3/94 + */ + +#ifndef _REGEX_H_ +#define _REGEX_H_ + +#include <sys/cdefs.h> + +/* types */ +typedef off_t regoff_t; + +typedef struct { + int re_magic; + size_t re_nsub; /* number of parenthesized subexpressions */ + __const char *re_endp; /* end pointer for REG_PEND */ + struct re_guts *re_g; /* none of your business :-) */ +} regex_t; + +typedef struct { + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; + +/* regcomp() flags */ +#define REG_BASIC 0000 +#define REG_EXTENDED 0001 +#define REG_ICASE 0002 +#define REG_NOSUB 0004 +#define REG_NEWLINE 0010 +#define REG_NOSPEC 0020 +#define REG_PEND 0040 +#define REG_DUMP 0200 + +/* regerror() flags */ +#define REG_NOMATCH 1 +#define REG_BADPAT 2 +#define REG_ECOLLATE 3 +#define REG_ECTYPE 4 +#define REG_EESCAPE 5 +#define REG_ESUBREG 6 +#define REG_EBRACK 7 +#define REG_EPAREN 8 +#define REG_EBRACE 9 +#define REG_BADBR 10 +#define REG_ERANGE 11 +#define REG_ESPACE 12 +#define REG_BADRPT 13 +#define REG_EMPTY 14 +#define REG_ASSERT 15 +#define REG_INVARG 16 +#define REG_ATOI 255 /* convert name to number (!) */ +#define REG_ITOA 0400 /* convert number to name (!) */ + +/* regexec() flags */ +#define REG_NOTBOL 00001 +#define REG_NOTEOL 00002 +#define REG_STARTEND 00004 +#define REG_TRACE 00400 /* tracing of execution */ +#define REG_LARGE 01000 /* force large representation */ +#define REG_BACKR 02000 /* force use of backref code */ + +__BEGIN_DECLS +int regcomp __P((regex_t *, const char *, int)); +size_t regerror __P((int, const regex_t *, char *, size_t)); +int regexec __P((const regex_t *, + const char *, size_t, regmatch_t [], int)); +void regfree __P((regex_t *)); +__END_DECLS + +#endif /* !_REGEX_H_ */ diff --git a/src/backend/port/win32/regex/regex2.h b/src/backend/port/win32/regex/regex2.h new file mode 100644 index 00000000000..0261b535d02 --- /dev/null +++ b/src/backend/port/win32/regex/regex2.h @@ -0,0 +1,175 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regex2.h 8.4 (Berkeley) 3/20/94 + */ + +/* + * First, the stuff that ends up in the outside-world include file +*/ +/* + typedef off_t regoff_t; + typedef struct { + int re_magic; + size_t re_nsub; // number of parenthesized subexpressions + const char *re_endp; // end pointer for REG_PEND + struct re_guts *re_g; // none of your business :-) + } regex_t; + typedef struct { + regoff_t rm_so; // start of match + regoff_t rm_eo; // end of match + } regmatch_t; +*/ +/* + * internals of regex_t + */ +#define MAGIC1 ((('r'^0200)<<8) | 'e') + +/* + * The internal representation is a *strip*, a sequence of + * operators ending with an endmarker. (Some terminology etc. is a + * historical relic of earlier versions which used multiple strips.) + * Certain oddities in the representation are there to permit running + * the machinery backwards; in particular, any deviation from sequential + * flow must be marked at both its source and its destination. Some + * fine points: + * + * - OPLUS_ and O_PLUS are *inside* the loop they create. + * - OQUEST_ and O_QUEST are *outside* the bypass they create. + * - OCH_ and O_CH are *outside* the multi-way branch they create, while + * OOR1 and OOR2 are respectively the end and the beginning of one of + * the branches. Note that there is an implicit OOR2 following OCH_ + * and an implicit OOR1 preceding O_CH. + * + * In state representations, an operator's bit is on to signify a state + * immediately *preceding* "execution" of that operator. + */ +typedef unsigned long sop; /* strip operator */ +typedef long sopno; +#define OPRMASK 0xf8000000 +#define OPDMASK 0x07ffffff +#define OPSHIFT ((unsigned)27) +#define OP(n) ((n)&OPRMASK) +#define OPND(n) ((n)&OPDMASK) +#define SOP(op, opnd) ((op)|(opnd)) +/* operators meaning operand */ +/* (back, fwd are offsets) */ +#define OEND (1<<OPSHIFT) /* endmarker - */ +#define OCHAR (2<<OPSHIFT) /* character unsigned char */ +#define OBOL (3<<OPSHIFT) /* left anchor - */ +#define OEOL (4<<OPSHIFT) /* right anchor - */ +#define OANY (5<<OPSHIFT) /* . - */ +#define OANYOF (6<<OPSHIFT) /* [...] set number */ +#define OBACK_ (7<<OPSHIFT) /* begin \d paren number */ +#define O_BACK (8<<OPSHIFT) /* end \d paren number */ +#define OPLUS_ (9<<OPSHIFT) /* + prefix fwd to suffix */ +#define O_PLUS (10<<OPSHIFT) /* + suffix back to prefix */ +#define OQUEST_ (11<<OPSHIFT) /* ? prefix fwd to suffix */ +#define O_QUEST (12<<OPSHIFT) /* ? suffix back to prefix */ +#define OLPAREN (13<<OPSHIFT) /* ( fwd to ) */ +#define ORPAREN (14<<OPSHIFT) /* ) back to ( */ +#define OCH_ (15<<OPSHIFT) /* begin choice fwd to OOR2 */ +#define OOR1 (16<<OPSHIFT) /* | pt. 1 back to OOR1 or OCH_ */ +#define OOR2 (17<<OPSHIFT) /* | pt. 2 fwd to OOR2 or O_CH */ +#define O_CH (18<<OPSHIFT) /* end choice back to OOR1 */ +#define OBOW (19<<OPSHIFT) /* begin word - */ +#define OEOW (20<<OPSHIFT) /* end word - */ + +/* + * Structure for [] character-set representation. Character sets are + * done as bit vectors, grouped 8 to a byte vector for compactness. + * The individual set therefore has both a pointer to the byte vector + * and a mask to pick out the relevant bit of each byte. A hash code + * simplifies testing whether two sets could be identical. + * + * This will get trickier for multicharacter collating elements. As + * preliminary hooks for dealing with such things, we also carry along + * a string of multi-character elements, and decide the size of the + * vectors at run time. + */ +typedef struct { + uch *ptr; /* -> uch [csetsize] */ + uch mask; /* bit within array */ + uch hash; /* hash code */ + size_t smultis; + char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ +} cset; +/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ +#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) +#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c)) +#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask) +#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */ +#define MCsub(p, cs, cp) mcsub(p, cs, cp) +#define MCin(p, cs, cp) mcin(p, cs, cp) + +/* stuff for character categories */ +typedef unsigned char cat_t; + +/* + * main compiled-expression structure + */ +struct re_guts { + int magic; +# define MAGIC2 ((('R'^0200)<<8)|'E') + sop *strip; /* malloced area for strip */ + int csetsize; /* number of bits in a cset vector */ + int ncsets; /* number of csets in use */ + cset *sets; /* -> cset [ncsets] */ + uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */ + int cflags; /* copy of regcomp() cflags argument */ + sopno nstates; /* = number of sops */ + sopno firststate; /* the initial OEND (normally 0) */ + sopno laststate; /* the final OEND */ + int iflags; /* internal flags */ +# define USEBOL 01 /* used ^ */ +# define USEEOL 02 /* used $ */ +# define BAD 04 /* something wrong */ + int nbol; /* number of ^ used */ + int neol; /* number of $ used */ + int ncategories; /* how many character categories */ + cat_t *categories; /* ->catspace[-CHAR_MIN] */ + char *must; /* match must contain this string */ + int mlen; /* length of must */ + size_t nsub; /* copy of re_nsub */ + int backrefs; /* does it use back references? */ + sopno nplus; /* how deep does it nest +s? */ + /* catspace must be last */ + cat_t catspace[1]; /* actually [NC] */ +}; + +/* misc utilities */ +#define OUT (CHAR_MAX+1) /* a non-character value */ +#define ISWORD(c) (isalnum(c) || (c) == '_') diff --git a/src/backend/port/win32/regex/regexec.c b/src/backend/port/win32/regex/regexec.c new file mode 100644 index 00000000000..3890b617869 --- /dev/null +++ b/src/backend/port/win32/regex/regexec.c @@ -0,0 +1,181 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regexec.c 8.3 (Berkeley) 3/20/94 + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * the outer shell of regexec() + * + * This file includes engine.c *twice*, after muchos fiddling with the + * macros that code uses. This lets the same code operate on two different + * representations for state sets. + */ +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <ctype.h> +#include <regex.h> + +#include "utils.h" +#include "regex2.h" + +static int nope = 0; /* for use in asserts; shuts lint up */ + +/* macros for manipulating states, small version */ +#define states long +#define states1 states /* for later use in regexec() decision */ +#define CLEAR(v) ((v) = 0) +#define SET0(v, n) ((v) &= ~(1 << (n))) +#define SET1(v, n) ((v) |= 1 << (n)) +#define ISSET(v, n) ((v) & (1 << (n))) +#define ASSIGN(d, s) ((d) = (s)) +#define EQ(a, b) ((a) == (b)) +#define STATEVARS int dummy /* dummy version */ +#define STATESETUP(m, n) /* nothing */ +#define STATETEARDOWN(m) /* nothing */ +#define SETUP(v) ((v) = 0) +#define onestate int +#define INIT(o, n) ((o) = (unsigned)1 << (n)) +#define INC(o) ((o) <<= 1) +#define ISSTATEIN(v, o) ((v) & (o)) +/* some abbreviations; note that some of these know variable names! */ +/* do "if I'm here, I can also be there" etc without branches */ +#define FWD(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) << (n)) +#define BACK(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) >> (n)) +#define ISSETBACK(v, n) ((v) & ((unsigned)here >> (n))) +/* function names */ +#define SNAMES /* engine.c looks after details */ + +#include "engine.c" + +/* now undo things */ +#undef states +#undef CLEAR +#undef SET0 +#undef SET1 +#undef ISSET +#undef ASSIGN +#undef EQ +#undef STATEVARS +#undef STATESETUP +#undef STATETEARDOWN +#undef SETUP +#undef onestate +#undef INIT +#undef INC +#undef ISSTATEIN +#undef FWD +#undef BACK +#undef ISSETBACK +#undef SNAMES + +/* macros for manipulating states, large version */ +#define states char * +#define CLEAR(v) memset(v, 0, m->g->nstates) +#define SET0(v, n) ((v)[n] = 0) +#define SET1(v, n) ((v)[n] = 1) +#define ISSET(v, n) ((v)[n]) +#define ASSIGN(d, s) memcpy(d, s, m->g->nstates) +#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0) +#define STATEVARS int vn; char *space +#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \ + if ((m)->space == NULL) return(REG_ESPACE); \ + (m)->vn = 0; } +#define STATETEARDOWN(m) { free((m)->space); } +#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates]) +#define onestate int +#define INIT(o, n) ((o) = (n)) +#define INC(o) ((o)++) +#define ISSTATEIN(v, o) ((v)[o]) +/* some abbreviations; note that some of these know variable names! */ +/* do "if I'm here, I can also be there" etc without branches */ +#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here]) +#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here]) +#define ISSETBACK(v, n) ((v)[here - (n)]) +/* function names */ +#define LNAMES /* flag */ + +#include "engine.c" + +/* + - regexec - interface for matching + = extern int regexec(const regex_t *, const char *, size_t, \ + = regmatch_t [], int); + = #define REG_NOTBOL 00001 + = #define REG_NOTEOL 00002 + = #define REG_STARTEND 00004 + = #define REG_TRACE 00400 // tracing of execution + = #define REG_LARGE 01000 // force large representation + = #define REG_BACKR 02000 // force use of backref code + * + * We put this here so we can exploit knowledge of the state representation + * when choosing which matcher to call. Also, by this point the matchers + * have been prototyped. + */ +int /* 0 success, REG_NOMATCH failure */ +regexec(preg, string, nmatch, pmatch, eflags) +const regex_t *preg; +const char *string; +size_t nmatch; +regmatch_t pmatch[]; +int eflags; +{ + register struct re_guts *g = preg->re_g; +#ifdef REDEBUG +# define GOODFLAGS(f) (f) +#else +# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND)) +#endif + + if (preg->re_magic != MAGIC1 || g->magic != MAGIC2) + return(REG_BADPAT); + assert(!(g->iflags&BAD)); + if (g->iflags&BAD) /* backstop for no-debug case */ + return(REG_BADPAT); + eflags = GOODFLAGS(eflags); + + if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE)) + return(smatcher(g, (char *)string, nmatch, pmatch, eflags)); + else + return(lmatcher(g, (char *)string, nmatch, pmatch, eflags)); +} diff --git a/src/backend/port/win32/regex/regexp.h b/src/backend/port/win32/regex/regexp.h new file mode 100644 index 00000000000..47c8e88fa69 --- /dev/null +++ b/src/backend/port/win32/regex/regexp.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1986 by University of Toronto. + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regexp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _REGEXP_H_ +#define _REGEXP_H_ + +/* + * Definitions etc. for regexp(3) routines. + * + * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], + * not the System V one. + */ +#define NSUBEXP 10 +typedef struct regexp { + char *startp[NSUBEXP]; + char *endp[NSUBEXP]; + char regstart; /* Internal use only. */ + char reganch; /* Internal use only. */ + char *regmust; /* Internal use only. */ + int regmlen; /* Internal use only. */ + char program[1]; /* Unwarranted chumminess with compiler. */ +} regexp; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +regexp *regcomp __P((const char *)); +int regexec __P((const regexp *, const char *)); +void regsub __P((const regexp *, const char *, char *)); +void regerror __P((const char *)); +__END_DECLS + +#endif /* !_REGEXP_H_ */ diff --git a/src/backend/port/win32/regex/regfree.c b/src/backend/port/win32/regex/regfree.c new file mode 100644 index 00000000000..580fb758c06 --- /dev/null +++ b/src/backend/port/win32/regex/regfree.c @@ -0,0 +1,80 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regfree.c 8.3 (Berkeley) 3/20/94 + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <regex.h> + +#include "utils.h" +#include "regex2.h" + +/* + - regfree - free everything + = extern void regfree(regex_t *); + */ +void +regfree(preg) +regex_t *preg; +{ + register struct re_guts *g; + + if (preg->re_magic != MAGIC1) /* oops */ + return; /* nice to complain, but hard */ + + g = preg->re_g; + if (g == NULL || g->magic != MAGIC2) /* oops again */ + return; + preg->re_magic = 0; /* mark it invalid */ + g->magic = 0; /* mark it invalid */ + + if (g->strip != NULL) + free((char *)g->strip); + if (g->sets != NULL) + free((char *)g->sets); + if (g->setbits != NULL) + free((char *)g->setbits); + if (g->must != NULL) + free(g->must); + free((char *)g); +} diff --git a/src/backend/port/win32/regex/utils.h b/src/backend/port/win32/regex/utils.h new file mode 100644 index 00000000000..6fb1e8970ed --- /dev/null +++ b/src/backend/port/win32/regex/utils.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)utils.h 8.3 (Berkeley) 3/20/94 + */ + +/* utility definitions */ +#define DUPMAX 100000000 /* xxx is this right? */ +#define INFINITY (DUPMAX + 1) +#define NC (CHAR_MAX - CHAR_MIN + 1) +typedef unsigned char uch; + +/* switch off assertions (if not already off) if no REDEBUG */ +#ifndef REDEBUG +#ifndef NDEBUG +#define NDEBUG /* no assertions please */ +#endif +#endif +#include <assert.h> + +/* for old systems with bcopy() but no memmove() */ +#ifdef USEBCOPY +#define memmove(d, s, c) bcopy(s, d, c) +#endif diff --git a/src/backend/port/win32/rusagestub.h b/src/backend/port/win32/rusagestub.h new file mode 100644 index 00000000000..ddd0e086a44 --- /dev/null +++ b/src/backend/port/win32/rusagestub.h @@ -0,0 +1,29 @@ +/*------------------------------------------------------------------------- + * + * rusagestub.h-- + * Stubs for getrusage(3). + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: rusagestub.h,v 1.1.1.1 1996/07/09 06:21:46 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef RUSAGESTUB_H +#define RUSAGESTUB_H + +#include <sys/time.h> /* for struct timeval */ +#include <limits.h> /* for CLK_TCK */ + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN -1 + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ +}; + +extern int getrusage(int who, struct rusage *rusage); + +#endif /* RUSAGESTUB_H */ diff --git a/src/backend/port/win32/sys/cdefs.h b/src/backend/port/win32/sys/cdefs.h new file mode 100644 index 00000000000..d98596bb8f5 --- /dev/null +++ b/src/backend/port/win32/sys/cdefs.h @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cdefs.h 8.7 (Berkeley) 1/21/94 + */ + +#ifndef _CDEFS_H_ +#define _CDEFS_H_ + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS }; +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif + +/* + * The __CONCAT macro is used to concatenate parts of symbol names, e.g. + * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. + * The __CONCAT macro is a bit tricky -- make sure you don't put spaces + * in between its arguments. __CONCAT can also concatenate double-quoted + * strings produced by the __STRING macro, but this only works with ANSI C. + */ +#if defined(__STDC__) || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define __const const /* define reserved names to standard */ +#define __signed signed +#define __volatile volatile +#if defined(__cplusplus) +#define __inline inline /* convert to C++ keyword */ +#else +#ifndef __GNUC__ +#define __inline /* delete GCC keyword */ +#endif /* !__GNUC__ */ +#endif /* !__cplusplus */ + +#else /* !(__STDC__ || __cplusplus) */ +#define __P(protos) () /* traditional C preprocessor */ +#define __CONCAT(x,y) x/**/y +#define __STRING(x) "x" + +#ifndef __GNUC__ +#define __const /* delete pseudo-ANSI C keywords */ +#define __inline +#define __signed +#define __volatile +/* + * In non-ANSI C environments, new programs will want ANSI-only C keywords + * deleted from the program and old programs will want them left alone. + * When using a compiler other than gcc, programs using the ANSI C keywords + * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. + * When using "gcc -traditional", we assume that this is the intent; if + * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. + */ +#ifndef NO_ANSI_KEYWORDS +#define const /* delete ANSI C keywords */ +#define inline +#define signed +#define volatile +#endif +#endif /* !__GNUC__ */ +#endif /* !(__STDC__ || __cplusplus) */ + +/* + * GCC1 and some versions of GCC2 declare dead (non-returning) and + * pure (no side effects) functions using "volatile" and "const"; + * unfortunately, these then cause warnings under "-ansi -pedantic". + * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of + * these work for GNU C++ (modulo a slight glitch in the C++ grammar + * in the distribution version of 2.5.5). + */ +#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#define __dead __volatile +#define __pure __const +#endif +#endif + +/* Delete pseudo-keywords wherever they are not available or needed. */ +#ifndef __dead +#define __dead +#define __pure +#endif + +typedef long off_t; + +#endif /* !_CDEFS_H_ */ diff --git a/src/backend/port/win32/sys/file.h b/src/backend/port/win32/sys/file.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/backend/port/win32/sys/file.h @@ -0,0 +1 @@ + diff --git a/src/backend/port/win32/sys/ipc.h b/src/backend/port/win32/sys/ipc.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/backend/port/win32/sys/ipc.h @@ -0,0 +1 @@ + diff --git a/src/backend/port/win32/sys/param.h b/src/backend/port/win32/sys/param.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/backend/port/win32/sys/param.h @@ -0,0 +1 @@ + diff --git a/src/backend/port/win32/sys/sem.h b/src/backend/port/win32/sys/sem.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/backend/port/win32/sys/sem.h @@ -0,0 +1 @@ + diff --git a/src/backend/port/win32/sys/shm.h b/src/backend/port/win32/sys/shm.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/backend/port/win32/sys/shm.h @@ -0,0 +1 @@ + diff --git a/src/backend/port/win32/sys/time.h b/src/backend/port/win32/sys/time.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/backend/port/win32/sys/time.h @@ -0,0 +1 @@ + |