Fix TeX "pool overflow" with very long filenames.

Add test case taken from the jawiki.

Change-Id: Iba92c5cd6a275859a38b7015440737751d2a5a36