LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File weekly.2012-03-04-fix.patch of Package go-lzma (Project devel:languages:go)

diff --git a/cmd/LICENSE b/cmd/LICENSE
deleted file mode 100644
index 091d84f..0000000
--- a/cmd/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2010, Andrei Vieru. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-//    * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//    * Redistributions in binary form must reproduce the above 
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the 
-// distribution.
-//    * Neither the name of the author nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/cmd/Makefile b/cmd/Makefile
deleted file mode 100644
index 4480d16..0000000
--- a/cmd/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright (c) 2010, Andrei Vieru. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-include $(GOROOT)/src/Make.inc
-
-TARG=lzma
-GOFILES=\
-	main.go\
-
-include $(GOROOT)/src/Make.cmd
diff --git a/cmd/main.go b/cmd/main.go
deleted file mode 100644
index 9422dfd..0000000
--- a/cmd/main.go
+++ /dev/null
@@ -1,261 +0,0 @@
-// Copyright (c) 2010, Andrei Vieru. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
-	"compress/lzma"
-	//"lzma.googlecode.com/hg"
-	"flag"
-	"fmt"
-	"log"
-	"io"
-	"os"
-	"path"
-	"runtime"
-	"strings"
-)
-
-var (
-	stdout     = flag.Bool("c", false, "write on standard output, keep original files unchanged")
-	decompress = flag.Bool("d", false, "decompress")
-	force      = flag.Bool("f", false, "force overwrite of output file")
-	help       = flag.Bool("h", false, "print this help message")
-	keep       = flag.Bool("k", false, "keep original files unchaned")
-	suffix     = flag.String("s", "lzma", "use provided suffix on compressed files")
-	level      = flag.Int("l", 5, "compression level [1 ... 9]")
-	cores      = flag.Int("cores", 1, "number of cores to use for parallelization")
-
-	stdin bool
-)
-
-func usage() {
-	fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]... [FILE]\n", os.Args[0])
-	fmt.Fprintf(os.Stderr, "Compress or uncompress FILE (by default, compress FILE in-place).\n\n")
-	flag.PrintDefaults()
-	fmt.Fprintf(os.Stderr, "\nWith no FILE, or when FILE is -, read standard input.\n")
-}
-
-func exit(msg string) {
-	usage()
-	fmt.Fprintln(os.Stderr)
-	log.Fatalf("%s: check args: %s\n\n", os.Args[0], msg)
-}
-
-func setByUser(name string) (isSet bool) {
-	flag.Visit(func(f *flag.Flag) {
-		if f.Name == name {
-			isSet = true
-		}
-	})
-	return
-}
-
-func main() {
-	flag.Parse()
-	if *help == true {
-		usage()
-		log.Fatal(0)
-	}
-	//if *stdout == true && *suffix != "lzma" {
-	if *stdout == true && setByUser("s") == true {
-		exit("stdout set, suffix not used")
-	}
-	if *stdout == true && *force == true {
-		exit("stdout set, force not used")
-	}
-	if *stdout == true && *keep == true {
-		exit("stdout set, keep is redundant")
-	}
-	if flag.NArg() > 1 {
-		exit("too many file, provide at most one file at a time or check order of flags")
-	}
-	//if *decompress == true && *level != 5 {
-	if *decompress == true && setByUser("l") == true {
-		exit("compression level is used for compression only")
-	}
-	if *level < 1 || *level > 9 {
-		exit("compression level out of range")
-	}
-	if *cores < 1 || *cores > 32 {
-		exit("invalid number of cores")
-	}
-
-	runtime.GOMAXPROCS(*cores)
-
-	var inFilePath string
-	var outFilePath string
-	if flag.NArg() == 0 || flag.NArg() == 1 && flag.Args()[0] == "-" { // parse args: read from stdin
-		if *stdout != true {
-			exit("reading from stdin, can write only to stdout")
-		}
-		//if *suffix != "lzma" {
-		if setByUser("s") == true {
-			exit("reading from stdin, suffix not needed")
-		}
-		stdin = true
-
-	} else if flag.NArg() == 1 { // parse args: read from file
-		inFilePath = flag.Args()[0]
-		f, err := os.Lstat(inFilePath)
-		if err != nil {
-			log.Fatal(err.String())
-		}
-		if f == nil {
-			exit(fmt.Sprintf("file %s not found", inFilePath))
-		}
-		if !f.IsRegular() {
-			exit(fmt.Sprintf("%s is not a regular file", inFilePath))
-		}
-
-		if *stdout == false { // parse args: write to file
-			if *suffix == "" {
-				exit("suffix can't be an empty string")
-			}
-
-			if *decompress == true {
-				outFileDir, outFileName := path.Split(inFilePath)
-				if strings.HasSuffix(outFileName, "."+*suffix) {
-					if len(outFileName) > len("."+*suffix) {
-						nstr := strings.SplitN(outFileName, ".", len(outFileName))
-						estr := strings.Join(nstr[0:len(nstr)-1], ".")
-						outFilePath = outFileDir + estr
-					} else {
-						log.Fatalf("error: can't strip suffix .%s from file %s", *suffix, inFilePath)
-					}
-				} else {
-					exit(fmt.Sprintf("file %s doesn't have suffix .%s", inFilePath, *suffix))
-				}
-
-			} else {
-				outFilePath = inFilePath + "." + *suffix
-			}
-
-			f, err = os.Lstat(outFilePath)
-			if err != nil && f != nil { // should be: ||| if err != nil && err != "file not found" ||| but i can't find the error's id
-				log.Fatal(err.String())
-			}
-			if f != nil && f.IsRegular() {
-				if *force == true {
-					err = os.Remove(outFilePath)
-					if err != nil {
-						log.Fatal(err.String())
-					}
-				} else {
-					exit(fmt.Sprintf("outFile %s exists. use force to overwrite", outFilePath))
-				}
-			} else if f != nil {
-				exit(fmt.Sprintf("outFile %s exists and is not a regular file", outFilePath))
-			}
-		}
-	}
-
-	pr, pw := io.Pipe()
-	//defer pr.Close()
-	//defer pw.Close()
-
-	if *decompress {
-		// read from inFile into pw
-		go func() {
-			defer pw.Close()
-			var inFile *os.File
-			var err os.Error
-			if stdin == true {
-				inFile = os.Stdin
-			} else {
-				inFile, err = os.Open(inFilePath)
-			}
-			defer inFile.Close()
-			if err != nil {
-				log.Fatal(err.String())
-			}
-
-			_, err = io.Copy(pw, inFile)
-			if err != nil {
-				log.Fatal(err.String())
-			}
-
-		}()
-
-		// write into outFile from z
-		defer pr.Close()
-		z := lzma.NewReader(pr)
-		defer z.Close()
-		var outFile *os.File
-		var err os.Error
-		if *stdout == true {
-			outFile = os.Stdout
-		} else {
-			outFile, err = os.Create(outFilePath)
-		}
-		defer outFile.Close()
-		if err != nil {
-			log.Fatal(err.String())
-		}
-
-		_, err = io.Copy(outFile, z)
-		if err != nil {
-			log.Fatal(err.String())
-		}
-
-	} else {
-		// read from inFile into z
-		go func() {
-			defer pw.Close()
-			var z io.WriteCloser
-			var inFile *os.File
-			var err os.Error
-			if stdin == true {
-				inFile = os.Stdin
-				defer inFile.Close()
-				z = lzma.NewWriterLevel(pw, *level)
-				defer z.Close()
-			} else {
-				inFile, err = os.Open(inFilePath)
-				defer inFile.Close()
-				if err != nil {
-					log.Fatal(err.String())
-				}
-				f, err := os.Lstat(inFilePath)
-				if err != nil {
-					log.Fatal(err.String())
-				}
-				z = lzma.NewWriterSizeLevel(pw, int64(f.Size), *level)
-				defer z.Close()
-			}
-
-			_, err = io.Copy(z, inFile)
-			if err != nil {
-				log.Fatal(err.String())
-			}
-		}()
-
-		// write into outFile from pr
-		defer pr.Close()
-		var outFile *os.File
-		var err os.Error
-		if *stdout == true {
-			outFile = os.Stdout
-		} else {
-			outFile, err = os.Create(outFilePath)
-		}
-		defer outFile.Close()
-		if err != nil {
-			log.Fatal(err.String())
-		}
-
-		_, err = io.Copy(outFile, pr)
-		if err != nil {
-			log.Fatal(err.String())
-		}
-	}
-
-	if *stdout == false && *keep == false {
-		err := os.Remove(inFilePath)
-		if err != nil {
-			log.Fatal(err.String())
-		}
-	}
-
-}
diff --git a/lz_window.go b/lz_window.go
index e57fdf4..2be2a33 100644
--- a/lz_window.go
+++ b/lz_window.go
@@ -4,10 +4,7 @@
 
 package lzma
 
