Skip to content

Commit

Permalink
access correction
Browse files Browse the repository at this point in the history
  • Loading branch information
gkiryaziev committed Feb 13, 2016
1 parent f0b60e5 commit ca8cac2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// Do job
func DoJob(remove, trim, duplicate, sorting, calculate bool, min, max int, src_file, new_file string) error {
func doJob(remove, trim, duplicate, sorting, calculate bool, min, max int, src_file, new_file string) error {

// Check operations
if !remove && !trim && !duplicate && !sorting && !calculate {
Expand Down Expand Up @@ -57,7 +57,7 @@ func DoJob(remove, trim, duplicate, sorting, calculate bool, min, max int, src_f
}

// Split file by name and extension
func SplitFileName(file string) (string, string) {
func splitFileName(file string) (string, string) {
ext := filepath.Ext(file)
name := file[0 : len(file)-len(ext)]
return name, ext
Expand Down Expand Up @@ -137,14 +137,14 @@ func main() {
fmt.Println(len(files_list), "files found.")
fmt.Println()
for _, src_file := range files_list {
name, ext := SplitFileName(src_file)
name, ext := splitFileName(src_file)
new_file := name + "_cleaned" + ext
err = DoJob(remove, trim, duplicate, sorting, calculate, min, max, src_file, new_file)
err = doJob(remove, trim, duplicate, sorting, calculate, min, max, src_file, new_file)
s.CheckError(err)
}
} else {
fmt.Println()
err := DoJob(remove, trim, duplicate, sorting, calculate, min, max, src_file, new_file)
err := doJob(remove, trim, duplicate, sorting, calculate, min, max, src_file, new_file)
s.CheckError(err)
}

Expand Down
10 changes: 5 additions & 5 deletions operations/remove_trim.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
s "../service"
)

func IsPrint(text string) bool {
func isPrint(text string) bool {
for _, r := range text {
if r < 32 || r > 126 {
return false
Expand All @@ -19,7 +19,7 @@ func IsPrint(text string) bool {
return true
}

func IsSize(min, max int, line string) bool {
func isSize(min, max int, line string) bool {
if len([]rune(line)) < min || len([]rune(line)) > max {
return false
}
Expand Down Expand Up @@ -64,21 +64,21 @@ func DoClean(remove, trim bool, min, max int, src_file, new_file string) error {
line := scanner.Text()

if remove && trim {
if IsPrint(line) && IsSize(min, max, line) {
if isPrint(line) && isSize(min, max, line) {
fmt.Fprintln(writer, line)
added++
}
}

if remove && !trim {
if IsPrint(line) {
if isPrint(line) {
fmt.Fprintln(writer, line)
added++
}
}

if !remove && trim {
if IsSize(min, max, line) {
if isSize(min, max, line) {
fmt.Fprintln(writer, line)
added++
}
Expand Down

0 comments on commit ca8cac2

Please sign in to comment.