diff --git a/src/ConvertUTF.cpp b/src/ConvertUTF.cpp index f7e5915d..c99b7d33 100644 --- a/src/ConvertUTF.cpp +++ b/src/ConvertUTF.cpp @@ -268,9 +268,9 @@ ConversionResult ConvertUTF16toUTF8 ( target -= bytesToWrite; result = targetExhausted; break; } switch (bytesToWrite) { /* note: everything falls through. */ - case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; // Intentional fallthrough + case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; // Intentional fallthrough + case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; // Intentional fallthrough case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); } target += bytesToWrite; @@ -299,10 +299,9 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) { switch (length) { default: return false; /* Everything else falls through when "true"... */ - case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; // Intentional fallthrough + case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; // Intentional fallthrough case 2: if ((a = (*--srcptr)) > 0xBF) return false; - switch (*source) { /* no fall-through in this inner switch */ case 0xE0: if (a < 0xA0) return false; break; @@ -311,7 +310,7 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) { case 0xF4: if (a > 0x8F) return false; break; default: if (a < 0x80) return false; } - + // Intentional fallthrough case 1: if (*source >= 0x80 && *source < 0xC2) return false; } if (*source > 0xF4) return false; @@ -355,11 +354,11 @@ ConversionResult ConvertUTF8toUTF16 ( * The cases all fall through. See "Note A" below. */ switch (extraBytesToRead) { - case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ - case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ - case 3: ch += *source++; ch <<= 6; - case 2: ch += *source++; ch <<= 6; - case 1: ch += *source++; ch <<= 6; + case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ // Intentional fallthrough + case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ // Intentional fallthrough + case 3: ch += *source++; ch <<= 6; // Intentional fallthrough + case 2: ch += *source++; ch <<= 6; // Intentional fallthrough + case 1: ch += *source++; ch <<= 6; // Intentional fallthrough case 0: ch += *source++; } ch -= offsetsFromUTF8[extraBytesToRead]; @@ -446,9 +445,9 @@ ConversionResult ConvertUTF32toUTF8 ( target -= bytesToWrite; result = targetExhausted; break; } switch (bytesToWrite) { /* note: everything falls through. */ - case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; // Intentional fallthrough + case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; // Intentional fallthrough + case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; // Intentional fallthrough case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]); } target += bytesToWrite; @@ -481,11 +480,11 @@ ConversionResult ConvertUTF8toUTF32 ( * The cases all fall through. See "Note A" below. */ switch (extraBytesToRead) { - case 5: ch += *source++; ch <<= 6; - case 4: ch += *source++; ch <<= 6; - case 3: ch += *source++; ch <<= 6; - case 2: ch += *source++; ch <<= 6; - case 1: ch += *source++; ch <<= 6; + case 5: ch += *source++; ch <<= 6; // Intentional fallthrough + case 4: ch += *source++; ch <<= 6; // Intentional fallthrough + case 3: ch += *source++; ch <<= 6; // Intentional fallthrough + case 2: ch += *source++; ch <<= 6; // Intentional fallthrough + case 1: ch += *source++; ch <<= 6; // Intentional fallthrough case 0: ch += *source++; } ch -= offsetsFromUTF8[extraBytesToRead]; diff --git a/src/linenoise.cpp b/src/linenoise.cpp index 8ee8984d..42c8638d 100644 --- a/src/linenoise.cpp +++ b/src/linenoise.cpp @@ -624,7 +624,20 @@ struct PromptBase { // a convenience struct for grouping prompt info int promptPreviousLen; // help erasing int promptErrorCode; // error code (invalid UTF-8) or zero - PromptBase() : promptPreviousInputLen(0) {} + PromptBase() : + promptText(0), + promptCharWidths(nullptr), + promptChars(0), + promptBytes(0), + promptExtraLines(0), + promptIndentation(0), + promptLastLinePosition(0), + promptPreviousInputLen(0), + promptCursorRowOffset(0), + promptScreenColumns(0), + promptPreviousLen(0), + promptErrorCode(0) + {} bool write() { if (write32(1, promptText.get(), promptBytes) == -1) return false; @@ -727,7 +740,7 @@ struct DynamicPrompt : public PromptBase { int direction; // current search direction, 1=forward, -1=reverse DynamicPrompt(PromptBase& pi, int initialDirection) - : searchTextLen(0), direction(initialDirection) { + : searchCharWidths(nullptr), searchTextLen(0), direction(initialDirection) { promptScreenColumns = pi.promptScreenColumns; promptCursorRowOffset = 0; Utf32String emptyString(1);