Skip to content

Commit

Permalink
fixed bugs and release version 0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
baolanlequang committed Feb 4, 2022
1 parent aa12aa2 commit 33fe781
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,17 @@ class Jcamp {
private fun scanner(strVal: String): ArrayList<String> {
var result = ArrayList<String>()


var tmpStr = ""
val scanStr = strVal

var startPoint = -1

for ((idx, c) in scanStr.withIndex()) {
if (idx == startPoint-1) {
for ((idx, c) in strVal.withIndex()) {
if (idx == startPoint - 1) {
continue
}
if (c.isNumberic() || c.equals('.', true)) {
tmpStr = tmpStr.plus(c)
}
else {
} else {
if (tmpStr != "") {
tmpStr = tmpStr.trim()
result.add(tmpStr)
Expand All @@ -330,35 +327,33 @@ class Jcamp {
val charString = c.toString()
if (Constants.DUP.containsKey(charString)) {
var nextChars = ""
if (idx < scanStr.length - 1) {
startPoint = idx+1
while (scanStr[startPoint].isNumberic()) {
nextChars = nextChars.plus(scanStr[idx+1])
if (idx < strVal.length - 1) {
startPoint = idx + 1
while (strVal[startPoint].isNumberic()) {
nextChars = nextChars.plus(strVal[idx + 1])
startPoint += 1
}
}
val dupVal: Int = Constants.DUP[charString]!!
val strDupValFull = "%d%s".format(Locale.getDefault(), dupVal, nextChars)
var dupValInt: Int = dupVal
try {
strDupValFull.toInt()
}
catch (e: Exception) {
dupValInt = strDupValFull.toInt()
} catch (e: Exception) {

}
//Check DUP
for (i in 0 until dupValInt-1) {
val lastTmpStr = result.last()
// Log.d("baolanlequang", lastTmpStr)
if (!lastTmpStr.isNullOrEmpty()) {
result.add(lastTmpStr)
}
}
}
else if (Constants.SQZ.containsKey(charString)) {
} else if (Constants.SQZ.containsKey(charString)) {
val sqzVal = Constants.SQZ[charString]
tmpStr = tmpStr.plus(sqzVal)
}
else {
} else {
tmpStr = tmpStr.plus(c)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val input = assets.open("testdata/test_file_10_failed.dx")
val input = assets.open("testdata/test_file_20.dx")

val reader = JcampReader(input)
val jcamp = reader.jcamp
Expand Down

0 comments on commit 33fe781

Please sign in to comment.