Change pgsql to use regsexp.
authorChris Hanson <org/chris-hanson/cph>
Wed, 3 May 2017 07:57:21 +0000 (00:57 -0700)
committerChris Hanson <org/chris-hanson/cph>
Wed, 3 May 2017 07:57:21 +0000 (00:57 -0700)
src/runtime/pgsql.scm

index f224583a6c8fc6d78ed5032c230453acb6e94cfb..126687d8fd640bf8f882fe59b0005683cc598acd 100644 (file)
@@ -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))))
 \f
 (define (open-pgsql-conn parameters #!optional wait?)
   (guarantee-pgsql-available)