From f36a8efcec75fd55ff35405ddda91e53dfdf063e Mon Sep 17 00:00:00 2001 From: Nikita Kalyazin Date: Wed, 23 Apr 2014 11:04:42 +0400 Subject: [PATCH] fix indentation (4 -> 2 spaces) --- src/cscope.coffee | 106 +++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/src/cscope.coffee b/src/cscope.coffee index c1885c5..417d857 100644 --- a/src/cscope.coffee +++ b/src/cscope.coffee @@ -18,81 +18,81 @@ findAssignCmd = "9" symbolToSearch = process.argv[2] dbPath = process.argv[3] if !symbolToSearch || !dbPath - console.log "Usage: coffee cscope.coffee " - process.exit 1 + console.log "Usage: coffee cscope.coffee " + process.exit 1 genericFind = (cmd, symbol, db, callback) -> - cscopeRegex = /cscope: (\d+) lines/ - outputRegex = /([\w.\/]+)\s+([a-zA-Z_$][\w$]+|)\s+(\d+)\s+(.+)/ - prompt = ">> " - quitCmd = "q" - - nexpect.spawn "cscope" - , ["-d", "-k", "-l", "-f" + db] - .expect prompt - .sendline cmd + symbolToSearch - .expect cscopeRegex - .sendline quitCmd - .run (err, stdout, exitcode) -> - if err - console.log "could not invoke cscope (#{err})" - process.exit 1 - header = stdout[1].match(cscopeRegex) - lines = parseInt(header[1]) - if lines == 0 # no such symbol - return null - - startIdx = 2 - res = [] - drop_next = null - # for line in [startIdx..startIdx + lines - 1] - padding = 3 # 2 x ">>" and lines count - # FIXME: ugly hack - for line in [startIdx..startIdx + (stdout.length - padding) - 1] - if drop_next - drop_next = null - continue - m = stdout[line].match(outputRegex) - if !m # broken line - m = (stdout[line] + stdout[line + 1]).match(outputRegex) - drop_next = 1 - res.push - file: m[1] - sym: m[2] - line: m[3] - ctx: m[4] - callback res + cscopeRegex = /cscope: (\d+) lines/ + outputRegex = /([\w.\/]+)\s+([a-zA-Z_$][\w$]+|)\s+(\d+)\s+(.+)/ + prompt = ">> " + quitCmd = "q" + + nexpect.spawn "cscope" + , ["-d", "-k", "-l", "-f" + db] + .expect prompt + .sendline cmd + symbolToSearch + .wait cscopeRegex + .sendline quitCmd + .run (err, stdout, exitcode) -> + if err + console.log "could not invoke cscope (#{err})" + process.exit 1 + header = stdout[1].match(cscopeRegex) + lines = parseInt(header[1]) + if lines == 0 # no such symbol + return null + + startIdx = 2 + res = [] + drop_next = null + # for line in [startIdx..startIdx + lines - 1] + padding = 3 # 2 x ">>" and lines count + # FIXME: ugly hack + for line in [startIdx..startIdx + (stdout.length - padding) - 1] + if drop_next + drop_next = null + continue + m = stdout[line].match(outputRegex) + if !m # broken line + m = (stdout[line] + stdout[line + 1]).match(outputRegex) + drop_next = 1 + res.push + file: m[1] + sym: m[2] + line: m[3] + ctx: m[4] + callback res findSymbol = (symbol, db, callback) -> - genericFind findSymbolCmd, symbol, db, callback + genericFind findSymbolCmd, symbol, db, callback funcsCalledBy = (symbol, db, callback) -> - genericFind funcsCalledByCmd, symbol, db, callback + genericFind funcsCalledByCmd, symbol, db, callback funcsCalling = (symbol, db, callback) -> - genericFind funcsCallingCmd, symbol, db, callback + genericFind funcsCallingCmd, symbol, db, callback findTextString = (symbol, db, callback) -> - genericFind findTextStringCmd, symbol, db, callback + genericFind findTextStringCmd, symbol, db, callback # changeTextString = (symbol, db, callback) -> - # genericFind changeTextStringCmd, symbol, db, callback +# genericFind changeTextStringCmd, symbol, db, callback findEgrepPattern = (symbol, db, callback) -> - genericFind findEgrepPatternCmd, symbol, db, callback + genericFind findEgrepPatternCmd, symbol, db, callback findFile = (symbol, db, callback) -> - genericFind findFileCmd, symbol, db, callback + genericFind findFileCmd, symbol, db, callback findFilesIncluding = (symbol, db, callback) -> - genericFind findFilesIncludingCmd, symbol, db, callback + genericFind findFilesIncludingCmd, symbol, db, callback findAssign = (symbol, db, callback) -> - genericFind findAssignCmd, symbol, db, callback + genericFind findAssignCmd, symbol, db, callback printResult = (results) -> - for r in results - console.log "file: #{r.file}, sym: #{r.sym}, line: #{r.line}" + for r in results + console.log "file: #{r.file}, sym: #{r.sym}, line: #{r.line}" # findSymbol symbolToSearch, dbPath, printResult # funcsCalledBy symbolToSearch, dbPath, printResult