diff pwm.c @ 13:cf81eb0c2d5a

Warn before quitting if there are unsaved changes If there are unsaved changes emit a warning when the quit command is used. Only quit if the quit command is used twice with no other command in between. Add a new Quit command which immediatly quits pwm without a warning.
author Guido Berhoerster <guido+pwm@berhoerster.name>
date Mon, 07 Aug 2017 16:59:47 +0200
parents 0b1bce8db371
children a07665727c19
line wrap: on
line diff
--- a/pwm.c	Thu Aug 03 10:22:07 2017 +0200
+++ b/pwm.c	Mon Aug 07 16:59:47 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Guido Berhoerster <guido+pwm@berhoerster.name>
+ * Copyright (C) 2017 Guido Berhoerster <guido+pwm@berhoerster.name>
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -69,6 +69,7 @@
 	int		i;
 
 	for (;;) {
+		cmd = NULL;
 		if (fgets(buf, (int)sizeof (buf), stdin) == NULL) {
 			if (ferror(stdin)) {
 				/* error */
@@ -146,6 +147,10 @@
 		}
 
 next:
+		if (cmd != NULL) {
+			ctx->prev_cmd = cmd->full_cmd;
+		}
+
 		for (i = 0; i < argc; i++) {
 			free(argv[i]);
 		}