summaryrefslogtreecommitdiff
path: root/ccode
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2010-07-27 21:56:30 +0200
committerJürg Billeter <j@bitron.ch>2010-07-27 22:07:22 +0200
commitf6b39547fac817ae7e6711f398eaa1ca87d98c90 (patch)
tree8b2bc3d3535e49106c846f140931d441504f846b /ccode
parent861ff92d49af5bdcc94950f5468cea80fccf5449 (diff)
downloadvala-f6b39547fac817ae7e6711f398eaa1ca87d98c90.tar.gz
Append doc comments to generated C files
Diffstat (limited to 'ccode')
-rw-r--r--ccode/valaccodewriter.vala45
1 files changed, 26 insertions, 19 deletions
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index 8f2575437..93f4a4261 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -217,30 +217,37 @@ public class Vala.CCodeWriter {
* @param text the comment text
*/
public void write_comment (string text) {
- write_indent ();
- stream.puts ("/*");
- bool first = true;
-
- /* separate declaration due to missing memory management in foreach statements */
- var lines = text.split ("\n");
+ try {
+ write_indent ();
+ stream.puts ("/*");
+ bool first = true;
+
+ // discard tabs at beginning of line
+ var regex = new GLib.Regex ("^\t+");
+
+ /* separate declaration due to missing memory management in foreach statements */
+ var lines = text.split ("\n");
- foreach (string line in lines) {
- if (!first) {
- write_indent ();
- } else {
- first = false;
- }
+ foreach (string line in lines) {
+ if (!first) {
+ write_indent ();
+ } else {
+ first = false;
+ }
- var lineparts = line.split ("*/");
+ var lineparts = regex.replace_literal (line, -1, 0, "").split ("*/");
- for (int i = 0; lineparts[i] != null; i++) {
- stream.puts (lineparts[i]);
- if (lineparts[i+1] != null) {
- stream.puts ("* /");
+ for (int i = 0; lineparts[i] != null; i++) {
+ stream.puts (lineparts[i]);
+ if (lineparts[i+1] != null) {
+ stream.puts ("* /");
+ }
}
}
+ stream.puts ("*/");
+ write_newline ();
+ } catch (RegexError e) {
+ // ignore
}
- stream.puts ("*/");
- write_newline ();
}
}