intirain преди 4 години
родител
ревизия
7531e77540
променени са 4 файла, в които са добавени 15 реда и са изтрити 9 реда
  1. 1 1
      Makefile
  2. 9 5
      cmd.c
  3. 2 2
      include/vcc/version.h
  4. 3 1
      main.c

+ 1 - 1
Makefile

@@ -1,6 +1,6 @@
 VCC_MAJOR 		= 1
 VCC_MINOR 		= 10
-VCC_PATCH 		= 2
+VCC_PATCH 		= 3
 VCC_STR 		= -rc 
 
 VCC_COMPILE_TIME 	= $(shell date)

+ 9 - 5
cmd.c

@@ -455,11 +455,12 @@ static char const warn_msg[] = {
 
 
 static int show_warn_msg(void) {
-	int c;
+	char c;
+
+	fprintf(stderr, "%s", warn_msg);
 
 	for (;;) {
-		fprintf(stderr, warn_msg);
-		scanf("%d", &c);
+		read(0, &c, 1);
 
 		if (c == 'y' || c == 'Y') 
 			return 0;
@@ -470,7 +471,7 @@ static int show_warn_msg(void) {
 		printf("Please answer y / n\n");
 	}
 
-	return 0;
+	return 1;
 }
 
 
@@ -481,9 +482,12 @@ int do_cmd_encry(char *s) {
 
 	memset(msg, 0, MSG_SIZE);
 
-	if (!did_warn) 
+	if (!did_warn) {
+		did_warn = 1;
+
 		if (show_warn_msg()) 
 			return 0;
+	}
 
 	fprintf(stderr, "Message: ");
 	scanf("%s", msg);

+ 2 - 2
include/vcc/version.h

@@ -1,2 +1,2 @@
-#define VCC_VERSION "VCC 1.10.2 Sat Apr 16 20:07:12 CST 2022 root"
-#define VCC_SEMVER "vcc 1.10.2-rc "
+#define VCC_VERSION "VCC 1.10.3 Sat Apr 16 20:23:49 CST 2022 root"
+#define VCC_SEMVER "vcc 1.10.3-rc "

+ 3 - 1
main.c

@@ -222,6 +222,7 @@ int main(int argc, char **argv) {
 	}
 
 	for (;;) {
+		memset(buf, 0, MSG_SIZE);
 		n = poll(fds, 2, rate);
 
 		if (n == -1) {
@@ -242,7 +243,8 @@ int main(int argc, char **argv) {
 		}
 
 		if (fds[0].revents & POLLIN) {
-			read(0, buf, MSG_SIZE);
+			if (read(0, buf, MSG_SIZE) == -1) 
+				continue;
 
 			do_handle_command(buf);
 		}