"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sift.go" between
sift-0.8.0.tar.gz and sift-0.9.0.tar.gz

About: sift is an alternative to grep that aims for both speed and flexibility (written in Go).

sift.go  (sift-0.8.0):sift.go  (sift-0.9.0)
skipping to change at line 53 skipping to change at line 53
// MultilinePipeTimeout is the timeout for reading and matching input // MultilinePipeTimeout is the timeout for reading and matching input
// from STDIN/network in multiline mode // from STDIN/network in multiline mode
MultilinePipeTimeout = 1000 * time.Millisecond MultilinePipeTimeout = 1000 * time.Millisecond
// MultilinePipeChunkTimeout is the timeout to consider last input from S TDIN/network // MultilinePipeChunkTimeout is the timeout to consider last input from S TDIN/network
// as a complete chunk for multiline matching // as a complete chunk for multiline matching
MultilinePipeChunkTimeout = 150 * time.Millisecond MultilinePipeChunkTimeout = 150 * time.Millisecond
// MaxDirRecursionRoutines is the maximum number of parallel routines use d // MaxDirRecursionRoutines is the maximum number of parallel routines use d
// to recurse into directories // to recurse into directories
MaxDirRecursionRoutines = 3 MaxDirRecursionRoutines = 3
SiftConfigFile = ".sift.conf" SiftConfigFile = ".sift.conf"
SiftVersion = "0.8.0" SiftVersion = "0.9.0"
) )
type ConditionType int type ConditionType int
const ( const (
ConditionPreceded ConditionType = iota ConditionPreceded ConditionType = iota
ConditionFollowed ConditionFollowed
ConditionSurrounded ConditionSurrounded
ConditionFileMatches ConditionFileMatches
ConditionLineMatches ConditionLineMatches
skipping to change at line 77 skipping to change at line 77
type Condition struct { type Condition struct {
regex *regexp.Regexp regex *regexp.Regexp
conditionType ConditionType conditionType ConditionType
within int64 within int64
lineRangeStart int64 lineRangeStart int64
lineRangeEnd int64 lineRangeEnd int64
negated bool negated bool
} }
type FileType struct { type FileType struct {
Name string
Patterns []string Patterns []string
ShebangRegex *regexp.Regexp ShebangRegex *regexp.Regexp
} }
type Match struct { type Match struct {
// offset of the start of the match // offset of the start of the match
start int64 start int64
// offset of the end of the match // offset of the end of the match
end int64 end int64
// offset of the beginning of the first line of the match // offset of the beginning of the first line of the match
skipping to change at line 589 skipping to change at line 588
var args []string var args []string
var err error var err error
parser := flags.NewNamedParser("sift", flags.HelpFlag|flags.PassDoubleDas h) parser := flags.NewNamedParser("sift", flags.HelpFlag|flags.PassDoubleDas h)
parser.AddGroup("Options", "Options", &options) parser.AddGroup("Options", "Options", &options)
parser.Name = "sift" parser.Name = "sift"
parser.Usage = "[OPTIONS] PATTERN [FILE|PATH|tcp://HOST:PORT]...\n" + parser.Usage = "[OPTIONS] PATTERN [FILE|PATH|tcp://HOST:PORT]...\n" +
" sift [OPTIONS] [-e PATTERN | -f FILE] [FILE|PATH|tcp://HOST:PO RT]...\n" + " sift [OPTIONS] [-e PATTERN | -f FILE] [FILE|PATH|tcp://HOST:PO RT]...\n" +
" sift [OPTIONS] --targets [FILE|PATH]..." " sift [OPTIONS] --targets [FILE|PATH]..."
// temporarily parse options to see if the --no-conf option was used and // temporarily parse options to see if the --no-conf/--conf options were used and
// then discard the result // then discard the result
options.LoadDefaults() options.LoadDefaults()
args, err = parser.Parse() args, err = parser.Parse()
if err != nil { if err != nil {
if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp { if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp {
fmt.Println(e.Error()) fmt.Println(e.Error())
os.Exit(0) os.Exit(0)
} else { } else {
errorLogger.Println(err) errorLogger.Println(err)
os.Exit(2) os.Exit(2)
} }
} }
loadConfig := !options.NoConfig noConf := options.NoConfig
configFile := options.ConfigFile
options = Options{} options = Options{}
// perform full option parsing respecting the --no-conf option // perform full option parsing respecting the --no-conf/--conf options
options.LoadDefaults() options.LoadDefaults()
if loadConfig { options.LoadConfigs(noConf, configFile)
options.LoadConfigs()
}
args, err = parser.Parse() args, err = parser.Parse()
if err != nil { if err != nil {
errorLogger.Println(err) errorLogger.Println(err)
os.Exit(2) os.Exit(2)
} }
for _, pattern := range options.Patterns { for _, pattern := range options.Patterns {
global.matchPatterns = append(global.matchPatterns, pattern) global.matchPatterns = append(global.matchPatterns, pattern)
} }
skipping to change at line 633 skipping to change at line 631
errorLogger.Fatalln("Cannot open pattern file:\n", err) errorLogger.Fatalln("Cannot open pattern file:\n", err)
} }
scanner := bufio.NewScanner(f) scanner := bufio.NewScanner(f)
for scanner.Scan() { for scanner.Scan() {
pattern := scanner.Text() pattern := scanner.Text()
global.matchPatterns = append(global.matchPatterns, patte rn) global.matchPatterns = append(global.matchPatterns, patte rn)
} }
} }
if len(global.matchPatterns) == 0 { if len(global.matchPatterns) == 0 {
if len(args) == 0 && !(options.PrintConfig || options.WriteConfig if len(args) == 0 && !(options.PrintConfig || options.WriteConfig
|| options.TargetsOnly) { ||
options.TargetsOnly || options.ListTypes) {
errorLogger.Fatalln("No pattern given. Try 'sift --help' for more information.") errorLogger.Fatalln("No pattern given. Try 'sift --help' for more information.")
} }
if len(args) > 0 && !options.TargetsOnly { if len(args) > 0 && !options.TargetsOnly {
global.matchPatterns = append(global.matchPatterns, args[ 0]) global.matchPatterns = append(global.matchPatterns, args[ 0])
args = args[1:len(args)] args = args[1:len(args)]
} }
} }
if len(args) == 0 { if len(args) == 0 {
// check whether there is input on STDIN // check whether there is input on STDIN
 End of changes. 7 change blocks. 
10 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)