From a060d5bedf67aec472bd3bfc55750ee98628b8e7 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 29 Aug 1998 04:05:46 +0000 Subject: [PATCH] Hello! Here is a new patch for libpq, to make it work on Win32 again (since the latest modifications broke it a little). Please also add the file "libpq.rc" to the interfaces/libpq directory. This will allow version-stamping of the generated DLL file, so that automatic install programs (and interested users) can determine the version of the file. The file is currently set as "prerelease". Before the release, somebody should change the line "FILEFLAGS VS_FF_PRERELEASE" to "FILEFLAGS 0". That information should probably go into toos\RELEASE_CHANGES. The patch is against the cvs as of ~ 1998-08-26 14:30 CEST. //Magnus --- src/bin/psql/psql.c | 21 +++++++++++++-------- src/include/c.h | 4 +++- src/include/libpq/pqcomm.h | 9 +++++++-- src/interfaces/libpq/libpq-fe.h | 8 +++++++- src/interfaces/libpq/win32.mak | 22 +++++++++++++++++----- 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index d9c3fd1e5e..715fb50a2c 100644 --- a/src/bin/psql/psql.c +++ b/src/bin/psql/psql.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.156 1998/08/27 13:25:18 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.157 1998/08/29 04:05:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,7 +89,8 @@ char *__progname = "psql"; #define PROMPT_READY '=' #define PROMPT_CONTINUE '-' #define PROMPT_COMMENT '*' -#define PROMPT_QUOTE '\'' +#define PROMPT_SINGLEQUOTE '\'' +#define PROMPT_DOUBLEQUOTE '"' /* Backslash command handling: * 0 - send currently constructed query to backend (i.e. we got a \g) @@ -2310,7 +2311,7 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) /* We've reached the end of our command input. */ bool success; - bool in_quote; + char in_quote; /* == 0 for no in_quote */ bool was_bslash; /* backslash */ int paren_level; char *query_start; @@ -2380,8 +2381,10 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) { if (interactive && !pset->quiet) { - if (in_quote) - pset->prompt[strlen(pset->prompt) - 3] = PROMPT_QUOTE; + if (in_quote && in_quote == PROMPT_SINGLEQUOTE) + pset->prompt[strlen(pset->prompt) - 3] = PROMPT_SINGLEQUOTE; + else if (in_quote && in_quote == PROMPT_DOUBLEQUOTE) + pset->prompt[strlen(pset->prompt) - 3] = PROMPT_DOUBLEQUOTE; else if (xcomment != NULL) pset->prompt[strlen(pset->prompt) - 3] = PROMPT_COMMENT; else if (query[0] != '\0' && !querySent) @@ -2500,7 +2503,7 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) was_bslash = true; /* inside a quote? */ - if (in_quote && (line[i] != '\'' || was_bslash)) + if (in_quote && (line[i] != in_quote || was_bslash)) /* do nothing */ ; else if (xcomment != NULL) /* inside an extended * comment? */ @@ -2548,8 +2551,10 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) line[i] = '\0'; /* remove comment */ break; } - else if (line[i] == '\'') - in_quote ^= 1; + else if (in_quote && line[i] == in_quote) + in_quote = false; + else if (!in_quote && (line[i] == '\'' || line[i] == '"')) + in_quote = line[i]; /* semi-colon? then send query now */ else if (!paren_level && line[i] == ';') { diff --git a/src/include/c.h b/src/include/c.h index 65eb4266ae..3d7c08ddd4 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.43 1998/08/25 21:04:41 scrappy Exp $ + * $Id: c.h,v 1.44 1998/08/29 04:05:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -133,7 +133,9 @@ typedef char *Pointer; * Example: * extern const Version RomVersion; */ +#ifndef WIN32 #define const /* const */ +#endif /* * signed -- diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h index a9bb120552..e3b5a71b83 100644 --- a/src/include/libpq/pqcomm.h +++ b/src/include/libpq/pqcomm.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pqcomm.h,v 1.27 1998/08/22 04:24:18 momjian Exp $ + * $Id: pqcomm.h,v 1.28 1998/08/29 04:05:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,20 +15,25 @@ #include #include +#ifdef WIN32 +#include +#else #include #include #include +#endif #include "c.h" - /* Define a generic socket address type. */ typedef union SockAddr { struct sockaddr sa; struct sockaddr_in in; +#ifndef WIN32 struct sockaddr_un un; +#endif } SockAddr; diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 4cd45fca6c..0e2112c159 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.38 1998/08/17 03:50:40 scrappy Exp $ + * $Id: libpq-fe.h,v 1.39 1998/08/29 04:05:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,9 +21,13 @@ extern "C" #include /* these wouldn't need to be included if PGSockAddr weren't exported: */ +#ifdef WIN32 +#include +#else #include #include #include +#endif /* ---------------- * include stuff common to fe and be * ---------------- @@ -141,7 +145,9 @@ extern "C" { struct sockaddr sa; struct sockaddr_in in; +#ifndef WIN32 struct sockaddr_un un; +#endif } PGSockAddr; /* large-object-access data ... allocated only if large-object code is used. diff --git a/src/interfaces/libpq/win32.mak b/src/interfaces/libpq/win32.mak index 4c50caf5e4..41d28189dc 100644 --- a/src/interfaces/libpq/win32.mak +++ b/src/interfaces/libpq/win32.mak @@ -11,6 +11,7 @@ NULL=nul !ENDIF CPP=cl.exe +RSC=rc.exe OUTDIR=.\Release INTDIR=.\Release @@ -28,10 +29,14 @@ CLEAN : -@erase "$(INTDIR)\fe-lobj.obj" -@erase "$(INTDIR)\fe-misc.obj" -@erase "$(INTDIR)\fe-print.obj" - -@erase "$(OUTDIR)\libpqdll.obj" - -@erase "$(INTDIR)\vc50.idb" + -@erase "$(OUTDIR)\libpqdll.obj" -@erase "$(OUTDIR)\libpq.lib" - -@erase "$(OUTDIR)\libpq.dll" + -@erase "$(OUTDIR)\libpq.dll" + -@erase "$(OUTDIR)\libpq.res" + -@erase "vc50.pch" + -@erase "$(OUTDIR)\libpq.pch" + -@erase "$(OUTDIR)\libpqdll.exp" + -@erase "$(OUTDIR)\libpqdll.lib" "$(OUTDIR)" : if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" @@ -53,6 +58,8 @@ LIB32_OBJS= \ "$(INTDIR)\fe-misc.obj" \ "$(INTDIR)\fe-print.obj" +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res" + LINK32=link.exe LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib wsock32.lib\ @@ -61,7 +68,8 @@ LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ /implib:"$(OUTDIR)\libpqdll.lib" /def:libpqdll.def LINK32_OBJS= \ "$(INTDIR)\libpqdll.obj" \ - "$(OUTDIR)\libpq.lib" + "$(OUTDIR)\libpq.lib" \ + "$(OUTDIR)\libpq.res" "$(OUTDIR)\libpq.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) @@ -69,7 +77,11 @@ LINK32_OBJS= \ $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) << -"$(OUTDIR)\libpq.dll" : "$(OUTDIR)" "$(OUTDIR)\libpqdll.obj" "$(INTDIR)\libpqdll.obj" +"$(INTDIR)\libpq.res" : "$(INTDIR)" libpq.rc + $(RSC) $(RSC_PROJ) libpq.rc + + +"$(OUTDIR)\libpq.dll" : "$(OUTDIR)" "$(OUTDIR)\libpqdll.obj" "$(INTDIR)\libpqdll.obj" "$(INTDIR)\libpq.res" $(LINK32) @<< $(LINK32_FLAGS) $(LINK32_OBJS) <<