projects/pwm

changeset 21:ee4d36c85287

Make EOF in interactive mode equivalent to the q command
author Guido Berhoerster <guido+pwm@berhoerster.name>
date Wed Sep 06 16:41:58 2017 +0200 (2017-09-06)
parents efef93e54c5f
children ec01c579024a
files pwm.1.xml pwm.c
line diff
     1.1 --- a/pwm.1.xml	Wed Sep 06 13:56:11 2017 +0200
     1.2 +++ b/pwm.1.xml	Wed Sep 06 16:41:58 2017 +0200
     1.3 @@ -528,6 +528,9 @@
     1.4              </cmdsynopsis>
     1.5              <cmdsynopsis>
     1.6                <command>q</command>
     1.7 +            </cmdsynopsis>
     1.8 +            <cmdsynopsis>
     1.9 +              <keysym>end-of-file</keysym>
    1.10                <sbr/>
    1.11              </cmdsynopsis>
    1.12              <para>Quit <command>pwm</command>.  If running in interactive mode
     2.1 --- a/pwm.c	Wed Sep 06 13:56:11 2017 +0200
     2.2 +++ b/pwm.c	Wed Sep 06 16:41:58 2017 +0200
     2.3 @@ -140,7 +140,14 @@
     2.4  			/* line was truncated in non-interactive mode */
     2.5  			fprintf(stderr, "line too long\n");
     2.6  			goto out;
     2.7 -		case IO_EOF:	/* FALLTHROUGH */
     2.8 +		case IO_EOF:
     2.9 +			if (is_interactive) {
    2.10 +				/* treat as "q" command */
    2.11 +				strcpy(buf, "q\n");
    2.12 +				io_retval = IO_OK;
    2.13 +				break;
    2.14 +			}
    2.15 +			/* FALLTHORUGH */
    2.16  		case IO_SIGNAL:
    2.17  			if (ctx->unsaved_changes) {
    2.18  				pwfile_write_autosave_file(ctx);