From 2af0d090f1bb26111ee19e5ab40ae00ed46313fb Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Wed, 13 May 1998 03:27:07 +0000
Subject: [PATCH] Fix to allow \f \ to make spaces as delimiter.

---
 src/bin/psql/psql.c        |  4 +++-
 src/bin/psql/stringutils.c | 13 +++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index a13ac63545e..0542d3951e9 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.142 1998/05/12 23:05:12 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.143 1998/05/13 03:27:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1988,6 +1988,8 @@ HandleSlashCmds(PsqlSettings *pset,
 
 				if (optarg)
 					fs = optarg;
+				if (optarg && !*optarg && strlen(cmd) > 2)
+					fs = cmd + 2;
 				if (pset->opt.fieldSep)
 					free(pset->opt.fieldSep);
 				if (!(pset->opt.fieldSep = strdup(fs)))
diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c
index 62d8fef5747..2b083ad2271 100644
--- a/src/bin/psql/stringutils.c
+++ b/src/bin/psql/stringutils.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.13 1998/02/26 04:39:13 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.14 1998/05/13 03:27:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -56,11 +56,20 @@ leftTrim(char *s)
 char *
 rightTrim(char *s)
 {
-	char	   *sEnd;
+	char	   *sEnd, *bsEnd;
+	bool		in_bs = false;
 
 	sEnd = s + strlen(s) - 1;
 	while (sEnd >= s && isspace(*sEnd))
 		sEnd--;
+	bsEnd = sEnd;
+	while (bsEnd >= s && *bsEnd == '\\')
+	{
+		in_bs = (in_bs == false);
+		bsEnd--;
+	}
+	if (in_bs && *sEnd)
+		sEnd++;
 	if (sEnd < s)
 		s[0] = '\0';
 	else
-- 
GitLab