Skip to content

Commit

Permalink
Minor fix to quote handling in the script.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchenbecker committed Jul 10, 2009
1 parent 9ca02ae commit 34b6bf8
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions findBrokenQuotes.scala
Expand Up @@ -3,6 +3,7 @@ import scala.io.Source
sealed abstract class State sealed abstract class State
case object Normal extends State case object Normal extends State
case object InListing extends State case object InListing extends State
case object InQuotes extends State


var state: State = Normal var state: State = Normal
var insetDepth = 0 var insetDepth = 0
Expand All @@ -22,18 +23,25 @@ for (file <- args) {


if (line.matches("""(?s)\\begin_inset Quotes e[lr]d.*""")) { if (line.matches("""(?s)\\begin_inset Quotes e[lr]d.*""")) {
printf("Bad quotes at %s : %d\n", file, index + 1) printf("Bad quotes at %s : %d\n", file, index + 1)
output = "\"" output = "\"\n"
} state = InQuotes
if (line.matches("""(?s)\\begin_inset.*""")) { } else {
insetDepth += 1 if (line.matches("""(?s)\\begin_inset.*""")) {
} insetDepth += 1
if (line.matches("""(?s)\\end_inset.*""")) { }
insetDepth -= 1 if (line.matches("""(?s)\\end_inset.*""")) {
} insetDepth -= 1
if (insetDepth == 0) { }
if (insetDepth == 0) {
state = Normal state = Normal
}
} }
} }
case InQuotes if line.matches("""(?s)\\end_inset.*""") => {
output = ""
state = InListing
}
case InQuotes => output = ""
case Normal => case Normal =>
// ok // ok
} }
Expand Down

0 comments on commit 34b6bf8

Please sign in to comment.