-import (
-	"io"
-	"os"
-)
+import "io"
 
 type lzOutWindow struct {
 	w         io.Writer
@@ -82,7 +79,6 @@ func (ow *lzOutWindow) getByte(distance uint32) byte {
 	return ow.buf[pos]
 }
 
-
 type lzInWindow struct {
 	r              io.Reader
 	buf            []byte
@@ -136,10 +132,10 @@ func (iw *lzInWindow) readBlock() {
 			return
 		}
 		n, err := iw.r.Read(iw.buf[iw.bufOffset+iw.streamPos : iw.blockSize])
-		if err != nil && err != os.EOF {
+		if err != nil && err != io.EOF {
 			throw(err)
 		}
-		if n == 0 && err == os.EOF {
+		if n == 0 && err == io.EOF {
 			iw.posLimit = iw.streamPos
 			ptr := iw.bufOffset + iw.posLimit
 			if ptr > iw.lastSafePos {
diff --git a/lzma/LICENSE b/lzma/LICENSE
new file mode 100644
index 0000000..091d84f
--- /dev/null
+++ b/lzma/LICENSE
@@ -0,0 +1,27 @@
+// Copyright (c) 2010, Andrei Vieru. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+//    * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//    * Redistributions in binary form must reproduce the above 
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the 
+// distribution.
+//    * Neither the name of the author nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/lzma/Makefile b/lzma/Makefile
new file mode 100644
index 0000000..4480d16
--- /dev/null
+++ b/lzma/Makefile
@@ -0,0 +1,11 @@
+# Copyright (c) 2010, Andrei Vieru. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+include $(GOROOT)/src/Make.inc
+
+TARG=lzma
+GOFILES=\
+	main.go\
+
+include $(GOROOT)/src/Make.cmd
diff --git a/lzma/main.go b/lzma/main.go
new file mode 100644
index 0000000..44ddbf0
--- /dev/null
+++ b/lzma/main.go
@@ -0,0 +1,260 @@
+// Copyright (c) 2010, Andrei Vieru. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+	"code.google.com/p/lzma"
+	"flag"
+	"fmt"
+	"io"
+	"log"
+	"os"
+	"path"
+	"runtime"
+	"strings"
+)
+
+var (
+	stdout     = flag.Bool("c", false, "write on standard output, keep original files unchanged")
+	decompress = flag.Bool("d", false, "decompress")
+	force      = flag.Bool("f", false, "force overwrite of output file")
+	help       = flag.Bool("h", false, "print this help message")
+	keep       = flag.Bool("k", false, "keep original files unchaned")
+	suffix     = flag.String("s", "lzma", "use provided suffix on compressed files")
+	level      = flag.Int("l", 5, "compression level [1 ... 9]")
+	cores      = flag.Int("cores", 1, "number of cores to use for parallelization")
+
+	stdin bool
+)
+
+func usage() {
+	fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]... [FILE]\n", os.Args[0])
+	fmt.Fprintf(os.Stderr, "Compress or uncompress FILE (by default, compress FILE in-place).\n\n")
+	flag.PrintDefaults()
+	fmt.Fprintf(os.Stderr, "\nWith no FILE, or when FILE is -, read standard input.\n")
+}
+
+func exit(msg string) {
+	usage()
+	fmt.Fprintln(os.Stderr)
+	log.Fatalf("%s: check args: %s\n\n", os.Args[0], msg)
+}
+
+func setByUser(name string) (isSet bool) {
+	flag.Visit(func(f *flag.Flag) {
+		if f.Name == name {
+			isSet = true
+		}
+	})
+	return
+}
+
+func main() {
+	flag.Parse()
+	if *help == true {
+		usage()
+		log.Fatal(0)
+	}
+	//if *stdout == true && *suffix != "lzma" {
+	if *stdout == true && setByUser("s") == true {
+		exit("stdout set, suffix not used")
+	}
+	if *stdout == true && *force == true {
+		exit("stdout set, force not used")
+	}
+	if *stdout == true && *keep == true {
+		exit("stdout set, keep is redundant")
+	}
+	if flag.NArg() > 1 {
+		exit("too many file, provide at most one file at a time or check order of flags")
+	}
+	//if *decompress == true && *level != 5 {
+	if *decompress == true && setByUser("l") == true {
+		exit("compression level is used for compression only")
+	}
+	if *level < 1 || *level > 9 {
+		exit("compression level out of range")
+	}
+	if *cores < 1 || *cores > 32 {
+		exit("invalid number of cores")
+	}
+
+	runtime.GOMAXPROCS(*cores)
+
+	var inFilePath string
+	var outFilePath string
+	if flag.NArg() == 0 || flag.NArg() == 1 && flag.Args()[0] == "-" { // parse args: read from stdin
+		if *stdout != true {
+			exit("reading from stdin, can write only to stdout")
+		}
+		//if *suffix != "lzma" {
+		if setByUser("s") == true {
+			exit("reading from stdin, suffix not needed")
+		}
+		stdin = true
+
+	} else if flag.NArg() == 1 { // parse args: read from file
+		inFilePath = flag.Args()[0]
+		f, err := os.Lstat(inFilePath)
+		if err != nil {
+			log.Fatal(err.Error())
+		}
+		if f == nil {
+			exit(fmt.Sprintf("file %s not found", inFilePath))
+		}
+		if !!f.IsDir() {
+			exit(fmt.Sprintf("%s is not a regular file", inFilePath))
+		}
+
+		if *stdout == false { // parse args: write to file
+			if *suffix == "" {
+				exit("suffix can't be an empty string")
+			}
+
+			if *decompress == true {
+				outFileDir, outFileName := path.Split(inFilePath)
+				if strings.HasSuffix(outFileName, "."+*suffix) {
+					if len(outFileName) > len("."+*suffix) {
+						nstr := strings.SplitN(outFileName, ".", len(outFileName))
+						estr := strings.Join(nstr[0:len(nstr)-1], ".")
+						outFilePath = outFileDir + estr
+					} else {
+						log.Fatalf("error: can't strip suffix .%s from file %s", *suffix, inFilePath)
+					}
+				} else {
+					exit(fmt.Sprintf("file %s doesn't have suffix .%s", inFilePath, *suffix))
+				}
+
+			} else {
+				outFilePath = inFilePath + "." + *suffix
+			}
+
+			f, err = os.Lstat(outFilePath)
+			if err != nil && f != nil { // should be: ||| if err != nil && err != "file not found" ||| but i can't find the error's id
+				log.Fatal(err.Error())
+			}
+			if f != nil && !f.IsDir() {
+				if *force == true {
+					err = os.Remove(outFilePath)
+					if err != nil {
+						log.Fatal(err.Error())
+					}
+				} else {
+					exit(fmt.Sprintf("outFile %s exists. use force to overwrite", outFilePath))
+				}
+			} else if f != nil {
+				exit(fmt.Sprintf("outFile %s exists and is not a regular file", outFilePath))
+			}
+		}
+	}
+
+	pr, pw := io.Pipe()
+	//defer pr.Close()
+	//defer pw.Close()
+
+	if *decompress {
+		// read from inFile into pw
+		go func() {
+			defer pw.Close()
+			var inFile *os.File
+			var err error
+			if stdin == true {
+				inFile = os.Stdin
+			} else {
+				inFile, err = os.Open(inFilePath)
+			}
+			defer inFile.Close()
+			if err != nil {
+				log.Fatal(err.Error())
+			}
+
+			_, err = io.Copy(pw, inFile)
+			if err != nil {
+				log.Fatal(err.Error())
+			}
+
+		}()
+
+		// write into outFile from z
+		defer pr.Close()
+		z := lzma.NewReader(pr)
+		defer z.Close()
+		var outFile *os.File
+		var err error
+		if *stdout == true {
+			outFile = os.Stdout
+		} else {
+			outFile, err = os.Create(outFilePath)
+		}
+		defer outFile.Close()
+		if err != nil {
+			log.Fatal(err.Error())
+		}
+
+		_, err = io.Copy(outFile, z)
+		if err != nil {
+			log.Fatal(err.Error())
+		}
+
+	} else {
+		// read from inFile into z
+		go func() {
+			defer pw.Close()
+			var z io.WriteCloser
+			var inFile *os.File
+			var err error
+			if stdin == true {
+				inFile = os.Stdin
+				defer inFile.Close()
+				z = lzma.NewWriterLevel(pw, *level)
+				defer z.Close()
+			} else {
+				inFile, err = os.Open(inFilePath)
+				defer inFile.Close()
+				if err != nil {
+					log.Fatal(err.Error())
+				}
+				f, err := os.Lstat(inFilePath)
+				if err != nil {
+					log.Fatal(err.Error())
+				}
+				z = lzma.NewWriterSizeLevel(pw, int64(f.Size()), *level)
+				defer z.Close()
+			}
+
+			_, err = io.Copy(z, inFile)
+			if err != nil {
+				log.Fatal(err.Error())
+			}
+		}()
+
+		// write into outFile from pr
+		defer pr.Close()
+		var outFile *os.File
+		var err error
+		if *stdout == true {
+			outFile = os.Stdout
+		} else {
+			outFile, err = os.Create(outFilePath)
+		}
+		defer outFile.Close()
+		if err != nil {
+			log.Fatal(err.Error())
+		}
+
+		_, err = io.Copy(outFile, pr)
+		if err != nil {
+			log.Fatal(err.Error())
+		}
+	}
+
+	if *stdout == false && *keep == false {
+		err := os.Remove(inFilePath)
+		if err != nil {
+			log.Fatal(err.Error())
+		}
+	}
+
+}
diff --git a/lzma_data_test.go b/lzma_data_test.go
index 5d0c247..fd953eb 100644
--- a/lzma_data_test.go
+++ b/lzma_data_test.go
@@ -7,7 +7,6 @@ package lzma
 import (
 	"io/ioutil"
 	"log"
-	"os"
 )
 
 type lzmaTest struct {
@@ -16,7 +15,7 @@ type lzmaTest struct {
 	size  bool
 	raw   string
 	lzma  []byte
-	err   os.Error
+	err   error
 }
 
 var lzmaTests = []lzmaTest{
@@ -289,7 +288,6 @@ var lzmaTests = []lzmaTest{
 	},
 }
 
-
 type lzmaBenchmark struct {
 	descr string
 	level int
diff --git a/lzma_decoder.go b/lzma_decoder.go
index 6c13baf..1f6d85c 100644
--- a/lzma_decoder.go
+++ b/lzma_decoder.go
@@ -50,8 +50,8 @@
 package lzma
 
 import (
+	"errors"
 	"io"
-	"os"
 )
 
 const (
@@ -89,16 +89,16 @@ const (
 )
 
 // A streamError reports the presence of corrupt input stream.
-var streamError = os.NewError("error in lzma encoded data stream")
+var streamError = errors.New("error in lzma encoded data stream")
 
 // A headerError reports an error in the header of the lzma encoder file.
-var headerError = os.NewError("error in lzma header")
+var headerError = errors.New("error in lzma header")
 
 // A nReadError reports what it's message reads
-var nReadError = os.NewError("number of bytes returned by Reader.Read() didn't meet expectances")
+var nReadError = errors.New("number of bytes returned by Reader.Read() didn't meet expectances")
 
 // A nWriteError reports what it's message reads
-var nWriteError = os.NewError("number of bytes returned by Writer.Write() didn't meet expectances")
+var nWriteError = errors.New("number of bytes returned by Writer.Write() didn't meet expectances")
 
 // TODO: implement this err
 // A dataIntegrityError reports an error encountered while cheching data integrity.
@@ -114,7 +114,6 @@ var nWriteError = os.NewError("number of bytes returned by Writer.Write() didn't
 //	// hz
 //}
 
-
 func stateUpdateChar(index uint32) uint32 {
 	if index < 4 {
 		return 0
@@ -307,7 +306,7 @@ func (z *decoder) doDecode() {
 	//}
 }
 
-func (z *decoder) decoder(r io.Reader, w io.Writer) (err os.Error) {
+func (z *decoder) decoder(r io.Reader, w io.Writer) (err error) {
 	defer handlePanics(&err)
 
 	// read 13 bytes (lzma header)
diff --git a/lzma_encoder.go b/lzma_encoder.go
index fb795ea..5794631 100644
--- a/lzma_encoder.go
+++ b/lzma_encoder.go
@@ -5,9 +5,8 @@
 package lzma
 
 import (
-	"io"
 	"fmt"
-	"os"
+	"io"
 	"strconv"
 	"strings"
 )
@@ -21,7 +20,7 @@ const (
 // local error wrapper so we can distinguish between os.Errors we want
 // to return as errors from genuine panics
 type osError struct {
-	os.Error
+	error
 }
 
 // An argumentValueError reports an error encountered while parsing user provided arguments.
@@ -30,23 +29,23 @@ type argumentValueError struct {
 	val interface{}
 }
 
-func (e *argumentValueError) String() string {
+func (e *argumentValueError) Error() string {
 	return fmt.Sprintf("illegal argument value error: %s with value %v", e.msg, e.val)
 }
 
 // Report error and stop executing. Wraps os.Errors an osError for handlePanics() to
 // distinguish them from genuine panics.
-func throw(err os.Error) {
+func throw(err error) {
 	panic(&osError{err})
 }
 
 // handlePanics is a deferred function to turn a panic with type *osError into a plain error
 // return. Other panics are unexpected and so are re-enabled.
-func handlePanics(error *os.Error) {
+func handlePanics(error *error) {
 	if v := recover(); v != nil {
 		switch e := v.(type) {
 		case *osError:
-			*error = e.Error
+			*error = e.error
 		default:
 			// runtime errors should crash
 			panic(v)
@@ -59,7 +58,7 @@ type syncPipeReader struct {
 	closeChan chan bool
 }
 
-func (sr *syncPipeReader) CloseWithError(err os.Error) os.Error {
+func (sr *syncPipeReader) CloseWithError(err error) error {
 	retErr := sr.PipeReader.CloseWithError(err)
 	sr.closeChan <- true // finish writer close
 	return retErr
@@ -70,7 +69,7 @@ type syncPipeWriter struct {
 	closeChan chan bool
 }
 
-func (sw *syncPipeWriter) Close() os.Error {
+func (sw *syncPipeWriter) Close() error {
 	err := sw.PipeWriter.Close()
 	<-sw.closeChan // wait for reader close
 	return err
@@ -987,7 +986,7 @@ func (z *encoder) doEncode() {
 	}
 }
 
-func (z *encoder) encoder(r io.Reader, w io.Writer, size int64, level int) (err os.Error) {
+func (z *encoder) encoder(r io.Reader, w io.Writer, size int64, level int) (err error) {
 	defer handlePanics(&err)
 
 	// these functions are good candidates for init() but the decoder doesn't need them
@@ -1033,7 +1032,7 @@ func (z *encoder) encoder(r io.Reader, w io.Writer, size int64, level int) (err
 
 	// do not move before w.Write(header)
 	z.re = newRangeEncoder(w)
-	mft, err := strconv.Atoui(strings.Split(z.cl.matchFinder, "")[2])
+	mft, err := strconv.ParseUint(strings.Split(z.cl.matchFinder, "")[2], 10, 0)
 	if err != nil {
 		return
 	}
diff --git a/range_coder.go b/range_coder.go
index 1b9d89f..ee72b6d 100644
--- a/range_coder.go
+++ b/range_coder.go
@@ -7,7 +7,6 @@ package lzma
 import (
 	"bufio"
 	"io"
-	"os"
 )
 
 const (
@@ -22,7 +21,7 @@ const (
 //
 type Reader interface {
 	io.Reader
-	ReadByte() (c byte, err os.Error)
+	ReadByte() (c byte, err error)
 }
 
 type rangeDecoder struct {
@@ -117,7 +116,6 @@ func initBitModels(length uint32) (probs []uint16) {
 	return
 }
 
-
 const (
 	kNumMoveReducingBits  = 2
 	kNumBitPriceShiftBits = 6
@@ -129,8 +127,8 @@ const (
 //
 type Writer interface {
 	io.Writer
-	Flush() os.Error
-	WriteByte(c byte) os.Error
+	Flush() error
+	WriteByte(c byte) error
 }
 
 type rangeEncoder struct {
@@ -224,7 +222,6 @@ func (re *rangeEncoder) encode(probs []uint16, index, symbol uint32) {
 	}
 }
 
-
 var probPrices []uint32 = make([]uint32, kBitModelTotal>>kNumMoveReducingBits) // len(probPrices) = 512
 
 // should be called in the encoder's contructor.