Add -Wswitch-enum
[openssl.git] / crypto / ui / ui_openssl.c
index 98fb0e192efcb7637d8f996cf93b87210fef8161..bdd07f90d3c79c829c0a597340dd3d82a58feea1 100644 (file)
@@ -219,7 +219,10 @@ static int write_string(UI *ui, UI_STRING *uis)
         fputs(UI_get0_output_string(uis), tty_out);
         fflush(tty_out);
         break;
-    default:
+    case UIT_NONE:
+    case UIT_PROMPT:
+    case UIT_VERIFY:
+    case UIT_BOOLEAN:
         break;
     }
     return 1;
@@ -256,7 +259,9 @@ static int read_string(UI *ui, UI_STRING *uis)
             return 0;
         }
         break;
-    default:
+    case UIT_NONE:
+    case UIT_INFO:
+    case UIT_ERROR:
         break;
     }
     return 1;
@@ -305,23 +310,26 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
     if (is_a_tty) {
         DWORD numread;
 #  if defined(CP_UTF8)
-        WCHAR wresult[BUFSIZ];
+        if (GetEnvironmentVariableW(L"OPENSSL_WIN32_UTF8", NULL, 0) != 0) {
+            WCHAR wresult[BUFSIZ];
 
-        if (ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE),
+            if (ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE),
                          wresult, maxsize, &numread, NULL)) {
-            if (numread >= 2 &&
-                wresult[numread-2] == L'\r' && wresult[numread-1] == L'\n') {
-                wresult[numread-2] = L'\n';
-                numread--;
+                if (numread >= 2 &&
+                    wresult[numread-2] == L'\r' &&
+                    wresult[numread-1] == L'\n') {
+                    wresult[numread-2] = L'\n';
+                    numread--;
+                }
+                wresult[numread] = '\0';
+                if (WideCharToMultiByte(CP_UTF8, 0, wresult, -1,
+                                        result, sizeof(result), NULL, 0) > 0)
+                    p = result;
+
+                OPENSSL_cleanse(wresult, sizeof(wresult));
             }
-            wresult[numread] = '\0';
-            if (WideCharToMultiByte(CP_UTF8, 0, wresult, -1,
-                                    result, sizeof(result), NULL, 0) > 0)
-                p = result;
-
-            OPENSSL_cleanse(wresult, sizeof(wresult));
-        }
-#  else
+        } else
+#  endif
         if (ReadConsoleA(GetStdHandle(STD_INPUT_HANDLE),
                          result, maxsize, &numread, NULL)) {
             if (numread >= 2 &&
@@ -332,7 +340,6 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
             result[numread] = '\0';
             p = result;
         }
-#  endif
     } else
 # elif defined(OPENSSL_SYS_MSDOS)
     if (!echo) {