[valadoc] libvaladoc: migrate to new string api
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] libvaladoc: migrate to new string api
- Date: Thu, 24 Feb 2011 01:31:57 +0000 (UTC)
commit 05898da628001474a1fbf925aa52039453dd867d
Author: Florian Brosch <flo brosch gmail com>
Date: Mon Feb 14 00:47:43 2011 +0100
libvaladoc: migrate to new string api
src/libvaladoc/documentation/wikiscanner.vala | 35 +++++++++++++------------
src/libvaladoc/errorreporter.vala | 2 +-
2 files changed, 19 insertions(+), 18 deletions(-)
---
diff --git a/src/libvaladoc/documentation/wikiscanner.vala b/src/libvaladoc/documentation/wikiscanner.vala
index 255fb60..9e1717c 100644
--- a/src/libvaladoc/documentation/wikiscanner.vala
+++ b/src/libvaladoc/documentation/wikiscanner.vala
@@ -30,9 +30,8 @@ public class Valadoc.WikiScanner : Object, Scanner {
private Parser _parser;
private string _content;
- private int _index;
+ private unowned string _index;
private bool _stop;
- private int _last_index;
private int _last_line;
private int _last_column;
private int _line;
@@ -49,7 +48,6 @@ public class Valadoc.WikiScanner : Object, Scanner {
public virtual void reset () {
_stop = false;
- _last_index = 0;
_last_line = 0;
_last_column = 0;
_line = 0;
@@ -61,10 +59,11 @@ public class Valadoc.WikiScanner : Object, Scanner {
_current_string.erase (0, -1);
}
- public void scan (string _content) throws ParserError {
- this._content = _content;
- for (_index = 0; !_stop && _index < _content.length; _index++) {
- unichar c = _content[_index];
+ public void scan (string content) throws ParserError {
+ this._content = content;
+
+ for (_index = _content; !_stop && _index.get_char () != 0; _index = _index.next_char ()) {
+ unichar c = _index.get_char ();
accept (c);
}
}
@@ -90,24 +89,28 @@ public class Valadoc.WikiScanner : Object, Scanner {
}
public virtual string get_line_content () {
- int i = _index;
- while (i > 0 && _content[i-1] != '\n') {
- i--;
- }
StringBuilder builder = new StringBuilder ();
- while (i < _content.length && _content[i] != '\n') {
- unichar c = _content[i++];
+ weak string line_start = _index;
+ unichar c;
+
+ while ((char*) line_start > (char*) _content && line_start.prev_char ().get_char () != '\n') {
+ line_start = line_start.prev_char ();
+ }
+
+ while ((c = line_start.get_char ()) != '\n' && c != '\0') {
if (c == '\t') {
- builder.append (" ");
+ builder.append_c (' ');
} else {
builder.append_unichar (c);
}
+ line_start = line_start.next_char ();
}
+
return builder.str;
}
protected unichar get_next_char (int offset = 1) {
- return _content[_index + offset];
+ return _index.get_char (_index.index_of_nth_char (offset));
}
protected virtual void accept (unichar c) throws ParserError {
@@ -314,7 +317,6 @@ public class Valadoc.WikiScanner : Object, Scanner {
_parser.accept_token (new Token.from_word (_current_string.str, get_begin (), get_end (-1)));
_current_string.erase (0, -1);
- _last_index = _index;
_last_line = _line;
_last_column = _column - 1;
}
@@ -325,7 +327,6 @@ public class Valadoc.WikiScanner : Object, Scanner {
_parser.accept_token (new Token.from_type (type, get_begin (), get_end (_skip)));
- _last_index = _index;
_last_line = _line;
_last_column = _column;
}
diff --git a/src/libvaladoc/errorreporter.vala b/src/libvaladoc/errorreporter.vala
index 6b4f988..7d573ba 100755
--- a/src/libvaladoc/errorreporter.vala
+++ b/src/libvaladoc/errorreporter.vala
@@ -68,7 +68,7 @@ public class Valadoc.ErrorReporter : Object {
this.stream.printf ("%s:%lu.%lu-%lu.%lu: %s: %s\n", file, line, startpos, line, endpos, (type == ErrorType.ERROR)? "error" : "warning", msg);
if (startpos <= endpos) {
this.stream.printf ("%s\n", errline);
- for (int i = 0; i < errline.length; i++) {
+ for (int i = 0; i < errline.char_count ()+1; i++) {
if (errline[i] == '\t') {
this.stream.printf ("\t");
} else if (i >= startpos - 1 && i < endpos - 1) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]