[Bins] [patch] bins omits names with special characters, when (`locale charmap` eq 'ANSI_X3.4-1968')

J.P. Larocque piranha at thoughtcrime.us
Sun Oct 5 11:31:14 BST 2003


Hello,

First, let me say hi: I tried out bins a few days ago, and was quite
impressed with the features and the layout, with the joi template
particularly.  Installation of its dependencies is a huge hassle on
non-Debian systems, however I haven't taken the time to investigate
and document exactly what went wrong with installing the dependencies
on an OpenBSD system.

bins (in my configuration) wouldn't handle directories with non-ASCII,
Latin-1 characters very well: All the HTML links would be correct, but
the name of these directories would not be outputted anywhere in the
HTML, or from the bins program as it prints which directory it's
processing ("> dir > sub-dir-with-special-character >" would become ">
dir > >").  bins also printed out warnings when it got to these
directories.  For instance:

	 > France Photos > October 1, 2003 > 
	Use of uninitialized value in concatenation (.) or string at /home/piranha/usr/bin/bins line 2197.
	Use of uninitialized value in concatenation (.) or string at /home/piranha/usr/bin/bins line 1431.
	 > France Photos > October 1, 2003 >  > 
	Use of uninitialized value in concatenation (.) or string at /home/piranha/usr/bin/bins line 1431.
	 > France Photos > October 1, 2003 >  > building exterior > 

I couldn't find a bins FAQ, or any mention of this problem on the bins
website or in a (cursory) search of the list archive.

I did some debugging, and all the trouble seemed to be coming from
local2html(); '$local2htmlConverter->convert(shift)' wasn't returning
a proper value.  I found this bit of code just before
$local2htmlConverter is assigned:

	my $localEncoding = `locale charmap`;
	# ANSI is unspeakably primitive, keep LATIN1 instead
	if ($? == 0 && $localEncoding && ($localEncoding ne "ANSI_X3.4-1968")) {
	  chop($localEncoding);
	  $defaultConfig{defaultEncoding} = $localEncoding;
	  beVerboseN("Forcing encoding to $localEncoding", 2);
	}

running 'locale charmap' on my account on this system returned
'ANSI_X3.4-1968'.  I'm really unfamiliar with how the locale system
works; all I can say is that I'm English-speaking, so I've mostly
ignored the matter.  My LANG variable is set to 'C', and I have no
LC_* variables set, if that's relevant at all.

The problem with the chunk of code above is that the output of the
locale command will have a newline at the end.  The literal string in
the comparison with that variable does not include the newline.  The
newline is 'chop'ed after the improbable condition is met.

Changing the code to this removes the warnings and makes bins
otherwise function as expected:

	chomp (my $localEncoding = `locale charmap`);
	# ANSI is unspeakably primitive, keep LATIN1 instead
	if ($? == 0 && $localEncoding && ($localEncoding ne "ANSI_X3.4-1968")) {
	  $defaultConfig{defaultEncoding} = $localEncoding;
	  beVerboseN("Forcing encoding to $localEncoding", 2);
	}

I believe that change at least makes bins operate in the manner that
was originally meant when that condition was written.  If I really
should be using different environment variables, though, let me know.

-- 
- J.P. Larocque, <piranha at ely.ath.cx>, <piranha at thoughtcrime.us>
- The attachment is a PGP sig, not a "virus"; you don't have to open it.
- Encrypted e-mail preferred; 0x0c14cdda; http://ely.ath.cx/~piranha/pgp
- "Beer is the cause of and solution to all of life's problems."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://www.email-lists.org/pipermail/bins/attachments/20031005/14b166df/attachment.bin


More information about the Bins mailing list