Index: pkpgcounter/trunk/pkpgpdls/pdlparser.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/pdlparser.py (revision 443)
+++ pkpgcounter/trunk/pkpgpdls/pdlparser.py (revision 450)
@@ -140,5 +140,5 @@
             mustclose = 0
         else :    
-            infile = open(arg, "rb")
+            infile = open(arg, "rbU")
             mustclose = 1
         try :
Index: pkpgcounter/trunk/pkpgpdls/pdf.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/pdf.py (revision 428)
+++ pkpgcounter/trunk/pkpgpdls/pdf.py (revision 450)
@@ -62,45 +62,45 @@
         inobject = 0
         objre = re.compile(r"\s?(\d+)\s+(\d+)\s+obj[<\s/]?")
-        for fullline in self.infile.xreadlines() :
-            parts = [ l.strip() for l in fullline.splitlines() ]
-            for line in parts :
-                if line.startswith("% ") :    
+        for line in self.infile :
+            line = line.strip()
+            if line.startswith("% ") :    
+                if inobject :
+                    obj.comments.append(line)
+                else :
+                    lastcomment = line[2:]
+            else :
+                # New object begins here
+                result = objre.search(line)
+                if result is not None :
+                    (major, minor) = [int(num) for num in line[result.start():result.end()].split()[:2]]
+                    obj = PDFObject(major, minor, lastcomment)
+                    obj.content.append(line[result.end():])
+                    inobject = 1
+                elif line.startswith("endobj") \
+                  or line.startswith(">> endobj") \
+                  or line.startswith(">>endobj") :
+                    # Handle previous object, if any
                     if inobject :
-                        obj.comments.append(line)
-                    else :
-                        lastcomment = line[2:]
-                else :
-                    # New object begins here
-                    result = objre.search(line)
-                    if result is not None :
-                        (major, minor) = [int(num) for num in line[result.start():result.end()].split()[:2]]
-                        obj = PDFObject(major, minor, lastcomment)
-                        obj.content.append(line[result.end():])
-                        inobject = 1
-                    elif line.startswith("endobj") \
-                      or line.startswith(">> endobj") \
-                      or line.startswith(">>endobj") :
-                        # Handle previous object, if any
-                        if inobject :
-                            # only overwrite older versions of this object
-                            # same minor seems to be possible, so the latest one
-                            # found in the file will be the one we keep.
-                            # if we want the first one, just use > instead of >=
-                            oldobject = objects.setdefault(major, obj)
-                            if minor >= oldobject.minor :
-                                objects[major] = obj
-                            inobject = 0        
-                    else :    
-                        if inobject :
-                            obj.content.append(line)
+                        # only overwrite older versions of this object
+                        # same minor seems to be possible, so the latest one
+                        # found in the file will be the one we keep.
+                        # if we want the first one, just use > instead of >=
+                        oldobject = objects.setdefault(major, obj)
+                        if minor >= oldobject.minor :
+                            objects[major] = obj
+                        inobject = 0        
+                else :    
+                    if inobject :
+                        obj.content.append(line)
                         
         # Now we check each PDF object we've just created.
         # colorregexp = re.compile(r"(/ColorSpace) ?(/DeviceRGB|/DeviceCMYK)[/ \t\r\n]", re.I)
-        newpageregexp = re.compile(r"(/Type)\s?(/Page)[/\s]", re.I)
+        newpageregexp = re.compile(r"(/Type)\s?(/Page)[/>\s]", re.I)
         pagecount = 0
         for obj in objects.values() :
             content = "".join(obj.content)
             count = len(newpageregexp.findall(content))
-            pagecount += count
+            if count and (content != r"<</Type /Page>>") : # Empty pages which are not rendered ?
+                pagecount += count
         return pagecount    
         
Index: pkpgcounter/trunk/pkpgpdls/postscript.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/postscript.py (revision 448)
+++ pkpgcounter/trunk/pkpgpdls/postscript.py (revision 450)
@@ -91,5 +91,5 @@
         acrobatmarker = 0
         pagescomment = None
-        for line in self.infile.xreadlines() : 
+        for line in self.infile : 
             if (not prescribe) and line.startswith(r"%%BeginResource: procset pdf") \
                and not acrobatmarker :
Index: pkpgcounter/trunk/pkpgpdls/analyzer.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/analyzer.py (revision 443)
+++ pkpgcounter/trunk/pkpgpdls/analyzer.py (revision 450)
@@ -110,10 +110,10 @@
         else :    
             # normal file
-            self.infile = open(self.filename, "rb")
+            self.infile = open(self.filename, "rbU")
             self.mustclose = 1
             return
             
         # Use a temporary file, always seekable contrary to standard input.
-        self.infile = tempfile.TemporaryFile(mode="w+b")
+        self.infile = tempfile.TemporaryFile(mode="w+bU")
         while 1 :
             data = infile.read(pdlparser.MEGABYTE) 
Index: pkpgcounter/trunk/pkpgpdls/version.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/version.py (revision 447)
+++ pkpgcounter/trunk/pkpgpdls/version.py (revision 450)
@@ -23,5 +23,5 @@
 
 
-__version__ = "2.15alpha"
+__version__ = "2.15"
 
 __doc__ = """pkpgcounter : a generic Page Description Languages parser."""
Index: pkpgcounter/trunk/man/pkpgcounter.1
===================================================================
--- pkpgcounter/trunk/man/pkpgcounter.1 (revision 445)
+++ pkpgcounter/trunk/man/pkpgcounter.1 (revision 450)
@@ -1,8 +1,8 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.36.
-.TH PKPGCOUNTER "1" "January 2007" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
+.TH PKPGCOUNTER "1" "February 2007" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
 .SH NAME
-pkpgcounter \- manual page for pkpgcounter 2.14
+pkpgcounter \- manual page for pkpgcounter 2.15
 .SH DESCRIPTION
-pkpgcounter v2.14 (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet
+pkpgcounter v2.15 (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet
 .PP
 pkpgcounter is a generic Page Description Language parser.
Index: pkpgcounter/trunk/NEWS
===================================================================
--- pkpgcounter/trunk/NEWS (revision 444)
+++ pkpgcounter/trunk/NEWS (revision 450)
@@ -22,4 +22,11 @@
 pkpgcounter News :
 
+  * 2.15 :
+   
+    - Fixed a regexp in the PDF parser which caused some files to be
+      incorrectly accounted for.
+    
+    - Improved the detection of the number of copies in PostScript documents.
+    
   * 2.14 :
   
