Skip to content

Commit d85a77a

Browse files
committed
A few changes to be more Rock friendly
1 parent 5727e49 commit d85a77a

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

mustang/Escape.ooc

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
import text/Buffer
22

3-
String: cover from Char* {
4-
/**
5-
Escape < > & " ' characters in the string.
6-
*/
7-
escapeHTML: func -> This {
8-
// Allocate a buffer to hold the escaped string
9-
// as we build it. Give it some extra space since
10-
// each escaped char will increase length.
11-
// Hopefully this will help avoid re-sizes most of the time.
12-
escaped := Buffer new(this length() + 128)
3+
/**
4+
Escape < > & " ' characters in the string.
5+
*/
6+
escapeHTML: func(text: String) -> String {
7+
// Allocate a buffer to hold the escaped string
8+
// as we build it. Give it some extra space since
9+
// each escaped char will increase length.
10+
// Hopefully this will help avoid re-sizes most of the time.
11+
escaped := Buffer new(text length() + 128)
1312

14-
for(c: Char in this) {
15-
e: String = match c {
16-
case '<' => "&lt;"
17-
case '>' => "&gt;"
18-
case '&' => "&amp;"
19-
case '"' => "&quot;"
20-
case '\'' => "&apos;"
21-
case =>
22-
escaped append(c)
23-
continue
24-
"null"
25-
}
26-
escaped append(e)
13+
for(c: Char in text) {
14+
e: String = match c {
15+
case '<' => "&lt;"
16+
case '>' => "&gt;"
17+
case '&' => "&amp;"
18+
case '"' => "&quot;"
19+
case '\'' => "&apos;"
20+
case =>
21+
escaped append(c)
22+
continue
23+
"null"
2724
}
28-
29-
return escaped toString()
25+
escaped append(e)
3026
}
27+
28+
return escaped toString()
3129
}

mustang/Node.ooc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ VariableNode: class extends TNode {
5353
variableText := variable emit()
5454
if(escape) {
5555
// Escape any HTML in the text
56-
variableText = variableText escapeHTML()
56+
variableText = escapeHTML(variableText)
5757
}
5858

5959
// Write variable text to output stream

mustang/YAMLContext.ooc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ YAMLContext: class extends Context {
3333
}
3434

3535
nodeToValue: static func(node: DocumentNode) -> Value {
36-
match node class {
36+
nodeType := node class
37+
38+
match nodeType {
3739
case ScalarNode => scalarToValue(node as ScalarNode)
3840
case SequenceNode => sequenceToListValue(node as SequenceNode)
3941
case MappingNode => mappingToHashValue(node as MappingNode)

0 commit comments

Comments
 (0)