]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix leading whitespace in preprocessing directives
authorJürg Billeter <j@bitron.ch>
Fri, 3 Apr 2009 18:01:47 +0000 (20:01 +0200)
committerJürg Billeter <j@bitron.ch>
Fri, 3 Apr 2009 18:01:47 +0000 (20:01 +0200)
vala/valascanner.vala

index 068cff7976e972b97c3395a99154bbe3a0ea957d..ec9e907b021d10a32be2774b3354301d07a1885c 100644 (file)
@@ -786,7 +786,7 @@ public class Vala.Scanner {
 
        bool pp_whitespace () {
                bool found = false;
-               while (current < end && current[0] == ' ') {
+               while (current < end && current[0].isspace () && current[0] != '\n') {
                        found = true;
                        current++;
                        column++;
@@ -795,10 +795,11 @@ public class Vala.Scanner {
        }
 
        void pp_directive () {
-               do {
-                       current++;
-                       column++;
-               } while (current < end && current[0] == ' ');
+               // hash sign
+               current++;
+               column++;
+
+               pp_whitespace ();
 
                char* begin = current;
                int len = 0;
@@ -826,13 +827,16 @@ public class Vala.Scanner {
                        bool bol = false;
                        while (current < end) {
                                if (bol && current[0] == '#') {
+                                       // go back to begin of line
+                                       current -= column;
+                                       column = 0;
                                        return;
                                }
                                if (current[0] == '\n') {
                                        line++;
                                        column = 0;
                                        bol = true;
-                               } else if (current[0] != ' ') {
+                               } else if (!current[0].isspace ()) {
                                        bol = false;
                                }
                                current++;