From 718bb2cc9c8483bed143d071aa000f9027c74a41 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sun, 20 Feb 2000 14:28:28 +0000 Subject: Moved psql \eset and \eshow to \encoding Improved psql's Ctrl-C handling Fixed configure test for sigsetjmp that now even recognizes it if it's a macro --- src/bin/psql/mainloop.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'src/bin/psql/mainloop.c') diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index 28d7b58bb06..9b3834cca7d 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.21 2000/02/20 02:37:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.22 2000/02/20 14:28:20 petere Exp $ */ #include "postgres.h" #include "mainloop.h" @@ -16,6 +16,11 @@ #include "common.h" #include "command.h" +#ifndef WIN32 +#include + +sigjmp_buf main_loop_jmp; +#endif /* @@ -88,6 +93,40 @@ MainLoop(FILE *source) /* main loop to get queries and execute them */ while (1) { + /* + * Welcome code for Control-C + */ + if (cancel_pressed) + { + cancel_pressed = false; + if (!pset.cur_cmd_interactive) + { + /* + * You get here if you stopped a script with Ctrl-C and a query + * cancel was issued. In that case we don't do the longjmp, so + * the query routine can finish nicely. + */ + successResult = EXIT_USER; + break; + } + } +#ifndef WIN32 + if (sigsetjmp(main_loop_jmp, 1) != 0) + { + /* got here with longjmp */ + if (pset.cur_cmd_interactive) + { + fputc('\n', stdout); + resetPQExpBuffer(query_buf); + } + else + { + successResult = EXIT_USER; + break; + } + } +#endif + if (slashCmdStatus == CMD_NEWEDIT) { /* @@ -213,7 +252,7 @@ MainLoop(FILE *source) /* echo back if flag is set */ var = GetVariable(pset.vars, "ECHO"); - if (var && strcmp(var, "all")==0) + if (!pset.cur_cmd_interactive && var && strcmp(var, "all")==0) puts(line); fflush(stdout); -- cgit v1.2.3