From d800dd8da3bf9b2d1f0eec80cd128ab38ff764c4 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 3 May 2017 00:57:21 -0700 Subject: [PATCH] Change pgsql to use regsexp. --- src/runtime/pgsql.scm | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/runtime/pgsql.scm b/src/runtime/pgsql.scm index f224583a6..126687d8f 100644 --- a/src/runtime/pgsql.scm +++ b/src/runtime/pgsql.scm @@ -204,17 +204,23 @@ USA. (if string (begin (write-string ": " port) - (let ((regs - (re-string-match "\\`\\s *\\(error:\\)?\\s *\\(.*\\)\\s *\\'" - string - #t))) - (if regs - (write-string string - port - (re-match-start-index 2 regs) - (re-match-end-index 2 regs)) - (write-string string port)))) + (write-string + (let ((result (regsexp-match-string error-regsexp string))) + (if result + (cdr (assv 'message (cddr result))) + string)) + port)) (write-string "." port))) + +(define error-regsexp + (compile-regsexp + '(seq (string-start) + (* (char-set whitespace)) + (? (string-ci "error:")) + (* (char-set whitespace)) + (group message (* (any-char))) + (* (char-set whitespace)) + (string-end)))) (define (open-pgsql-conn parameters #!optional wait?) (guarantee-pgsql-available) -- 2.25.1