diff --git a/kotstd/include/CodedOutputStream.kt b/kotstd/include/CodedOutputStream.kt index 7470239a2ba..9c40747b99c 100644 --- a/kotstd/include/CodedOutputStream.kt +++ b/kotstd/include/CodedOutputStream.kt @@ -145,7 +145,7 @@ class CodedOutputStream(val buffer: ByteArray) { val res = ByteArray(10) var resSize = 0 - while(curValue != 0L) { + do { // encode current 7 bits var curByte = (curValue and WireFormat.VARINT_INFO_BITS_MASK.toLong()) @@ -159,7 +159,7 @@ class CodedOutputStream(val buffer: ByteArray) { res[resSize] = curByte.toByte() resSize++ - } + } while(curValue != 0L) output.write(res, 0, resSize) } diff --git a/proto/compiler/google/src/google/protobuf/compiler/kotlin/src/kotlin_field_generator.cc b/proto/compiler/google/src/google/protobuf/compiler/kotlin/src/kotlin_field_generator.cc index 63db2906335..07a8c27a5cf 100644 --- a/proto/compiler/google/src/google/protobuf/compiler/kotlin/src/kotlin_field_generator.cc +++ b/proto/compiler/google/src/google/protobuf/compiler/kotlin/src/kotlin_field_generator.cc @@ -165,7 +165,7 @@ void FieldGenerator::generateSerializationForPacked(io::Printer *printer, bool i singleFieldGen.generateSerializationCode(printer, isRead, /* noTag = */ true, /* isField = */ false); // increment iterator - printer->Print("i += 1"); + printer->Print("i += 1\n"); printer->Outdent(); // while-loop printer->Print("}\n"); diff --git a/proto/compiler/runtime/src/main/kotlin/CodedOutputStream.kt b/proto/compiler/runtime/src/main/kotlin/CodedOutputStream.kt index 7470239a2ba..9c40747b99c 100644 --- a/proto/compiler/runtime/src/main/kotlin/CodedOutputStream.kt +++ b/proto/compiler/runtime/src/main/kotlin/CodedOutputStream.kt @@ -145,7 +145,7 @@ class CodedOutputStream(val buffer: ByteArray) { val res = ByteArray(10) var resSize = 0 - while(curValue != 0L) { + do { // encode current 7 bits var curByte = (curValue and WireFormat.VARINT_INFO_BITS_MASK.toLong()) @@ -159,7 +159,7 @@ class CodedOutputStream(val buffer: ByteArray) { res[resSize] = curByte.toByte() resSize++ - } + } while(curValue != 0L) output.write(res, 0, resSize) }