From c2b22b9e2b60617e77d07f31c2caec052c578f0c Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Wed, 4 Mar 2015 17:07:40 -0800 Subject: [PATCH] Fix #26. Fix #19. --- src/dfmt.d | 16 ++++++++-------- tests/issue0026.d | 6 ++++++ tests/issue0026.d.ref | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 tests/issue0026.d create mode 100644 tests/issue0026.d.ref diff --git a/src/dfmt.d b/src/dfmt.d index 6b4ab01..9124762 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -311,13 +311,8 @@ private: break; case tok!"cast": writeToken(); - write(" "); writeParens(true); break; - case tok!"mixin": - writeToken(); - write(" "); - break; default: if (index + 1 < tokens.length) { @@ -627,7 +622,7 @@ private: else { // Silly hack to format enums better. - if (peekBackIs(tok!"identifier")) + if (peekBackIs(tok!"identifier") || peekBackIs(tok!",")) newline(); write("}"); depth--; @@ -702,11 +697,11 @@ private: } else if (current.type == tok!")") { - if (peekIs(tok!"identifier")) + if (peekIs(tok!"identifier") || peekIsBasicType()) { writeToken(); if (space_afterwards) - write(" "); + write(" "); } else if (index + 1 < tokens.length) { @@ -740,6 +735,11 @@ private: linebreakHints = []; } + bool peekIsBasicType() + { + return index + 1 < tokens.length && isBasicType(tokens[index + 1].type); + } + bool peekIsLabel() { return peekIs(tok!"identifier") && peek2Is(tok!":"); diff --git a/tests/issue0026.d b/tests/issue0026.d new file mode 100644 index 0000000..fe1881a --- /dev/null +++ b/tests/issue0026.d @@ -0,0 +1,6 @@ +extern +(C++) +int +HtmlNamedEntity( +const(char)* p, size_t length) +; diff --git a/tests/issue0026.d.ref b/tests/issue0026.d.ref new file mode 100644 index 0000000..17c536b --- /dev/null +++ b/tests/issue0026.d.ref @@ -0,0 +1 @@ +extern(C++) int HtmlNamedEntity(const(char)* p, size_t length);