Skip to content

Commit

Permalink
Merge branch 'hotfix-0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamierocks committed Oct 26, 2018
2 parents 8784012 + 8e70b05 commit c80ba57
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ Lorenz releases can be obtained through Maven Central:
<dependency>
<groupId>me.jamiemansfield</groupId>
<artifactId>lorenz</artifactId>
<version>0.4.0</version>
<version>0.4.2</version>
</dependency>
```

### Gradle

```groovy
compile 'me.jamiemansfield:lorenz:0.4.0'
compile 'me.jamiemansfield:lorenz:0.4.2'
```

You may also find snapshot artifacts on [Sonatype's OSS repository], and for older
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ subprojects {

group = 'me.jamiemansfield'
archivesBaseName = project.name.toLowerCase()
version = '0.4.1'
version = '0.4.2'

repositories {
mavenCentral()
Expand Down
5 changes: 5 additions & 0 deletions changelogs/0.4.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Lorenz 0.4.2
============

This version of Lorenz addresses a critical bug in the Enigma reader, that prevents inner
classes from preceding the other members of a class.
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,23 @@ public Processor() {
public void accept(final String rawLine) {
final int indentLevel = getIndentLevel(rawLine);

if (indentLevel < this.lastIndentLevel) {
if (this.currentMethod != null && indentLevel == this.lastIndentLevel - 1) {
// new method / field mapping
this.currentMethod = null;
}
else {
this.stack.pop();
// If there is a change in the indentation level, we will need to alter the
// state as need be.
final int classLevel = indentLevel - (this.currentMethod == null ? 0 : 1);
if (classLevel < this.stack.size()) {
final int difference = this.stack.size() - classLevel;
final int indentDifference = this.lastIndentLevel - indentLevel;

// as the stack is exclusive to classes, don't pop anything when a method
// is the container
if (!(this.currentMethod != null && indentDifference == 1)) {
for (int i = 0; i < difference; i++) {
this.stack.pop();
}
}

// wipe the current method
this.currentMethod = null;
}

final String line = EnigmaConstants.removeComments(rawLine).trim();
Expand Down
6 changes: 3 additions & 3 deletions lorenz/src/test/resources/test.enigma
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# CLASS yu uk/jamierocks/Comment
CLASS uih uk/jamierocks/CommentTest # CLASS op uk/jr/Operator
CLASS ght uk/jamierocks/Test
FIELD rft log Ljava/util/logging/Logger;
METHOD hyuip isEven (I)Z
ARG 0 num
CLASS ght$ds Example
FIELD juh server Luk/jamierocks/Server;
METHOD hyuip isOdd (I)Z
ARG 0 num
CLASS ght$ds$bg Inner
FIELD rft log Ljava/util/logging/Logger;
METHOD hyuip isEven (I)Z
ARG 0 num

0 comments on commit c80ba57

Please sign in to comment.