]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
ccode: Don't allow more than one consecutive empty lines in generated code
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 19 Nov 2018 13:25:14 +0000 (14:25 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 19 Nov 2018 15:02:12 +0000 (16:02 +0100)
ccode/valaccodewriter.vala

index a71e16c8974ebb3a89d19121a5e2bfd46182f727..21cc4172092b692df7f38e766904af965bf5fdc6 100644 (file)
@@ -61,6 +61,8 @@ public class Vala.CCodeWriter {
 
        /* at begin of line */
        private bool _bol = true;
+       /* at begin after empty line */
+       private bool _bael = false;
 
        public CCodeWriter (string filename, string? source_filename = null) {
                this.filename = filename;
@@ -195,6 +197,13 @@ public class Vala.CCodeWriter {
         * Writes a newline.
         */
        public void write_newline () {
+               if (!_bol) {
+                       _bael = false;
+               } else if (!_bael) {
+                       _bael = true;
+               } else {
+                       return;
+               }
                stream.putc ('\n');
                current_line_number++;
                _bol = true;