[mkgmap-dev] StandardCharsets and try (with-resources)
From Gerd Petermann gpetermann_muenchen at hotmail.com on Fri Jan 17 16:20:28 GMT 2020
Hi Ticker, - I think there is a small change in the handling of lines in OsmMapDataSource.readDeleteTagsFile. The old code used line = line.trim(); This is missing now. Is that intended? - I also don't understand the line with your comment "// ??? I don't understand this" . Looks like an endless recursive call? - You sometimes replaced FileReader, but not in CombinedStyleFileLoader. Why not? We have a few places where we read files which use "#" for comment lines. Would it help to create a class for that? I made a few minor mods, see attachment. Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces at lists.mkgmap.org.uk> im Auftrag von Ticker Berkin <rwb-mkgmap at jagit.co.uk> Gesendet: Freitag, 17. Januar 2020 13:53 An: Development list for mkgmap Betreff: [mkgmap-dev] StandardCharsets and try (with-resources) Hi Gerd Attached patch - uses StandardCharsets.* where possible. - notes some usage of the java local DefaultCharset. - changed a couple of these to force utf-8 instead. - if --read-config file gives decoding errors, names the charset used to read the file (ie DefaultCharset) instead of 'utf-8' in the error message. - accepts/ignores unicode BOM in more files - uses try (open...) {} where possible in files changed for the above reasons. There is some code in mkgmap/srt/SrtTextReader.java:sortForCodepage() that I don't understand; it would appear to get into a recursive loop on IOException. Ticker On Tue, 2020-01-14 at 09:55 +0000, Gerd Petermann wrote: > Hi Ticker, > > yes, and every missing close() is a brain teaser ;) > We have a few places where files are opened and closed in a different > method. This is likely to cause trouble in unit tests, esp. on > Windows. > Whereever possible we should use try-with-ressources instead of > Utils.closeFile() and add a comment > like in SeaGenerator line > in zipFile = new ZipFile(precompSeaDir); // don't close here! > when a file is intentionally kept open. > > Gerd > > ________________________________________ > Von: mkgmap-dev <mkgmap-dev-bounces at lists.mkgmap.org.uk> im Auftrag > von Ticker Berkin <rwb-mkgmap at jagit.co.uk> > Gesendet: Dienstag, 14. Januar 2020 10:43 > An: Development list for mkgmap > Betreff: Re: [mkgmap-dev] TYP files and character encoding > > Hi Gerd > > Here is updated patch that closes the file, although I find many > files > in mkgmap that don't have explicit close(), but I presume .finalize() > will close them eventually. > > I'll do another patch for other text file handling, using > StandardCharset where possible and fixing TokenScanner message for > bad > characters if not utf-8 and, if reasonable, allowing a BOM even if > the > file is opened as utf-8 anyway. > > Ticker > > On Tue, 2020-01-14 at 08:21 +0000, Gerd Petermann wrote: > > Hi Ticker, > > > > thanks for the patch. > > > > Please review TypCompiler.CharsetProbe. BufferedReader br is not > > closed. Is that intended? > > > > I see that we have a mix of "utf-8" and "UTF-8" in the mkgmap > > sources. I think it would be good to use StandardCharsets.UTF_8 > > where > > possible > > and unify the rest. -------------- next part -------------- A non-text attachment was scrubbed... Name: utf8-v2.patch Type: application/octet-stream Size: 24468 bytes Desc: utf8-v2.patch URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20200117/be0c9ce9/attachment-0001.obj>
- Previous message: [mkgmap-dev] StandardCharsets and try (with-resources)
- Next message: [mkgmap-dev] StandardCharsets and try (with-resources)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the mkgmap-dev mailing list