Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Feb 2005 20:06:25 +0100 (CET)
From:      Helge Oldach <palmdoc@oldach.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Simon Dick <simond@irrelevant.org>
Subject:   ports/77228: bug fixes for p5-Palm-PalmDoc (with patch)
Message-ID:  <200502071906.j17J6PZI020482@sep.oldach.net>
Resent-Message-ID: <200502071910.j17JA7ZE023221@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         77228
>Category:       ports
>Synopsis:       bug fixes for p5-Palm-PalmDoc (with patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 07 19:10:07 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Helge Oldach
>Release:        FreeBSD 4.11-STABLE i386
>Organization:
none at all
>Environment:
System: FreeBSD localhost 4.11-STABLE FreeBSD 4.11-STABLE #2087: Sat Jan 29 23:19:10 CET 2005 toor@localhost:/usr/obj/usr/src/sys/GENERIC i386


	
>Description:

Owner of PalmDoc (Hendrik Van Belleghem) has been notified, but no
response so far... So let's just fix the FreeBSD port in the first
place:

I think I have spotted (and fixed) two errors in version 0.12 of
Palm::PalmDoc.

Firstly, I stumbled over error messages like this one:

substr outside of string at /usr/local/lib/perl5/site_perl/5.005/Palm/PalmDoc.pm line 320.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/5.005/Palm/PalmDoc.pm line 320.

Some debugging revealed that they show up when the last character of a
block has the high bit set. Some further debugging with this sample code

	$doc->body("ö" x 1 . " " .
		"ä" x 2 . " " .
		"ü" x 3 . " " .
		"ß" x 4 . " " .
		"Ö" x 5 . " " .
		"Ü" x 6 . " " .
		"Ä" x 7 . " " .
		"·" x 8 . " " .
		"½" x 9 . " " .
		"¼" x 10);

revealed that the repeated sequences are encoded correctly, but rather
strangely:

    03 f6 20 e4 04 e4 20 fc fc 05 fc 20 df df df 06 |.. ... .... ....|
    df 20 d6 d6 d6 d6 07 d6 20 dc dc dc dc dc 08 dc |. ...... .......|
    20 c4 c4 c4 c4 c4 c4 08 c4 20 b7 b7 b7 b7 b7 b7 | ........ ......|
    01 b7 08 b7 20 bd bd bd bd bd bd 02 bd bd 08 bd |.... ...........|
    20 bc bc bc bc bc bc 03 bc bc bc 01 bc          | ............   |

This is what I would have expected (each sequence of up to eight
8-bit-set bytes encoded into "copy verbatim" sequence):

    01 f6 20 02 e4 e4 20 03 fc fc fc 20 04 df df df |.. ... .... ....|
    df 20 05 d6 d6 d6 d6 d6 20 06 dc dc dc dc dc dc |. ...... .......|
    20 07 c4 c4 c4 c4 c4 c4 c4 20 08 b7 b7 b7 b7 b7 | ........ ......|
    b7 b7 b7 20 08 bd bd bd bd bd bd bd bd 01 bd 20 |... ........... |
    08 bc bc bc bc bc bc bc bc 02 bc bc             |............    |

I have changed line 320 from

                while ( (substr($block,$index + ($y + 1),1)  =~

to

                while ( (substr($block,$index + $y,1)  =~

and things are fine. No error messages any more, and the encoding is as
expected. $y is just out of range to detect the first match, skipping
the second character in each turn.

The second error is rather trivial, it shows up with perl 5.6 and above
as the famous "Character in \"c\" format wrapped in pack" message. Line
416 is simply using the wrong pack() format:

                              $compr_buff .= pack("c", ord ($byte2) | 0x80 );

This should clearly be a "C" as we always deliver a positive integer in
the range 0..255 as the argument to pack.

	
>How-To-Repeat:
	
>Fix:

--- PalmDoc.pm.ORIG	Fri Jun 20 00:05:16 2003
+++ PalmDoc.pm	Sat Feb  5 07:09:58 2005
@@ -317,7 +317,7 @@
 
 		$y = 1;			# found at least one!
 
-		while ( (substr($block,$index + ($y + 1),1)  =~ 
+		while ( (substr($block,$index + $y,1)  =~ 
 			      /[\200-\377]/) &&
 			($y < 8) ) {
 
@@ -413,7 +413,7 @@
 							# Set the high bit
 							# and add to output 
 							# buffer.
-	         		$compr_buff .= pack("c", ord ($byte2) | 0x80 );
+	         		$compr_buff .= pack("C", ord ($byte2) | 0x80 );
 				$index += 2;		# Compressed 2 bytes
 	
 		} else {


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200502071906.j17J6PZI020482>