[gdal] 03/08: Imported Upstream version 1.11.2+dfsg

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Thu Feb 19 00:17:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch experimental
in repository gdal.

commit 225f50a8028e43baad6b4595b050e246ee32c1a6
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Feb 17 22:44:00 2015 +0100

    Imported Upstream version 1.11.2+dfsg
---
 COMMITERS                                          |   2 +-
 GDALmake.opt.in                                    |   3 +-
 NEWS                                               | 149 ++++++++
 VERSION                                            |   2 +-
 alg/gdal_rpc.cpp                                   | 385 +++++++++++----------
 alg/gdalrasterize.cpp                              |  15 +-
 alg/gdaltransformer.cpp                            |  67 ++--
 alg/gdalwarper.cpp                                 |  14 +-
 alg/gdalwarper.h                                   |   6 +-
 alg/gdalwarpkernel.cpp                             |   7 +-
 alg/gdalwarpkernel_opencl.c                        |   6 +-
 alg/gdalwarpoperation.cpp                          |  14 +-
 alg/llrasterize.cpp                                |  13 +-
 apps/GNUmakefile                                   |   2 +-
 apps/gdal_contour.cpp                              |  19 +-
 apps/gdal_translate.cpp                            |   6 +-
 apps/gdalbuildvrt.cpp                              |   8 +-
 apps/gdaldem.cpp                                   |  74 ++--
 apps/gdalenhance.cpp                               |   6 +-
 apps/gdalserver.c                                  |   6 +-
 apps/gdaltindex.c                                  |   6 +-
 apps/gdalwarp.cpp                                  |  38 +-
 apps/makefile.vc                                   |  64 ++--
 apps/ogr2ogr.cpp                                   |  43 ++-
 apps/ogrlineref.cpp                                |  23 +-
 configure                                          | 101 +++++-
 configure.in                                       |  35 +-
 data/gml_registry.xml                              |   7 +
 data/ruian_vf_ob_v1.gfs                            | 331 +++++++++++++++++-
 data/ruian_vf_st_uvoh_v1.gfs                       |  92 +++++
 data/ruian_vf_st_v1.gfs                            |  28 +-
 data/ruian_vf_v1.gfs                               |  42 +--
 frmts/arg/argdataset.cpp                           |  20 +-
 frmts/ceos2/ceosrecipe.c                           |  12 +-
 frmts/e00grid/e00read.c                            |  21 +-
 frmts/ecw/ecwcreatecopy.cpp                        |  27 +-
 frmts/ecw/ecwdataset.cpp                           |  55 ++-
 frmts/ecw/jp2userbox.cpp                           |  14 +-
 frmts/fits/fitsdataset.cpp                         |  16 +-
 frmts/gif/biggifdataset.cpp                        |  11 +-
 frmts/gif/gifdataset.cpp                           |  19 +-
 frmts/grass/grass57dataset.cpp                     |   5 +-
 frmts/grib/degrib18/degrib/clock.c                 |   6 +-
 frmts/grib/degrib18/degrib/degrib1.cpp             |  12 +-
 frmts/grib/degrib18/degrib/grib2api.c              |  12 +-
 frmts/grib/degrib18/degrib/inventory.cpp           |   8 +-
 frmts/grib/degrib18/degrib/tdlpack.cpp             |  10 +-
 frmts/grib/degrib18/g2clib-1.0.4/compack.c         |   4 +-
 frmts/grib/degrib18/g2clib-1.0.4/jpcunpack.c       |   6 +-
 frmts/grib/degrib18/g2clib-1.0.4/misspack.c        |   8 +-
 frmts/grib/degrib18/g2clib-1.0.4/mkieee.c          |   4 +-
 frmts/grib/degrib18/g2clib-1.0.4/reduce.c          |   9 +-
 frmts/grib/degrib18/g2clib-1.0.4/seekgb.c          |   8 +-
 frmts/grib/degrib18/g2clib-1.0.4/simunpack.c       |   9 +-
 frmts/grib/degrib18/g2clib-1.0.4/specpack.c        |   6 +-
 frmts/gsg/gs7bgdataset.cpp                         |  10 +-
 frmts/gsg/gsbgdataset.cpp                          |  12 +-
 frmts/gtiff/geotiff.cpp                            |  55 ++-
 frmts/gtiff/gt_citation.cpp                        |   8 +-
 frmts/gtiff/gt_jpeg_copy.cpp                       |  35 +-
 frmts/gtiff/libgeotiff/geo_new.c                   |   7 +-
 frmts/gtiff/libgeotiff/geo_print.c                 |  15 +-
 frmts/gtiff/libtiff/tif_dir.c                      |  50 ++-
 frmts/gtiff/libtiff/tif_dirinfo.c                  |  30 +-
 frmts/gtiff/libtiff/tif_dirread.c                  |  37 +-
 frmts/gtiff/libtiff/tif_getimage.c                 |  39 ++-
 frmts/gtiff/libtiff/tif_lzw.c                      |   4 +-
 frmts/gtiff/libtiff/tif_next.c                     |  25 +-
 frmts/gtiff/libtiff/tif_ojpeg.c                    |  13 +-
 frmts/gtiff/libtiff/tif_read.c                     |  15 +-
 frmts/gtiff/libtiff/tif_vsi.c                      |   8 +-
 frmts/gtiff/libtiff/tif_zip.c                      |   4 +-
 frmts/gtiff/libtiff/tiff.h                         |   5 +-
 frmts/gtiff/libtiff/tiffvers.h                     |   2 +-
 frmts/hdf4/hdf4dataset.cpp                         |  10 +-
 frmts/hdf4/makefile.vc                             |   5 +
 frmts/hdf5/hdf5dataset.cpp                         |   9 +-
 frmts/hdf5/hdf5imagedataset.cpp                    |  21 +-
 frmts/hdf5/makefile.vc                             |   5 +
 frmts/hfa/hfaband.cpp                              |   6 +-
 frmts/hfa/hfaopen.cpp                              |  16 +-
 frmts/hfa/hfatype.cpp                              |  15 +-
 frmts/ilwis/ilwiscoordinatesystem.cpp              |  59 ++--
 frmts/ilwis/ilwisdataset.cpp                       |  18 +-
 frmts/iris/irisdataset.cpp                         |  26 +-
 frmts/jpeg/GNUmakefile                             |   2 +
 frmts/jpeg/frmt_jpeg.html                          |   8 +
 frmts/jpeg/jpgdataset.cpp                          | 100 +++++-
 frmts/jpeg/libjpeg/jccoefct.c                      |   3 +-
 frmts/jpeg/libjpeg/jccolor.c                       |   3 +-
 frmts/jpeg/libjpeg/jcmarker.c                      |   7 +-
 frmts/jpeg/libjpeg/jcsample.c                      |   3 +-
 frmts/jpeg/libjpeg/jctrans.c                       |   3 +-
 frmts/jpeg/libjpeg/jdatasrc.c                      |   3 +-
 frmts/jpeg/libjpeg/jdcoefct.c                      |   4 +-
 frmts/jpeg/libjpeg/jdcolor.c                       |   3 +-
 frmts/jpeg/libjpeg/jdmerge.c                       |   8 +-
 frmts/jpeg/libjpeg/jdpostct.c                      |   9 +-
 frmts/jpeg/libjpeg/jdsample.c                      |  13 +-
 frmts/jpeg/libjpeg/jmemansi.c                      |  22 +-
 frmts/jpeg/libjpeg/jquant1.c                       |  10 +-
 frmts/jpeg/libjpeg/jquant2.c                       |   6 +-
 frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp   |  15 +-
 frmts/leveller/levellerdataset.cpp                 |   3 +-
 frmts/mrsid/nmake.opt                              |   2 +
 frmts/mrsid_lidar/gdal_MG4Lidar.cpp                |  10 +-
 frmts/msgn/msg_basic_types.cpp                     |  11 +-
 frmts/netcdf/gmtdataset.cpp                        |  19 +-
 frmts/netcdf/makefile.vc                           |   4 +
 frmts/netcdf/netcdfdataset.cpp                     |  30 +-
 frmts/nitf/nitffile.c                              |  24 +-
 frmts/nitf/nitfimage.c                             |  71 ++--
 frmts/northwood/northwood.cpp                      |   6 +-
 frmts/openjpeg/GNUmakefile                         |   4 +
 frmts/openjpeg/makefile.vc                         |   6 +-
 frmts/openjpeg/openjpegdataset.cpp                 |  20 +-
 frmts/pcidsk/sdk/channel/ctiledchannel.cpp         |  10 +-
 frmts/pcidsk/sdk/core/libjpeg_io.cpp               |  22 +-
 frmts/pcidsk/sdk/core/pcidskcreate.cpp             |   9 +-
 frmts/pcidsk/sdk/segment/cpcidsk_array.cpp         |   8 +-
 frmts/pcidsk/sdk/segment/cpcidskbitmap.cpp         |  41 +--
 frmts/pcraster/libcsf/mopen.c                      |  23 +-
 frmts/pdf/GNUmakefile                              |   2 +-
 frmts/pdf/makefile.vc                              |   2 +-
 frmts/pdf/pdfcreatecopy.cpp                        |  26 +-
 frmts/pdf/pdfdataset.cpp                           |  28 +-
 frmts/pds/isis3dataset.cpp                         |   2 +-
 frmts/postgisraster/postgisrasterdataset.cpp       |  16 +-
 .../postgisraster/postgisrastertilerasterband.cpp  |  12 +-
 frmts/raw/cpgdataset.cpp                           |  23 +-
 frmts/raw/genbindataset.cpp                        |   5 +-
 frmts/raw/hkvdataset.cpp                           |  29 +-
 frmts/rs2/rs2dataset.cpp                           |  24 +-
 frmts/saga/sagadataset.cpp                         |   6 +-
 frmts/usgsdem/usgsdemdataset.cpp                   |  65 ++--
 frmts/vrt/vrtdataset.cpp                           |  21 +-
 frmts/vrt/vrtsources.cpp                           |  14 +-
 frmts/webp/webpdataset.cpp                         |  12 +-
 frmts/xyz/xyzdataset.cpp                           |  10 +-
 gcore/GNUmakefile                                  |   3 +-
 gcore/gdal_priv.h                                  |  22 +-
 gcore/gdal_version.h                               |   6 +-
 gcore/gdalproxypool.cpp                            |   7 +-
 gcore/gdalrasterband.cpp                           |  23 +-
 gcore/gdalrescaledalphaband.cpp                    | 144 ++++++++
 gcore/gdalvirtualmem.cpp                           |  12 +-
 gcore/makefile.vc                                  |   2 +-
 gcore/overview.cpp                                 |  19 +-
 gcore/rasterio.cpp                                 |  12 +-
 m4/ax_oracle_oci.m4                                |   9 +-
 man/man1/gdal-config.1                             |   4 +-
 man/man1/gdal2tiles.1                              |   4 +-
 man/man1/gdal_calc.1                               |   4 +-
 man/man1/gdal_contour.1                            |   4 +-
 man/man1/gdal_edit.1                               |   4 +-
 man/man1/gdal_fillnodata.1                         |   4 +-
 man/man1/gdal_grid.1                               |   4 +-
 man/man1/gdal_merge.1                              |   4 +-
 man/man1/gdal_polygonize.1                         |   4 +-
 man/man1/gdal_proximity.1                          |   4 +-
 man/man1/gdal_rasterize.1                          |   4 +-
 man/man1/gdal_retile.1                             |   4 +-
 man/man1/gdal_sieve.1                              |   4 +-
 man/man1/gdal_translate.1                          |   4 +-
 man/man1/gdal_utilities.1                          |   4 +-
 man/man1/gdaladdo.1                                |   4 +-
 man/man1/gdalbuildvrt.1                            |   4 +-
 man/man1/gdalcompare.1                             |   4 +-
 man/man1/gdaldem.1                                 |   4 +-
 man/man1/gdalinfo.1                                |   4 +-
 man/man1/gdallocationinfo.1                        |   4 +-
 man/man1/gdalmanage.1                              |   4 +-
 man/man1/gdalmove.1                                |   4 +-
 man/man1/gdalsrsinfo.1                             |   4 +-
 man/man1/gdaltindex.1                              |   4 +-
 man/man1/gdaltransform.1                           |   4 +-
 man/man1/gdalwarp.1                                |   4 +-
 man/man1/nearblack.1                               |   4 +-
 man/man1/ogr2ogr.1                                 |   4 +-
 man/man1/ogr_utilities.1                           |   4 +-
 man/man1/ogrinfo.1                                 |   4 +-
 man/man1/ogrlineref.1                              |   4 +-
 man/man1/ogrtindex.1                               |   4 +-
 man/man1/pct2rgb.1                                 |   4 +-
 man/man1/rgb2pct.1                                 |   4 +-
 nmake.opt                                          |   6 +-
 ogr/gml2ogrgeometry.cpp                            |  26 +-
 ogr/ogr_core.h                                     |   8 +-
 ogr/ogr_srs_pci.cpp                                |  11 +-
 ogr/ogr_srs_proj4.cpp                              |   9 +-
 ogr/ogr_srs_xml.cpp                                |  16 +-
 ogr/ogrfeature.cpp                                 |  26 +-
 ogr/ogrpgeogeometry.cpp                            |  10 +-
 ogr/ogrsf_frmts/avc/avc_bin.c                      |  16 +-
 ogr/ogrsf_frmts/avc/avc_e00read.c                  |   9 +-
 ogr/ogrsf_frmts/avc/avc_misc.c                     |   6 +-
 ogr/ogrsf_frmts/csv/ogrcsvdatasource.cpp           |   8 +-
 ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp                |  16 +-
 ogr/ogrsf_frmts/dgn/dgnwrite.cpp                   |  23 +-
 ogr/ogrsf_frmts/dxf/intronurbs.cpp                 |   5 +-
 ogr/ogrsf_frmts/dxf/ogrdxf_dimension.cpp           |  26 +-
 ogr/ogrsf_frmts/dxf/ogrdxf_hatch.cpp               |  10 +-
 ogr/ogrsf_frmts/elastic/ogrelasticdatasource.cpp   |   9 +-
 ogr/ogrsf_frmts/filegdb/FGdbDriver.cpp             |  26 +-
 ogr/ogrsf_frmts/generic/ogrlayer.cpp               |   6 +-
 ogr/ogrsf_frmts/geoconcept/geoconcept.c            |  47 +--
 ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp |   4 +-
 ogr/ogrsf_frmts/geojson/ogr_geojson.h              |   5 +-
 ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp      |  31 +-
 ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp       |  11 +-
 ogr/ogrsf_frmts/geojson/ogrgeojsonreader.h         |   4 +-
 ogr/ogrsf_frmts/geomedia/ogrgeomediadatasource.cpp |  10 +-
 ogr/ogrsf_frmts/geomedia/ogrgeomediadriver.cpp     |   8 +-
 ogr/ogrsf_frmts/geomedia/ogrgeomedialayer.cpp      |   7 +-
 ogr/ogrsf_frmts/gft/ogrgftlayer.cpp                |   7 +-
 ogr/ogrsf_frmts/gml/gmlhandler.cpp                 |  21 +-
 ogr/ogrsf_frmts/gml/hugefileresolver.cpp           |  16 +-
 ogr/ogrsf_frmts/gmt/ogrgmtlayer.cpp                |   8 +-
 ogr/ogrsf_frmts/grass/ogrgrassdatasource.cpp       |   8 +-
 ogr/ogrsf_frmts/ili/ili1reader.cpp                 |   6 +-
 ogr/ogrsf_frmts/ili/ili2handler.cpp                |  43 ++-
 ogr/ogrsf_frmts/ili/ili2reader.cpp                 |  20 +-
 ogr/ogrsf_frmts/ili/ogrili1datasource.cpp          |  14 +-
 ogr/ogrsf_frmts/ili/ogrili1layer.cpp               |  10 +-
 ogr/ogrsf_frmts/ili/ogrili2datasource.cpp          |  15 +-
 ogr/ogrsf_frmts/ili/ogrili2layer.cpp               |  10 +-
 ogr/ogrsf_frmts/libkml/ogr_libkml.h                |   2 -
 ogr/ogrsf_frmts/libkml/ogrlibkmldatasource.cpp     |  35 +-
 ogr/ogrsf_frmts/libkml/ogrlibkmldriver.cpp         |  40 ++-
 ogr/ogrsf_frmts/libkml/ogrlibkmlfeature.cpp        |   4 +-
 ogr/ogrsf_frmts/libkml/ogrlibkmllayer.cpp          |  10 +-
 ogr/ogrsf_frmts/mitab/mitab_bounds.cpp             |   2 +-
 ogr/ogrsf_frmts/mitab/mitab_feature.cpp            |  49 +--
 ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp            |   5 +-
 ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp        |   3 +-
 ogr/ogrsf_frmts/mitab/mitab_miffile.cpp            |   6 +-
 ogr/ogrsf_frmts/mitab/mitab_spatialref.cpp         |  12 +-
 ogr/ogrsf_frmts/mitab/mitab_tabfile.cpp            |  12 +-
 ogr/ogrsf_frmts/mitab/mitab_tabseamless.cpp        |   4 +-
 .../mssqlspatial/ogrmssqlgeometryvalidator.cpp     |  10 +-
 .../mssqlspatial/ogrmssqlspatialdatasource.cpp     | 179 ++++++----
 .../mssqlspatial/ogrmssqlspatialdriver.cpp         |  10 +-
 .../mssqlspatial/ogrmssqlspatiallayer.cpp          |   8 +-
 .../mssqlspatial/ogrmssqlspatialselectlayer.cpp    |  14 +-
 .../mssqlspatial/ogrmssqlspatialtablelayer.cpp     |  12 +-
 ogr/ogrsf_frmts/mysql/ogrmysqldatasource.cpp       |  20 +-
 ogr/ogrsf_frmts/mysql/ogrmysqlresultlayer.cpp      |   8 +-
 ogr/ogrsf_frmts/mysql/ogrmysqltablelayer.cpp       |  26 +-
 ogr/ogrsf_frmts/nas/drv_nas.html                   |   8 +-
 ogr/ogrsf_frmts/nas/nashandler.cpp                 |  21 +-
 ogr/ogrsf_frmts/nas/nasreader.cpp                  |  21 +-
 ogr/ogrsf_frmts/nas/nasreaderp.h                   |   4 +-
 ogr/ogrsf_frmts/nas/ogrnasdatasource.cpp           |  26 +-
 ogr/ogrsf_frmts/nas/ogrnasdriver.cpp               |   8 +-
 ogr/ogrsf_frmts/oci/ogrocitablelayer.cpp           |  15 +-
 ogr/ogrsf_frmts/odbc/ogrodbcdatasource.cpp         |  15 +-
 ogr/ogrsf_frmts/odbc/ogrodbclayer.cpp              |   8 +-
 ogr/ogrsf_frmts/ods/ods_formula_node.cpp           |   5 +-
 ogr/ogrsf_frmts/openair/ogropenairlayer.cpp        |  23 +-
 ogr/ogrsf_frmts/openfilegdb/filegdbindex.cpp       |   4 +-
 ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h      |  10 +-
 .../openfilegdb/ogropenfilegdbdatasource.cpp       | 158 +++++----
 .../openfilegdb/ogropenfilegdblayer.cpp            |   6 +-
 ogr/ogrsf_frmts/osm/gpb.h                          |   3 +-
 ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp           |   7 +-
 ogr/ogrsf_frmts/osm/osm_parser.cpp                 |   5 +-
 ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp             |   7 +-
 ogr/ogrsf_frmts/pg/ogrpglayer.cpp                  |  15 +-
 ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp             |   6 +-
 ogr/ogrsf_frmts/pgeo/ogrpgeodatasource.cpp         |  10 +-
 ogr/ogrsf_frmts/pgeo/ogrpgeodriver.cpp             |  12 +-
 ogr/ogrsf_frmts/pgeo/ogrpgeolayer.cpp              |   7 +-
 ogr/ogrsf_frmts/pgeo/ogrpgeotablelayer.cpp         |   7 +-
 ogr/ogrsf_frmts/s57/ogrs57layer.cpp                |   8 +-
 ogr/ogrsf_frmts/s57/s57reader.cpp                  |  19 +-
 ogr/ogrsf_frmts/s57/s57writer.cpp                  |  32 +-
 ogr/ogrsf_frmts/shape/ogrshapelayer.cpp            |  16 +-
 ogr/ogrsf_frmts/shape/shape2ogr.cpp                |  11 +-
 ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp          |   5 +-
 ogr/ogrsf_frmts/sqlite/ogrsqliteregexp.cpp         |   4 +-
 ogr/ogrsf_frmts/sqlite/ogrsqlitetablelayer.cpp     |  23 +-
 ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp            |   6 +-
 ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp     |  43 +--
 ogr/ogrsf_frmts/sxf/ogrsxfdatasource.cpp           |  49 +--
 ogr/ogrsf_frmts/sxf/ogrsxflayer.cpp                |   4 +-
 ogr/ogrsf_frmts/vfk/vfkdatablocksqlite.cpp         |  18 +-
 ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp                |  37 +-
 ogr/ogrsf_frmts/walk/ogrwalkdriver.cpp             |   9 +-
 ogr/ogrsf_frmts/walk/ogrwalktablelayer.cpp         |   3 +-
 ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp           |  10 +-
 ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp         |   9 +-
 ogr/ogrsf_frmts/xplane/ogr_xplane_apt_reader.cpp   |  10 +-
 ogr/ogrsf_frmts/xplane/ogr_xplane_nav_reader.cpp   |   8 +-
 port/cpl_csv.cpp                                   |  34 +-
 port/cpl_odbc.cpp                                  |  15 +-
 port/cpl_string.cpp                                |  75 ++--
 port/cpl_vsil_curl.cpp                             |  16 +-
 swig/include/gdal_array.i                          |  10 +-
 swig/include/perl/gdal_perl.i                      |   4 +-
 swig/include/python/ogr_python.i                   |  18 +-
 swig/include/python/python_exceptions.i            |  16 +-
 swig/perl/lib/Geo/GDAL.pm                          |   4 +-
 swig/python/extensions/gdal_array_wrap.cpp         |   8 +-
 swig/python/extensions/gdal_wrap.cpp               |  16 +-
 swig/python/extensions/ogr_wrap.cpp                |  16 +-
 swig/python/extensions/osr_wrap.cpp                |  16 +-
 swig/python/osgeo/ogr.py                           |  30 +-
 swig/python/setup.py                               |   2 +-
 308 files changed, 3615 insertions(+), 2169 deletions(-)

diff --git a/COMMITERS b/COMMITERS
index 5a92c22..8de1528 100644
--- a/COMMITERS
+++ b/COMMITERS
@@ -170,7 +170,7 @@ wolf          Wolf Bergenheim              GME, vector, python
               wolf+grass at bergenheim.net
 
 goatbar       Kurt Schwehr                 ocean related drivers, python
-              schwehr at gmail.com
+              schwehr at google.com
 
 jef           Juergen Fischer              OGR: NAS
               jef at norbit.de
diff --git a/GDALmake.opt.in b/GDALmake.opt.in
index 82525d9..1b7147b 100644
--- a/GDALmake.opt.in
+++ b/GDALmake.opt.in
@@ -87,7 +87,7 @@ GDAL_INCLUDE	=	-I$(GDAL_ROOT)/port -I$(GDAL_ROOT)/gcore \
 # libtool targets and help variables
 LIBGDAL	:=		libgdal.la
 LIBGDAL_CURRENT	:=	19
-LIBGDAL_REVISION	:=	1
+LIBGDAL_REVISION	:=	2
 LIBGDAL_AGE	:=	18
 
 # native build targets and variables
@@ -191,6 +191,7 @@ JASPER_FLAGS	= @JASPER_FLAGS@
 # JPEG-2000 Support via OpenJPEG library.
 #
 HAVE_OPENJPEG   = @HAVE_OPENJPEG@
+OPENJPEG_VERSION = @OPENJPEG_VERSION@
 
 #
 # MrSID support via LizardTech's DSDK
diff --git a/NEWS b/NEWS
index 9648cfa..cd88a0c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,156 @@
+= GDAL/OGR 1.11.2 Release Notes = 
+
+The 1.11.2 release is a bug fix release.
+
+== Build ==
+
+  * configure: fix detection of OCI by changing linking order to please modern GCC (#5550)
+  * configure: fix test to accept MariaDB 10.X as valid MySQL (#5722)
+  * More compiler warnings addressed (#5414)
+  * Windows build of PDF: fix compilation issue with Visual Studio 2012 (#5744)
+  * Windows build: Add support for MrSID 9.1 SDK (#5814)
+  * Windows build: when building netCDF, HDF4, HDF5 as plugins, call registration of 'sub-drivers' GMT, HDF4Image and HDF5Image (#5802)
+
+== Port ==
+
+ * CSV finder: Stop probing for csv/horiz_cs.csv. (#5698)
+ * /vsicurl/: avoid reading after end-of-file and fix failure when reading more than 16MB in a single time (#5786)
+ * CPLHexToBinary(): faster implementation (#5812)
+
+== GDAL Core and algorithms ==
+
+  * Make GetMaskBand() work with GDT_UInt16 alpha bands (#5692)
+  * Fix 32bit overflow in GDALRasterBand::IRasterIO() (#5713)
+  * RPC transformer: take into account nodata in RPC DEM (#5680)
+  * RPC transformer: add RPC_DEM_MISSING_VALUE transformer option to avoid failure when there's no DEM at the transformed point (#5730)
+  * Fix GDALSuggestedWarpOutput() wrong extent in some circumstances (e.g. dataset of big dimension with world coordinates) (#5693)
+  * Fix crash when calling GetTiledVirtualMem() on non-Linux platform (#5728)
+  * warp: fix integer overflow when reprojecting into an area with (part of) bounds completely outside of the source projection (#5789)
+  * OpenCL warper: fix OpenCL code compilation with NVIDIA OpenCL (#5772)
+
+== Utilities ==
+
+  * gdalwarp: initialize destination dataset to no_data value when automatically propagating source nodata (#5675)
+  * gdalwarp: only apply INIT_DEST when processing the first input dataset (#5387)
+  * gdaldem: avoid too large files to be produced when using -co COMPRESS=xxxx -co TILED=YES (#5678)
+
+== GDAL drivers ==
+
+GRASS driver:
+ * fix compilation issues against GRASS 7 (#2953)
+
+GIF driver:
+ * fix crash on images without color table (#5792)
+ * validate the size of the graphic control extension block (#5793)
+
+GTiff driver:
+ * Internal overviews: for near, average, gauss, and pixel interleaving, make sure to use the same code path for compressed vs uncompressed overviews (#5701)
+ * allow lossless copying of CMYK JPEG into JPEG-in-TIFF (#5712)
+ * when overriding metadata in update mode, make sure to clear it from PAM file (#5807)
+ * fix GTiffRasterBand::DirectIO() to work with TIFF files with multiple directories (overviews, masks) (#5831)
+ * Internal libtiff: partial (mostly security related fixes) upgrade to 4.0.4beta (#5830)
+
+ISIS3 driver:
+ * fix to recognize IsisCube.Mapping.LatitudeType = Planetocentric (#5717)
+
+JP2OpenJPEG driver:
+ * add compatibility with OpenJPEG 2.1 (#5579)
+
+JPEG driver:
+ * Report non-fatal libjpeg errors as CE_Warning (or CE_Failure if GDAL_ERROR_ON_LIBJPEG_WARNING = TRUE) (#5667)
+
+KMLSuperOverlay driver:
+ * remove useless and unreliable computations on floating point numbers that caused issues (truncated raster) on 32bit (#5683)
+
+USGSDEM driver:
+ * take into account horizontal unit = ft in the UTM case (#5819)
+
+VRT driver:
+ * fix RasterIO() to be able to fill buffers larger than 2GB (#5700, #5734)
+
+== OGR core ==
+
+  * ogr_core.h: only ignore -Wfloat-equal for IsInit() and not for the rest of the file and files that inc it (#5299)
+  * OGR layer algebra: properly initialize field maps to avoid Valgrind warnings in OGRLayer::Update() (#5778)
+
+== OGR drivers ==
+
+CSV driver:
+ * fix segfault when reading allCountries.txt of geonames.org (#5668)
+
+FileGDB:
+ * avoid emitting error when opening a FileGDB v9, so that OpenFileGDB can be tried to open it, in the case FileGDB is a plugin (#5674)
+
+GeoJSON driver:
+ * ESRIJson: parse correctly rings of esriGeometryPolygon objects to build correct Polygon or MultiPolygon (#5538)
+
+GML driver:
+ * Fix incorrect geometry cast when reading GML topogeometries (#5715)
+ * Update GFS files for RUIAN (UVOH & OB) (#5770)
+
+LIBKML driver:
+ * when skipped, fix segfault on second OGRRegisterAll() call (#5775)
+ * do not delete the libkml singleton factory (linked to #5775)
+
+MapInfo File driver:
+ * Add GDA94 datum entries to the lookup table (#5671)
+ * fix segfault in CreateFeature() if passing an invalid OGR feature style string (#1209)
+
+MSSQL driver:
+ * Fix recognizing image columns as geometry columns for the select layers. (#5498)
+ * Fix issue when creating non-spatial table (#5696)
+ * Fix to read metadata if the tables are specified in the connection string (#5796)
+ * Fix invalid use of CSLAddString() in OGR MSSQL (#5810)
+ * Fix crash if the tablename is specified in the connection string (#5826)
+
+MySQL driver:
+ * don't be dependant on locale when building spatial filter (#5720)
+
+NAS driver:
+ * make chevrons configurable by NAS_INDICATOR (#5708)
+
+OCI driver:
+ * Initialize member variable to avoid UpdateLayerExtents() to be called randomly on non spatial tables (#5376)
+ * fix FID (multi_load=off, OGRNullFID) - start with 1 (not -1) (#5454)
+
+OpenFileGDB driver:
+ * fix ResetReading() on SQL layer with ORDER BY on indexed column (#5669)
+ * add support for non spatial GDB v9 tables (#5673)
+
+PG driver:
+  * fix GDAL 1.11.0 regression that prevented to retrieve more than 500 features from a connection with tables= parameter and on a SQL result layer (#5837)
+
+SQLite/Spatialite driver:
+ * remove 'T' suffix when formatting the content of a Date field (#5672)
+ * fix segmentation fault when executing OGR2SQLITE_Register() when compiling against sqlite 3.8.7 (#5725)
+ * make GetFIDColumn() work when run as first method call (#5781)
+
+VRT driver:
+ * do not propagate ignoring of x and y cols of a PointFromColumns to the source layer (#5777)
+
+XLSX driver:
+ * fix column numbering when there are more than 26 columns (#5774)
+
+== SWIG Language Bindings ==
+
+Python bindings:
+  * Fix hang of Python in case of repeated call to gdal/ogr.UseExceptions() and CE_Warning emitted (#5704)
+  * fix processing error of ogr_python.i with SWIG 3 (#5795)
+  * NUMPY driver: avoid returning CE_None in GetGeoTransform() when there's no geotransform set (#5801)
+
+
 = GDAL/OGR 1.11.1 Release Notes = 
 
 The 1.11.1 release is a bug fix release.
 
+'''Security announcement'''
+
+Robert Coup has noticed a security problem with the OGR WCTS service.
+This code is not part of the standard build process, nor usually packaged by binary distributions,
+so most users should not be affected by this problem unless they have compiled it by themselves.
+This code still lies in the ogr/wcts directory from the source distribution of the 1.11 branch.
+For more details, you can read the "Security Concern" paragraph at http://svn.osgeo.org/gdal/spike/wcts/html/index.html
+
 == Build ==
 
  * Fix compilation errors with json-c 0.12 (#5449)
diff --git a/VERSION b/VERSION
index 720c738..ca71766 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.11.1
+1.11.2
diff --git a/alg/gdal_rpc.cpp b/alg/gdal_rpc.cpp
index 79f386e..0ff0255 100644
--- a/alg/gdal_rpc.cpp
+++ b/alg/gdal_rpc.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdal_rpc.cpp 27486 2014-07-01 17:30:04Z rouault $
+ * $Id: gdal_rpc.cpp 27931 2014-11-07 13:24:50Z rouault $
  *
  * Project:  Image Warper
  * Purpose:  Implements a rational polynomail (RPC) based transformer. 
@@ -33,7 +33,7 @@
 #include "ogr_spatialref.h"
 #include "cpl_minixml.h"
 
-CPL_CVSID("$Id: gdal_rpc.cpp 27486 2014-07-01 17:30:04Z rouault $");
+CPL_CVSID("$Id: gdal_rpc.cpp 27931 2014-11-07 13:24:50Z rouault $");
 
 CPL_C_START
 CPLXMLNode *GDALSerializeRPCTransformer( void *pTransformArg );
@@ -249,6 +249,9 @@ typedef struct {
     char        *pszDEMPath;
 
     DEMResampleAlg eResampleAlg;
+    
+    int         bHasDEMMissingValue;
+    double      dfDEMMissingValue;
 
     int         bHasTriedOpeningDS;
     GDALDataset *poDS;
@@ -260,6 +263,24 @@ typedef struct {
 } GDALRPCTransformInfo;
 
 /************************************************************************/
+/*                     GDALSerializeRPCDEMResample()                    */
+/************************************************************************/
+
+static const char* GDALSerializeRPCDEMResample(DEMResampleAlg eResampleAlg)
+{
+    switch(eResampleAlg)
+    {
+        case  DRA_NearestNeighbour:
+            return "near";
+        case DRA_Cubic:
+            return "cubic";
+        default:
+        case DRA_Bilinear:
+            return "bilinear";
+    }
+}
+
+/************************************************************************/
 /*                      GDALCreateRPCTransformer()                      */
 /************************************************************************/
 
@@ -345,6 +366,12 @@ typedef struct {
  * a non uniform ground for the target scene (GDAL >= 1.8.0)
  *
  * <li> RPC_DEMINTERPOLATION: the DEM interpolation (near, bilinear or cubic)
+ *
+ * <li> RPC_DEM_MISSING_VALUE: value of DEM height that must be used in case
+ * the DEM has nodata value at the sampling point, or if its extent does not
+ * cover the requested coordinate. When not specified, missing values will cause
+ * a failed transform. (GDAL >= 1.11.2)
+ *
  * </ul>
  *
  * @param psRPCInfo Definition of the RPC parameters.
@@ -418,8 +445,21 @@ void *GDALCreateRPCTransformer( GDALRPCInfo *psRPCInfo, int bReversed,
     else if(EQUAL(pszDEMInterpolation, "cubic" ))
         psTransform->eResampleAlg = DRA_Cubic;
     else
+    {
+        CPLDebug("RPC", "Unknown interpolation %s. Defaulting to bilinear", pszDEMInterpolation); 
         psTransform->eResampleAlg = DRA_Bilinear;
-       
+    }
+
+/* -------------------------------------------------------------------- */
+/*                       The DEM missing value                          */
+/* -------------------------------------------------------------------- */
+    const char *pszDEMMissingValue = CSLFetchNameValue( papszOptions, "RPC_DEM_MISSING_VALUE" );
+    if( pszDEMMissingValue != NULL )
+    {
+        psTransform->bHasDEMMissingValue = TRUE;
+        psTransform->dfDEMMissingValue = CPLAtof(pszDEMMissingValue);
+    }
+
 /* -------------------------------------------------------------------- */
 /*      Establish a reference point for calcualating an affine          */
 /*      geotransform approximate transformation.                        */
@@ -590,6 +630,134 @@ double BiCubicKernel(double dfVal)
 }
 
 /************************************************************************/
+/*                        GDALRPCGetDEMHeight()                         */
+/************************************************************************/
+
+static
+int GDALRPCGetDEMHeight( GDALRPCTransformInfo *psTransform,
+                      double dfX, double dfY, double* pdfDEMH )
+{
+    
+    int bGotNoDataValue = FALSE;
+    double dfNoDataValue = 0;
+    int nRasterXSize = psTransform->poDS->GetRasterXSize();
+    int nRasterYSize = psTransform->poDS->GetRasterYSize();
+    dfNoDataValue = psTransform->poDS->GetRasterBand(1)->GetNoDataValue( &bGotNoDataValue );
+
+    int bands[1] = {1};
+
+    int dX = int(dfX);
+    int dY = int(dfY);
+    double dfDEMH(0);
+    double dfDeltaX = dfX - dX;
+    double dfDeltaY = dfY - dY;
+    
+    if(psTransform->eResampleAlg == DRA_Cubic)
+    {
+        int dXNew = dX - 1;
+        int dYNew = dY - 1;
+        if (!(dXNew >= 0 && dYNew >= 0 && dXNew + 4 <= nRasterXSize && dYNew + 4 <= nRasterYSize))
+        {
+            return FALSE;
+        }
+        //cubic interpolation
+        double adfElevData[16] = {0};
+        CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dXNew, dYNew, 4, 4,
+                                                    &adfElevData, 4, 4,
+                                                    GDT_Float64, 1, bands, 0, 0, 0);
+        if(eErr != CE_None)
+        {
+            return FALSE;
+        }
+
+        double dfSumH(0), dfSumWeight(0);
+        for ( int k_i = 0; k_i < 4; k_i++ )
+        {
+            // Loop across the X axis
+            for ( int k_j = 0; k_j < 4; k_j++ )
+            {
+                // Calculate the weight for the specified pixel according
+                // to the bicubic b-spline kernel we're using for
+                // interpolation
+                int dKernIndX = k_j - 1;
+                int dKernIndY = k_i - 1;
+                double dfPixelWeight = BiCubicKernel(dKernIndX - dfDeltaX) * BiCubicKernel(dKernIndY - dfDeltaY);
+
+                // Create a sum of all values
+                // adjusted for the pixel's calculated weight
+                double dfElev = adfElevData[k_j + k_i * 4];
+                if( bGotNoDataValue && ARE_REAL_EQUAL(dfNoDataValue, dfElev) )
+                    continue;
+
+                dfSumH += dfElev * dfPixelWeight;
+                dfSumWeight += dfPixelWeight;
+            }
+        }
+        if( dfSumWeight == 0.0 )
+        {
+            return FALSE;
+        }
+        dfDEMH = dfSumH / dfSumWeight;
+    }
+    else if(psTransform->eResampleAlg == DRA_Bilinear)
+    {
+        if (!(dX >= 0 && dY >= 0 && dX + 2 <= nRasterXSize && dY + 2 <= nRasterYSize))
+        {
+            return FALSE;
+        }
+        //bilinear interpolation
+        double adfElevData[4] = {0,0,0,0};
+        CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dX, dY, 2, 2,
+                                                    &adfElevData, 2, 2,
+                                                    GDT_Float64, 1, bands, 0, 0, 0);
+        if(eErr != CE_None)
+        {
+            return FALSE;
+        }
+        if( bGotNoDataValue )
+        {
+            // TODO: we could perhaps use a valid sample if there's one
+            int bFoundNoDataElev = FALSE;
+            for(int k_i=0;k_i<4;k_i++)
+            {
+                if( ARE_REAL_EQUAL(dfNoDataValue, adfElevData[k_i]) )
+                    bFoundNoDataElev = TRUE;
+            }
+            if( bFoundNoDataElev )
+            {
+                return FALSE;
+            }
+        }
+        double dfDeltaX1 = 1.0 - dfDeltaX;                
+        double dfDeltaY1 = 1.0 - dfDeltaY;
+
+        double dfXZ1 = adfElevData[0] * dfDeltaX1 + adfElevData[1] * dfDeltaX;
+        double dfXZ2 = adfElevData[2] * dfDeltaX1 + adfElevData[3] * dfDeltaX;
+        double dfYZ = dfXZ1 * dfDeltaY1 + dfXZ2 * dfDeltaY;
+        dfDEMH = dfYZ;
+    }
+    else
+    {
+        if (!(dX >= 0 && dY >= 0 && dX < nRasterXSize && dY < nRasterYSize))
+        {
+            return FALSE;
+        }
+        CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dX, dY, 1, 1,
+                                                    &dfDEMH, 1, 1,
+                                                    GDT_Float64, 1, bands, 0, 0, 0);
+        if(eErr != CE_None ||
+            (bGotNoDataValue && ARE_REAL_EQUAL(dfNoDataValue, dfDEMH)) )
+        {
+            return FALSE;
+        }
+    }
+    
+    *pdfDEMH = dfDEMH;
+
+    return TRUE;
+}
+
+/************************************************************************/
 /*                          GDALRPCTransform()                          */
 /************************************************************************/
 
@@ -608,9 +776,6 @@ int GDALRPCTransform( void *pTransformArg, int bDstToSrc,
     if( psTransform->bReversed )
         bDstToSrc = !bDstToSrc;
 
-    int bands[1] = {1};
-    int nRasterXSize = 0, nRasterYSize = 0;
-
 /* -------------------------------------------------------------------- */
 /*      Lazy opening of the optionnal DEM file.                         */
 /* -------------------------------------------------------------------- */
@@ -652,11 +817,6 @@ int GDALRPCTransform( void *pTransformArg, int bDstToSrc,
             psTransform->poDS = NULL;
         }
     }
-    if (psTransform->poDS)
-    {
-        nRasterXSize = psTransform->poDS->GetRasterXSize();
-        nRasterYSize = psTransform->poDS->GetRasterYSize();
-    }
 
 /* -------------------------------------------------------------------- */
 /*      The simple case is transforming from lat/long to pixel/line.    */
@@ -687,101 +847,18 @@ int GDALRPCTransform( void *pTransformArg, int bDstToSrc,
                 else
                     GDALApplyGeoTransform( psTransform->adfReverseGeoTransform,
                                            padfX[i], padfY[i], &dfX, &dfY );
-                int dX = int(dfX);
-                int dY = int(dfY);
-
-                if (!(dX >= 0 && dY >= 0 &&
-                      dX+2 <= nRasterXSize && dY+2 <= nRasterYSize))
-                {
-                    panSuccess[i] = FALSE;
-                    continue;
-                }
 
                 double dfDEMH(0);
-                double dfDeltaX = dfX - dX;
-                double dfDeltaY = dfY - dY;
-                
-                if(psTransform->eResampleAlg == DRA_Cubic)
+                if( !GDALRPCGetDEMHeight( psTransform, dfX, dfY, &dfDEMH) )
                 {
-                    int dXNew = dX - 1;
-                    int dYNew = dY - 1;
-                    if (!(dXNew >= 0 && dYNew >= 0 && dXNew + 4 <= nRasterXSize && dYNew + 4 <= nRasterYSize))
-                    {
-                        panSuccess[i] = FALSE;
-                        continue;
-                    }
-                    //cubic interpolation
-                    int anElevData[16] = {0};
-                    CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dXNew, dYNew, 4, 4,
-                                                              &anElevData, 4, 4,
-                                                              GDT_Int32, 1, bands, 0, 0, 0);
-                    if(eErr != CE_None)
+                    if( psTransform->bHasDEMMissingValue )
+                        dfDEMH = psTransform->dfDEMMissingValue;
+                    else
                     {
                         panSuccess[i] = FALSE;
                         continue;
                     }
-
-                    double dfSumH(0);
-                    for ( int i = 0; i < 4; i++ )
-                    {
-                        // Loop across the X axis
-                        for ( int j = 0; j < 4; j++ )
-                        {
-                            // Calculate the weight for the specified pixel according
-                            // to the bicubic b-spline kernel we're using for
-                            // interpolation
-                            int dKernIndX = j - 1;
-                            int dKernIndY = i - 1;
-                            double dfPixelWeight = BiCubicKernel(dKernIndX - dfDeltaX) * BiCubicKernel(dKernIndY - dfDeltaY);
-
-                            // Create a sum of all values
-                            // adjusted for the pixel's calculated weight
-                            dfSumH += anElevData[j + i * 4] * dfPixelWeight;
-                        }
-                    }
-                    dfDEMH = dfSumH;
                 }
-                else if(psTransform->eResampleAlg == DRA_Bilinear)
-                {
-                    if (!(dX >= 0 && dY >= 0 && dX + 2 <= nRasterXSize && dY + 2 <= nRasterYSize))
-                    {
-                        panSuccess[i] = FALSE;
-                        continue;
-                    }
-                    //bilinear interpolation
-                    int anElevData[4] = {0,0,0,0};
-                    CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dX, dY, 2, 2,
-                                                              &anElevData, 2, 2,
-                                                              GDT_Int32, 1, bands, 0, 0, 0);
-                    if(eErr != CE_None)
-                    {
-                        panSuccess[i] = FALSE;
-                        continue;
-                    }
-                    double dfDeltaX1 = 1.0 - dfDeltaX;                
-                    double dfDeltaY1 = 1.0 - dfDeltaY;
-
-                    double dfXZ1 = anElevData[0] * dfDeltaX1 + anElevData[1] * dfDeltaX;
-                    double dfXZ2 = anElevData[2] * dfDeltaX1 + anElevData[3] * dfDeltaX;
-                    double dfYZ = dfXZ1 * dfDeltaY1 + dfXZ2 * dfDeltaY;
-                    dfDEMH = dfYZ;
-                }
-                else
-                {
-                    if (!(dX >= 0 && dY >= 0 && dX < nRasterXSize && dY < nRasterYSize))
-                    {
-                        panSuccess[i] = FALSE;
-                        continue;
-                    }
-                    CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dX, dY, 1, 1,
-                                                              &dfDEMH, 1, 1,
-                                                              GDT_Float64, 1, bands, 0, 0, 0);
-                    if(eErr != CE_None)
-                    {
-                        panSuccess[i] = FALSE;
-                        continue;
-                    }              
-                }                
 
                 RPCTransformPoint( psRPC, padfX[i], padfY[i], 
                                    padfZ[i] + (psTransform->dfHeightOffset + dfDEMH) *
@@ -829,93 +906,17 @@ int GDALRPCTransform( void *pTransformArg, int bDstToSrc,
 
             GDALApplyGeoTransform( psTransform->adfReverseGeoTransform,
                                     dfResultX, dfResultY, &dfX, &dfY );
-            int dX = int(dfX);
-            int dY = int(dfY);
 
             double dfDEMH(0);
-            double dfDeltaX = dfX - dX;
-            double dfDeltaY = dfY - dY;
-
-            if(psTransform->eResampleAlg == DRA_Cubic)
+            if( !GDALRPCGetDEMHeight( psTransform, dfX, dfY, &dfDEMH) )
             {
-                int dXNew = dX - 1;
-                int dYNew = dY - 1;
-                if (!(dXNew >= 0 && dYNew >= 0 && dXNew + 4 <= nRasterXSize && dYNew + 4 <= nRasterYSize))
-                {
-                    panSuccess[i] = FALSE;
-                    continue;
-                }
-                //cubic interpolation
-                int anElevData[16] = {0};
-                CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dXNew, dYNew, 4, 4,
-                                                          &anElevData, 4, 4,
-                                                          GDT_Int32, 1, bands, 0, 0, 0);
-                if(eErr != CE_None)
-                {
-                    panSuccess[i] = FALSE;
-                    continue;
-                }
-
-                double dfSumH(0);
-                for ( int i = 0; i < 4; i++ )
-                {
-                    // Loop across the X axis
-                    for ( int j = 0; j < 4; j++ )
-                    {
-                        // Calculate the weight for the specified pixel according
-                        // to the bicubic b-spline kernel we're using for
-                        // interpolation
-                        int dKernIndX = j - 1;
-                        int dKernIndY = i - 1;
-                        double dfPixelWeight = BiCubicKernel(dKernIndX - dfDeltaX) * BiCubicKernel(dKernIndY - dfDeltaY);
-
-                        // Create a sum of all values
-                        // adjusted for the pixel's calculated weight
-                        dfSumH += anElevData[j + i * 4] * dfPixelWeight;
-                    }
-                }
-                dfDEMH = dfSumH;
-            }
-            else if(psTransform->eResampleAlg == DRA_Bilinear)
-            {
-                if (!(dX >= 0 && dY >= 0 && dX + 2 <= nRasterXSize && dY + 2 <= nRasterYSize))
-                {
-                    panSuccess[i] = FALSE;
-                    continue;
-                }
-                //bilinear interpolation
-                int anElevData[4] = {0,0,0,0};
-                CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dX, dY, 2, 2,
-                                                          &anElevData, 2, 2,
-                                                          GDT_Int32, 1, bands, 0, 0, 0);
-                if(eErr != CE_None)
-                {
-                    panSuccess[i] = FALSE;
-                    continue;
-                }
-                double dfDeltaX1 = 1.0 - dfDeltaX;                
-                double dfDeltaY1 = 1.0 - dfDeltaY;
-
-                double dfXZ1 = anElevData[0] * dfDeltaX1 + anElevData[1] * dfDeltaX;
-                double dfXZ2 = anElevData[2] * dfDeltaX1 + anElevData[3] * dfDeltaX;
-                double dfYZ = dfXZ1 * dfDeltaY1 + dfXZ2 * dfDeltaY;
-                dfDEMH = dfYZ;
-            }
-            else
-            {
-                if (!(dX >= 0 && dY >= 0 && dX < nRasterXSize && dY < nRasterYSize))
+                if( psTransform->bHasDEMMissingValue )
+                    dfDEMH = psTransform->dfDEMMissingValue;
+                else
                 {
                     panSuccess[i] = FALSE;
                     continue;
                 }
-                CPLErr eErr = psTransform->poDS->RasterIO(GF_Read, dX, dY, 1, 1,
-                                                          &dfDEMH, 1, 1,
-                                                          GDT_Float64, 1, bands, 0, 0, 0);
-                if(eErr != CE_None)
-                {
-                    panSuccess[i] = FALSE;
-                    continue;
-                }           
             }
 
             RPCInverseTransformPoint( psTransform, padfX[i], padfY[i], 
@@ -981,6 +982,7 @@ CPLXMLNode *GDALSerializeRPCTransformer( void *pTransformArg )
 /*      Serialize DEM path.                                             */
 /* -------------------------------------------------------------------- */
     if (psInfo->pszDEMPath != NULL)
+    {
         CPLCreateXMLElementAndValue( 
             psTree, "DEMPath", 
             CPLString().Printf( "%s", psInfo->pszDEMPath ) );
@@ -988,21 +990,15 @@ CPLXMLNode *GDALSerializeRPCTransformer( void *pTransformArg )
 /* -------------------------------------------------------------------- */
 /*      Serialize DEM interpolation                                     */
 /* -------------------------------------------------------------------- */
-    CPLString soDEMInterpolation;
-    switch(psInfo->eResampleAlg)
-    {
-    case  DRA_NearestNeighbour:
-        soDEMInterpolation = "near";
-        break;
-    case DRA_Cubic:
-        soDEMInterpolation = "cubic";
-        break;
-    default:
-    case DRA_Bilinear:
-        soDEMInterpolation = "bilinear";
+        CPLCreateXMLElementAndValue( 
+            psTree, "DEMInterpolation", GDALSerializeRPCDEMResample(psInfo->eResampleAlg) );
+
+        if( psInfo->bHasDEMMissingValue )
+        {
+            CPLCreateXMLElementAndValue( 
+                psTree, "DEMMissingValue", CPLSPrintf("%.18g", psInfo->dfDEMMissingValue) );
+        }
     }
-    CPLCreateXMLElementAndValue( 
-        psTree, "DEMInterpolation", soDEMInterpolation );
 
 /* -------------------------------------------------------------------- */
 /*      Serialize pixel error threshold.                                */
@@ -1114,6 +1110,11 @@ void *GDALDeserializeRPCTransformer( CPLXMLNode *psTree )
         papszOptions = CSLSetNameValue( papszOptions, "RPC_DEMINTERPOLATION",
                                         pszDEMInterpolation);
 
+    const char* pszDEMMissingValue = CPLGetXMLValue(psTree,"DEMMissingValue", NULL);
+    if (pszDEMMissingValue != NULL)
+        papszOptions = CSLSetNameValue( papszOptions, "RPC_DEM_MISSING_VALUE",
+                                        pszDEMMissingValue);
+
 /* -------------------------------------------------------------------- */
 /*      Generate transformation.                                        */
 /* -------------------------------------------------------------------- */
diff --git a/alg/gdalrasterize.cpp b/alg/gdalrasterize.cpp
index bb4f7df..9b47587 100644
--- a/alg/gdalrasterize.cpp
+++ b/alg/gdalrasterize.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalrasterize.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gdalrasterize.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL
  * Purpose:  Vector rasterization.
@@ -112,8 +112,9 @@ void gvBurnScanline( void *pCBData, int nY, int nXStart, int nXEnd,
             }
         }
     }
-    else
+    else {
         CPLAssert(0);
+    }
 }
 
 /************************************************************************/
@@ -167,8 +168,9 @@ void gvBurnPoint( void *pCBData, int nY, int nX, double dfVariant )
             }
         }
     }
-    else
+    else {
         CPLAssert(0);
+    }
 }
 
 /************************************************************************/
@@ -176,9 +178,9 @@ void gvBurnPoint( void *pCBData, int nY, int nX, double dfVariant )
 /************************************************************************/
 
 static void GDALCollectRingsFromGeometry(
-    OGRGeometry *poShape, 
-    std::vector<double> &aPointX, std::vector<double> &aPointY, 
-    std::vector<double> &aPointVariant, 
+    OGRGeometry *poShape,
+    std::vector<double> &aPointX, std::vector<double> &aPointY,
+    std::vector<double> &aPointVariant,
     std::vector<int> &aPartSize, GDALBurnValueSrc eBurnValueSrc)
 
 {
@@ -1319,4 +1321,3 @@ CPLErr GDALRasterizeLayersBuf( void *pData, int nBufXSize, int nBufYSize,
     return eErr;
 #endif /* def OGR_ENABLED */
 }
-
diff --git a/alg/gdaltransformer.cpp b/alg/gdaltransformer.cpp
index 5c39ea5..48a104c 100644
--- a/alg/gdaltransformer.cpp
+++ b/alg/gdaltransformer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdaltransformer.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: gdaltransformer.cpp 27865 2014-10-15 22:44:28Z rouault $
  *
  * Project:  Mapinfo Image Warper
  * Purpose:  Implementation of one or more GDALTrasformerFunc types, including
@@ -38,7 +38,7 @@
 #include "cpl_list.h"
 #include "cpl_multiproc.h"
 
-CPL_CVSID("$Id: gdaltransformer.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: gdaltransformer.cpp 27865 2014-10-15 22:44:28Z rouault $");
 CPL_C_START
 void *GDALDeserializeGCPTransformer( CPLXMLNode *psTree );
 void *GDALDeserializeTPSTransformer( CPLXMLNode *psTree );
@@ -400,27 +400,27 @@ retry:
         dfRatio = (iStep == nSteps) ? 1.0 : iStep * dfStep;
 
         // Along top 
-        padfX[nSamplePoints]   = dfRatio * nInXSize;
-        padfY[nSamplePoints]   = 0.0;
-        padfZ[nSamplePoints++] = 0.0;
+        padfX[iStep]   = dfRatio * nInXSize;
+        padfY[iStep]   = 0.0;
+        padfZ[iStep] = 0.0;
 
         // Along bottom 
-        padfX[nSamplePoints]   = dfRatio * nInXSize;
-        padfY[nSamplePoints]   = nInYSize;
-        padfZ[nSamplePoints++] = 0.0;
+        padfX[nSteps + 1 + iStep]   = dfRatio * nInXSize;
+        padfY[nSteps + 1 + iStep]   = nInYSize;
+        padfZ[nSteps + 1 + iStep] = 0.0;
 
         // Along left
-        padfX[nSamplePoints]   = 0.0;
-        padfY[nSamplePoints] = dfRatio * nInYSize;
-        padfZ[nSamplePoints++] = 0.0;
+        padfX[2 * (nSteps + 1) + iStep]   = 0.0;
+        padfY[2 * (nSteps + 1) + iStep] = dfRatio * nInYSize;
+        padfZ[2 * (nSteps + 1) + iStep] = 0.0;
 
         // Along right
-        padfX[nSamplePoints]   = nInXSize;
-        padfY[nSamplePoints] = dfRatio * nInYSize;
-        padfZ[nSamplePoints++] = 0.0;
+        padfX[3 * (nSteps + 1) + iStep]   = nInXSize;
+        padfY[3 * (nSteps + 1) + iStep] = dfRatio * nInYSize;
+        padfZ[3 * (nSteps + 1) + iStep] = 0.0;
     }
 
-    CPLAssert( nSamplePoints == 4 * (nSteps + 1) );
+    nSamplePoints = 4 * (nSteps + 1);
 
     memset( pabSuccess, 1, sizeof(int) * nSampleMax );
 
@@ -466,24 +466,27 @@ retry:
             for( i = 0; nFailedCount == 0 && i < nSamplePoints; i++ )
             {
                 if( !pabSuccess[i] )
+                {
                     nFailedCount++;
+                    break;
+                }
 
-                dfRatio = 0.0 + (i/4) * dfStep;
+                dfRatio = (i % (nSteps + 1)) * dfStep;
                 if (dfRatio>0.99)
                     dfRatio = 1.0;
 
                 double dfExpectedX, dfExpectedY;
-                if ((i % 4) == 0)
+                if (i < nSteps + 1)
                 {
                     dfExpectedX   = dfRatio * nInXSize;
                     dfExpectedY   = 0.0;
                 }
-                else if ((i % 4) == 1)
+                else if (i < 2 * (nSteps + 1))
                 {
                     dfExpectedX   = dfRatio * nInXSize;
                     dfExpectedY   = nInYSize;
                 }
-                else if ((i % 4) == 2)
+                else if (i < 3 * (nSteps + 1))
                 {
                     dfExpectedX   = 0.0;
                     dfExpectedY   = dfRatio * nInYSize;
@@ -498,8 +501,12 @@ retry:
                     fabs(padfYRevert[i] - dfExpectedY) > nInYSize / nSteps)
                     nFailedCount ++;
             }
+            if( nFailedCount != 0 )
+                CPLDebug("WARP", "At least one point failed after revert transform");
         }
     }
+    else
+        CPLDebug("WARP", "At least one point failed after direct transform");
 
 /* -------------------------------------------------------------------- */
 /*      If any of the edge points failed to transform, we need to       */
@@ -521,7 +528,7 @@ retry:
             {
                 dfRatio2 = (iStep2 == nSteps) ? 1.0 : iStep2 * dfStep;
 
-                // Along top 
+                // From top to bottom, from left to right
                 padfX[nSamplePoints]   = dfRatio2 * nInXSize;
                 padfY[nSamplePoints]   = dfRatio * nInYSize;
                 padfZ[nSamplePoints++] = 0.0;
@@ -554,9 +561,23 @@ retry:
     nFailedCount = 0;
     for( i = 0; i < nSamplePoints; i++ )
     {
-        
-        int x_i = i % (nSteps + 1);
-        int y_i = i / (nSteps + 1);
+        int x_i, y_i;
+
+        if( nSamplePoints == nSampleMax )
+        {
+            x_i = i % (nSteps + 1);
+            y_i = i / (nSteps + 1);
+        }
+        else
+        {
+            if( i < 2 * (nSteps + 1 ) )
+            {
+                x_i = i % (nSteps + 1);
+                y_i = (i < nSteps + 1) ? 0 : nSteps;
+            }
+            else
+                x_i = y_i = 0;
+        }
 
         if (x_i > 0 && (pabSuccess[i-1] || pabSuccess[i]))
         {
diff --git a/alg/gdalwarper.cpp b/alg/gdalwarper.cpp
index f13f6b2..647bff1 100644
--- a/alg/gdalwarper.cpp
+++ b/alg/gdalwarper.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalwarper.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: gdalwarper.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  High Performance Image Reprojector
  * Purpose:  Implementation of high level convenience APIs for warper.
@@ -34,7 +34,7 @@
 #include "ogr_api.h"
 #include "gdal_priv.h"
 
-CPL_CVSID("$Id: gdalwarper.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: gdalwarper.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 /************************************************************************/
 /*                         GDALReprojectImage()                         */
@@ -73,13 +73,13 @@ CPL_CVSID("$Id: gdalwarper.cpp 27729 2014-09-24 00:40:16Z goatbar $");
  * @return CE_None on success or CE_Failure if something goes wrong.
  */
 
-CPLErr CPL_STDCALL 
-GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT, 
+CPLErr CPL_STDCALL
+GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
                     GDALDatasetH hDstDS, const char *pszDstWKT,
-                    GDALResampleAlg eResampleAlg, 
-                    CPL_UNUSED double dfWarpMemoryLimit, 
+                    GDALResampleAlg eResampleAlg,
+                    CPL_UNUSED double dfWarpMemoryLimit,
                     double dfMaxError,
-                    GDALProgressFunc pfnProgress, void *pProgressArg, 
+                    GDALProgressFunc pfnProgress, void *pProgressArg,
                     GDALWarpOptions *psOptions )
 
 {
diff --git a/alg/gdalwarper.h b/alg/gdalwarper.h
index 9531fc3..4de0c97 100644
--- a/alg/gdalwarper.h
+++ b/alg/gdalwarper.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalwarper.h 27701 2014-09-20 15:07:02Z goatbar $
+ * $Id: gdalwarper.h 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL High Performance Warper
  * Purpose:  Prototypes, and definitions for warping related work.
@@ -339,8 +339,8 @@ private:
                                       const char *pszType );
 
     /* Unused kept to preserve binary ABI */
-    CPL_UNUSED void            *unused1;
-    CPL_UNUSED void            *unused2;
+    /* CPL_UNUSED */ void            *unused1;
+    /* CPL_UNUSED */ void            *unused2;
     void            *hIOMutex;
     void            *hWarpMutex;
 
diff --git a/alg/gdalwarpkernel.cpp b/alg/gdalwarpkernel.cpp
index 8b0f7e9..07bd038 100644
--- a/alg/gdalwarpkernel.cpp
+++ b/alg/gdalwarpkernel.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalwarpkernel.cpp 27159 2014-04-12 15:49:25Z rouault $
+ * $Id: gdalwarpkernel.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  High Performance Image Reprojector
  * Purpose:  Implementation of the GDALWarpKernel class.  Implements the actual
@@ -37,7 +37,7 @@
 #include "cpl_atomic_ops.h"
 #include "cpl_multiproc.h"
 
-CPL_CVSID("$Id: gdalwarpkernel.cpp 27159 2014-04-12 15:49:25Z rouault $");
+CPL_CVSID("$Id: gdalwarpkernel.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 static const int anGWKFilterRadius[] =
 {
@@ -3346,7 +3346,7 @@ free_warper:
                 || _padfY[_iDstX] < _poWK->nSrcYOff ) \
                 continue; \
 \
-            int iSrcX, iSrcY, iSrcOffset;\
+            int iSrcX, iSrcY, CPL_UNUSED iSrcOffset;\
 \
             iSrcX = ((int) (_padfX[_iDstX] + 1e-10)) - _poWK->nSrcXOff;\
             iSrcY = ((int) (_padfY[_iDstX] + 1e-10)) - _poWK->nSrcYOff;\
@@ -5368,4 +5368,3 @@ static void GWKAverageOrModeThread( void* pData)
     VSIFree(pafVals);
     VSIFree(panSums);
 }
-
diff --git a/alg/gdalwarpkernel_opencl.c b/alg/gdalwarpkernel_opencl.c
index 3bb4204..15edf86 100644
--- a/alg/gdalwarpkernel_opencl.c
+++ b/alg/gdalwarpkernel_opencl.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalwarpkernel_opencl.c 27455 2014-06-15 10:54:41Z rouault $
+ * $Id: gdalwarpkernel_opencl.c 28301 2015-01-07 08:31:04Z rouault $
  *
  * Project:  OpenCL Image Reprojector
  * Purpose:  Implementation of the GDALWarpKernel reprojector in OpenCL.
@@ -41,7 +41,7 @@
 #include "cpl_string.h"
 #include "gdalwarpkernel_opencl.h"
 
-CPL_CVSID("$Id: gdalwarpkernel_opencl.c 27455 2014-06-15 10:54:41Z rouault $");
+CPL_CVSID("$Id: gdalwarpkernel_opencl.c 28301 2015-01-07 08:31:04Z rouault $");
 
 #define handleErr(err) if((err) != CL_SUCCESS) { \
     CPLError(CE_Failure, CPLE_AppDefined, "Error at file %s line %d: %s", __FILE__, __LINE__, getCLErrorString(err)); \
@@ -593,7 +593,7 @@ cl_kernel get_kernel(struct oclWarper *warper, char useVec,
         "if (dstPtr[iDstOffset] == dstMinVal)\n"
             "dstPtr[iDstOffset] = dstMinVal + 1;\n"
         "else\n"
-            "dstPtr[iDstOffset] --;\n"
+            "dstPtr[iDstOffset] = dstPtr[iDstOffset] - 1;\n"
     "}\n"
 "}\n"
 "#endif\n"
diff --git a/alg/gdalwarpoperation.cpp b/alg/gdalwarpoperation.cpp
index 13088c7..215ace6 100644
--- a/alg/gdalwarpoperation.cpp
+++ b/alg/gdalwarpoperation.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalwarpoperation.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gdalwarpoperation.cpp 28206 2014-12-24 10:32:49Z rouault $
  *
  * Project:  High Performance Image Reprojector
  * Purpose:  Implementation of the GDALWarpOperation class.
@@ -33,7 +33,7 @@
 #include "cpl_multiproc.h"
 #include "ogr_api.h"
 
-CPL_CVSID("$Id: gdalwarpoperation.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gdalwarpoperation.cpp 28206 2014-12-24 10:32:49Z rouault $");
 
 /* Defined in gdalwarpkernel.cpp */
 int GWKGetFilterRadius(GDALResampleAlg eResampleAlg);
@@ -2213,10 +2213,16 @@ CPLErr GDALWarpOperation::ComputeSourceWindow(int nDstXOff, int nDstYOff,
     *pnSrcXOff = MIN(*pnSrcXOff,GDALGetRasterXSize(psOptions->hSrcDS));
     *pnSrcYOff = MIN(*pnSrcYOff,GDALGetRasterYSize(psOptions->hSrcDS));
 
+    double dfCeilMaxXOut = ceil(dfMaxXOut);
+    if( dfCeilMaxXOut > INT_MAX )
+        dfCeilMaxXOut = INT_MAX;
+    double dfCeilMaxYOut = ceil(dfMaxYOut);
+    if( dfCeilMaxYOut > INT_MAX )
+        dfCeilMaxYOut = INT_MAX;
     *pnSrcXSize = MIN( GDALGetRasterXSize(psOptions->hSrcDS) - *pnSrcXOff,
-                       ((int) ceil( dfMaxXOut )) - *pnSrcXOff + nResWinSize );
+                       ((int) dfCeilMaxXOut) - *pnSrcXOff + nResWinSize );
     *pnSrcYSize = MIN( GDALGetRasterYSize(psOptions->hSrcDS) - *pnSrcYOff,
-                       ((int) ceil( dfMaxYOut )) - *pnSrcYOff + nResWinSize );
+                       ((int) dfCeilMaxYOut) - *pnSrcYOff + nResWinSize );
     *pnSrcXSize = MAX(0,*pnSrcXSize);
     *pnSrcYSize = MAX(0,*pnSrcYSize);
 
diff --git a/alg/llrasterize.cpp b/alg/llrasterize.cpp
index 1ac1352..9dbfe42 100644
--- a/alg/llrasterize.cpp
+++ b/alg/llrasterize.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: llrasterize.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: llrasterize.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL
  * Purpose:  Vector polygon rasterization code.
@@ -105,16 +105,13 @@ No known bug
     double dx2, dy2;
     double dy;
     double intersect;
-    
 
     int ind1, ind2;
     int ints, n, part;
-    int *polyInts, polyAllocated;
+    int *polyInts;
 
-  
     int horizontal_x1, horizontal_x2;
 
-
     if (!nPartCount) {
         return;
     }
@@ -122,10 +119,9 @@ No known bug
     n = 0;
     for( part = 0; part < nPartCount; part++ )
         n += panPartSize[part];
-    
+
     polyInts = (int *) malloc(sizeof(int) * n);
-    polyAllocated = n;
-    
+
     dminy = padfY[0];
     dmaxy = padfY[0];
     for (i=1; (i < n); i++) {
@@ -605,4 +601,3 @@ GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize,
         } // next segment
     } // next part
 }
-
diff --git a/apps/GNUmakefile b/apps/GNUmakefile
index 77a44ec..f9950df 100644
--- a/apps/GNUmakefile
+++ b/apps/GNUmakefile
@@ -4,7 +4,7 @@
 
 include ../GDALmake.opt
 
-CPPFLAGS	:=	$(GDAL_INCLUDE) -I$(GDAL_ROOT)/frmts $(CPPFLAGS)
+CPPFLAGS	:=	$(GDAL_INCLUDE) -I$(GDAL_ROOT)/frmts/vrt $(CPPFLAGS)
 LNK_FLAGS   :=  $(LDFLAGS)
 DEP_LIBS	=	$(EXE_DEP_LIBS) $(XTRAOBJ)
 BIN_LIST	=	gdalinfo$(EXE) gdalserver$(EXE) gdal_translate$(EXE) gdaladdo$(EXE) \
diff --git a/apps/gdal_contour.cpp b/apps/gdal_contour.cpp
index 41a96ae..e018801 100644
--- a/apps/gdal_contour.cpp
+++ b/apps/gdal_contour.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdal_contour.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gdal_contour.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Contour Generator
  * Purpose:  Contour Generator mainline.
@@ -35,7 +35,7 @@
 #include "ogr_api.h"
 #include "ogr_srs_api.h"
 
-CPL_CVSID("$Id: gdal_contour.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gdal_contour.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                            ArgIsNumeric()                            */
@@ -292,16 +292,15 @@ int main( int argc, char ** argv )
 /* -------------------------------------------------------------------- */
 /*      Invoke.                                                         */
 /* -------------------------------------------------------------------- */
-    CPLErr eErr;
-    
-    eErr = GDALContourGenerate( hBand, dfInterval, dfOffset, 
+    /* CPLErr eErr = */
+    GDALContourGenerate( hBand, dfInterval, dfOffset,
                          nFixedLevelCount, adfFixedLevels,
-                         bNoDataSet, dfNoData, hLayer, 
-                         OGR_FD_GetFieldIndex( OGR_L_GetLayerDefn( hLayer ), 
-                                               "ID" ), 
+                         bNoDataSet, dfNoData, hLayer,
+                         OGR_FD_GetFieldIndex( OGR_L_GetLayerDefn( hLayer ),
+                                               "ID" ),
                          (pszElevAttrib == NULL) ? -1 :
-                                 OGR_FD_GetFieldIndex( OGR_L_GetLayerDefn( hLayer ), 
-                                                       pszElevAttrib ), 
+                         OGR_FD_GetFieldIndex( OGR_L_GetLayerDefn( hLayer ),
+                                               pszElevAttrib ),
                          pfnProgress, NULL );
 
     OGR_DS_Destroy( hDS );
diff --git a/apps/gdal_translate.cpp b/apps/gdal_translate.cpp
index 4acebd9..22747e4 100644
--- a/apps/gdal_translate.cpp
+++ b/apps/gdal_translate.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdal_translate.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gdal_translate.cpp 27994 2014-11-21 20:03:49Z rouault $
  *
  * Project:  GDAL Utilities
  * Purpose:  GDAL Image Translator Program
@@ -33,10 +33,10 @@
 #include "cpl_string.h"
 #include "gdal_priv.h"
 #include "ogr_spatialref.h"
-#include "vrt/vrtdataset.h"
+#include "vrtdataset.h"
 #include "commonutils.h"
 
-CPL_CVSID("$Id: gdal_translate.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gdal_translate.cpp 27994 2014-11-21 20:03:49Z rouault $");
 
 static int ArgIsNumeric( const char * );
 static void AttachMetadata( GDALDatasetH, char ** );
diff --git a/apps/gdalbuildvrt.cpp b/apps/gdalbuildvrt.cpp
index 890aa5b..078278f 100644
--- a/apps/gdalbuildvrt.cpp
+++ b/apps/gdalbuildvrt.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalbuildvrt.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gdalbuildvrt.cpp 27994 2014-11-21 20:03:49Z rouault $
  *
  * Project:  GDAL Utilities
  * Purpose:  Commandline application to build VRT datasets from raster products or content of SHP tile index
@@ -29,15 +29,15 @@
 
 #include "gdal_proxy.h"
 #include "cpl_string.h"
-#include "vrt/gdal_vrt.h"
-#include "vrt/vrtdataset.h"
+#include "gdal_vrt.h"
+#include "vrtdataset.h"
 
 #ifdef OGR_ENABLED
 #include "ogr_api.h"
 #endif
 #include "ogr_srs_api.h"
 
-CPL_CVSID("$Id: gdalbuildvrt.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gdalbuildvrt.cpp 27994 2014-11-21 20:03:49Z rouault $");
 
 #define GEOTRSFRM_TOPLEFT_X            0
 #define GEOTRSFRM_WE_RES               1
diff --git a/apps/gdaldem.cpp b/apps/gdaldem.cpp
index 86c0dd3..513bec2 100644
--- a/apps/gdaldem.cpp
+++ b/apps/gdaldem.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdaldem.cpp 27613 2014-08-30 15:55:30Z rouault $
+ * $Id: gdaldem.cpp 27781 2014-10-01 17:48:26Z rouault $
  *
  * Project:  GDAL DEM Utilities
  * Purpose:  
@@ -91,7 +91,7 @@
 #include "gdal_priv.h"
 #include "commonutils.h"
 
-CPL_CVSID("$Id: gdaldem.cpp 27613 2014-08-30 15:55:30Z rouault $");
+CPL_CVSID("$Id: gdaldem.cpp 27781 2014-10-01 17:48:26Z rouault $");
 
 #ifndef M_PI
 # define M_PI  3.1415926535897932384626433832795
@@ -467,11 +467,11 @@ typedef struct
            cos(az * degreesToRadians - M_PI/2 - aspect);
 */
 
-float GDALHillshadeAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALHillshadeAlg (float* afWin, CPL_UNUSED float fDstNoDataValue, void* pData)
 {
     GDALHillshadeAlgData* psData = (GDALHillshadeAlgData*)pData;
     double x, y, aspect, xx_plus_yy, cang;
-    
+
     // First Slope ...
     x = ((afWin[0] + afWin[3] + afWin[3] + afWin[6]) -
         (afWin[2] + afWin[5] + afWin[5] + afWin[8])) / psData->ewres;
@@ -490,19 +490,19 @@ float GDALHillshadeAlg (float* afWin, float fDstNoDataValue, void* pData)
            sin(aspect - psData->azRadians)) /
            sqrt(1 + psData->square_z_scale_factor * xx_plus_yy);
 
-    if (cang <= 0.0) 
+    if (cang <= 0.0)
         cang = 1.0;
     else
         cang = 1.0 + (254.0 * cang);
-        
+
     return (float) cang;
 }
 
-float GDALHillshadeCombinedAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALHillshadeCombinedAlg (float* afWin, CPL_UNUSED float fDstNoDataValue, void* pData)
 {
     GDALHillshadeAlgData* psData = (GDALHillshadeAlgData*)pData;
     double x, y, aspect, xx_plus_yy, cang;
-    
+
     // First Slope ...
     x = ((afWin[0] + afWin[3] + afWin[3] + afWin[6]) -
         (afWin[2] + afWin[5] + afWin[5] + afWin[8])) / psData->ewres;
@@ -525,19 +525,19 @@ float GDALHillshadeCombinedAlg (float* afWin, float fDstNoDataValue, void* pData
     // combined shading
     cang = 1 - cang * atan(sqrt(slope)) / psData->square_M_PI_2;
 
-    if (cang <= 0.0) 
+    if (cang <= 0.0)
         cang = 1.0;
     else
         cang = 1.0 + (254.0 * cang);
-        
+
     return (float) cang;
 }
 
-float GDALHillshadeZevenbergenThorneAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALHillshadeZevenbergenThorneAlg (float* afWin, CPL_UNUSED float fDstNoDataValue, void* pData)
 {
     GDALHillshadeAlgData* psData = (GDALHillshadeAlgData*)pData;
     double x, y, aspect, xx_plus_yy, cang;
-    
+
     // First Slope ...
     x = (afWin[3] - afWin[5]) / psData->ewres;
 
@@ -554,19 +554,19 @@ float GDALHillshadeZevenbergenThorneAlg (float* afWin, float fDstNoDataValue, vo
            sin(aspect - psData->azRadians)) /
            sqrt(1 + psData->square_z_scale_factor * xx_plus_yy);
 
-    if (cang <= 0.0) 
+    if (cang <= 0.0)
         cang = 1.0;
     else
         cang = 1.0 + (254.0 * cang);
-        
+
     return (float) cang;
 }
 
-float GDALHillshadeZevenbergenThorneCombinedAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALHillshadeZevenbergenThorneCombinedAlg (float* afWin, CPL_UNUSED float fDstNoDataValue, void* pData)
 {
     GDALHillshadeAlgData* psData = (GDALHillshadeAlgData*)pData;
     double x, y, aspect, xx_plus_yy, cang;
-    
+
     // First Slope ...
     x = (afWin[3] - afWin[5]) / psData->ewres;
 
@@ -630,39 +630,39 @@ typedef struct
     int    slopeFormat;
 } GDALSlopeAlgData;
 
-float GDALSlopeHornAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALSlopeHornAlg (float* afWin, CPL_UNUSED float fDstNoDataValue, void* pData)
 {
     const double radiansToDegrees = 180.0 / M_PI;
     GDALSlopeAlgData* psData = (GDALSlopeAlgData*)pData;
     double dx, dy, key;
-    
-    dx = ((afWin[0] + afWin[3] + afWin[3] + afWin[6]) - 
+
+    dx = ((afWin[0] + afWin[3] + afWin[3] + afWin[6]) -
           (afWin[2] + afWin[5] + afWin[5] + afWin[8]))/psData->ewres;
 
-    dy = ((afWin[6] + afWin[7] + afWin[7] + afWin[8]) - 
+    dy = ((afWin[6] + afWin[7] + afWin[7] + afWin[8]) -
           (afWin[0] + afWin[1] + afWin[1] + afWin[2]))/psData->nsres;
 
     key = (dx * dx + dy * dy);
 
-    if (psData->slopeFormat == 1) 
+    if (psData->slopeFormat == 1)
         return (float) (atan(sqrt(key) / (8*psData->scale)) * radiansToDegrees);
     else
         return (float) (100*(sqrt(key) / (8*psData->scale)));
 }
 
-float GDALSlopeZevenbergenThorneAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALSlopeZevenbergenThorneAlg (float* afWin, CPL_UNUSED float fDstNoDataValue, void* pData)
 {
     const double radiansToDegrees = 180.0 / M_PI;
     GDALSlopeAlgData* psData = (GDALSlopeAlgData*)pData;
     double dx, dy, key;
-    
+
     dx = (afWin[3] - afWin[5])/psData->ewres;
 
     dy = (afWin[7] - afWin[1])/psData->nsres;
 
     key = (dx * dx + dy * dy);
 
-    if (psData->slopeFormat == 1) 
+    if (psData->slopeFormat == 1)
         return (float) (atan(sqrt(key) / (2*psData->scale)) * radiansToDegrees);
     else
         return (float) (100*(sqrt(key) / (2*psData->scale)));
@@ -1721,7 +1721,9 @@ CPLErr GDALGenerateVRTColorRelief(const char* pszDstFilename,
 /*                         GDALTRIAlg()                                 */
 /************************************************************************/
 
-float GDALTRIAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALTRIAlg (float* afWin,
+                  CPL_UNUSED float fDstNoDataValue,
+                  CPL_UNUSED void* pData)
 {
     // Terrain Ruggedness is average difference in height
     return (fabs(afWin[0]-afWin[4]) +
@@ -1739,11 +1741,13 @@ float GDALTRIAlg (float* afWin, float fDstNoDataValue, void* pData)
 /*                         GDALTPIAlg()                                 */
 /************************************************************************/
 
-float GDALTPIAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALTPIAlg (float* afWin,
+                  CPL_UNUSED float fDstNoDataValue,
+                  CPL_UNUSED void* pData)
 {
     // Terrain Position is the difference between
     // The central cell and the mean of the surrounding cells
-    return afWin[4] - 
+    return afWin[4] -
             ((afWin[0]+
               afWin[1]+
               afWin[2]+
@@ -1758,7 +1762,7 @@ float GDALTPIAlg (float* afWin, float fDstNoDataValue, void* pData)
 /*                     GDALRoughnessAlg()                               */
 /************************************************************************/
 
-float GDALRoughnessAlg (float* afWin, float fDstNoDataValue, void* pData)
+float GDALRoughnessAlg (float* afWin, CPL_UNUSED float fDstNoDataValue, CPL_UNUSED void* pData)
 {
     // Roughness is the largest difference
     //  between any two cells
@@ -1918,7 +1922,7 @@ void   GDALGeneric3x3RasterBand::InitWidthNoData(void* pImage)
     }
 }
 
-CPLErr GDALGeneric3x3RasterBand::IReadBlock( int nBlockXOff,
+CPLErr GDALGeneric3x3RasterBand::IReadBlock( CPL_UNUSED int nBlockXOff,
                                              int nBlockYOff,
                                              void *pImage )
 {
@@ -2628,7 +2632,16 @@ int main( int argc, char ** argv )
         }
     }
     
-    if( GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATE, NULL ) == NULL &&
+    // We might actually want to always go through the intermediate dataset
+    int bForceUseIntermediateDataset = FALSE;
+    if( EQUAL(pszFormat, "GTiff") &&
+        !EQUAL(CSLFetchNameValueDef(papszCreateOptions, "COMPRESS", "NONE"), "NONE") &&
+        CSLTestBoolean(CSLFetchNameValueDef(papszCreateOptions, "TILED", "NO")) )
+    {
+        bForceUseIntermediateDataset = TRUE;
+    }
+
+    if( (bForceUseIntermediateDataset || GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATE, NULL ) == NULL) &&
         GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATECOPY, NULL ) != NULL)
     {
         GDALDatasetH hIntermediateDataset;
@@ -2730,4 +2743,3 @@ int main( int argc, char ** argv )
 
     return 0;
 }
-
diff --git a/apps/gdalenhance.cpp b/apps/gdalenhance.cpp
index f2baca4..0bbc0f9 100644
--- a/apps/gdalenhance.cpp
+++ b/apps/gdalenhance.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalenhance.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gdalenhance.cpp 27994 2014-11-21 20:03:49Z rouault $
  *
  * Project:  GDAL Utilities
  * Purpose:  Commandline application to do image enhancement. 
@@ -32,10 +32,10 @@
 #include "cpl_string.h"
 #include "cpl_conv.h"
 #include "cpl_multiproc.h"
-#include "vrt/vrtdataset.h"
+#include "vrtdataset.h"
 #include "commonutils.h"
 
-CPL_CVSID("$Id: gdalenhance.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gdalenhance.cpp 27994 2014-11-21 20:03:49Z rouault $");
 
 static int
 ComputeEqualizationLUTs( GDALDatasetH hDataset,  int nLUTBins,
diff --git a/apps/gdalserver.c b/apps/gdalserver.c
index ee55c90..b7ce6db 100644
--- a/apps/gdalserver.c
+++ b/apps/gdalserver.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalserver.c 27142 2014-04-09 11:14:35Z rouault $
+ * $Id: gdalserver.c 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  GDAL
  * Purpose:  Server application that is forked by libgdal
@@ -77,7 +77,7 @@ int CPL_DLL GDALServerLoop(CPL_FILE_HANDLE fin, CPL_FILE_HANDLE fout);
 int CPL_DLL GDALServerLoopSocket(CPL_SOCKET nSocket);
 CPL_C_END
 
-CPL_CVSID("$Id: gdalserver.c 27142 2014-04-09 11:14:35Z rouault $");
+CPL_CVSID("$Id: gdalserver.c 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                               Usage()                                */
@@ -391,7 +391,7 @@ int RunNewConnection()
 /*                             RunServer()                              */
 /************************************************************************/
 
-int RunServer(const char* pszApplication,
+int RunServer(CPL_UNUSED const char* pszApplication,
               const char* pszService,
               const char* pszUnixSocketFilename)
 {
diff --git a/apps/gdaltindex.c b/apps/gdaltindex.c
index ddcca6c..1cbb100 100644
--- a/apps/gdaltindex.c
+++ b/apps/gdaltindex.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdaltindex.c 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gdaltindex.c 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  MapServer
  * Purpose:  Commandline App to build tile index for raster files.
@@ -35,7 +35,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: gdaltindex.c 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gdaltindex.c 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                               Usage()                                */
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
     const char *index_filename = NULL;
     const char *tile_index = "location";
     const char* pszDriverName = "ESRI Shapefile";
-    int nMaxFieldSize = 254;
+    size_t nMaxFieldSize = 254;
     int		i_arg, ti_field;
     OGRDataSourceH hTileIndexDS;
     OGRLayerH hLayer = NULL;
diff --git a/apps/gdalwarp.cpp b/apps/gdalwarp.cpp
index a917f7a..5b9e34e 100644
--- a/apps/gdalwarp.cpp
+++ b/apps/gdalwarp.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalwarp.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gdalwarp.cpp 28186 2014-12-20 21:14:58Z rouault $
  *
  * Project:  High Performance Image Reprojector
  * Purpose:  Test program for high performance warper API.
@@ -36,7 +36,7 @@
 #include "commonutils.h"
 #include <vector>
 
-CPL_CVSID("$Id: gdalwarp.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gdalwarp.cpp 28186 2014-12-20 21:14:58Z rouault $");
 
 static void
 LoadCutline( const char *pszCutlineDSName, const char *pszCLayer, 
@@ -888,10 +888,9 @@ int main( int argc, char ** argv )
 /* -------------------------------------------------------------------- */
 /*      If not, we need to create it.                                   */
 /* -------------------------------------------------------------------- */
-    int   bInitDestSetForFirst = FALSE;
-
     void* hUniqueTransformArg = NULL;
     GDALDatasetH hUniqueSrcDS = NULL;
+    int bInitDestSetByUser = ( CSLFetchNameValue( papszWarpOptions, "INIT_DEST" ) != NULL );
 
     const char* pszWarpThreads = CSLFetchNameValue(papszWarpOptions, "NUM_THREADS");
     if( pszWarpThreads != NULL )
@@ -908,18 +907,18 @@ int main( int argc, char ** argv )
                                        &hUniqueSrcDS, bSetColorInterpretation);
         bCreateOutput = TRUE;
 
-        if( CSLFetchNameValue( papszWarpOptions, "INIT_DEST" ) == NULL 
-            && pszDstNodata == NULL )
-        {
-            papszWarpOptions = CSLSetNameValue(papszWarpOptions,
-                                               "INIT_DEST", "0");
-            bInitDestSetForFirst = TRUE;
-        }
-        else if( CSLFetchNameValue( papszWarpOptions, "INIT_DEST" ) == NULL )
+        if( !bInitDestSetByUser )
         {
-            papszWarpOptions = CSLSetNameValue(papszWarpOptions,
-                                               "INIT_DEST", "NO_DATA" );
-            bInitDestSetForFirst = TRUE;
+            if ( pszDstNodata == NULL )
+            {
+                papszWarpOptions = CSLSetNameValue(papszWarpOptions,
+                                                "INIT_DEST", "0");
+            }
+            else
+            {
+                papszWarpOptions = CSLSetNameValue(papszWarpOptions,
+                                                "INIT_DEST", "NO_DATA" );
+            }
         }
 
         CSLDestroy( papszCreateOptions );
@@ -1116,7 +1115,7 @@ int main( int argc, char ** argv )
 /* -------------------------------------------------------------------- */
 /*      Clear temporary INIT_DEST settings after the first image.       */
 /* -------------------------------------------------------------------- */
-        if( bInitDestSetForFirst && iSrc == 1 )
+        if( bCreateOutput && iSrc == 1 )
             papszWarpOptions = CSLSetNameValue( papszWarpOptions, 
                                                 "INIT_DEST", NULL );
 
@@ -1413,6 +1412,13 @@ int main( int argc, char ** argv )
                 }
             }
 
+            if( !bInitDestSetByUser && iSrc == 0 )
+            {
+                /* As we didn't know at the beginning if there was source nodata */
+                /* we have initialized INIT_DEST=0. Override this with NO_DATA now */
+                psWO->papszWarpOptions = CSLSetNameValue(psWO->papszWarpOptions,
+                                                   "INIT_DEST", "NO_DATA" );
+            }
         }
 
 /* -------------------------------------------------------------------- */
diff --git a/apps/makefile.vc b/apps/makefile.vc
index 864847a..b29c647 100644
--- a/apps/makefile.vc
+++ b/apps/makefile.vc
@@ -5,7 +5,7 @@ XTRAOBJ =	$(SETARGV)
 
 LIBS	=	$(GDAL_ROOT)\gdal_i.lib
 
-XTRAFLAGS =	-I..\frmts -I..\alg -I..\ogr -I..\ogr\ogrsf_frmts  $(GEOS_CFLAGS)
+XTRAFLAGS =	-I..\gcore -I..\port -I..\frmts\vrt -I..\alg -I..\ogr -I..\ogr\ogrsf_frmts  $(GEOS_CFLAGS)
 
 !INCLUDE ..\nmake.opt
 
@@ -24,157 +24,157 @@ all:	default multireadtest.exe \
 			gdaltorture.exe gdal2ogr.exe test_ogrsf.exe
 
 gdalinfo.exe:	gdalinfo.c commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalinfo.c commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalinfo.c commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdalserver.exe:	gdalserver.c $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalserver.c ws2_32.lib $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalserver.c ws2_32.lib $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdal_translate.exe:	gdal_translate.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ)
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdal_translate.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdal_translate.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdaladdo.exe:	gdaladdo.cpp $(GDALLIB) $(XTRAOBJ)
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdaladdo.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdaladdo.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdalwarpsimple.exe:	gdalwarpsimple.c $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalwarpsimple.c $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalwarpsimple.c $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdaltransform.exe:	gdaltransform.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdaltransform.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdaltransform.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdallocationinfo.exe:	gdallocationinfo.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdallocationinfo.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdallocationinfo.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdalsrsinfo.exe:	gdalsrsinfo.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalsrsinfo.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalsrsinfo.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdalwarp.exe:	gdalwarp.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalwarp.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalwarp.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdal_contour.exe:	gdal_contour.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdal_contour.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdal_contour.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 nearblack.exe:	nearblack.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) nearblack.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) nearblack.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdalenhance.exe:	gdalenhance.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalenhance.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalenhance.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdaldem.exe:	gdaldem.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdaldem.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdaldem.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdal_grid.exe:	gdal_grid.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdal_grid.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdal_grid.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 
 gdalmanage.exe:	gdalmanage.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalmanage.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalmanage.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 
 gdaltindex.exe:	gdaltindex.c $(GDALLIB) $(XTRAOBJ)
-	$(CC) /I$(GDAL_ROOT) $(CFLAGS) $(XTRAFLAGS) gdaltindex.c \
+	$(CC) /I$(GDAL_ROOT) $(XTRAFLAGS) $(CFLAGS) gdaltindex.c \
 		$(XTRAOBJ) $(LIBS) /link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdal_rasterize.exe:	gdal_rasterize.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdal_rasterize.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdal_rasterize.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 
 multireadtest.exe:	multireadtest.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) multireadtest.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) multireadtest.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdalasyncread.exe:	gdalasyncread.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalasyncread.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalasyncread.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 testreprojmulti.exe:	testreprojmulti.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) testreprojmulti.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) testreprojmulti.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 ogr2ogr.exe:	ogr2ogr.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) ogr2ogr.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) ogr2ogr.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 ogrinfo.exe:	ogrinfo.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) ogrinfo.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) ogrinfo.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 ogrtindex.exe:	ogrtindex.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) ogrtindex.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) ogrtindex.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 
 ogrlineref.exe:	ogrlineref.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) ogrlineref.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) ogrlineref.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 testepsg.exe:	testepsg.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) testepsg.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) testepsg.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 test_ogrsf.exe:	test_ogrsf.cpp commonutils.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) test_ogrsf.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) test_ogrsf.cpp commonutils.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdalbuildvrt.exe:	gdalbuildvrt.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalbuildvrt.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalbuildvrt.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 dumpoverviews.exe:	dumpoverviews.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) dumpoverviews.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) dumpoverviews.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdalflattenmask.exe:	gdalflattenmask.c $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdalflattenmask.c $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdalflattenmask.c $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdaltorture.exe:	gdaltorture.cpp $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdaltorture.cpp $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdaltorture.cpp $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
 gdal2ogr.exe:	gdal2ogr.c $(GDALLIB) $(XTRAOBJ) 
-	$(CC) $(CFLAGS) $(XTRAFLAGS) gdal2ogr.c $(XTRAOBJ) $(LIBS) \
+	$(CC) $(XTRAFLAGS) $(CFLAGS) gdal2ogr.c $(XTRAOBJ) $(LIBS) \
 		/link $(LINKER_FLAGS)
 	if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
 	
diff --git a/apps/ogr2ogr.cpp b/apps/ogr2ogr.cpp
index 2973435..01d8ebb 100644
--- a/apps/ogr2ogr.cpp
+++ b/apps/ogr2ogr.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogr2ogr.cpp 27475 2014-06-28 13:16:46Z rouault $
+ * $Id: ogr2ogr.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Simple client for translating between formats.
@@ -39,7 +39,7 @@
 #include <map>
 #include <vector>
 
-CPL_CVSID("$Id: ogr2ogr.cpp 27475 2014-06-28 13:16:46Z rouault $");
+CPL_CVSID("$Id: ogr2ogr.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 static int bSkipFailures = FALSE;
 static int nGroupTransactions = 20000;
@@ -2479,24 +2479,24 @@ static int ForceCoordDimension(int eGType, int nCoordDim)
 /*                         SetupTargetLayer()                           */
 /************************************************************************/
 
-static TargetLayerInfo* SetupTargetLayer( OGRDataSource *poSrcDS,
-                                                OGRLayer * poSrcLayer,
-                                                OGRDataSource *poDstDS,
-                                                char **papszLCO,
-                                                const char *pszNewLayerName,
-                                                OGRSpatialReference *poOutputSRSIn,
-                                                int bNullifyOutputSRS,
-                                                char **papszSelFields,
-                                                int bAppend, int bAddMissingFields, int eGType,
-                                                int bPromoteToMulti,
-                                                int nCoordDim, int bOverwrite,
-                                                char** papszFieldTypesToString,
-                                                int bUnsetFieldWidth,
-                                                int bExplodeCollections,
-                                                const char* pszZField,
-                                                char **papszFieldMap,
-                                                const char* pszWHERE,
-                                                int bExactFieldNameMatch )
+static TargetLayerInfo* SetupTargetLayer( CPL_UNUSED OGRDataSource *poSrcDS,
+                                          OGRLayer * poSrcLayer,
+                                          OGRDataSource *poDstDS,
+                                          char **papszLCO,
+                                          const char *pszNewLayerName,
+                                          OGRSpatialReference *poOutputSRSIn,
+                                          int bNullifyOutputSRS,
+                                          char **papszSelFields,
+                                          int bAppend, int bAddMissingFields, int eGType,
+                                          int bPromoteToMulti,
+                                          int nCoordDim, int bOverwrite,
+                                          char** papszFieldTypesToString,
+                                          int bUnsetFieldWidth,
+                                          int bExplodeCollections,
+                                          const char* pszZField,
+                                          char **papszFieldMap,
+                                          const char* pszWHERE,
+                                          int bExactFieldNameMatch )
 {
     OGRLayer    *poDstLayer;
     OGRFeatureDefn *poSrcFDefn;
@@ -3252,7 +3252,7 @@ static int SetupCT( TargetLayerInfo* psInfo,
 static int TranslateLayer( TargetLayerInfo* psInfo,
                            OGRDataSource *poSrcDS,
                            OGRLayer * poSrcLayer,
-                           OGRDataSource *poDstDS,
+                           CPL_UNUSED OGRDataSource *poDstDS,
                            int bTransform,
                            int bWrapDateline,
                            const char* pszDateLineOffset,
@@ -3633,4 +3633,3 @@ end_loop:
 
     return TRUE;
 }
-
diff --git a/apps/ogrlineref.cpp b/apps/ogrlineref.cpp
index f07845a..365b347 100644
--- a/apps/ogrlineref.cpp
+++ b/apps/ogrlineref.cpp
@@ -409,7 +409,12 @@ OGRErr AddFeature(OGRLayer* const poOutLayer, OGRLineString* pPart, double dfFro
 //------------------------------------------------------------------------
 // CreateSubline
 //------------------------------------------------------------------------
-OGRErr CreateSubline(OGRLayer* const poPkLayer, double dfPosBeg, double dfPosEnd, OGRLayer* const poOutLayer, int bDisplayProgress, int bQuiet)
+OGRErr CreateSubline(OGRLayer* const poPkLayer,
+                     double dfPosBeg,
+                     double dfPosEnd,
+                     OGRLayer* const poOutLayer,
+                     CPL_UNUSED int bDisplayProgress,
+                     int bQuiet)
 {
     OGRFeature* pFeature = NULL;
     double dfBeg, dfEnd, dfStep;
@@ -715,9 +720,9 @@ OGRErr CreatePartsFromLineString(OGRLineString* pPathGeom, OGRLayer* const poPkL
     int nCount = 2;
     dfDistance1 = dfDistance2;
     dfPosition = IT->first;
-    ++IT;//get third point    
+    ++IT; // get third point
 
-    double dfEndPosition;
+    double dfEndPosition = 0.0;
     while (IT != moRepers.end())
     {
         if (bDisplayProgress)
@@ -1001,7 +1006,11 @@ OGRErr CreatePartsMultiple(OGRLayer* const poLnLayer, const char* pszLineSepFiel
 //------------------------------------------------------------------------
 // GetPosition
 //------------------------------------------------------------------------
-OGRErr GetPosition(OGRLayer* const poPkLayer, double dfX, double dfY, int bDisplayProgress, int bQuiet)
+OGRErr GetPosition(OGRLayer* const poPkLayer,
+                   double dfX,
+                   double dfY,
+                   CPL_UNUSED int bDisplayProgress,
+                   int bQuiet)
 {
     //create point
     OGRPoint pt;
@@ -1058,7 +1067,10 @@ OGRErr GetPosition(OGRLayer* const poPkLayer, double dfX, double dfY, int bDispl
 //------------------------------------------------------------------------
 // GetCoordinates
 //------------------------------------------------------------------------
-OGRErr GetCoordinates(OGRLayer* const poPkLayer, double dfPos, int bDisplayProgress, int bQuiet)
+OGRErr GetCoordinates(OGRLayer* const poPkLayer,
+                      double dfPos,
+                      CPL_UNUSED int bDisplayProgress,
+                      int bQuiet)
 {
     CPLString szAttributeFilter;
     szAttributeFilter.Printf("%s < %f AND %s > %f", FIELD_START, dfPos, FIELD_FINISH, dfPos);
@@ -1730,4 +1742,3 @@ int main( int nArgc, char ** papszArgv )
     
     return eErr == OGRERR_NONE ? 0 : 1;
 }
-
diff --git a/configure b/configure
index ec031b0..095b79f 100755
--- a/configure
+++ b/configure
@@ -745,6 +745,7 @@ ECW_SETTING
 FGDB_INC
 FGDB_LIB
 FGDB_ENABLED
+OPENJPEG_VERSION
 HAVE_OPENJPEG
 JASPER_FLAGS
 HAVE_JASPER
@@ -22199,14 +22200,78 @@ fi
     if test "$HAVE_OPENJPEG" = "yes"; then
         LIBS="-lopenjp2 $LIBS"
     fi
+  else
+    for ac_header in openjpeg-2.1/openjpeg.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "openjpeg-2.1/openjpeg.h" "ac_cv_header_openjpeg_2_1_openjpeg_h" "$ac_includes_default"
+if test "x$ac_cv_header_openjpeg_2_1_openjpeg_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_OPENJPEG_2_1_OPENJPEG_H 1
+_ACEOF
+
+fi
+
+done
+
+    if test "$ac_cv_header_openjpeg_2_1_openjpeg_h" = "yes"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for opj_stream_set_user_data_length in -lopenjp2" >&5
+$as_echo_n "checking for opj_stream_set_user_data_length in -lopenjp2... " >&6; }
+if ${ac_cv_lib_openjp2_opj_stream_set_user_data_length+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lopenjp2  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opj_stream_set_user_data_length ();
+int
+main ()
+{
+return opj_stream_set_user_data_length ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_openjp2_opj_stream_set_user_data_length=yes
+else
+  ac_cv_lib_openjp2_opj_stream_set_user_data_length=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_openjp2_opj_stream_set_user_data_length" >&5
+$as_echo "$ac_cv_lib_openjp2_opj_stream_set_user_data_length" >&6; }
+if test "x$ac_cv_lib_openjp2_opj_stream_set_user_data_length" = xyes; then :
+  HAVE_OPENJPEG=yes
+else
+  HAVE_OPENJPEG=no
+fi
+
+        if test "$HAVE_OPENJPEG" = "yes"; then
+            OPENJPEG_VERSION=20100
+            LIBS="-lopenjp2 $LIBS"
+        fi
+    fi
   fi
 else
 
   HAVE_OPENJPEG=yes
   if test -r $with_openjpeg/include/openjpeg-2.0/openjpeg.h ; then
     EXTRA_INCLUDES="-I$with_openjpeg/include $EXTRA_INCLUDES"
+  elif test -r $with_openjpeg/include/openjpeg-2.1/openjpeg.h ; then
+    OPENJPEG_VERSION=20100
+    EXTRA_INCLUDES="-I$with_openjpeg/include $EXTRA_INCLUDES"
   else
-    as_fn_error $? "openjpeg.h not found in $with_openjpeg/include/openjpeg-2.0" "$LINENO" 5
+    as_fn_error $? "openjpeg.h not found in $with_openjpeg/include/openjpeg-2.0 or $with_openjpeg/include/openjpeg-2.1" "$LINENO" 5
   fi
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for opj_stream_set_user_data_length in -lopenjp2" >&5
@@ -22265,6 +22330,7 @@ fi
 
 HAVE_OPENJPEG=$HAVE_OPENJPEG
 
+OPENJPEG_VERSION=$OPENJPEG_VERSION
 
 
 
@@ -22963,13 +23029,14 @@ Please, locate Oracle directories using --with-oci or \
             CPPFLAGS="$CPPFLAGS -I$oracle_include_dir3"
         fi
 
-                        saved_LDFLAGS="$LDFLAGS"
-	if test -n "$oracle_include_dir" ; then
+                        if test -n "$oracle_include_dir" ; then
           oci_ldflags="-L$oracle_lib_dir -lclntsh"
         else
           oci_ldflags="-L$oracle_lib_dir -L$oracle_lib_dir2 -lclntsh"
         fi
-        LDFLAGS="$LDFLAGS $oci_ldflags"
+
+        saved_LIBS="$LIBS"
+        LIBS="$LIBS $oci_ldflags"
 
                                 if test -f "$oracle_include_dir/oci.h"; then
             ACTIVE_INCLUDE_DIR="$oracle_include_dir"
@@ -23099,7 +23166,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
         fi
 
         CPPFLAGS="$saved_CPPFLAGS"
-        LDFLAGS="$saved_LDFLAGS"
+        LIBS="$saved_LIBS"
     fi
 
                 oracle_version_req=$ORACLE_OCI_REQ_VERSION
@@ -23323,22 +23390,19 @@ $as_echo "no" >&6; }
   fi
 
   MYSQL_VERSION="`$MYSQL_CONFIG --version`"
+  MYSQL_MAJOR_VERSION=${MYSQL_VERSION%%'.'*}
 
-  case ${MYSQL_VERSION} in
-    [0-3]*)
-      HAVE_MYSQL=no
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, mysql is pre-4.x" >&5
+  if test $MYSQL_MAJOR_VERSION -le 3 ; then
+    HAVE_MYSQL=no
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, mysql is pre-4.x" >&5
 $as_echo "no, mysql is pre-4.x" >&6; }
-	;;
-    *)
+  else
       HAVE_MYSQL=yes
       MYSQL_LIB="`$MYSQL_CONFIG --libs`"
       MYSQL_INC="`$MYSQL_CONFIG --include`"
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-
-	;;
-  esac
+  fi
 fi
 
 HAVE_MYSQL=$HAVE_MYSQL
@@ -24582,13 +24646,14 @@ Please, locate Oracle directories using --with-oci or \
             CPPFLAGS="$CPPFLAGS -I$oracle_include_dir3"
         fi
 
-                        saved_LDFLAGS="$LDFLAGS"
-	if test -n "$oracle_include_dir" ; then
+                        if test -n "$oracle_include_dir" ; then
           oci_ldflags="-L$oracle_lib_dir -lclntsh"
         else
           oci_ldflags="-L$oracle_lib_dir -L$oracle_lib_dir2 -lclntsh"
         fi
-        LDFLAGS="$LDFLAGS $oci_ldflags"
+
+        saved_LIBS="$LIBS"
+        LIBS="$LIBS $oci_ldflags"
 
                                 if test -f "$oracle_include_dir/oci.h"; then
             ACTIVE_INCLUDE_DIR="$oracle_include_dir"
@@ -24718,7 +24783,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
         fi
 
         CPPFLAGS="$saved_CPPFLAGS"
-        LDFLAGS="$saved_LDFLAGS"
+        LIBS="$saved_LIBS"
     fi
 
                 oracle_version_req=$ORACLE_OCI_REQ_VERSION
diff --git a/configure.in b/configure.in
index a0cf595..f1e85d2 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 dnl ***************************************************************************
-dnl $Id: configure.in 27506 2014-07-07 19:49:05Z rouault $
+dnl $Id: configure.in 28317 2015-01-15 22:49:41Z tamas $
 dnl
 dnl Project:  GDAL
 dnl Purpose:  Configure source file.
@@ -1935,14 +1935,26 @@ elif test "$with_openjpeg" = "yes" -o "$with_openjpeg" = "" ; then
     if test "$HAVE_OPENJPEG" = "yes"; then
         LIBS="-lopenjp2 $LIBS"
     fi
+  else
+    AC_CHECK_HEADERS([openjpeg-2.1/openjpeg.h])
+    if test "$ac_cv_header_openjpeg_2_1_openjpeg_h" = "yes"; then
+        AC_CHECK_LIB(openjp2,opj_stream_set_user_data_length,HAVE_OPENJPEG=yes,HAVE_OPENJPEG=no,)
+        if test "$HAVE_OPENJPEG" = "yes"; then
+            OPENJPEG_VERSION=20100
+            LIBS="-lopenjp2 $LIBS"
+        fi
+    fi
   fi
 else
 
   HAVE_OPENJPEG=yes
   if test -r $with_openjpeg/include/openjpeg-2.0/openjpeg.h ; then
     EXTRA_INCLUDES="-I$with_openjpeg/include $EXTRA_INCLUDES"
+  elif test -r $with_openjpeg/include/openjpeg-2.1/openjpeg.h ; then
+    OPENJPEG_VERSION=20100
+    EXTRA_INCLUDES="-I$with_openjpeg/include $EXTRA_INCLUDES"
   else
-    AC_MSG_ERROR([openjpeg.h not found in $with_openjpeg/include/openjpeg-2.0])
+    AC_MSG_ERROR([openjpeg.h not found in $with_openjpeg/include/openjpeg-2.0 or $with_openjpeg/include/openjpeg-2.1])
   fi
 
   AC_CHECK_LIB(openjp2,opj_stream_set_user_data_length,HAVE_OPENJPEG=yes,HAVE_OPENJPEG=no,-L$with_openjpeg/lib)
@@ -1958,7 +1970,7 @@ if test "$HAVE_OPENJPEG" != "no" ; then
 fi
 
 AC_SUBST([HAVE_OPENJPEG],$HAVE_OPENJPEG)
-
+AC_SUBST([OPENJPEG_VERSION],$OPENJPEG_VERSION)
 
 dnl ---------------------------------------------------------------------------
 dnl Select a FGDB API to use, or disable driver.
@@ -2476,20 +2488,17 @@ else
   fi
 
   MYSQL_VERSION="`$MYSQL_CONFIG --version`"
+  MYSQL_MAJOR_VERSION=${MYSQL_VERSION%%'.'*}
 
-  case ${MYSQL_VERSION} in 
-    [[0-3]*]) 
-      HAVE_MYSQL=no
-      AC_MSG_RESULT([no, mysql is pre-4.x])
-	;;
-    *)
+  if test $MYSQL_MAJOR_VERSION -le 3 ; then
+    HAVE_MYSQL=no
+    AC_MSG_RESULT([no, mysql is pre-4.x])
+  else
       HAVE_MYSQL=yes
       MYSQL_LIB="`$MYSQL_CONFIG --libs`"
       MYSQL_INC="`$MYSQL_CONFIG --include`"
-      AC_MSG_RESULT([yes])
-
-	;;
-  esac
+      AC_MSG_RESULT([yes]) 
+  fi
 fi
 
 AC_SUBST(HAVE_MYSQL,$HAVE_MYSQL)
diff --git a/data/gml_registry.xml b/data/gml_registry.xml
index bfaa4c3..545326f 100644
--- a/data/gml_registry.xml
+++ b/data/gml_registry.xml
@@ -37,4 +37,11 @@
                      elementValue="ST"
                      gfsSchemaLocation="ruian_vf_st_v1.gfs" />
     </namespace>
+    <namespace prefix="vf"
+               uri="urn:cz:isvs:ruian:schemas:SpecialniVymennyFormatTypy:v1 SpecialniVymennyFormatTypy.xsd"
+               useGlobalSRSName="true">
+        <featureType elementName="TypSouboru"
+                     elementValue="ST_UVOH"
+                     gfsSchemaLocation="ruian_vf_st_uvoh_v1.gfs" />
+    </namespace>
 </gml_registry>
diff --git a/data/ruian_vf_ob_v1.gfs b/data/ruian_vf_ob_v1.gfs
index bebc746..5bd2e0d 100644
--- a/data/ruian_vf_ob_v1.gfs
+++ b/data/ruian_vf_ob_v1.gfs
@@ -35,7 +35,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -171,6 +171,315 @@
       <Width>12</Width>
     </PropertyDefn>
   </GMLFeatureClass>
+  <!-- Spravní obvody -->
+  <GMLFeatureClass>
+    <Name>SpravniObvody</Name>
+    <ElementPath>Data|SpravniObvody|SpravniObvod</ElementPath>
+    <SRSName>urn:ogc:def:crs:EPSG::5514</SRSName>
+    <!-- Geometrie definičního bodu správního obvodu-->
+    <GeomPropertyDefn>
+      <Name>DefinicniBod</Name> 
+      <ElementPath>Geometrie|DefinicniBod</ElementPath> 
+      <Type>Point</Type>
+    </GeomPropertyDefn>
+    <!-- Originální geometrie hranice správního obvodu -->
+    <GeomPropertyDefn>
+      <Name>OriginalniHranice</Name> 
+      <ElementPath>Geometrie|OriginalniHranice</ElementPath> 
+      <Type>MultiPolygon</Type>
+    </GeomPropertyDefn>
+    <!-- Kód správního obvodu -->
+    <PropertyDefn>
+      <Name>Kod</Name>
+      <ElementPath>Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Název správního obvodu -->
+    <PropertyDefn>
+      <Name>Nazev</Name>
+      <ElementPath>Nazev</ElementPath>
+      <Type>String</Type>
+      <Width>32</Width>
+    </PropertyDefn>
+    <!-- Identifikátor nesprávnosti na prvku -->
+    <PropertyDefn>
+      <Name>Nespravny</Name>
+      <ElementPath>Nespravny</ElementPath>
+      <Type>String</Type>
+      <Width>5</Width>
+    </PropertyDefn>
+    <!-- Kód správniho MOMC -->
+    <PropertyDefn>
+      <Name>SpravniMomcKod</Name>
+      <ElementPath>SpravniMomcKod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Nadřazená obec -->
+    <PropertyDefn>
+      <Name>ObecKod</Name>
+      <ElementPath>Obec|Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Začátek platnosti -->
+    <PropertyDefn>
+      <Name>PlatiOd</Name>
+      <ElementPath>PlatiOd</ElementPath>
+      <Type>String</Type>
+      <Width>19</Width>
+    </PropertyDefn>
+    <!-- Konec platnosti -->
+    <PropertyDefn>
+      <Name>PlatiDo</Name>
+      <ElementPath>PlatiDo</ElementPath>
+      <Type>String</Type>
+      <Width>19</Width>
+    </PropertyDefn>
+    <!-- ID transakce v RUIAN -->
+    <PropertyDefn>
+      <Name>IdTransakce</Name>
+      <ElementPath>IdTransakce</ElementPath>
+      <!-- OGR integers are only 32 bit wide for now, see http://trac.osgeo.org/gdal/wiki/rfc31_ogr_64
+      <Type>Integer</Type>
+      -->
+      <Type>String</Type>
+      <Width>18</Width>
+    </PropertyDefn>
+    <!-- ID návrhu změn v ISUI -->
+    <PropertyDefn>
+      <Name>GlobalniIdNavrhuZmeny</Name>
+      <ElementPath>GlobalniIdNavrhuZmeny</ElementPath>
+      <!-- OGR integers are only 32 bit wide for now, see http://trac.osgeo.org/gdal/wiki/rfc31_ogr_64
+      <Type>Integer</Type>
+      -->
+      <Type>String</Type>
+      <Width>18</Width>
+    </PropertyDefn>
+  </GMLFeatureClass>
+  <!-- MOP -->
+  <GMLFeatureClass>
+    <Name>Mop</Name>
+    <ElementPath>Data|Mop|Mop</ElementPath>
+    <SRSName>urn:ogc:def:crs:EPSG::5514</SRSName>
+    <!-- Geometrie definičního bodu MOP -->
+    <GeomPropertyDefn>
+      <Name>DefinicniBod</Name> 
+      <ElementPath>Geometrie|DefinicniBod</ElementPath> 
+      <Type>Point</Type>
+    </GeomPropertyDefn>
+    <!-- Originální geometrie hranice MOP -->
+    <GeomPropertyDefn>
+      <Name>OriginalniHranice</Name> 
+      <ElementPath>Geometrie|OriginalniHranice</ElementPath> 
+      <Type>MultiPolygon</Type>
+    </GeomPropertyDefn>
+    <!-- Kód MOP -->
+    <PropertyDefn>
+      <Name>Kod</Name>
+      <ElementPath>Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Název MOP -->
+    <PropertyDefn>
+      <Name>Nazev</Name>
+      <ElementPath>Nazev</ElementPath>
+      <Type>String</Type>
+      <Width>32</Width>
+    </PropertyDefn>
+    <!-- Identifikátor nesprávnosti na prvku -->
+    <PropertyDefn>
+      <Name>Nespravny</Name>
+      <ElementPath>Nespravny</ElementPath>
+      <Type>String</Type>
+      <Width>5</Width>
+    </PropertyDefn>
+    <!-- Nadřazená obec -->
+    <PropertyDefn>
+      <Name>ObecKod</Name>
+      <ElementPath>Obec|Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Začátek platnosti -->
+    <PropertyDefn>
+      <Name>PlatiOd</Name>
+      <ElementPath>PlatiOd</ElementPath>
+      <Type>String</Type>
+      <Width>19</Width>
+    </PropertyDefn>
+    <!-- Konec platnosti -->
+    <PropertyDefn>
+      <Name>PlatiDo</Name>
+      <ElementPath>PlatiDo</ElementPath>
+      <Type>String</Type>
+      <Width>19</Width>
+    </PropertyDefn>
+    <!-- ID transakce v RUIAN -->
+    <PropertyDefn>
+      <Name>IdTransakce</Name>
+      <ElementPath>IdTransakce</ElementPath>
+      <!-- OGR integers are only 32 bit wide for now, see http://trac.osgeo.org/gdal/wiki/rfc31_ogr_64
+      <Type>Integer</Type>
+      -->
+      <Type>String</Type>
+      <Width>18</Width>
+    </PropertyDefn>
+    <!-- ID návrhu změn v ISUI -->
+    <PropertyDefn>
+      <Name>GlobalniIdNavrhuZmeny</Name>
+      <ElementPath>GlobalniIdNavrhuZmeny</ElementPath>
+      <!-- OGR integers are only 32 bit wide for now, see http://trac.osgeo.org/gdal/wiki/rfc31_ogr_64
+      <Type>Integer</Type>
+      -->
+      <Type>String</Type>
+      <Width>18</Width>
+    </PropertyDefn>
+  </GMLFeatureClass>
+  <!-- MOMC -->
+  <GMLFeatureClass>
+    <Name>Momc</Name>
+    <ElementPath>Data|Momc|Momc</ElementPath>
+    <SRSName>urn:ogc:def:crs:EPSG::5514</SRSName>
+    <!-- Geometrie definičního bodu MOMC -->
+    <GeomPropertyDefn>
+      <Name>DefinicniBod</Name> 
+      <ElementPath>Geometrie|DefinicniBod</ElementPath> 
+      <Type>Point</Type>
+    </GeomPropertyDefn>
+    <!-- Originální geometrie hranice MOMC -->
+    <GeomPropertyDefn>
+      <Name>OriginalniHranice</Name> 
+      <ElementPath>Geometrie|OriginalniHranice</ElementPath> 
+      <Type>MultiPolygon</Type>
+    </GeomPropertyDefn>
+    <!-- Kód MOMC -->
+    <PropertyDefn>
+      <Name>Kod</Name>
+      <ElementPath>Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Název MOMC -->
+    <PropertyDefn>
+      <Name>Nazev</Name>
+      <ElementPath>Nazev</ElementPath>
+      <Type>String</Type>
+      <Width>48</Width>
+    </PropertyDefn>
+    <!-- Identifikátor nesprávnosti na prvku -->
+    <PropertyDefn>
+      <Name>Nespravny</Name>
+      <ElementPath>Nespravny</ElementPath>
+      <Type>String</Type>
+      <Width>5</Width>
+    </PropertyDefn>
+    <!-- Nadřazená MOP -->
+    <PropertyDefn>
+      <Name>MopKod</Name>
+      <ElementPath>Mop|Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Nadřazená obec -->
+    <PropertyDefn>
+      <Name>ObecKod</Name>
+      <ElementPath>Obec|Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Nadřazený správní obvod -->
+    <PropertyDefn>
+      <Name>SpravniObvodKod</Name>
+      <ElementPath>SpravniObvod|Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Začátek platnosti -->
+    <PropertyDefn>
+      <Name>PlatiOd</Name>
+      <ElementPath>PlatiOd</ElementPath>
+      <Type>String</Type>
+      <Width>19</Width>
+    </PropertyDefn>
+    <!-- Konec platnosti -->
+    <PropertyDefn>
+      <Name>PlatiDo</Name>
+      <ElementPath>PlatiDo</ElementPath>
+      <Type>String</Type>
+      <Width>19</Width>
+    </PropertyDefn>
+    <!-- ID transakce v RUIAN -->
+    <PropertyDefn>
+      <Name>IdTransakce</Name>
+      <ElementPath>IdTransakce</ElementPath>
+      <!-- OGR integers are only 32 bit wide for now, see http://trac.osgeo.org/gdal/wiki/rfc31_ogr_64
+      <Type>Integer</Type>
+      -->
+      <Type>String</Type>
+      <Width>18</Width>
+    </PropertyDefn>
+    <!-- ID návrhu změn v ISUI -->
+    <PropertyDefn>
+      <Name>GlobalniIdNavrhuZmeny</Name>
+      <ElementPath>GlobalniIdNavrhuZmeny</ElementPath>
+      <!-- OGR integers are only 32 bit wide for now, see http://trac.osgeo.org/gdal/wiki/rfc31_ogr_64
+      <Type>Integer</Type>
+      -->
+      <Type>String</Type>
+      <Width>18</Width>
+    </PropertyDefn>
+    <!-- Text popisující vlajku MOMC -->
+    <PropertyDefn>
+      <Name>VlajkaText</Name>
+      <ElementPath>VlajkaText</ElementPath>
+      <Type>String</Type>
+      <Width>4000</Width>
+    </PropertyDefn>
+    <!-- Obrázek vlajky MOMC -->
+    <PropertyDefn>
+      <Name>VlajkaObrazek</Name>
+      <ElementPath>VlajkaObrazek</ElementPath>
+      <Type>Complex</Type> <!-- ??? -->
+    </PropertyDefn>
+    <!-- Mluvnické charakteristiky 2 až 7 pád -->
+    <PropertyDefn>
+      <Name>MluvnickeCharakteristikyPad2</Name>
+      <ElementPath>MluvnickeCharakteristiky|Pad2</ElementPath>
+      <Type>String</Type>
+      <Width>48</Width>
+    </PropertyDefn>
+    <PropertyDefn>
+      <Name>MluvnickeCharakteristikyPad3</Name>
+      <ElementPath>MluvnickeCharakteristiky|Pad3</ElementPath>
+      <Type>String</Type>
+      <Width>48</Width>
+    </PropertyDefn>
+    <PropertyDefn>
+      <Name>MluvnickeCharakteristikyPad4</Name>
+      <ElementPath>MluvnickeCharakteristiky|Pad4</ElementPath>
+      <Type>String</Type>
+      <Width>48</Width>
+    </PropertyDefn>
+    <PropertyDefn>
+      <Name>MluvnickeCharakteristikyPad6</Name>
+      <ElementPath>MluvnickeCharakteristiky|Pad6</ElementPath>
+      <Type>String</Type>
+      <Width>48</Width>
+    </PropertyDefn>
+    <PropertyDefn>
+      <Name>MluvnickeCharakteristikyPad7</Name>
+      <ElementPath>MluvnickeCharakteristiky|Pad7</ElementPath>
+      <Type>String</Type>
+      <Width>48</Width>
+    </PropertyDefn>
+    <!-- Text popisující znak MOMC -->
+    <PropertyDefn>
+      <Name>ZnakText</Name>
+      <ElementPath>ZnakText</ElementPath>
+      <Type>String</Type>
+      <Width>4000</Width>
+    </PropertyDefn>
+    <!-- Obrázek znaku MOMC -->
+    <PropertyDefn>
+      <Name>ZnakObrazek</Name>
+      <ElementPath>ZnakObrazek</ElementPath>
+      <Type>Complex</Type> <!-- ??? -->
+    </PropertyDefn>
+  </GMLFeatureClass>
   <!-- CastiObci -->
   <GMLFeatureClass>
     <Name>CastiObci</Name>
@@ -195,7 +504,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -310,7 +619,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -436,7 +745,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -555,7 +864,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -614,7 +923,7 @@
       <ElementPath>Geometrie|DefinicniBod</ElementPath> 
       <Type>Point</Type>
     </GeomPropertyDefn>
-    <!-- Originální geometrie hranice parcely ? -->
+    <!-- Originální geometrie hranice parcely -->
     <GeomPropertyDefn>
       <Name>OriginalniHranice</Name> 
       <ElementPath>Geometrie|OriginalniHranice</ElementPath> 
@@ -630,7 +939,7 @@
       <Type>String</Type>
       <Width>18</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -789,7 +1098,7 @@
       <ElementPath>Geometrie|DefinicniBod</ElementPath> 
       <Type>Point</Type>
     </GeomPropertyDefn>
-    <!-- Originální geometrie hranice stavebního objektu ? -->
+    <!-- Originální geometrie hranice stavebního objektu -->
     <GeomPropertyDefn>
       <Name>OriginalniHranice</Name> 
       <ElementPath>Geometrie|OriginalniHranice</ElementPath> 
@@ -801,7 +1110,7 @@
       <ElementPath>Kod</ElementPath>
       <Type>Integer</Type>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -994,7 +1303,7 @@
       <Type>String</Type>
       <Width>18</Width>
     </PropertyDefn>
-    <!-- Detailní tecnicko-ekonomické atributy (TEA) (?) -->
+    <!-- Detailní tecnicko-ekonomické atributy (TEA) -->
     <PropertyDefn>
       <Name>DetailniTEAKod</Name>
       <ElementPath>DetailniTEA|Kod</ElementPath>
@@ -1030,7 +1339,7 @@
       <ElementPath>Kod</ElementPath>
       <Type>Integer</Type>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
diff --git a/data/ruian_vf_st_uvoh_v1.gfs b/data/ruian_vf_st_uvoh_v1.gfs
new file mode 100644
index 0000000..e5ac150
--- /dev/null
+++ b/data/ruian_vf_st_uvoh_v1.gfs
@@ -0,0 +1,92 @@
+<GMLFeatureClassList>
+  <!-- Seznam volebních okrsků -->
+  <GMLFeatureClass>
+    <Name>VolebniOkrsek</Name>
+    <ElementPath>Data|VolebniOkrsek|VO</ElementPath>
+    <SRSName>urn:ogc:def:crs:EPSG::5514</SRSName>
+    <!-- Geometrie definičního bodu volebního okrsku -->
+    <GeomPropertyDefn>
+      <Name>DefinicniBod</Name> 
+      <ElementPath>Geometrie|DefinicniBod</ElementPath> 
+      <Type>Point</Type>
+    </GeomPropertyDefn>
+    <!-- Originální geometrie hranice volebního okrsku -->
+    <GeomPropertyDefn>
+      <Name>OriginalniHranice</Name> 
+      <ElementPath>Geometrie|OriginalniHranice</ElementPath> 
+      <Type>MultiPolygon</Type>
+    </GeomPropertyDefn>
+    <!-- Kód volebního okrsku -->
+    <PropertyDefn>
+      <Name>Kod</Name>
+      <ElementPath>Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Číslo volebního okrsku -->
+    <PropertyDefn>
+      <Name>Cislo</Name>
+      <ElementPath>Cislo</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <PropertyDefn>
+      <Name>Nespravny</Name>
+      <ElementPath>Nespravny</ElementPath>
+      <Type>String</Type>
+      <Width>5</Width>
+    </PropertyDefn>
+    <!-- Nadřazená obec -->
+    <PropertyDefn>
+      <Name>ObecKod</Name>
+      <ElementPath>Obec|Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Nadřazený MOMC -->
+    <PropertyDefn>
+      <Name>MomcKod</Name>
+      <ElementPath>Momc|Kod</ElementPath>
+      <Type>Integer</Type>
+    </PropertyDefn>
+    <!-- Poznámka -->
+    <PropertyDefn>
+      <Name>Poznamka</Name>
+      <ElementPath>Poznamka</ElementPath>
+      <Type>String</Type>
+      <Width>60</Width>
+    </PropertyDefn>
+    <!-- Začátek platnosti -->
+    <PropertyDefn>
+      <Name>PlatiOd</Name>
+      <ElementPath>PlatiOd</ElementPath>
+      <Type>String</Type>
+      <Width>19</Width>
+    </PropertyDefn>
+    <!-- Konec platnosti -->
+    <PropertyDefn>
+      <Name>PlatiDo</Name>
+      <ElementPath>PlatiDo</ElementPath>
+      <Type>String</Type>
+      <Width>19</Width>
+    </PropertyDefn>
+    <!-- ID transakce v RUIAN -->
+    <PropertyDefn>
+      <Name>IdTransakce</Name>
+      <ElementPath>IdTransakce</ElementPath>
+      <!-- OGR integers are only 32 bit wide for now, see http://trac.osgeo.org/gdal/wiki/rfc31_ogr_64
+      <Type>Integer</Type>
+      -->
+      <Type>String</Type>
+      <Width>18</Width>
+    </PropertyDefn>
+    <!-- ID návrhu změny v ISUI -->
+    <PropertyDefn>
+      <Name>GlobalniIdNavrhuZmeny</Name>
+      <ElementPath>GlobalniIdNavrhuZmeny</ElementPath>
+      <!-- OGR integers are only 32 bit wide for now, see http://trac.osgeo.org/gdal/wiki/rfc31_ogr_64
+      <Type>Integer</Type>
+      -->
+      <Type>String</Type>
+      <Width>18</Width>
+    </PropertyDefn>
+  </GMLFeatureClass>
+</GMLFeatureClassList>
diff --git a/data/ruian_vf_st_v1.gfs b/data/ruian_vf_st_v1.gfs
index 368da78..59e0b16 100644
--- a/data/ruian_vf_st_v1.gfs
+++ b/data/ruian_vf_st_v1.gfs
@@ -35,7 +35,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -120,7 +120,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -211,7 +211,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -303,7 +303,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -394,7 +394,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -491,7 +491,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -581,7 +581,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -673,7 +673,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -839,7 +839,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -923,7 +923,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1001,7 +1001,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1142,7 +1142,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1257,7 +1257,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1383,7 +1383,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
diff --git a/data/ruian_vf_v1.gfs b/data/ruian_vf_v1.gfs
index 30655ed..00da809 100644
--- a/data/ruian_vf_v1.gfs
+++ b/data/ruian_vf_v1.gfs
@@ -35,7 +35,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -120,7 +120,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -211,7 +211,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -303,7 +303,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -394,7 +394,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -491,7 +491,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -581,7 +581,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -673,7 +673,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -839,7 +839,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -923,7 +923,7 @@
       <Type>String</Type>
       <Width>32</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1001,7 +1001,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1142,7 +1142,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1257,7 +1257,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1383,7 +1383,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1502,7 +1502,7 @@
       <Type>String</Type>
       <Width>48</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1561,7 +1561,7 @@
       <ElementPath>Geometrie|DefinicniBod</ElementPath> 
       <Type>Point</Type>
     </GeomPropertyDefn>
-    <!-- Originální geometrie hranice parcely ? -->
+    <!-- Originální geometrie hranice parcely -->
     <GeomPropertyDefn>
       <Name>OriginalniHranice</Name> 
       <ElementPath>Geometrie|OriginalniHranice</ElementPath> 
@@ -1577,7 +1577,7 @@
       <Type>String</Type>
       <Width>18</Width>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1736,7 +1736,7 @@
       <ElementPath>Geometrie|DefinicniBod</ElementPath> 
       <Type>Point</Type>
     </GeomPropertyDefn>
-    <!-- Originální geometrie hranice stavebního objektu ? -->
+    <!-- Originální geometrie hranice stavebního objektu -->
     <GeomPropertyDefn>
       <Name>OriginalniHranice</Name> 
       <ElementPath>Geometrie|OriginalniHranice</ElementPath> 
@@ -1748,7 +1748,7 @@
       <ElementPath>Kod</ElementPath>
       <Type>Integer</Type>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
@@ -1941,7 +1941,7 @@
       <Type>String</Type>
       <Width>18</Width>
     </PropertyDefn>
-    <!-- Detailní tecnicko-ekonomické atributy (TEA) (?) -->
+    <!-- Detailní tecnicko-ekonomické atributy (TEA) -->
     <PropertyDefn>
       <Name>DetailniTEAKod</Name>
       <ElementPath>DetailniTEA|Kod</ElementPath>
@@ -1977,7 +1977,7 @@
       <ElementPath>Kod</ElementPath>
       <Type>Integer</Type>
     </PropertyDefn>
-    <!-- Identifikátor nesprávnosti na prvku (?) -->
+    <!-- Identifikátor nesprávnosti na prvku -->
     <PropertyDefn>
       <Name>Nespravny</Name>
       <ElementPath>Nespravny</ElementPath>
diff --git a/frmts/arg/argdataset.cpp b/frmts/arg/argdataset.cpp
index 7924434..5a7e646 100644
--- a/frmts/arg/argdataset.cpp
+++ b/frmts/arg/argdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: argdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: argdataset.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Azavea Raster Grid format driver.
  * Purpose:  Implements support for reading and writing Azavea Raster Grid
@@ -34,7 +34,7 @@
 #include <json.h>
 #include <ogr_spatialref.h>
 
-CPL_CVSID("$Id: argdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: argdataset.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 #define MAX_FILENAME_LEN 4096
 
@@ -576,17 +576,17 @@ GDALDataset *ARGDataset::Open( GDALOpenInfo * poOpenInfo )
 /************************************************************************/
 /*                          CreateCopy()                                */
 /************************************************************************/
-GDALDataset * ARGDataset::CreateCopy( const char * pszFilename, 
+GDALDataset * ARGDataset::CreateCopy( const char * pszFilename,
                                       GDALDataset * poSrcDS,
                                       CPL_UNUSED int bStrict,
-                                      CPL_UNUSED char ** papszOptions, 
+                                      CPL_UNUSED char ** papszOptions,
                                       CPL_UNUSED GDALProgressFunc pfnProgress,
-                                      CPL_UNUSED void * pProgressData ) 
+                                      CPL_UNUSED void * pProgressData )
 {
     int nBands = poSrcDS->GetRasterCount();
     int nXSize = poSrcDS->GetRasterXSize();
     int nYSize = poSrcDS->GetRasterYSize();
-    int nXBlockSize, nYBlockSize, nPixelOffset;
+    int nXBlockSize, nYBlockSize, nPixelOffset = 0;
     GDALDataType eType;
     CPLString osJSONFilename;
     CPLString pszDataType;
@@ -657,7 +657,7 @@ GDALDataset * ARGDataset::CreateCopy( const char * pszFilename,
     pszWKT = (char *)poSrcDS->GetProjectionRef();
     nErr = oSRS.importFromWkt(&pszWKT);
     if (nErr != OGRERR_NONE) {
-        CPLError( CE_Failure, CPLE_NotSupported, 
+        CPLError( CE_Failure, CPLE_NotSupported,
               "Cannot import spatial reference WKT from source dataset.");
         return NULL;
     }
@@ -760,8 +760,9 @@ GDALDataset * ARGDataset::CreateCopy( const char * pszFilename,
     int bNative = TRUE;
 #endif
 
-    poDstBand = new RawRasterBand( fpImage, 0, nPixelOffset, 
-        nPixelOffset * nXSize, eType, bNative, nXSize, nYSize, TRUE, FALSE);
+    poDstBand = new RawRasterBand( fpImage, 0, nPixelOffset,
+                                   nPixelOffset * nXSize, eType, bNative,
+                                   nXSize, nYSize, TRUE, FALSE);
 
     poSrcBand->GetBlockSize(&nXBlockSize, &nYBlockSize);
 
@@ -846,4 +847,3 @@ void GDALRegister_ARG()
         GetGDALDriverManager()->RegisterDriver( poDriver );
     }
 }
-
diff --git a/frmts/ceos2/ceosrecipe.c b/frmts/ceos2/ceosrecipe.c
index 28b5712..d98b97e 100644
--- a/frmts/ceos2/ceosrecipe.c
+++ b/frmts/ceos2/ceosrecipe.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ceosrecipe.c 10645 2007-01-18 02:22:39Z warmerdam $
+ * $Id: ceosrecipe.c 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  ASI CEOS Translator
  * Purpose:  CEOS field layout recipes.
@@ -29,7 +29,7 @@
 
 #include "ceos.h"
 
-CPL_CVSID("$Id: ceosrecipe.c 10645 2007-01-18 02:22:39Z warmerdam $");
+CPL_CVSID("$Id: ceosrecipe.c 27739 2014-09-25 18:49:52Z goatbar $");
 
 /* Array of Datatypes and their names/values */
 
@@ -310,8 +310,8 @@ int CeosDefaultRecipe( CeosSARVolume_t *volume, void *token )
     CeosTypeCode_t TypeCode;
     struct CeosSARImageDesc *ImageDesc = &(volume->ImageDesc);
     char temp_str[1024];
-    int i, temp_int;
-    
+    int i /*, temp_int */;
+
 #define DoExtractInt(a) ExtractInt( record, recipe[i].Type, recipe[i].Offset, recipe[i].Length, &a)
 
     if(token == NULL)
@@ -323,7 +323,7 @@ int CeosDefaultRecipe( CeosSARVolume_t *volume, void *token )
 
 /*    temp_imagerecipe = (CeosSARImageDescRecipe_t *) token;
     recipe = temp_imagerecipe->Recipe; */
- 
+
     recipe = token;
 
     for(i = 0; recipe[i].ImageDescValue != 0; i++ )
@@ -339,7 +339,7 @@ int CeosDefaultRecipe( CeosSARVolume_t *volume, void *token )
 
 	    if(record == NULL)
 	    {
-		temp_int = 0;
+              /* temp_int = 0; */
 	    } else {
 
 		switch( recipe[i].ImageDescValue )
diff --git a/frmts/e00grid/e00read.c b/frmts/e00grid/e00read.c
index 4a41dc4..0c91d50 100644
--- a/frmts/e00grid/e00read.c
+++ b/frmts/e00grid/e00read.c
@@ -451,15 +451,14 @@ static const char *_UncompressNextLine(E00ReadPtr psInfo)
     int     bEOL = 0;   /* Set to 1 when End of Line reached */
     int     iOutBufPtr = 0, i, n;
     int     iDecimalPoint, bOddNumDigits, iCurDigit;
-    char    *pszExp;
+    char    const *pszExp;
     int     bPreviousCodeWasNumeric = 0;
 
     while(!bEOL && (c=_GetNextSourceChar(psInfo)) != '\0')
     {
         if (c != '~')
         {
-            /* Normal character... just copy it 
-             */
+            /* Normal character... just copy it */
             psInfo->szOutBuf[iOutBufPtr++] = c;
             bPreviousCodeWasNumeric = 0;
         }
@@ -495,7 +494,7 @@ static const char *_UncompressNextLine(E00ReadPtr psInfo)
                 /* If the previous code was numeric, then the only valid code
                  * sequences are the ones above: "~ " and "~}".  If we end up
                  * here, it is because the number was followed by a '~' but
-                 * this '~' was not a code, it only marked the end of a 
+                 * this '~' was not a code, it only marked the end of a
                  * number that was not followed by any space.
                  *
                  * We should simply ignore the '~' and return the character
@@ -522,10 +521,10 @@ static const char *_UncompressNextLine(E00ReadPtr psInfo)
              *                of the number (decimal position, exponent, 
              *                and even or odd number of digits)
              *
-             *  c1 c2 ... cn  each of these characters represent a pair of 
+             *  c1 c2 ... cn  each of these characters represent a pair of
              *                digits of the encoded value with '!' == 00
              *                values 92..99 are encoded on 2 chars that
-             *                must be added to each other 
+             *                must be added to each other
              *                (i.e. 92 == }!, 93 == }", ...)
              *
              *  The sequence ends with a ' ' or a '~' character
@@ -545,14 +544,14 @@ static const char *_UncompressNextLine(E00ReadPtr psInfo)
                     pszExp = "E+";
                 else if (n % 3 == 2 )
                     pszExp = "E-";
-                else 
+                else
                     pszExp = NULL;
 
                 /* Decode the c1 c2 ... cn value and apply the format.
                  * Read characters until we encounter a ' ' or a '~'
                  */
                 iCurDigit = 0;
-                while((c=_GetNextSourceChar(psInfo)) != '\0' && 
+                while((c=_GetNextSourceChar(psInfo)) != '\0' &&
                       c != ' ' && c != '~')
                 {
                     n = c - '!';
@@ -588,7 +587,7 @@ static const char *_UncompressNextLine(E00ReadPtr psInfo)
                 {
                     for(i=0; i<2;i++)
                     {
-                        psInfo->szOutBuf[iOutBufPtr] = 
+                        psInfo->szOutBuf[iOutBufPtr] =
                                    psInfo->szOutBuf[iOutBufPtr-2];
                         psInfo->szOutBuf[iOutBufPtr-2] = pszExp[i];
                         iOutBufPtr++;
@@ -598,7 +597,7 @@ static const char *_UncompressNextLine(E00ReadPtr psInfo)
             else
             {
                 /* Unsupported code sequence... this is a possibility
-                 * given the fact that this library was written by 
+                 * given the fact that this library was written by
                  * reverse-engineering the format!
                  *
                  * Send an error to the user and abort.
@@ -642,5 +641,3 @@ static const char *_UncompressNextLine(E00ReadPtr psInfo)
 
     return psInfo->szOutBuf;
 }
-
-
diff --git a/frmts/ecw/ecwcreatecopy.cpp b/frmts/ecw/ecwcreatecopy.cpp
index 92bf42a..4546a98 100644
--- a/frmts/ecw/ecwcreatecopy.cpp
+++ b/frmts/ecw/ecwcreatecopy.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ecwcreatecopy.cpp 27182 2014-04-14 20:03:08Z rouault $
+ * $Id: ecwcreatecopy.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL ECW Driver
  * Purpose:  ECW CreateCopy method implementation.
@@ -32,7 +32,7 @@
 #include "gdaljp2metadata.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: ecwcreatecopy.cpp 27182 2014-04-14 20:03:08Z rouault $");
+CPL_CVSID("$Id: ecwcreatecopy.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 #if defined(FRMT_ecw) && defined(HAVE_COMPRESS)
 
@@ -268,8 +268,15 @@ bool GDALECWCompressor::WriteCancel()
 /*                         PrepareCoverageBox()                         */
 /************************************************************************/
 
-CPLErr  GDALECWCompressor::PrepareCoverageBox( const char *pszWKT, 
-                                               double *padfGeoTransform )
+CPLErr  GDALECWCompressor::PrepareCoverageBox(
+#ifndef ECW_FW
+    CPL_UNUSED
+#endif
+    const char *pszWKT,
+#ifndef ECW_FW
+    CPL_UNUSED
+#endif
+    double *padfGeoTransform )
 
 {
 #ifndef ECW_FW
@@ -1927,14 +1934,14 @@ ECWWriteRasterBand::~ECWWriteRasterBand()
 /*                             IReadBlock()                             */
 /************************************************************************/
 
-CPLErr ECWWriteRasterBand::IReadBlock( int nBlockX, int nBlockY, 
+CPLErr ECWWriteRasterBand::IReadBlock( CPL_UNUSED int nBlockX,
+                                       CPL_UNUSED int nBlockY,
                                        void *pBuffer )
-
 {
     int nWordSize = GDALGetDataTypeSize( eDataType ) / 8;
 
     // We zero stuff out here, but we can't really read stuff from
-    // a write only stream. 
+    // a write only stream.
 
     memset( pBuffer, 0, nBlockXSize * nWordSize );
 
@@ -1980,13 +1987,13 @@ CPLErr ECWWriteRasterBand::IRasterIO( GDALRWFlag eRWFlag,
 /*                            IWriteBlock()                             */
 /************************************************************************/
 
-CPLErr ECWWriteRasterBand::IWriteBlock( int nBlockX, int nBlockY, 
+CPLErr ECWWriteRasterBand::IWriteBlock( CPL_UNUSED int nBlockX,
+                                        int nBlockY,
                                         void *pBuffer )
-
 {
     int nWordSize = GDALGetDataTypeSize( eDataType ) / 8;
     CPLErr eErr;
-    
+
     if( poGDS->bOutOfOrderWriteOccured )
         return CE_Failure;
 
diff --git a/frmts/ecw/ecwdataset.cpp b/frmts/ecw/ecwdataset.cpp
index ce77e76..e317448 100644
--- a/frmts/ecw/ecwdataset.cpp
+++ b/frmts/ecw/ecwdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ecwdataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ecwdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL 
  * Purpose:  ECW (ERDAS Wavelet Compression Format) Driver
@@ -34,7 +34,7 @@
 #include "ogr_api.h"
 #include "ogr_geometry.h"
 
-CPL_CVSID("$Id: ecwdataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ecwdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 #undef NOISY_DEBUG
 
@@ -715,17 +715,16 @@ CPLErr ECWRasterBand::OldIRasterIO( GDALRWFlag eRWFlag,
 /* -------------------------------------------------------------------- */
 /*      Establish access at the desired resolution.                     */
 /* -------------------------------------------------------------------- */
-    CNCSError oErr;
-
     poGDS->CleanupWindow();
 
     iBand = nBand-1;
     poGDS->nBandIndexToPromoteTo8Bit = ( bPromoteTo8Bit ) ? 0 : -1;
-    oErr = poGDS->poFileView->SetView( 1, (unsigned int *) (&iBand),
-                                       nXOff, nYOff, 
-                                       nXOff + nXSize - 1, 
-                                       nYOff + nYSize - 1,
-                                       nNewXSize, nNewYSize );
+    // TODO: Fix writable strings issue.
+    CNCSError oErr = poGDS->poFileView->SetView( 1, (unsigned int *) (&iBand),
+                                                 nXOff, nYOff,
+                                                 nXOff + nXSize - 1,
+                                                 nYOff + nYSize - 1,
+                                                 nNewXSize, nNewYSize );
     if( oErr.GetErrorNumber() != NCS_SUCCESS )
     {
         CPLFree( pabyWorkBuffer );
@@ -1461,11 +1460,10 @@ void ECWDataset::WriteHeader()
 /************************************************************************/
 
 CPLErr ECWDataset::AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
-                               int nBufXSize, int nBufYSize, 
-                               GDALDataType eDT, 
+                               int nBufXSize, int nBufYSize,
+                               CPL_UNUSED GDALDataType eDT,
                                int nBandCount, int *panBandList,
-                               char **papszOptions )
-
+                               CPL_UNUSED char **papszOptions )
 {
     int *panAdjustedBandList = NULL;
 
@@ -1476,10 +1474,10 @@ CPLErr ECWDataset::AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
 #if !defined(SDK_CAN_DO_SUPERSAMPLING)
     if( nBufXSize > nXSize || nBufYSize > nYSize )
     {
-        CPLError( CE_Warning, CPLE_AppDefined, 
+        CPLError( CE_Warning, CPLE_AppDefined,
                   "Supersampling not directly supported by ECW toolkit,\n"
                   "ignoring AdviseRead() request." );
-        return CE_Warning; 
+        return CE_Warning;
     }
 #endif
 
@@ -1586,14 +1584,13 @@ CPLErr ECWDataset::AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
 /*      another way (not report an error).                              */
 /************************************************************************/
 
-int ECWDataset::TryWinRasterIO( GDALRWFlag eFlag, 
+int ECWDataset::TryWinRasterIO( CPL_UNUSED GDALRWFlag eFlag,
                                 int nXOff, int nYOff, int nXSize, int nYSize,
-                                GByte *pabyData, int nBufXSize, int nBufYSize, 
+                                GByte *pabyData, int nBufXSize, int nBufYSize,
                                 GDALDataType eDT,
-                                int nBandCount, int *panBandList, 
-                                int nPixelSpace, int nLineSpace, 
+                                int nBandCount, int *panBandList,
+                                int nPixelSpace, int nLineSpace,
                                 int nBandSpace )
-
 {
     int iBand, i;
 
@@ -2042,17 +2039,17 @@ CPLErr ECWDataset::IRasterIO( GDALRWFlag eRWFlag,
 /************************************************************************/
 
 CPLErr ECWDataset::ReadBandsDirectly(void * pData, int nBufXSize, int nBufYSize,
-                                     GDALDataType eBufType, 
+                                     CPL_UNUSED GDALDataType eBufType,
                                      int nBandCount,
-                                     int nPixelSpace, int nLineSpace, int nBandSpace)
+                                     CPL_UNUSED int nPixelSpace, int nLineSpace, int nBandSpace)
 {
-    CPLDebug( "ECW", 
-              "ReadBandsDirectly(-> %dx%d) - reading lines directly.", 
+    CPLDebug( "ECW",
+              "ReadBandsDirectly(-> %dx%d) - reading lines directly.",
               nBufXSize, nBufYSize);
 
     UINT8 **pBIL = (UINT8**)NCSMalloc(nBandCount * sizeof(UINT8*), FALSE);
-    
-    for(int nB = 0; nB < nBandCount; nB++) 
+
+    for(int nB = 0; nB < nBandCount; nB++)
     {
         pBIL[nB] = ((UINT8*)pData) + (nBandSpace*nB);//for any bit depth
     }
@@ -2242,8 +2239,8 @@ GDALDataset *ECWDataset::OpenECW( GDALOpenInfo * poOpenInfo )
 
 CNCSJP2FileView *ECWDataset::OpenFileView( const char *pszDatasetName,
                                            bool bProgressive,
-                                           int &bUsingCustomStream, bool bWrite )
-
+                                           int &bUsingCustomStream,
+                                           CPL_UNUSED bool bWrite )
 {
 /* -------------------------------------------------------------------- */
 /*      First we try to open it as a normal CNCSFile, letting the       */
@@ -2256,7 +2253,7 @@ CNCSJP2FileView *ECWDataset::OpenFileView( const char *pszDatasetName,
 
     bUsingCustomStream = FALSE;
     poFileView = new CNCSFile();
-    //we always open in read only mode. This should be improved in the future. 
+    //we always open in read only mode. This should be improved in the future.
     oErr = poFileView->Open( (char *) pszDatasetName, bProgressive, false );
     eErr = oErr.GetErrorNumber();
 
diff --git a/frmts/ecw/jp2userbox.cpp b/frmts/ecw/jp2userbox.cpp
index a04173d..c24651e 100644
--- a/frmts/ecw/jp2userbox.cpp
+++ b/frmts/ecw/jp2userbox.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: jp2userbox.cpp 25784 2013-03-23 11:13:42Z rouault $
+ * $Id: jp2userbox.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL ECW Driver
  * Purpose:  JP2UserBox implementation - arbitrary box read/write.
@@ -29,7 +29,7 @@
 
 #include "gdal_ecw.h"
 
-CPL_CVSID("$Id: jp2userbox.cpp 25784 2013-03-23 11:13:42Z rouault $");
+CPL_CVSID("$Id: jp2userbox.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 #if defined(HAVE_COMPRESS)
 
@@ -94,15 +94,15 @@ void JP2UserBox::UpdateXLBox()
 /************************************************************************/
 
 #if ECWSDK_VERSION >= 40
-CNCSError JP2UserBox::Parse( NCS::SDK::CFileBase &JP2File, 
-                             NCS::CIOStream &Stream )
+CNCSError JP2UserBox::Parse( CPL_UNUSED NCS::SDK::CFileBase &JP2File,
+                             CPL_UNUSED NCS::CIOStream &Stream )
 #else
-CNCSError JP2UserBox::Parse( class CNCSJP2File &JP2File, 
-                             CNCSJPCIOStream &Stream )
+CNCSError JP2UserBox::Parse( CPL_UNUSED class CNCSJP2File &JP2File,
+                             CPL_UNUSED CNCSJPCIOStream &Stream )
 #endif
 {
     CNCSError Error = NCS_SUCCESS;
-    
+
     return Error;
 }
 
diff --git a/frmts/fits/fitsdataset.cpp b/frmts/fits/fitsdataset.cpp
index 8483d21..5f0e878 100644
--- a/frmts/fits/fitsdataset.cpp
+++ b/frmts/fits/fitsdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: fitsdataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: fitsdataset.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  FITS Driver
  * Purpose:  Implement FITS raster read/write support
@@ -34,7 +34,7 @@
 #include "cpl_string.h"
 #include <string.h>
 
-CPL_CVSID("$Id: fitsdataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: fitsdataset.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 CPL_C_START
 #include <fitsio.h>
@@ -121,9 +121,8 @@ FITSRasterBand::~FITSRasterBand() {
 /*                             IReadBlock()                             */
 /************************************************************************/
 
-CPLErr FITSRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff,
+CPLErr FITSRasterBand::IReadBlock(CPL_UNUSED int nBlockXOff, int nBlockYOff,
                                   void* pImage ) {
- 
   // A FITS block is one row (we assume BSQ formatted data)
   FITSDataset* dataset = (FITSDataset*) poDS;
   fitsfile* hFITS = dataset->hFITS;
@@ -166,9 +165,8 @@ CPLErr FITSRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff,
 /*                                                                      */
 /************************************************************************/
 
-CPLErr FITSRasterBand::IWriteBlock(int nBlockXOff, int nBlockYOff,
+CPLErr FITSRasterBand::IWriteBlock(CPL_UNUSED int nBlockXOff, int nBlockYOff,
 				   void* pImage) {
-
   FITSDataset* dataset = (FITSDataset*) poDS;
   fitsfile* hFITS = dataset->hFITS;
   int status = 0;
@@ -526,11 +524,9 @@ GDALDataset* FITSDataset::Open(GDALOpenInfo* poOpenInfo) {
 /************************************************************************/
 
 GDALDataset *FITSDataset::Create(const char* pszFilename,
-				 int nXSize, int nYSize, 
+				 int nXSize, int nYSize,
 				 int nBands, GDALDataType eType,
-				 char** papszParmList) {
-
-
+				 CPL_UNUSED char** papszParmList) {
   FITSDataset* dataset;
   fitsfile* hFITS;
   int status = 0;
diff --git a/frmts/gif/biggifdataset.cpp b/frmts/gif/biggifdataset.cpp
index 6ee6679..aca3924 100644
--- a/frmts/gif/biggifdataset.cpp
+++ b/frmts/gif/biggifdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: biggifdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: biggifdataset.cpp 28278 2015-01-03 14:00:06Z rouault $
  *
  * Project:  BIGGIF Driver
  * Purpose:  Implement GDAL support for reading large GIF files in a 
@@ -34,7 +34,7 @@
 #include "cpl_string.h"
 #include "gifabstractdataset.h"
 
-CPL_CVSID("$Id: biggifdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: biggifdataset.cpp 28278 2015-01-03 14:00:06Z rouault $");
 
 CPL_C_START
 void	GDALRegister_BIGGIF(void);
@@ -478,6 +478,13 @@ GDALDataset *BIGGIFDataset::Open( GDALOpenInfo * poOpenInfo )
     
     poDS->nRasterXSize = poDS->hGifFile->SavedImages[0].ImageDesc.Width;
     poDS->nRasterYSize = poDS->hGifFile->SavedImages[0].ImageDesc.Height;
+    if( poDS->hGifFile->SavedImages[0].ImageDesc.ColorMap == NULL &&
+        poDS->hGifFile->SColorMap == NULL )
+    {
+        CPLDebug("GIF", "Skipping image without color table");
+        delete poDS;
+        return NULL;
+    }
 
 /* -------------------------------------------------------------------- */
 /*      Create band information objects.                                */
diff --git a/frmts/gif/gifdataset.cpp b/frmts/gif/gifdataset.cpp
index 8a69906..4772cee 100644
--- a/frmts/gif/gifdataset.cpp
+++ b/frmts/gif/gifdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gifdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: gifdataset.cpp 28284 2015-01-03 20:08:36Z rouault $
  *
  * Project:  GIF Driver
  * Purpose:  Implement GDAL GIF Support using libungif code.  
@@ -32,7 +32,7 @@
 #include "cpl_string.h"
 #include "gifabstractdataset.h"
 
-CPL_CVSID("$Id: gifdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: gifdataset.cpp 28284 2015-01-03 20:08:36Z rouault $");
 
 CPL_C_START
 void	GDALRegister_GIF(void);
@@ -166,7 +166,8 @@ GIFRasterBand::GIFRasterBand( GIFDataset *poDS, int nBand,
     {
         unsigned char *pExtData;
 
-        if( psImage->ExtensionBlocks[iExtBlock].Function != 0xf9 )
+        if( psImage->ExtensionBlocks[iExtBlock].Function != 0xf9 ||
+            psImage->ExtensionBlocks[iExtBlock].ByteCount < 4  )
             continue;
 
         pExtData = (unsigned char *) psImage->ExtensionBlocks[iExtBlock].Bytes;
@@ -456,10 +457,22 @@ GDALDataset *GIFDataset::Open( GDALOpenInfo * poOpenInfo )
             || psImage->ImageDesc.Height != poDS->nRasterYSize )
             continue;
 
+        if( psImage->ImageDesc.ColorMap == NULL &&
+            poDS->hGifFile->SColorMap == NULL )
+        {
+            CPLDebug("GIF", "Skipping image without color table");
+            continue;
+        }
+
         poDS->SetBand( poDS->nBands+1, 
                        new GIFRasterBand( poDS, poDS->nBands+1, psImage,
                                           hGifFile->SBackGroundColor ));
     }
+    if( poDS->nBands == 0 )
+    {
+        delete poDS;
+        return NULL;
+    }
 
 /* -------------------------------------------------------------------- */
 /*      Check for georeferencing.                                       */
diff --git a/frmts/grass/grass57dataset.cpp b/frmts/grass/grass57dataset.cpp
index 06a142f..0e1d620 100644
--- a/frmts/grass/grass57dataset.cpp
+++ b/frmts/grass/grass57dataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: grass57dataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: grass57dataset.cpp 28291 2015-01-05 14:45:07Z martinl $
  *
  * Project:  GRASS Driver
  * Purpose:  Implement GRASS raster read/write support
@@ -63,7 +63,7 @@ char *GPJ_grass_to_wkt(struct Key_Value *,
 
 #define GRASS_MAX_COLORS 100000  // what is the right value
 
-CPL_CVSID("$Id: grass57dataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: grass57dataset.cpp 28291 2015-01-05 14:45:07Z martinl $");
 
 CPL_C_START
 void	GDALRegister_GRASS(void);
@@ -92,6 +92,7 @@ CPL_C_END
 #define G_get_d_raster_row       Rast_get_d_row
 #define G_allocate_f_raster_buf  Rast_allocate_f_buf
 #define G_allocate_d_raster_buf  Rast_allocate_d_buf
+#define G__setenv                G_setenv_nogisrc
 #endif
 
 /************************************************************************/
diff --git a/frmts/grib/degrib18/degrib/clock.c b/frmts/grib/degrib18/degrib/clock.c
index 878bbe6..4d43056 100644
--- a/frmts/grib/degrib18/degrib/clock.c
+++ b/frmts/grib/degrib18/degrib/clock.c
@@ -2004,7 +2004,7 @@ int Clock_Scan (double *clock, char *buffer, char f_gmt)
    sChar TimeZone = Clock_GetTimeZone ();
    /* hours to add to local time to get UTC. */
    char f_dayLight = 0;
-   int month;
+   int month = 0;
    int day;
    sInt4 year;
    char f_year = 0;
@@ -2024,7 +2024,7 @@ int Clock_Scan (double *clock, char *buffer, char f_gmt)
    sChar f_ampm = -1;
    char f_timeZone = 0;
    char f_time = 0;
-   char f_date = 0;
+   /* char f_date = 0; */
    char f_slashWord = 0;
    char f_dateWord = 0;
    char f_monthWord = 0;
@@ -2041,7 +2041,7 @@ int Clock_Scan (double *clock, char *buffer, char f_gmt)
       return 0;
 
    f_time = 0;
-   f_date = 0;
+   /* f_date = 0; */
    lastWordType = WT_NONE;
    curTime = 0;
    while (Clock_GetWord (&ptr, &ptr2, word, &wordType) == 0) {
diff --git a/frmts/grib/degrib18/degrib/degrib1.cpp b/frmts/grib/degrib18/degrib/degrib1.cpp
index b830522..9e411c6 100644
--- a/frmts/grib/degrib18/degrib/degrib1.cpp
+++ b/frmts/grib/degrib18/degrib/degrib1.cpp
@@ -1241,10 +1241,10 @@ static int ReadGrib1Sect3 (uChar *bms, uInt4 gribLen, uInt4 *curLoc,
 }
 
 #ifdef DEBUG
-static int UnpackCmplx (uChar *bds, uInt4 gribLen, uInt4 *curLoc,
-                        short int DSF, double *data, grib_MetaData *meta,
-                        char f_bms, uChar *bitmap, double unitM,
-                        double unitB, short int ESF, double refVal,
+static int UnpackCmplx (uChar *bds, CPL_UNUSED uInt4 gribLen, CPL_UNUSED uInt4 *curLoc,
+                        CPL_UNUSED short int DSF, CPL_UNUSED double *data, CPL_UNUSED grib_MetaData *meta,
+                        CPL_UNUSED char f_bms, CPL_UNUSED uChar *bitmap, CPL_UNUSED double unitM,
+                        CPL_UNUSED double unitB, CPL_UNUSED short int ESF, CPL_UNUSED double refVal,
                         uChar numBits, uChar f_octet14)
 {
    uInt4 secLen;
@@ -1391,7 +1391,9 @@ static int ReadGrib1Sect4 (uChar *bds, uInt4 gribLen, uInt4 *curLoc,
    uChar numUnusedBit;  /* # of extra bits at end of record. */
    uChar f_spherHarm;   /* Flag if data contains Spherical Harmonics. */
    uChar f_cmplxPack;   /* Flag if complex packing was used. */
+#ifdef DEBUG
    uChar f_octet14;     /* Flag if octet 14 was used. */
+#endif
    uChar bufLoc;        /* Keeps track of where to start getting more data
                          * out of the packed data stream. */
    uChar f_convert;     /* Determine if scan mode implies that we have to do
@@ -1428,7 +1430,9 @@ static int ReadGrib1Sect4 (uChar *bds, uInt4 gribLen, uInt4 *curLoc,
    f_spherHarm = (*bds) & GRIB2BIT_1;
    f_cmplxPack = (*bds) & GRIB2BIT_2;
    meta->gridAttrib.fieldType = (*bds) & GRIB2BIT_3;
+#ifdef DEBUG
    f_octet14 = (*bds) & GRIB2BIT_4;
+#endif
 
    numUnusedBit = (*bds) & 0x0f;
 #ifdef DEBUG
diff --git a/frmts/grib/degrib18/degrib/grib2api.c b/frmts/grib/degrib18/degrib/grib2api.c
index 9898538..fc2a7b8 100644
--- a/frmts/grib/degrib18/degrib/grib2api.c
+++ b/frmts/grib/degrib18/degrib/grib2api.c
@@ -1630,7 +1630,7 @@ void unpk_grib2 (sInt4 * kfildo, float * ain, sInt4 * iain, sInt4 * nd2x3,
    sInt4 pdsTmpl;
    sInt4 drsTmpl;
    sInt4 numGrps;
-      char f_useMDL = 0;   /* Instructed 3/8/2005 10:30 to not use MDL. */
+   /* char f_useMDL = 0; */   /* Instructed 3/8/2005 10:30 to not use MDL. */
    uChar f_noBitmap;    /* 0 if bitmap, else no bitmap. */
    sInt4 orderDiff;
 
@@ -1643,23 +1643,23 @@ void unpk_grib2 (sInt4 * kfildo, float * ain, sInt4 * iain, sInt4 * nd2x3,
    if ((gdsTmpl != 0) && (gdsTmpl != 10) && (gdsTmpl != 20) &&
        (gdsTmpl != 30) && (gdsTmpl != 90) && (gdsTmpl != 110) &&
        (gdsTmpl != 120)) {
-      f_useMDL = 0;
+       /* f_useMDL = 0; */
    }
    if ((pdsTmpl != 0) && (pdsTmpl != 1) && (pdsTmpl != 2) &&
        (pdsTmpl != 8) && (pdsTmpl != 9) && (pdsTmpl != 20) &&
        (pdsTmpl != 30)) {
-      f_useMDL = 0;
+       /* f_useMDL = 0; */
    }
    if ((drsTmpl != 0) && (drsTmpl != 2) && (drsTmpl != 3)) {
-      f_useMDL = 0;
+       /* f_useMDL = 0; */
    }
    /* MDL GRIB2 lib does not support drsTmpl 2 or 3 if there is a bitmap. */
    if ((!f_noBitmap) && ((drsTmpl == 2) || (drsTmpl == 3))) {
-      f_useMDL = 0;
+       /* f_useMDL = 0; */
    }
    /* MDL GRIB2 lib does not support anything but second order differencing. */
    if ((drsTmpl == 3) && (orderDiff != 2) && (orderDiff != 0)) {
-      f_useMDL = 0;
+       /* f_useMDL = 0; */
    }
 
 #ifdef _FORTRAN
diff --git a/frmts/grib/degrib18/degrib/inventory.cpp b/frmts/grib/degrib18/degrib/inventory.cpp
index 1b39d87..8788fc1 100644
--- a/frmts/grib/degrib18/degrib/inventory.cpp
+++ b/frmts/grib/degrib18/degrib/inventory.cpp
@@ -1070,11 +1070,11 @@ int GRIB2RefTime (char *filename, double *refTime)
    sInt4 sect0[SECT0LEN_WORD]; /* Holds the current Section 0. */
    char *buffer = NULL; /* Holds a given section. */
    uInt4 bufferLen = 0; /* Size of buffer. */
-   wordType word;       /* Used to parse the prodType out of Sect 0. */
+   /* wordType word; */       /* Used to parse the prodType out of Sect 0. */
    int ans;             /* The return error code of ReadSect0. */
    char *msg;           /* Used to pop messages off the error Stack. */
    int version;         /* Which version of GRIB is in this message. */
-   uChar prodType;      /* Which GRIB2 type of product, 0 is meteo, 1 is
+   /* uChar prodType; */      /* Which GRIB2 type of product, 0 is meteo, 1 is
                          * hydro, 2 is land, 3 is space, 10 is oceanographic. 
                          */
    int grib_limit;      /* How many bytes to look for before the first "GRIB" 
@@ -1160,8 +1160,8 @@ int GRIB2RefTime (char *filename, double *refTime)
             return -13;
          }
       } else {
-         word.li = sect0[1];
-         prodType = word.buffer[2];
+          /* word.li = sect0[1]; */
+         /* prodType = word.buffer[2]; */
 
          /* Read section 1 into buffer. */
          sectNum = 1;
diff --git a/frmts/grib/degrib18/degrib/tdlpack.cpp b/frmts/grib/degrib18/degrib/tdlpack.cpp
index b0931b5..32ace53 100644
--- a/frmts/grib/degrib18/degrib/tdlpack.cpp
+++ b/frmts/grib/degrib18/degrib/tdlpack.cpp
@@ -4018,10 +4018,13 @@ int WriteTDLPRecord (FILE * fp, double *Data, sInt4 DataLen, int DSF,
    sInt4 *Scaled;       /* The scaled data. */
    TDLGroupType *group; /* The groups used to pack the data. */
    size_t numGroup;     /* Number of groups. */
-   char f_grid = 1;     /* Flag if this is gridded data. In theory can handle 
+   char f_grid = 1;     /* Flag if this is gridded data. In theory can handle
                          * vector data, but haven't tested it. */
    char f_sndOrder;     /* Flag if we should try second order packing. */
+
+   /* TODO: Trace overallMin to figure out how it could be used uninitialized */
    sInt4 overallMin;    /* Overall min value of the scaled data. */
+
    sInt4 a1;            /* 2nd order difference: 1st value. */
    sInt4 b2;            /* 2nd order difference: 1st 1st order difference */
    sInt4 li_primMiss;   /* Scaled primary missing value. */
@@ -4174,7 +4177,10 @@ int WriteTDLPRecord (FILE * fp, double *Data, sInt4 DataLen, int DSF,
 
    /* --- Start Writing record. --- */
    /* First write FORTRAN record information */
-   fread(&(recSize), sizeof (sInt4), 1, fp);
+   const size_t read_size = fread(&(recSize), sizeof (sInt4), 1, fp);
+   if (read_size != 1) {
+     fprintf(stderr, "WARNING: tdlpack.cpp read of recSize failed.\n");
+   }
    li_temp = 0;
    FWRITE_BIG (&(li_temp), sizeof (sInt4), 1, fp);
    li_temp = recSize - 8; /* FORTRAN rec length. */
diff --git a/frmts/grib/degrib18/g2clib-1.0.4/compack.c b/frmts/grib/degrib18/g2clib-1.0.4/compack.c
index bb30755..4f9bd2c 100644
--- a/frmts/grib/degrib18/g2clib-1.0.4/compack.c
+++ b/frmts/grib/degrib18/g2clib-1.0.4/compack.c
@@ -67,7 +67,7 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
       static g2int zero=0;
       g2int  *ifld,*gref,*glen,*gwidth;
       g2int  *jmin, *jmax, *lbit;
-      g2int  i,j,n,nbits,imin,imax,left;
+      g2int  i,j,n, /* nbits, */ imin,imax,left;
       g2int  isd,itemp,ilmax,ngwidthref=0,nbitsgwidth=0;
       g2int  nglenref=0,nglenlast=0,iofst,ival1,ival2;
       g2int  minsd,nbitsd=0,maxorig,nbitorig,ngroups;
@@ -385,7 +385,7 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
         if ( glen!=0 ) free(glen);
       }
       else {          //   Constant field ( max = min )
-        nbits=0;
+        /* nbits=0; */
         *lcpack=0;
         nbitsgref=0;
         ngroups=0;
diff --git a/frmts/grib/degrib18/g2clib-1.0.4/jpcunpack.c b/frmts/grib/degrib18/g2clib-1.0.4/jpcunpack.c
index 3a76c6e..6fbecbf 100644
--- a/frmts/grib/degrib18/g2clib-1.0.4/jpcunpack.c
+++ b/frmts/grib/degrib18/g2clib-1.0.4/jpcunpack.c
@@ -11,7 +11,7 @@ g2int jpcunpack(unsigned char *cpack,g2int len,g2int *idrstmpl,g2int ndpts,
 // SUBPROGRAM:    jpcunpack
 //   PRGMMR: Gilbert          ORG: W/NP11    DATE: 2003-08-27
 //
-// ABSTRACT: This subroutine unpacks a data field that was packed into a 
+// ABSTRACT: This subroutine unpacks a data field that was packed into a
 //   JPEG2000 code stream
 //   using info from the GRIB2 Data Representation Template 5.40 or 5.40000.
 //
@@ -40,7 +40,7 @@ g2int jpcunpack(unsigned char *cpack,g2int len,g2int *idrstmpl,g2int ndpts,
 {
 
       g2int  *ifld;
-      g2int  j,nbits,iret;
+      g2int  j,nbits /* ,iret */;
       g2float  ref,bscale,dscale;
 
       rdieee(idrstmpl+0,&ref,1);
@@ -58,7 +58,7 @@ g2int jpcunpack(unsigned char *cpack,g2int len,g2int *idrstmpl,g2int ndpts,
             fprintf(stderr,"Could not allocate space in jpcunpack.\n  Data field NOT upacked.\n");
             return(1);
          }
-         iret=(g2int)dec_jpeg2000((char *) cpack,len,ifld);
+         /* iret= (g2int) */ dec_jpeg2000((char *) cpack,len,ifld);
          for (j=0;j<ndpts;j++) {
            fld[j]=(((g2float)ifld[j]*bscale)+ref)*dscale;
          }
diff --git a/frmts/grib/degrib18/g2clib-1.0.4/misspack.c b/frmts/grib/degrib18/g2clib-1.0.4/misspack.c
index 6aada5e..d79a5f3 100644
--- a/frmts/grib/degrib18/g2clib-1.0.4/misspack.c
+++ b/frmts/grib/degrib18/g2clib-1.0.4/misspack.c
@@ -69,9 +69,9 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
       static g2int zero=0;
       g2int  *gref, *gwidth, *glen;
       g2int  glength, grpwidth;
-      g2int  i, n, iofst, imin, ival1, ival2, isd, minsd, nbitsd;
+      g2int  i, n, iofst, imin, ival1, ival2, isd, minsd, nbitsd = 0;
       g2int  nbitsgref, left, iwmax, ngwidthref, nbitsgwidth, ilmax;
-      g2int  nglenref, nglenlast, nbitsglen, ij;
+      g2int  nglenref, nglenlast, nbitsglen /* , ij */;
       g2int  j, missopt, nonmiss, itemp, maxorig, nbitorig, miss1, miss2;
       g2int  ngroups, ng, num0, num1, num2;
       g2int  imax, lg, mtemp, ier, igmax;
@@ -80,7 +80,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
       static g2int simple_alg = 0;
       static g2float alog2=0.69314718;       //  ln(2.0)
       static g2int one=1;
-      
+
       bscale=int_power(2.0,-idrstmpl[1]);
       dscale=int_power(10.0,idrstmpl[2]);
       missopt=idrstmpl[6];
@@ -472,7 +472,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
         //
         //write(77,*)'IFLDS: ',(ifld(j),j=1,ndpts)
         n=0;
-        ij=0;
+        // ij=0;
         for ( ng=0; ng<ngroups; ng++) {
            glength=glen[ng]+nglenref;
            if (ng == (ngroups-1) ) glength=nglenlast;
diff --git a/frmts/grib/degrib18/g2clib-1.0.4/mkieee.c b/frmts/grib/degrib18/g2clib-1.0.4/mkieee.c
index 41e0734..f0931a2 100644
--- a/frmts/grib/degrib18/g2clib-1.0.4/mkieee.c
+++ b/frmts/grib/degrib18/g2clib-1.0.4/mkieee.c
@@ -36,7 +36,7 @@ void mkieee(g2float *a,g2int *rieee,g2int num)
 {
 
       g2int  j,n,ieee,iexp,imant;
-      double  alog2,atemp;
+      double  /* alog2, */ atemp;
 
       static double  two23,two126;
       static g2int test=0;
@@ -50,7 +50,7 @@ void mkieee(g2float *a,g2int *rieee,g2int num)
          test=1;
       }
 
-      alog2=0.69314718;       //  ln(2.0)
+      // alog2=0.69314718;       //  ln(2.0)
 
       for (j=0;j<num;j++) {
       
diff --git a/frmts/grib/degrib18/g2clib-1.0.4/reduce.c b/frmts/grib/degrib18/g2clib-1.0.4/reduce.c
index ae94949..50bdaa2 100644
--- a/frmts/grib/degrib18/g2clib-1.0.4/reduce.c
+++ b/frmts/grib/degrib18/g2clib-1.0.4/reduce.c
@@ -36,8 +36,8 @@ typedef g2float real;
     static real pimp;
     static integer move, novl;
     static char cfeed[1];
-    static integer nboxj[31], lxnkp, iorigb, ibxx2m1, movmin,
-	     ntotbt[31], ntotpr, newboxt;
+    static integer /* nboxj[31], */ lxnkp, iorigb, ibxx2m1, movmin,
+        ntotbt[31], ntotpr, newboxt;
     integer *newbox, *newboxp;
 
 
@@ -146,7 +146,7 @@ typedef g2float real;
 
     for (j = 1; j <= 31; ++j) {
 	ntotbt[j - 1] = 999999999;
-	nboxj[j - 1] = 0;
+	/* nboxj[j - 1] = 0; */
 /* L112: */
     }
 
@@ -220,7 +220,7 @@ L190:
 	    ;
 	}
 
-	nboxj[j - 1] = newboxt;
+	/* nboxj[j - 1] = newboxt; */
 	ntotpr = ntotbt[j];
 	ntotbt[j - 1] = (*ibit + *jbit) * (*lx + newboxt) + j * (*lx + 
 		newboxt);
@@ -410,4 +410,3 @@ L410:
     if ( newboxp != 0 ) free(newboxp);
     return 0;
 } /* reduce_ */
-
diff --git a/frmts/grib/degrib18/g2clib-1.0.4/seekgb.c b/frmts/grib/degrib18/g2clib-1.0.4/seekgb.c
index b1fb9b7..8bff0c5 100644
--- a/frmts/grib/degrib18/g2clib-1.0.4/seekgb.c
+++ b/frmts/grib/degrib18/g2clib-1.0.4/seekgb.c
@@ -9,7 +9,7 @@ void seekgb(FILE *lugb,g2int iseek,g2int mseek,g2int *lskip,g2int *lgrib)
 //   PRGMMR: Gilbert          ORG: W/NP11      DATE: 2002-10-28
 //
 // ABSTRACT: This subprogram searches a file for the next GRIB Message.
-//   The search is done starting at byte offset iseek of the file referenced 
+//   The search is done starting at byte offset iseek of the file referenced
 //   by lugb for mseek bytes at a time.
 //   If found, the starting position and length of the message are returned
 //   in lskip and lgrib, respectively.
@@ -34,7 +34,7 @@ void seekgb(FILE *lugb,g2int iseek,g2int mseek,g2int *lskip,g2int *lgrib)
 //
 //$$$
 {
-      g2int  ret;
+      // g2int  ret;
       g2int k,k4,ipos,nread,lim,start,vers,end,lengrib;
       unsigned char *cbuf;
 
@@ -51,7 +51,7 @@ void seekgb(FILE *lugb,g2int iseek,g2int mseek,g2int *lskip,g2int *lgrib)
 
 //  READ PARTIAL SECTION
 
-        ret=fseek(lugb,ipos,SEEK_SET);
+        /* ret= */ fseek(lugb,ipos,SEEK_SET);
         nread=fread(cbuf,sizeof(unsigned char),mseek,lugb);
         lim=nread-8;
 
@@ -64,7 +64,7 @@ void seekgb(FILE *lugb,g2int iseek,g2int mseek,g2int *lskip,g2int *lgrib)
 //  LOOK FOR '7777' AT END OF GRIB MESSAGE
             if (vers == 1) gbit(cbuf,&lengrib,(k+4)*8,3*8);
             if (vers == 2) gbit(cbuf,&lengrib,(k+12)*8,4*8);
-            ret=fseek(lugb,ipos+k+lengrib-4,SEEK_SET);
+            /* ret= */ fseek(lugb,ipos+k+lengrib-4,SEEK_SET);
             k4=fread(&end,sizeof(g2int),1,lugb);
             if (k4 == 1 && end == 926365495) {      //GRIB message found
                 *lskip=ipos+k;
diff --git a/frmts/grib/degrib18/g2clib-1.0.4/simunpack.c b/frmts/grib/degrib18/g2clib-1.0.4/simunpack.c
index dfa431b..cca0d1e 100644
--- a/frmts/grib/degrib18/g2clib-1.0.4/simunpack.c
+++ b/frmts/grib/degrib18/g2clib-1.0.4/simunpack.c
@@ -33,28 +33,27 @@ g2int simunpack(unsigned char *cpack,g2int *idrstmpl,g2int ndpts,g2float *fld)
 //
 // ATTRIBUTES:
 //   LANGUAGE: C
-//   MACHINE:  
+//   MACHINE:
 //
 //$$$//
 {
 
       g2int  *ifld;
-      g2int  j,nbits,itype;
+      g2int  j,nbits /* ,itype */;
       g2float ref,bscale,dscale;
 
-      
       rdieee(idrstmpl+0,&ref,1);
       bscale = int_power(2.0,idrstmpl[1]);
       dscale = int_power(10.0,-idrstmpl[2]);
       nbits = idrstmpl[3];
-      itype = idrstmpl[4];
+      /* itype = idrstmpl[4]; */
 
       ifld=(g2int *)calloc(ndpts,sizeof(g2int));
       if ( ifld == 0 ) {
          fprintf(stderr,"Could not allocate space in simunpack.\n  Data field NOT upacked.\n");
          return(1);
       }
-      
+
 //
 //  if nbits equals 0, we have a constant field where the reference value
 //  is the data value at each gridpoint
diff --git a/frmts/grib/degrib18/g2clib-1.0.4/specpack.c b/frmts/grib/degrib18/g2clib-1.0.4/specpack.c
index 66c16f0..c52f817 100644
--- a/frmts/grib/degrib18/g2clib-1.0.4/specpack.c
+++ b/frmts/grib/degrib18/g2clib-1.0.4/specpack.c
@@ -43,12 +43,12 @@ void specpack(g2float *fld,g2int ndpts,g2int JJ,g2int KK,g2int MM,
 {
 
       g2int    *ifld,tmplsim[5];
-      g2float  bscale,dscale,*unpk,*tfld;
+      g2float  /* bscale, dscale, */ *unpk,*tfld;
       g2float  *pscale,tscale;
       g2int    Js,Ks,Ms,Ts,Ns,inc,incu,incp,n,Nm,m,ipos;
 
-      bscale = int_power(2.0,-idrstmpl[1]);
-      dscale = int_power(10.0,idrstmpl[2]);
+      /* bscale = int_power(2.0,-idrstmpl[1]); */
+      /* dscale = int_power(10.0,idrstmpl[2]); */
       Js=idrstmpl[5];
       Ks=idrstmpl[6];
       Ms=idrstmpl[7];
diff --git a/frmts/gsg/gs7bgdataset.cpp b/frmts/gsg/gs7bgdataset.cpp
index 79167d0..e741522 100644
--- a/frmts/gsg/gs7bgdataset.cpp
+++ b/frmts/gsg/gs7bgdataset.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
- * $Id: gs7bgdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: gs7bgdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL
  * Purpose:  Implements the Golden Software Surfer 7 Binary Grid Format.
@@ -61,7 +61,7 @@
 # define SHRT_MAX 32767
 #endif /* SHRT_MAX */
 
-CPL_CVSID("$Id: gs7bgdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: gs7bgdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void    GDALRegister_GS7BG(void);
@@ -313,10 +313,11 @@ CPLErr GS7BGRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
         return CE_Failure;
     }
 
-    double *pfImage;
-    pfImage = (double *)pImage;
+#ifdef CPL_MSB
+    double *pfImage = (double *)pImage;
     for( int iPixel=0; iPixel<nBlockXSize; iPixel++ )
         CPL_LSBPTR64( pfImage + iPixel );
+#endif
 
     return CE_None;
 }
@@ -1371,4 +1372,3 @@ void GDALRegister_GS7BG()
         GetGDALDriverManager()->RegisterDriver( poDriver );
     }
 }
-
diff --git a/frmts/gsg/gsbgdataset.cpp b/frmts/gsg/gsbgdataset.cpp
index 0393e7e..f0b9270 100644
--- a/frmts/gsg/gsbgdataset.cpp
+++ b/frmts/gsg/gsbgdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gsbgdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: gsbgdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL
  * Purpose:  Implements the Golden Software Binary Grid Format.
@@ -61,7 +61,7 @@
 # define SHRT_MAX 32767
 #endif /* SHRT_MAX */
 
-CPL_CVSID("$Id: gsbgdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: gsbgdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void	GDALRegister_GSBG(void);
@@ -302,10 +302,12 @@ CPLErr GSBGRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
 	return CE_Failure;
     }
 
-    float *pfImage;
-    pfImage = (float *)pImage;
-    for( int iPixel=0; iPixel<nBlockXSize; iPixel++ )
+#ifdef CPL_MSB
+    float *pfImage = (float *)pImage;
+    for( int iPixel=0; iPixel<nBlockXSize; iPixel++ ) {
 	CPL_LSBPTR32( pfImage+iPixel );
+    }
+#endif
 
     return CE_None;
 }
diff --git a/frmts/gtiff/geotiff.cpp b/frmts/gtiff/geotiff.cpp
index 5d9f850..48111e1 100644
--- a/frmts/gtiff/geotiff.cpp
+++ b/frmts/gtiff/geotiff.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: geotiff.cpp 27607 2014-08-27 12:54:43Z rouault $
+ * $Id: geotiff.cpp 28419 2015-02-06 00:28:50Z rouault $
  *
  * Project:  GeoTIFF Driver
  * Purpose:  GDAL GeoTIFF support.
@@ -60,7 +60,7 @@
 #include "tiffiop.h"
 #endif
 
-CPL_CVSID("$Id: geotiff.cpp 27607 2014-08-27 12:54:43Z rouault $");
+CPL_CVSID("$Id: geotiff.cpp 28419 2015-02-06 00:28:50Z rouault $");
 
 #if SIZEOF_VOIDP == 4
 static int bGlobalStripIntegerOverflow = FALSE;
@@ -793,6 +793,7 @@ CPLErr GTiffRasterBand::DirectIO( GDALRWFlag eRWFlag,
           (poGDS->nBitsPerSample == 8 || (poGDS->nBitsPerSample == 16) ||
            poGDS->nBitsPerSample == 32 || poGDS->nBitsPerSample == 64) &&
           poGDS->nBitsPerSample == GDALGetDataTypeSize(eDataType) &&
+          poGDS->SetDirectory() && /* very important to make hTIFF uptodate! */
           !TIFFIsTiled( poGDS->hTIFF )) )
     {
         return CE_Failure;
@@ -1883,7 +1884,13 @@ CPLErr GTiffRasterBand::SetMetadata( char ** papszMD, const char *pszDomain )
     if( pszDomain == NULL || !EQUAL(pszDomain,"_temporary_") )
     {
         if( papszMD != NULL || GetMetadata(pszDomain) != NULL )
+        {
             poGDS->bMetadataChanged = TRUE;
+            // Cancel any existing metadata from PAM file
+            if( eAccess == GA_Update &&
+                GDALPamRasterBand::GetMetadata(pszDomain) != NULL )
+                GDALPamRasterBand::SetMetadata(papszMD, pszDomain);
+        }
     }
 
     return oGTiffMDMD.SetMetadata( papszMD, pszDomain );
@@ -1910,7 +1917,13 @@ CPLErr GTiffRasterBand::SetMetadataItem( const char *pszName,
 
 {
     if( pszDomain == NULL || !EQUAL(pszDomain,"_temporary_") )
+    {
         poGDS->bMetadataChanged = TRUE;
+        // Cancel any existing metadata from PAM file
+        if( eAccess == GA_Update &&
+            GDALPamRasterBand::GetMetadataItem(pszName, pszDomain) != NULL )
+            GDALPamRasterBand::SetMetadataItem(pszName, NULL, pszDomain);
+    }
 
     return oGTiffMDMD.SetMetadataItem( pszName, pszValue, pszDomain );
 }
@@ -2792,8 +2805,9 @@ CPLErr GTiffOddBitsBand::IWriteBlock( int nBlockXOff, int nBlockYOff,
                     nInWord = ((GUInt16 *) pImage)[iPixel++];
                 else if( eDataType == GDT_UInt32 )
                     nInWord = ((GUInt32 *) pImage)[iPixel++];
-                else
+                else {
                     CPLAssert(0);
+                }
 
                 if (nInWord > nMaxVal)
                 {
@@ -2905,8 +2919,9 @@ CPLErr GTiffOddBitsBand::IWriteBlock( int nBlockXOff, int nBlockYOff,
                     nInWord = ((GUInt16 *) pabyThisImage)[iPixel++];
                 else if( eDataType == GDT_UInt32 )
                     nInWord = ((GUInt32 *) pabyThisImage)[iPixel++];
-                else
+                else {
                     CPLAssert(0);
+                }
 
                 if (nInWord > nMaxVal)
                 {
@@ -3218,22 +3233,23 @@ CPLErr GTiffOddBitsBand::IReadBlock( int nBlockXOff, int nBlockYOff,
 
                 for( iBit = 0; iBit < poGDS->nBitsPerSample; iBit++ )
                 {
-                    if( pabyBlockBuf[iBitOffset>>3] 
+                    if( pabyBlockBuf[iBitOffset>>3]
                         & (0x80 >>(iBitOffset & 7)) )
                         nOutWord |= (1 << (poGDS->nBitsPerSample - 1 - iBit));
                     iBitOffset++;
-                } 
+                }
 
                 iBitOffset= iBitOffset + iPixelBitSkip - poGDS->nBitsPerSample;
-                
+
                 if( eDataType == GDT_Byte )
                     ((GByte *) pImage)[iPixel++] = (GByte) nOutWord;
                 else if( eDataType == GDT_UInt16 )
                     ((GUInt16 *) pImage)[iPixel++] = (GUInt16) nOutWord;
                 else if( eDataType == GDT_UInt32 )
                     ((GUInt32 *) pImage)[iPixel++] = nOutWord;
-                else
+                else {
                     CPLAssert(0);
+                }
             }
         }
     }
@@ -5143,8 +5159,7 @@ CPLErr GTiffDataset::IBuildOverviews(
 /* -------------------------------------------------------------------- */
 /*      Refresh old overviews that were listed.                         */
 /* -------------------------------------------------------------------- */
-    if (nCompression != COMPRESSION_NONE &&
-        nPlanarConfig == PLANARCONFIG_CONTIG &&
+    if (nPlanarConfig == PLANARCONFIG_CONTIG &&
         GDALDataTypeIsComplex(GetRasterBand( panBandList[0] )->GetRasterDataType()) == FALSE &&
         GetRasterBand( panBandList[0] )->GetColorTable() == NULL &&
         (EQUALN(pszResampling, "NEAR", 4) || EQUAL(pszResampling, "AVERAGE") || EQUAL(pszResampling, "GAUSS")))
@@ -5152,6 +5167,9 @@ CPLErr GTiffDataset::IBuildOverviews(
         /* In the case of pixel interleaved compressed overviews, we want to generate */
         /* the overviews for all the bands block by block, and not band after band, */
         /* in order to write the block once and not loose space in the TIFF file */
+        /* We also use that logic for uncompressed overviews, since GDALRegenerateOverviewsMultiBand() */
+        /* will be able to trigger cascading overview regeneration even in the presence */
+        /* of an alpha band. */
 
         GDALRasterBand ***papapoOverviewBands;
         GDALRasterBand  **papoBandList;
@@ -9129,8 +9147,12 @@ GTiffDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
 /*      Should we use optimized way of copying from an input JPEG       */
 /*      dataset ?                                                       */
 /* -------------------------------------------------------------------- */
+#if defined(HAVE_LIBJPEG)
     int bCopyFromJPEG = FALSE;
+#endif
+#if defined(HAVE_LIBJPEG) || defined(JPEG_DIRECT_COPY)
     int bDirectCopyFromJPEG = FALSE;
+#endif
 
     /* Note: JPEG_DIRECT_COPY is not defined by default, because it is mainly */
     /* usefull for debugging purposes */
@@ -10174,7 +10196,13 @@ CPLErr GTiffDataset::SetMetadata( char ** papszMD, const char *pszDomain )
     if ((papszMD != NULL) && (pszDomain != NULL) && EQUAL(pszDomain, "COLOR_PROFILE"))
         bColorProfileMetadataChanged = TRUE;
     else if( pszDomain == NULL || !EQUAL(pszDomain,"_temporary_") )
+    {
         bMetadataChanged = TRUE;
+        // Cancel any existing metadata from PAM file
+        if( eAccess == GA_Update &&
+            GDALPamDataset::GetMetadata(pszDomain) != NULL )
+            GDALPamDataset::SetMetadata(papszMD, pszDomain);
+    }
 
     if( (pszDomain == NULL || EQUAL(pszDomain, "")) &&
         CSLFetchNameValue(papszMD, GDALMD_AREA_OR_POINT) != NULL )
@@ -10241,7 +10269,13 @@ CPLErr GTiffDataset::SetMetadataItem( const char *pszName,
     if ((pszDomain != NULL) && EQUAL(pszDomain, "COLOR_PROFILE"))
         bColorProfileMetadataChanged = TRUE;
     else if( pszDomain == NULL || !EQUAL(pszDomain,"_temporary_") )
+    {
         bMetadataChanged = TRUE;
+        // Cancel any existing metadata from PAM file
+        if( eAccess == GA_Update &&
+            GDALPamDataset::GetMetadataItem(pszName, pszDomain) != NULL )
+            GDALPamDataset::SetMetadataItem(pszName, NULL, pszDomain);
+    }
 
     if( (pszDomain == NULL || EQUAL(pszDomain, "")) &&
         pszName != NULL && EQUAL(pszName, GDALMD_AREA_OR_POINT) )
@@ -11087,4 +11121,3 @@ void GDALRegister_GTiff()
         GetGDALDriverManager()->RegisterDriver( poDriver );
     }
 }
-
diff --git a/frmts/gtiff/gt_citation.cpp b/frmts/gtiff/gt_citation.cpp
index 361a962..fc937a5 100644
--- a/frmts/gtiff/gt_citation.cpp
+++ b/frmts/gtiff/gt_citation.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gt_citation.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gt_citation.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GeoTIFF Driver
  * Purpose:  Implements special parsing of Imagine citation strings, and
@@ -35,7 +35,7 @@
 #include "geovalues.h"
 #include "gt_citation.h"
 
-CPL_CVSID("$Id: gt_citation.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gt_citation.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 static const char *apszUnitMap[] = {
     "meters", "1.0",
@@ -156,7 +156,7 @@ char* ImagineCitationTranslation(char* psCitation, geokey_t keyID)
                 if(p1[0] == '\0' || p1[0] == '\n' || p1[0] == ' ')
                     p1 --;
                 p2 = p1 - 1;
-                while( p2>0 && (p2[0] == ' ' || p2[0] == '\0' || p2[0] == '\n') )
+                while( p2 != 0 && (p2[0] == ' ' || p2[0] == '\0' || p2[0] == '\n') )
                     p2--;
                 if(p2 != p1 - 1)
                     p1 = p2;
@@ -199,7 +199,7 @@ char* ImagineCitationTranslation(char* psCitation, geokey_t keyID)
                 if(p1[0] == '\0' || p1[0] == '\n' || p1[0] == ' ')
                     p1 --;
                 char* p2 = p1 - 1;
-                while( p2>0 && (p2[0] == ' ' || p2[0] == '\0' || p2[0] == '\n') )
+                while( p2 != 0 && (p2[0] == ' ' || p2[0] == '\0' || p2[0] == '\n') )
                     p2--;
                 if(p2 != p1 - 1)
                     p1 = p2;
diff --git a/frmts/gtiff/gt_jpeg_copy.cpp b/frmts/gtiff/gt_jpeg_copy.cpp
index 339ba69..aa684f3 100644
--- a/frmts/gtiff/gt_jpeg_copy.cpp
+++ b/frmts/gtiff/gt_jpeg_copy.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gt_jpeg_copy.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: gt_jpeg_copy.cpp 27899 2014-10-23 13:36:59Z rouault $
  *
  * Project:  GeoTIFF Driver
  * Purpose:  Specialized copy of JPEG content into TIFF.
@@ -33,7 +33,7 @@
 /* Note: JPEG_DIRECT_COPY is not defined by default, because it is mainly */
 /* usefull for debugging purposes */
 
-CPL_CVSID("$Id: gt_jpeg_copy.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: gt_jpeg_copy.cpp 27899 2014-10-23 13:36:59Z rouault $");
 
 #if defined(JPEG_DIRECT_COPY) || defined(HAVE_LIBJPEG)
 
@@ -265,9 +265,6 @@ int GTIFF_CanCopyFromJPEG(GDALDataset* poSrcDS, char** &papszCreateOptions)
         poSrcDS->GetMetadataItem("SOURCE_COLOR_SPACE", "IMAGE_STRUCTURE");
     if (pszSrcColorSpace != NULL && EQUAL(pszSrcColorSpace, "YCbCr"))
         nMCUSize = 16;
-    else if (pszSrcColorSpace != NULL &&
-        (EQUAL(pszSrcColorSpace, "CMYK") || EQUAL(pszSrcColorSpace, "YCbCrK")))
-        return FALSE;
 
     int     nXSize = poSrcDS->GetRasterXSize();
     int     nYSize = poSrcDS->GetRasterYSize();
@@ -277,17 +274,37 @@ int GTIFF_CanCopyFromJPEG(GDALDataset* poSrcDS, char** &papszCreateOptions)
     int bCompatiblePhotometric = (
             pszPhotometric == NULL ||
             (nMCUSize == 16 && EQUAL(pszPhotometric, "YCbCr")) ||
+            (nMCUSize == 8 && nBands == 4 &&
+             poSrcDS->GetRasterBand(1)->GetColorInterpretation() == GCI_CyanBand &&
+             poSrcDS->GetRasterBand(2)->GetColorInterpretation() == GCI_MagentaBand &&
+             poSrcDS->GetRasterBand(3)->GetColorInterpretation() == GCI_YellowBand &&
+             poSrcDS->GetRasterBand(4)->GetColorInterpretation() == GCI_BlackBand) ||
             (nMCUSize == 8 && EQUAL(pszPhotometric, "RGB") && nBands == 3) ||
             (nMCUSize == 8 && EQUAL(pszPhotometric, "MINISBLACK") && nBands == 1) );
     if (!bCompatiblePhotometric)
         return FALSE;
 
+    if ( nBands == 4 && pszPhotometric == NULL &&
+         poSrcDS->GetRasterBand(1)->GetColorInterpretation() == GCI_CyanBand &&
+         poSrcDS->GetRasterBand(2)->GetColorInterpretation() == GCI_MagentaBand &&
+         poSrcDS->GetRasterBand(3)->GetColorInterpretation() == GCI_YellowBand &&
+         poSrcDS->GetRasterBand(4)->GetColorInterpretation() == GCI_BlackBand )
+    {
+        papszCreateOptions = CSLSetNameValue(papszCreateOptions, "PHOTOMETRIC", "CMYK");
+    }
+
+    const char* pszInterleave = CSLFetchNameValue(papszCreateOptions, "INTERLEAVE");
+    int bCompatibleInterleave = ( pszInterleave == NULL ||
+                                  (nBands > 1 && EQUAL(pszInterleave, "PIXEL")) ||
+                                  nBands == 1 );
+    if( !bCompatibleInterleave )
+        return FALSE;
+
     if ( (nBlockXSize == nXSize || (nBlockXSize % nMCUSize) == 0) &&
          (nBlockYSize == nYSize || (nBlockYSize % nMCUSize) == 0) &&
          poSrcDS->GetRasterBand(1)->GetRasterDataType() == GDT_Byte &&
          CSLFetchNameValue(papszCreateOptions, "NBITS") == NULL &&
-         CSLFetchNameValue(papszCreateOptions, "JPEG_QUALITY") == NULL &&
-         bCompatiblePhotometric )
+         CSLFetchNameValue(papszCreateOptions, "JPEG_QUALITY") == NULL )
     {
         if (nMCUSize == 16 && pszPhotometric == NULL)
             papszCreateOptions = CSLSetNameValue(papszCreateOptions, "PHOTOMETRIC", "YCBCR");
@@ -752,12 +769,12 @@ CPLErr GTIFF_CopyFromJPEG(GDALDataset* poDS, GDALDataset* poSrcDS,
 /* -------------------------------------------------------------------- */
 /*      Get raster and block dimensions                                 */
 /* -------------------------------------------------------------------- */
-    int nXSize, nYSize, nBands;
+    int nXSize, nYSize /* , nBands */;
     int nBlockXSize, nBlockYSize;
 
     nXSize = poDS->GetRasterXSize();
     nYSize = poDS->GetRasterYSize();
-    nBands = poDS->GetRasterCount();
+    /* nBands = poDS->GetRasterCount(); */
 
     /* We don't use the GDAL block dimensions because of the split-band */
     /* mechanism that can expose a pseudo one-line-strip whereas the */
diff --git a/frmts/gtiff/libgeotiff/geo_new.c b/frmts/gtiff/libgeotiff/geo_new.c
index f8bb0e1..bcd1a8e 100644
--- a/frmts/gtiff/libgeotiff/geo_new.c
+++ b/frmts/gtiff/libgeotiff/geo_new.c
@@ -215,23 +215,24 @@ static int ReadKey(GTIF* gt, TempKeyData* tempData,
                    KeyEntry* entptr, GeoKey* keyptr)
 {
     int offset,count;
-	
+
     keyptr->gk_key = entptr->ent_key;
     keyptr->gk_count = entptr->ent_count;
     count = entptr->ent_count;
     offset = entptr->ent_val_offset;
     if (gt->gt_keymin > keyptr->gk_key)  gt->gt_keymin=keyptr->gk_key;
     if (gt->gt_keymax < keyptr->gk_key)  gt->gt_keymax=keyptr->gk_key;
-	
+
     if (entptr->ent_location)
         keyptr->gk_type = (gt->gt_methods.type)(gt->gt_tif,entptr->ent_location);
     else
         keyptr->gk_type = (gt->gt_methods.type)(gt->gt_tif,GTIFF_GEOKEYDIRECTORY);
-	  
+
     switch (entptr->ent_location)
     {
         case GTIFF_LOCAL:
             /* store value into data value */
+            /* TODO: Fix strict-aliasing issue. */
             *(pinfo_t *)(&keyptr->gk_data) = entptr->ent_val_offset;
             break;
         case GTIFF_GEOKEYDIRECTORY:
diff --git a/frmts/gtiff/libgeotiff/geo_print.c b/frmts/gtiff/libgeotiff/geo_print.c
index 6c7f37f..0a00fc4 100644
--- a/frmts/gtiff/libgeotiff/geo_print.c
+++ b/frmts/gtiff/libgeotiff/geo_print.c
@@ -475,11 +475,11 @@ static int ReadKey(GTIF *gt, GTIFReadMethod scan, void *aux)
                     vptr = message;
                 }
             }
-            GTIFKeySet(gt,key,ktype,outcount,sptr);			
+            GTIFKeySet(gt,key,ktype,outcount,sptr);
         }
         break;
-        
-      default: 
+
+      default:
         return -1;
     }
     return 1;
@@ -488,7 +488,10 @@ static int ReadKey(GTIF *gt, GTIFReadMethod scan, void *aux)
 
 static void DefaultRead(char *string, void *aux)
 {
-	/* Pretty boring */
-	fscanf((FILE *)aux,"%[^\n]\n",string);
+    /* Pretty boring */
+    int num_read;
+    num_read = fscanf((FILE *)aux, "%[^\n]\n", string);
+    if (num_read != 0) {
+      fprintf(stderr, "geo_print.c DefaultRead failed to read anything.\n");
+    }
 }
-
diff --git a/frmts/gtiff/libtiff/tif_dir.c b/frmts/gtiff/libtiff/tif_dir.c
index acff7b8..17bf878 100644
--- a/frmts/gtiff/libtiff/tif_dir.c
+++ b/frmts/gtiff/libtiff/tif_dir.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dir.c,v 1.116 2013-11-30 20:24:36 fwarmerdam Exp $ */
+/* $Id: tif_dir.c,v 1.119 2014-12-27 15:20:42 erouault Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -160,10 +160,12 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
 	TIFFDirectory* td = &tif->tif_dir;
 	int status = 1;
 	uint32 v32, i, v;
+    double dblval;
 	char* s;
 	const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
 	uint32 standard_tag = tag;
-
+	if( fip == NULL ) /* cannot happen since OkToChangeTag() already checks it */
+	    return 0;
 	/*
 	 * We want to force the custom code to be used for custom
 	 * fields even if the tag happens to match a well known 
@@ -283,10 +285,16 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
 			setDoubleArrayOneValue(&td->td_smaxsamplevalue, va_arg(ap, double), td->td_samplesperpixel);
 		break;
 	case TIFFTAG_XRESOLUTION:
-		td->td_xresolution = (float) va_arg(ap, double);
+        dblval = va_arg(ap, double);
+        if( dblval < 0 )
+            goto badvaluedouble;
+		td->td_xresolution = (float) dblval;
 		break;
 	case TIFFTAG_YRESOLUTION:
-		td->td_yresolution = (float) va_arg(ap, double);
+        dblval = va_arg(ap, double);
+        if( dblval < 0 )
+            goto badvaluedouble;
+		td->td_yresolution = (float) dblval;
 		break;
 	case TIFFTAG_PLANARCONFIG:
 		v = (uint16) va_arg(ap, uint16_vap);
@@ -449,11 +457,11 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
 		 * happens, for example, when tiffcp is used to convert between
 		 * compression schemes and codec-specific tags are blindly copied.
 		 */
-		if(fip == NULL || fip->field_bit != FIELD_CUSTOM) {
+		if(fip->field_bit != FIELD_CUSTOM) {
 			TIFFErrorExt(tif->tif_clientdata, module,
 			    "%s: Invalid %stag \"%s\" (not supported by codec)",
 			    tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
-			    fip ? fip->field_name : "Unknown");
+			    fip->field_name);
 			status = 0;
 			break;
 		}
@@ -693,6 +701,16 @@ badvalue32:
 		va_end(ap);
         }
 	return (0);
+badvaluedouble:
+        {
+        const TIFFField* fip=TIFFFieldWithTag(tif,tag);
+        TIFFErrorExt(tif->tif_clientdata, module,
+             "%s: Bad value %f for \"%s\" tag",
+             tif->tif_name, dblval,
+             fip ? fip->field_name : "Unknown");
+        va_end(ap);
+        }
+    return (0);
 }
 
 /*
@@ -809,6 +827,8 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
 	int ret_val = 1;
 	uint32 standard_tag = tag;
 	const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
+	if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */
+	    return 0;
 	
 	/*
 	 * We want to force the custom code to be used for custom
@@ -1006,14 +1026,14 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
 				 * get a tag that is not valid for the image's
 				 * codec then we'll arrive here.
 				 */
-				if( fip == NULL || fip->field_bit != FIELD_CUSTOM )
+				if( fip->field_bit != FIELD_CUSTOM )
 				{
 					TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
 					    "%s: Invalid %stag \"%s\" "
 					    "(not supported by codec)",
 					    tif->tif_name,
 					    isPseudoTag(tag) ? "pseudo-" : "",
-					    fip ? fip->field_name : "Unknown");
+					    fip->field_name);
 					ret_val = 0;
 					break;
 				}
@@ -1302,8 +1322,20 @@ TIFFDefaultDirectory(TIFF* tif)
 	tif->tif_tagmethods.printdir = NULL;
 	/*
 	 *  Give client code a chance to install their own
-	 *  tag extensions & methods, prior to compression overloads.
+	 *  tag extensions & methods, prior to compression overloads,
+	 *  but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054)
 	 */
+	if (tif->tif_nfieldscompat > 0) {
+		uint32 i;
+
+		for (i = 0; i < tif->tif_nfieldscompat; i++) {
+				if (tif->tif_fieldscompat[i].allocated_size)
+						_TIFFfree(tif->tif_fieldscompat[i].fields);
+		}
+		_TIFFfree(tif->tif_fieldscompat);
+		tif->tif_nfieldscompat = 0;
+		tif->tif_fieldscompat = NULL;
+	}
 	if (_TIFFextender)
 		(*_TIFFextender)(tif);
 	(void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
diff --git a/frmts/gtiff/libtiff/tif_dirinfo.c b/frmts/gtiff/libtiff/tif_dirinfo.c
index 4dae5e5..7db4bdb 100644
--- a/frmts/gtiff/libtiff/tif_dirinfo.c
+++ b/frmts/gtiff/libtiff/tif_dirinfo.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirinfo.c,v 1.118 2013-05-02 14:44:29 tgl Exp $ */
+/* $Id: tif_dirinfo.c,v 1.121 2014-05-07 01:58:46 bfriesen Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -128,6 +128,8 @@ tiffFields[] = {
 	{ TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL },
 	{ TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL },
 	{ TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL },
+	{ TIFFTAG_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED,	FIELD_CUSTOM, 0,	0,	"CFARepeatPatternDim", NULL },
+	{ TIFFTAG_CFAPATTERN,	4, 4,	TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0,	0,	"CFAPattern" , NULL},
 	{ TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL },
 	/* end Pixar tags */
 	{ TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL },
@@ -193,19 +195,19 @@ tiffFields[] = {
 	{ TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL},
 	/* end DNG tags */
 	/* begin TIFF/FX tags */
-    { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Indexed" },
-    { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GlobalParametersIFD", NULL },
-    { TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ProfileType", NULL },
-    { TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "FaxProfile", NULL },
-    { TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CodingMethods", NULL },
-    { TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "VersionYear", NULL },
-    { TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ModeNumber", NULL },
-    { TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Decode", NULL },
-    { TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ImageBaseColor", NULL },
-    { TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "T82Options", NULL },
-    { TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "StripRowCounts", NULL },
-    { TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ImageLayer", NULL },
-	/* end DNG tags */
+        { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Indexed", NULL },
+        { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GlobalParametersIFD", NULL },
+        { TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ProfileType", NULL },
+        { TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "FaxProfile", NULL },
+        { TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CodingMethods", NULL },
+        { TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "VersionYear", NULL },
+        { TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ModeNumber", NULL },
+        { TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Decode", NULL },
+        { TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ImageBaseColor", NULL },
+        { TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "T82Options", NULL },
+        { TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "StripRowCounts", NULL },
+        { TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ImageLayer", NULL },
+	/* end TIFF/FX tags */
 	/* begin pseudo tags */
 };
 
diff --git a/frmts/gtiff/libtiff/tif_dirread.c b/frmts/gtiff/libtiff/tif_dirread.c
index 19a26e2..7835a7c 100644
--- a/frmts/gtiff/libtiff/tif_dirread.c
+++ b/frmts/gtiff/libtiff/tif_dirread.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirread.c,v 1.178 2012-08-19 16:56:34 bfriesen Exp $ */
+/* $Id: tif_dirread.c,v 1.183 2015-01-03 18:03:40 erouault Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -3374,7 +3374,7 @@ static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, c
 	} else {
 		switch (err) {
 			case TIFFReadDirEntryErrCount:
-				TIFFErrorExt(tif->tif_clientdata, module,
+				TIFFWarningExt(tif->tif_clientdata, module,
 				"Incorrect count for \"%s\"; tag ignored",
 					     tagname);
 				break;
@@ -3430,6 +3430,8 @@ TIFFReadDirectory(TIFF* tif)
 	const TIFFField* fip;
 	uint32 fii=FAILED_FII;
         toff_t nextdiroff;
+    int bitspersample_read = FALSE;
+
 	tif->tif_diroff=tif->tif_nextdiroff;
 	if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff))
 		return 0;           /* last offset or bad offset (IFD looping) */
@@ -3706,6 +3708,8 @@ TIFFReadDirectory(TIFF* tif)
 					}
 					if (!TIFFSetField(tif,dp->tdir_tag,value))
 						goto bad;
+                    if( dp->tdir_tag == TIFFTAG_BITSPERSAMPLE )
+                        bitspersample_read = TRUE;
 				}
 				break;
 			case TIFFTAG_SMINSAMPLEVALUE:
@@ -3763,6 +3767,19 @@ TIFFReadDirectory(TIFF* tif)
 					uint32 countrequired;
 					uint32 incrementpersample;
 					uint16* value=NULL;
+                    /* It would be dangerous to instanciate those tag values */
+                    /* since if td_bitspersample has not yet been read (due to */
+                    /* unordered tags), it could be read afterwards with a */
+                    /* values greater than the default one (1), which may cause */
+                    /* crashes in user code */
+                    if( !bitspersample_read )
+                    {
+                        fip = TIFFFieldWithTag(tif,dp->tdir_tag);
+                        TIFFWarningExt(tif->tif_clientdata,module,
+                                       "Ignoring %s since BitsPerSample tag not found",
+                                       fip ? fip->field_name : "unknown tagname");
+                        continue;
+                    }
 					countpersample=(1L<<tif->tif_dir.td_bitspersample);
 					if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample))
 					{
@@ -4278,7 +4295,8 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
 	TIFFDirectory *td = &tif->tif_dir;
 	uint32 strip;
 
-    _TIFFFillStriles( tif );
+    if( !_TIFFFillStriles( tif ) )
+        return -1;
 
 	if (td->td_stripbytecount)
 		_TIFFfree(td->td_stripbytecount);
@@ -4377,6 +4395,11 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff)
 
 	if (diroff == 0)			/* no more directories */
 		return 0;
+	if (tif->tif_dirnumber == 65535) {
+	    TIFFErrorExt(tif->tif_clientdata, "TIFFCheckDirOffset",
+			 "Cannot handle more than 65535 TIFF directories");
+	    return 0;
+	}
 
 	for (n = 0; n < tif->tif_dirnumber && tif->tif_dirlist; n++) {
 		if (tif->tif_dirlist[n] == diroff)
@@ -4396,7 +4419,10 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff)
 		    tif->tif_dirnumber, 2 * sizeof(uint64), "for IFD list");
 		if (!new_dirlist)
 			return 0;
-		tif->tif_dirlistsize = 2 * tif->tif_dirnumber;
+		if( tif->tif_dirnumber >= 32768 )
+		    tif->tif_dirlistsize = 65535;
+		else
+		    tif->tif_dirlistsize = 2 * tif->tif_dirnumber;
 		tif->tif_dirlist = new_dirlist;
 	}
 
@@ -4708,6 +4734,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
             return 0;
         }
 	fip=tif->tif_fields[fii];
+	assert(fip != NULL); /* should not happen */
 	assert(fip->set_field_type!=TIFF_SETGET_OTHER);  /* if so, we shouldn't arrive here but deal with this in specialized code */
 	assert(fip->set_field_type!=TIFF_SETGET_INT);    /* if so, we shouldn't arrive here as this is only the case for pseudo-tags */
 	err=TIFFReadDirEntryErrOk;
@@ -5355,7 +5382,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
 	}
 	if (err!=TIFFReadDirEntryErrOk)
 	{
-		TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",recover);
+		TIFFReadDirEntryOutputErr(tif,err,module,fip->field_name,recover);
 		return(0);
 	}
 	return(1);
diff --git a/frmts/gtiff/libtiff/tif_getimage.c b/frmts/gtiff/libtiff/tif_getimage.c
index a85273c..a856cc5 100644
--- a/frmts/gtiff/libtiff/tif_getimage.c
+++ b/frmts/gtiff/libtiff/tif_getimage.c
@@ -1,4 +1,4 @@
-/* $Id: tif_getimage.c,v 1.82 2012-06-06 00:17:49 fwarmerdam Exp $ */
+/* $Id: tif_getimage.c,v 1.87 2014-12-29 18:28:46 erouault Exp $ */
 
 /*
  * Copyright (c) 1991-1997 Sam Leffler
@@ -182,8 +182,23 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
 				    "Planarconfiguration", td->td_planarconfig);
 				return (0);
 			}
+			if( td->td_samplesperpixel != 3 )
+            {
+                sprintf(emsg,
+                        "Sorry, can not handle image with %s=%d",
+                        "Samples/pixel", td->td_samplesperpixel);
+                return 0;
+            }
 			break;
 		case PHOTOMETRIC_CIELAB:
+            if( td->td_samplesperpixel != 3 || td->td_bitspersample != 8 )
+            {
+                sprintf(emsg,
+                        "Sorry, can not handle image with %s=%d and %s=%d",
+                        "Samples/pixel", td->td_samplesperpixel,
+                        "Bits/sample", td->td_bitspersample);
+                return 0;
+            }
 			break;
 		default:
 			sprintf(emsg, "Sorry, can not handle image with %s=%d",
@@ -842,6 +857,12 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
 	int32 fromskew, toskew;
 	int ret = 1, flip;
 
+	TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver);
+	if( subsamplingver == 0 ) {
+		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Invalid vertical YCbCr subsampling");
+		return (0);
+	}
+
 	buf = (unsigned char*) _TIFFmalloc(TIFFStripSize(tif));
 	if (buf == 0) {
 		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for strip buffer");
@@ -859,7 +880,7 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
 	}
 
 	TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
-	TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver);
+
 	scanline = TIFFScanlineSize(tif);
 	fromskew = (w < imagewidth ? imagewidth - w : 0);
 	for (row = 0; row < h; row += nrow)
@@ -1852,7 +1873,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
 
     (void) y;
     fromskew = (fromskew * 10) / 4;
-    if ((h & 3) == 0 && (w & 1) == 0) {
+    if ((w & 3) == 0 && (h & 1) == 0) {
         for (; h >= 2; h -= 2) {
             x = w>>2;
             do {
@@ -1929,7 +1950,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
     /* XXX adjust fromskew */
     do {
 	x = w>>2;
-	do {
+	while(x>0) {
 	    int32 Cb = pp[4];
 	    int32 Cr = pp[5];
 
@@ -1940,7 +1961,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
 
 	    cp += 4;
 	    pp += 6;
-	} while (--x);
+		x--;
+	}
 
         if( (w&3) != 0 )
         {
@@ -2031,7 +2053,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
 	fromskew = (fromskew * 4) / 2;
 	do {
 		x = w>>1;
-		do {
+		while(x>0) {
 			int32 Cb = pp[2];
 			int32 Cr = pp[3];
 
@@ -2040,7 +2062,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
 
 			cp += 2;
 			pp += 4;
-		} while (--x);
+			x --;
+		}
 
 		if( (w&1) != 0 )
 		{
@@ -2541,7 +2564,7 @@ PickContigCase(TIFFRGBAImage* img)
 					 * must always be <= horizontal subsampling; so
 					 * there are only a few possibilities and we just
 					 * enumerate the cases.
-					 * Joris: added support for the [1,2] case, nonetheless, to accomodate
+					 * Joris: added support for the [1,2] case, nonetheless, to accommodate
 					 * some OJPEG files
 					 */
 					uint16 SubsamplingHor;
diff --git a/frmts/gtiff/libtiff/tif_lzw.c b/frmts/gtiff/libtiff/tif_lzw.c
index fd9c7a0..b81bc71 100644
--- a/frmts/gtiff/libtiff/tif_lzw.c
+++ b/frmts/gtiff/libtiff/tif_lzw.c
@@ -1,4 +1,4 @@
-/* $Id: tif_lzw.c,v 1.45 2011-04-02 20:54:09 bfriesen Exp $ */
+/* $Id: tif_lzw.c,v 1.46 2014-11-20 16:47:21 erouault Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -268,6 +268,8 @@ LZWPreDecode(TIFF* tif, uint16 s)
 	if( sp->dec_codetab == NULL )
         {
             tif->tif_setupdecode( tif );
+	    if( sp->dec_codetab == NULL )
+		return (0);
         }
 
 	/*
diff --git a/frmts/gtiff/libtiff/tif_next.c b/frmts/gtiff/libtiff/tif_next.c
index 524e127..17e0311 100644
--- a/frmts/gtiff/libtiff/tif_next.c
+++ b/frmts/gtiff/libtiff/tif_next.c
@@ -1,4 +1,4 @@
-/* $Id: tif_next.c,v 1.13 2010-03-10 18:56:48 bfriesen Exp $ */
+/* $Id: tif_next.c,v 1.16 2014-12-29 12:09:11 erouault Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -71,7 +71,7 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
 		TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
 		return (0);
 	}
-	for (row = buf; occ > 0; occ -= scanline, row += scanline) {
+	for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {
 		n = *bp++, cc--;
 		switch (n) {
 		case LITERALROW:
@@ -90,6 +90,8 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
 			 * The scanline has a literal span that begins at some
 			 * offset.
 			 */
+			if( cc < 4 )
+				goto bad;
 			off = (bp[0] * 256) + bp[1];
 			n = (bp[2] * 256) + bp[3];
 			if (cc < 4+n || off+n > scanline)
@@ -102,6 +104,8 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
 		default: {
 			uint32 npixels = 0, grey;
 			uint32 imagewidth = tif->tif_dir.td_imagewidth;
+            if( isTiled(tif) )
+                imagewidth = tif->tif_dir.td_tilewidth;
 
 			/*
 			 * The scanline is composed of a sequence of constant
@@ -139,10 +143,27 @@ bad:
 	return (0);
 }
 
+static int
+NeXTPreDecode(TIFF* tif, uint16 s)
+{
+	static const char module[] = "NeXTPreDecode";
+	TIFFDirectory *td = &tif->tif_dir;
+	(void)s;
+
+	if( td->td_bitspersample != 2 )
+	{
+		TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d",
+					 td->td_bitspersample);
+		return (0);
+	}
+	return (1);
+}
+	
 int
 TIFFInitNeXT(TIFF* tif, int scheme)
 {
 	(void) scheme;
+	tif->tif_predecode = NeXTPreDecode;  
 	tif->tif_decoderow = NeXTDecode;  
 	tif->tif_decodestrip = NeXTDecode;  
 	tif->tif_decodetile = NeXTDecode;
diff --git a/frmts/gtiff/libtiff/tif_ojpeg.c b/frmts/gtiff/libtiff/tif_ojpeg.c
index 6ea3c38..61f4221 100644
--- a/frmts/gtiff/libtiff/tif_ojpeg.c
+++ b/frmts/gtiff/libtiff/tif_ojpeg.c
@@ -1,4 +1,4 @@
-/* $Id: tif_ojpeg.c,v 1.56 2012-05-24 03:15:18 fwarmerdam Exp $ */
+/* $Id: tif_ojpeg.c,v 1.58 2014-12-25 18:29:11 erouault Exp $ */
 
 /* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0
    specification is now totally obsolete and deprecated for new applications and
@@ -39,7 +39,7 @@
    OF THIS SOFTWARE.
 
    Joris Van Damme and/or AWare Systems may be available for custom
-   developement. If you like what you see, and need anything similar or related,
+   development. If you like what you see, and need anything similar or related,
    contact <info at awaresystems.be>.
 */
 
@@ -141,7 +141,7 @@
  * OJPEG_BUFFER: Define the size of the desired buffer here. Should be small enough so as to guarantee
  * 	instant processing, optimal streaming and optimal use of processor cache, but also big
  * 	enough so as to not result in significant call overhead. It should be at least a few
- * 	bytes to accomodate some structures (this is verified in asserts), but it would not be
+ * 	bytes to accommodate some structures (this is verified in asserts), but it would not be
  * 	sensible to make it this small anyway, and it should be at most 64K since it is indexed
  * 	with uint16. We recommend 2K.
  * EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has
@@ -528,6 +528,8 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap)
 	uint32 ma;
 	uint64* mb;
 	uint32 n;
+	const TIFFField* fip;
+
 	switch(tag)
 	{
 		case TIFFTAG_JPEGIFOFFSET:
@@ -597,7 +599,10 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap)
 		default:
 			return (*sp->vsetparent)(tif,tag,ap);
 	}
-	TIFFSetFieldBit(tif,TIFFFieldWithTag(tif,tag)->field_bit);
+	fip = TIFFFieldWithTag(tif,tag);
+	if( fip == NULL ) /* shouldn't happen */
+	    return(0);
+	TIFFSetFieldBit(tif,fip->field_bit);
 	tif->tif_flags|=TIFF_DIRTYDIRECT;
 	return(1);
 }
diff --git a/frmts/gtiff/libtiff/tif_read.c b/frmts/gtiff/libtiff/tif_read.c
index acca0b8..b009519 100644
--- a/frmts/gtiff/libtiff/tif_read.c
+++ b/frmts/gtiff/libtiff/tif_read.c
@@ -1,4 +1,4 @@
-/* $Id: tif_read.c,v 1.42 2013-01-18 21:37:13 fwarmerdam Exp $ */
+/* $Id: tif_read.c,v 1.44 2014-12-23 10:15:35 erouault Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -458,7 +458,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
 		return ((tmsize_t)(-1));
 	}
 	bytecount = td->td_stripbytecount[strip];
-	if (bytecount <= 0) {
+	if ((int64)bytecount <= 0) {
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
 		TIFFErrorExt(tif->tif_clientdata, module,
 			     "%I64u: Invalid strip byte count, strip %lu",
@@ -498,7 +498,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
 	if ((tif->tif_flags&TIFF_NOREADRAW)==0)
 	{
 		uint64 bytecount = td->td_stripbytecount[strip];
-		if (bytecount <= 0) {
+		if ((int64)bytecount <= 0) {
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
 			TIFFErrorExt(tif->tif_clientdata, module,
 				"Invalid strip byte count %I64u, strip %lu",
@@ -801,7 +801,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
 	if ((tif->tif_flags&TIFF_NOREADRAW)==0)
 	{
 		uint64 bytecount = td->td_stripbytecount[tile];
-		if (bytecount <= 0) {
+		if ((int64)bytecount <= 0) {
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
 			TIFFErrorExt(tif->tif_clientdata, module,
 				"%I64u: Invalid tile byte count, tile %lu",
@@ -930,8 +930,11 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
 		tif->tif_flags &= ~TIFF_MYBUFFER;
 	} else {
 		tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024);
-		if (tif->tif_rawdatasize==0)
-			tif->tif_rawdatasize=(tmsize_t)(-1);
+		if (tif->tif_rawdatasize==0) {
+		    TIFFErrorExt(tif->tif_clientdata, module,
+				 "Invalid buffer size");
+		    return (0);
+		}
 		tif->tif_rawdata = (uint8*) _TIFFmalloc(tif->tif_rawdatasize);
 		tif->tif_flags |= TIFF_MYBUFFER;
 	}
diff --git a/frmts/gtiff/libtiff/tif_vsi.c b/frmts/gtiff/libtiff/tif_vsi.c
index 72dc100..b7f9da5 100644
--- a/frmts/gtiff/libtiff/tif_vsi.c
+++ b/frmts/gtiff/libtiff/tif_vsi.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: tif_vsi.c 20996 2010-10-28 18:38:15Z rouault $
+ * $Id: tif_vsi.c 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GeoTIFF Driver
  * Purpose:  Implement system hook functions for libtiff on top of CPL/VSI,
@@ -70,7 +70,7 @@ _tiffSizeProc(thandle_t fd)
 
     old_off = VSIFTellL( (VSILFILE *) fd );
     VSIFSeekL( (VSILFILE *) fd, 0, SEEK_END );
-    
+
     file_size = (toff_t) VSIFTellL( (VSILFILE *) fd );
     VSIFSeekL( (VSILFILE *) fd, old_off, SEEK_SET );
 
@@ -94,7 +94,7 @@ _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size)
  * Open a TIFF file descriptor for read/writing.
  */
 TIFF*
-TIFFFdOpen(int fd, const char* name, const char* mode)
+TIFFFdOpen(CPL_UNUSED int fd, CPL_UNUSED const char* name, CPL_UNUSED const char* mode)
 {
 	return NULL;
 }
@@ -126,7 +126,7 @@ TIFFOpen(const char* name, const char* mode)
         }
 
         strcat( access, "b" );
-                    
+
         fp = VSIFOpenL( name, access );
 	if (fp == NULL) {
             if( errno >= 0 )
diff --git a/frmts/gtiff/libtiff/tif_zip.c b/frmts/gtiff/libtiff/tif_zip.c
index f95fd04..22e9f35 100644
--- a/frmts/gtiff/libtiff/tif_zip.c
+++ b/frmts/gtiff/libtiff/tif_zip.c
@@ -1,4 +1,4 @@
-/* $Id: tif_zip.c,v 1.32 2012-10-18 17:34:59 fwarmerdam Exp $ */
+/* $Id: tif_zip.c,v 1.33 2014-12-25 18:29:11 erouault Exp $ */
 
 /*
  * Copyright (c) 1995-1997 Sam Leffler
@@ -36,7 +36,7 @@
  * of the library: this code assumes the 1.0 API and also depends on
  * the ability to write the zlib header multiple times (one per strip)
  * which was not possible with versions prior to 0.95.  Note also that
- * older versions of this codec avoided this bug by supressing the header
+ * older versions of this codec avoided this bug by suppressing the header
  * entirely.  This means that files written with the old library cannot
  * be read; they should be converted to a different compression scheme
  * and then reconverted.
diff --git a/frmts/gtiff/libtiff/tiff.h b/frmts/gtiff/libtiff/tiff.h
index 19b4e79..bc46acd 100644
--- a/frmts/gtiff/libtiff/tiff.h
+++ b/frmts/gtiff/libtiff/tiff.h
@@ -1,4 +1,4 @@
-/* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */
+/* $Id: tiff.h,v 1.69 2014-04-02 17:23:06 fwarmerdam Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -201,6 +201,7 @@ typedef enum {
 #define	    PHOTOMETRIC_CIELAB		8	/* !1976 CIE L*a*b* */
 #define	    PHOTOMETRIC_ICCLAB		9	/* ICC L*a*b* [Adobe TIFF Technote 4] */
 #define	    PHOTOMETRIC_ITULAB		10	/* ITU L*a*b* */
+#define	    PHOTOMETRIC_CFA		32803	/* color filter array */
 #define     PHOTOMETRIC_LOGL		32844	/* CIE Log2(L) */
 #define     PHOTOMETRIC_LOGLUV		32845	/* CIE Log2(L) (u',v') */
 #define	TIFFTAG_THRESHHOLDING		263	/* +thresholding used on data */
@@ -402,6 +403,8 @@ typedef enum {
 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306
 /* tag 33405 is a private tag registered to Eastman Kodak */
 #define TIFFTAG_WRITERSERIALNUMBER      33405   /* device serial number */
+#define TIFFTAG_CFAREPEATPATTERNDIM	33421	/* dimensions of CFA pattern */
+#define TIFFTAG_CFAPATTERN		33422	/* color filter array pattern */
 /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */
 #define	TIFFTAG_COPYRIGHT		33432	/* copyright string */
 /* IPTC TAG from RichTIFF specifications */
diff --git a/frmts/gtiff/libtiff/tiffvers.h b/frmts/gtiff/libtiff/tiffvers.h
index 40edc81..4326145 100644
--- a/frmts/gtiff/libtiff/tiffvers.h
+++ b/frmts/gtiff/libtiff/tiffvers.h
@@ -1,4 +1,4 @@
-#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
+#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3patched\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
 /*
  * This define can be used in code that requires
  * compilation-related definitions specific to a
diff --git a/frmts/hdf4/hdf4dataset.cpp b/frmts/hdf4/hdf4dataset.cpp
index ef1d4ad..b6bc1a6 100644
--- a/frmts/hdf4/hdf4dataset.cpp
+++ b/frmts/hdf4/hdf4dataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: hdf4dataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: hdf4dataset.cpp 28365 2015-01-27 10:39:30Z rouault $
  *
  * Project:  Hierarchical Data Format Release 4 (HDF4)
  * Purpose:  HDF4 Datasets. Open HDF4 file, fetch metadata and list of
@@ -42,7 +42,7 @@
 #include "hdf4compat.h"
 #include "hdf4dataset.h"
 
-CPL_CVSID("$Id: hdf4dataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: hdf4dataset.cpp 28365 2015-01-27 10:39:30Z rouault $");
 
 CPL_C_START
 void	GDALRegister_HDF4(void);
@@ -1245,5 +1245,9 @@ void GDALRegister_HDF4()
 
         GetGDALDriverManager()->RegisterDriver( poDriver );
     }
-}
 
+#ifdef HDF4_PLUGIN
+    GDALRegister_HDF4Image();
+#endif
+
+}
diff --git a/frmts/hdf4/makefile.vc b/frmts/hdf4/makefile.vc
index 84d8f38..7d6a2cd 100644
--- a/frmts/hdf4/makefile.vc
+++ b/frmts/hdf4/makefile.vc
@@ -8,6 +8,11 @@ PLUGIN_DLL 	=	gdal_HDF4.dll
 
 EXTRAFLAGS = 	-I..\pds -I$(HDF4_DIR)\include -Ihdf-eos -DFRMT_hdf4 
 
+!IF "$(HDF4_PLUGIN)" == "YES"
+EXTRAFLAGS = $(EXTRAFLAGS) -DHDF4_PLUGIN
+!ENDIF
+
+
 default:	$(OBJ)
 	xcopy /D  /Y *.obj ..\o
 	cd  hdf-eos
diff --git a/frmts/hdf5/hdf5dataset.cpp b/frmts/hdf5/hdf5dataset.cpp
index f98b0a7..d7e0b15 100644
--- a/frmts/hdf5/hdf5dataset.cpp
+++ b/frmts/hdf5/hdf5dataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: hdf5dataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: hdf5dataset.cpp 28365 2015-01-27 10:39:30Z rouault $
  *
  * Project:  Hierarchical Data Format Release 5 (HDF5)
  * Purpose:  HDF5 Datasets. Open HDF5 file, fetch metadata and list of
@@ -40,7 +40,7 @@
 #include "cpl_string.h"
 #include "hdf5dataset.h"
 
-CPL_CVSID("$Id: hdf5dataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: hdf5dataset.cpp 28365 2015-01-27 10:39:30Z rouault $");
 
 CPL_C_START
 void GDALRegister_HDF5(void);
@@ -75,6 +75,11 @@ void GDALRegister_HDF5()
         poDriver->pfnIdentify = HDF5Dataset::Identify;
         GetGDALDriverManager()->RegisterDriver(poDriver);
     }
+
+#ifdef HDF5_PLUGIN
+    GDALRegister_HDF5Image();
+#endif
+
 }
 
 /************************************************************************/
diff --git a/frmts/hdf5/hdf5imagedataset.cpp b/frmts/hdf5/hdf5imagedataset.cpp
index a107622..132cc7e 100644
--- a/frmts/hdf5/hdf5imagedataset.cpp
+++ b/frmts/hdf5/hdf5imagedataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: hdf5imagedataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: hdf5imagedataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  Hierarchical Data Format Release 5 (HDF5)
  * Purpose:  Read subdatasets of HDF5 file.
@@ -38,7 +38,7 @@
 #include "hdf5dataset.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: hdf5imagedataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: hdf5imagedataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void GDALRegister_HDF5Image(void);
@@ -304,12 +304,12 @@ HDF5ImageRasterBand::HDF5ImageRasterBand( HDF5ImageDataset *poDS, int nBand,
         if(H5Pget_layout(listid) == H5D_CHUNKED)
         {
             hsize_t panChunkDims[3];
-            int nDimSize = H5Pget_chunk(listid, 3, panChunkDims);
+            CPL_UNUSED int nDimSize = H5Pget_chunk(listid, 3, panChunkDims);
             CPLAssert(nDimSize == poDS->ndims);
             nBlockXSize   = (int) panChunkDims[poDS->GetXIndex()];
             nBlockYSize   = (int) panChunkDims[poDS->GetYIndex()];
         }
-        
+
         H5Pclose(listid);
     }
 
@@ -756,11 +756,11 @@ CPLErr HDF5ImageDataset::CreateProjections()
             if(EQUALN(osMissionLevel,"GTC",3))
                 productType  = PROD_CSK_L1D;
         }
-            
+
         CaptureCSKGeoTransform(productType);
         CaptureCSKGeolocation(productType);
         CaptureCSKGCPs(productType);
-        
+
         break;
     }
     case UNKNOWN_PRODUCT:
@@ -770,8 +770,8 @@ CPLErr HDF5ImageDataset::CreateProjections()
 
     hid_t LatitudeDatasetID  = -1;
     hid_t LongitudeDatasetID = -1;
-    hid_t LatitudeDataspaceID;
-    hid_t LongitudeDataspaceID;
+    // hid_t LatitudeDataspaceID;
+    // hid_t LongitudeDataspaceID;
     float* Latitude;
     float* Longitude;
     int    i,j;
@@ -805,11 +805,11 @@ CPLErr HDF5ImageDataset::CreateProjections()
     /*      Retrieve HDF5 data information                                  */
     /* -------------------------------------------------------------------- */
     LatitudeDatasetID   = H5Dopen( hHDF5,poH5Objects->pszPath );
-    LatitudeDataspaceID = H5Dget_space( dataset_id );
+    // LatitudeDataspaceID = H5Dget_space( dataset_id );
 
     poH5Objects=HDF5FindDatasetObjects( poH5RootGroup, "Longitude" );
     LongitudeDatasetID   = H5Dopen( hHDF5,poH5Objects->pszPath );
-    LongitudeDataspaceID = H5Dget_space( dataset_id );
+    // LongitudeDataspaceID = H5Dget_space( dataset_id );
 
     if( ( LatitudeDatasetID > 0 ) && ( LongitudeDatasetID > 0) ) {
 
@@ -1257,4 +1257,3 @@ void HDF5ImageDataset::CaptureCSKGCPs(int iProductType)
         }
     }
 }
-
diff --git a/frmts/hdf5/makefile.vc b/frmts/hdf5/makefile.vc
index b4435c5..e2e695d 100644
--- a/frmts/hdf5/makefile.vc
+++ b/frmts/hdf5/makefile.vc
@@ -9,6 +9,11 @@ PLUGIN_DLL 	=	gdal_HDF5.dll
 
 EXTRAFLAGS 	= 	-I$(HDF5_DIR)\include -DWIN32 -D_HDF5USEDLL_ 
 
+!IF "$(HDF5_PLUGIN)" == "YES"
+EXTRAFLAGS = $(EXTRAFLAGS) -DHDF5_PLUGIN
+!ENDIF
+
+
 default:	$(OBJ)
 	$(INSTALL) *.obj ..\o
 
diff --git a/frmts/hfa/hfaband.cpp b/frmts/hfa/hfaband.cpp
index 322b55f..b6db31d 100644
--- a/frmts/hfa/hfaband.cpp
+++ b/frmts/hfa/hfaband.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: hfaband.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: hfaband.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  Erdas Imagine (.img) Translator
  * Purpose:  Implementation of the HFABand, for accessing one Eimg_Layer.
@@ -33,7 +33,7 @@
 
 /* include the compression code */
 
-CPL_CVSID("$Id: hfaband.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: hfaband.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 /************************************************************************/
 /*                              HFABand()                               */
@@ -703,7 +703,7 @@ static CPLErr UncompressBlock( GByte *pabyCData, int nSrcBytes,
                  nNumRuns, nDataOffset);
         return CE_Failure;
     }
-    
+
     if (nNumBits > INT_MAX / nNumRuns ||
         nNumBits * nNumRuns > INT_MAX - 7 ||
         (nNumBits * nNumRuns + 7)/8 > INT_MAX - nDataOffset)
diff --git a/frmts/hfa/hfaopen.cpp b/frmts/hfa/hfaopen.cpp
index ad0ac9d..86a9fd1 100644
--- a/frmts/hfa/hfaopen.cpp
+++ b/frmts/hfa/hfaopen.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: hfaopen.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: hfaopen.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  Erdas Imagine (.img) Translator
  * Purpose:  Supporting functions for HFA (.img) ... main (C callable) API
@@ -42,7 +42,7 @@
 #include <limits.h>
 #include <vector>
 
-CPL_CVSID("$Id: hfaopen.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: hfaopen.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 
 static const char *apszAuxMetadataItems[] = {
@@ -3061,12 +3061,12 @@ int HFACreateSpillStack( HFAInfo_t *psInfo, int nXSize, int nYSize,
         fpVSIL = VSIFOpenL( pszFullFilename, "w+" );
         if( fpVSIL == NULL )
         {
-            CPLError( CE_Failure, CPLE_OpenFailed, 
+            CPLError( CE_Failure, CPLE_OpenFailed,
                       "Failed to create spill file %s.\n%s",
                       psInfo->pszIGEFilename, VSIStrerror( errno ) );
             return FALSE;
         }
-        
+
         VSIFWriteL( (void *) pszMagick, 1, strlen(pszMagick)+1, fpVSIL );
     }
 
@@ -3075,18 +3075,18 @@ int HFACreateSpillStack( HFAInfo_t *psInfo, int nXSize, int nYSize,
 /* -------------------------------------------------------------------- */
 /*      Work out some details about the tiling scheme.                  */
 /* -------------------------------------------------------------------- */
-    int	nBlocksPerRow, nBlocksPerColumn, nBlocks, nBytesPerBlock;
-    int	nBytesPerRow, nBlockMapSize, iFlagsSize;
+    int	nBlocksPerRow, nBlocksPerColumn, /* nBlocks, */ nBytesPerBlock;
+    int	nBytesPerRow, nBlockMapSize /* , iFlagsSize */;
 
     nBlocksPerRow = (nXSize + nBlockSize - 1) / nBlockSize;
     nBlocksPerColumn = (nYSize + nBlockSize - 1) / nBlockSize;
-    nBlocks = nBlocksPerRow * nBlocksPerColumn;
+    /* nBlocks = nBlocksPerRow * nBlocksPerColumn; */
     nBytesPerBlock = (nBlockSize * nBlockSize
                       * HFAGetDataTypeBits(nDataType) + 7) / 8;
 
     nBytesPerRow = ( nBlocksPerRow + 7 ) / 8;
     nBlockMapSize = nBytesPerRow * nBlocksPerColumn;
-    iFlagsSize = nBlockMapSize + 20;
+    /* iFlagsSize = nBlockMapSize + 20; */
 
 /* -------------------------------------------------------------------- */
 /*      Write stack prefix information.                                 */
diff --git a/frmts/hfa/hfatype.cpp b/frmts/hfa/hfatype.cpp
index 08a89a5..172f3b4 100644
--- a/frmts/hfa/hfatype.cpp
+++ b/frmts/hfa/hfatype.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: hfatype.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: hfatype.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  Erdas Imagine (.img) Translator
  * Purpose:  Implementation of the HFAType class, for managing one type
@@ -31,7 +31,7 @@
 
 #include "hfa_p.h"
 
-CPL_CVSID("$Id: hfatype.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: hfatype.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 /************************************************************************/
 /* ==================================================================== */
@@ -288,7 +288,8 @@ HFAType::GetInstCount( const char * pszFieldPath,
                        GByte *pabyData, CPL_UNUSED GUInt32 nDataOffset, int nDataSize )
 
 {
-    int		nArrayIndex = 0, nNameLen, iField, nByteOffset;
+    /* int		nArrayIndex = 0; */
+    int		nNameLen, iField, nByteOffset;
     const char	*pszRemainder;
 
 /* -------------------------------------------------------------------- */
@@ -298,8 +299,8 @@ HFAType::GetInstCount( const char * pszFieldPath,
     if( strchr(pszFieldPath,'[') != NULL )
     {
         const char	*pszEnd = strchr(pszFieldPath,'[');
-        
-        nArrayIndex = atoi(pszEnd+1);
+
+        /* nArrayIndex = atoi(pszEnd+1); */
         nNameLen = pszEnd - pszFieldPath;
 
         pszRemainder = strchr(pszFieldPath,'.');
@@ -310,7 +311,7 @@ HFAType::GetInstCount( const char * pszFieldPath,
     else if( strchr(pszFieldPath,'.') != NULL )
     {
         const char	*pszEnd = strchr(pszFieldPath,'.');
-        
+
         nNameLen = pszEnd - pszFieldPath;
 
         pszRemainder = pszEnd + 1;
@@ -321,7 +322,7 @@ HFAType::GetInstCount( const char * pszFieldPath,
         nNameLen = strlen(pszFieldPath);
         pszRemainder = NULL;
     }
-    
+
 /* -------------------------------------------------------------------- */
 /*      Find this field within this type, if possible.                  */
 /* -------------------------------------------------------------------- */
diff --git a/frmts/ilwis/ilwiscoordinatesystem.cpp b/frmts/ilwis/ilwiscoordinatesystem.cpp
index 318aaa2..3f6696b 100644
--- a/frmts/ilwis/ilwiscoordinatesystem.cpp
+++ b/frmts/ilwis/ilwiscoordinatesystem.cpp
@@ -53,10 +53,10 @@ bool WriteElement(string sSection, string sEntry, string fn, double dValue);
 
 static const IlwisDatums iwDatums[] =
 {
-    { "Adindan", "Adindan", 4201 },								
-    { "Afgooye", "Afgooye", 4205 },								
+    { "Adindan", "Adindan", 4201 },
+    { "Afgooye", "Afgooye", 4205 },
 		//AGREF --- skipped
-    { "Ain el Abd 1970", "Ain_el_Abd_1970", 4204 },				
+    { "Ain el Abd 1970", "Ain_el_Abd_1970", 4204 },
 		{ "American Samoa 1962", "American_Samoa_1962", 4169 },    
 		//Anna 1 Astro 1965 --- skipped
 		{ "Antigua Island Astro 1943", "Antigua_1943", 4601 },    
@@ -192,44 +192,44 @@ static const IlwisDatums iwDatums[] =
 
 static const IlwisEllips iwEllips[] =
 {
-    { "Sphere", 7035, 6371007, 0.0  },	//rad 6370997 m (normal sphere)   
-    { "Airy 1830", 7031, 6377563.396, 299.3249646 },   
-    { "Modified Airy", 7002, 6377340.189, 299.3249646 },   
-    { "ATS77", 7204, 6378135.0, 298.257000006 },   
-    { "Australian National", 7003, 6378160, 298.249997276 },   
-    { "Bessel 1841", 7042, 6377397.155, 299.1528128},   
-		{ "Bessel 1841 (Japan By Law)", 7046 , 6377397.155, 299.152815351 }, 
-    { "Bessel 1841 (Namibia)", 7006, 6377483.865, 299.1528128 },   
-    { "Clarke 1866", 7008, 6378206.4, 294.9786982 },   
-    { "Clarke 1880", 7034, 6378249.145, 293.465 },   
-    { "Clarke 1880 (IGN)", 7011, 6378249.2, 293.466  },   
+    { "Sphere", 7035, 6371007, 0.0  },	//rad 6370997 m (normal sphere)
+    { "Airy 1830", 7031, 6377563.396, 299.3249646 },
+    { "Modified Airy", 7002, 6377340.189, 299.3249646 },
+    { "ATS77", 7204, 6378135.0, 298.257000006 },
+    { "Australian National", 7003, 6378160, 298.249997276 },
+    { "Bessel 1841", 7042, 6377397.155, 299.1528128},
+		{ "Bessel 1841 (Japan By Law)", 7046 , 6377397.155, 299.152815351 },
+    { "Bessel 1841 (Namibia)", 7006, 6377483.865, 299.1528128 },
+    { "Clarke 1866", 7008, 6378206.4, 294.9786982 },
+    { "Clarke 1880", 7034, 6378249.145, 293.465 },
+    { "Clarke 1880 (IGN)", 7011, 6378249.2, 293.466 },
     // FIXME: D-PAF (Orbits) --- skipped
     // FIXME: Du Plessis Modified --- skipped
     // FIXME: Du Plessis Reconstituted --- skipped
     { "Everest (India 1830)", 7015, 6377276.345, 300.8017 },
     // Everest (India 1956) --- skipped
 		// Everest (Malaysia 1969) --- skipped
-    { "Everest (E. Malaysia and Brunei)", 7016, 6377298.556, 300.8017 },   
-    { "Everest (Malay. and Singapore 1948)", 7018, 6377304.063, 300.8017 },   
-		{ "Everest (Pakistan)", 7044, 6377309.613, 300.8017 }, 
+    { "Everest (E. Malaysia and Brunei)", 7016, 6377298.556, 300.8017 },
+    { "Everest (Malay. and Singapore 1948)", 7018, 6377304.063, 300.8017 },
+		{ "Everest (Pakistan)", 7044, 6377309.613, 300.8017 },
 		// Everest (Sabah Sarawak) --- skipped
 		// Fischer 1960 --- skipped
 		// Fischer 1960 (Modified) --- skipped
 		// Fischer 1968 --- skipped
-		{ "GRS 80", 7019, 6378137, 298.257222101  },   
-		{ "Helmert 1906", 7020, 6378200, 298.3 }, 
+		{ "GRS 80", 7019, 6378137, 298.257222101  },
+		{ "Helmert 1906", 7020, 6378200, 298.3 },
 		// Hough 1960 --- skipped
-		{ "Indonesian 1974", 7021, 6378160, 298.247 }, 
-		{ "International 1924", 7022, 6378388, 297 }, 
-		{ "Krassovsky 1940", 7024, 6378245, 298.3 }, 
+		{ "Indonesian 1974", 7021, 6378160, 298.247 },
+		{ "International 1924", 7022, 6378388, 297 },
+		{ "Krassovsky 1940", 7024, 6378245, 298.3 },
 		// New_International 1967
-		// SGS 85 
+		// SGS 85
 		// South American 1969
 		// WGS 60
 		// WGS 66
-		{ "WGS 72", 7020, 6378135.0, 298.259998590  }, 
-		{ "WGS 84", 7030, 6378137, 298.257223563 }, 
-    { NULL, 0 }
+		{ "WGS 72", 7020, 6378135.0, 298.259998590  },
+		{ "WGS 84", 7030, 6378137, 298.257223563 },
+    { NULL, 0, 0.0, 0.0 }
 };
 
 #ifndef PI
@@ -1034,7 +1034,7 @@ CPLErr ILWISDataset::WriteProjection()
     if( poGeogSRS )
     {
         csy = pszBaseName + ".csy";
-				
+
         WriteElement("Ilwis", "Type", csFileName, "CoordSystem");
         pszDatum = poGeogSRS->GetAttrValue( "GEOGCS|DATUM" );
 
@@ -1049,10 +1049,10 @@ CPLErr ILWISDataset::WriteProjection()
             piwDatum++;
         } //end of searchong for matching datum
         WriteElement("CoordSystem", "Width", csFileName, 28);
-        double a, b, f;
+        double a, /* b, */f;
         pszEllips = poGeogSRS->GetAttrValue( "GEOGCS|DATUM|SPHEROID" );
         a = poGeogSRS->GetSemiMajor();
-        b = poGeogSRS->GetSemiMinor();
+        /* b = */ poGeogSRS->GetSemiMinor();
         f = poGeogSRS->GetInvFlattening();
         WriteElement("CoordSystem", "Ellipsoid", csFileName, "User Defined");
         WriteElement("Ellipsoid", "a", csFileName, a);
@@ -1190,4 +1190,3 @@ CPLErr ILWISDataset::WriteProjection()
 
     return CE_None;
 }
-
diff --git a/frmts/ilwis/ilwisdataset.cpp b/frmts/ilwis/ilwisdataset.cpp
index 380c610..ac9ebee 100644
--- a/frmts/ilwis/ilwisdataset.cpp
+++ b/frmts/ilwis/ilwisdataset.cpp
@@ -845,9 +845,9 @@ void ILWISDataset::FlushCache()
 /************************************************************************/
 
 GDALDataset *ILWISDataset::Create(const char* pszFilename,
-                                  int nXSize, int nYSize, 
+                                  int nXSize, int nYSize,
                                   int nBands, GDALDataType eType,
-                                  char** papszParmList) 
+                                  CPL_UNUSED char** papszParmList)
 {
     ILWISDataset	*poDS;
     int 		iBand;
@@ -1451,7 +1451,7 @@ CPLErr ILWISRasterBand::GetILWISInfo(string pszFileName)
 }
 
 /** This driver defines a Block to be the entire raster; The method reads
-    each line as a block. it reads the data into pImage.  
+    each line as a block. it reads the data into pImage.
 
     @param nBlockXOff This must be zero for this driver
     @param pImage Dump the data here
@@ -1461,20 +1461,20 @@ CPLErr ILWISRasterBand::GetILWISInfo(string pszFileName)
 /************************************************************************/
 /*                             IReadBlock()                             */
 /************************************************************************/
-CPLErr ILWISRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
-                                  void * pImage )
+CPLErr ILWISRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYOff,
+                                    void * pImage )
 {
     // pImage is empty; this function fills it with data from fpRaw
     // (ILWIS data to foreign data)
 
     // If the x block offset is non-zero, something is wrong.
     CPLAssert( nBlockXOff == 0 );
-		
+
     int nBlockSize =  nBlockXSize * nBlockYSize * nSizePerPixel;
     if( fpRaw == NULL )
     {
         CPLError( CE_Failure, CPLE_OpenFailed,
-                  "Failed to open ILWIS data file.");  
+                  "Failed to open ILWIS data file.");
         return( CE_Failure );
     }
 
@@ -1653,8 +1653,8 @@ void ILWISRasterBand::FillWithNoData(void * pImage)
 /*                                                                      */
 /************************************************************************/
 
-CPLErr ILWISRasterBand::IWriteBlock(int nBlockXOff, int nBlockYOff,
-				   void* pImage)
+CPLErr ILWISRasterBand::IWriteBlock(CPL_UNUSED int nBlockXOff, int nBlockYOff,
+                                    void* pImage)
 {
     // pImage has data; this function reads this data and stores it to fpRaw
     // (foreign data to ILWIS data)
diff --git a/frmts/iris/irisdataset.cpp b/frmts/iris/irisdataset.cpp
index e8fa7f2..bb1ba38 100644
--- a/frmts/iris/irisdataset.cpp
+++ b/frmts/iris/irisdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: irisdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: irisdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  IRIS Reader
  * Purpose:  All code for IRIS format Reader
@@ -43,7 +43,7 @@
 #include <sstream>
 
 
-CPL_CVSID("$Id: irisdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: irisdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void	GDALRegister_IRIS(void);
@@ -536,24 +536,24 @@ std::pair <double,double> IRISDataset::GeodesicCalculation(float fLat, float fLo
     double dfAlpha1 = DEG2RAD * fAngle;
     double dfSinAlpha1 = sin(dfAlpha1);
     double dfCosAlpha1 = cos(dfAlpha1);
-    
+
     double dfTanU1 = (1-fFlattening) * tan(fLat*DEG2RAD);
     double dfCosU1 = 1 / sqrt((1 + dfTanU1*dfTanU1));
     double dfSinU1 = dfTanU1*dfCosU1;
-    
+
     double dfSigma1 = atan2(dfTanU1, dfCosAlpha1);
     double dfSinAlpha = dfCosU1 * dfSinAlpha1;
     double dfCosSqAlpha = 1 - dfSinAlpha*dfSinAlpha;
     double dfUSq = dfCosSqAlpha * (fEquatorialRadius*fEquatorialRadius - fPolarRadius*fPolarRadius) / (fPolarRadius*fPolarRadius);
     double dfA = 1 + dfUSq/16384*(4096+dfUSq*(-768+dfUSq*(320-175*dfUSq)));
     double dfB = dfUSq/1024 * (256+dfUSq*(-128+dfUSq*(74-47*dfUSq)));
-    
+
     double dfSigma = fDist / (fPolarRadius*dfA);
     double dfSigmaP = 2*M_PI;
-    
-    double dfSinSigma;
-    double dfCosSigma;
-    double dfCos2SigmaM; 
+
+    double dfSinSigma = 0.0;
+    double dfCosSigma = 0.0;
+    double dfCos2SigmaM = 0.0;
     double dfDeltaSigma;
 
     while (fabs(dfSigma-dfSigmaP) > 1e-12) {
@@ -564,10 +564,10 @@ std::pair <double,double> IRISDataset::GeodesicCalculation(float fLat, float fLo
           dfB/6*dfCos2SigmaM*(-3+4*dfSinSigma*dfSinSigma)*(-3+4*dfCos2SigmaM*dfCos2SigmaM)));
         dfSigmaP = dfSigma;
         dfSigma = fDist / (fPolarRadius*dfA) + dfDeltaSigma;
-    }    
-    
+    }
+
     double dfTmp = dfSinU1*dfSinSigma - dfCosU1*dfCosSigma*dfCosAlpha1;
-    double dfLat2 = atan2(dfSinU1*dfCosSigma + dfCosU1*dfSinSigma*dfCosAlpha1, 
+    double dfLat2 = atan2(dfSinU1*dfCosSigma + dfCosU1*dfSinSigma*dfCosAlpha1,
       (1-fFlattening)*sqrt(dfSinAlpha*dfSinAlpha + dfTmp*dfTmp));
     double dfLambda = atan2(dfSinSigma*dfSinAlpha1, dfCosU1*dfCosSigma - dfSinU1*dfSinSigma*dfCosAlpha1);
     double dfC = fFlattening/16*dfCosSqAlpha*(4+fFlattening*(4-3*dfCosSqAlpha));
@@ -580,7 +580,7 @@ std::pair <double,double> IRISDataset::GeodesicCalculation(float fLat, float fLo
         dfLon2 = dfLon2 + 2*M_PI;
     oOutput.first = dfLon2*RAD2DEG;
     oOutput.second = dfLat2*RAD2DEG;
-    
+
     return oOutput;
 }
 
diff --git a/frmts/jpeg/GNUmakefile b/frmts/jpeg/GNUmakefile
index 4539b2f..7c7b82e 100644
--- a/frmts/jpeg/GNUmakefile
+++ b/frmts/jpeg/GNUmakefile
@@ -37,6 +37,8 @@ CPPFLAGS	:=	$(XTRA_OPT) $(GDAL_INCLUDE) $(CPPFLAGS)
 
 default:	install-obj
 
+$(O_OBJ): jpgdataset.cpp
+
 clean:
 	rm -f *.o $(O_OBJ) libjpeg12/*.c libjpeg12/*.h
 
diff --git a/frmts/jpeg/frmt_jpeg.html b/frmts/jpeg/frmt_jpeg.html
index 417e49c..627cf4d 100644
--- a/frmts/jpeg/frmt_jpeg.html
+++ b/frmts/jpeg/frmt_jpeg.html
@@ -62,6 +62,14 @@ stored as XML raw content in the xml:XMP metadata domain.<p>
 
 <p>This metadata tag can be used as creation options.</p>
 
+<h2>Error management</h2>
+
+While decoding, libjpeg has resiliency towards some errors in the JPEG datastream and will
+try to recover from them as much of possible. Starting with GDAL 1.11.2, 
+such errors will be reported as GDAL Warnings, but can optionaly be considered
+as true Errors by setting the GDAL_ERROR_ON_LIBJPEG_WARNING configuration option
+to TRUE.
+
 <h2>Creation Options</h2>
 
 JPEG files are created using the "JPEG" driver code.  Only Byte band types
diff --git a/frmts/jpeg/jpgdataset.cpp b/frmts/jpeg/jpgdataset.cpp
index 9a2021b..26943f5 100644
--- a/frmts/jpeg/jpgdataset.cpp
+++ b/frmts/jpeg/jpgdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: jpgdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: jpgdataset.cpp 27743 2014-09-26 21:56:05Z rouault $
  *
  * Project:  JPEG JFIF Driver
  * Purpose:  Implement GDAL JPEG Support based on IJG libjpeg.
@@ -50,7 +50,7 @@ typedef struct {
         GUInt32  tiff_diroff;    /* byte offset to first directory */
 } TIFFHeader;
 
-CPL_CVSID("$Id: jpgdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: jpgdataset.cpp 27743 2014-09-26 21:56:05Z rouault $");
 
 CPL_C_START
 #ifdef LIBJPEG_12_PATH 
@@ -118,6 +118,13 @@ GDALRasterBand* JPGCreateBand(JPGDatasetCommon* poDS, int nBand);
 CPLErr JPGAppendMask( const char *pszJPGFilename, GDALRasterBand *poMask,
                       GDALProgressFunc pfnProgress, void * pProgressData );
 
+typedef struct
+{
+    jmp_buf     setjmp_buffer;
+    int         bNonFatalErrorEncountered;
+    void      (*p_previous_emit_message)(j_common_ptr cinfo, int msg_level);
+} GDALJPEGErrorStruct;
+
 /************************************************************************/
 /* ==================================================================== */
 /*                         JPGDatasetCommon                             */
@@ -133,7 +140,8 @@ protected:
     friend class JPGRasterBand;
     friend class JPGMaskBand;
 
-    jmp_buf setjmp_buffer;
+    GDALJPEGErrorStruct sErrorStruct;
+    int           ErrorOutOnNonFatalError();
 
     int           nScaleFactor;
     int           bHasInitInternalOverviews;
@@ -265,6 +273,7 @@ class JPGDataset : public JPGDatasetCommon
                                     void * pProgressData );
 
     static void ErrorExit(j_common_ptr cinfo);
+    static void EmitMessage(j_common_ptr cinfo, int msg_level);
 };
 
 /************************************************************************/
@@ -1125,6 +1134,9 @@ JPGDatasetCommon::JPGDatasetCommon()
 
     bIsSubfile = FALSE;
     bHasTriedLoadWorldFileOrTab = FALSE;
+
+    sErrorStruct.bNonFatalErrorEncountered = FALSE;
+    sErrorStruct.p_previous_emit_message = NULL;
 }
 
 /************************************************************************/
@@ -1253,6 +1265,21 @@ CPLErr JPGDatasetCommon::IBuildOverviews( const char *pszResampling,
     return eErr;
 }
 
+/************************************************************************/
+/*                      ErrorOutOnNonFatalError()                       */
+/************************************************************************/
+
+int JPGDatasetCommon::ErrorOutOnNonFatalError()
+{
+    if( sErrorStruct.bNonFatalErrorEncountered )
+    {
+        sErrorStruct.bNonFatalErrorEncountered = FALSE;
+        return TRUE;
+    }
+    return FALSE;
+}
+
+
 #endif // !defined(JPGDataset)
 
 /************************************************************************/
@@ -1295,7 +1322,7 @@ CPLErr JPGDataset::LoadScanline( int iLine )
         return CE_None;
 
     // setup to trap a fatal error.
-    if (setjmp(setjmp_buffer)) 
+    if (setjmp(sErrorStruct.setjmp_buffer)) 
         return CE_Failure;
 
     if (!bHasDoneJpegStartDecompress)
@@ -1338,6 +1365,8 @@ CPLErr JPGDataset::LoadScanline( int iLine )
             
         ppSamples = (JSAMPLE *) pabyScanline;
         jpeg_read_scanlines( &sDInfo, &ppSamples, 1 );
+        if( ErrorOutOnNonFatalError() )
+            return CE_Failure;
         nLoadedScanline++;
     }
 
@@ -1920,7 +1949,7 @@ GDALDataset *JPGDataset::Open( const char* pszFilename, char** papszSiblingFiles
     poDS->eAccess = GA_ReadOnly;
 
     /* Will detect mismatch between compile-time and run-time libjpeg versions */
-    if (setjmp(poDS->setjmp_buffer)) 
+    if (setjmp(poDS->sErrorStruct.setjmp_buffer)) 
     {
         delete poDS;
         return NULL;
@@ -1928,7 +1957,9 @@ GDALDataset *JPGDataset::Open( const char* pszFilename, char** papszSiblingFiles
 
     poDS->sDInfo.err = jpeg_std_error( &(poDS->sJErr) );
     poDS->sJErr.error_exit = JPGDataset::ErrorExit;
-    poDS->sDInfo.client_data = (void *) &(poDS->setjmp_buffer);
+    poDS->sErrorStruct.p_previous_emit_message = poDS->sJErr.emit_message;
+    poDS->sJErr.emit_message = JPGDataset::EmitMessage;
+    poDS->sDInfo.client_data = (void *) &(poDS->sErrorStruct);
 
     jpeg_create_decompress( &(poDS->sDInfo) );
     poDS->bHasDoneJpegCreateDecompress = TRUE;
@@ -1953,7 +1984,7 @@ GDALDataset *JPGDataset::Open( const char* pszFilename, char** papszSiblingFiles
 /* -------------------------------------------------------------------- */
 /*      If a fatal error occurs after this, we will return NULL         */
 /* -------------------------------------------------------------------- */
-    if (setjmp(poDS->setjmp_buffer)) 
+    if (setjmp(poDS->sErrorStruct.setjmp_buffer)) 
     {
 #if defined(JPEG_DUAL_MODE_8_12) && !defined(JPGDataset)
         if (poDS->sDInfo.data_precision == 12)
@@ -2342,7 +2373,7 @@ void JPGDatasetCommon::DecompressMask()
 
 void JPGDataset::ErrorExit(j_common_ptr cinfo)
 {
-    jmp_buf *setjmp_buffer = (jmp_buf *) cinfo->client_data;
+    GDALJPEGErrorStruct* psErrorStruct = (GDALJPEGErrorStruct* ) cinfo->client_data;
     char buffer[JMSG_LENGTH_MAX];
 
     /* Create the message */
@@ -2358,7 +2389,49 @@ void JPGDataset::ErrorExit(j_common_ptr cinfo)
               "libjpeg: %s", buffer );
 
     /* Return control to the setjmp point */
-    longjmp(*setjmp_buffer, 1);
+    longjmp(psErrorStruct->setjmp_buffer, 1);
+}
+
+/************************************************************************/
+/*                             EmitMessage()                            */
+/************************************************************************/
+
+void JPGDataset::EmitMessage(j_common_ptr cinfo, int msg_level)
+{
+    GDALJPEGErrorStruct* psErrorStruct = (GDALJPEGErrorStruct* ) cinfo->client_data;
+    if( msg_level >= 0 ) /* Trace message */
+    {
+        if( psErrorStruct->p_previous_emit_message != NULL )
+            psErrorStruct->p_previous_emit_message(cinfo, msg_level);
+    }
+    else /* Warning : libjpeg will try to recover but the image will be likely corrupted */
+    {
+        struct jpeg_error_mgr * err = cinfo->err;
+        /* It's a warning message.  Since corrupt files may generate many warnings,
+        * the policy implemented here is to show only the first warning,
+        * unless trace_level >= 3.
+        */
+        if (err->num_warnings == 0 || err->trace_level >= 3)
+        {
+            char buffer[JMSG_LENGTH_MAX];
+
+            /* Create the message */
+            (*cinfo->err->format_message) (cinfo, buffer);
+
+            if( CSLTestBoolean(CPLGetConfigOption("GDAL_ERROR_ON_LIBJPEG_WARNING", "NO")) )
+            {
+                psErrorStruct->bNonFatalErrorEncountered = TRUE;
+                CPLError( CE_Failure, CPLE_AppDefined, "libjpeg: %s", buffer );
+            }
+            else
+            {
+                CPLError( CE_Warning, CPLE_AppDefined, "libjpeg: %s (this warning can be turned as an error by setting GDAL_ERROR_ON_LIBJPEG_WARNING to TRUE)", buffer );
+            }
+        }
+
+        /* Always count warnings in num_warnings. */
+        err->num_warnings++;
+    }
 }
 
 /************************************************************************/
@@ -2692,9 +2765,10 @@ JPGDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
 /* -------------------------------------------------------------------- */
     struct jpeg_compress_struct sCInfo;
     struct jpeg_error_mgr sJErr;
-    jmp_buf setjmp_buffer;
+    GDALJPEGErrorStruct sErrorStruct;
+    sErrorStruct.bNonFatalErrorEncountered = FALSE;
     
-    if (setjmp(setjmp_buffer)) 
+    if (setjmp(sErrorStruct.setjmp_buffer)) 
     {
         VSIFCloseL( fpImage );
         return NULL;
@@ -2702,7 +2776,9 @@ JPGDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
 
     sCInfo.err = jpeg_std_error( &sJErr );
     sJErr.error_exit = JPGDataset::ErrorExit;
-    sCInfo.client_data = (void *) &(setjmp_buffer);
+    sErrorStruct.p_previous_emit_message = sJErr.emit_message;
+    sJErr.emit_message = JPGDataset::EmitMessage;
+    sCInfo.client_data = (void *) &(sErrorStruct);
 
     jpeg_create_compress( &sCInfo );
     
diff --git a/frmts/jpeg/libjpeg/jccoefct.c b/frmts/jpeg/libjpeg/jccoefct.c
index 1963ddb..6c1d57f 100644
--- a/frmts/jpeg/libjpeg/jccoefct.c
+++ b/frmts/jpeg/libjpeg/jccoefct.c
@@ -14,6 +14,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
 
 /* We use a full-image coefficient buffer when doing Huffman optimization,
  * and also for writing multiple-scan JPEG files.  In all cases, the DCT
@@ -338,7 +339,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
  */
 
 METHODDEF(boolean)
-compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
+compress_output (j_compress_ptr cinfo, CPL_UNUSED JSAMPIMAGE input_buf)
 {
   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
   JDIMENSION MCU_col_num;	/* index of current MCU within row */
diff --git a/frmts/jpeg/libjpeg/jccolor.c b/frmts/jpeg/libjpeg/jccolor.c
index 0a8a4b5..bbd44b3 100644
--- a/frmts/jpeg/libjpeg/jccolor.c
+++ b/frmts/jpeg/libjpeg/jccolor.c
@@ -12,6 +12,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
 
 /* Private subobject */
 
@@ -338,7 +339,7 @@ null_convert (j_compress_ptr cinfo,
  */
 
 METHODDEF(void)
-null_method (j_compress_ptr cinfo)
+null_method (CPL_UNUSED j_compress_ptr cinfo)
 {
   /* no work needed */
 }
diff --git a/frmts/jpeg/libjpeg/jcmarker.c b/frmts/jpeg/libjpeg/jcmarker.c
index 3d1e6c6..125a15d 100644
--- a/frmts/jpeg/libjpeg/jcmarker.c
+++ b/frmts/jpeg/libjpeg/jcmarker.c
@@ -12,6 +12,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
 
 typedef enum {			/* JPEG marker codes */
   M_SOF0  = 0xc0,
@@ -212,14 +213,14 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
     
     for (i = 0; i < length; i++)
       emit_byte(cinfo, htbl->huffval[i]);
-    
+
     htbl->sent_table = TRUE;
   }
 }
 
 
 LOCAL(void)
-emit_dac (j_compress_ptr cinfo)
+emit_dac (CPL_UNUSED j_compress_ptr cinfo)
 /* Emit a DAC marker */
 /* Since the useful info is so small, we want to emit all the tables in */
 /* one DAC marker.  Therefore this routine does its own scan of the table. */
@@ -229,7 +230,7 @@ emit_dac (j_compress_ptr cinfo)
   char ac_in_use[NUM_ARITH_TBLS];
   int length, i;
   jpeg_component_info *compptr;
-  
+
   for (i = 0; i < NUM_ARITH_TBLS; i++)
     dc_in_use[i] = ac_in_use[i] = 0;
   
diff --git a/frmts/jpeg/libjpeg/jcsample.c b/frmts/jpeg/libjpeg/jcsample.c
index 212ec87..c544c7d 100644
--- a/frmts/jpeg/libjpeg/jcsample.c
+++ b/frmts/jpeg/libjpeg/jcsample.c
@@ -49,6 +49,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
 
 /* Pointer to routine to downsample a single component */
 typedef JMETHOD(void, downsample1_ptr,
@@ -72,7 +73,7 @@ typedef my_downsampler * my_downsample_ptr;
  */
 
 METHODDEF(void)
-start_pass_downsample (j_compress_ptr cinfo)
+start_pass_downsample (CPL_UNUSED j_compress_ptr cinfo)
 {
   /* no work for now */
 }
diff --git a/frmts/jpeg/libjpeg/jctrans.c b/frmts/jpeg/libjpeg/jctrans.c
index 0e6d707..6c2314d 100644
--- a/frmts/jpeg/libjpeg/jctrans.c
+++ b/frmts/jpeg/libjpeg/jctrans.c
@@ -14,6 +14,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
 
 /* Forward declarations */
 LOCAL(void) transencode_master_selection
@@ -275,7 +276,7 @@ start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
  */
 
 METHODDEF(boolean)
-compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
+compress_output (j_compress_ptr cinfo, CPL_UNUSED JSAMPIMAGE input_buf)
 {
   my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
   JDIMENSION MCU_col_num;	/* index of current MCU within row */
diff --git a/frmts/jpeg/libjpeg/jdatasrc.c b/frmts/jpeg/libjpeg/jdatasrc.c
index edc752b..9de896a 100644
--- a/frmts/jpeg/libjpeg/jdatasrc.c
+++ b/frmts/jpeg/libjpeg/jdatasrc.c
@@ -19,6 +19,7 @@
 #include "jpeglib.h"
 #include "jerror.h"
 
+#include "cpl_port.h"
 
 /* Expanded data source object for stdio input */
 
@@ -166,7 +167,7 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
  */
 
 METHODDEF(void)
-term_source (j_decompress_ptr cinfo)
+term_source (CPL_UNUSED j_decompress_ptr cinfo)
 {
   /* no work necessary here */
 }
diff --git a/frmts/jpeg/libjpeg/jdcoefct.c b/frmts/jpeg/libjpeg/jdcoefct.c
index 4938d20..01fe5a5 100644
--- a/frmts/jpeg/libjpeg/jdcoefct.c
+++ b/frmts/jpeg/libjpeg/jdcoefct.c
@@ -18,6 +18,8 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
+
 /* Block smoothing is only applicable for progressive JPEG, so: */
 #ifndef D_PROGRESSIVE_SUPPORTED
 #undef BLOCK_SMOOTHING_SUPPORTED
@@ -225,7 +227,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
  */
 
 METHODDEF(int)
-dummy_consume_data (j_decompress_ptr cinfo)
+dummy_consume_data (CPL_UNUSED j_decompress_ptr cinfo)
 {
   return JPEG_SUSPENDED;	/* Always indicate nothing was done */
 }
diff --git a/frmts/jpeg/libjpeg/jdcolor.c b/frmts/jpeg/libjpeg/jdcolor.c
index 6c04dfe..eced921 100644
--- a/frmts/jpeg/libjpeg/jdcolor.c
+++ b/frmts/jpeg/libjpeg/jdcolor.c
@@ -12,6 +12,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
 
 /* Private subobject */
 
@@ -290,7 +291,7 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
  */
 
 METHODDEF(void)
-start_pass_dcolor (j_decompress_ptr cinfo)
+start_pass_dcolor (CPL_UNUSED j_decompress_ptr cinfo)
 {
   /* no work needed */
 }
diff --git a/frmts/jpeg/libjpeg/jdmerge.c b/frmts/jpeg/libjpeg/jdmerge.c
index 3744446..3e2ab0e 100644
--- a/frmts/jpeg/libjpeg/jdmerge.c
+++ b/frmts/jpeg/libjpeg/jdmerge.c
@@ -36,6 +36,8 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
+
 #ifdef UPSAMPLE_MERGING_SUPPORTED
 
 
@@ -143,7 +145,7 @@ start_pass_merged_upsample (j_decompress_ptr cinfo)
 METHODDEF(void)
 merged_2v_upsample (j_decompress_ptr cinfo,
 		    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
-		    JDIMENSION in_row_groups_avail,
+		    CPL_UNUSED JDIMENSION in_row_groups_avail,
 		    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
 		    JDIMENSION out_rows_avail)
 /* 2:1 vertical sampling case: may need a spare row. */
@@ -192,9 +194,9 @@ merged_2v_upsample (j_decompress_ptr cinfo,
 METHODDEF(void)
 merged_1v_upsample (j_decompress_ptr cinfo,
 		    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
-		    JDIMENSION in_row_groups_avail,
+		    CPL_UNUSED JDIMENSION in_row_groups_avail,
 		    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
-		    JDIMENSION out_rows_avail)
+		    CPL_UNUSED JDIMENSION out_rows_avail)
 /* 1:1 vertical sampling case: much easier, never need a spare row. */
 {
   my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
diff --git a/frmts/jpeg/libjpeg/jdpostct.c b/frmts/jpeg/libjpeg/jdpostct.c
index 571563d..93c3bb3 100644
--- a/frmts/jpeg/libjpeg/jdpostct.c
+++ b/frmts/jpeg/libjpeg/jdpostct.c
@@ -20,6 +20,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
 
 /* Private buffer controller object */
 
@@ -158,8 +159,8 @@ METHODDEF(void)
 post_process_prepass (j_decompress_ptr cinfo,
 		      JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
 		      JDIMENSION in_row_groups_avail,
-		      JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
-		      JDIMENSION out_rows_avail)
+		      CPL_UNUSED JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
+		      CPL_UNUSED JDIMENSION out_rows_avail)
 {
   my_post_ptr post = (my_post_ptr) cinfo->post;
   JDIMENSION old_next_row, num_rows;
@@ -200,8 +201,8 @@ post_process_prepass (j_decompress_ptr cinfo,
 
 METHODDEF(void)
 post_process_2pass (j_decompress_ptr cinfo,
-		    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
-		    JDIMENSION in_row_groups_avail,
+		    CPL_UNUSED JSAMPIMAGE input_buf, CPL_UNUSED JDIMENSION *in_row_group_ctr,
+		    CPL_UNUSED JDIMENSION in_row_groups_avail,
 		    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
 		    JDIMENSION out_rows_avail)
 {
diff --git a/frmts/jpeg/libjpeg/jdsample.c b/frmts/jpeg/libjpeg/jdsample.c
index 80ffefb..f9979d3 100644
--- a/frmts/jpeg/libjpeg/jdsample.c
+++ b/frmts/jpeg/libjpeg/jdsample.c
@@ -22,6 +22,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
 
 /* Pointer to routine to upsample a single component */
 typedef JMETHOD(void, upsample1_ptr,
@@ -88,7 +89,7 @@ start_pass_upsample (j_decompress_ptr cinfo)
 METHODDEF(void)
 sep_upsample (j_decompress_ptr cinfo,
 	      JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
-	      JDIMENSION in_row_groups_avail,
+	      CPL_UNUSED JDIMENSION in_row_groups_avail,
 	      JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
 	      JDIMENSION out_rows_avail)
 {
@@ -154,7 +155,7 @@ sep_upsample (j_decompress_ptr cinfo,
  */
 
 METHODDEF(void)
-fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+fullsize_upsample (CPL_UNUSED j_decompress_ptr cinfo, CPL_UNUSED jpeg_component_info * compptr,
 		   JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   *output_data_ptr = input_data;
@@ -167,8 +168,8 @@ fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
  */
 
 METHODDEF(void)
-noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-	       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
+noop_upsample (CPL_UNUSED j_decompress_ptr cinfo, CPL_UNUSED jpeg_component_info * compptr,
+	       CPL_UNUSED JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   *output_data_ptr = NULL;	/* safety check */
 }
@@ -230,7 +231,7 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
  */
 
 METHODDEF(void)
-h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+h2v1_upsample (j_decompress_ptr cinfo, CPL_UNUSED jpeg_component_info * compptr,
 	       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   JSAMPARRAY output_data = *output_data_ptr;
@@ -258,7 +259,7 @@ h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
  */
 
 METHODDEF(void)
-h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+h2v2_upsample (j_decompress_ptr cinfo, CPL_UNUSED jpeg_component_info * compptr,
 	       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   JSAMPARRAY output_data = *output_data_ptr;
diff --git a/frmts/jpeg/libjpeg/jmemansi.c b/frmts/jpeg/libjpeg/jmemansi.c
index 2d93e49..27a22c5 100644
--- a/frmts/jpeg/libjpeg/jmemansi.c
+++ b/frmts/jpeg/libjpeg/jmemansi.c
@@ -17,6 +17,8 @@
 #include "jpeglib.h"
 #include "jmemsys.h"		/* import the system-dependent declarations */
 
+#include "cpl_port.h"
+
 #ifndef HAVE_STDLIB_H		/* <stdlib.h> should declare malloc(),free() */
 extern void * malloc JPP((size_t size));
 extern void free JPP((void *ptr));
@@ -33,13 +35,13 @@ extern void free JPP((void *ptr));
  */
 
 GLOBAL(void *)
-jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
+jpeg_get_small (CPL_UNUSED j_common_ptr cinfo, size_t sizeofobject)
 {
   return (void *) malloc(sizeofobject);
 }
 
 GLOBAL(void)
-jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
+jpeg_free_small (CPL_UNUSED j_common_ptr cinfo, void * object, CPL_UNUSED size_t sizeofobject)
 {
   free(object);
 }
@@ -53,13 +55,13 @@ jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
  */
 
 GLOBAL(void FAR *)
-jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
+jpeg_get_large (CPL_UNUSED j_common_ptr cinfo, size_t sizeofobject)
 {
   return (void FAR *) malloc(sizeofobject);
 }
 
 GLOBAL(void)
-jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
+jpeg_free_large (CPL_UNUSED j_common_ptr cinfo, void FAR * object, CPL_UNUSED size_t sizeofobject)
 {
   free(object);
 }
@@ -78,8 +80,8 @@ jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
 #endif
 
 GLOBAL(long)
-jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
-		    long max_bytes_needed, long already_allocated)
+jpeg_mem_available (j_common_ptr cinfo, CPL_UNUSED long min_bytes_needed,
+		    CPL_UNUSED long max_bytes_needed, long already_allocated)
 {
   return cinfo->mem->max_memory_to_use - already_allocated;
 }
@@ -120,7 +122,7 @@ write_backing_store (j_common_ptr cinfo, backing_store_ptr info,
 
 
 METHODDEF(void)
-close_backing_store (j_common_ptr cinfo, backing_store_ptr info)
+close_backing_store (CPL_UNUSED j_common_ptr cinfo, backing_store_ptr info)
 {
   fclose(info->temp_file);
   /* Since this implementation uses tmpfile() to create the file,
@@ -139,7 +141,7 @@ close_backing_store (j_common_ptr cinfo, backing_store_ptr info)
 
 GLOBAL(void)
 jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
-			 long total_bytes_needed)
+			 CPL_UNUSED long total_bytes_needed)
 {
   if ((info->temp_file = tmpfile()) == NULL)
     ERREXITS(cinfo, JERR_TFILE_CREATE, "");
@@ -155,13 +157,13 @@ jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
  */
 
 GLOBAL(long)
-jpeg_mem_init (j_common_ptr cinfo)
+jpeg_mem_init (CPL_UNUSED j_common_ptr cinfo)
 {
   return DEFAULT_MAX_MEM;	/* default for max_memory_to_use */
 }
 
 GLOBAL(void)
-jpeg_mem_term (j_common_ptr cinfo)
+jpeg_mem_term (CPL_UNUSED j_common_ptr cinfo)
 {
   /* no work */
 }
diff --git a/frmts/jpeg/libjpeg/jquant1.c b/frmts/jpeg/libjpeg/jquant1.c
index b2f96aa..56a3dc8 100644
--- a/frmts/jpeg/libjpeg/jquant1.c
+++ b/frmts/jpeg/libjpeg/jquant1.c
@@ -14,6 +14,8 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
+
 #ifdef QUANT_1PASS_SUPPORTED
 
 
@@ -242,7 +244,7 @@ select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
 
 
 LOCAL(int)
-output_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
+output_value (CPL_UNUSED j_decompress_ptr cinfo, CPL_UNUSED int ci, int j, int maxj)
 /* Return j'th output value, where j will range from 0 to maxj */
 /* The output values must fall in 0..MAXJSAMPLE in increasing order */
 {
@@ -256,7 +258,7 @@ output_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
 
 
 LOCAL(int)
-largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
+largest_input_value (CPL_UNUSED j_decompress_ptr cinfo, CPL_UNUSED int ci, int j, int maxj)
 /* Return largest input value that should map to j'th output value */
 /* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */
 {
@@ -738,7 +740,7 @@ alloc_fs_workspace (j_decompress_ptr cinfo)
  */
 
 METHODDEF(void)
-start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
+start_pass_1_quant (j_decompress_ptr cinfo, CPL_UNUSED boolean is_pre_scan)
 {
   my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
   size_t arraysize;
@@ -795,7 +797,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
  */
 
 METHODDEF(void)
-finish_pass_1_quant (j_decompress_ptr cinfo)
+finish_pass_1_quant (CPL_UNUSED j_decompress_ptr cinfo)
 {
   /* no work in 1-pass case */
 }
diff --git a/frmts/jpeg/libjpeg/jquant2.c b/frmts/jpeg/libjpeg/jquant2.c
index af601e3..f9f597b 100644
--- a/frmts/jpeg/libjpeg/jquant2.c
+++ b/frmts/jpeg/libjpeg/jquant2.c
@@ -21,6 +21,8 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 
+#include "cpl_port.h"
+
 #ifdef QUANT_2PASS_SUPPORTED
 
 
@@ -222,7 +224,7 @@ typedef my_cquantizer * my_cquantize_ptr;
 
 METHODDEF(void)
 prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
-		  JSAMPARRAY output_buf, int num_rows)
+		  CPL_UNUSED JSAMPARRAY output_buf, int num_rows)
 {
   my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
   register JSAMPROW ptr;
@@ -1153,7 +1155,7 @@ finish_pass1 (j_decompress_ptr cinfo)
 
 
 METHODDEF(void)
-finish_pass2 (j_decompress_ptr cinfo)
+finish_pass2 (CPL_UNUSED j_decompress_ptr cinfo)
 {
   /* no work */
 }
diff --git a/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp b/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp
index a8d1e86..248b01d 100644
--- a/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp
+++ b/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp
@@ -638,7 +638,7 @@ GDALDataset *KmlSuperOverlayCreateCopy( const char * pszFilename, GDALDataset *p
     }
 
     //Zoom levels of the pyramid.
-    int maxzoom;
+    int maxzoom = 0;
     int tilexsize;
     int tileysize;
     // Let the longer side determine the max zoom level and x/y tilesizes.
@@ -648,9 +648,8 @@ GDALDataset *KmlSuperOverlayCreateCopy( const char * pszFilename, GDALDataset *p
         while (dtilexsize > 400) //calculate x tile size
         {
             dtilexsize = dtilexsize/2;
+            maxzoom ++;
         }
-
-        maxzoom   = static_cast<int>(log( (double)xsize / dtilexsize ) / log(2.0));
         tilexsize = (int)dtilexsize;
         tileysize = (int)( (double)(dtilexsize * ysize) / xsize );
     }
@@ -660,9 +659,9 @@ GDALDataset *KmlSuperOverlayCreateCopy( const char * pszFilename, GDALDataset *p
         while (dtileysize > 400) //calculate y tile size
         {
             dtileysize = dtileysize/2;
+            maxzoom ++;
         }
 
-        maxzoom   = static_cast<int>(log( (double)ysize / dtileysize ) / log(2.0));
         tileysize = (int)dtileysize;
         tilexsize = (int)( (double)(dtileysize * xsize) / ysize );
     }
@@ -748,8 +747,8 @@ GDALDataset *KmlSuperOverlayCreateCopy( const char * pszFilename, GDALDataset *p
 
     for (zoom = maxzoom; zoom >= 0; --zoom)
     {
-        int rmaxxsize = static_cast<int>(pow(2.0, (maxzoom-zoom)) * tilexsize);
-        int rmaxysize = static_cast<int>(pow(2.0, (maxzoom-zoom)) * tileysize);
+        int rmaxxsize = tilexsize * (1 << (maxzoom-zoom));
+        int rmaxysize = tileysize * (1 << (maxzoom-zoom));
 
         int xloop = (int)xsize/rmaxxsize;
         int yloop = (int)ysize/rmaxysize;
@@ -758,8 +757,8 @@ GDALDataset *KmlSuperOverlayCreateCopy( const char * pszFilename, GDALDataset *p
 
     for (zoom = maxzoom; zoom >= 0; --zoom)
     {
-        int rmaxxsize = static_cast<int>(pow(2.0, (maxzoom-zoom)) * tilexsize);
-        int rmaxysize = static_cast<int>(pow(2.0, (maxzoom-zoom)) * tileysize);
+        int rmaxxsize = tilexsize * (1 << (maxzoom-zoom));
+        int rmaxysize = tileysize * (1 << (maxzoom-zoom));
 
         int xloop = (int)xsize/rmaxxsize;
         int yloop = (int)ysize/rmaxysize;
diff --git a/frmts/leveller/levellerdataset.cpp b/frmts/leveller/levellerdataset.cpp
index 620f52f..f959429 100644
--- a/frmts/leveller/levellerdataset.cpp
+++ b/frmts/leveller/levellerdataset.cpp
@@ -35,7 +35,7 @@
 #include "gdal_pam.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: levellerdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: levellerdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void	GDALRegister_Leveller(void);
@@ -1345,6 +1345,7 @@ bool LevellerDataset::load_from_file(VSILFILE* file, const char* pszFilename)
 			{
 				UNITLABEL unitcode;
 				//char szLocalUnits[8];
+                                // TODO: Fix strict aliasing issue.
 				if(!this->get((int&)unitcode, file, "coordsys_units"))
 					unitcode = UNITLABEL_M;
 
diff --git a/frmts/mrsid/nmake.opt b/frmts/mrsid/nmake.opt
index 8b11ac5..b06c1a3 100644
--- a/frmts/mrsid/nmake.opt
+++ b/frmts/mrsid/nmake.opt
@@ -440,6 +440,8 @@ MRSID_INCLUDE =    -I"$(MRSID_LIDAR_DIR)\include" $(MRSID_INCLUDE)
 MRSID_LIB =        "$(MRSID_RASTER_DIR)\lib\lti_dsdk.lib" $(MRSID_LIB)
 !ELSE IF EXIST("$(MRSID_RASTER_DIR)\lib\lti_dsdk_9.0.dll")
 MRSID_LIB =        "$(MRSID_RASTER_DIR)\lib\lti_dsdk.lib" $(MRSID_LIB)
+!ELSE IF EXIST("$(MRSID_RASTER_DIR)\lib\lti_dsdk_9.1.dll")
+MRSID_LIB =        "$(MRSID_RASTER_DIR)\lib\lti_dsdk.lib" $(MRSID_LIB)
 !ELSE IF EXIST("$(MRSID_RASTER_DIR)\lib\$(MRSID_CONFIG)\lti_dsdk_dll.dll")
 MRSID_LIB =        "$(MRSID_RASTER_DIR)\lib\$(MRSID_CONFIG)\lti_dsdk_dll.lib" $(MRSID_LIB)
 !ELSE IF EXIST("$(MRSID_RASTER_DIR)\lib\Release_md\lti_dsdk_dll.dll")
diff --git a/frmts/mrsid_lidar/gdal_MG4Lidar.cpp b/frmts/mrsid_lidar/gdal_MG4Lidar.cpp
index eaf4ae3..4e88df0 100644
--- a/frmts/mrsid_lidar/gdal_MG4Lidar.cpp
+++ b/frmts/mrsid_lidar/gdal_MG4Lidar.cpp
@@ -447,7 +447,7 @@ double MG4LidarRasterBand::getMaxValue()
       #define DO_CASE(gdt, largestvalue)  case (gdt):\
          retval = static_cast<double>(largestvalue); \
          break;
-         
+
       DO_CASE (GDT_Float64, DBL_MAX);
       DO_CASE (GDT_Float32, FLT_MAX);
       DO_CASE (GDT_Int32, INT_MAX);
@@ -455,7 +455,7 @@ double MG4LidarRasterBand::getMaxValue()
       DO_CASE (GDT_Int16, SHRT_MAX);
       DO_CASE (GDT_UInt16, USHRT_MAX);
       DO_CASE (GDT_Byte, UCHAR_MAX);
-      #undef DO_CASE 
+      #undef DO_CASE
        default:
            retval = 0;
            break;
@@ -469,11 +469,11 @@ double MG4LidarRasterBand::getMaxValue()
 CPLErr MG4LidarRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
                                       void * pImage )
 {
-   CPLErr eErr;
+   // CPLErr eErr;
    switch(eDataType)
    {
 #define DO_CASE(gdt, nativedt)  case (gdt):\
-   eErr = doReadBlock<nativedt>(nBlockXOff, nBlockYOff, pImage); \
+     /* eErr = */doReadBlock<nativedt>(nBlockXOff, nBlockYOff, pImage); \
    break;
 
       DO_CASE (GDT_Float64, double);
@@ -483,7 +483,7 @@ CPLErr MG4LidarRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
       DO_CASE (GDT_Int16, short);
       DO_CASE (GDT_UInt16, unsigned short);
       DO_CASE (GDT_Byte, char);
-#undef DO_CASE 
+#undef DO_CASE
       default:
            return CE_Failure;
            break;
diff --git a/frmts/msgn/msg_basic_types.cpp b/frmts/msgn/msg_basic_types.cpp
index 5f7af53..2873530 100644
--- a/frmts/msgn/msg_basic_types.cpp
+++ b/frmts/msgn/msg_basic_types.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: msg_basic_types.cpp 17686 2009-09-25 13:35:11Z dron $
+ * $Id: msg_basic_types.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  MSG Native Reader
  * Purpose:  Basic types implementation.
@@ -30,7 +30,7 @@
 #include "msg_basic_types.h"
 #include "cpl_port.h"
 
-CPL_CVSID("$Id: msg_basic_types.cpp 17686 2009-09-25 13:35:11Z dron $");
+CPL_CVSID("$Id: msg_basic_types.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 #include <stdio.h>
 
@@ -76,12 +76,13 @@ void to_native(IMAGE_DESCRIPTION_RECORD& r) {
     r.referencegrid_visir.numberOfColumns = CPL_MSBWORD32(r.referencegrid_visir.numberOfColumns);
     // should floats be swapped too?
     unsigned int t;
-    
+
     // convert float using CPL_MSBWORD32
+    // TODO: Fix strict aliasing issue
     t = *(unsigned int *)&r.referencegrid_visir.lineDirGridStep;
     t = CPL_MSBWORD32(t);
     r.referencegrid_visir.lineDirGridStep = *(float *)&t;
-    
+
     // convert float using CPL_MSBWORD32
     t = *(unsigned int *)&r.referencegrid_visir.columnDirGridStep;
     t = CPL_MSBWORD32(t);
@@ -221,5 +222,3 @@ void Conversions::convert_geo_to_pixel(double longitude, double latitude,unsigne
 }
 
 } // namespace msg_native_format
-
-
diff --git a/frmts/netcdf/gmtdataset.cpp b/frmts/netcdf/gmtdataset.cpp
index b92a9a2..b09e205 100644
--- a/frmts/netcdf/gmtdataset.cpp
+++ b/frmts/netcdf/gmtdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gmtdataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: gmtdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  netCDF read/write Driver
  * Purpose:  GDAL bindings over netCDF library for GMT Grids.
@@ -33,7 +33,7 @@
 #include "netcdf.h"
 #include "cpl_multiproc.h"
 
-CPL_CVSID("$Id: gmtdataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: gmtdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 extern void *hNCMutex; /* shared with netcdf. See netcdfdataset.cpp */
 
@@ -128,9 +128,8 @@ GMTRasterBand::GMTRasterBand( GMTDataset *poDS, int nZId, int nBand )
 /*                             IReadBlock()                             */
 /************************************************************************/
 
-CPLErr GMTRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
+CPLErr GMTRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYOff,
                                   void * pImage )
-
 {
     size_t start[2], edge[2];
     int    nErr = NC_NOERR;
@@ -386,10 +385,10 @@ GDALDataset *GMTDataset::Open( GDALOpenInfo * poOpenInfo )
 /************************************************************************/
 
 static GDALDataset *
-GMTCreateCopy( const char * pszFilename, GDALDataset *poSrcDS, 
-                  int bStrict, char ** papszOptions, 
-                  GDALProgressFunc pfnProgress, void * pProgressData )
-
+GMTCreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+               int bStrict, CPL_UNUSED char ** papszOptions,
+               CPL_UNUSED GDALProgressFunc pfnProgress,
+               CPL_UNUSED void * pProgressData )
 {
 /* -------------------------------------------------------------------- */
 /*      Figure out general characteristics.                             */
@@ -397,12 +396,12 @@ GMTCreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
     nc_type nc_datatype;
     GDALRasterBand *poBand;
     int nXSize, nYSize;
-    
+
     CPLMutexHolderD(&hNCMutex);
 
     if( poSrcDS->GetRasterCount() != 1 )
     {
-        CPLError( CE_Failure, CPLE_AppDefined, 
+        CPLError( CE_Failure, CPLE_AppDefined,
                   "Currently GMT export only supports 1 band datasets." );
         return NULL;
     }
diff --git a/frmts/netcdf/makefile.vc b/frmts/netcdf/makefile.vc
index 5759168..cd3ccd7 100644
--- a/frmts/netcdf/makefile.vc
+++ b/frmts/netcdf/makefile.vc
@@ -9,6 +9,10 @@ PLUGIN_DLL 	=	gdal_netCDF.dll
 
 EXTRAFLAGS 	= 	/I$(NETCDF_INC_DIR)
 
+!IF "$(NETCDF_PLUGIN)" == "YES"
+EXTRAFLAGS = $(EXTRAFLAGS) -DNETCDF_PLUGIN
+!ENDIF
+
 !IFDEF NETCDF_HAS_NC4
 EXTRAFLAGS = $(EXTRAFLAGS) -DNETCDF_HAS_NC4
 !ENDIF
diff --git a/frmts/netcdf/netcdfdataset.cpp b/frmts/netcdf/netcdfdataset.cpp
index da5550f..5c7d7a8 100644
--- a/frmts/netcdf/netcdfdataset.cpp
+++ b/frmts/netcdf/netcdfdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: netcdfdataset.cpp 27050 2014-03-18 00:09:03Z kyle $
+ * $Id: netcdfdataset.cpp 28365 2015-01-27 10:39:30Z rouault $
  *
  * Project:  netCDF read/write Driver
  * Purpose:  GDAL bindings over netCDF library.
@@ -33,7 +33,7 @@
 #include "cpl_error.h"
 #include "cpl_multiproc.h"
 
-CPL_CVSID("$Id: netcdfdataset.cpp 27050 2014-03-18 00:09:03Z kyle $");
+CPL_CVSID("$Id: netcdfdataset.cpp 28365 2015-01-27 10:39:30Z rouault $");
 
 #include <map> //for NCDFWriteProjAttribs()
 
@@ -833,8 +833,7 @@ CPLErr netCDFRasterBand::SetNoDataValue( double dfNoData )
 /*                           SerializeToXML()                           */
 /************************************************************************/
 
-CPLXMLNode *netCDFRasterBand::SerializeToXML( const char *pszUnused )
-
+CPLXMLNode *netCDFRasterBand::SerializeToXML( CPL_UNUSED const char *pszUnused )
 {
 /* -------------------------------------------------------------------- */
 /*      Overriden from GDALPamDataset to add only band histogram        */
@@ -1326,9 +1325,9 @@ CPLErr netCDFRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
 /*                             IWriteBlock()                            */
 /************************************************************************/
 
-CPLErr netCDFRasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff,
+CPLErr netCDFRasterBand::IWriteBlock( CPL_UNUSED int nBlockXOff,
+                                      int nBlockYOff,
                                       void * pImage )
-
 {
     size_t start[ MAX_NC_DIMS];
     size_t edge[ MAX_NC_DIMS ];
@@ -3115,12 +3114,12 @@ CPLErr netCDFDataset::Set1DGeolocation( int nVarId, const char *szDimName )
     SetMetadataItem( szTemp, pszVarValues, "GEOLOCATION2" );
 
     CPLFree( pszVarValues );
-    
+
     return CE_None;
 }
 
 
-double *netCDFDataset::Get1DGeolocation( const char *szDimName, int &nVarLen )
+double *netCDFDataset::Get1DGeolocation( CPL_UNUSED const char *szDimName, int &nVarLen )
 {
     char   **papszValues = NULL;
     char   *pszTemp = NULL;
@@ -5084,12 +5083,12 @@ void CopyMetadata( void  *poDS, int fpImage, int CDFVarID,
 
 netCDFDataset *
 netCDFDataset::CreateLL( const char * pszFilename,
-                         int nXSize, int nYSize, int nBands,
+                         int nXSize, int nYSize, CPL_UNUSED int nBands,
                          char ** papszOptions )
 {
     int status = NC_NOERR;
     netCDFDataset *poDS;
-    
+
     CPLReleaseMutex(hNCMutex); // Release mutex otherwise we'll deadlock with GDALDataset own mutex
     poDS = new netCDFDataset();
     CPLAcquireMutex(hNCMutex, 1000.0);
@@ -5262,8 +5261,8 @@ CPLErr  NCDFCopyBand( GDALRasterBand *poSrcBand, GDALRasterBand *poDstBand,
 /************************************************************************/
 
 GDALDataset*
-netCDFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, 
-                           int bStrict, char ** papszOptions, 
+netCDFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
+                           CPL_UNUSED int bStrict, char ** papszOptions,
                            GDALProgressFunc pfnProgress, void * pProgressData )
 {
     netCDFDataset *poDS;
@@ -5805,7 +5804,7 @@ int netCDFDataset::DefVarDeflate( int nVarId, int bChunkingArg )
 /*                           NCDFUnloadDriver()                         */
 /************************************************************************/
 
-static void NCDFUnloadDriver(GDALDriver* poDriver)
+static void NCDFUnloadDriver(CPL_UNUSED GDALDriver* poDriver)
 {
     if( hNCMutex != NULL )
         CPLDestroyMutex(hNCMutex);
@@ -5914,6 +5913,10 @@ void GDALRegister_netCDF()
 
         GetGDALDriverManager( )->RegisterDriver( poDriver );
     }
+
+#ifdef NETCDF_PLUGIN
+    GDALRegister_GMT();
+#endif
 }
 
 /************************************************************************/
@@ -7036,4 +7039,3 @@ char **NCDFTokenizeArray( const char *pszValue )
     
     return papszValues;
 }
-
diff --git a/frmts/nitf/nitffile.c b/frmts/nitf/nitffile.c
index 2909904..ed7bce0 100644
--- a/frmts/nitf/nitffile.c
+++ b/frmts/nitf/nitffile.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: nitffile.c 27731 2014-09-24 07:58:14Z rouault $
+ * $Id: nitffile.c 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  NITF Read/Write Library
  * Purpose:  Module responsible for opening NITF file, populating NITFFile
@@ -34,7 +34,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: nitffile.c 27731 2014-09-24 07:58:14Z rouault $");
+CPL_CVSID("$Id: nitffile.c 27739 2014-09-25 18:49:52Z goatbar $");
 
 static int NITFWriteBLOCKA( VSILFILE* fp, vsi_l_offset nOffsetUDIDL,
                             int *pnOffset,
@@ -1366,7 +1366,7 @@ static int NITFWriteBLOCKA( VSILFILE* fp, vsi_l_offset nOffsetUDIDL,
             int  iSize = atoi(apszFields[iField*3+2]);
             const char *pszValue;
 
-            sprintf( szFullFieldName, "BLOCKA_%s_%02d", 
+            sprintf( szFullFieldName, "BLOCKA_%s_%02d",
                      apszFields[iField*3 + 0], iBlock );
 
             pszValue = CSLFetchNameValue( papszOptions, szFullFieldName );
@@ -1383,11 +1383,13 @@ static int NITFWriteBLOCKA( VSILFILE* fp, vsi_l_offset nOffsetUDIDL,
 
             /* Right align value and left pad with spaces */
             memset( szBLOCKA + iStart, ' ', iSize );
-            memcpy( szBLOCKA + iStart + MAX((size_t)0,iSize-strlen(pszValue)),
+            /* unsigned is always >= 0 */
+            /* memcpy( szBLOCKA + iStart + MAX((size_t)0,iSize-strlen(pszValue)), */
+            memcpy( szBLOCKA + iStart + iSize-strlen(pszValue),
                     pszValue, strlen(pszValue) );
         }
 
-        // required field - semantics unknown. 
+        // required field - semantics unknown.
         memcpy( szBLOCKA + 118, "010.0", 5);
 
         if( !NITFWriteTRE( fp,
@@ -1396,10 +1398,10 @@ static int NITFWriteBLOCKA( VSILFILE* fp, vsi_l_offset nOffsetUDIDL,
                            "BLOCKA", szBLOCKA, 123 ) )
             return FALSE;
     }
-    
+
     return TRUE;
 }
-                      
+
 /************************************************************************/
 /*                       NITFCollectSegmentInfo()                       */
 /*                                                                      */
@@ -2587,7 +2589,7 @@ char **NITFGenericMetadataReadTRE(char **papszMD,
                                   int nTRESize,
                                   CPLXMLNode* psTreNode)
 {
-    int nTreLength, nTreMinLength = -1, nTreMaxLength = -1;
+    int nTreLength, nTreMinLength = -1 /*, nTreMaxLength = -1 */;
     int bError = FALSE;
     int nTreOffset = 0;
     const char* pszMDPrefix;
@@ -2595,7 +2597,7 @@ char **NITFGenericMetadataReadTRE(char **papszMD,
 
     nTreLength = atoi(CPLGetXMLValue(psTreNode, "length", "-1"));
     nTreMinLength = atoi(CPLGetXMLValue(psTreNode, "minlength", "-1"));
-    nTreMaxLength = atoi(CPLGetXMLValue(psTreNode, "maxlength", "-1"));
+    /* nTreMaxLength = atoi(CPLGetXMLValue(psTreNode, "maxlength", "-1")); */
 
     if( (nTreLength > 0 && nTRESize != nTreLength) ||
         (nTreMinLength > 0 && nTRESize < nTreMinLength) )
@@ -2711,7 +2713,7 @@ CPLXMLNode* NITFCreateXMLTre(NITFFile* psFile,
                              const char *pachTRE,
                              int nTRESize)
 {
-    int nTreLength, nTreMinLength = -1, nTreMaxLength = -1;
+    int nTreLength, nTreMinLength = -1 /* , nTreMaxLength = -1 */;
     int bError = FALSE;
     int nTreOffset = 0;
     CPLXMLNode* psTreNode;
@@ -2731,7 +2733,7 @@ CPLXMLNode* NITFCreateXMLTre(NITFFile* psFile,
 
     nTreLength = atoi(CPLGetXMLValue(psTreNode, "length", "-1"));
     nTreMinLength = atoi(CPLGetXMLValue(psTreNode, "minlength", "-1"));
-    nTreMaxLength = atoi(CPLGetXMLValue(psTreNode, "maxlength", "-1"));
+    /* nTreMaxLength = atoi(CPLGetXMLValue(psTreNode, "maxlength", "-1")); */
 
     if( (nTreLength > 0 && nTRESize != nTreLength) ||
         (nTreMinLength > 0 && nTRESize < nTreMinLength) )
diff --git a/frmts/nitf/nitfimage.c b/frmts/nitf/nitfimage.c
index c1bef04..854f7e9 100644
--- a/frmts/nitf/nitfimage.c
+++ b/frmts/nitf/nitfimage.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: nitfimage.c 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: nitfimage.c 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  NITF Read/Write Library
  * Purpose:  Module responsible for implementation of most NITFImage 
@@ -36,7 +36,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: nitfimage.c 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: nitfimage.c 27739 2014-09-25 18:49:52Z goatbar $");
 
 static int NITFReadIMRFCA( NITFImage *psImage, NITFRPC00BInfo *psRPC );
 static char *NITFTrimWhite( char * );
@@ -282,15 +282,15 @@ NITFImage *NITFImageAccess( NITFFile *psFile, int iSegment )
             }
             else if( psImage->chICORDS == 'G' || psImage->chICORDS == 'C' )
             {
-                pdfXY[1] = 
-                    atof(NITFGetField( szTemp, pszCoordPair, 0, 2 )) 
+                pdfXY[1] =
+                    atof(NITFGetField( szTemp, pszCoordPair, 0, 2 ))
                   + atof(NITFGetField( szTemp, pszCoordPair, 2, 2 )) / 60.0
                   + atof(NITFGetField( szTemp, pszCoordPair, 4, 2 )) / 3600.0;
                 if( pszCoordPair[6] == 's' || pszCoordPair[6] == 'S' )
                     pdfXY[1] *= -1;
 
-                pdfXY[0] = 
-                    atof(NITFGetField( szTemp, pszCoordPair, 7, 3 )) 
+                pdfXY[0] =
+                    atof(NITFGetField( szTemp, pszCoordPair, 7, 3 ))
                   + atof(NITFGetField( szTemp, pszCoordPair,10, 2 )) / 60.0
                   + atof(NITFGetField( szTemp, pszCoordPair,12, 2 )) / 3600.0;
 
@@ -301,17 +301,17 @@ NITFImage *NITFImageAccess( NITFFile *psFile, int iSegment )
             {  /* 'D' is Decimal Degrees */
                 pdfXY[1] = atof(NITFGetField( szTemp, pszCoordPair, 0, 7 ));
                 pdfXY[0] = atof(NITFGetField( szTemp, pszCoordPair, 7, 8 ));
-            }      
+            }
             else if( psImage->chICORDS == 'U' )
             {
-                int err;
+                /* int err; */
                 long nZone;
                 char chHemisphere;
                 NITFGetField( szTemp, pszCoordPair, 0, 15 );
-                
+
                 CPLDebug( "NITF", "IGEOLO = %15.15s", pszCoordPair );
-                err = Convert_MGRS_To_UTM( szTemp, &nZone, &chHemisphere,
-                                           pdfXY+0, pdfXY+1 );
+                /* err = */ Convert_MGRS_To_UTM( szTemp, &nZone, &chHemisphere,
+                                                 pdfXY+0, pdfXY+1 );
 
                 if( chHemisphere == 'S' )
                     nZone = -1 * nZone;
@@ -2751,7 +2751,7 @@ static void NITFLoadAttributeSection( NITFImage *psImage )
 
 {
     int i;
-    GUInt32 nASHOffset=0, nASHSize=0, nASSOffset=0, nASSSize=0, nNextOffset=0;
+    GUInt32 nASHOffset=0, /* nASHSize=0, */ nASSOffset=0, nASSSize=0, nNextOffset=0;
     GInt16 nAttrCount;
     GByte *pabyAttributeSubsection;
     GByte abyBuffer[128];
@@ -2761,7 +2761,7 @@ static void NITFLoadAttributeSection( NITFImage *psImage )
         if( psImage->pasLocations[i].nLocId == LID_AttributeSectionSubheader )
         {
             nASHOffset = psImage->pasLocations[i].nLocOffset;
-            nASHSize = psImage->pasLocations[i].nLocSize;
+            /* nASHSize = psImage->pasLocations[i].nLocSize; */
         }
         else if( psImage->pasLocations[i].nLocId == LID_AttributeSubsection )
         {
@@ -2781,7 +2781,6 @@ static void NITFLoadAttributeSection( NITFImage *psImage )
 
     CPL_MSBPTR16( &nAttrCount );
 
-    
 /* -------------------------------------------------------------------- */
 /*      nASSSize Hack                                                   */
 /* -------------------------------------------------------------------- */
@@ -2888,45 +2887,43 @@ static void NITFLoadColormapSubSection( NITFImage *psImage )
 {
     int nLocBaseColorGrayscaleSection = 0;
     int nLocBaseColormapSubSection = 0;
-    int colorGrayscaleSectionSize = 0;
-    int colormapSubSectionSize = 0;
+    /* int colorGrayscaleSectionSize = 0; */
+    /* int colormapSubSectionSize = 0; */
     NITFFile *psFile = psImage->psFile;
     unsigned int i, j;
     unsigned char nOffsetRecs;
     NITFColormapRecord* colormapRecords;
     unsigned int colormapOffsetTableOffset;
     unsigned short offsetRecLen;
-    
+
     NITFBandInfo *psBandInfo = psImage->pasBandInfo;
-  
+
     for( i = 0; (int)i < psImage->nLocCount; i++ )
     {
         if( psImage->pasLocations[i].nLocId == LID_ColorGrayscaleSectionSubheader )
         {
             nLocBaseColorGrayscaleSection = psImage->pasLocations[i].nLocOffset;
-            colorGrayscaleSectionSize = psImage->pasLocations[i].nLocSize;
+            /* colorGrayscaleSectionSize = psImage->pasLocations[i].nLocSize; */
         }
         else if( psImage->pasLocations[i].nLocId == LID_ColormapSubsection )
         {
             nLocBaseColormapSubSection = psImage->pasLocations[i].nLocOffset;
-            colormapSubSectionSize = psImage->pasLocations[i].nLocSize;
+            /* colormapSubSectionSize = psImage->pasLocations[i].nLocSize; */
         }
     }
     if (nLocBaseColorGrayscaleSection == 0)
     {
-        //fprintf(stderr, "nLocBaseColorGrayscaleSection == 0\n");
         return;
     }
     if (nLocBaseColormapSubSection == 0)
     {
-        //fprintf(stderr, "nLocBaseColormapSubSection == 0\n");
         return;
     }
-    
-    if( VSIFSeekL( psFile->fp, nLocBaseColorGrayscaleSection, 
+
+    if( VSIFSeekL( psFile->fp, nLocBaseColorGrayscaleSection,
                   SEEK_SET ) != 0 )
     {
-        CPLError( CE_Failure, CPLE_FileIO, 
+        CPLError( CE_Failure, CPLE_FileIO,
                   "Failed to seek to %d.",
                   nLocBaseColorGrayscaleSection );
         return;
@@ -3134,12 +3131,12 @@ static GUInt32 NITFReadMSBGUInt32(VSILFILE* fp, int* pbSuccess)
 
 NITFLocation* NITFReadRPFLocationTable(VSILFILE* fp, int* pnLocCount)
 {
-    GUInt16 nLocSectionLength;
+    /* GUInt16 nLocSectionLength; */
     GUInt32 nLocSectionOffset;
     GUInt16 iLoc;
     GUInt16 nLocCount;
     GUInt16 nLocRecordLength;
-    GUInt32 nLocComponentAggregateLength;
+    /* GUInt32 nLocComponentAggregateLength; */
     NITFLocation* pasLocations = NULL;
     int bSuccess;
     GUIntBig nCurOffset;
@@ -3152,7 +3149,7 @@ NITFLocation* NITFReadRPFLocationTable(VSILFILE* fp, int* pnLocCount)
     nCurOffset = VSIFTellL(fp);
 
     bSuccess = TRUE;
-    nLocSectionLength = NITFReadMSBGUInt16(fp, &bSuccess);
+    /* nLocSectionLength = */ NITFReadMSBGUInt16(fp, &bSuccess);
     nLocSectionOffset = NITFReadMSBGUInt32(fp, &bSuccess);
     if (nLocSectionOffset != 14)
     {
@@ -3174,7 +3171,7 @@ NITFLocation* NITFReadRPFLocationTable(VSILFILE* fp, int* pnLocCount)
         return NULL;
     }
 
-    nLocComponentAggregateLength = NITFReadMSBGUInt32(fp, &bSuccess);
+    /* nLocComponentAggregateLength = */ NITFReadMSBGUInt32(fp, &bSuccess);
 
     VSIFSeekL(fp, nCurOffset + nLocSectionOffset, SEEK_SET);
 
@@ -3344,7 +3341,7 @@ static int NITFLoadVQTables( NITFImage *psImage, int bTryGuessingOffset )
 
 {
     int     i;
-    GUInt32 nVQOffset=0, nVQSize=0;
+    GUInt32 nVQOffset=0 /*, nVQSize=0 */;
     GByte abyTestChunk[1000];
     GByte abySignature[6];
 
@@ -3362,7 +3359,7 @@ static int NITFLoadVQTables( NITFImage *psImage, int bTryGuessingOffset )
         if( psImage->pasLocations[i].nLocId == LID_CompressionLookupSubsection)
         {
             nVQOffset = psImage->pasLocations[i].nLocOffset;
-            nVQSize = psImage->pasLocations[i].nLocSize;
+            /* nVQSize = psImage->pasLocations[i].nLocSize; */
         }
     }
 
@@ -3656,12 +3653,12 @@ static int NITFDoLinesIntersect( double dfL1X1, double dfL1Y1,
         dfL2M = 1e10;
         dfL2B = 0.0;
     }
-    else 
+    else
     {
         dfL2M = (dfL2Y2 - dfL2Y1 ) / (dfL2X2 - dfL2X1);
         dfL2B = dfL2Y2 - dfL2M * dfL2X2;
     }
-    
+
     if( dfL2M == dfL1M )
     {
         // parallel .. no meaningful intersection.
@@ -3669,12 +3666,12 @@ static int NITFDoLinesIntersect( double dfL1X1, double dfL1Y1,
     }
     else
     {
-        double dfX, dfY;
-        
+        double dfX /*, dfY*/;
+
         dfX = (dfL2B - dfL1B) / (dfL1M-dfL2M);
-        dfY = dfL2M * dfX + dfL2B;
+        /* dfY = dfL2M * dfX + dfL2B; */
 
-        /* 
+        /*
         ** Is this intersection on the line between
         ** our corner points or "out somewhere" else?
         */
diff --git a/frmts/northwood/northwood.cpp b/frmts/northwood/northwood.cpp
index 71fed3e..c72806b 100644
--- a/frmts/northwood/northwood.cpp
+++ b/frmts/northwood/northwood.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: northwood.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: northwood.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GRC/GRD Reader
  * Purpose:  Northwood Format basic implementation
@@ -40,7 +40,7 @@ int nwt_ParseHeader( NWT_GRID * pGrd, char *nwtHeader )
 {
     int i;
     unsigned short usTmp;
-    double dfTmp;
+    /* double dfTmp; */
     unsigned char cTmp[256];
 
     if( nwtHeader[4] == '1' )
@@ -88,7 +88,7 @@ int nwt_ParseHeader( NWT_GRID * pGrd, char *nwtHeader )
     CPL_LSBPTR64(&pGrd->dfMaxY);
 
     pGrd->dfStepSize = (pGrd->dfMaxX - pGrd->dfMinX) / (pGrd->nXSide - 1);
-    dfTmp = (pGrd->dfMaxY - pGrd->dfMinY) / (pGrd->nYSide - 1);
+    /* dfTmp = (pGrd->dfMaxY - pGrd->dfMinY) / (pGrd->nYSide - 1); */
 
     memcpy( (void *) &pGrd->fZMin, (void *) &nwtHeader[45],
             sizeof(pGrd->fZMin) );
diff --git a/frmts/openjpeg/GNUmakefile b/frmts/openjpeg/GNUmakefile
index b32d0ef..9f90b1c 100644
--- a/frmts/openjpeg/GNUmakefile
+++ b/frmts/openjpeg/GNUmakefile
@@ -5,6 +5,10 @@ OBJ	=	openjpegdataset.o
 
 CPPFLAGS	:=	$(GDAL_INCLUDE) $(CPPFLAGS)
 
+ifneq ($(OPENJPEG_VERSION),)
+CPPFLAGS        :=      $(CPPFLAGS) -DOPENJPEG_VERSION=$(OPENJPEG_VERSION)
+endif
+
 default:	$(OBJ:.o=.$(OBJ_EXT))
 
 clean:
diff --git a/frmts/openjpeg/makefile.vc b/frmts/openjpeg/makefile.vc
index 40a2cdf..2ad929e 100644
--- a/frmts/openjpeg/makefile.vc
+++ b/frmts/openjpeg/makefile.vc
@@ -5,7 +5,11 @@ GDAL_ROOT	=	..\..
 
 !INCLUDE $(GDAL_ROOT)\nmake.opt
 
-EXTRAFLAGS = $(OPENJPEG_CFLAGS)
+EXTRAFLAGS = $(OPENJPEG_CFLAGS) $(OPENJPEG_VERSION_CFLAGS)
+
+!IFDEF OPENJPEG_VERSION
+OPENJPEG_VERSION_CFLAGS = -DOPENJPEG_VERSION=$(OPENJPEG_VERSION)
+!ENDIF
 
 default:	$(OBJ)
 	xcopy /D  /Y *.obj ..\o
diff --git a/frmts/openjpeg/openjpegdataset.cpp b/frmts/openjpeg/openjpegdataset.cpp
index 98ec8c0..1fd4f4f 100644
--- a/frmts/openjpeg/openjpegdataset.cpp
+++ b/frmts/openjpeg/openjpegdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: openjpegdataset.cpp 27373 2014-05-21 12:14:37Z rouault $
+ * $Id: openjpegdataset.cpp 28317 2015-01-15 22:49:41Z tamas $
  *
  * Project:  JPEG2000 driver based on OpenJPEG library
  * Purpose:  JPEG2000 driver based on OpenJPEG library
@@ -29,8 +29,12 @@
 
 /* This file is to be used with openjpeg 2.0 */
 
+#if defined(OPENJPEG_VERSION) && OPENJPEG_VERSION >= 20100
+#include <openjpeg-2.1/openjpeg.h>
+#else
 #include <stdio.h> /* openjpeg.h needs FILE* */
 #include <openjpeg-2.0/openjpeg.h>
+#endif
 #include <vector>
 
 #include "gdaljp2abstractdataset.h"
@@ -39,7 +43,7 @@
 #include "cpl_multiproc.h"
 #include "cpl_atomic_ops.h"
 
-CPL_CVSID("$Id: openjpegdataset.cpp 27373 2014-05-21 12:14:37Z rouault $");
+CPL_CVSID("$Id: openjpegdataset.cpp 28317 2015-01-15 22:49:41Z tamas $");
 
 /************************************************************************/
 /*                  JP2OpenJPEGDataset_ErrorCallback()                  */
@@ -612,7 +616,11 @@ CPLErr JP2OpenJPEGDataset::ReadBlock( int nBand, VSILFILE* fp,
     opj_stream_set_read_function(pStream, JP2OpenJPEGDataset_Read);
     opj_stream_set_seek_function(pStream, JP2OpenJPEGDataset_Seek);
     opj_stream_set_skip_function(pStream, JP2OpenJPEGDataset_Skip);
+#if defined(OPENJPEG_VERSION) && OPENJPEG_VERSION >= 20100
+    opj_stream_set_user_data(pStream, fp, NULL);
+#else
     opj_stream_set_user_data(pStream, fp);
+#endif
 
     if(!opj_read_header(pStream,pCodec,&psImage))
     {
@@ -950,7 +958,11 @@ GDALDataset *JP2OpenJPEGDataset::Open( GDALOpenInfo * poOpenInfo )
     opj_stream_set_read_function(pStream, JP2OpenJPEGDataset_Read);
     opj_stream_set_seek_function(pStream, JP2OpenJPEGDataset_Seek);
     opj_stream_set_skip_function(pStream, JP2OpenJPEGDataset_Skip);
+#if defined(OPENJPEG_VERSION) && OPENJPEG_VERSION >= 20100
+    opj_stream_set_user_data(pStream, fp, NULL);
+#else
     opj_stream_set_user_data(pStream, fp);
+#endif
 
     opj_image_t * psImage = NULL;
     OPJ_INT32  nX0,nY0;
@@ -1498,7 +1510,11 @@ GDALDataset * JP2OpenJPEGDataset::CreateCopy( const char * pszFilename,
     opj_stream_set_write_function(pStream, JP2OpenJPEGDataset_Write);
     opj_stream_set_seek_function(pStream, JP2OpenJPEGDataset_Seek);
     opj_stream_set_skip_function(pStream, JP2OpenJPEGDataset_Skip);
+#if defined(OPENJPEG_VERSION) && OPENJPEG_VERSION >= 20100
+    opj_stream_set_user_data(pStream, fp, NULL);
+#else
     opj_stream_set_user_data(pStream, fp);
+#endif
 
     if (!opj_start_compress(pCodec,psImage,pStream))
     {
diff --git a/frmts/pcidsk/sdk/channel/ctiledchannel.cpp b/frmts/pcidsk/sdk/channel/ctiledchannel.cpp
index 4c090e7..fcf2429 100644
--- a/frmts/pcidsk/sdk/channel/ctiledchannel.cpp
+++ b/frmts/pcidsk/sdk/channel/ctiledchannel.cpp
@@ -896,9 +896,6 @@ void CTiledChannel::JPEGDecompressBlock( PCIDSKBuffer &oCompressedData,
 
 void CTiledChannel::JPEGCompressBlock( PCIDSKBuffer &oDecompressedData,
                                        PCIDSKBuffer &oCompressedData )
-                                       
-
-                               
 {
     if( file->GetInterfaces()->JPEGCompressBlock == NULL )
         ThrowPCIDSKException( "JPEG compression not enabled in the PCIDSKInterfaces of this build." );
@@ -906,11 +903,13 @@ void CTiledChannel::JPEGCompressBlock( PCIDSKBuffer &oDecompressedData,
 /* -------------------------------------------------------------------- */
 /*      What quality should we be using?                                */
 /* -------------------------------------------------------------------- */
+#if 0
     int quality = 75;
 
-    if( compression.c_str()[4] >= '1' 
+    if( compression.c_str()[4] >= '1'
         && compression.c_str()[4] <= '0' )
         quality = atoi(compression.c_str() + 4);
+#endif
 
 /* -------------------------------------------------------------------- */
 /*      Make the output buffer plent big to hold any conceivable        */
@@ -921,9 +920,8 @@ void CTiledChannel::JPEGCompressBlock( PCIDSKBuffer &oDecompressedData,
 /* -------------------------------------------------------------------- */
 /*      invoke.                                                         */
 /* -------------------------------------------------------------------- */
-    file->GetInterfaces()->JPEGCompressBlock( 
+    file->GetInterfaces()->JPEGCompressBlock(
         (uint8 *) oDecompressedData.buffer, oDecompressedData.buffer_size,
         (uint8 *) oCompressedData.buffer, oCompressedData.buffer_size,
         GetBlockWidth(), GetBlockHeight(), GetType(), 75 );
 }
-
diff --git a/frmts/pcidsk/sdk/core/libjpeg_io.cpp b/frmts/pcidsk/sdk/core/libjpeg_io.cpp
index 2af2917..91cc2d6 100644
--- a/frmts/pcidsk/sdk/core/libjpeg_io.cpp
+++ b/frmts/pcidsk/sdk/core/libjpeg_io.cpp
@@ -3,7 +3,7 @@
  * Purpose:  Implementation of the JPEG compression/decompression based
  *           on libjpeg.  This implements functions suitable for use
  *           as jpeg interfaces in the PCIDSKInterfaces class.
- * 
+ *
  ******************************************************************************
  * Copyright (c) 2009
  * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada
@@ -34,6 +34,8 @@
 #include <cassert>
 #include <cstdio>
 
+#include "cpl_port.h"
+
 using namespace PCIDSK;
 
 #if defined(HAVE_LIBJPEG)
@@ -66,9 +68,8 @@ static void JpegError(j_common_ptr cinfo)
 /************************************************************************/
 
 void PCIDSK::LibJPEG_DecompressBlock(
-    uint8 *src_data, int src_bytes, uint8 *dst_data, int dst_bytes,
-    int xsize, int ysize, eChanType pixel_type )
-
+    uint8 *src_data, int src_bytes, uint8 *dst_data, CPL_UNUSED int dst_bytes,
+    int xsize, int ysize, eChanType CPL_UNUSED pixel_type )
 {
     struct jpeg_decompress_struct sJCompInfo;
     struct jpeg_source_mgr	sSrcMgr;
@@ -91,7 +92,7 @@ void PCIDSK::LibJPEG_DecompressBlock(
 
     sSrcMgr.next_input_byte = src_data;
     sSrcMgr.bytes_in_buffer = src_bytes;
-    
+
 /* -------------------------------------------------------------------- */
 /*      Setup JPEG Decompression                                        */
 /* -------------------------------------------------------------------- */
@@ -115,16 +116,14 @@ void PCIDSK::LibJPEG_DecompressBlock(
     }
 
     sJCompInfo.out_color_space = JCS_GRAYSCALE;
-
     jpeg_start_decompress(&sJCompInfo);
-    
+
 /* -------------------------------------------------------------------- */
 /*	Read each of the scanlines.					*/
 /* -------------------------------------------------------------------- */
     for( i = 0; i < ysize; i++ )
     {
         uint8	*line_data = dst_data + i*xsize;
-        
         jpeg_read_scanlines( &sJCompInfo, (JSAMPARRAY) &line_data, 1 );
     }
 
@@ -140,9 +139,8 @@ void PCIDSK::LibJPEG_DecompressBlock(
 /************************************************************************/
 
 void PCIDSK::LibJPEG_CompressBlock(
-    uint8 *src_data, int src_bytes, uint8 *dst_data, int &dst_bytes,
-    int xsize, int ysize, eChanType pixel_type, int quality )
-
+    uint8 *src_data, CPL_UNUSED int src_bytes, uint8 *dst_data, int &dst_bytes,
+    int xsize, int ysize, CPL_UNUSED eChanType pixel_type, int quality )
 {
     struct jpeg_compress_struct	sJCompInfo;
     struct jpeg_destination_mgr	sDstMgr;
@@ -159,7 +157,7 @@ void PCIDSK::LibJPEG_CompressBlock(
     sDstMgr.empty_output_buffer = (boolean (*)(j_compress_ptr))
         						_DummyMgrMethod;
     sDstMgr.term_destination = _DummyMgrMethod;
-    
+
 /* -------------------------------------------------------------------- */
 /*      Setup JPEG Compression                                          */
 /* -------------------------------------------------------------------- */
diff --git a/frmts/pcidsk/sdk/core/pcidskcreate.cpp b/frmts/pcidsk/sdk/core/pcidskcreate.cpp
index 12a85c7..ea574d9 100644
--- a/frmts/pcidsk/sdk/core/pcidskcreate.cpp
+++ b/frmts/pcidsk/sdk/core/pcidskcreate.cpp
@@ -82,13 +82,13 @@ PCIDSK::Create( std::string filename, int pixels, int lines,
         default_channel_types.resize( channel_count+1, CHN_8U );
         channel_types = &(default_channel_types[0]);
     }
-   
+
 /* -------------------------------------------------------------------- */
 /*      Validate parameters.                                            */
 /* -------------------------------------------------------------------- */
     const char *interleaving = NULL;
     std::string compression = "NONE";
-    bool nozero = false;
+    /* bool nozero = false; */
     bool nocreate = false;
     bool externallink = false;
     int  blocksize = 127;
@@ -116,11 +116,12 @@ PCIDSK::Create( std::string filename, int pixels, int lines,
         interleaving = "FILE";
     }
     else
-        ThrowPCIDSKException( "PCIDSK::Create() options '%s' not recognised.", 
+        ThrowPCIDSKException( "PCIDSK::Create() options '%s' not recognised.",
                               options.c_str() );
-
+#if 0
     if( strstr(options.c_str(),"NOZERO") != NULL )
         nozero = true;
+#endif
 
 /* -------------------------------------------------------------------- */
 /*      Validate the channel types.                                     */
diff --git a/frmts/pcidsk/sdk/segment/cpcidsk_array.cpp b/frmts/pcidsk/sdk/segment/cpcidsk_array.cpp
index 40e7d8f..656a27d 100644
--- a/frmts/pcidsk/sdk/segment/cpcidsk_array.cpp
+++ b/frmts/pcidsk/sdk/segment/cpcidsk_array.cpp
@@ -109,9 +109,10 @@ void CPCIDSK_ARRAY::Load()
     {
         nElements *= moSizes[i];
     }
-    
+
     for( unsigned int i = 0; i < nElements; i++ )
     {
+        /* TODO: Deal with strict-aliasing issue. */
         const double* pdValue = (const double*)seg_data.Get(i*8,8);
         char uValue[8];
         std::memcpy(uValue,pdValue,8);
@@ -122,10 +123,10 @@ void CPCIDSK_ARRAY::Load()
 
     //PCIDSK doesn't have support for headers.
 
-    // We've now loaded the structure up with data. Mark it as being loaded 
+    // We've now loaded the structure up with data. Mark it as being loaded
     // properly.
     loaded_ = true;
-    
+
 }
 
 /**
@@ -331,4 +332,3 @@ void CPCIDSK_ARRAY::SetHeaders(const std::vector<std::string>& oHeaders)
     moHeaders = oHeaders;
     mbModified = true;
 }
-
diff --git a/frmts/pcidsk/sdk/segment/cpcidskbitmap.cpp b/frmts/pcidsk/sdk/segment/cpcidskbitmap.cpp
index 1796007..e30ebc3 100644
--- a/frmts/pcidsk/sdk/segment/cpcidskbitmap.cpp
+++ b/frmts/pcidsk/sdk/segment/cpcidskbitmap.cpp
@@ -35,6 +35,8 @@
 #include <cstdio>
 #include <cctype>
 
+#include "cpl_port.h"
+
 using namespace PCIDSK;
 
 /************************************************************************/
@@ -315,10 +317,10 @@ int CPCIDSKBitmap::WriteBlock( int block_index, void *buffer )
     else
     {
         uint64 short_block_size;
-        
-        short_block_size = 
+
+        short_block_size =
             ((height - block_index*block_height) * block_width + 7) / 8;
-        
+
         WriteToFile( buffer, block_size * block_index, short_block_size );
     }
 
@@ -330,7 +332,6 @@ int CPCIDSKBitmap::WriteBlock( int block_index, void *buffer )
 /************************************************************************/
 
 int CPCIDSKBitmap::GetOverviewCount()
-
 {
     return 0;
 }
@@ -339,10 +340,10 @@ int CPCIDSKBitmap::GetOverviewCount()
 /*                            GetOverview()                             */
 /************************************************************************/
 
-PCIDSKChannel *CPCIDSKBitmap::GetOverview( int i )
-
+PCIDSKChannel *CPCIDSKBitmap::GetOverview( CPL_UNUSED int i )
 {
-    ThrowPCIDSKException("Non-existant overview %d requested on bitmap segment."); 
+    // The %d is ignored in the exception.
+    ThrowPCIDSKException("Non-existant overview %d requested on bitmap segment.");
     return NULL;
 }
 
@@ -350,8 +351,7 @@ PCIDSKChannel *CPCIDSKBitmap::GetOverview( int i )
 /*                          IsOverviewValid()                           */
 /************************************************************************/
 
-bool CPCIDSKBitmap::IsOverviewValid( int i )
-
+bool CPCIDSKBitmap::IsOverviewValid( CPL_UNUSED int i )
 {
     return false;
 }
@@ -360,8 +360,7 @@ bool CPCIDSKBitmap::IsOverviewValid( int i )
 /*                       GetOverviewResampling()                        */
 /************************************************************************/
 
-std::string CPCIDSKBitmap::GetOverviewResampling( int i )
-
+std::string CPCIDSKBitmap::GetOverviewResampling( CPL_UNUSED int i )
 {
     return "";
 }
@@ -370,8 +369,7 @@ std::string CPCIDSKBitmap::GetOverviewResampling( int i )
 /*                        SetOverviewValidity()                         */
 /************************************************************************/
 
-void CPCIDSKBitmap::SetOverviewValidity( int i, bool validity )
-
+void CPCIDSKBitmap::SetOverviewValidity( CPL_UNUSED int i, CPL_UNUSED bool validity )
 {
 }
 
@@ -498,10 +496,9 @@ void CPCIDSKBitmap::GetChanInfo( std::string &filename, uint64 &image_offset,
 /*                            SetChanInfo()                             */
 /************************************************************************/
 
-void CPCIDSKBitmap::SetChanInfo( std::string filename, uint64 image_offset, 
-                                  uint64 pixel_offset, uint64 line_offset, 
-                                  bool little_endian )
-
+void CPCIDSKBitmap::SetChanInfo( CPL_UNUSED std::string filename, CPL_UNUSED uint64 image_offset,
+                                 CPL_UNUSED uint64 pixel_offset, CPL_UNUSED uint64 line_offset,
+                                 CPL_UNUSED bool little_endian )
 {
     ThrowPCIDSKException( "Attempt to SetChanInfo() on a bitmap." );
 }
@@ -510,9 +507,8 @@ void CPCIDSKBitmap::SetChanInfo( std::string filename, uint64 image_offset,
 /*                            GetEChanInfo()                            */
 /************************************************************************/
 void CPCIDSKBitmap::GetEChanInfo( std::string &filename, int &echannel,
-                                  int &exoff, int &eyoff, 
+                                  int &exoff, int &eyoff,
                                   int &exsize, int &eysize ) const
-    
 {
     echannel = 0;
     exoff = 0;
@@ -526,10 +522,9 @@ void CPCIDSKBitmap::GetEChanInfo( std::string &filename, int &echannel,
 /*                            SetEChanInfo()                            */
 /************************************************************************/
 
-void CPCIDSKBitmap::SetEChanInfo( std::string filename, int echannel,
-                                  int exoff, int eyoff, 
-                                  int exsize, int eysize )
-
+void CPCIDSKBitmap::SetEChanInfo( CPL_UNUSED std::string filename, CPL_UNUSED int echannel,
+                                  CPL_UNUSED int exoff, CPL_UNUSED int eyoff,
+                                  CPL_UNUSED int exsize, CPL_UNUSED int eysize )
 {
     ThrowPCIDSKException( "Attempt to SetEChanInfo() on a bitmap." );
 }
diff --git a/frmts/pcraster/libcsf/mopen.c b/frmts/pcraster/libcsf/mopen.c
index 46de10e..a89dc16 100644
--- a/frmts/pcraster/libcsf/mopen.c
+++ b/frmts/pcraster/libcsf/mopen.c
@@ -85,13 +85,13 @@ MAP  *Mopen(
  	M_ERROR(OPENFAILED);
  	goto error_notOpen;
  }
- 
- /*  check if file could be C.S.F.-file 
-  *   (at least 256 bytes long) 
+
+ /*  check if file could be C.S.F.-file
+  *   (at least 256 bytes long)
   *  otherwise the signature comparison will
   *  fail
   */
- 
+
  (void)fseek(m->fp,0L, SEEK_END);
  if (ftell(m->fp) < (long)ADDR_DATA)
  {
@@ -100,7 +100,10 @@ MAP  *Mopen(
  }
 
  (void)fseek(m->fp, 14+CSF_SIG_SPACE, SEEK_SET);
- (void)fread((void *)&s, sizeof(UINT4),(size_t)1,m->fp);
+ if (1 != fread((void *)&s, sizeof(UINT4),(size_t)1,m->fp))
+ {
+     fprintf(stderr, "WARNING: Unable to read ORD_OK in CSF.\n");
+ }
  if (s != ORD_OK) {
 	m->write = CsfWriteSwapped;
 	m->read  = CsfReadSwapped;
@@ -130,8 +133,14 @@ MAP  *Mopen(
  m->read((void *)&(m->raster.valueScale), sizeof(UINT2),(size_t)1,m->fp);
  m->read((void *)&(m->raster.cellRepr), sizeof(UINT2),(size_t)1,m->fp);
 
- (void)fread((void *)&(m->raster.minVal), sizeof(CSF_VAR_TYPE),(size_t)1,m->fp);
- (void)fread((void *)&(m->raster.maxVal), sizeof(CSF_VAR_TYPE),(size_t)1,m->fp);
+ if (0 != fread((void *)&(m->raster.minVal), sizeof(CSF_VAR_TYPE),(size_t)1,m->fp))
+ {
+     fprintf(stderr, "WARNING: Unable to read min val in CSF.\n");
+ }
+ if (0 != fread((void *)&(m->raster.maxVal), sizeof(CSF_VAR_TYPE),(size_t)1,m->fp))
+ {
+     fprintf(stderr, "WARNING: Unable to read max val in CSF.\n");
+ }
  if (s != ORD_OK) {
   CsfSwap((void *)&(m->raster.minVal), CELLSIZE(m->raster.cellRepr),(size_t)1);
   CsfSwap((void *)&(m->raster.maxVal), CELLSIZE(m->raster.cellRepr),(size_t)1);
diff --git a/frmts/pdf/GNUmakefile b/frmts/pdf/GNUmakefile
index cc506a4..ec632f1 100644
--- a/frmts/pdf/GNUmakefile
+++ b/frmts/pdf/GNUmakefile
@@ -29,7 +29,7 @@ endif
 
 $(O_OBJ):       pdfobject.h pdfio.h pdfcreatecopy.h
 
-CPPFLAGS	:=	$(GDAL_INCLUDE) $(CPPFLAGS) $(POPPLER_INC) $(PODOFO_INC) -I..
+CPPFLAGS	:=	$(GDAL_INCLUDE) $(CPPFLAGS) -I../vrt $(POPPLER_INC) $(PODOFO_INC)
 
 default:	$(OBJ:.o=.$(OBJ_EXT))
 
diff --git a/frmts/pdf/makefile.vc b/frmts/pdf/makefile.vc
index d46a6ba..30cc7eb 100644
--- a/frmts/pdf/makefile.vc
+++ b/frmts/pdf/makefile.vc
@@ -5,7 +5,7 @@ GDAL_ROOT	=	..\..
 
 !INCLUDE $(GDAL_ROOT)\nmake.opt
 
-EXTRAFLAGS = $(POPPLER_EXTRAFLAGS) $(PODOFO_EXTRAFLAGS) -I..
+EXTRAFLAGS = -I..\vrt $(POPPLER_EXTRAFLAGS) $(PODOFO_EXTRAFLAGS)
 
 !IFDEF POPPLER_ENABLED
 POPPLER_EXTRAFLAGS = $(POPPLER_CFLAGS) $(POPPLER_HAS_OPTCONTENT_FLAGS) $(POPPLER_BASE_STREAM_HAS_TWO_ARGS_FLAGS) $(POPPLER_0_20_OR_LATER_FLAGS) $(POPPLER_0_23_OR_LATER_FLAGS) -DHAVE_POPPLER
diff --git a/frmts/pdf/pdfcreatecopy.cpp b/frmts/pdf/pdfcreatecopy.cpp
index 85bba5e..7a977bd 100644
--- a/frmts/pdf/pdfcreatecopy.cpp
+++ b/frmts/pdf/pdfcreatecopy.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: pdfcreatecopy.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: pdfcreatecopy.cpp 27991 2014-11-21 09:09:00Z rouault $
  *
  * Project:  PDF driver
  * Purpose:  GDALDataset driver for PDF dataset.
@@ -39,7 +39,7 @@
 #include "cpl_error.h"
 #include "ogr_spatialref.h"
 #include "ogr_geometry.h"
-#include "vrt/vrtdataset.h"
+#include "vrtdataset.h"
 
 #include "pdfobject.h"
 
@@ -50,7 +50,7 @@
 /* Cf PDF reference v1.7, Appendix C, page 993 */
 #define MAXIMUM_SIZE_IN_UNITS   14400
 
-CPL_CVSID("$Id: pdfcreatecopy.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: pdfcreatecopy.cpp 27991 2014-11-21 09:09:00Z rouault $");
 
 #define PIXEL_TO_GEO_X(x,y) adfGeoTransform[0] + x * adfGeoTransform[1] + y * adfGeoTransform[2]
 #define PIXEL_TO_GEO_Y(x,y) adfGeoTransform[3] + x * adfGeoTransform[4] + y * adfGeoTransform[5]
@@ -2866,10 +2866,14 @@ int GDALPDFWriter::WriteOGRFeature(GDALPDFLayerDesc& osVectorDesc,
         {
             /*if (osLabelText[i] == '\n')
                 VSIFPrintfL(fp, ") Tj T* (");
-            else */if (osLabelText[i] >= 32 && osLabelText[i] <= 127)
-                VSIFPrintfL(fp, "%c", osLabelText[i]);
-            else
-                VSIFPrintfL(fp, "_");
+            else */
+
+            /* Tautology.  Always true. */
+            /* if (osLabelText[i] >= 32 && osLabelText[i] <= 127) { */
+            VSIFPrintfL(fp, "%c", osLabelText[i]);
+            /* } else {
+                   VSIFPrintfL(fp, "_");
+            } */
         }
         VSIFPrintfL(fp, ") Tj\n");
         VSIFPrintfL(fp, "ET\n");
@@ -3421,17 +3425,19 @@ int GDALPDFWriter::WriteMask(GDALDataset* poSrcDS,
 
     int bOnly0or255 = TRUE;
     int bOnly255 = TRUE;
-    int bOnly0 = TRUE;
+    /* int bOnly0 = TRUE; */
     int i;
     for(i=0;i<nReqXSize * nReqYSize;i++)
     {
         if (pabyMask[i] == 0)
             bOnly255 = FALSE;
         else if (pabyMask[i] == 255)
-            bOnly0 = FALSE;
+        {
+            /* bOnly0 = FALSE; */
+        }
         else
         {
-            bOnly0 = FALSE;
+            /* bOnly0 = FALSE; */
             bOnly255 = FALSE;
             bOnly0or255 = FALSE;
             break;
diff --git a/frmts/pdf/pdfdataset.cpp b/frmts/pdf/pdfdataset.cpp
index 03d41aa..116cb74 100644
--- a/frmts/pdf/pdfdataset.cpp
+++ b/frmts/pdf/pdfdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: pdfdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: pdfdataset.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  PDF driver
  * Purpose:  GDALDataset driver for PDF dataset.
@@ -55,7 +55,7 @@
 
 /* g++ -fPIC -g -Wall frmts/pdf/pdfdataset.cpp -shared -o gdal_PDF.so -Iport -Igcore -Iogr -L. -lgdal -lpoppler -I/usr/include/poppler */
 
-CPL_CVSID("$Id: pdfdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: pdfdataset.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 CPL_C_START
 void    GDALRegister_PDF(void);
@@ -1256,9 +1256,8 @@ PDFImageRasterBand::PDFImageRasterBand( PDFDataset *poDS, int nBand ) : PDFRaste
 /*                             IReadBlock()                             */
 /************************************************************************/
 
-CPLErr PDFImageRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
-                                  void * pImage )
-
+CPLErr PDFImageRasterBand::IReadBlock( int CPL_UNUSED nBlockXOff, int nBlockYOff,
+                                       void * pImage )
 {
     PDFDataset *poGDS = (PDFDataset *) poDS;
     CPLAssert(poGDS->poImageObj != NULL);
@@ -1597,7 +1596,7 @@ static void PDFDatasetErrorFunctionCommon(const CPLString& osError)
 }
 
 #ifdef POPPLER_0_20_OR_LATER
-static void PDFDatasetErrorFunction(void* userData, ErrorCategory eErrCatagory,
+static void PDFDatasetErrorFunction(CPL_UNUSED void* userData, CPL_UNUSED ErrorCategory eErrCatagory,
 #ifdef POPPLER_0_23_OR_LATER
                                     Goffset nPos,
 #else
@@ -2827,7 +2826,10 @@ GDALDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo )
                 if (pszUserPwd && EQUAL(pszUserPwd, "ASK_INTERACTIVE"))
                 {
                     printf( "Enter password (will be echo'ed in the console): " );
-                    fgets( szPassword, sizeof(szPassword), stdin );
+                    if (0 == fgets( szPassword, sizeof(szPassword), stdin ))
+                    {
+                      fprintf(stderr, "WARNING: Error getting password.\n");
+                    }
                     szPassword[sizeof(szPassword)-1] = 0;
                     char* sz10 = strchr(szPassword, '\n');
                     if (sz10)
@@ -3908,7 +3910,7 @@ int PDFDataset::ParseProjDict(GDALPDFDictionary* poProjDict)
 /* -------------------------------------------------------------------- */
     int bIsWGS84 = FALSE;
     int bIsNAD83 = FALSE;
-    int bIsNAD27 = FALSE;
+    /* int bIsNAD27 = FALSE; */
 
     GDALPDFObject* poDatum;
     if ((poDatum = poProjDict->Get("Datum")) != NULL)
@@ -3929,7 +3931,7 @@ int PDFDataset::ParseProjDict(GDALPDFDictionary* poProjDict)
             }
             else if (EQUAL(pszDatum, "NAS") || EQUALN(pszDatum, "NAS-", 4))
             {
-                bIsNAD27 = TRUE;
+                /* bIsNAD27 = TRUE; */
                 oSRS.SetWellKnownGeogCS("NAD27");
             }
             else if (EQUAL(pszDatum, "HEN")) /* HERAT North, Afghanistan */
@@ -5190,12 +5192,7 @@ CPL_UNUSED
 /*                       GDALPDFUnloadDriver()                          */
 /************************************************************************/
 
-static void GDALPDFUnloadDriver(
-#ifndef HAVE_POPPLER
-CPL_UNUSED
-#endif
-                                GDALDriver * poDriver
-)
+static void GDALPDFUnloadDriver(CPL_UNUSED GDALDriver * poDriver)
 {
 #ifdef HAVE_POPPLER
     if( hGlobalParamsMutex != NULL )
@@ -5305,4 +5302,3 @@ void GDALRegister_PDF()
         GetGDALDriverManager()->RegisterDriver( poDriver );
     }
 }
-
diff --git a/frmts/pds/isis3dataset.cpp b/frmts/pds/isis3dataset.cpp
index 0caef85..90d33a1 100644
--- a/frmts/pds/isis3dataset.cpp
+++ b/frmts/pds/isis3dataset.cpp
@@ -541,7 +541,7 @@ GDALDataset *ISIS3Dataset::Open( GDALOpenInfo * poOpenInfo )
 
     // Frank - may need to talk this over
     value = poDS->GetKeyword("IsisCube.Mapping.LatitudeType");
-    if (EQUAL( value, "\"Planetocentric\"" ))
+    if (EQUAL( value, "Planetocentric" ))
         bIsGeographic = FALSE; 
      
     //Set oSRS projection and parameters
diff --git a/frmts/postgisraster/postgisrasterdataset.cpp b/frmts/postgisraster/postgisrasterdataset.cpp
index 98d1cd7..b7ed352 100644
--- a/frmts/postgisraster/postgisrasterdataset.cpp
+++ b/frmts/postgisraster/postgisrasterdataset.cpp
@@ -3145,10 +3145,13 @@ char **PostGISRasterDataset::GetFileList()
 /********************************************************
  * \brief Create a copy of a PostGIS Raster dataset.
  ********************************************************/
-GDALDataset * 
-PostGISRasterDataset::CreateCopy( const char * pszFilename,
-    GDALDataset *poGSrcDS, int bStrict, char ** papszOptions, 
-    GDALProgressFunc pfnProgress, void * pProgressData ) 
+GDALDataset *
+PostGISRasterDataset::CreateCopy( CPL_UNUSED const char * pszFilename,
+                                  GDALDataset *poGSrcDS,
+                                  CPL_UNUSED int bStrict,
+                                  CPL_UNUSED char ** papszOptions,
+                                  CPL_UNUSED GDALProgressFunc pfnProgress,
+                                  CPL_UNUSED void * pProgressData )
 {
     char* pszSchema = NULL;
     char* pszTable = NULL;
@@ -3162,10 +3165,10 @@ PostGISRasterDataset::CreateCopy( const char * pszFilename,
     PGresult * poResult = NULL;
     CPLString osCommand;
     GBool bInsertSuccess;
-    
+
     if( poGSrcDS->GetDriver() != GDALGetDriverByName("PostGISRaster") )
     {
-        CPLError( CE_Failure, CPLE_NotSupported, 
+        CPLError( CE_Failure, CPLE_NotSupported,
             "PostGISRasterDataset::CreateCopy() only works on source "
             "datasets that are PostGISRaster" );
         return NULL;
@@ -3691,4 +3694,3 @@ void GDALRegister_PostGISRaster() {
         GetGDALDriverManager()->RegisterDriver(poDriver);
     }
 }
-
diff --git a/frmts/postgisraster/postgisrastertilerasterband.cpp b/frmts/postgisraster/postgisrastertilerasterband.cpp
index 5397bad..b14c7ed 100644
--- a/frmts/postgisraster/postgisrastertilerasterband.cpp
+++ b/frmts/postgisraster/postgisrastertilerasterband.cpp
@@ -86,16 +86,17 @@ GBool PostGISRasterTileRasterBand::IsCached()
 /*****************************************************
  * \brief Read a natural block of raster band data
  *****************************************************/
-CPLErr PostGISRasterTileRasterBand::IReadBlock(int nBlockXOff, 
-    int nBlockYOff, void * pImage)
+CPLErr PostGISRasterTileRasterBand::IReadBlock(CPL_UNUSED int nBlockXOff,
+                                               CPL_UNUSED int nBlockYOff,
+                                               void * pImage)
 {
     CPLString osCommand;
     PGresult * poResult = NULL;
     int nWKBLength = 0;
-    
+
     int nPixelSize = GDALGetDataTypeSize(eDataType)/8;
-    
-    PostGISRasterTileDataset * poRTDS = 
+
+    PostGISRasterTileDataset * poRTDS =
         (PostGISRasterTileDataset *)poDS;
         
     // Get by PKID
@@ -191,4 +192,3 @@ CPLErr PostGISRasterTileRasterBand::IReadBlock(int nBlockXOff,
 
     return eRet;
 }
-
diff --git a/frmts/raw/cpgdataset.cpp b/frmts/raw/cpgdataset.cpp
index 563d635..5ec2c9b 100644
--- a/frmts/raw/cpgdataset.cpp
+++ b/frmts/raw/cpgdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: cpgdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: cpgdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  Polarimetric Workstation
  * Purpose:  Convair PolGASP data (.img/.hdr format). 
@@ -32,7 +32,7 @@
 #include "ogr_spatialref.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: cpgdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: cpgdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void	GDALRegister_CPG(void);
@@ -465,7 +465,7 @@ GDALDataset* CPGDataset::InitializeType1Or2Dataset( const char *pszFilename )
     int nLines = 0, nSamples = 0;
     int nError = 0;
     int nNameLen = 0;
-    
+
     /* Parameters required for pseudo-geocoding.  GCPs map */
     /* slant range to ground range at 16 points.           */
     int iGeoParamsFound = 0, itransposed = 0;
@@ -473,7 +473,7 @@ GDALDataset* CPGDataset::InitializeType1Or2Dataset( const char *pszFilename )
     double dfsample_size = 0.0, dfsample_size_az = 0.0;
 
     /* Parameters in geogratis geocoded images */
-    int iUTMParamsFound = 0, iUTMZone=0, iCorner=0;
+    int iUTMParamsFound = 0, iUTMZone=0 /* , iCorner=0 */;
     double dfnorth = 0.0, dfeast = 0.0;
 
     char* pszWorkname = CPLStrdup(pszFilename);
@@ -520,7 +520,7 @@ GDALDataset* CPGDataset::InitializeType1Or2Dataset( const char *pszFilename )
                EQUAL(papszTokens[1],"corner") &&
                EQUALN(papszTokens[2],"Upper_Left",10) )
         {
-            iCorner = 0;
+            /* iCorner = 0; */
             iUTMParamsFound++;
         }  
         else if( EQUAL(papszTokens[0],"number_lines") )
@@ -1422,7 +1422,7 @@ CPLErr CPG_STOKESRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYO
 
 {
     int iPixel;
-    int m11, m12, m13, m14, m21, m22, m23, m24, step;
+    int m11, /* m12, */ m13, m14, /* m21, */ m22, m23, m24, step;
     int m31, m32, m33, m34, m41, m42, m43, m44;
     CPGDataset *poGDS = (CPGDataset *) poDS;
     float *M;
@@ -1434,7 +1434,7 @@ CPLErr CPG_STOKESRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYO
     eErr = poGDS->LoadStokesLine(nBlockYOff, bNativeOrder);
     if( eErr != CE_None )
         return eErr;
-    
+
     M = poGDS->padfStokesMatrix;
     pafLine = ( float * ) pImage;
 
@@ -1442,10 +1442,10 @@ CPLErr CPG_STOKESRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYO
     {
         step = 16;
         m11 = M11;
-        m12 = M12;
+        // m12 = M12;
         m13 = M13;
         m14 = M14;
-        m21 = M21;
+        // m21 = M21;
         m22 = M22;
         m23 = M23;
         m24 = M24;
@@ -1462,10 +1462,10 @@ CPLErr CPG_STOKESRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYO
     {
         step = 1;
         m11=0;
-        m12=nRasterXSize;
+        // m12=nRasterXSize;
         m13=nRasterXSize*2;
         m14=nRasterXSize*3;
-        m21=nRasterXSize*4;
+        // m21=nRasterXSize*4;
         m22=nRasterXSize*5;
         m23=nRasterXSize*6;
         m24=nRasterXSize*7;
@@ -1697,4 +1697,3 @@ void GDALRegister_CPG()
         GetGDALDriverManager()->RegisterDriver( poDriver );
     }
 }
-
diff --git a/frmts/raw/genbindataset.cpp b/frmts/raw/genbindataset.cpp
index 8f6a7b9..4381420 100644
--- a/frmts/raw/genbindataset.cpp
+++ b/frmts/raw/genbindataset.cpp
@@ -308,7 +308,7 @@ CPLErr GenBinBitRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYOf
     {
         for( iX = 0; iX < nBlockXSize; iX++, iBitOffset += nBits )
         {
-            ((GByte *) pImage)[iX] = 
+            ((GByte *) pImage)[iX] =
                 ((pabyBuffer[iBitOffset>>3]) >> (6-(iBitOffset&0x7)) & 0x3);
         }
     }
@@ -322,8 +322,9 @@ CPLErr GenBinBitRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYOf
                 ((GByte *) pImage)[iX] = (pabyBuffer[iBitOffset>>3]) & 0xf;
         }
     }
-    else
+    else {
         CPLAssert( FALSE );
+    }
 
     CPLFree( pabyBuffer );
 
diff --git a/frmts/raw/hkvdataset.cpp b/frmts/raw/hkvdataset.cpp
index 38e9cc2..109fde4 100644
--- a/frmts/raw/hkvdataset.cpp
+++ b/frmts/raw/hkvdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: hkvdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: hkvdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GView
  * Purpose:  Implementation of Atlantis HKV labelled blob support
@@ -34,7 +34,7 @@
 #include "ogr_spatialref.h"
 #include "atlsci_spheroid.h"
 
-CPL_CVSID("$Id: hkvdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: hkvdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void	GDALRegister_HKV(void);
@@ -1074,9 +1074,9 @@ void HKVDataset::ProcessGeoref( const char * pszFilename )
 /*      Do we have a recognised projection?                             */
 /* -------------------------------------------------------------------- */
     const char *pszProjName, *pszOriginLong, *pszSpheroidName;
-    double eq_radius, inv_flattening;
+    /* double eq_radius, inv_flattening; */
 
-    pszProjName = CSLFetchNameValue(papszGeoref, 
+    pszProjName = CSLFetchNameValue(papszGeoref,
                                     "projection.name");
     pszOriginLong = CSLFetchNameValue(papszGeoref, 
                                       "projection.origin_longitude");
@@ -1086,14 +1086,14 @@ void HKVDataset::ProcessGeoref( const char * pszFilename )
 
     if ((pszSpheroidName != NULL) && (hkvEllipsoids->SpheroidInList(pszSpheroidName)))
     {
-      eq_radius=hkvEllipsoids->GetSpheroidEqRadius(pszSpheroidName);
-      inv_flattening=hkvEllipsoids->GetSpheroidInverseFlattening(pszSpheroidName);
+      /* eq_radius=hkvEllipsoids->GetSpheroidEqRadius(pszSpheroidName); */
+      /* inv_flattening=hkvEllipsoids->GetSpheroidInverseFlattening(pszSpheroidName); */
     }
     else if (pszProjName != NULL)
     {
       CPLError(CE_Warning,CPLE_AppDefined,"Warning- unrecognized ellipsoid.  Using wgs-84 parameters.\n");
-      eq_radius=hkvEllipsoids->GetSpheroidEqRadius("wgs-84");
-      inv_flattening=hkvEllipsoids->GetSpheroidInverseFlattening("wgs-84");
+      /* eq_radius=hkvEllipsoids->GetSpheroidEqRadius("wgs-84"); */
+      /* inv_flattening=hkvEllipsoids->GetSpheroidInverseFlattening("wgs-84"); */
     }
 
     if( (pszProjName != NULL) && EQUAL(pszProjName,"utm") && (nGCPCount == 5) )
@@ -1405,26 +1405,27 @@ GDALDataset *HKVDataset::Open( GDALOpenInfo * poOpenInfo )
                        atof(CSLFetchNameValue(papszAttrib, "version")));
     else
       poDS->SetVersion(1.0);
-    
+
 /* -------------------------------------------------------------------- */
 /*      Figure out the datatype                                         */
 /* -------------------------------------------------------------------- */
     const char * pszEncoding;
     int          nSize = 1;
-    int          nPseudoBands;
+    /* int          nPseudoBands; */
     GDALDataType eType;
-   
+
     pszEncoding = CSLFetchNameValue(papszAttrib,"pixel.encoding");
     if( pszEncoding == NULL )
         pszEncoding = "{ *unsigned }";
-  
+
     if( CSLFetchNameValue(papszAttrib,"pixel.size") != NULL )
         nSize = atoi(CSLFetchNameValue(papszAttrib,"pixel.size"))/8;
-        
+#if 0
     if( bComplex )
         nPseudoBands = 2;
-    else 
+    else
         nPseudoBands = 1;
+#endif
 
     if( nSize == 1 )
         eType = GDT_Byte;
diff --git a/frmts/rs2/rs2dataset.cpp b/frmts/rs2/rs2dataset.cpp
index 3f6044c..b7daf1a 100644
--- a/frmts/rs2/rs2dataset.cpp
+++ b/frmts/rs2/rs2dataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: rs2dataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: rs2dataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  Polarimetric Workstation
  * Purpose:  Radarsat 2 - XML Products (product.xml) driver
@@ -32,7 +32,7 @@
 #include "cpl_minixml.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: rs2dataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: rs2dataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void    GDALRegister_RS2(void);
@@ -1226,35 +1226,36 @@ GDALDataset *RS2Dataset::Open( GDALOpenInfo * poOpenInfo )
         }
    
         if ( psMapProjection != NULL ) {
-            const char *pszProj = CPLGetXMLValue( 
+            const char *pszProj = CPLGetXMLValue(
                 psMapProjection, "mapProjectionDescriptor", "" );
             bool bUseProjInfo = FALSE;
 
-            CPLXMLNode *psUtmParams = 
+            CPLXMLNode *psUtmParams =
                 CPLGetXMLNode( psMapProjection,
                                "utmProjectionParameters" );
 
-            CPLXMLNode *psNspParams = 
+            CPLXMLNode *psNspParams =
                 CPLGetXMLNode( psMapProjection,
                                "nspProjectionParameters" );
-            
+
             if ((psUtmParams != NULL) && poDS->bHaveGeoTransform ) {
                 const char *pszHemisphere;
                 int utmZone;
-                double origEasting, origNorthing;
+                /* double origEasting, origNorthing; */
                 bool bNorth = TRUE;
 
                 utmZone = atoi(CPLGetXMLValue( psUtmParams, "utmZone", "" ));
                 pszHemisphere = CPLGetXMLValue( psUtmParams,
                                                 "hemisphere", "" );
-                origEasting = strtod(CPLGetXMLValue( psUtmParams, 
+#if 0
+                origEasting = strtod(CPLGetXMLValue( psUtmParams,
                                                      "mapOriginFalseEasting", "0.0" ), NULL);
-                origNorthing = strtod(CPLGetXMLValue( psUtmParams, 
+                origNorthing = strtod(CPLGetXMLValue( psUtmParams,
                                                       "mapOriginFalseNorthing", "0.0" ), NULL);
-
+#endif
                 if ( EQUALN(pszHemisphere,"southern",8) )
                     bNorth = FALSE;
-                
+
                 if (EQUALN(pszProj,"UTM",3)) {
                     oPrj.SetUTM(utmZone, bNorth);
                     bUseProjInfo = TRUE;
@@ -1530,4 +1531,3 @@ void GDALRegister_RS2()
         GetGDALDriverManager()->RegisterDriver( poDriver );
     }
 }
-
diff --git a/frmts/saga/sagadataset.cpp b/frmts/saga/sagadataset.cpp
index 66478df..fb10cb7 100644
--- a/frmts/saga/sagadataset.cpp
+++ b/frmts/saga/sagadataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: sagadataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: sagadataset.cpp 27741 2014-09-26 19:20:02Z goatbar $
  * Project:  SAGA GIS Binary Driver
  * Purpose:  Implements the SAGA GIS Binary Grid Format.
  * Author:   Volker Wichmann, wichmann at laserdata.at
@@ -37,7 +37,7 @@
 #include "gdal_pam.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: sagadataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: sagadataset.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 #ifndef INT_MAX
 # define INT_MAX 2147483647
@@ -995,7 +995,7 @@ GDALDataset *SAGADataset::Create( const char * pszFilename,
 
 GDALDataset *SAGADataset::CreateCopy( const char *pszFilename,
 				      GDALDataset *poSrcDS,
-				      int bStrict, char **papszOptions,
+				      int bStrict, CPL_UNUSED char **papszOptions,
 				      GDALProgressFunc pfnProgress,
 				      void *pProgressData )
 {
diff --git a/frmts/usgsdem/usgsdemdataset.cpp b/frmts/usgsdem/usgsdemdataset.cpp
index 1d08d79..f4bd939 100644
--- a/frmts/usgsdem/usgsdemdataset.cpp
+++ b/frmts/usgsdem/usgsdemdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: usgsdemdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: usgsdemdataset.cpp 28352 2015-01-23 18:48:38Z rouault $
  *
  * Project:  USGS DEM Driver
  * Purpose:  All reader for USGS DEM Reader
@@ -34,7 +34,7 @@
 #include "gdal_pam.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: usgsdemdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: usgsdemdataset.cpp 28352 2015-01-23 18:48:38Z rouault $");
 
 CPL_C_START
 void	GDALRegister_USGSDEM(void);
@@ -332,7 +332,7 @@ CPLErr USGSDEMRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, CPL_UNUSED int
 
 {
     double	dfYMin;
-    int		bad = FALSE;
+    /* int		bad = FALSE; */
     USGSDEMDataset *poGDS = (USGSDEMDataset *) poDS;
 
 /* -------------------------------------------------------------------- */
@@ -367,23 +367,23 @@ CPLErr USGSDEMRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, CPL_UNUSED int
 
     for( int i = 0; i < GetXSize(); i++)
     {
-        int	njunk, nCPoints, lygap;
-        double	djunk, dxStart, dyStart, dfElevOffset;
+        int	/* njunk, */ nCPoints, lygap;
+        double	/* djunk, dxStart, */ dyStart, dfElevOffset;
 
-        njunk = USGSDEMReadIntFromBuffer(&sBuffer);
-        njunk = USGSDEMReadIntFromBuffer(&sBuffer);
+        /* njunk = */ USGSDEMReadIntFromBuffer(&sBuffer);
+        /* njunk = */ USGSDEMReadIntFromBuffer(&sBuffer);
         nCPoints = USGSDEMReadIntFromBuffer(&sBuffer);
-        njunk = USGSDEMReadIntFromBuffer(&sBuffer);
+        /* njunk = */ USGSDEMReadIntFromBuffer(&sBuffer);
 
-        dxStart = USGSDEMReadDoubleFromBuffer(&sBuffer, 24);
+        /* dxStart = */ USGSDEMReadDoubleFromBuffer(&sBuffer, 24);
         dyStart = USGSDEMReadDoubleFromBuffer(&sBuffer, 24);
         dfElevOffset = USGSDEMReadDoubleFromBuffer(&sBuffer, 24);
-        djunk = USGSDEMReadDoubleFromBuffer(&sBuffer, 24);
-        djunk = USGSDEMReadDoubleFromBuffer(&sBuffer, 24);
+        /* djunk = */ USGSDEMReadDoubleFromBuffer(&sBuffer, 24);
+        /* djunk = */ USGSDEMReadDoubleFromBuffer(&sBuffer, 24);
 
         if( EQUALN(poGDS->pszProjection,"GEOGCS",6) )
             dyStart = dyStart / 3600.0;
-        
+
         lygap = (int)((dfYMin - dyStart)/poGDS->adfGeoTransform[5]+ 0.5);
 
         for (int j=lygap; j < (nCPoints+(int)lygap); j++)
@@ -398,19 +398,19 @@ CPLErr USGSDEMRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, CPL_UNUSED int
                 CPLFree(sBuffer.buffer);
                 return CE_Failure;
             }
-            
-            if (iY < 0 || iY >= GetYSize() )
-                bad = TRUE;
-            else if( nElev == USGSDEM_NODATA )
+
+            if (iY < 0 || iY >= GetYSize() ) {
+                /* bad = TRUE; */
+            } else if( nElev == USGSDEM_NODATA )
                 /* leave in output buffer as nodata */;
             else
             {
-                float fComputedElev = 
+                float fComputedElev =
                     (float)(nElev * poGDS->fVRes + dfElevOffset);
 
                 if( GetRasterDataType() == GDT_Int16 )
                 {
-                    ((GInt16 *) pImage)[i + iY*GetXSize()] = 
+                    ((GInt16 *) pImage)[i + iY*GetXSize()] =
                         (GInt16) fComputedElev;
                 }
                 else
@@ -495,7 +495,7 @@ int USGSDEMDataset::LoadFromFile(VSILFILE *InDem)
     int		nRow, nColumn;
     int		nVUnit, nGUnit;
     double 	dxdelta, dydelta;
-    double	dElevMax, dElevMin;
+    /* double	dElevMax, dElevMin; */
     int 	bNewFormat;
     int		nCoordSystem;
     int		nProfiles;
@@ -572,15 +572,15 @@ int USGSDEMDataset::LoadFromFile(VSILFILE *InDem)
         corners[i].x = DConvert(InDem, 24);
         corners[i].y = DConvert(InDem, 24);
     }
-    
+
     // find absolute extents of raw vales
     extent_min.x = MIN(corners[0].x, corners[1].x);
     extent_max.x = MAX(corners[2].x, corners[3].x);
     extent_min.y = MIN(corners[0].y, corners[3].y);
     extent_max.y = MAX(corners[1].y, corners[2].y);
 
-    dElevMin = DConvert(InDem, 48);
-    dElevMax = DConvert(InDem, 48);
+    /* dElevMin = */ DConvert(InDem, 48);
+    /* dElevMax = */ DConvert(InDem, 48);
 
     VSIFSeekL(InDem, 858, 0);
     nProfiles = ReadInt(InDem);
@@ -647,7 +647,16 @@ int USGSDEMDataset::LoadFromFile(VSILFILE *InDem)
     }
 
     if (nCoordSystem == 1)	// UTM
+    {
         sr.SetUTM( iUTMZone, TRUE );
+        if( nGUnit == 1 )
+        {
+            sr.SetLinearUnitsAndUpdateParameters( SRS_UL_US_FOOT, CPLAtof(SRS_UL_US_FOOT_CONV) );
+            char    szUTMName[128];
+            sprintf( szUTMName, "UTM Zone %d, Northern Hemisphere, us-ft", iUTMZone );
+            sr.SetNode( "PROJCS", szUTMName );
+        }
+    }
 
     else if (nCoordSystem == 2)	// state plane
     {
@@ -670,7 +679,7 @@ int USGSDEMDataset::LoadFromFile(VSILFILE *InDem)
         || nCoordSystem == 2 	   // State Plane
         || nCoordSystem == -9999 ) // unknown
     {
-        int	njunk;
+        /* int	njunk; */
         double  dxStart;
 
         // expand extents modulus the pixel size.
@@ -679,12 +688,12 @@ int USGSDEMDataset::LoadFromFile(VSILFILE *InDem)
 
         // Forceably compute X extents based on first profile and pixelsize.
         VSIFSeekL(InDem, nDataStartOffset, 0);
-        njunk = ReadInt(InDem);
-        njunk = ReadInt(InDem);
-        njunk = ReadInt(InDem);
-        njunk = ReadInt(InDem);
+        /* njunk = */ ReadInt(InDem);
+        /* njunk = */ ReadInt(InDem);
+        /* njunk = */ ReadInt(InDem);
+        /* njunk = */ ReadInt(InDem);
         dxStart = DConvert(InDem, 24);
-        
+
         nRasterYSize = (int) ((extent_max.y - extent_min.y)/dydelta + 1.5);
         nRasterXSize = nProfiles;
 
diff --git a/frmts/vrt/vrtdataset.cpp b/frmts/vrt/vrtdataset.cpp
index a1e3c0e..eeb9c18 100644
--- a/frmts/vrt/vrtdataset.cpp
+++ b/frmts/vrt/vrtdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: vrtdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: vrtdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  Virtual GDAL Datasets
  * Purpose:  Implementation of VRTDataset
@@ -33,7 +33,7 @@
 #include "cpl_minixml.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: vrtdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: vrtdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 /************************************************************************/
 /*                            VRTDataset()                             */
@@ -64,7 +64,7 @@ VRTDataset::VRTDataset( int nXSize, int nYSize )
     pszVRTPath = NULL;
 
     poMaskBand = NULL;
-    
+
     GDALRegister_VRT();
     poDriver = (GDALDriver *) GDALGetDriverByName( "VRT" );
 
@@ -631,23 +631,24 @@ GDALDataset *VRTDataset::Open( GDALOpenInfo * poOpenInfo )
     if( fp != NULL )
     {
         unsigned int nLength;
-     
+
         VSIFSeekL( fp, 0, SEEK_END );
         nLength = (int) VSIFTellL( fp );
         VSIFSeekL( fp, 0, SEEK_SET );
-        
-        nLength = MAX(0,nLength);
+
+        // Unsigned always >= 0.
+        // nLength = MAX(0, nLength);
         pszXML = (char *) VSIMalloc(nLength+1);
-        
+
         if( pszXML == NULL )
         {
             VSIFCloseL(fp);
-            CPLError( CE_Failure, CPLE_OutOfMemory, 
+            CPLError( CE_Failure, CPLE_OutOfMemory,
                       "Failed to allocate %d byte buffer to hold VRT xml file.",
                       nLength );
             return NULL;
         }
-        
+
         if( VSIFReadL( pszXML, 1, nLength, fp ) != nLength )
         {
             VSIFCloseL(fp);
@@ -657,7 +658,7 @@ GDALDataset *VRTDataset::Open( GDALOpenInfo * poOpenInfo )
                       nLength );
             return NULL;
         }
-        
+
         pszXML[nLength] = '\0';
 
         char* pszCurDir = CPLGetCurrentDir();
diff --git a/frmts/vrt/vrtsources.cpp b/frmts/vrt/vrtsources.cpp
index c335108..1968120 100644
--- a/frmts/vrt/vrtsources.cpp
+++ b/frmts/vrt/vrtsources.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: vrtsources.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: vrtsources.cpp 27957 2014-11-12 23:09:34Z rouault $
  *
  * Project:  Virtual GDAL Datasets
  * Purpose:  Implementation of VRTSimpleSource, VRTFuncSource and 
@@ -36,7 +36,7 @@
 
 #include <algorithm>
 
-CPL_CVSID("$Id: vrtsources.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: vrtsources.cpp 27957 2014-11-12 23:09:34Z rouault $");
 
 /************************************************************************/
 /* ==================================================================== */
@@ -901,7 +901,7 @@ VRTSimpleSource::RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
                                 nReqXOff, nReqYOff, nReqXSize, nReqYSize,
                                 ((unsigned char *) pData) 
                                 + nOutXOff * nPixelSpace
-                                + nOutYOff * nLineSpace, 
+                                + (size_t)nOutYOff * nLineSpace, 
                                 nOutXSize, nOutYSize, 
                                 eBufType, nPixelSpace, nLineSpace );
 
@@ -1093,7 +1093,7 @@ CPLErr VRTSimpleSource::DatasetRasterIO(
                            nReqXOff, nReqYOff, nReqXSize, nReqYSize,
                            ((unsigned char *) pData)
                            + nOutXOff * nPixelSpace
-                           + nOutYOff * nLineSpace,
+                           + (size_t)nOutYOff * nLineSpace,
                            nOutXSize, nOutYSize,
                            eBufType, nBandCount, panBandMap,
                            nPixelSpace, nLineSpace, nBandSpace );
@@ -1274,7 +1274,7 @@ VRTAveragedSource::RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
 
             pDstLocation = ((GByte *)pData) 
                 + nPixelSpace * iBufPixel
-                + nLineSpace * iBufLine;
+                + (size_t)nLineSpace * iBufLine;
 
             if( eBufType == GDT_Byte )
                 *pDstLocation = (GByte) MIN(255,MAX(0,dfOutputValue + 0.5));
@@ -1673,7 +1673,7 @@ VRTComplexSource::RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
     return RasterIOInternal(nReqXOff, nReqYOff, nReqXSize, nReqYSize,
                        ((GByte *)pData)
                             + nPixelSpace * nOutXOff
-                            + nLineSpace * nOutYOff,
+                            + (size_t)nLineSpace * nOutYOff,
                        nOutXSize, nOutYSize,
                        eBufType,
                        nPixelSpace, nLineSpace );
@@ -1755,7 +1755,7 @@ CPLErr VRTComplexSource::RasterIOInternal( int nReqXOff, int nReqYOff,
 
             pDstLocation = ((GByte *)pData)
                 + nPixelSpace * iX
-                + nLineSpace * iY;
+                + (size_t)nLineSpace * iY;
 
             if (pafData && !bIsComplex)
             {
diff --git a/frmts/webp/webpdataset.cpp b/frmts/webp/webpdataset.cpp
index 050f7c0..9e334f3 100644
--- a/frmts/webp/webpdataset.cpp
+++ b/frmts/webp/webpdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: webpdataset.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: webpdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL WEBP Driver
  * Purpose:  Implement GDAL WEBP Support based on libwebp
@@ -33,7 +33,7 @@
 #include "webp/decode.h"
 #include "webp/encode.h"
 
-CPL_CVSID("$Id: webpdataset.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: webpdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void    GDALRegister_WEBP(void);
@@ -101,8 +101,7 @@ class WEBPRasterBand : public GDALPamRasterBand
 /*                          WEBPRasterBand()                            */
 /************************************************************************/
 
-WEBPRasterBand::WEBPRasterBand( WEBPDataset *poDS, int nBand )
-
+WEBPRasterBand::WEBPRasterBand( WEBPDataset *poDS, CPL_UNUSED int nBand )
 {
     this->poDS = poDS;
 
@@ -116,9 +115,8 @@ WEBPRasterBand::WEBPRasterBand( WEBPDataset *poDS, int nBand )
 /*                             IReadBlock()                             */
 /************************************************************************/
 
-CPLErr WEBPRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
-                                  void * pImage )
-
+CPLErr WEBPRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYOff,
+                                   void * pImage )
 {
     WEBPDataset* poGDS = (WEBPDataset*) poDS;
 
diff --git a/frmts/xyz/xyzdataset.cpp b/frmts/xyz/xyzdataset.cpp
index 6b924a9..28d3ac4 100644
--- a/frmts/xyz/xyzdataset.cpp
+++ b/frmts/xyz/xyzdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: xyzdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: xyzdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  XYZ driver
  * Purpose:  GDALDataset driver for XYZ dataset.
@@ -31,7 +31,7 @@
 #include "cpl_string.h"
 #include "gdal_pam.h"
 
-CPL_CVSID("$Id: xyzdataset.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: xyzdataset.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 CPL_C_START
 void    GDALRegister_XYZ(void);
@@ -358,9 +358,10 @@ CPLErr XYZRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff, int nBlockYOff,
         if( idx + 1 == nRasterXSize )
             break;
     }
-    
-    if( poGDS->bSameNumberOfValuesPerLine )
+
+    if( poGDS->bSameNumberOfValuesPerLine ) {
         CPLAssert(poGDS->nDataLineNum == (nBlockYOff + 1) * nBlockXSize);
+    }
 
     nLastYOff = nBlockYOff;
 
@@ -1240,4 +1241,3 @@ void GDALRegister_XYZ()
         GetGDALDriverManager()->RegisterDriver( poDriver );
     }
 }
-
diff --git a/gcore/GNUmakefile b/gcore/GNUmakefile
index a5e19b6..c831914 100644
--- a/gcore/GNUmakefile
+++ b/gcore/GNUmakefile
@@ -10,7 +10,8 @@ OBJ	=	gdalopeninfo.o gdaldrivermanager.o gdaldriver.o gdaldataset.o \
 		gdalallvalidmaskband.o gdalnodatamaskband.o gdal_rpcimdio.o \
  		gdalproxydataset.o gdalproxypool.o gdaldefaultasync.o \
 		gdalnodatavaluesmaskband.o gdaldllmain.o gdalexif.o gdalclientserver.o \
-		gdalgeorefpamdataset.o gdaljp2abstractdataset.o gdalvirtualmem.o
+		gdalgeorefpamdataset.o gdaljp2abstractdataset.o gdalvirtualmem.o \
+		gdalrescaledalphaband.o
 
 # Enable the following if you want to use MITAB's code to convert
 # .tab coordinate systems into well known text.  But beware that linking
diff --git a/gcore/gdal_priv.h b/gcore/gdal_priv.h
index 3474688..34220ad 100644
--- a/gcore/gdal_priv.h
+++ b/gcore/gdal_priv.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdal_priv.h 27657 2014-09-10 07:21:17Z rouault $
+ * $Id: gdal_priv.h 27874 2014-10-17 18:36:22Z rouault $
  *
  * Name:     gdal_priv.h
  * Project:  GDAL Core
@@ -684,6 +684,26 @@ class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
 };
 
 /* ******************************************************************** */
+/*                         GDALRescaledAlphaBand                        */
+/* ******************************************************************** */
+
+class GDALRescaledAlphaBand : public GDALRasterBand
+{
+    GDALRasterBand *poParent;
+    void           *pTemp;
+
+  protected:
+    virtual CPLErr IReadBlock( int, int, void * );
+    virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
+                              void *, int, int, GDALDataType,
+                              int, int );
+
+  public:
+                GDALRescaledAlphaBand( GDALRasterBand * );
+    virtual     ~GDALRescaledAlphaBand();
+};
+
+/* ******************************************************************** */
 /*                              GDALDriver                              */
 /* ******************************************************************** */
 
diff --git a/gcore/gdal_version.h b/gcore/gdal_version.h
index 199c51b..e2d2fdd 100644
--- a/gcore/gdal_version.h
+++ b/gcore/gdal_version.h
@@ -6,7 +6,7 @@
 #ifndef GDAL_VERSION_MAJOR
 #  define GDAL_VERSION_MAJOR    1
 #  define GDAL_VERSION_MINOR    11
-#  define GDAL_VERSION_REV      1
+#  define GDAL_VERSION_REV      2
 #  define GDAL_VERSION_BUILD    0
 #endif
 
@@ -22,8 +22,8 @@
 #endif
 
 #ifndef GDAL_RELEASE_DATE
-#  define GDAL_RELEASE_DATE     20140924
+#  define GDAL_RELEASE_DATE     20150210
 #endif
 #ifndef GDAL_RELEASE_NAME
-#  define GDAL_RELEASE_NAME     "1.11.1"
+#  define GDAL_RELEASE_NAME     "1.11.2"
 #endif
diff --git a/gcore/gdalproxypool.cpp b/gcore/gdalproxypool.cpp
index e9d2421..79db267 100644
--- a/gcore/gdalproxypool.cpp
+++ b/gcore/gdalproxypool.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalproxypool.cpp 27723 2014-09-22 18:21:08Z goatbar $
+ * $Id: gdalproxypool.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL Core
  * Purpose:  A dataset and raster band classes that differ the opening of the
@@ -31,7 +31,7 @@
 #include "gdal_proxy.h"
 #include "cpl_multiproc.h"
 
-CPL_CVSID("$Id: gdalproxypool.cpp 27723 2014-09-22 18:21:08Z goatbar $");
+CPL_CVSID("$Id: gdalproxypool.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 /* We *must* share the same mutex as the gdaldataset.cpp file, as we are */
 /* doing GDALOpen() calls that can indirectly call GDALOpenShared() on */
@@ -255,8 +255,9 @@ GDALProxyPoolCacheEntry* GDALDatasetPool::_RefDataset(const char* pszFileName, G
         /* moves it to the top of the list */
         if (lastEntryWithZeroRefCount->prev)
             lastEntryWithZeroRefCount->prev->next = lastEntryWithZeroRefCount->next;
-        else
+        else {
             CPLAssert(0);
+        }
         if (lastEntryWithZeroRefCount->next)
             lastEntryWithZeroRefCount->next->prev = lastEntryWithZeroRefCount->prev;
         else
diff --git a/gcore/gdalrasterband.cpp b/gcore/gdalrasterband.cpp
index be758ef..a3c945c 100644
--- a/gcore/gdalrasterband.cpp
+++ b/gcore/gdalrasterband.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalrasterband.cpp 27723 2014-09-22 18:21:08Z goatbar $
+ * $Id: gdalrasterband.cpp 27858 2014-10-15 08:41:23Z rouault $
  *
  * Project:  GDAL Core
  * Purpose:  Base class for format specific band class implementation.  This
@@ -37,7 +37,7 @@
 #define TO_SUBBLOCK(x) ((x) >> 6)
 #define WITHIN_SUBBLOCK(x) ((x) & 0x3f)
 
-CPL_CVSID("$Id: gdalrasterband.cpp 27723 2014-09-22 18:21:08Z goatbar $");
+CPL_CVSID("$Id: gdalrasterband.cpp 27858 2014-10-15 08:41:23Z rouault $");
 
 /************************************************************************/
 /*                           GDALRasterBand()                           */
@@ -4554,12 +4554,21 @@ GDALRasterBand *GDALRasterBand::GetMaskBand()
         && (this == poDS->GetRasterBand(1)
             || this == poDS->GetRasterBand(2)
             || this == poDS->GetRasterBand(3))
-        && poDS->GetRasterBand(4)->GetColorInterpretation() == GCI_AlphaBand
-        && poDS->GetRasterBand(4)->GetRasterDataType() == GDT_Byte )
+        && poDS->GetRasterBand(4)->GetColorInterpretation() == GCI_AlphaBand )
     {
-        nMaskFlags = GMF_ALPHA | GMF_PER_DATASET;
-        poMask = poDS->GetRasterBand(4);
-        return poMask;
+        if( poDS->GetRasterBand(4)->GetRasterDataType() == GDT_Byte )
+        {
+            nMaskFlags = GMF_ALPHA | GMF_PER_DATASET;
+            poMask = poDS->GetRasterBand(4);
+            return poMask;
+        }
+        else if( poDS->GetRasterBand(4)->GetRasterDataType() == GDT_UInt16 )
+        {
+            nMaskFlags = GMF_ALPHA | GMF_PER_DATASET;
+            poMask = new GDALRescaledAlphaBand( poDS->GetRasterBand(4) );
+            bOwnMask = true;
+            return poMask;
+        }
     }
 
 /* -------------------------------------------------------------------- */
diff --git a/gcore/gdalrescaledalphaband.cpp b/gcore/gdalrescaledalphaband.cpp
new file mode 100644
index 0000000..a25a962
--- /dev/null
+++ b/gcore/gdalrescaledalphaband.cpp
@@ -0,0 +1,144 @@
+/******************************************************************************
+ * $Id: gdalrescaledalphaband.cpp 27858 2014-10-15 08:41:23Z rouault $
+ *
+ * Project:  GDAL Core
+ * Purpose:  Implementation of GDALRescaledAlphaBand, a class implementing
+ *           a band mask based from a non-GDT_Byte alpha band
+ * Author:   Even Rouault, <even dot rouault at spatialys dot com>
+ *
+ ******************************************************************************
+ * Copyright (c) 2014, Even Rouault <even dot rouault at spatialys dot com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ****************************************************************************/
+
+#include "gdal_priv.h"
+
+CPL_CVSID("$Id: gdalrescaledalphaband.cpp 27858 2014-10-15 08:41:23Z rouault $");
+
+/************************************************************************/
+/*                        GDALRescaledAlphaBand()                       */
+/************************************************************************/
+
+GDALRescaledAlphaBand::GDALRescaledAlphaBand( GDALRasterBand *poParent )
+
+{
+    CPLAssert(poParent->GetRasterDataType() == GDT_UInt16);
+
+    poDS = NULL;
+    nBand = 0;
+
+    nRasterXSize = poParent->GetXSize();
+    nRasterYSize = poParent->GetYSize();
+
+    eDataType = GDT_Byte;
+    poParent->GetBlockSize( &nBlockXSize, &nBlockYSize );
+
+    this->poParent = poParent;
+
+    pTemp = NULL;
+}
+
+/************************************************************************/
+/*                      ~GDALRescaledAlphaBand()                        */
+/************************************************************************/
+
+GDALRescaledAlphaBand::~GDALRescaledAlphaBand()
+
+{
+    VSIFree(pTemp);
+}
+
+/************************************************************************/
+/*                             IReadBlock()                             */
+/************************************************************************/
+
+CPLErr GDALRescaledAlphaBand::IReadBlock( int nXBlockOff, int nYBlockOff,
+                                         void * pImage )
+{
+    int nXSizeRequest = nBlockXSize;
+    if (nXBlockOff * nBlockXSize + nBlockXSize > nRasterXSize)
+        nXSizeRequest = nRasterXSize - nXBlockOff * nBlockXSize;
+    int nYSizeRequest = nBlockYSize;
+    if (nYBlockOff * nBlockYSize + nBlockYSize > nRasterYSize)
+        nYSizeRequest = nRasterYSize - nYBlockOff * nBlockYSize;
+
+    return IRasterIO(GF_Read, nXBlockOff * nBlockXSize, nYBlockOff * nBlockYSize,
+                     nXSizeRequest, nYSizeRequest, pImage,
+                     nXSizeRequest, nYSizeRequest, GDT_Byte,
+                     1, nBlockXSize);
+}
+
+/************************************************************************/
+/*                             IRasterIO()                              */
+/************************************************************************/
+
+CPLErr GDALRescaledAlphaBand::IRasterIO( GDALRWFlag eRWFlag,
+                                      int nXOff, int nYOff, int nXSize, int nYSize,
+                                      void * pData, int nBufXSize, int nBufYSize,
+                                      GDALDataType eBufType,
+                                      int nPixelSpace, int nLineSpace )
+{
+    /* Optimization in common use case */
+    /* This avoids triggering the block cache on this band, which helps */
+    /* reducing the global block cache consumption */
+    if (eRWFlag == GF_Read && eBufType == GDT_Byte &&
+        nXSize == nBufXSize && nYSize == nBufYSize &&
+        nPixelSpace == 1)
+    {
+        if( pTemp == NULL )
+        {
+            pTemp = VSIMalloc2( sizeof(GUInt16), nRasterXSize );
+            if (pTemp == NULL)
+            {
+                CPLError( CE_Failure, CPLE_OutOfMemory,
+                        "GDALRescaledAlphaBand::IReadBlock: Out of memory for buffer." );
+                return CE_Failure;
+            }
+        }
+        for(int j = 0; j < nBufYSize; j++ )
+        {
+            CPLErr eErr = poParent->RasterIO( GF_Read, nXOff, nYOff + j, nXSize, 1,
+                                              pTemp, nBufXSize, 1,
+                                              GDT_UInt16,
+                                              0, 0 );
+            if (eErr != CE_None)
+                return eErr;
+
+            GByte* pabyImage = ((GByte*) pData) + j * nLineSpace;
+            GUInt16* pSrc = (GUInt16 *)pTemp;
+
+            for( int i = 0; i < nBufXSize; i++ )
+            {
+                /* In case the dynamics was actually 0-255 and not 0-65535 as */
+                /* expected, we want to make sure non-zero alpha will still be non-zero */
+                if( pSrc[i] > 0 && pSrc[i] < 257 )
+                    pabyImage[i] = 1;
+                else
+                    pabyImage[i] = (pSrc[i] * 255) / 65535;
+            }
+        }
+        return CE_None;
+    }
+
+    return GDALRasterBand::IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize,
+                                      pData, nBufXSize, nBufYSize,
+                                      eBufType,
+                                      nPixelSpace, nLineSpace );
+}
diff --git a/gcore/gdalvirtualmem.cpp b/gcore/gdalvirtualmem.cpp
index 3e5484c..0f54653 100644
--- a/gcore/gdalvirtualmem.cpp
+++ b/gcore/gdalvirtualmem.cpp
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: gdalvirtualmem.cpp 27723 2014-09-22 18:21:08Z goatbar $
+ * $Id: gdalvirtualmem.cpp 27922 2014-11-05 13:01:30Z rouault $
  *
  * Name:     gdalvirtualmem.cpp
  * Project:  GDAL
@@ -1236,6 +1236,14 @@ static CPLVirtualMem* GDALGetTiledVirtualMem( GDALDatasetH hDS,
     GDALTiledVirtualMem* psParams;
     (void) papszOptions;
 
+    size_t nPageSize = CPLGetPageSize();
+    if( nPageSize == 0 )
+    {
+        CPLError(CE_Failure, CPLE_NotSupported,
+             "GDALGetTiledVirtualMem() unsupported on this operating system / configuration");
+        return NULL;
+    }
+
     int nRasterXSize = (hDS) ? GDALGetRasterXSize(hDS) : GDALGetRasterBandXSize(hBand);
     int nRasterYSize = (hDS) ? GDALGetRasterYSize(hDS) : GDALGetRasterBandYSize(hBand);
 
@@ -1266,7 +1274,7 @@ static CPLVirtualMem* GDALGetTiledVirtualMem( GDALDatasetH hDS,
     size_t nPageSizeHint = nTileXSize * nTileYSize * nDataTypeSize;
     if( eTileOrganization != GTO_BSQ )
         nPageSizeHint *= nBandCount;
-    if( (nPageSizeHint % CPLGetPageSize()) != 0 )
+    if( (nPageSizeHint % nPageSize) != 0 )
     {
         CPLError(CE_Failure, CPLE_AppDefined,
                  "Tile dimensions incompatible with page size");
diff --git a/gcore/makefile.vc b/gcore/makefile.vc
index 1ac9bde..bdaad65 100644
--- a/gcore/makefile.vc
+++ b/gcore/makefile.vc
@@ -11,7 +11,7 @@ OBJ	=	gdalopeninfo.obj gdaldrivermanager.obj gdaldriver.obj \
 		gdalnodatavaluesmaskband.obj gdaldefaultasync.obj \
 		gdaldllmain.obj gdalexif.obj gdalclientserver.obj \
 		gdalgeorefpamdataset.obj  gdaljp2abstractdataset.obj \
-		gdalvirtualmem.obj
+		gdalvirtualmem.obj gdalrescaledalphaband.obj
 
 RES	=	Version.res
 
diff --git a/gcore/overview.cpp b/gcore/overview.cpp
index 623c268..ad7d322 100644
--- a/gcore/overview.cpp
+++ b/gcore/overview.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: overview.cpp 27723 2014-09-22 18:21:08Z goatbar $
+ * $Id: overview.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  GDAL Core
  * Purpose:  Helper code to implement overview support in different drivers.
@@ -30,7 +30,7 @@
 
 #include "gdal_priv.h"
 
-CPL_CVSID("$Id: overview.cpp 27723 2014-09-22 18:21:08Z goatbar $");
+CPL_CVSID("$Id: overview.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 typedef CPLErr (*GDALDownsampleFunction)
                       ( int nSrcWidth, int nSrcHeight,
@@ -1032,7 +1032,7 @@ static CPLErr
 GDALDownsampleChunk32R_Cubic( int nSrcWidth, int nSrcHeight,
                               CPL_UNUSED GDALDataType eWrkDataType,
                               void * pChunk,
-                              GByte * pabyChunkNodataMask,
+                              CPL_UNUSED GByte * pabyChunkNodataMask,
                               int nChunkXOff, int nChunkXSize,
                               int nChunkYOff, int nChunkYSize,
                               GDALRasterBand * poOverview,
@@ -1110,7 +1110,7 @@ GDALDownsampleChunk32R_Cubic( int nSrcWidth, int nSrcHeight,
     for( int iDstLine = nDstYOff; iDstLine < nDstYOff2 && eErr == CE_None; iDstLine++ )
     {
         float *pafSrcScanline;
-        GByte *pabySrcScanlineNodataMask;
+        // GByte *pabySrcScanlineNodataMask;
         int   nSrcYOff, nSrcYOff2 = 0, iDstPixel;
 
         nSrcYOff = (int) floor(((iDstLine+0.5)/(double)nOYSize) * nSrcHeight - 0.5)-1;
@@ -1126,10 +1126,13 @@ GDALDownsampleChunk32R_Cubic( int nSrcWidth, int nSrcHeight,
             nSrcYOff2 = nChunkYOff + nChunkYSize;
 
         pafSrcScanline = pafChunk + ((nSrcYOff-nChunkYOff) * nChunkXSize);
+#if 0
+        // pabySrcScanlineNodataMask is unused.
         if (pabyChunkNodataMask != NULL)
             pabySrcScanlineNodataMask = pabyChunkNodataMask + ((nSrcYOff-nChunkYOff) * nChunkXSize);
         else
             pabySrcScanlineNodataMask = NULL;
+#endif
 
 /* -------------------------------------------------------------------- */
 /*      Loop over destination pixels                                    */
@@ -1730,8 +1733,9 @@ GDALRegenerateOverviews( GDALRasterBandH hSrcBand,
                         pabyChunk[i] = 255;
                 }
             }
-            else
+            else {
                 CPLAssert(0);
+            }
         }
         else if( EQUAL(pszResampling,"AVERAGE_BIT2GRAYSCALE_MINISWHITE") )
         {
@@ -1759,10 +1763,11 @@ GDALRegenerateOverviews( GDALRasterBandH hSrcBand,
                         pabyChunk[i] = 255;
                 }
             }
-            else
+            else {
                 CPLAssert(0);
+            }
         }
-        
+
         for( int iOverview = 0; iOverview < nOverviewCount && eErr == CE_None; iOverview++ )
         {
             if( eType == GDT_Byte || eType == GDT_Float32 )
diff --git a/gcore/rasterio.cpp b/gcore/rasterio.cpp
index f53337c..5c42baa 100644
--- a/gcore/rasterio.cpp
+++ b/gcore/rasterio.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: rasterio.cpp 27119 2014-04-03 18:48:27Z rouault $
+ * $Id: rasterio.cpp 27904 2014-10-23 23:42:29Z rouault $
  *
  * Project:  GDAL Core
  * Purpose:  Contains default implementation of GDALRasterBand::IRasterIO()
@@ -48,7 +48,7 @@
 #endif
 
 
-CPL_CVSID("$Id: rasterio.cpp 27119 2014-04-03 18:48:27Z rouault $");
+CPL_CVSID("$Id: rasterio.cpp 27904 2014-10-23 23:42:29Z rouault $");
 
 /************************************************************************/
 /*                             IRasterIO()                              */
@@ -296,11 +296,11 @@ CPLErr GDALRasterBand::IRasterIO( GDALRWFlag eRWFlag,
                         && nPixelSpace == nBufDataSize )
                     {
                         if( eRWFlag == GF_Read )
-                            memcpy( ((GByte *) pData) + iBufOffset + k * nLineSpace,
+                            memcpy( ((GByte *) pData) + iBufOffset + (size_t)k * nLineSpace,
                                     pabySrcBlock + iSrcOffset, nXSpanSize );
                         else
                             memcpy( pabySrcBlock + iSrcOffset, 
-                                    ((GByte *) pData) + iBufOffset + k * nLineSpace, nXSpanSize );
+                                    ((GByte *) pData) + iBufOffset + (size_t)k * nLineSpace, nXSpanSize );
                     }
                     else
                     {
@@ -309,10 +309,10 @@ CPLErr GDALRasterBand::IRasterIO( GDALRWFlag eRWFlag,
                         if( eRWFlag == GF_Read )
                             GDALCopyWords( pabySrcBlock + iSrcOffset,
                                         eDataType, nBandDataSize,
-                                        ((GByte *) pData) + iBufOffset + k * nLineSpace,
+                                        ((GByte *) pData) + iBufOffset + (size_t)k * nLineSpace,
                                         eBufType, nPixelSpace, nXSpan );
                         else
-                            GDALCopyWords( ((GByte *) pData) + iBufOffset + k * nLineSpace,
+                            GDALCopyWords( ((GByte *) pData) + iBufOffset + (size_t)k * nLineSpace,
                                         eBufType, nPixelSpace,
                                         pabySrcBlock + iSrcOffset,
                                         eDataType, nBandDataSize, nXSpan );
diff --git a/m4/ax_oracle_oci.m4 b/m4/ax_oracle_oci.m4
index 3f7da93..35f45dd 100644
--- a/m4/ax_oracle_oci.m4
+++ b/m4/ax_oracle_oci.m4
@@ -155,14 +155,15 @@ Please, locate Oracle directories using --with-oci or \
 
         dnl Depending on later Oracle version detection,
         dnl -lnnz10 flag might be removed for older Oracle < 10.x
-        saved_LDFLAGS="$LDFLAGS"
-	if test -n "$oracle_include_dir" ; then
+        if test -n "$oracle_include_dir" ; then
           oci_ldflags="-L$oracle_lib_dir -lclntsh"
         else
           oci_ldflags="-L$oracle_lib_dir -L$oracle_lib_dir2 -lclntsh"
         fi
-        LDFLAGS="$LDFLAGS $oci_ldflags"
 
+        saved_LIBS="$LIBS"
+        LIBS="$LIBS $oci_ldflags"
+        
         dnl
         dnl Check OCI headers
         dnl
@@ -244,7 +245,7 @@ if (envh) OCIHandleFree(envh, OCI_HTYPE_ENV);
         fi
 
         CPPFLAGS="$saved_CPPFLAGS"
-        LDFLAGS="$saved_LDFLAGS"
+        LIBS="$saved_LIBS"
     fi
 
     dnl
diff --git a/man/man1/gdal-config.1 b/man/man1/gdal-config.1
index 2ff10fa..a841b26 100644
--- a/man/man1/gdal-config.1
+++ b/man/man1/gdal-config.1
@@ -1,8 +1,8 @@
-.TH "gdal-config" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal-config" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal-config \- .TH "gdal-config" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal-config \- .TH "gdal-config" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal2tiles.1 b/man/man1/gdal2tiles.1
index 49905ea..4cde8bc 100644
--- a/man/man1/gdal2tiles.1
+++ b/man/man1/gdal2tiles.1
@@ -1,8 +1,8 @@
-.TH "gdal2tiles" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal2tiles" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal2tiles \- .TH "gdal2tiles" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal2tiles \- .TH "gdal2tiles" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_calc.1 b/man/man1/gdal_calc.1
index 991655e..330f091 100644
--- a/man/man1/gdal_calc.1
+++ b/man/man1/gdal_calc.1
@@ -1,8 +1,8 @@
-.TH "gdal_calc" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_calc" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_calc \- .TH "gdal_calc" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_calc \- .TH "gdal_calc" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_contour.1 b/man/man1/gdal_contour.1
index 5da197a..cf4ebea 100644
--- a/man/man1/gdal_contour.1
+++ b/man/man1/gdal_contour.1
@@ -1,8 +1,8 @@
-.TH "gdal_contour" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_contour" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_contour \- .TH "gdal_contour" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_contour \- .TH "gdal_contour" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_edit.1 b/man/man1/gdal_edit.1
index db9ac05..987e24d 100644
--- a/man/man1/gdal_edit.1
+++ b/man/man1/gdal_edit.1
@@ -1,8 +1,8 @@
-.TH "gdal_edit" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_edit" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_edit \- .TH "gdal_edit" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_edit \- .TH "gdal_edit" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_fillnodata.1 b/man/man1/gdal_fillnodata.1
index b95706c..32cb11e 100644
--- a/man/man1/gdal_fillnodata.1
+++ b/man/man1/gdal_fillnodata.1
@@ -1,8 +1,8 @@
-.TH "gdal_fillnodata" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_fillnodata" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_fillnodata \- .TH "gdal_fillnodata" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_fillnodata \- .TH "gdal_fillnodata" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_grid.1 b/man/man1/gdal_grid.1
index 3660469..1ff0d3e 100644
--- a/man/man1/gdal_grid.1
+++ b/man/man1/gdal_grid.1
@@ -1,8 +1,8 @@
-.TH "gdal_grid" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_grid" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_grid \- .TH "gdal_grid" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_grid \- .TH "gdal_grid" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_merge.1 b/man/man1/gdal_merge.1
index 2311d41..a85dec8 100644
--- a/man/man1/gdal_merge.1
+++ b/man/man1/gdal_merge.1
@@ -1,8 +1,8 @@
-.TH "gdal_merge" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_merge" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_merge \- .TH "gdal_merge" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_merge \- .TH "gdal_merge" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_polygonize.1 b/man/man1/gdal_polygonize.1
index 5f83663..36b72c2 100644
--- a/man/man1/gdal_polygonize.1
+++ b/man/man1/gdal_polygonize.1
@@ -1,8 +1,8 @@
-.TH "gdal_polygonize" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_polygonize" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_polygonize \- .TH "gdal_polygonize" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_polygonize \- .TH "gdal_polygonize" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_proximity.1 b/man/man1/gdal_proximity.1
index 80201d1..94abf12 100644
--- a/man/man1/gdal_proximity.1
+++ b/man/man1/gdal_proximity.1
@@ -1,8 +1,8 @@
-.TH "gdal_proximity" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_proximity" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_proximity \- .TH "gdal_proximity" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_proximity \- .TH "gdal_proximity" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_rasterize.1 b/man/man1/gdal_rasterize.1
index 3ff9410..0a9528f 100644
--- a/man/man1/gdal_rasterize.1
+++ b/man/man1/gdal_rasterize.1
@@ -1,8 +1,8 @@
-.TH "gdal_rasterize" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_rasterize" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_rasterize \- .TH "gdal_rasterize" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_rasterize \- .TH "gdal_rasterize" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_retile.1 b/man/man1/gdal_retile.1
index 85b6947..7434f8b 100644
--- a/man/man1/gdal_retile.1
+++ b/man/man1/gdal_retile.1
@@ -1,8 +1,8 @@
-.TH "gdal_retile" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_retile" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_retile \- .TH "gdal_retile" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_retile \- .TH "gdal_retile" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_sieve.1 b/man/man1/gdal_sieve.1
index ac86f6c..eca889c 100644
--- a/man/man1/gdal_sieve.1
+++ b/man/man1/gdal_sieve.1
@@ -1,8 +1,8 @@
-.TH "gdal_sieve" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_sieve" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_sieve \- .TH "gdal_sieve" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_sieve \- .TH "gdal_sieve" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_translate.1 b/man/man1/gdal_translate.1
index 449d92e..4b7ba64 100644
--- a/man/man1/gdal_translate.1
+++ b/man/man1/gdal_translate.1
@@ -1,8 +1,8 @@
-.TH "gdal_translate" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_translate" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_translate \- .TH "gdal_translate" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_translate \- .TH "gdal_translate" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_utilities.1 b/man/man1/gdal_utilities.1
index 6734492..f073f26 100644
--- a/man/man1/gdal_utilities.1
+++ b/man/man1/gdal_utilities.1
@@ -1,8 +1,8 @@
-.TH "gdal_utilities" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdal_utilities" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_utilities \- .TH "gdal_utilities" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdal_utilities \- .TH "gdal_utilities" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdaladdo.1 b/man/man1/gdaladdo.1
index 1246fa1..0667339 100644
--- a/man/man1/gdaladdo.1
+++ b/man/man1/gdaladdo.1
@@ -1,8 +1,8 @@
-.TH "gdaladdo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdaladdo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdaladdo \- .TH "gdaladdo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdaladdo \- .TH "gdaladdo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalbuildvrt.1 b/man/man1/gdalbuildvrt.1
index e103d49..b41c3d0 100644
--- a/man/man1/gdalbuildvrt.1
+++ b/man/man1/gdalbuildvrt.1
@@ -1,8 +1,8 @@
-.TH "gdalbuildvrt" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdalbuildvrt" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalbuildvrt \- .TH "gdalbuildvrt" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdalbuildvrt \- .TH "gdalbuildvrt" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalcompare.1 b/man/man1/gdalcompare.1
index 07a5e73..3625889 100644
--- a/man/man1/gdalcompare.1
+++ b/man/man1/gdalcompare.1
@@ -1,8 +1,8 @@
-.TH "gdalcompare" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdalcompare" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalcompare \- .TH "gdalcompare" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdalcompare \- .TH "gdalcompare" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdaldem.1 b/man/man1/gdaldem.1
index cd6c1db..8c8f062 100644
--- a/man/man1/gdaldem.1
+++ b/man/man1/gdaldem.1
@@ -1,8 +1,8 @@
-.TH "gdaldem" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdaldem" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdaldem \- .TH "gdaldem" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdaldem \- .TH "gdaldem" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalinfo.1 b/man/man1/gdalinfo.1
index 761a813..486cbd1 100644
--- a/man/man1/gdalinfo.1
+++ b/man/man1/gdalinfo.1
@@ -1,8 +1,8 @@
-.TH "gdalinfo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdalinfo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalinfo \- .TH "gdalinfo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdalinfo \- .TH "gdalinfo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdallocationinfo.1 b/man/man1/gdallocationinfo.1
index e27cd12..c84888b 100644
--- a/man/man1/gdallocationinfo.1
+++ b/man/man1/gdallocationinfo.1
@@ -1,8 +1,8 @@
-.TH "gdallocationinfo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdallocationinfo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdallocationinfo \- .TH "gdallocationinfo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdallocationinfo \- .TH "gdallocationinfo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalmanage.1 b/man/man1/gdalmanage.1
index 4d51541..79a1bd7 100644
--- a/man/man1/gdalmanage.1
+++ b/man/man1/gdalmanage.1
@@ -1,8 +1,8 @@
-.TH "gdalmanage" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdalmanage" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalmanage \- .TH "gdalmanage" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdalmanage \- .TH "gdalmanage" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalmove.1 b/man/man1/gdalmove.1
index 852a6e9..526174c 100644
--- a/man/man1/gdalmove.1
+++ b/man/man1/gdalmove.1
@@ -1,8 +1,8 @@
-.TH "gdalmove" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdalmove" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalmove \- .TH "gdalmove" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdalmove \- .TH "gdalmove" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalsrsinfo.1 b/man/man1/gdalsrsinfo.1
index ae68df1..b4a6cc7 100644
--- a/man/man1/gdalsrsinfo.1
+++ b/man/man1/gdalsrsinfo.1
@@ -1,8 +1,8 @@
-.TH "gdalsrsinfo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdalsrsinfo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalsrsinfo \- .TH "gdalsrsinfo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdalsrsinfo \- .TH "gdalsrsinfo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdaltindex.1 b/man/man1/gdaltindex.1
index ba1de88..6b25fa9 100644
--- a/man/man1/gdaltindex.1
+++ b/man/man1/gdaltindex.1
@@ -1,8 +1,8 @@
-.TH "gdaltindex" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdaltindex" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdaltindex \- .TH "gdaltindex" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdaltindex \- .TH "gdaltindex" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdaltransform.1 b/man/man1/gdaltransform.1
index 8013647..4adc1c8 100644
--- a/man/man1/gdaltransform.1
+++ b/man/man1/gdaltransform.1
@@ -1,8 +1,8 @@
-.TH "gdaltransform" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdaltransform" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdaltransform \- .TH "gdaltransform" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdaltransform \- .TH "gdaltransform" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalwarp.1 b/man/man1/gdalwarp.1
index 83b6e35..944583c 100644
--- a/man/man1/gdalwarp.1
+++ b/man/man1/gdalwarp.1
@@ -1,8 +1,8 @@
-.TH "gdalwarp" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "gdalwarp" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalwarp \- .TH "gdalwarp" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+gdalwarp \- .TH "gdalwarp" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/nearblack.1 b/man/man1/nearblack.1
index 24eaf48..fa0729a 100644
--- a/man/man1/nearblack.1
+++ b/man/man1/nearblack.1
@@ -1,8 +1,8 @@
-.TH "nearblack" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "nearblack" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-nearblack \- .TH "nearblack" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+nearblack \- .TH "nearblack" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogr2ogr.1 b/man/man1/ogr2ogr.1
index a9ad156..885e4c4 100644
--- a/man/man1/ogr2ogr.1
+++ b/man/man1/ogr2ogr.1
@@ -1,8 +1,8 @@
-.TH "ogr2ogr" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "ogr2ogr" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogr2ogr \- .TH "ogr2ogr" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+ogr2ogr \- .TH "ogr2ogr" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogr_utilities.1 b/man/man1/ogr_utilities.1
index 8223ed7..7b3daf1 100644
--- a/man/man1/ogr_utilities.1
+++ b/man/man1/ogr_utilities.1
@@ -1,8 +1,8 @@
-.TH "ogr_utilities" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "ogr_utilities" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogr_utilities \- .TH "ogr_utilities" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+ogr_utilities \- .TH "ogr_utilities" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogrinfo.1 b/man/man1/ogrinfo.1
index bee5b50..8398f67 100644
--- a/man/man1/ogrinfo.1
+++ b/man/man1/ogrinfo.1
@@ -1,8 +1,8 @@
-.TH "ogrinfo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "ogrinfo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogrinfo \- .TH "ogrinfo" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+ogrinfo \- .TH "ogrinfo" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogrlineref.1 b/man/man1/ogrlineref.1
index dfd2ecc..062c486 100644
--- a/man/man1/ogrlineref.1
+++ b/man/man1/ogrlineref.1
@@ -1,8 +1,8 @@
-.TH "ogrlineref" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "ogrlineref" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogrlineref \- .TH "ogrlineref" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+ogrlineref \- .TH "ogrlineref" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogrtindex.1 b/man/man1/ogrtindex.1
index c816abd..a40c7e9 100644
--- a/man/man1/ogrtindex.1
+++ b/man/man1/ogrtindex.1
@@ -1,8 +1,8 @@
-.TH "ogrtindex" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "ogrtindex" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogrtindex \- .TH "ogrtindex" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+ogrtindex \- .TH "ogrtindex" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/pct2rgb.1 b/man/man1/pct2rgb.1
index 5648066..84c3faa 100644
--- a/man/man1/pct2rgb.1
+++ b/man/man1/pct2rgb.1
@@ -1,8 +1,8 @@
-.TH "pct2rgb" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "pct2rgb" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-pct2rgb \- .TH "pct2rgb" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+pct2rgb \- .TH "pct2rgb" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/rgb2pct.1 b/man/man1/rgb2pct.1
index bfec1b9..fdb9ce6 100644
--- a/man/man1/rgb2pct.1
+++ b/man/man1/rgb2pct.1
@@ -1,8 +1,8 @@
-.TH "rgb2pct" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+.TH "rgb2pct" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-rgb2pct \- .TH "rgb2pct" 1 "Wed Sep 24 2014" "GDAL" \" -*- nroff -*-
+rgb2pct \- .TH "rgb2pct" 1 "Tue Feb 10 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/nmake.opt b/nmake.opt
index 936cfcc..ba1ecc4 100644
--- a/nmake.opt
+++ b/nmake.opt
@@ -1,4 +1,4 @@
-# $Id: nmake.opt 27143 2014-04-09 12:35:26Z rouault $
+# $Id: nmake.opt 28317 2015-01-15 22:49:41Z tamas $
 #
 # nmake.opt - main configuration file for NMAKE makefiles.
 #
@@ -522,7 +522,9 @@ OCI_INCLUDE =	-I$(ORACLE_HOME)\oci\include
 # Uncomment for OpenJpeg (release v2.0.0) support
 #OPENJPEG_ENABLED = YES
 #OPENJPEG_CFLAGS = -IC:\openjpeg\include
-#OPENJPEG_LIB = C:\openjpeg\lib\openjpeg.lib
+#OPENJPEG_LIB = C:\openjpeg\lib\openjp2.lib
+# For OpenJpeg >= 2.1, uncomment
+#OPENJPEG_VERSION = 20100
 
 # Uncomment for PDF support
 # Uncomment POPPLER_BASE_STREAM_HAS_TWO_ARGS = YES for Poppler >= 0.16.0
diff --git a/ogr/gml2ogrgeometry.cpp b/ogr/gml2ogrgeometry.cpp
index 9edabcb..07c8d7a 100644
--- a/ogr/gml2ogrgeometry.cpp
+++ b/ogr/gml2ogrgeometry.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gml2ogrgeometry.cpp 27135 2014-04-06 09:58:27Z rouault $
+ * $Id: gml2ogrgeometry.cpp 27908 2014-10-26 13:06:58Z rouault $
  *
  * Project:  GML Reader
  * Purpose:  Code to translate between GML and OGR geometry forms.
@@ -2051,7 +2051,21 @@ OGRGeometry *GML2OGRGeometry_XMLNode( const CPLXMLNode *psNode,
                                         "Failed Union for TopoSurface" );
                             return NULL;
                         }
-                        poTS = (OGRMultiPolygon *)poUnion;
+                        if( wkbFlatten( poUnion->getGeometryType()) == wkbPolygon )
+                        {
+                            /* forcing to be a MultiPolygon */
+                            poTS = new OGRMultiPolygon();
+                            poTS->addGeometryDirectly(poUnion);
+                        }
+                        else if( wkbFlatten( poUnion->getGeometryType()) == wkbMultiPolygon )
+                            poTS = (OGRMultiPolygon *)poUnion;
+                        else
+                        {
+                            CPLError( CE_Failure, CPLE_AppDefined,
+                                        "Unexpected geometry type resulting from Union for TopoSurface" );
+                            delete poUnion;
+                            return NULL;
+                        }
                     }
                 }
                 delete poFaceCollectionGeom;
@@ -2059,14 +2073,6 @@ OGRGeometry *GML2OGRGeometry_XMLNode( const CPLXMLNode *psNode,
               }
             }
 
-            if( wkbFlatten( poTS->getGeometryType()) == wkbPolygon )
-            {
-                /* forcing to be a MultiPolygon */
-                OGRGeometry *poOldTS = poTS;
-                poTS = new OGRMultiPolygon();
-                poTS->addGeometryDirectly(poOldTS);
-            }
-
             return poTS;
 #endif // HAVE_GEOS
         }
diff --git a/ogr/ogr_core.h b/ogr/ogr_core.h
index a0c98fe..ef3337e 100644
--- a/ogr/ogr_core.h
+++ b/ogr/ogr_core.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogr_core.h 27058 2014-03-19 22:19:21Z kyle $
+ * $Id: ogr_core.h 27792 2014-10-04 09:02:06Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Define some core portability services for cross-platform OGR code.
@@ -63,13 +63,13 @@ class CPL_DLL OGREnvelope
     double      MaxY;
 
 /* See http://trac.osgeo.org/gdal/ticket/5299 for details on this pragma */
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && !defined(_MSC_VER)) 
-#pragma GCC diagnostic ignored "-Wfloat-equal"
+#if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(_MSC_VER)) 
 #pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
 #endif
     int  IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
 
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && !defined(_MSC_VER))
+#if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(_MSC_VER))
 #pragma GCC diagnostic pop
 #endif
 
diff --git a/ogr/ogr_srs_pci.cpp b/ogr/ogr_srs_pci.cpp
index d7ba2ad..e49b183 100644
--- a/ogr/ogr_srs_pci.cpp
+++ b/ogr/ogr_srs_pci.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogr_srs_pci.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogr_srs_pci.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  OGRSpatialReference translation to/from PCI georeferencing
@@ -34,7 +34,7 @@
 #include "cpl_conv.h"
 #include "cpl_csv.h"
 
-CPL_CVSID("$Id: ogr_srs_pci.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogr_srs_pci.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 typedef struct 
 {
@@ -812,18 +812,20 @@ OGRErr OGRSpatialReference::exportToPCI( char **ppszProj, char **ppszUnits,
     *ppadfPrjParams = (double *)CPLMalloc( 17 * sizeof(double) );
     for ( i = 0; i < 17; i++ )
         (*ppadfPrjParams)[i] = 0.0;
-   
+
 /* -------------------------------------------------------------------- */
 /*      Get the prime meridian info.                                    */
 /* -------------------------------------------------------------------- */
+#if 0
     const OGR_SRSNode *poPRIMEM = GetAttrNode( "PRIMEM" );
     double dfFromGreenwich = 0.0;
 
-    if( poPRIMEM != NULL && poPRIMEM->GetChildCount() >= 2 
+    if( poPRIMEM != NULL && poPRIMEM->GetChildCount() >= 2
         && atof(poPRIMEM->GetChild(1)->GetValue()) != 0.0 )
     {
         dfFromGreenwich = atof(poPRIMEM->GetChild(1)->GetValue());
     }
+#endif
 
 /* ==================================================================== */
 /*      Handle the projection definition.                               */
@@ -1347,4 +1349,3 @@ OGRErr OGRSpatialReference::exportToPCI( char **ppszProj, char **ppszUnits,
 
     return OGRERR_NONE;
 }
-
diff --git a/ogr/ogr_srs_proj4.cpp b/ogr/ogr_srs_proj4.cpp
index 6360ba4..de8839e 100644
--- a/ogr/ogr_srs_proj4.cpp
+++ b/ogr/ogr_srs_proj4.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogr_srs_proj4.cpp 27437 2014-06-06 19:14:53Z rouault $
+ * $Id: ogr_srs_proj4.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  OGRSpatialReference interface to PROJ.4.
@@ -35,7 +35,7 @@
 
 extern int EPSGGetWGS84Transform( int nGeogCS, double *padfTransform );
 
-CPL_CVSID("$Id: ogr_srs_proj4.cpp 27437 2014-06-06 19:14:53Z rouault $");
+CPL_CVSID("$Id: ogr_srs_proj4.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /* -------------------------------------------------------------------- */
 /*      The following list comes from osrs/proj/src/pj_ellps.c          */
@@ -473,7 +473,7 @@ OGRErr OGRSpatialReference::importFromProj4( const char * pszProj4 )
 /* -------------------------------------------------------------------- */
     const char *pszPM = CSLFetchNameValue( papszNV, "pm" );
     double dfFromGreenwich = 0.0;
-    int    nPMCode = -1;
+    /* int    nPMCode = -1; */
 
     if( pszPM != NULL )
     {
@@ -482,7 +482,7 @@ OGRErr OGRSpatialReference::importFromProj4( const char * pszProj4 )
         {
             dfFromGreenwich = CPLDMSToDec(psProj4PM->pszFromGreenwich);
             pszPM = psProj4PM->pszWKTPMName;
-            nPMCode = psProj4PM->nPMCode;
+            /* nPMCode = psProj4PM->nPMCode; */
         }
         else
         {
@@ -2564,4 +2564,3 @@ OGRErr OGRSpatialReference::exportToProj4( char ** ppszProj4 ) const
 
     return OGRERR_NONE;
 }
-
diff --git a/ogr/ogr_srs_xml.cpp b/ogr/ogr_srs_xml.cpp
index de1fd53..04a60af 100644
--- a/ogr/ogr_srs_xml.cpp
+++ b/ogr/ogr_srs_xml.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogr_srs_xml.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogr_srs_xml.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  OGRSpatialReference interface to OGC XML (014r4).
@@ -231,28 +231,26 @@ static CPLXMLNode *addAuthorityIDBlock( CPLXMLNode *psTarget,
 
     return psElement;
 }
-    
 
 /************************************************************************/
 /*                              addGMLId()                              */
 /************************************************************************/
 
 static void addGMLId( CPLXMLNode *psParent )
-
 {
     static void *hGMLIdMutex = NULL;
     CPLMutexHolderD( &hGMLIdMutex );
 
-    CPLXMLNode *psId;
+    /* CPLXMLNode *psId; */
     static int nNextGMLId = 1;
     char   szIdText[40];
 
     sprintf( szIdText, "ogrcrs%d", nNextGMLId++ );
-    
-    psId = 
-        CPLCreateXMLNode( 
-            CPLCreateXMLNode( psParent, CXT_Attribute, "gml:id" ),
-            CXT_Text, szIdText );
+
+    /* psId =  */
+    CPLCreateXMLNode(
+        CPLCreateXMLNode( psParent, CXT_Attribute, "gml:id" ),
+        CXT_Text, szIdText );
 }
 
 /************************************************************************/
diff --git a/ogr/ogrfeature.cpp b/ogr/ogrfeature.cpp
index e6f9c24..da53f76 100644
--- a/ogr/ogrfeature.cpp
+++ b/ogr/ogrfeature.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrfeature.cpp 27714 2014-09-21 15:51:52Z jef $
+ * $Id: ogrfeature.cpp 27741 2014-09-26 19:20:02Z goatbar $
  * 
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  The OGRFeature class implementation. 
@@ -33,7 +33,7 @@
 #include "ogr_p.h"
 #include <vector>
 
-CPL_CVSID("$Id: ogrfeature.cpp 27714 2014-09-21 15:51:52Z jef $");
+CPL_CVSID("$Id: ogrfeature.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                             OGRFeature()                             */
@@ -2184,11 +2184,13 @@ void OGRFeature::SetField( int iField, int nValue )
 
         if( IsFieldSet( iField) )
             CPLFree( pauFields[iField].String );
-        
+
         pauFields[iField].String = CPLStrdup( szTempBuffer );
     }
     else
-        /* do nothing for other field types */;
+    {
+        /* do nothing for other field types */
+    }
 }
 
 /************************************************************************/
@@ -2274,7 +2276,9 @@ void OGRFeature::SetField( int iField, double dfValue )
         pauFields[iField].String = CPLStrdup( szTempBuffer );
     }
     else
-        /* do nothing for other field types */;
+    {
+        /* do nothing for other field types */
+    }
 }
 
 /************************************************************************/
@@ -2414,7 +2418,9 @@ void OGRFeature::SetField( int iField, const char * pszValue )
         }
     }
     else
+    {
         /* do nothing for other field types */;
+    }
 }
 
 /************************************************************************/
@@ -2934,15 +2940,17 @@ void OGRFeature::SetField( int iField, OGRField * puValue )
         else
         {
             pauFields[iField].Binary.nCount = puValue->Binary.nCount;
-            pauFields[iField].Binary.paData = 
+            pauFields[iField].Binary.paData =
                 (GByte *) CPLMalloc(puValue->Binary.nCount);
-            memcpy( pauFields[iField].Binary.paData, 
-                    puValue->Binary.paData, 
+            memcpy( pauFields[iField].Binary.paData,
+                    puValue->Binary.paData,
                     puValue->Binary.nCount );
         }
     }
     else
-        /* do nothing for other field types */;
+    {
+        /* do nothing for other field types */
+    }
 }
 
 /************************************************************************/
diff --git a/ogr/ogrpgeogeometry.cpp b/ogr/ogrpgeogeometry.cpp
index 523208b..e858091 100644
--- a/ogr/ogrpgeogeometry.cpp
+++ b/ogr/ogrpgeogeometry.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrpgeogeometry.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrpgeogeometry.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements decoder of shapebin geometry for PGeo
@@ -34,7 +34,7 @@
 #include "ogr_p.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrpgeogeometry.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrpgeogeometry.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 #define SHPP_TRISTRIP   0
 #define SHPP_TRIFAN     1
@@ -1592,7 +1592,7 @@ OGRErr OGRCreateFromShapeBin( GByte *pabyShape,
              || nSHPType == SHPT_POINTZ
              || nSHPType == SHPT_POINTZM )
     {
-        int nOffset;
+        /* int nOffset; */
         double  dfX, dfY, dfZ = 0;
 
         int bHasZ = (nSHPType == SHPT_POINTZ || nSHPType == SHPT_POINTZM);
@@ -1609,7 +1609,7 @@ OGRErr OGRCreateFromShapeBin( GByte *pabyShape,
 
         CPL_LSBPTR64( &dfX );
         CPL_LSBPTR64( &dfY );
-        nOffset = 20 + 8;
+        /* nOffset = 20 + 8; */
 
         if( bHasZ )
         {
@@ -1624,7 +1624,7 @@ OGRErr OGRCreateFromShapeBin( GByte *pabyShape,
     }
 
     CPLError(CE_Failure, CPLE_AppDefined,
-             "Unsupported geometry type: %d", 
+             "Unsupported geometry type: %d",
               nSHPType );
 
     return OGRERR_FAILURE;
diff --git a/ogr/ogrsf_frmts/avc/avc_bin.c b/ogr/ogrsf_frmts/avc/avc_bin.c
index dafc339..1c66b2e 100644
--- a/ogr/ogrsf_frmts/avc/avc_bin.c
+++ b/ogr/ogrsf_frmts/avc/avc_bin.c
@@ -2334,17 +2334,18 @@ AVCBinFile *_AVCBinReadOpenDBFTable(const char *pszDBFFilename,
     for(iField=0; iField< psTableDef->numFields; iField++)
     {
         int nWidth, nDecimals;
-        DBFFieldType eDBFType;
+        /* DBFFieldType eDBFType; */
         char         cNativeType;
 
         /*-------------------------------------------------------------
-         * Fetch DBF Field info and convert to Arc/Info type... 
-         * Note that since DBF fields names are limited to 10 chars, 
+         * Fetch DBF Field info and convert to Arc/Info type...
+         * Note that since DBF fields names are limited to 10 chars,
          * we do not have to worry about field name length in the process.
          *------------------------------------------------------------*/
-        eDBFType = DBFGetFieldInfo(hDBFFile, iField, 
-                                   pasFieldDef[iField].szName,
-                                   &nWidth, &nDecimals);
+        /* eDBFType = */
+        DBFGetFieldInfo(hDBFFile, iField,
+                        pasFieldDef[iField].szName,
+                        &nWidth, &nDecimals);
         cNativeType = DBFGetNativeFieldType(hDBFFile, iField);
 
         pasFieldDef[iField].nFmtWidth = (GInt16)nWidth;
@@ -2594,6 +2595,3 @@ void _AVCBinReadRepairDBFFieldName(char *pszFieldName)
         *pszTmp = '-';
 
 }
-
-
-
diff --git a/ogr/ogrsf_frmts/avc/avc_e00read.c b/ogr/ogrsf_frmts/avc/avc_e00read.c
index 7bb1374..b7f5932 100644
--- a/ogr/ogrsf_frmts/avc/avc_e00read.c
+++ b/ogr/ogrsf_frmts/avc/avc_e00read.c
@@ -826,7 +826,7 @@ static int _AVCE00ReadAddJabberwockySection(AVCE00ReadPtr psInfo,
 static void *_AVCE00ReadNextLineE00(AVCE00ReadE00Ptr psRead,
         const char *pszLine)
 {
-    int nStatus = 0;
+    /* int nStatus = 0; */
     void *psObj = 0;
 
     AVCE00ParseInfo *psInfo = psRead->hParseInfo;
@@ -946,8 +946,10 @@ static void *_AVCE00ReadNextLineE00(AVCE00ReadE00Ptr psRead,
         }
     }
 
+#if 0
     if (CPLGetLastErrorNo() != 0)
         nStatus = -1;
+#endif
 
     return psObj;
 }
@@ -2039,7 +2041,7 @@ static int _AVCE00ReadSeekE00(AVCE00ReadE00Ptr psRead, int nOffset,
         int nWhence)
 {
     const char *pszLine;
-    void       *obj;
+    /* void       *obj; */
 
     switch (nWhence)
     {
@@ -2059,7 +2061,8 @@ static int _AVCE00ReadSeekE00(AVCE00ReadE00Ptr psRead, int nOffset,
             CPLGetLastErrorNo() == 0 &&
             (pszLine = CPLReadLine(psRead->hFile) ) != NULL )
     {
-        obj = _AVCE00ReadNextLineE00(psRead, pszLine);
+        /* obj = */
+        _AVCE00ReadNextLineE00(psRead, pszLine);
     }
 
     return nOffset ? -1 : 0;
diff --git a/ogr/ogrsf_frmts/avc/avc_misc.c b/ogr/ogrsf_frmts/avc/avc_misc.c
index 8ae713c..fbd0f30 100644
--- a/ogr/ogrsf_frmts/avc/avc_misc.c
+++ b/ogr/ogrsf_frmts/avc/avc_misc.c
@@ -490,7 +490,7 @@ int  AVCPrintRealValue(char *pszBuf, int nPrecision, AVCFileType eType,
     {
         int n;
         n = strlen(pszBuf);
-        
+
         pszBuf[n - numExpDigits]    = pszBuf[n-2];
         pszBuf[n - numExpDigits +1] = pszBuf[n-1];
         pszBuf[n - numExpDigits +2] = '\0';
@@ -498,9 +498,7 @@ int  AVCPrintRealValue(char *pszBuf, int nPrecision, AVCFileType eType,
 
     /* Just make sure that the actual output length is what we expected.
      */
-    CPLAssert(strlen(pszBuf) == nLen);
+    CPLAssert(strlen(pszBuf) == (size_t)nLen);
 
     return nLen;
 }
-
-
diff --git a/ogr/ogrsf_frmts/csv/ogrcsvdatasource.cpp b/ogr/ogrsf_frmts/csv/ogrcsvdatasource.cpp
index 56d191f..1fae02e 100644
--- a/ogr/ogrsf_frmts/csv/ogrcsvdatasource.cpp
+++ b/ogr/ogrsf_frmts/csv/ogrcsvdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrcsvdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrcsvdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  CSV Translator
  * Purpose:  Implements OGRCSVDataSource class
@@ -34,7 +34,7 @@
 #include "cpl_csv.h"
 #include "cpl_vsi_virtual.h"
 
-CPL_CVSID("$Id: ogrcsvdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrcsvdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                          OGRCSVDataSource()                          */
@@ -138,7 +138,7 @@ int OGRCSVDataSource::Open( const char * pszFilename, int bUpdateIn,
 
     int bIgnoreExtension = EQUALN(osFilename, "CSV:", 4);
     int bUSGeonamesFile = FALSE;
-    int bGeonamesOrgFile = FALSE;
+    /* int bGeonamesOrgFile = FALSE; */
     if (bIgnoreExtension)
     {
         osFilename = osFilename + 4;
@@ -186,7 +186,7 @@ int OGRCSVDataSource::Open( const char * pszFilename, int bUpdateIn,
         if (bUpdateIn)
             return FALSE;
         bIgnoreExtension = TRUE;
-        bGeonamesOrgFile = TRUE;
+        /* bGeonamesOrgFile = TRUE; */
 
         if (EQUAL(osExt, "zip") &&
             strstr(osFilename, "/vsizip/") == NULL )
diff --git a/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp b/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp
index 6f0d852..820c035 100644
--- a/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp
+++ b/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrcsvlayer.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrcsvlayer.cpp 27748 2014-09-28 12:05:20Z rouault $
  *
  * Project:  CSV Translator
  * Purpose:  Implements OGRCSVLayer class.
@@ -34,7 +34,7 @@
 #include "cpl_csv.h"
 #include "ogr_p.h"
 
-CPL_CVSID("$Id: ogrcsvlayer.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrcsvlayer.cpp 27748 2014-09-28 12:05:20Z rouault $");
 
 
 
@@ -332,6 +332,12 @@ OGRCSVLayer::OGRCSVLayer( const char *pszLayerNameIn,
 
     if( !bNew && !bHasFieldNames )
         VSIRewindL( fpCSV );
+    
+    panGeomFieldIndex = (int*) CPLCalloc(nFieldCount, sizeof(int));
+    for( iField = 0; iField < nFieldCount; iField++ )
+    {
+        panGeomFieldIndex[iField] = -1;
+    }
 
 /* -------------------------------------------------------------------- */
 /*      Check for geonames.org tables                                   */
@@ -405,12 +411,6 @@ OGRCSVLayer::OGRCSVLayer( const char *pszLayerNameIn,
             VSIFCloseL(fpCSVT);
         }
     }
-    
-    panGeomFieldIndex = (int*) CPLCalloc(nFieldCount, sizeof(int));
-    for( iField = 0; iField < nFieldCount; iField++ )
-    {
-        panGeomFieldIndex[iField] = -1;
-    }
 
 /* -------------------------------------------------------------------- */
 /*      Build field definitions.                                        */
diff --git a/ogr/ogrsf_frmts/dgn/dgnwrite.cpp b/ogr/ogrsf_frmts/dgn/dgnwrite.cpp
index b303d8c..3bc9a5a 100644
--- a/ogr/ogrsf_frmts/dgn/dgnwrite.cpp
+++ b/ogr/ogrsf_frmts/dgn/dgnwrite.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: dgnwrite.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: dgnwrite.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Microstation DGN Access Library
  * Purpose:  DGN Access functions related to writing DGN elements.
@@ -30,7 +30,7 @@
 
 #include "dgnlibp.h"
 
-CPL_CVSID("$Id: dgnwrite.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: dgnwrite.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 static void DGNPointToInt( DGNInfo *psDGN, DGNPoint *psPoint, 
                            unsigned char *pabyTarget );
@@ -645,14 +645,14 @@ DGNElemCore *DGNCloneElement( CPL_UNUSED DGNHandle hDGNSrc, DGNHandle hDGNDst,
     }
     else if( psSrcElement->stype == DGNST_KNOT_WEIGHT )
     {
-        DGNElemKnotWeight *psArray, *psSrcArray;
+        DGNElemKnotWeight *psArray /* , *psSrcArray*/;
         int               nSize, numelems;
 
         // FIXME: Is it OK to assume that the # of elements corresponds
         // directly to the element size? kintel 20051218.
         numelems = (psSrcElement->size - 36 - psSrcElement->attr_bytes)/4;
 
-        psSrcArray = (DGNElemKnotWeight *) psSrcElement;
+        /* psSrcArray = (DGNElemKnotWeight *) psSrcElement; */
 
         nSize = sizeof(DGNElemKnotWeight) + sizeof(long) * (numelems-1);
 
@@ -2184,7 +2184,7 @@ DGNCreateCellHeaderFromGroup( DGNHandle hDGN, const char *pszName,
 
 {
     int         nTotalLength;
-    int         i, nLevel;
+    int         i /* , nLevel */;
     DGNElemCore *psCH;
     DGNPoint    sMin={0.0,0.0,0.0}, sMax={0.0,0.0,0.0};
     unsigned char abyLevelsOccuring[8] = {0,0,0,0,0,0,0,0};
@@ -2207,7 +2207,7 @@ DGNCreateCellHeaderFromGroup( DGNHandle hDGN, const char *pszName,
 /* -------------------------------------------------------------------- */
 /*      Collect the total size, and bounds.                             */
 /* -------------------------------------------------------------------- */
-    nLevel = papsElems[0]->level;
+    /* nLevel = papsElems[0]->level; */
 
     for( i = 0; i < nNumElems; i++ )
     {
@@ -2406,17 +2406,18 @@ int DGNAddRawAttrLink( DGNHandle hDGN, DGNElemCore *psElement,
     
     memcpy( psElement->attr_data + (psElement->attr_bytes-nLinkSize), 
             pabyRawLinkData, nLinkSize );
-    
+
 /* -------------------------------------------------------------------- */
 /*      Grow the raw data, if we have rawdata.                          */
 /* -------------------------------------------------------------------- */
+    /* TODO: operation on raw_bytes may be undefined. */
     psElement->raw_bytes = psElement->raw_bytes += nLinkSize;
-    psElement->raw_data = (unsigned char *) 
+    psElement->raw_data = (unsigned char *)
         CPLRealloc( psElement->raw_data, psElement->raw_bytes );
-    
-    memcpy( psElement->raw_data + (psElement->raw_bytes-nLinkSize), 
+
+    memcpy( psElement->raw_data + (psElement->raw_bytes-nLinkSize),
             pabyRawLinkData, nLinkSize );
-    
+
 /* -------------------------------------------------------------------- */
 /*      If the element is a shape or chain complex header, then we      */
 /*      need to increase the total complex group size appropriately.    */
diff --git a/ogr/ogrsf_frmts/dxf/intronurbs.cpp b/ogr/ogrsf_frmts/dxf/intronurbs.cpp
index ca62ef4..b32294b 100644
--- a/ogr/ogrsf_frmts/dxf/intronurbs.cpp
+++ b/ogr/ogrsf_frmts/dxf/intronurbs.cpp
@@ -61,10 +61,10 @@ POSSIBILITY OF SUCH DAMAGE.
 static void knotu(int n,int c,int x[])
 
 {
-    int nplusc,nplus2,i;
+  int nplusc, /* nplus2, */i;
 
     nplusc = n + c;
-    nplus2 = n + 2;
+    /* nplus2 = n + 2; */
 
     x[1] = 0;
     for (i = 2; i <= nplusc; i++){
@@ -423,4 +423,3 @@ void rbsplinu(int npts,int k,int p1,double b[],double h[], double p[])
         t = t + step;
     }
 }
-
diff --git a/ogr/ogrsf_frmts/dxf/ogrdxf_dimension.cpp b/ogr/ogrsf_frmts/dxf/ogrdxf_dimension.cpp
index 87d9e49..9e31d7b 100644
--- a/ogr/ogrsf_frmts/dxf/ogrdxf_dimension.cpp
+++ b/ogr/ogrsf_frmts/dxf/ogrdxf_dimension.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrdxf_dimension.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrdxf_dimension.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  DXF Translator
  * Purpose:  Implements translation support for DIMENSION elements as a part
@@ -32,11 +32,11 @@
 #include "ogr_dxf.h"
 #include "cpl_conv.h"
 
-CPL_CVSID("$Id: ogrdxf_dimension.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrdxf_dimension.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 #ifndef PI
 #define PI  3.14159265358979323846
-#endif 
+#endif
 
 /************************************************************************/
 /*                         TranslateDIMENSION()                         */
@@ -46,12 +46,12 @@ OGRFeature *OGRDXFLayer::TranslateDIMENSION()
 
 {
     char szLineBuf[257];
-    int nCode, nDimType = 0;
+    int nCode /*, nDimType = 0 */;
     OGRFeature *poFeature = new OGRFeature( poFeatureDefn );
-    double dfArrowX1 = 0.0, dfArrowY1 = 0.0, dfArrowZ1 = 0.0;
-    double dfTargetX1 = 0.0, dfTargetY1 = 0.0, dfTargetZ1 = 0.0;
-    double dfTargetX2 = 0.0, dfTargetY2 = 0.0, dfTargetZ2 = 0.0;
-    double dfTextX = 0.0, dfTextY = 0.0, dfTextZ = 0.0;
+    double dfArrowX1 = 0.0, dfArrowY1 = 0.0 /*, dfArrowZ1 = 0.0 */;
+    double dfTargetX1 = 0.0, dfTargetY1 = 0.0 /* , dfTargetZ1 = 0.0 */;
+    double dfTargetX2 = 0.0, dfTargetY2 = 0.0 /* , dfTargetZ2 = 0.0 */;
+    double dfTextX = 0.0, dfTextY = 0.0 /* , dfTextZ = 0.0 */;
     double dfAngle = 0.0;
     double dfHeight = CPLAtof(poDS->GetVariable("$DIMTXT", "2.5"));
 
@@ -70,7 +70,7 @@ OGRFeature *OGRDXFLayer::TranslateDIMENSION()
             break;
 
           case 30:
-            dfArrowZ1 = CPLAtof(szLineBuf);
+            /* dfArrowZ1 = CPLAtof(szLineBuf); */
             break;
 
           case 11:
@@ -82,7 +82,7 @@ OGRFeature *OGRDXFLayer::TranslateDIMENSION()
             break;
 
           case 31:
-            dfTextZ = CPLAtof(szLineBuf);
+            /* dfTextZ = CPLAtof(szLineBuf); */
             break;
 
           case 13:
@@ -94,7 +94,7 @@ OGRFeature *OGRDXFLayer::TranslateDIMENSION()
             break;
 
           case 33:
-            dfTargetZ2 = CPLAtof(szLineBuf);
+            /* dfTargetZ2 = CPLAtof(szLineBuf); */
             break;
 
           case 14:
@@ -106,11 +106,11 @@ OGRFeature *OGRDXFLayer::TranslateDIMENSION()
             break;
 
           case 34:
-            dfTargetZ1 = CPLAtof(szLineBuf);
+            /* dfTargetZ1 = CPLAtof(szLineBuf); */
             break;
 
           case 70:
-            nDimType = atoi(szLineBuf);
+            /* nDimType = atoi(szLineBuf); */
             break;
 
           case 1:
diff --git a/ogr/ogrsf_frmts/dxf/ogrdxf_hatch.cpp b/ogr/ogrsf_frmts/dxf/ogrdxf_hatch.cpp
index 17c4081..19f29ca 100644
--- a/ogr/ogrsf_frmts/dxf/ogrdxf_hatch.cpp
+++ b/ogr/ogrsf_frmts/dxf/ogrdxf_hatch.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrdxf_hatch.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrdxf_hatch.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  DXF Translator
  * Purpose:  Implements translation support for HATCH elements as part
@@ -35,11 +35,11 @@
 
 #include "ogrdxf_polyline_smooth.h"
 
-CPL_CVSID("$Id: ogrdxf_hatch.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrdxf_hatch.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 #ifndef PI
 #define PI  3.14159265358979323846
-#endif 
+#endif
 
 /************************************************************************/
 /*                           TranslateHATCH()                           */
@@ -57,7 +57,7 @@ OGRFeature *OGRDXFLayer::TranslateHATCH()
     OGRFeature *poFeature = new OGRFeature( poFeatureDefn );
 
     CPLString osHatchPattern;
-    int nFillFlag = 0;
+    /* int nFillFlag = 0; */
     OGRGeometryCollection oGC;
 
     while( (nCode = poDS->ReadValue(szLineBuf,sizeof(szLineBuf))) > 0 )
@@ -65,7 +65,7 @@ OGRFeature *OGRDXFLayer::TranslateHATCH()
         switch( nCode )
         {
           case 70:
-            nFillFlag = atoi(szLineBuf);
+            /* nFillFlag = atoi(szLineBuf); */
             break;
 
           case 2:
diff --git a/ogr/ogrsf_frmts/elastic/ogrelasticdatasource.cpp b/ogr/ogrsf_frmts/elastic/ogrelasticdatasource.cpp
index 7a74ef9..b2c8be5 100644
--- a/ogr/ogrsf_frmts/elastic/ogrelasticdatasource.cpp
+++ b/ogr/ogrsf_frmts/elastic/ogrelasticdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrelasticdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrelasticdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  ElasticSearch Translator
  * Purpose:
@@ -37,7 +37,7 @@
 #include "cpl_csv.h"
 #include "cpl_http.h"
 
-CPL_CVSID("$Id: ogrelasticdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrelasticdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                        OGRElasticDataSource()                        */
@@ -176,7 +176,10 @@ int OGRElasticDataSource::Create(const char *pszFilename,
             fdata = (char *) malloc(fsize + 1);
 
             fseek(fp, 0, SEEK_SET);
-            fread(fdata, fsize, 1, fp);
+            if (0 == fread(fdata, fsize, 1, fp)) {
+                CPLError(CE_Failure, CPLE_FileIO,
+                         "OGRElasticDataSource::Create read failed.");
+            }
             fdata[fsize] = 0;
             this->pszMapping = fdata;
             fclose(fp);
diff --git a/ogr/ogrsf_frmts/filegdb/FGdbDriver.cpp b/ogr/ogrsf_frmts/filegdb/FGdbDriver.cpp
index a79692a..482380b 100644
--- a/ogr/ogrsf_frmts/filegdb/FGdbDriver.cpp
+++ b/ogr/ogrsf_frmts/filegdb/FGdbDriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: FGdbDriver.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: FGdbDriver.cpp 28412 2015-02-04 14:32:09Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements FileGDB OGR driver.
@@ -9,7 +9,7 @@
  ******************************************************************************
  * Copyright (c) 2010, Ragi Yaser Burhum
  * Copyright (c) 2011, Paul Ramsey <pramsey at cleverelephant.ca>
- * Copyright (c) 2011-2013, Even Rouault <even dot rouault at mines-paris dot org>
+ * Copyright (c) 2011-2013, Even Rouault <even dot rouault at mines-paris dot org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -35,8 +35,9 @@
 #include "FGdbUtils.h"
 #include "cpl_multiproc.h"
 #include "ogrmutexeddatasource.h"
+#include "ogr_api.h"
 
-CPL_CVSID("$Id: FGdbDriver.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: FGdbDriver.cpp 28412 2015-02-04 14:32:09Z rouault $");
 
 extern "C" void RegisterOGRFileGDB();
 
@@ -114,7 +115,24 @@ OGRDataSource *FGdbDriver::Open( const char* pszFilename, int bUpdate )
         {
             delete pGeoDatabase;
 
-            GDBErr(hr, "Failed to open Geodatabase");
+            if( OGRGetDriverByName("OpenFileGDB") != NULL && bUpdate == FALSE )
+            {
+                std::wstring fgdb_error_desc_w;
+                std::string fgdb_error_desc("Unknown error");
+                fgdbError er;
+                er = FileGDBAPI::ErrorInfo::GetErrorDescription(hr, fgdb_error_desc_w);
+                if ( er == S_OK )
+                {
+                    fgdb_error_desc = WStringToString(fgdb_error_desc_w);
+                }
+                CPLDebug("FileGDB", "Cannot open %s with FileGDB driver: %s. Failing silently so OpenFileGDB can be tried",
+                         pszFilename,
+                         fgdb_error_desc.c_str());
+            }
+            else
+            {
+                GDBErr(hr, "Failed to open Geodatabase");
+            }
             return NULL;
         }
 
diff --git a/ogr/ogrsf_frmts/generic/ogrlayer.cpp b/ogr/ogrsf_frmts/generic/ogrlayer.cpp
index c23d798..d2eca8b 100644
--- a/ogr/ogrsf_frmts/generic/ogrlayer.cpp
+++ b/ogr/ogrsf_frmts/generic/ogrlayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrlayer.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrlayer.cpp 28169 2014-12-17 16:24:25Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  The generic portions of the OGRSFLayer class.
@@ -34,7 +34,7 @@
 #include "ogr_attrind.h"
 #include "swq.h"
 
-CPL_CVSID("$Id: ogrlayer.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrlayer.cpp 28169 2014-12-17 16:24:25Z rouault $");
 
 /************************************************************************/
 /*                              OGRLayer()                              */
@@ -1631,6 +1631,8 @@ OGRErr create_field_map(OGRFeatureDefn *poDefn, int **map)
     if (n > 0) {
         *map = (int*)VSIMalloc(sizeof(int) * n);
         if (!(*map)) return OGRERR_NOT_ENOUGH_MEMORY;
+        for(int i=0;i<n;i++)
+            (*map)[i] = -1;
     }
     return ret;
 }
diff --git a/ogr/ogrsf_frmts/geoconcept/geoconcept.c b/ogr/ogrsf_frmts/geoconcept/geoconcept.c
index b08f7db..e86b021 100644
--- a/ogr/ogrsf_frmts/geoconcept/geoconcept.c
+++ b/ogr/ogrsf_frmts/geoconcept/geoconcept.c
@@ -2482,14 +2482,15 @@ static GCExportFileMetadata GCIOAPI_CALL1(*) _parseObject_GCIO (
   theSubType= NULL;
   coff= -1L;
 reloop:
-  if( GetGCWhatIs_GCIO(H)==vComType_GCIO )
+  /* TODO: Switch to C++ casts below. */
+  if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(H) == vComType_GCIO )
   {
     if( _get_GCIO(H)==-1 )
       return Meta;
     goto reloop;
   }
   /* analyze the line according to schema : */
-  if( GetGCWhatIs_GCIO(H)==vPragma_GCIO )
+  if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(H) == vPragma_GCIO )
   {
     if( strstr(GetGCCache_GCIO(H),k3DOBJECTMONO_GCIO) )
     {
@@ -3028,11 +3029,11 @@ static OGRErr GCIOAPI_CALL _readConfigField_GCIO (
   theField= NULL;
   while( _get_GCIO(hGCT)!=EOF )
   {
-    if( GetGCWhatIs_GCIO(hGCT)==vComType_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vComType_GCIO )
     {
       continue;
     }
-    if( GetGCWhatIs_GCIO(hGCT)==vHeader_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vHeader_GCIO )
     {
       if( strstr(GetGCCache_GCIO(hGCT),kConfigEndField_GCIO)!=NULL)
       {
@@ -3235,11 +3236,12 @@ static OGRErr GCIOAPI_CALL _readConfigFieldType_GCIO (
   knd= vUnknownItemType_GCIO;
   theField= NULL;
   while( _get_GCIO(hGCT)!=EOF ) {
-    if( GetGCWhatIs_GCIO(hGCT)==vComType_GCIO )
+    /* TODO: Switch to C++ casts below. */
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vComType_GCIO )
     {
       continue;
     }
-    if( GetGCWhatIs_GCIO(hGCT)==vHeader_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vHeader_GCIO )
     {
       if( strstr(GetGCCache_GCIO(hGCT),kConfigEndField_GCIO)!=NULL)
       {
@@ -3424,11 +3426,11 @@ static OGRErr GCIOAPI_CALL _readConfigFieldSubType_GCIO (
   knd= vUnknownItemType_GCIO;
   theField= NULL;
   while( _get_GCIO(hGCT)!=EOF ) {
-    if( GetGCWhatIs_GCIO(hGCT)==vComType_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vComType_GCIO )
     {
       continue;
     }
-    if( GetGCWhatIs_GCIO(hGCT)==vHeader_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vHeader_GCIO )
     {
       if( strstr(GetGCCache_GCIO(hGCT),kConfigEndField_GCIO)!=NULL)
       {
@@ -3612,11 +3614,11 @@ static OGRErr GCIOAPI_CALL _readConfigSubTypeType_GCIO (
   sys= v2D_GCIO;
   theSubType= NULL;
   while( _get_GCIO(hGCT)!=EOF ) {
-    if( GetGCWhatIs_GCIO(hGCT)==vComType_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vComType_GCIO )
     {
       continue;
     }
-    if( GetGCWhatIs_GCIO(hGCT)==vHeader_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vHeader_GCIO )
     {
       if( strstr(GetGCCache_GCIO(hGCT),kConfigEndSubType_GCIO)!=NULL)
       {
@@ -3796,11 +3798,11 @@ static OGRErr GCIOAPI_CALL _readConfigType_GCIO (
   id= UNDEFINEDID_GCIO;
   theClass= NULL;
   while( _get_GCIO(hGCT)!=EOF ) {
-    if( GetGCWhatIs_GCIO(hGCT)==vComType_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vComType_GCIO )
     {
       continue;
     }
-    if( GetGCWhatIs_GCIO(hGCT)==vHeader_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vHeader_GCIO )
     {
       if( strstr(GetGCCache_GCIO(hGCT),kConfigEndType_GCIO)!=NULL )
       {
@@ -3924,11 +3926,11 @@ static OGRErr GCIOAPI_CALL _readConfigMap_GCIO (
 
   eom= 0;
   while( _get_GCIO(hGCT)!=EOF ) {
-    if( GetGCWhatIs_GCIO(hGCT)==vComType_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vComType_GCIO )
     {
       continue;
     }
-    if( GetGCWhatIs_GCIO(hGCT)==vHeader_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vHeader_GCIO )
     {
       if( strstr(GetGCCache_GCIO(hGCT),kConfigEndMap_GCIO)!=NULL )
       {
@@ -4017,7 +4019,7 @@ GCExportFileMetadata GCIOAPI_CALL1(*) ReadConfig_GCIO (
   {
     return NULL;
   }
-  if( GetGCWhatIs_GCIO(hGCT)!=vHeader_GCIO &&
+  if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) != vHeader_GCIO &&
       strstr(GetGCCache_GCIO(hGCT),kConfigBeginConfig_GCIO)==NULL )
   {
     CPLError( CE_Failure, CPLE_AppDefined,
@@ -4032,11 +4034,11 @@ GCExportFileMetadata GCIOAPI_CALL1(*) ReadConfig_GCIO (
   }
   while( _get_GCIO(hGCT)!=EOF )
   {
-    if( GetGCWhatIs_GCIO(hGCT)==vComType_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vComType_GCIO )
     {
       continue;
     }
-    if( GetGCWhatIs_GCIO(hGCT)==vHeader_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGCT) == vHeader_GCIO )
     {
       if( strstr(GetGCCache_GCIO(hGCT),kConfigEndConfig_GCIO)!=NULL )
       {
@@ -4581,7 +4583,7 @@ GCExportFileMetadata GCIOAPI_CALL1(*) ReadHeader_GCIO (
   {
     return NULL;
   }
-  if( GetGCWhatIs_GCIO(hGXT)!=vPragma_GCIO )
+  if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGXT)!=vPragma_GCIO )
   {
     CPLDebug( "GEOCONCEPT",
               "Geoconcept export badly formatted :"
@@ -4597,11 +4599,11 @@ GCExportFileMetadata GCIOAPI_CALL1(*) ReadHeader_GCIO (
   SetMetaExtent_GCIO(Meta, CreateExtent_GCIO(HUGE_VAL,HUGE_VAL,-HUGE_VAL,-HUGE_VAL));
   while( _get_GCIO(hGXT)!=EOF )
   {
-    if( GetGCWhatIs_GCIO(hGXT)==vComType_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGXT)==vComType_GCIO )
     {
       continue;
     }
-    if( GetGCWhatIs_GCIO(hGXT)==vPragma_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(hGXT)==vPragma_GCIO )
     {
       /* try config header first ... */
       if( !_parsePragma_GCIO(hGXT) )
@@ -5352,12 +5354,12 @@ OGRFeatureH GCIOAPI_CALL ReadNextFeature_GCIO (
   d= vUnknown3D_GCIO;
   while( _get_GCIO(H)!=EOF )
   {
-    if( GetGCWhatIs_GCIO(H)==vComType_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(H) == vComType_GCIO )
     {
       continue;
     }
     /* analyze the line according to schema : */
-    if( GetGCWhatIs_GCIO(H)==vPragma_GCIO )
+    if( (enum _tIO_MetadataType_GCIO)GetGCWhatIs_GCIO(H) == vPragma_GCIO )
     {
       if( strstr(GetGCCache_GCIO(H),k3DOBJECTMONO_GCIO) )
       {
@@ -5382,4 +5384,3 @@ OGRFeatureH GCIOAPI_CALL ReadNextFeature_GCIO (
 
   return f;
 }/* ReadNextFeature_GCIO */
-
diff --git a/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp b/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp
index 60829a0..0cb909d 100644
--- a/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp
+++ b/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp
@@ -86,7 +86,7 @@ OGRDataSource *OGRGeoconceptDriver::CreateDataSource( const char* pszName,
 
 {
     VSIStatBuf  stat;
-    int         bSingleNewFile = FALSE;
+    /* int bSingleNewFile = FALSE; */
 
     if( pszName==NULL || strlen(pszName)==0 )
     {
@@ -118,7 +118,7 @@ OGRDataSource *OGRGeoconceptDriver::CreateDataSource( const char* pszName,
              EQUAL(CPLGetExtension(pszName),"txt")
            )
     {
-        bSingleNewFile = TRUE;
+        /* bSingleNewFile = TRUE; */
     }
 
 /* -------------------------------------------------------------------- */
diff --git a/ogr/ogrsf_frmts/geojson/ogr_geojson.h b/ogr/ogrsf_frmts/geojson/ogr_geojson.h
index 588067a..9d870d0 100644
--- a/ogr/ogrsf_frmts/geojson/ogr_geojson.h
+++ b/ogr/ogrsf_frmts/geojson/ogr_geojson.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogr_geojson.h 27718 2014-09-21 16:55:01Z goatbar $
+ * $Id: ogr_geojson.h 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Definitions of OGR OGRGeoJSON driver types.
@@ -83,7 +83,7 @@ private:
     FeaturesSeq::iterator iterCurrent_;
 
     /* poDS_ retained for ABI compatibility. */
-    CPL_UNUSED OGRGeoJSONDataSource* poDS_;
+    /* CPL_UNUSED */ OGRGeoJSONDataSource* poDS_;
     OGRFeatureDefn* poFeatureDefn_;
     CPLString sFIDColumn_;
 };
@@ -237,4 +237,3 @@ public:
 };
 
 #endif /* OGR_GEOJSON_H_INCLUDED */
-
diff --git a/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp b/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp
index 41afbb1..3bebd3f 100644
--- a/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp
+++ b/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogresrijsonreader.cpp 27268 2014-05-01 10:46:20Z rouault $
+ * $Id: ogresrijsonreader.cpp 28350 2015-01-23 17:53:57Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implementation of OGRESRIJSONReader class (OGR ESRIJSON Driver)
@@ -400,7 +400,7 @@ OGRESRIJSONReader::ReadFeatureCollection( json_object* poObj )
 
     if( json_type_array == json_object_get_type( poObjFeatures ) )
     {
-        bool bAdded = false;
+        /* bool bAdded = false; */
         OGRFeature* poFeature = NULL;
         json_object* poObjFeature = NULL;
 
@@ -412,7 +412,7 @@ OGRESRIJSONReader::ReadFeatureCollection( json_object* poObj )
                 json_object_get_type(poObjFeature) == json_type_object)
             {
                 poFeature = OGRESRIJSONReader::ReadFeature( poObjFeature );
-                bAdded = AddFeature( poFeature );
+                /* bAdded = */ AddFeature( poFeature );
             }
             //CPLAssert( bAdded );
         }
@@ -775,7 +775,7 @@ OGRLineString* OGRESRIJSONReadLineString( json_object* poObj)
 /*                          OGRESRIJSONReadPolygon()                    */
 /************************************************************************/
 
-OGRPolygon* OGRESRIJSONReadPolygon( json_object* poObj)
+OGRGeometry* OGRESRIJSONReadPolygon( json_object* poObj)
 {
     CPLAssert( NULL != poObj );
 
@@ -789,8 +789,6 @@ OGRPolygon* OGRESRIJSONReadPolygon( json_object* poObj)
                   "Failed to parse hasZ and/or hasM from geometry" );
     }
 
-    OGRPolygon* poPoly = NULL;
-
     json_object* poObjRings = OGRGeoJSONFindMemberByName( poObj, "rings" );
     if( NULL == poObjRings )
     {
@@ -808,23 +806,26 @@ OGRPolygon* OGRESRIJSONReadPolygon( json_object* poObj)
         return NULL;
     }
 
-    poPoly = new OGRPolygon();
-
     const int nRings = json_object_array_length( poObjRings );
+    OGRGeometry** papoGeoms = new OGRGeometry*[nRings];
     for(int iRing = 0; iRing < nRings; iRing ++)
     {
         json_object* poObjRing = json_object_array_get_idx( poObjRings, iRing );
         if ( poObjRing == NULL ||
                 json_type_array != json_object_get_type( poObjRing ) )
         {
-            delete poPoly;
+            for(int j=0;j<iRing;j++)
+                delete papoGeoms[j];
+            delete[] papoGeoms;
             CPLDebug( "ESRIJSON",
                     "Polygon: got non-array object." );
             return NULL;
         }
 
+        OGRPolygon* poPoly = new OGRPolygon();
         OGRLinearRing* poLine = new OGRLinearRing();
         poPoly->addRingDirectly(poLine);
+        papoGeoms[iRing] = poPoly;
 
         const int nPoints = json_object_array_length( poObjRing );
         for(int i = 0; i < nPoints; i++)
@@ -836,7 +837,9 @@ OGRPolygon* OGRESRIJSONReadPolygon( json_object* poObj)
             poObjCoords = json_object_array_get_idx( poObjRing, i );
             if( !OGRESRIJSONReaderParseXYZMArray (poObjCoords, &dfX, &dfY, &dfZ, &nNumCoords) )
             {
-                delete poPoly;
+                for(int j=0;j<=iRing;j++)
+                    delete papoGeoms[j];
+                delete[] papoGeoms;
                 return NULL;
             }
 
@@ -850,8 +853,14 @@ OGRPolygon* OGRESRIJSONReadPolygon( json_object* poObj)
             }
         }
     }
+    
+    OGRGeometry* poRet = OGRGeometryFactory::organizePolygons( papoGeoms,
+                                                               nRings,
+                                                               NULL,
+                                                               NULL);
+    delete[] papoGeoms;
 
-    return poPoly;
+    return poRet;
 }
 
 /************************************************************************/
diff --git a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp
index 48bf918..55c3f4e 100644
--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp
+++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrgeojsonreader.cpp 27613 2014-08-30 15:55:30Z rouault $
+ * $Id: ogrgeojsonreader.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implementation of OGRGeoJSONReader class (OGR GeoJSON Driver).
@@ -422,7 +422,7 @@ bool OGRGeoJSONReader::GenerateLayerDefn( OGRGeoJSONLayer* poLayer, json_object*
     OGRFeatureDefn* poLayerDefn = poLayer->GetLayerDefn();
     CPLAssert( NULL != poLayerDefn );
 
-    bool bHasFID = false;
+    /* bool bHasFID = false; */
 
     for( int i = 0; i < poLayerDefn->GetFieldCount(); ++i )
     {
@@ -431,7 +431,7 @@ bool OGRGeoJSONReader::GenerateLayerDefn( OGRGeoJSONLayer* poLayer, json_object*
             && OFTInteger == poDefn->GetType() )
         {
             poLayer->SetFIDColumn( poDefn->GetNameRef() );
-            bHasFID = true;
+            /* bHasFID = true; */
             break;
         }
     }
@@ -868,7 +868,7 @@ OGRGeoJSONReader::ReadFeatureCollection( OGRGeoJSONLayer* poLayer, json_object*
 
     if( json_type_array == json_object_get_type( poObjFeatures ) )
     {
-        bool bAdded = false;
+        /* bool bAdded = false; */
         OGRFeature* poFeature = NULL;
         json_object* poObjFeature = NULL;
 
@@ -877,7 +877,7 @@ OGRGeoJSONReader::ReadFeatureCollection( OGRGeoJSONLayer* poLayer, json_object*
         {
             poObjFeature = json_object_array_get_idx( poObjFeatures, i );
             poFeature = ReadFeature( poLayer, poObjFeature );
-            bAdded = AddFeature( poLayer, poFeature );
+            /* bAdded = */ AddFeature( poLayer, poFeature );
             //CPLAssert( bAdded );
         }
         //CPLAssert( nFeatures == poLayer_->GetFeatureCount() );
@@ -1542,4 +1542,3 @@ OGRGeometryH OGR_G_CreateGeometryFromJson( const char* pszJson )
     /* Translation failed */
     return NULL;
 }
-
diff --git a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.h b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.h
index 7c2c26b..789c124 100644
--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.h
+++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrgeojsonreader.h 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrgeojsonreader.h 28350 2015-01-23 17:53:57Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Defines GeoJSON reader within OGR OGRGeoJSON Driver.
@@ -195,7 +195,7 @@ OGRSpatialReference* OGRESRIJSONReadSpatialReference( json_object* poObj );
 OGRwkbGeometryType OGRESRIJSONGetGeometryType( json_object* poObj );
 OGRPoint* OGRESRIJSONReadPoint( json_object* poObj);
 OGRLineString* OGRESRIJSONReadLineString( json_object* poObj);
-OGRPolygon* OGRESRIJSONReadPolygon( json_object* poObj);
+OGRGeometry* OGRESRIJSONReadPolygon( json_object* poObj);
 OGRMultiPoint* OGRESRIJSONReadMultiPoint( json_object* poObj);
 
 /************************************************************************/
diff --git a/ogr/ogrsf_frmts/geomedia/ogrgeomediadatasource.cpp b/ogr/ogrsf_frmts/geomedia/ogrgeomediadatasource.cpp
index 68f36d9..e582daa 100644
--- a/ogr/ogrsf_frmts/geomedia/ogrgeomediadatasource.cpp
+++ b/ogr/ogrsf_frmts/geomedia/ogrgeomediadatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrgeomediadatasource.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrgeomediadatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRGeomediaDataSource class.
@@ -34,7 +34,7 @@
 #include "cpl_string.h"
 #include <vector>
 
-CPL_CVSID("$Id: ogrgeomediadatasource.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrgeomediadatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                       OGRGeomediaDataSource()                        */
@@ -105,8 +105,7 @@ static int CheckDSNStringTemplate(const char* pszStr)
 /************************************************************************/
 
 int OGRGeomediaDataSource::Open( const char * pszNewName, int bUpdate,
-                              int bTestOpen )
-
+                                 CPL_UNUSED int bTestOpen )
 {
     CPLAssert( nLayers == 0 );
 
@@ -323,8 +322,7 @@ OGRSpatialReference* OGRGeomediaDataSource::GetGeomediaSRS(const char* pszGCoord
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRGeomediaDataSource::TestCapability( const char * pszCap )
-
+int OGRGeomediaDataSource::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
diff --git a/ogr/ogrsf_frmts/geomedia/ogrgeomediadriver.cpp b/ogr/ogrsf_frmts/geomedia/ogrgeomediadriver.cpp
index afac77a..a378a69 100644
--- a/ogr/ogrsf_frmts/geomedia/ogrgeomediadriver.cpp
+++ b/ogr/ogrsf_frmts/geomedia/ogrgeomediadriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrgeomediadriver.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrgeomediadriver.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements Personal Geodatabase driver.
@@ -31,7 +31,7 @@
 #include "ogr_geomedia.h"
 #include "cpl_conv.h"
 
-CPL_CVSID("$Id: ogrgeomediadriver.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrgeomediadriver.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                          ~OGRODBCDriver()                            */
@@ -141,8 +141,7 @@ OGRDataSource *OGRGeomediaDriver::Open( const char * pszFilename,
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRGeomediaDriver::TestCapability( const char * pszCap )
-
+int OGRGeomediaDriver::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
@@ -156,4 +155,3 @@ void RegisterOGRGeomedia()
 {
     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRGeomediaDriver );
 }
-
diff --git a/ogr/ogrsf_frmts/geomedia/ogrgeomedialayer.cpp b/ogr/ogrsf_frmts/geomedia/ogrgeomedialayer.cpp
index 3e1d1c1..ecaee4d 100644
--- a/ogr/ogrsf_frmts/geomedia/ogrgeomedialayer.cpp
+++ b/ogr/ogrsf_frmts/geomedia/ogrgeomedialayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrgeomedialayer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrgeomedialayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRGeomediaLayer class, code shared between
@@ -34,7 +34,7 @@
 #include "cpl_string.h"
 #include "ogrgeomediageometry.h"
 
-CPL_CVSID("$Id: ogrgeomedialayer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrgeomedialayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                          OGRGeomediaLayer()                          */
@@ -318,8 +318,7 @@ OGRFeature *OGRGeomediaLayer::GetFeature( long nFeatureId )
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRGeomediaLayer::TestCapability( const char * pszCap )
-
+int OGRGeomediaLayer::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
diff --git a/ogr/ogrsf_frmts/gft/ogrgftlayer.cpp b/ogr/ogrsf_frmts/gft/ogrgftlayer.cpp
index 9317e61..bbfed06 100644
--- a/ogr/ogrsf_frmts/gft/ogrgftlayer.cpp
+++ b/ogr/ogrsf_frmts/gft/ogrgftlayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrgftlayer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrgftlayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  GFT Translator
  * Purpose:  Implements OGRGFTLayer class.
@@ -30,7 +30,7 @@
 #include "ogr_gft.h"
 #include "cpl_minixml.h"
 
-CPL_CVSID("$Id: ogrgftlayer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrgftlayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                            OGRGFTLayer()                             */
@@ -340,8 +340,9 @@ static OGRGeometry* ParseKMLGeometry(/* const */ CPLXMLNode* psXML)
             poColl = new OGRMultiLineString();
         else if (eType == wkbPolygon)
             poColl = new OGRMultiPolygon();
-        else
+        else {
             CPLAssert(0);
+        }
 
         psIter = psXML->psChild;
         for(psIter = psXML->psChild; psIter; psIter = psIter->psNext)
diff --git a/ogr/ogrsf_frmts/gml/gmlhandler.cpp b/ogr/ogrsf_frmts/gml/gmlhandler.cpp
index 13812a9..bbbc117 100644
--- a/ogr/ogrsf_frmts/gml/gmlhandler.cpp
+++ b/ogr/ogrsf_frmts/gml/gmlhandler.cpp
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: gmlhandler.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: gmlhandler.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  GML Reader
  * Purpose:  Implementation of GMLHandler class.
@@ -52,11 +52,10 @@ GMLXercesHandler::GMLXercesHandler( GMLReader *poReader ) : GMLHandler(poReader)
 /*                            startElement()                            */
 /************************************************************************/
 
-void GMLXercesHandler::startElement(const XMLCh* const    uri,
-                                    const XMLCh* const    localname,
-                                    const XMLCh* const    qname,
+void GMLXercesHandler::startElement(CPL_UNUSED const XMLCh* const uri,
+                                    const XMLCh* const localname,
+                                    CPL_UNUSED const XMLCh* const qname,
                                     const Attributes& attrs )
-
 {
     char        szElementName[MAX_TOKEN_SIZE];
 
@@ -89,10 +88,9 @@ void GMLXercesHandler::startElement(const XMLCh* const    uri,
 /************************************************************************/
 /*                             endElement()                             */
 /************************************************************************/
-void GMLXercesHandler::endElement(const   XMLCh* const    uri,
-                                  const   XMLCh* const    localname,
-                                  const   XMLCh* const    qname )
-
+void GMLXercesHandler::endElement(CPL_UNUSED const XMLCh* const uri,
+                                  CPL_UNUSED const XMLCh* const localname,
+                                  CPL_UNUSED const XMLCh* const qname )
 {
     m_nEntityCounter = 0;
 
@@ -107,6 +105,7 @@ void GMLXercesHandler::endElement(const   XMLCh* const    uri,
 /************************************************************************/
 
 void GMLXercesHandler::characters(const XMLCh* const chars_in,
+                                  CPL_UNUSED
 #if XERCES_VERSION_MAJOR >= 3
                                   const XMLSize_t length
 #else
@@ -146,7 +145,7 @@ void GMLXercesHandler::fatalError( const SAXParseException &exception)
 /*                             startEntity()                            */
 /************************************************************************/
 
-void GMLXercesHandler::startEntity (const XMLCh *const name)
+void GMLXercesHandler::startEntity (CPL_UNUSED const XMLCh *const name)
 {
     m_nEntityCounter ++;
     if (m_nEntityCounter > 1000 && !m_poReader->HasStoppedParsing())
@@ -765,7 +764,7 @@ void GMLHandler::DealWithAttributes(const char *pszName, int nLenName, void* att
         if( pszAttrVal == NULL )
             break;
 
-        int nAttrIndex;
+        int nAttrIndex = 0;
         const char* pszAttrKeyNoNS = strchr(pszAttrKey, ':');
         if( pszAttrKeyNoNS != NULL )
             pszAttrKeyNoNS ++;
diff --git a/ogr/ogrsf_frmts/gml/hugefileresolver.cpp b/ogr/ogrsf_frmts/gml/hugefileresolver.cpp
index b2d124a..87cb944 100644
--- a/ogr/ogrsf_frmts/gml/hugefileresolver.cpp
+++ b/ogr/ogrsf_frmts/gml/hugefileresolver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: hugefileresolver.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: hugefileresolver.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  GML Reader
  * Purpose:  Implementation of GMLReader::HugeFileResolver() method.
@@ -47,7 +47,7 @@
 
 #include <stack>
 
-CPL_CVSID("$Id: hugefileresolver.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: hugefileresolver.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /****************************************************/
 /*      SQLite is absolutely required in order to   */
@@ -376,7 +376,7 @@ static int gmlHugeFileResolveEdges( struct huge_helper *helper )
         sqlite3_finalize ( hUpdateStmt );
         return FALSE;
     }
-    
+
     /* looping on the QUERY result-set */
     while ( TRUE )
     {
@@ -391,7 +391,7 @@ static int gmlHugeFileResolveEdges( struct huge_helper *helper )
         int             bIsYFromNull;
         double          zFrom = 0.0;
         int             bIsZFromNull;
-        const char      *pszNodeFromId = NULL;
+        /* const char      *pszNodeFromId = NULL; */
         int             bIsNodeFromIdNull;
         double          xNodeFrom = 0.0;
         int             bIsXNodeFromNull;
@@ -407,7 +407,7 @@ static int gmlHugeFileResolveEdges( struct huge_helper *helper )
         int             bIsYToNull;
         double          zTo = 0.0;
         int             bIsZToNull;
-        const char      *pszNodeToId = NULL;
+        /* const char      *pszNodeToId = NULL; */
         int             bIsNodeToIdNull;
         double          xNodeTo = 0.0;
         int             bIsXNodeToNull;
@@ -462,7 +462,8 @@ static int gmlHugeFileResolveEdges( struct huge_helper *helper )
                 bIsNodeFromIdNull = TRUE;
             else
             {
-                pszNodeFromId = (const char *) sqlite3_column_text( hQueryStmt, 6 );
+                /* TODO: Can sqlite3_column_text be removed? */
+                /* pszNodeFromId = (const char *) */ sqlite3_column_text( hQueryStmt, 6 );
                 bIsNodeFromIdNull = FALSE;
             }
             if( sqlite3_column_type( hQueryStmt, 7 ) == SQLITE_NULL )
@@ -518,7 +519,8 @@ static int gmlHugeFileResolveEdges( struct huge_helper *helper )
                 bIsNodeToIdNull = TRUE;
             else
             {
-                pszNodeToId = (const char *) sqlite3_column_text( hQueryStmt, 14 );
+                /* TODO: Can sqlite3_column_text be removed? */
+                /* pszNodeToId = (const char *) */ sqlite3_column_text( hQueryStmt, 14 );
                 bIsNodeToIdNull = FALSE;
             }
             if( sqlite3_column_type( hQueryStmt, 15 ) == SQLITE_NULL )
diff --git a/ogr/ogrsf_frmts/gmt/ogrgmtlayer.cpp b/ogr/ogrsf_frmts/gmt/ogrgmtlayer.cpp
index 6e76328..0878fb9 100644
--- a/ogr/ogrsf_frmts/gmt/ogrgmtlayer.cpp
+++ b/ogr/ogrsf_frmts/gmt/ogrgmtlayer.cpp
@@ -440,9 +440,11 @@ int OGRGmtLayer::NextIsFeature()
 OGRFeature *OGRGmtLayer::GetNextRawFeature()
 
 {
-    int  bMultiVertex = 
+#if 0
+    int  bMultiVertex =
         poFeatureDefn->GetGeomType() != wkbPoint
         && poFeatureDefn->GetGeomType() != wkbUnknown;
+#endif
     CPLString osFieldData;
     OGRGeometry *poGeom = NULL;
 
@@ -502,13 +504,13 @@ OGRFeature *OGRGmtLayer::GetNextRawFeature()
             else if( poFeatureDefn->GetGeomType() == wkbUnknown )
             {
                 poFeatureDefn->SetGeomType( wkbLineString );
-                bMultiVertex = TRUE;
+                /* bMultiVertex = TRUE; */
             }
         }
         else if( osLine[0] == '#' )
         {
             int i;
-            for( i = 0; 
+            for( i = 0;
                  papszKeyedValues != NULL && papszKeyedValues[i] != NULL; 
                  i++ )
             {
diff --git a/ogr/ogrsf_frmts/grass/ogrgrassdatasource.cpp b/ogr/ogrsf_frmts/grass/ogrgrassdatasource.cpp
index 9298c45..c95ce7e 100644
--- a/ogr/ogrsf_frmts/grass/ogrgrassdatasource.cpp
+++ b/ogr/ogrsf_frmts/grass/ogrgrassdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrgrassdatasource.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrgrassdatasource.cpp 28291 2015-01-05 14:45:07Z martinl $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRGRASSDataSource class.
@@ -32,7 +32,11 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrgrassdatasource.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrgrassdatasource.cpp 28291 2015-01-05 14:45:07Z martinl $");
+
+#if GRASS_VERSION_MAJOR  >= 7
+#define G__setenv                G_setenv_nogisrc
+#endif
 
 /************************************************************************/
 /*                         Grass2CPLErrorHook()                         */
diff --git a/ogr/ogrsf_frmts/ili/ili1reader.cpp b/ogr/ogrsf_frmts/ili/ili1reader.cpp
index c2e7234..730d7eb 100644
--- a/ogr/ogrsf_frmts/ili/ili1reader.cpp
+++ b/ogr/ogrsf_frmts/ili/ili1reader.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ili1reader.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ili1reader.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Interlis 1 Reader
  * Purpose:  Implementation of ILI1Reader class.
@@ -50,7 +50,7 @@
 #  endif
 #endif
 
-CPL_CVSID("$Id: ili1reader.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ili1reader.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 //
 // ILI1Reader
@@ -247,7 +247,7 @@ int ILI1Reader::AddIliGeom(OGRFeature *feature, int iField, long fpos)
 }
 
 
-int ILI1Reader::ReadTable(const char *layername) {
+int ILI1Reader::ReadTable(CPL_UNUSED const char *layername) {
     char **tokens = NULL;
     const char *firsttok = NULL;
     int ret = TRUE;
diff --git a/ogr/ogrsf_frmts/ili/ili2handler.cpp b/ogr/ogrsf_frmts/ili/ili2handler.cpp
index f30dc30..c00719b 100644
--- a/ogr/ogrsf_frmts/ili/ili2handler.cpp
+++ b/ogr/ogrsf_frmts/ili/ili2handler.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ili2handler.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ili2handler.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Interlis 2 Reader
  * Purpose:  Implementation of ILI2Handler class.
@@ -35,7 +35,7 @@
 #include "ili2readerp.h"
 #include <xercesc/sax2/Attributes.hpp>
 
-CPL_CVSID("$Id: ili2handler.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ili2handler.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 // 
 // constants
@@ -86,22 +86,21 @@ void ILI2Handler::startDocument() {
 void ILI2Handler::endDocument() {
   // nothing to do
 }
-    
+
 void ILI2Handler::startElement(
-        const   XMLCh* const    uri,
-        const   XMLCh* const    localname,
-        const   XMLCh* const    qname,
-        const   Attributes& attrs
+    CPL_UNUSED const XMLCh* const uri,
+    CPL_UNUSED const XMLCh* const localname,
+    const XMLCh* const qname,
+    const Attributes& attrs
     ) {
-  
   // start to add the layers, features with the DATASECTION
   char *tmpC = NULL;
   m_nEntityCounter = 0;
   if ((level >= 0) || (cmpStr(ILI2_DATASECTION, tmpC = XMLString::transcode(qname)) == 0)) {
     level++;
-    
-    if (level >= 2) { 
-      
+
+    if (level >= 2) {
+
       // create the dom tree
       DOMElement *elem = (DOMElement*)dom_doc->createElement(qname);
       
@@ -117,15 +116,14 @@ void ILI2Handler::startElement(
 }
 
 void ILI2Handler::endElement(
-        const   XMLCh* const    uri,
-        const   XMLCh* const    localname,
-        const   XMLCh* const    qname
+    CPL_UNUSED const XMLCh* const uri,
+    CPL_UNUSED const XMLCh* const localname,
+    CPL_UNUSED const XMLCh* const qname
     ) {
-    
   m_nEntityCounter = 0;
   if (level >= 0) {
     if (level == 2) {
-    
+
       // go to the parent element and parse the child element
       DOMElement* childElem = dom_elem;
       dom_elem = (DOMElement*)dom_elem->getParentNode();
@@ -135,7 +133,7 @@ void ILI2Handler::endElement(
       // remove the child element
       childElem = (DOMElement*)dom_elem->removeChild(childElem);
     } else if (level >= 3) {
-    
+
       // go to the parent element
       dom_elem = (DOMElement*)dom_elem->getParentNode();
     }
@@ -149,16 +147,15 @@ void ILI2Handler::endElement(
 /************************************************************************/
 
 void ILI2Handler::characters( const XMLCh *const chars,
-                     const XMLSize_t length ) {
-  
+                              CPL_UNUSED const XMLSize_t length ) {
   // add the text element
   if (level >= 3) {
     char *tmpC = XMLString::transcode(chars);
-    
+
     // only add the text if it is not empty
-    if (trim(tmpC) != "") 
+    if (trim(tmpC) != "")
       dom_elem->appendChild(dom_doc->createTextNode(chars));
-    
+
     XMLString::release(&tmpC);
   }
 }
@@ -184,7 +181,7 @@ void ILI2Handler::characters( const XMLCh *const chars,
 }
 #endif
 
-void ILI2Handler::startEntity (const XMLCh *const name)
+void ILI2Handler::startEntity (CPL_UNUSED const XMLCh *const name)
 {
     m_nEntityCounter++;
     if (m_nEntityCounter > 1000)
diff --git a/ogr/ogrsf_frmts/ili/ili2reader.cpp b/ogr/ogrsf_frmts/ili/ili2reader.cpp
index bf3b24c..39154bb 100644
--- a/ogr/ogrsf_frmts/ili/ili2reader.cpp
+++ b/ogr/ogrsf_frmts/ili/ili2reader.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ili2reader.cpp 27187 2014-04-14 23:26:02Z rouault $
+ * $Id: ili2reader.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Interlis 2 Reader
  * Purpose:  Implementation of ILI2Reader class.
@@ -41,7 +41,7 @@ char *tr_strdup( const XMLCh * );
 
 using namespace std;
 
-CPL_CVSID("$Id: ili2reader.cpp 27187 2014-04-14 23:26:02Z rouault $");
+CPL_CVSID("$Id: ili2reader.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 //
 // constants
@@ -93,7 +93,7 @@ string ltrim(string tmpstr) {
 string rtrim(string tmpstr) {
   if (tmpstr.length() == 0) return tmpstr;
   unsigned int i = tmpstr.length() - 1;
-  while (i >= 0 && (tmpstr[i] == ' ' || tmpstr[i] == '\t' || tmpstr[i] == '\r' || tmpstr[i] == '\n')) --i;
+  while (tmpstr[i] == ' ' || tmpstr[i] == '\t' || tmpstr[i] == '\r' || tmpstr[i] == '\n') --i;
   return i < tmpstr.length() - 1 ? tmpstr.substr(0, i+1) : tmpstr;
 }
 
@@ -176,7 +176,7 @@ OGRLineString *ILI2Reader::getArc(DOMElement *elem) {
   OGRPoint *ptEnd = new OGRPoint();
   // point on the arc
   OGRPoint *ptOnArc = new OGRPoint();
-  double radius = 0; // radius
+  // double radius = 0; // radius
 
   DOMElement *arcElem = (DOMElement *)elem->getFirstChild();
   while (arcElem != NULL) {
@@ -194,8 +194,9 @@ OGRLineString *ILI2Reader::getArc(DOMElement *elem) {
       ptOnArc->setY(atof(pszObjValue));
     else if (cmpStr("A3", pszTagName) == 0)
       ptOnArc->setZ(atof(pszObjValue));
-    else if (cmpStr("R", pszTagName) == 0)
-      radius = atof(pszObjValue);
+    else if (cmpStr("R", pszTagName) == 0) {
+      // radius = atof(pszObjValue);
+    }
     CPLFree(pszObjValue);
     XMLString::release(&pszTagName);
     arcElem = (DOMElement *)arcElem->getNextSibling();
@@ -232,7 +233,7 @@ OGRLineString *getLineString(DOMElement *elem, int bAsLinearRing) {
       // point on the arc
       OGRPoint *ptOnArc = new OGRPoint();
       // radius
-      double radius = 0;
+      // double radius = 0;
 
       DOMElement *arcElem = (DOMElement *)lineElem->getFirstChild();
       while (arcElem != NULL) {
@@ -250,8 +251,9 @@ OGRLineString *getLineString(DOMElement *elem, int bAsLinearRing) {
           ptOnArc->setY(atof(pszObjValue));
         else if (cmpStr("A3", pszTagName) == 0)
           ptOnArc->setZ(atof(pszObjValue));
-        else if (cmpStr("R", pszTagName) == 0)
-          radius = atof(pszObjValue);
+        else if (cmpStr("R", pszTagName) == 0) {
+          // radius = atof(pszObjValue);
+        }
         CPLFree(pszObjValue);
         XMLString::release(&pszTagName);
 
diff --git a/ogr/ogrsf_frmts/ili/ogrili1datasource.cpp b/ogr/ogrsf_frmts/ili/ogrili1datasource.cpp
index 33ec4a1..8e547d5 100644
--- a/ogr/ogrsf_frmts/ili/ogrili1datasource.cpp
+++ b/ogr/ogrsf_frmts/ili/ogrili1datasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrili1datasource.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrili1datasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Interlis 1 Translator
  * Purpose:  Implements OGRILI1DataSource class.
@@ -36,7 +36,7 @@
 
 #include <string>
 
-CPL_CVSID("$Id: ogrili1datasource.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrili1datasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                         OGRILI1DataSource()                         */
@@ -181,8 +181,7 @@ int OGRILI1DataSource::Open( const char * pszNewName, int bTestOpen )
 /************************************************************************/
 
 int OGRILI1DataSource::Create( const char *pszFilename,
-                              char **papszOptions )
-
+                               CPL_UNUSED char **papszOptions )
 {
     std::string osBasename, osModelFilename;
     char **filenames = CSLTokenizeString2( pszFilename, ",", 0 );
@@ -248,10 +247,9 @@ static char *ExtractTopic(const char * pszLayerName)
 
 OGRLayer *
 OGRILI1DataSource::CreateLayer( const char * pszLayerName,
-                               OGRSpatialReference *poSRS,
-                               OGRwkbGeometryType eType,
-                               char ** papszOptions )
-
+                                CPL_UNUSED OGRSpatialReference *poSRS,
+                                OGRwkbGeometryType eType,
+                                CPL_UNUSED char ** papszOptions )
 {
     FeatureDefnInfo featureDefnInfo = poImdReader->GetFeatureDefnInfo(pszLayerName);
     const char *table = pszLayerName;
diff --git a/ogr/ogrsf_frmts/ili/ogrili1layer.cpp b/ogr/ogrsf_frmts/ili/ogrili1layer.cpp
index 084be5a..578e2ec 100644
--- a/ogr/ogrsf_frmts/ili/ogrili1layer.cpp
+++ b/ogr/ogrsf_frmts/ili/ogrili1layer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrili1layer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrili1layer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Interlis 1 Translator
  * Purpose:  Implements OGRILI1Layer class.
@@ -33,7 +33,7 @@
 #include "cpl_string.h"
 #include "ogr_geos.h"
 
-CPL_CVSID("$Id: ogrili1layer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrili1layer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                           OGRILI1Layer()                              */
@@ -376,15 +376,15 @@ OGRErr OGRILI1Layer::CreateFeature( OGRFeature *poFeature ) {
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRILI1Layer::TestCapability( const char * pszCap ) {
-        return FALSE;
+int OGRILI1Layer::TestCapability( CPL_UNUSED const char * pszCap ) {
+    return FALSE;
 }
 
 /************************************************************************/
 /*                            CreateField()                             */
 /************************************************************************/
 
-OGRErr OGRILI1Layer::CreateField( OGRFieldDefn *poField, int bApproxOK ) {
+OGRErr OGRILI1Layer::CreateField( OGRFieldDefn *poField, CPL_UNUSED int bApproxOK ) {
     poFeatureDefn->AddFieldDefn( poField );
 
     return OGRERR_NONE;
diff --git a/ogr/ogrsf_frmts/ili/ogrili2datasource.cpp b/ogr/ogrsf_frmts/ili/ogrili2datasource.cpp
index aae02e0..1b135af 100644
--- a/ogr/ogrsf_frmts/ili/ogrili2datasource.cpp
+++ b/ogr/ogrsf_frmts/ili/ogrili2datasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrili2datasource.cpp 27184 2014-04-14 22:21:56Z pka $
+ * $Id: ogrili2datasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Interlis 2 Translator
  * Purpose:  Implements OGRILI2DataSource class.
@@ -37,7 +37,7 @@
 using namespace std;
 
 
-CPL_CVSID("$Id: ogrili2datasource.cpp 27184 2014-04-14 22:21:56Z pka $");
+CPL_CVSID("$Id: ogrili2datasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                         OGRILI2DataSource()                         */
@@ -179,8 +179,8 @@ int OGRILI2DataSource::Open( const char * pszNewName, int bTestOpen )
 /*                               Create()                               */
 /************************************************************************/
 
-int OGRILI2DataSource::Create( const char *pszFilename, 
-                              char **papszOptions )
+int OGRILI2DataSource::Create( const char *pszFilename,
+                               CPL_UNUSED char **papszOptions )
 
 {
     char **filenames = CSLTokenizeString2( pszFilename, ",", 0 );
@@ -260,10 +260,9 @@ int OGRILI2DataSource::Create( const char *pszFilename,
 
 OGRLayer *
 OGRILI2DataSource::CreateLayer( const char * pszLayerName,
-                               OGRSpatialReference *poSRS,
-                               OGRwkbGeometryType eType,
-                               char ** papszOptions )
-
+                                CPL_UNUSED OGRSpatialReference *poSRS,
+                                OGRwkbGeometryType eType,
+                                CPL_UNUSED char ** papszOptions )
 {
     if (fpOutput == NULL)
         return NULL;
diff --git a/ogr/ogrsf_frmts/ili/ogrili2layer.cpp b/ogr/ogrsf_frmts/ili/ogrili2layer.cpp
index a214b97..ad17b9f 100644
--- a/ogr/ogrsf_frmts/ili/ogrili2layer.cpp
+++ b/ogr/ogrsf_frmts/ili/ogrili2layer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrili2layer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrili2layer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  Interlis 2 Translator
  * Purpose:  Implements OGRILI2Layer class.
@@ -32,7 +32,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrili2layer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrili2layer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                           OGRILI2Layer()                              */
@@ -325,15 +325,15 @@ OGRErr OGRILI2Layer::CreateFeature( OGRFeature *poFeature ) {
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRILI2Layer::TestCapability( const char * pszCap ) {
-   return FALSE;
+int OGRILI2Layer::TestCapability( CPL_UNUSED const char * pszCap ) {
+    return FALSE;
 }
 
 /************************************************************************/
 /*                            CreateField()                             */
 /************************************************************************/
 
-OGRErr OGRILI2Layer::CreateField( OGRFieldDefn *poField, int bApproxOK ) {
+OGRErr OGRILI2Layer::CreateField( OGRFieldDefn *poField, CPL_UNUSED int bApproxOK ) {
     poFeatureDefn->AddFieldDefn( poField );
     return OGRERR_NONE;
 }
diff --git a/ogr/ogrsf_frmts/libkml/ogr_libkml.h b/ogr/ogrsf_frmts/libkml/ogr_libkml.h
index 92fa90d..c403c06 100644
--- a/ogr/ogrsf_frmts/libkml/ogr_libkml.h
+++ b/ogr/ogrsf_frmts/libkml/ogr_libkml.h
@@ -355,8 +355,6 @@ class OGRLIBKMLDataSource:public OGRDataSource
 
 class OGRLIBKMLDriver:public OGRSFDriver
 {
-    KmlFactory               *m_poKmlFactory;
-    
   public:
     OGRLIBKMLDriver           (  );
     ~OGRLIBKMLDriver          (  );
diff --git a/ogr/ogrsf_frmts/libkml/ogrlibkmldatasource.cpp b/ogr/ogrsf_frmts/libkml/ogrlibkmldatasource.cpp
index 641b8a5..14af048 100644
--- a/ogr/ogrsf_frmts/libkml/ogrlibkmldatasource.cpp
+++ b/ogr/ogrsf_frmts/libkml/ogrlibkmldatasource.cpp
@@ -1453,7 +1453,7 @@ int OGRLIBKMLDataSource::Open (
 
     /***** dir *****/
 
-    VSIStatBufL sStatBuf = { };
+    VSIStatBufL sStatBuf;
     if ( !VSIStatExL ( pszFilename, &sStatBuf, VSI_STAT_NATURE_FLAG ) &&
          VSI_ISDIR ( sStatBuf.st_mode ) )
         return OpenDir ( pszFilename, bUpdate );
@@ -1727,16 +1727,16 @@ void OGRLIBKMLDataSource::ParseDocumentOptions(KmlPtr poKml,
 
 /******************************************************************************
  method to create a single file .kml ds
- 
+
  Args:          pszFilename     the datasource to create
                 papszOptions    datasource creation options
- 
+
  Returns:       True on success, false on failure
 
 ******************************************************************************/
 
 int OGRLIBKMLDataSource::CreateKml (
-    const char *pszFilename,
+    CPL_UNUSED const char *pszFilename,
     char **papszOptions )
 {
     m_poKmlDSKml = OGRLIBKMLCreateOGCKml22(m_poKmlFactory, papszOptions);
@@ -1755,20 +1755,18 @@ int OGRLIBKMLDataSource::CreateKml (
 
 /******************************************************************************
  method to create a .kmz ds
- 
+
  Args:          pszFilename     the datasource to create
                 papszOptions    datasource creation options
- 
+
  Returns:       True on success, false on failure
 
 ******************************************************************************/
 
 int OGRLIBKMLDataSource::CreateKmz (
-    const char *pszFilename,
-    char **papszOptions )
+    CPL_UNUSED const char *pszFilename,
+    CPL_UNUSED char **papszOptions )
 {
-
-
     /***** create the doc.kml  *****/
     if( osUpdateTargetHref.size() == 0 )
     {
@@ -1790,19 +1788,18 @@ int OGRLIBKMLDataSource::CreateKmz (
 
 /******************************************************************************
  Method to create a dir datasource
- 
+
  Args:          pszFilename     the datasource to create
                 papszOptions    datasource creation options
- 
+
  Returns:       True on success, false on failure
 
 ******************************************************************************/
 
 int OGRLIBKMLDataSource::CreateDir (
     const char *pszFilename,
-    char **papszOptions )
+    CPL_UNUSED char **papszOptions )
 {
-
     if ( VSIMkdir ( pszFilename, 0755 ) ) {
         CPLError ( CE_Failure, CPLE_AppDefined,
                    "ERROR Creating dir: %s for KML datasource", pszFilename );
@@ -2059,7 +2056,7 @@ OGRErr OGRLIBKMLDataSource::DeleteLayer (
         const char *pszFilePath =
             CPLFormFilename ( pszName, papoLayers[iLayer]->GetFileName (  ),
                               NULL );
-        VSIStatBufL oStatBufL = { };
+        VSIStatBufL oStatBufL;
         if ( !VSIStatL ( pszFilePath, &oStatBufL ) ) {
             if ( VSIUnlink ( pszFilePath ) ) {
                 CPLError ( CE_Failure, CPLE_AppDefined,
@@ -2130,12 +2127,12 @@ OGRLIBKMLLayer *OGRLIBKMLDataSource::CreateLayerKml (
 
 /******************************************************************************
  method to create a layer in a .kmz or dir
- 
+
  Args:          pszLayerName    name of the layer to create
                 poOgrSRS        the SRS of the layer
                 eGType          the layers geometry type
                 papszOptions    layer creation options
- 
+
  Returns:       return a pointer to the new layer or NULL on failure
 
 ******************************************************************************/
@@ -2144,11 +2141,11 @@ OGRLIBKMLLayer *OGRLIBKMLDataSource::CreateLayerKmz (
     const char *pszLayerName,
     OGRSpatialReference * poOgrSRS,
     OGRwkbGeometryType eGType,
-    char **papszOptions )
+    CPL_UNUSED char **papszOptions )
 {
     OGRLIBKMLLayer *poOgrLayer = NULL;
     DocumentPtr poKmlDocument = NULL;
-    
+
     if( m_poKmlUpdate == NULL )
     {
         /***** add a network link to doc.kml *****/
diff --git a/ogr/ogrsf_frmts/libkml/ogrlibkmldriver.cpp b/ogr/ogrsf_frmts/libkml/ogrlibkmldriver.cpp
index 26c8cfc..476be8d 100644
--- a/ogr/ogrsf_frmts/libkml/ogrlibkmldriver.cpp
+++ b/ogr/ogrsf_frmts/libkml/ogrlibkmldriver.cpp
@@ -29,23 +29,21 @@
 #include "ogr_libkml.h"
 #include "cpl_conv.h"
 #include "cpl_error.h"
-#include "cpl_atomic_ops.h"
+#include "cpl_multiproc.h"
 
 #include <kml/dom.h>
 
 using kmldom::KmlFactory;
 
-static volatile int nKmlFactoryRefCount = 0;
-
+static void *hMutex = NULL;
+static KmlFactory *poKmlFactory = NULL;
+    
 /******************************************************************************
  OGRLIBKMLDriver()
 ******************************************************************************/
 
 OGRLIBKMLDriver::OGRLIBKMLDriver (  )
 {
-    CPLAtomicInc(&nKmlFactoryRefCount);
-    m_poKmlFactory = KmlFactory::GetFactory (  );
-
 }
 
 /******************************************************************************
@@ -54,8 +52,10 @@ OGRLIBKMLDriver::OGRLIBKMLDriver (  )
 
 OGRLIBKMLDriver::~OGRLIBKMLDriver (  )
 {
-    if (CPLAtomicDec(&nKmlFactoryRefCount) == 0)
-        delete m_poKmlFactory;
+    if( hMutex != NULL )
+        CPLDestroyMutex(hMutex);
+    hMutex = NULL;
+    poKmlFactory = NULL;
 }
 
 /******************************************************************************
@@ -77,7 +77,19 @@ OGRDataSource *OGRLIBKMLDriver::Open (
     const char *pszFilename,
     int bUpdate )
 {
-    OGRLIBKMLDataSource *poDS = new OGRLIBKMLDataSource ( m_poKmlFactory );
+    VSIStatBufL sStatBuf;
+    if( !EQUAL(CPLGetExtension(pszFilename), "kml") &&
+        !EQUAL(CPLGetExtension(pszFilename), "kmz") &&
+        !(VSIStatL(pszFilename, &sStatBuf) == 0 && VSI_ISDIR(sStatBuf.st_mode)) )
+        return NULL;
+
+    {
+        CPLMutexHolderD(&hMutex);
+        if( poKmlFactory == NULL )
+            poKmlFactory = KmlFactory::GetFactory (  );
+    }
+
+    OGRLIBKMLDataSource *poDS = new OGRLIBKMLDataSource ( poKmlFactory );
 
     if ( !poDS->Open ( pszFilename, bUpdate ) ) {
         delete poDS;
@@ -99,7 +111,13 @@ OGRDataSource *OGRLIBKMLDriver::CreateDataSource (
     CPLAssert ( NULL != pszName );
     CPLDebug ( "LIBKML", "Attempt to create: %s", pszName );
 
-    OGRLIBKMLDataSource *poDS = new OGRLIBKMLDataSource ( m_poKmlFactory );
+    {
+        CPLMutexHolderD(&hMutex);
+        if( poKmlFactory == NULL )
+            poKmlFactory = KmlFactory::GetFactory (  );
+    }
+
+    OGRLIBKMLDataSource *poDS = new OGRLIBKMLDataSource ( poKmlFactory );
 
     if ( !poDS->Create ( pszName, papszOptions ) ) {
         delete poDS;
@@ -124,7 +142,7 @@ OGRErr OGRLIBKMLDriver::DeleteDataSource (
 
     /***** dir *****/
 
-    VSIStatBufL sStatBuf = { };
+    VSIStatBufL sStatBuf;
     if ( !VSIStatL ( pszName, &sStatBuf ) && VSI_ISDIR ( sStatBuf.st_mode ) ) {
 
         char **papszDirList = NULL;
diff --git a/ogr/ogrsf_frmts/libkml/ogrlibkmlfeature.cpp b/ogr/ogrsf_frmts/libkml/ogrlibkmlfeature.cpp
index 20b3e01..49683c1 100644
--- a/ogr/ogrsf_frmts/libkml/ogrlibkmlfeature.cpp
+++ b/ogr/ogrsf_frmts/libkml/ogrlibkmlfeature.cpp
@@ -748,8 +748,8 @@ OGRFeature *kml2feat (
 
 OGRFeature *kmlgroundoverlay2feat (
     GroundOverlayPtr poKmlOverlay,
-    OGRLIBKMLDataSource * poOgrDS,
-    OGRLayer * poOgrLayer,
+    CPL_UNUSED OGRLIBKMLDataSource * poOgrDS,
+    CPL_UNUSED OGRLayer * poOgrLayer,
     OGRFeatureDefn * poOgrFeatDefn,
     OGRSpatialReference *poOgrSRS)
 {
diff --git a/ogr/ogrsf_frmts/libkml/ogrlibkmllayer.cpp b/ogr/ogrsf_frmts/libkml/ogrlibkmllayer.cpp
index bc46414..df3d0a0 100644
--- a/ogr/ogrsf_frmts/libkml/ogrlibkmllayer.cpp
+++ b/ogr/ogrsf_frmts/libkml/ogrlibkmllayer.cpp
@@ -83,10 +83,13 @@ CPLString OGRLIBKMLGetSanitizedNCName(const char* pszName)
         {
             /* ok */
         }
+#if 0
+        /* Always false. */
         else if ( ch > 127 )
         {
             /* ok : this is an approximation */
         }
+#endif
         else
             osName[i] = '_';
     }
@@ -752,18 +755,17 @@ OGRErr OGRLIBKMLLayer::GetExtent (
  Method to create a field on a layer
 
  Args:          poField     pointer to the Field Definition to add
-                bApproxOK   no effect as of now 
+                bApproxOK   no effect as of now
 
  Returns:       OGRERR_NONE on success or OGRERR_UNSUPPORTED_OPERATION if the
                 layer is not writeable
-                
+
 ******************************************************************************/
 
 OGRErr OGRLIBKMLLayer::CreateField (
     OGRFieldDefn * poField,
-    int bApproxOK )
+    CPL_UNUSED int bApproxOK )
 {
-
     if ( !bUpdate )
         return OGRERR_UNSUPPORTED_OPERATION;
 
diff --git a/ogr/ogrsf_frmts/mitab/mitab_bounds.cpp b/ogr/ogrsf_frmts/mitab/mitab_bounds.cpp
index d50b1f0..3f76e6d 100644
--- a/ogr/ogrsf_frmts/mitab/mitab_bounds.cpp
+++ b/ogr/ogrsf_frmts/mitab/mitab_bounds.cpp
@@ -1036,7 +1036,7 @@ static MapInfoBoundsInfo gasBoundsList[] = {
 {{28, 7, 7, {0,-90,90,0,0,0}, 0,-8,160,176, {0,0,0,0,0}},  -10018863.1846597, -10018863.1846597, 10018863.1846597, 10018863.1846597},
 {{28, 7, 7, {0,90,90,0,0,0}, 0,-8,160,176, {0,0,0,0,0}},  -10018863.1846597, -10018863.1846597, 10018863.1846597, 10018863.1846597},
 
-{{0xff, 0, 0, {0,0,0,0,0,0}, 0,0,0,0, {0,0,0,0,0}},  0, 0, 0, 0} 
+{{0xff, 0, 0, {0,0,0,0,0,0}, 0,0,0,0, {0,0,0,0,0}},  0, 0, 0, 0}
 };
 
 
diff --git a/ogr/ogrsf_frmts/mitab/mitab_feature.cpp b/ogr/ogrsf_frmts/mitab/mitab_feature.cpp
index efd6e41..b58acd1 100644
--- a/ogr/ogrsf_frmts/mitab/mitab_feature.cpp
+++ b/ogr/ogrsf_frmts/mitab/mitab_feature.cpp
@@ -2207,7 +2207,7 @@ int TABPolyline::ReadGeometryFromMAPFile(TABMAPFile *poMapFile,
          *============================================================*/
         int     i, iSection;
         GInt32  nCoordBlockPtr, numLineSections;
-        GInt32  nCoordDataSize, numPointsTotal, *panXY;
+        GInt32  /* nCoordDataSize, */ numPointsTotal, *panXY;
         OGRMultiLineString      *poMultiLine;
         TABMAPCoordSecHdr       *pasSecHdrs;
         int nVersion = TAB_GEOM_GET_VERSION(m_nMapInfoType);
@@ -2218,7 +2218,7 @@ int TABPolyline::ReadGeometryFromMAPFile(TABMAPFile *poMapFile,
         TABMAPObjPLine *poPLineHdr = (TABMAPObjPLine *)poObjHdr;
 
         nCoordBlockPtr  = poPLineHdr->m_nCoordBlockPtr;
-        nCoordDataSize  = poPLineHdr->m_nCoordDataSize;
+        /* nCoordDataSize  = poPLineHdr->m_nCoordDataSize; */
         numLineSections = poPLineHdr->m_numLineSections;
         m_bSmooth       = poPLineHdr->m_bSmooth;
 
@@ -3021,7 +3021,7 @@ int TABRegion::ReadGeometryFromMAPFile(TABMAPFile *poMapFile,
          *============================================================*/
         int     i, iSection;
         GInt32  nCoordBlockPtr, numLineSections;
-        GInt32  nCoordDataSize, numPointsTotal, *panXY;
+        GInt32  /* nCoordDataSize, */ numPointsTotal, *panXY;
         OGRMultiPolygon         *poMultiPolygon = NULL;
         OGRPolygon              *poPolygon = NULL;
         TABMAPCoordSecHdr       *pasSecHdrs;
@@ -3034,12 +3034,12 @@ int TABRegion::ReadGeometryFromMAPFile(TABMAPFile *poMapFile,
         TABMAPObjPLine *poPLineHdr = (TABMAPObjPLine *)poObjHdr;
 
         nCoordBlockPtr  = poPLineHdr->m_nCoordBlockPtr;
-        nCoordDataSize  = poPLineHdr->m_nCoordDataSize;
+        /* nCoordDataSize  = poPLineHdr->m_nCoordDataSize; */
         numLineSections = poPLineHdr->m_numLineSections;
         m_bSmooth       = poPLineHdr->m_bSmooth;
 
         // Centroid/label point
-        poMapFile->Int2Coordsys(poPLineHdr->m_nLabelX, poPLineHdr->m_nLabelY, 
+        poMapFile->Int2Coordsys(poPLineHdr->m_nLabelX, poPLineHdr->m_nLabelY,
                                 dX, dY);
         SetCenter(dX, dY);
 
@@ -6159,12 +6159,11 @@ const char *TABText::GetLabelStyleString()
     int nStringLen = strlen(GetTextString());
     // ALL Caps, Extpanded need to modify the string value
     char *pszTextString = (char*)CPLMalloc((nStringLen+1)*sizeof(char));
-    char szPattern[20];
+    /* char szPattern[20]; */
     int nJustification = 1;
-    
+
     strcpy(pszTextString, GetTextString());
-    szPattern[0] = '\0';
-    
+    /* szPattern[0] = '\0'; */
 
     switch(GetTextJustification())
     {
@@ -7259,9 +7258,9 @@ int TABCollection::ReadGeometryFromMAPFile(TABMAPFile *poMapFile,
         // In V800 the mini-header starts with a copy of num_parts
         if (nVersion >= 800)
         {
-            int numParts;
-            numParts = poCoordBlock->ReadInt32();
-            CPLAssert(numParts == poCollHdr->m_nNumRegSections);
+            /* int numParts; */
+            /* numParts = poCoordBlock->ReadInt32(); */
+            CPLAssert(poCoordBlock->ReadInt32() == poCollHdr->m_nNumRegSections);
         }
 
         ReadLabelAndMBR(poCoordBlock, bComprCoord,
@@ -7322,9 +7321,9 @@ int TABCollection::ReadGeometryFromMAPFile(TABMAPFile *poMapFile,
         // In V800 the mini-header starts with a copy of num_parts
         if (nVersion >= 800)
         {
-            int numParts;
-            numParts = poCoordBlock->ReadInt32();
-            CPLAssert(numParts == poCollHdr->m_nNumPLineSections);
+            /* int numParts; */
+            /* numParts = poCoordBlock->ReadInt32(); */
+            CPLAssert(poCoordBlock->ReadInt32() == poCollHdr->m_nNumPLineSections);
         }
 
         ReadLabelAndMBR(poCoordBlock, bComprCoord,
@@ -8408,6 +8407,8 @@ void  ITABFeaturePen::SetPenFromStyleString(const char *pszStyleString)
     for(i=0; i<numParts; i++)
     {
         poStylePart = poStyleMgr->GetPart(i);
+        if( poStylePart == NULL )
+            continue;
 
         if(poStylePart->GetType() == OGRSTCPen)
         {
@@ -8594,10 +8595,9 @@ const char *ITABFeatureBrush::GetBrushStyleString()
 {
     const char *pszStyle = NULL;
     int    nOGRStyle  = 0;
-    char szPattern[20];
-    
-    szPattern[0] = '\0';
-    
+    /* char szPattern[20]; */
+    //* szPattern[0] = '\0'; */
+
     if (m_sBrushDef.nFillPattern == 1)
       nOGRStyle = 1;
     else if (m_sBrushDef.nFillPattern == 3)
@@ -8663,6 +8663,8 @@ void  ITABFeatureBrush::SetBrushFromStyleString(const char *pszStyleString)
     for(i=0; i<numParts; i++)
     {
         poStylePart = poStyleMgr->GetPart(i);
+        if( poStylePart == NULL )
+            continue;
 
         if(poStylePart->GetType() == OGRSTCBrush)
         {
@@ -8836,11 +8838,10 @@ const char *ITABFeatureSymbol::GetSymbolStyleString(double dfAngle)
 {
     const char *pszStyle = NULL;
     int    nOGRStyle  = 1;
-    char szPattern[20];
+    /* char szPattern[20]; */
     int nAngle = 0;
-    
-    szPattern[0] = '\0';
-    
+    /* szPattern[0] = '\0'; */
+
     if (m_sSymbolDef.nSymbolNo == 31)
       nOGRStyle = 0;
     else if (m_sSymbolDef.nSymbolNo == 32)
@@ -8933,6 +8934,8 @@ void ITABFeatureSymbol::SetSymbolFromStyleString(const char *pszStyleString)
     for(i=0; i<numParts; i++)
     {
         poStylePart = poStyleMgr->GetPart(i);
+        if( poStylePart == NULL )
+            continue;
 
         if(poStylePart->GetType() == OGRSTCSymbol)
         {
diff --git a/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp b/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp
index d5cb734..fbaf289 100644
--- a/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp
+++ b/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp
@@ -721,8 +721,9 @@ int TABMAPFile::LoadNextMatchingObjectBlock( int bFirstObject )
             return FALSE;
         else if( poBlock->GetBlockType() == TABMAP_OBJECT_BLOCK )
             return TRUE;
-        else
-            /* continue processing new index block */;
+        else {
+            /* continue processing new index block */
+        }
     }
 
     return m_poSpIndexLeaf != NULL;
diff --git a/ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp b/ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp
index 7267d98..5b27474 100644
--- a/ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp
+++ b/ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp
@@ -225,8 +225,9 @@ const char *MIDDATAFile::GetLine()
         return pszLine;
     }
     else
+    {
       CPLAssert(FALSE);
-    
+    }
     return NULL;
 }
 
diff --git a/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp b/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp
index 4fddea8..287f918 100644
--- a/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp
+++ b/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp
@@ -447,7 +447,7 @@ int MIFFile::Open(const char *pszFname, const char *pszAccess,
      *------------------------------------------------------------*/
     int numPoints=0, numRegions=0, numTexts=0, numLines=0;
 
-    if( GetFeatureCountByType( numPoints, numLines, numRegions, numTexts, 
+    if( GetFeatureCountByType( numPoints, numLines, numRegions, numTexts,
                                FALSE ) == 0 )
     {
         numPoints += numTexts;
@@ -456,7 +456,9 @@ int MIFFile::Open(const char *pszFname, const char *pszAccess,
         else if( numPoints == 0 && numLines > 0 && numRegions == 0 )
             m_poDefn->SetGeomType( wkbLineString );
         else
-            /* we leave it unknown indicating a mixture */;
+        {
+            /* we leave it unknown indicating a mixture */
+        }
     }
 
     /* A newly created layer should have OGRFeatureDefn */
diff --git a/ogr/ogrsf_frmts/mitab/mitab_spatialref.cpp b/ogr/ogrsf_frmts/mitab/mitab_spatialref.cpp
index bc6939a..d82b946 100644
--- a/ogr/ogrsf_frmts/mitab/mitab_spatialref.cpp
+++ b/ogr/ogrsf_frmts/mitab/mitab_spatialref.cpp
@@ -341,7 +341,8 @@ MapInfoDatumInfo asDatumInfoList[] =
 { 0,    113, "Lisboa_DLX",                 4, -303, -62, 105,  0, 0, 0, 0, 0},
 { 0,    114, "Melrica_1973_D73",           4, -223, 110, 37,   0, 0, 0, 0, 0},
 { 0,    115, "Euref_98",                   0, 0,    0,   0,    0, 0, 0, 0, 0},
-{ 0,    116, "GDA94",                      0, 0,    0,   0,    0, 0, 0, 0, 0},
+{ 6283, 116, "GDA94",                      0, 0,    0,   0,    0, 0, 0, 0, 0},
+{ 6283, 116, "Geocentric_Datum_of_Australia_1994", 0, 0, 0, 0, 0, 0, 0, 0, 0},
 { 6167, 117, "NZGD2000",                   0, 0,    0,   0,    0, 0, 0, 0, 0},
 { 6167, 117, "New_Zealand_Geodetic_Datum_2000",0,0, 0,   0,    0, 0, 0, 0, 0},
 { 6169, 118, "America_Samoa",              7, -115, 118, 426,  0, 0, 0, 0, 0},
@@ -521,9 +522,9 @@ OGRSpatialReference *TABFile::GetSpatialRef()
     /*-----------------------------------------------------------------
      * Get the units name, and translation factor.
      *----------------------------------------------------------------*/
-    const char *pszUnitsName; 
+    const char *pszUnitsName;
     const char *pszUnitsConv;
-    double      dfConv = 1.0;
+    /* double      dfConv = 1.0; */
 
     switch( sTABProj.nUnitsId )
     {
@@ -591,14 +592,14 @@ OGRSpatialReference *TABFile::GetSpatialRef()
         pszUnitsName = SRS_UL_ROD;
         pszUnitsConv = SRS_UL_ROD_CONV;
         break;
-            
+
       default:
         pszUnitsName = SRS_UL_METER;
         pszUnitsConv = "1.0";
         break;
     }
 
-    dfConv = CPLAtof(pszUnitsConv);
+    /* dfConv = CPLAtof(pszUnitsConv); */
 
     /*-----------------------------------------------------------------
      * Transform them into an OGRSpatialReference.
@@ -1607,4 +1608,3 @@ int TABFile::SetSpatialRef(OGRSpatialReference *poSpatialRef)
 
     return 0;
 }
-
diff --git a/ogr/ogrsf_frmts/mitab/mitab_tabfile.cpp b/ogr/ogrsf_frmts/mitab/mitab_tabfile.cpp
index 859b7b8..be725fd 100644
--- a/ogr/ogrsf_frmts/mitab/mitab_tabfile.cpp
+++ b/ogr/ogrsf_frmts/mitab/mitab_tabfile.cpp
@@ -190,14 +190,13 @@ void TABFile::ResetReading()
         {
             OGREnvelope  sEnvelope;
             TABVertex sMin, sMax;
-            TABMAPHeaderBlock *poHeader;
-    
-            poHeader = m_poMAPFile->GetHeaderBlock();
+            /* TABMAPHeaderBlock *poHeader; */
+            /* poHeader = m_poMAPFile->GetHeaderBlock(); */
 
             m_poFilterGeom->getEnvelope( &sEnvelope );
             m_poMAPFile->GetCoordFilter( sMin, sMax );
 
-            if( sEnvelope.MinX > sMin.x 
+            if( sEnvelope.MinX > sMin.x
                 || sEnvelope.MinY > sMin.y
                 || sEnvelope.MaxX < sMax.x
                 || sEnvelope.MaxY < sMax.y )
@@ -482,8 +481,9 @@ int TABFile::Open(const char *pszFname, const char *pszAccess,
             m_poDefn->SetGeomType( wkbPoint );
         else if( numPoints == 0 && numLines > 0 && numRegions == 0 )
             m_poDefn->SetGeomType( wkbLineString );
-        else
-            /* we leave it unknown indicating a mixture */;
+        else {
+            /* we leave it unknown indicating a mixture */
+        }
     }
     else if (m_poMAPFile->Open(pszTmpFname, pszAccess) != 0)
     {
diff --git a/ogr/ogrsf_frmts/mitab/mitab_tabseamless.cpp b/ogr/ogrsf_frmts/mitab/mitab_tabseamless.cpp
index e0bd312..c9b9c6b 100644
--- a/ogr/ogrsf_frmts/mitab/mitab_tabseamless.cpp
+++ b/ogr/ogrsf_frmts/mitab/mitab_tabseamless.cpp
@@ -598,7 +598,7 @@ int TABSeamless::ExtractBaseFeatureId(int nEncodedFeatureId)
     if (nEncodedFeatureId == -1)
         return -1;
 
-    return (nEncodedFeatureId & (1<<m_nIndexTableFIDMask)-1);
+    return (nEncodedFeatureId & ((1<<m_nIndexTableFIDMask) -1 ));
 }
 
 /**********************************************************************
@@ -925,5 +925,3 @@ void TABSeamless::Dump(FILE *fpOut /*=NULL*/)
 }
 
 #endif // DEBUG
-
-
diff --git a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlgeometryvalidator.cpp b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlgeometryvalidator.cpp
index 9b4a0f8..2df1c72 100644
--- a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlgeometryvalidator.cpp
+++ b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlgeometryvalidator.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmssqlgeometryvalidator.cpp 21933 2011-03-11 16:50:10Z tamas $
+ * $Id: ogrmssqlgeometryvalidator.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  MSSQL Spatial driver
  * Purpose:  Implements OGRMSSQLGeometryValidator class to create valid SqlGeometries.
@@ -30,7 +30,7 @@
 #include "cpl_conv.h"
 #include "ogr_mssqlspatial.h"
 
-CPL_CVSID("$Id: ogrmssqlgeometryvalidator.cpp 21933 2011-03-11 16:50:10Z tamas $");
+CPL_CVSID("$Id: ogrmssqlgeometryvalidator.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                   OGRMSSQLGeometryValidator()                        */
@@ -57,7 +57,7 @@ OGRMSSQLGeometryValidator::~OGRMSSQLGeometryValidator()
 /*                         ValidatePoint()                              */
 /************************************************************************/
 
-int OGRMSSQLGeometryValidator::ValidatePoint(OGRPoint* poGeom)
+int OGRMSSQLGeometryValidator::ValidatePoint(CPL_UNUSED OGRPoint* poGeom)
 {
     return TRUE;
 }
@@ -66,7 +66,7 @@ int OGRMSSQLGeometryValidator::ValidatePoint(OGRPoint* poGeom)
 /*                     ValidateMultiPoint()                             */
 /************************************************************************/
 
-int OGRMSSQLGeometryValidator::ValidateMultiPoint(OGRMultiPoint* poGeom)
+int OGRMSSQLGeometryValidator::ValidateMultiPoint(CPL_UNUSED OGRMultiPoint* poGeom)
 {
     return TRUE;
 }
@@ -491,5 +491,3 @@ OGRGeometry* OGRMSSQLGeometryValidator::GetValidGeometryRef()
 
     return poValidGeometry;
 }
-
-
diff --git a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp
index 3358c4f..39c8040 100644
--- a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp
+++ b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmssqlspatialdatasource.cpp 27344 2014-05-15 21:13:54Z tamas $
+ * $Id: ogrmssqlspatialdatasource.cpp 28316 2015-01-15 11:35:26Z tamas $
  *
  * Project:  MSSQL Spatial driver
  * Purpose:  Implements OGRMSSQLSpatialDataSource class..
@@ -30,7 +30,7 @@
 
 #include "ogr_mssqlspatial.h"
 
-CPL_CVSID("$Id: ogrmssqlspatialdatasource.cpp 27344 2014-05-15 21:13:54Z tamas $");
+CPL_CVSID("$Id: ogrmssqlspatialdatasource.cpp 28316 2015-01-15 11:35:26Z tamas $");
 
 /************************************************************************/
 /*                          OGRMSSQLSpatialDataSource()                 */
@@ -106,49 +106,49 @@ OGRLayer *OGRMSSQLSpatialDataSource::GetLayer( int iLayer )
         return papoLayers[iLayer];
 }
 
-/************************************************************************/
-/*                           GetLayerByName()                           */
-/************************************************************************/
-
-OGRLayer *OGRMSSQLSpatialDataSource::GetLayerByName( const char* pszLayerName )
-
-{
-    if (!pszLayerName)
-        return NULL;
-    
-    char *pszTableName = NULL;
-    char *pszSchemaName = NULL;
-
-    const char* pszDotPos = strstr(pszLayerName,".");
-    if ( pszDotPos != NULL )
-    {
-      int length = pszDotPos - pszLayerName;
-      pszSchemaName = (char*)CPLMalloc(length+1);
-      strncpy(pszSchemaName, pszLayerName, length);
-      pszSchemaName[length] = '\0';
-      pszTableName = CPLStrdup( pszDotPos + 1 ); //skip "."
-    }
-    else
-    {
-      pszSchemaName = CPLStrdup("dbo");
-      pszTableName = CPLStrdup( pszLayerName );
-    }
-    
-    for( int iLayer = 0; iLayer < nLayers; iLayer++ )
-    {
-        if( EQUAL(pszTableName,papoLayers[iLayer]->GetTableName()) && 
-            EQUAL(pszSchemaName,papoLayers[iLayer]->GetSchemaName()) )
-        {
-            CPLFree( pszSchemaName );
-            CPLFree( pszTableName );
-            return papoLayers[iLayer];
-        }
-    }
-
-    CPLFree( pszSchemaName );
-    CPLFree( pszTableName );
-
-    return NULL;
+/************************************************************************/
+/*                           GetLayerByName()                           */
+/************************************************************************/
+
+OGRLayer *OGRMSSQLSpatialDataSource::GetLayerByName( const char* pszLayerName )
+
+{
+    if (!pszLayerName)
+        return NULL;
+    
+    char *pszTableName = NULL;
+    char *pszSchemaName = NULL;
+
+    const char* pszDotPos = strstr(pszLayerName,".");
+    if ( pszDotPos != NULL )
+    {
+      int length = pszDotPos - pszLayerName;
+      pszSchemaName = (char*)CPLMalloc(length+1);
+      strncpy(pszSchemaName, pszLayerName, length);
+      pszSchemaName[length] = '\0';
+      pszTableName = CPLStrdup( pszDotPos + 1 ); //skip "."
+    }
+    else
+    {
+      pszSchemaName = CPLStrdup("dbo");
+      pszTableName = CPLStrdup( pszLayerName );
+    }
+    
+    for( int iLayer = 0; iLayer < nLayers; iLayer++ )
+    {
+        if( EQUAL(pszTableName,papoLayers[iLayer]->GetTableName()) && 
+            EQUAL(pszSchemaName,papoLayers[iLayer]->GetSchemaName()) )
+        {
+            CPLFree( pszSchemaName );
+            CPLFree( pszTableName );
+            return papoLayers[iLayer];
+        }
+    }
+
+    CPLFree( pszSchemaName );
+    CPLFree( pszTableName );
+
+    return NULL;
 }
 
 /************************************************************************/
@@ -270,7 +270,7 @@ OGRLayer * OGRMSSQLSpatialDataSource::CreateLayer( const char * pszLayerName,
 
     for( iLayer = 0; iLayer < nLayers; iLayer++ )
     {
-        if( EQUAL(pszTableName,papoLayers[iLayer]->GetTableName()) && 
+        if( EQUAL(pszTableName,papoLayers[iLayer]->GetTableName()) && 
             EQUAL(pszSchemaName,papoLayers[iLayer]->GetSchemaName()) )
         {
             if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != NULL
@@ -366,15 +366,15 @@ OGRLayer * OGRMSSQLSpatialDataSource::CreateLayer( const char * pszLayerName,
             pszCatalog, pszSchemaName, pszTableName, pszGeomColumn, nCoordDimension, nSRSId, pszGeometryType );
     }
 
-    if (!EQUAL(pszSchemaName,"dbo"))
-    {
-        // creating the schema if not exists
-        oStmt.Appendf("IF NOT EXISTS (SELECT name from sys.schemas WHERE name = '%s') EXEC sp_executesql N'CREATE SCHEMA [%s]'\n", pszSchemaName, pszSchemaName);
+    if (!EQUAL(pszSchemaName,"dbo"))
+    {
+        // creating the schema if not exists
+        oStmt.Appendf("IF NOT EXISTS (SELECT name from sys.schemas WHERE name = '%s') EXEC sp_executesql N'CREATE SCHEMA [%s]'\n", pszSchemaName, pszSchemaName);
     }
 
     if( eType == wkbNone ) 
     { 
-        oStmt.Appendf("CREATE TABLE [%s].[%s] ([ogr_fid] [int] IDENTITY(1,1) NOT NULL"
+        oStmt.Appendf("CREATE TABLE [%s].[%s] ([ogr_fid] [int] IDENTITY(1,1) NOT NULL, "
             "CONSTRAINT [PK_%s] PRIMARY KEY CLUSTERED ([ogr_fid] ASC))",
             pszSchemaName, pszTableName, pszTableName);
     }
@@ -441,10 +441,10 @@ OGRLayer * OGRMSSQLSpatialDataSource::CreateLayer( const char * pszLayerName,
 /*                             OpenTable()                              */
 /************************************************************************/
 
-int OGRMSSQLSpatialDataSource::OpenTable( const char *pszSchemaName, const char *pszTableName, 
-                    const char *pszGeomCol, int nCoordDimension,
-                    int nSRID, const char *pszSRText, OGRwkbGeometryType eType, int bUpdate )
-
+int OGRMSSQLSpatialDataSource::OpenTable( const char *pszSchemaName, const char *pszTableName,
+                                          const char *pszGeomCol, int nCoordDimension,
+                                          int nSRID, const char *pszSRText, OGRwkbGeometryType eType,
+                                          CPL_UNUSED int bUpdate )
 {
 /* -------------------------------------------------------------------- */
 /*      Create the layer object.                                        */
@@ -697,6 +697,48 @@ int OGRMSSQLSpatialDataSource::Open( const char * pszNewName, int bUpdate,
 
     char** papszTypes = NULL;
 
+    /* read metadata for the specified tables */
+    if (papszTableNames != NULL && bUseGeometryColumns)
+    {
+        for( int iTable = 0; 
+            papszTableNames != NULL && papszTableNames[iTable] != NULL; 
+            iTable++ )
+        {        
+            CPLODBCStatement oStmt( &oSession );
+            
+            /* Use join to make sure the existence of the referred column/table */
+            oStmt.Appendf( "SELECT f_geometry_column, coord_dimension, g.srid, srtext, geometry_type FROM dbo.geometry_columns g JOIN INFORMATION_SCHEMA.COLUMNS ON f_table_schema = TABLE_SCHEMA and f_table_name = TABLE_NAME and f_geometry_column = COLUMN_NAME left outer join dbo.spatial_ref_sys s on g.srid = s.srid WHERE f_table_schema = '%s' AND f_table_name = '%s'", papszSchemaNames[iTable], papszTableNames[iTable]);
+
+            if( oStmt.ExecuteSQL() )
+            {
+                while( oStmt.Fetch() )
+                {
+                    if (papszGeomColumnNames == NULL)
+                            papszGeomColumnNames = CSLAddString( papszGeomColumnNames, oStmt.GetColData(0) );
+                    else if (*papszGeomColumnNames[iTable] == 0)
+                    {
+                        CPLFree(papszGeomColumnNames[iTable]);
+                        papszGeomColumnNames[iTable] = CPLStrdup( oStmt.GetColData(0) );
+                    }
+
+                    papszCoordDimensions = 
+                            CSLAddString( papszCoordDimensions, oStmt.GetColData(1, "2") );
+                    papszSRIds = 
+                            CSLAddString( papszSRIds, oStmt.GetColData(2, "0") );
+                    papszSRTexts = 
+                        CSLAddString( papszSRTexts, oStmt.GetColData(3, "") );
+                    papszTypes = 
+                            CSLAddString( papszTypes, oStmt.GetColData(4, "GEOMETRY") );
+                }
+            }
+            else
+            {
+                /* probably the table is missing at all */
+                InitializeMetadataTables();
+            }
+        }
+    }
+
     /* if requesting all user database table then this takes priority */ 
  	if (papszTableNames == NULL && bListAllTables) 
  	{ 
@@ -730,19 +772,19 @@ int OGRMSSQLSpatialDataSource::Open( const char * pszNewName, int bUpdate,
         {
             while( oStmt.Fetch() )
             {
-                papszSchemaNames = 
-                        CSLAddString( papszSchemaNames, oStmt.GetColData(0, "dbo") );
-                papszTableNames = 
-                        CSLAddString( papszTableNames, oStmt.GetColData(1) );
-                papszGeomColumnNames = 
-                        CSLAddString( papszGeomColumnNames, oStmt.GetColData(2) );
-                papszCoordDimensions = 
-                        CSLAddString( papszCoordDimensions, oStmt.GetColData(3, "2") );
-                papszSRIds = 
-                        CSLAddString( papszSRIds, oStmt.GetColData(4, "0") );
-                papszSRTexts = 
-                    CSLAddString( papszSRTexts, oStmt.GetColData(5, "") );
-                papszTypes = 
+                papszSchemaNames = 
+                        CSLAddString( papszSchemaNames, oStmt.GetColData(0, "dbo") );
+                papszTableNames = 
+                        CSLAddString( papszTableNames, oStmt.GetColData(1) );
+                papszGeomColumnNames = 
+                        CSLAddString( papszGeomColumnNames, oStmt.GetColData(2) );
+                papszCoordDimensions = 
+                        CSLAddString( papszCoordDimensions, oStmt.GetColData(3, "2") );
+                papszSRIds = 
+                        CSLAddString( papszSRIds, oStmt.GetColData(4, "0") );
+                papszSRTexts = 
+                    CSLAddString( papszSRTexts, oStmt.GetColData(5, "") );
+                papszTypes = 
                         CSLAddString( papszTypes, oStmt.GetColData(6, "GEOMETRY") );
             }
         }
@@ -1278,4 +1320,3 @@ int OGRMSSQLSpatialDataSource::FetchSRSId( OGRSpatialReference * poSRS)
 
     return nSRSId;
 }
-
diff --git a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdriver.cpp b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdriver.cpp
index 161a7bf..571bd47 100644
--- a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdriver.cpp
+++ b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmssqlspatialdriver.cpp 20570 2010-09-11 20:40:59Z tamas $
+ * $Id: ogrmssqlspatialdriver.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  MSSQL Spatial driver
  * Purpose:  Definition of classes for OGR MSSQL Spatial driver.
@@ -30,7 +30,7 @@
 #include "ogr_mssqlspatial.h"
 #include "cpl_conv.h"
 
-CPL_CVSID("$Id: ogrmssqlspatialdriver.cpp 20570 2010-09-11 20:40:59Z tamas $");
+CPL_CVSID("$Id: ogrmssqlspatialdriver.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                           ~OGRMSSQLSpatialDriver()                   */
@@ -79,8 +79,7 @@ OGRDataSource *OGRMSSQLSpatialDriver::Open( const char * pszFilename, int bUpdat
 /************************************************************************/
 
 OGRDataSource *OGRMSSQLSpatialDriver::CreateDataSource( const char * pszName,
-                                               char **papszOptions )
-
+                                                        CPL_UNUSED char **papszOptions )
 {
     OGRMSSQLSpatialDataSource   *poDS = new OGRMSSQLSpatialDataSource();
 
@@ -90,7 +89,7 @@ OGRDataSource *OGRMSSQLSpatialDriver::CreateDataSource( const char * pszName,
     if( !poDS->Open( pszName, TRUE, TRUE ) )
     {
         delete poDS;
-        CPLError( CE_Failure, CPLE_AppDefined, 
+        CPLError( CE_Failure, CPLE_AppDefined,
          "MSSQL Spatial driver doesn't currently support database creation.\n"
                   "Please create database with the Microsoft SQL Server Client Tools." );
         return NULL;
@@ -124,4 +123,3 @@ void RegisterOGRMSSQLSpatial()
         return;
     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRMSSQLSpatialDriver );
 }
-
diff --git a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatiallayer.cpp b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatiallayer.cpp
index 8a1a222..b49ea51 100644
--- a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatiallayer.cpp
+++ b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatiallayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmssqlspatiallayer.cpp 25989 2013-05-05 19:35:01Z tamas $
+ * $Id: ogrmssqlspatiallayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  MSSQL Spatial driver
  * Purpose:  Definition of classes for OGR MSSQL Spatial driver.
@@ -29,7 +29,7 @@
 
 #include "ogr_mssqlspatial.h"
 
-CPL_CVSID("$Id: ogrmssqlspatiallayer.cpp 25989 2013-05-05 19:35:01Z tamas $");
+CPL_CVSID("$Id: ogrmssqlspatiallayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 /************************************************************************/
 /*                        OGRMSSQLSpatialLayer()                        */
 /************************************************************************/
@@ -396,8 +396,7 @@ OGRFeature *OGRMSSQLSpatialLayer::GetFeature( long nFeatureId )
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRMSSQLSpatialLayer::TestCapability( const char * pszCap )
-
+int OGRMSSQLSpatialLayer::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
@@ -513,4 +512,3 @@ char* OGRMSSQLSpatialLayer::GByteArrayToHexString( const GByte* pabyData, int nL
 
     return pszTextBuf;
 }
-
diff --git a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialselectlayer.cpp b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialselectlayer.cpp
index 06656dd..13ab025 100644
--- a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialselectlayer.cpp
+++ b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialselectlayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmssqlspatialselectlayer.cpp 27361 2014-05-18 12:11:28Z tamas $
+ * $Id: ogrmssqlspatialselectlayer.cpp 27760 2014-09-28 18:31:18Z tamas $
  *
  * Project:  MSSQL Spatial driver
  * Purpose:  Implements OGRMSSQLSpatialSelectLayer class, layer access to the results
@@ -31,7 +31,7 @@
 #include "cpl_conv.h"
 #include "ogr_mssqlspatial.h"
 
-CPL_CVSID("$Id: ogrmssqlspatialselectlayer.cpp 27361 2014-05-18 12:11:28Z tamas $");
+CPL_CVSID("$Id: ogrmssqlspatialselectlayer.cpp 27760 2014-09-28 18:31:18Z tamas $");
 /************************************************************************/
 /*                     OGRMSSQLSpatialSelectLayer()                     */
 /************************************************************************/
@@ -51,6 +51,7 @@ OGRMSSQLSpatialSelectLayer::OGRMSSQLSpatialSelectLayer( OGRMSSQLSpatialDataSourc
 
     /* identify the geometry column */
     pszGeomColumn = NULL;
+    int iImageCol = -1;
     for ( int iColumn = 0; iColumn < poStmt->GetColCount(); iColumn++ )
     {
         if ( EQUAL(poStmt->GetColTypeName( iColumn ), "image") )
@@ -75,6 +76,8 @@ OGRMSSQLSpatialSelectLayer::OGRMSSQLSpatialSelectLayer( OGRMSSQLSpatialDataSourc
                     break;
                 }
             }
+            else if (iImageCol == -1)
+                iImageCol = iColumn;
         }
         else if ( EQUAL(poStmt->GetColTypeName( iColumn ), "geometry") )
         {
@@ -90,6 +93,13 @@ OGRMSSQLSpatialSelectLayer::OGRMSSQLSpatialSelectLayer( OGRMSSQLSpatialDataSourc
         }
     }
 
+    if (pszGeomColumn == NULL && iImageCol >= 0)
+    {
+        /* set the image col as geometry column as the last resort */
+        nGeomColumnType = MSSQLCOLTYPE_BINARY;
+        pszGeomColumn = CPLStrdup(poStmt->GetColName(iImageCol));
+    }
+
     BuildFeatureDefn( "SELECT", poStmt );
 
     if ( GetSpatialRef() && poFeatureDefn->GetGeomFieldCount() == 1)
diff --git a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp
index 19941ce..952c497 100644
--- a/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp
+++ b/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialtablelayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmssqlspatialtablelayer.cpp 27361 2014-05-18 12:11:28Z tamas $
+ * $Id: ogrmssqlspatialtablelayer.cpp 28397 2015-01-31 22:34:06Z tamas $
  *
  * Project:  MSSQL Spatial driver
  * Purpose:  Implements OGRMSSQLSpatialTableLayer class, access to an existing table.
@@ -31,7 +31,7 @@
 #include "cpl_conv.h"
 #include "ogr_mssqlspatial.h"
 
-CPL_CVSID("$Id: ogrmssqlspatialtablelayer.cpp 27361 2014-05-18 12:11:28Z tamas $");
+CPL_CVSID("$Id: ogrmssqlspatialtablelayer.cpp 28397 2015-01-31 22:34:06Z tamas $");
 
 /************************************************************************/
 /*                         OGRMSSQLAppendEscaped( )                     */
@@ -234,13 +234,12 @@ OGRFeatureDefn* OGRMSSQLSpatialTableLayer::GetLayerDefn()
 /************************************************************************/
 
 CPLErr OGRMSSQLSpatialTableLayer::Initialize( const char *pszSchema,
-                                              const char *pszLayerName, 
+                                              const char *pszLayerName,
                                               const char *pszGeomCol,
-                                              int nCoordDimension, 
+                                              CPL_UNUSED int nCoordDimension,
                                               int nSRId,
                                               const char *pszSRText,
                                               OGRwkbGeometryType eType )
-
 {
     CPLFree( pszFIDColumn );
     pszFIDColumn = NULL;
@@ -431,6 +430,8 @@ CPLString OGRMSSQLSpatialTableLayer::BuildFields()
     int nColumn = 0;
     CPLString osFieldList;
 
+    GetLayerDefn();
+
     if( pszFIDColumn && poFeatureDefn->GetFieldIndex( pszFIDColumn ) == -1 )
     {
         /* Always get the FID column */
@@ -1246,4 +1247,3 @@ void OGRMSSQLSpatialTableLayer::AppendFieldValue(CPLODBCStatement *poStatement,
         poStatement->Append( pszStrValue );
     }
 }
-
diff --git a/ogr/ogrsf_frmts/mysql/ogrmysqldatasource.cpp b/ogr/ogrsf_frmts/mysql/ogrmysqldatasource.cpp
index a9055a8..4dcfbb8 100644
--- a/ogr/ogrsf_frmts/mysql/ogrmysqldatasource.cpp
+++ b/ogr/ogrsf_frmts/mysql/ogrmysqldatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmysqldatasource.cpp 27506 2014-07-07 19:49:05Z rouault $
+ * $Id: ogrmysqldatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRMySQLDataSource class.
@@ -37,7 +37,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrmysqldatasource.cpp 27506 2014-07-07 19:49:05Z rouault $");
+CPL_CVSID("$Id: ogrmysqldatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 /************************************************************************/
 /*                         OGRMySQLDataSource()                         */
 /************************************************************************/
@@ -294,8 +294,7 @@ int OGRMySQLDataSource::Open( const char * pszNewName, int bUpdate,
 /************************************************************************/
 
 int OGRMySQLDataSource::OpenTable( const char *pszNewName, int bUpdate,
-                                int bTestOpen )
-
+                                   CPL_UNUSED int bTestOpen )
 {
 /* -------------------------------------------------------------------- */
 /*      Create the layer object.                                        */
@@ -819,11 +818,10 @@ OGRMySQLDataSource::CreateLayer( const char * pszLayerNameIn,
     MYSQL_RES           *hResult=NULL;
     CPLString            osCommand;
     const char          *pszGeometryType;
-    const char			*pszGeomColumnName;
-    const char 			*pszExpectedFIDName; 
-	
+    const char		*pszGeomColumnName;
+    const char		*pszExpectedFIDName;
     char                *pszLayerName;
-    int                 nDimension = 3; // MySQL only supports 2d currently
+    // int                 nDimension = 3; // MySQL only supports 2d currently
 
 
 /* -------------------------------------------------------------------- */
@@ -837,8 +835,8 @@ OGRMySQLDataSource::CreateLayer( const char * pszLayerNameIn,
     else
         pszLayerName = CPLStrdup( pszLayerNameIn );
 
-    if( wkbFlatten(eType) == eType )
-        nDimension = 2;
+    // if( wkbFlatten(eType) == eType )
+    //    nDimension = 2;
 
     CPLDebug("MYSQL","Creating layer %s.", pszLayerName);
 
@@ -852,7 +850,7 @@ OGRMySQLDataSource::CreateLayer( const char * pszLayerNameIn,
     {
         if( EQUAL(pszLayerName,papoLayers[iLayer]->GetLayerDefn()->GetName()) )
         {
-			
+
             if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != NULL
                 && !EQUAL(CSLFetchNameValue(papszOptions,"OVERWRITE"),"NO") )
             {
diff --git a/ogr/ogrsf_frmts/mysql/ogrmysqlresultlayer.cpp b/ogr/ogrsf_frmts/mysql/ogrmysqlresultlayer.cpp
index 9cc3543..67dafa7 100644
--- a/ogr/ogrsf_frmts/mysql/ogrmysqlresultlayer.cpp
+++ b/ogr/ogrsf_frmts/mysql/ogrmysqlresultlayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmysqlresultlayer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrmysqlresultlayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRMySQLResultLayer class.
@@ -32,7 +32,7 @@
 #include "cpl_conv.h"
 #include "ogr_mysql.h"
 
-CPL_CVSID("$Id: ogrmysqlresultlayer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrmysqlresultlayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                        OGRMySQLResultLayer()                         */
@@ -310,9 +310,7 @@ int OGRMySQLResultLayer::GetFeatureCount( int bForce )
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRMySQLResultLayer::TestCapability( const char * pszCap )
-
+int OGRMySQLResultLayer::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
-
diff --git a/ogr/ogrsf_frmts/mysql/ogrmysqltablelayer.cpp b/ogr/ogrsf_frmts/mysql/ogrmysqltablelayer.cpp
index 3b0bc4e..d255239 100644
--- a/ogr/ogrsf_frmts/mysql/ogrmysqltablelayer.cpp
+++ b/ogr/ogrsf_frmts/mysql/ogrmysqltablelayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrmysqltablelayer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrmysqltablelayer.cpp 27916 2014-10-30 15:38:57Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRMySQLTableLayer class.
@@ -33,23 +33,22 @@
 #include "cpl_string.h"
 #include "ogr_mysql.h"
 
-CPL_CVSID("$Id: ogrmysqltablelayer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrmysqltablelayer.cpp 27916 2014-10-30 15:38:57Z rouault $");
 
 /************************************************************************/
 /*                         OGRMySQLTableLayer()                         */
 /************************************************************************/
 
-OGRMySQLTableLayer::OGRMySQLTableLayer( OGRMySQLDataSource *poDSIn, 
-                                  const char * pszTableName,
-                                  int bUpdate, int nSRSIdIn )
-
+OGRMySQLTableLayer::OGRMySQLTableLayer( OGRMySQLDataSource *poDSIn,
+                                        CPL_UNUSED const char * pszTableName,
+                                        int bUpdate, int nSRSIdIn )
 {
     poDS = poDSIn;
 
     pszQuery = NULL;
     pszWHERE = CPLStrdup( "" );
     pszQueryStatement = NULL;
-    
+
     bUpdateAccess = bUpdate;
 
     iNextShapeId = 0;
@@ -406,6 +405,9 @@ void OGRMySQLTableLayer::SetSpatialFilter( OGRGeometry * poGeomIn )
 void OGRMySQLTableLayer::BuildWhere()
 
 {
+    // don't mess up decimal separator 
+    CPLLocaleC oLocaleForcer; 
+
     CPLFree( pszWHERE );
     pszWHERE = (char*)CPLMalloc(500 + ((pszQuery) ? strlen(pszQuery) : 0));
     pszWHERE[0] = '\0';
@@ -1069,14 +1071,13 @@ OGRFeature *OGRMySQLTableLayer::GetFeature( long nFeatureId )
 /*      way of counting features matching a spatial query.              */
 /************************************************************************/
 
-int OGRMySQLTableLayer::GetFeatureCount( int bForce )
-
+int OGRMySQLTableLayer::GetFeatureCount( CPL_UNUSED int bForce )
 {
 /* -------------------------------------------------------------------- */
 /*      Ensure any active long result is interrupted.                   */
 /* -------------------------------------------------------------------- */
     poDS->InterruptLongResult();
-    
+
 /* -------------------------------------------------------------------- */
 /*      Issue the appropriate select command.                           */
 /* -------------------------------------------------------------------- */
@@ -1123,8 +1124,7 @@ int OGRMySQLTableLayer::GetFeatureCount( int bForce )
 /*      like PostgreSQL.						*/
 /************************************************************************/
 
-OGRErr OGRMySQLTableLayer::GetExtent(OGREnvelope *psExtent, int bForce )
-
+OGRErr OGRMySQLTableLayer::GetExtent(OGREnvelope *psExtent, CPL_UNUSED int bForce )
 {
 	if( GetLayerDefn()->GetGeomType() == wkbNone )
     {
@@ -1132,7 +1132,7 @@ OGRErr OGRMySQLTableLayer::GetExtent(OGREnvelope *psExtent, int bForce )
         psExtent->MaxX = 0.0;
         psExtent->MinY = 0.0;
         psExtent->MaxY = 0.0;
-        
+
         return OGRERR_FAILURE;
     }
 
diff --git a/ogr/ogrsf_frmts/nas/drv_nas.html b/ogr/ogrsf_frmts/nas/drv_nas.html
index af833aa..2898627 100644
--- a/ogr/ogrsf_frmts/nas/drv_nas.html
+++ b/ogr/ogrsf_frmts/nas/drv_nas.html
@@ -17,10 +17,16 @@ library.<p>
 This driver was implemented within the context of the PostNAS project
 which has more information on it's use.<p>
 
+The driver looks for "opengis.net/gml" and one of the strings semicolon
+separated strings listed in the option NAS_INDICATOR (which defaults to
+"NAS-Operationen.xsd;NAS-Operationen_optional.xsd;AAA-Fachschema.xsd") to
+determine if a input is a NAS file and ignores all files without any matches.
+
 <h2>See Also</h2>
 
 <ul>
-<li> <a href="http://trac.wheregroup.com/PostNAS">PostNAS</a><p>
+<li> <a href="http://trac.wheregroup.com/PostNAS">PostNAS</a>
+<li> <a href="http://www.norbit.de/68/">norGIS ALKIS-Import</a>
 </ul>
 
 </body>
diff --git a/ogr/ogrsf_frmts/nas/nashandler.cpp b/ogr/ogrsf_frmts/nas/nashandler.cpp
index ef701ec..36b4c7f 100644
--- a/ogr/ogrsf_frmts/nas/nashandler.cpp
+++ b/ogr/ogrsf_frmts/nas/nashandler.cpp
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: nashandler.cpp 27713 2014-09-21 15:51:47Z jef $
+ * $Id: nashandler.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  NAS Reader
  * Purpose:  Implementation of NASHandler class.
@@ -128,9 +128,9 @@ CPLString NASHandler::GetAttributes(const Attributes* attrs)
 /*                            startElement()                            */
 /************************************************************************/
 
-void NASHandler::startElement(const XMLCh* const    uri,
-                              const XMLCh* const    localname,
-                              const XMLCh* const    qname,
+void NASHandler::startElement(CPL_UNUSED const XMLCh* const uri,
+                              const XMLCh* const localname,
+                              CPL_UNUSED const XMLCh* const qname,
                               const Attributes& attrs )
 
 {
@@ -416,9 +416,9 @@ void NASHandler::startElement(const XMLCh* const    uri,
 /************************************************************************/
 /*                             endElement()                             */
 /************************************************************************/
-void NASHandler::endElement(const   XMLCh* const    uri,
-                            const   XMLCh* const    localname,
-                            const   XMLCh* const    qname )
+void NASHandler::endElement(CPL_UNUSED const XMLCh* const uri,
+                            const XMLCh* const localname,
+                            CPL_UNUSED const XMLCh* const qname )
 
 {
     char        szElementName[MAX_TOKEN_SIZE];
@@ -648,12 +648,11 @@ void NASHandler::endElement(const   XMLCh* const    uri,
 
 #if XERCES_VERSION_MAJOR >= 3
 void NASHandler::characters( const XMLCh *const chars_in,
-                             const XMLSize_t length )
+                             CPL_UNUSED const XMLSize_t length )
 #else
-void NASHandler::characters(const XMLCh* const chars_in,
-                            const unsigned int length )
+void NASHandler::characters( const XMLCh* const chars_in,
+                             CPL_UNUSED const unsigned int length )
 #endif
-
 {
     const XMLCh *chars = chars_in;
 
diff --git a/ogr/ogrsf_frmts/nas/nasreader.cpp b/ogr/ogrsf_frmts/nas/nasreader.cpp
index 2e1dcdd..49e9a35 100644
--- a/ogr/ogrsf_frmts/nas/nasreader.cpp
+++ b/ogr/ogrsf_frmts/nas/nasreader.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: nasreader.cpp 27713 2014-09-21 15:51:47Z jef $
+ * $Id: nasreader.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  NAS Reader
  * Purpose:  Implementation of NASReader class.
@@ -854,8 +854,7 @@ int NASReader::SaveClasses( const char *pszFile )
 /*      looking for schema information.                                 */
 /************************************************************************/
 
-int NASReader::PrescanForSchema( int bGetExtents, int bAnalyzeSRSPerFeature )
-
+int NASReader::PrescanForSchema( int bGetExtents, CPL_UNUSED int bAnalyzeSRSPerFeature )
 {
     GMLFeature  *poFeature;
 
@@ -1035,10 +1034,9 @@ void NASReader::CheckForRelations( const char *pszElement,
 /*      Returns TRUE for success                                        */
 /************************************************************************/
 
-int NASReader::HugeFileResolver( const char *pszFile,
-                              int bSqliteIsTempFile,
-                              int iSqliteCacheMB )
-
+int NASReader::HugeFileResolver( CPL_UNUSED const char *pszFile,
+                                 CPL_UNUSED int bSqliteIsTempFile,
+                                 CPL_UNUSED int iSqliteCacheMB )
 {
     CPLDebug( "NAS", "HugeFileResolver() not currently implemented for NAS." );
     return FALSE;
@@ -1061,11 +1059,10 @@ int NASReader::PrescanForTemplate( void )
 /*      Returns TRUE for success                                        */
 /************************************************************************/
 
-int NASReader::ResolveXlinks( const char *pszFile,
-                              int* pbOutIsTempFile,
-                              char **papszSkip,
-                              const int bStrict )
-
+int NASReader::ResolveXlinks( CPL_UNUSED const char *pszFile,
+                              CPL_UNUSED int* pbOutIsTempFile,
+                              CPL_UNUSED char **papszSkip,
+                              CPL_UNUSED const int bStrict )
 {
     CPLDebug( "NAS", "ResolveXlinks() not currently implemented for NAS." );
     return FALSE;
diff --git a/ogr/ogrsf_frmts/nas/nasreaderp.h b/ogr/ogrsf_frmts/nas/nasreaderp.h
index 605c3c3..61bafc8 100644
--- a/ogr/ogrsf_frmts/nas/nasreaderp.h
+++ b/ogr/ogrsf_frmts/nas/nasreaderp.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: nasreaderp.h 27713 2014-09-21 15:51:47Z jef $
+ * $Id: nasreaderp.h 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  NAS Reader
  * Purpose:  Private Declarations for OGR NAS Reader code.
@@ -191,7 +191,7 @@ public:
     int              PrescanForTemplate( void );
     void             ResetReading();
 
-    int              ParseXSD( const char *pszFile ) { return FALSE; }
+    int              ParseXSD( CPL_UNUSED const char *pszFile ) { return FALSE; }
 
     int              ResolveXlinks( const char *pszFile,
                                     int* pbOutIsTempFile,
diff --git a/ogr/ogrsf_frmts/nas/ogrnasdatasource.cpp b/ogr/ogrsf_frmts/nas/ogrnasdatasource.cpp
index 67e22ed..8c12618 100644
--- a/ogr/ogrsf_frmts/nas/ogrnasdatasource.cpp
+++ b/ogr/ogrsf_frmts/nas/ogrnasdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrnasdatasource.cpp 27713 2014-09-21 15:51:47Z jef $
+ * $Id: ogrnasdatasource.cpp 28132 2014-12-11 22:31:03Z jef $
  *
  * Project:  OGR
  * Purpose:  Implements OGRNASDataSource class.
@@ -32,7 +32,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrnasdatasource.cpp 27713 2014-09-21 15:51:47Z jef $");
+CPL_CVSID("$Id: ogrnasdatasource.cpp 28132 2014-12-11 22:31:03Z jef $");
 
 static const char *apszURNNames[] =
 {
@@ -133,11 +133,20 @@ int OGRNASDataSource::Open( const char * pszNewName, int bTestOpen )
 /* -------------------------------------------------------------------- */
 /*      Here, we expect the opening chevrons of NAS tree root element   */
 /* -------------------------------------------------------------------- */
-        if( szPtr[0] != '<'
-            || strstr(szPtr,"opengis.net/gml") == NULL
-            || (strstr(szPtr,"NAS-Operationen.xsd") == NULL &&
-                strstr(szPtr,"NAS-Operationen_optional.xsd") == NULL &&
-                strstr(szPtr,"AAA-Fachschema.xsd") == NULL ) )
+        bool bFound = FALSE;
+        if( szPtr[0] == '<' && strstr(szPtr,"opengis.net/gml") != NULL )
+        {
+            char **papszIndicators = CSLTokenizeStringComplex( CPLGetConfigOption( "NAS_INDICATOR", "NAS-Operationen.xsd;NAS-Operationen_optional.xsd;AAA-Fachschema.xsd" ), ";", 0, 0 );
+
+            for( int i = 0; papszIndicators[i] && !bFound; i++ )
+            {
+                bFound = strstr( szPtr, papszIndicators[i] ) != NULL;
+            }
+
+            CSLDestroy( papszIndicators );
+        }
+
+        if( !bFound )
         {
             /*CPLDebug( "NAS",
                       "Skipping. No chevrons of NAS found [%s]\n", szPtr );*/
@@ -380,8 +389,7 @@ OGRLayer *OGRNASDataSource::GetLayer( int iLayer )
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRNASDataSource::TestCapability( const char * pszCap )
-
+int OGRNASDataSource::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
diff --git a/ogr/ogrsf_frmts/nas/ogrnasdriver.cpp b/ogr/ogrsf_frmts/nas/ogrnasdriver.cpp
index b1d7a9d..0ddbdc9 100644
--- a/ogr/ogrsf_frmts/nas/ogrnasdriver.cpp
+++ b/ogr/ogrsf_frmts/nas/ogrnasdriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrnasdriver.cpp 26335 2013-08-15 22:34:46Z rouault $
+ * $Id: ogrnasdriver.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OGR
  * Purpose:  OGRNASDriver implementation
@@ -32,7 +32,7 @@
 #include "nasreaderp.h"
 #include "cpl_multiproc.h"
 
-CPL_CVSID("$Id: ogrnasdriver.cpp 26335 2013-08-15 22:34:46Z rouault $");
+CPL_CVSID("$Id: ogrnasdriver.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 
 /************************************************************************/
@@ -86,8 +86,7 @@ OGRDataSource *OGRNASDriver::Open( const char * pszFilename,
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRNASDriver::TestCapability( const char * pszCap )
-
+int OGRNASDriver::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
@@ -101,4 +100,3 @@ void RegisterOGRNAS()
 {
     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRNASDriver );
 }
-
diff --git a/ogr/ogrsf_frmts/oci/ogrocitablelayer.cpp b/ogr/ogrsf_frmts/oci/ogrocitablelayer.cpp
index 3ced924..70d49f3 100644
--- a/ogr/ogrsf_frmts/oci/ogrocitablelayer.cpp
+++ b/ogr/ogrsf_frmts/oci/ogrocitablelayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrocitablelayer.cpp 26688 2013-12-02 19:07:41Z rouault $
+ * $Id: ogrocitablelayer.cpp 28319 2015-01-15 23:29:32Z martinl $
  *
  * Project:  Oracle Spatial Driver
  * Purpose:  Implementation of the OGROCITableLayer class.  This class provides
@@ -33,7 +33,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrocitablelayer.cpp 26688 2013-12-02 19:07:41Z rouault $");
+CPL_CVSID("$Id: ogrocitablelayer.cpp 28319 2015-01-15 23:29:32Z martinl $");
 
 static int nDiscarded = 0;
 static int nHits = 0;
@@ -50,6 +50,7 @@ OGROCITableLayer::OGROCITableLayer( OGROCIDataSource *poDSIn,
 
 {
     poDS = poDSIn;
+    bExtentUpdated = false;
 
     pszQuery = NULL;
     pszWHERE = CPLStrdup( "" );
@@ -959,9 +960,15 @@ OGRErr OGROCITableLayer::UnboundCreateFeature( OGRFeature *poFeature )
         nOffset += strlen(pszCommand+nOffset);
 
         nFID = poFeature->GetFID();
-        if( nFID == -1 )
+        if( nFID == OGRNullFID )
+        {
+            if( iNextFIDToWrite < 0 )
+            {
+                iNextFIDToWrite = GetMaxFID() + 1;
+            }
             nFID = iNextFIDToWrite++;
-
+            poFeature->SetFID( nFID );
+        }
         sprintf( pszCommand+nOffset, "%ld", nFID );
     }
 
diff --git a/ogr/ogrsf_frmts/odbc/ogrodbcdatasource.cpp b/ogr/ogrsf_frmts/odbc/ogrodbcdatasource.cpp
index 393fadd..0b734bb 100644
--- a/ogr/ogrsf_frmts/odbc/ogrodbcdatasource.cpp
+++ b/ogr/ogrsf_frmts/odbc/ogrodbcdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrodbcdatasource.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrodbcdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRODBCDataSource class.
@@ -32,7 +32,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrodbcdatasource.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrodbcdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 /************************************************************************/
 /*                         OGRODBCDataSource()                          */
 /************************************************************************/
@@ -181,8 +181,7 @@ int OGRODBCDataSource::OpenMDB( const char * pszNewName, int bUpdate )
 /************************************************************************/
 
 int OGRODBCDataSource::Open( const char * pszNewName, int bUpdate,
-                             int bTestOpen )
-
+                             CPL_UNUSED int bTestOpen )
 {
     CPLAssert( nLayers == 0 );
 
@@ -482,10 +481,9 @@ int OGRODBCDataSource::Open( const char * pszNewName, int bUpdate,
 /*                             OpenTable()                              */
 /************************************************************************/
 
-int OGRODBCDataSource::OpenTable( const char *pszNewName, 
+int OGRODBCDataSource::OpenTable( const char *pszNewName,
                                   const char *pszGeomCol,
-                                  int bUpdate )
-
+                                  CPL_UNUSED int bUpdate )
 {
 /* -------------------------------------------------------------------- */
 /*      Create the layer object.                                        */
@@ -514,8 +512,7 @@ int OGRODBCDataSource::OpenTable( const char *pszNewName,
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRODBCDataSource::TestCapability( const char * pszCap )
-
+int OGRODBCDataSource::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
diff --git a/ogr/ogrsf_frmts/odbc/ogrodbclayer.cpp b/ogr/ogrsf_frmts/odbc/ogrodbclayer.cpp
index 20ffadf..3b1247a 100644
--- a/ogr/ogrsf_frmts/odbc/ogrodbclayer.cpp
+++ b/ogr/ogrsf_frmts/odbc/ogrodbclayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrodbclayer.cpp 17755 2009-10-04 21:04:10Z rouault $
+ * $Id: ogrodbclayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRODBCLayer class, code shared between 
@@ -32,7 +32,7 @@
 #include "ogr_odbc.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrodbclayer.cpp 17755 2009-10-04 21:04:10Z rouault $");
+CPL_CVSID("$Id: ogrodbclayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                            OGRODBCLayer()                            */
@@ -344,8 +344,7 @@ OGRFeature *OGRODBCLayer::GetFeature( long nFeatureId )
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRODBCLayer::TestCapability( const char * pszCap )
-
+int OGRODBCLayer::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
@@ -359,4 +358,3 @@ OGRSpatialReference *OGRODBCLayer::GetSpatialRef()
 {
     return poSRS;
 }
-
diff --git a/ogr/ogrsf_frmts/ods/ods_formula_node.cpp b/ogr/ogrsf_frmts/ods/ods_formula_node.cpp
index 1715a18..9619fe3 100644
--- a/ogr/ogrsf_frmts/ods/ods_formula_node.cpp
+++ b/ogr/ogrsf_frmts/ods/ods_formula_node.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ods_formula_node.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ods_formula_node.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Component: ODS formula Engine
  * Purpose: Implementation of the ods_formula_node class used to represent a
@@ -512,8 +512,9 @@ int ods_formula_node::EvaluateIF(IODSCellEvaluator* poEvaluator)
     CPLAssert(papoSubExpr[0]->eNodeType == SNT_CONSTANT );
     CPLAssert(papoSubExpr[1]->eNodeType == SNT_CONSTANT );
     if (nSubExprCount == 3)
+    {
         CPLAssert(papoSubExpr[2]->eNodeType == SNT_CONSTANT );
-
+    }
     int bCond = FALSE;
     if (papoSubExpr[0]->field_type == ODS_FIELD_TYPE_INTEGER)
     {
diff --git a/ogr/ogrsf_frmts/openair/ogropenairlayer.cpp b/ogr/ogrsf_frmts/openair/ogropenairlayer.cpp
index 04cdee5..2c3d3ae 100644
--- a/ogr/ogrsf_frmts/openair/ogropenairlayer.cpp
+++ b/ogr/ogrsf_frmts/openair/ogropenairlayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogropenairlayer.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogropenairlayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenAir Translator
  * Purpose:  Implements OGROpenAirLayer class.
@@ -34,7 +34,7 @@
 #include "ogr_xplane_geo_utils.h"
 #include "ogr_srs_api.h"
 
-CPL_CVSID("$Id: ogropenairlayer.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogropenairlayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                         OGROpenAirLayer()                            */
@@ -137,7 +137,7 @@ OGRFeature *OGROpenAirLayer::GetNextRawFeature()
     const char* pszLine;
     CPLString osCLASS, osNAME, osFLOOR, osCEILING;
     OGRLinearRing oLR;
-    double dfLastLat = 0, dfLastLon = 0;
+    /* double dfLastLat = 0, dfLastLon = 0; */
     int bFirst = TRUE;
     int bClockWise = TRUE;
     double dfCenterLat = 0, dfCenterLon = 0;
@@ -272,8 +272,8 @@ OGRFeature *OGROpenAirLayer::GetNextRawFeature()
                 continue;
 
             oLR.addPoint(dfLon, dfLat);
-            dfLastLat = dfLat;
-            dfLastLon = dfLon;
+            /* dfLastLat = dfLat; */
+            /* dfLastLon = dfLon; */
         }
         else if (EQUALN(pszLine, "DA ", 3))
         {
@@ -314,8 +314,8 @@ OGRFeature *OGROpenAirLayer::GetNextRawFeature()
                                          dfEndDistance, dfEndAngle, &dfLat, &dfLon);
                 oLR.addPoint(dfLon, dfLat);
 
-                dfLastLat = oLR.getY(oLR.getNumPoints() - 1);
-                dfLastLon = oLR.getX(oLR.getNumPoints() - 1);
+                /* dfLastLat = oLR.getY(oLR.getNumPoints() - 1); */
+                /* dfLastLon = oLR.getX(oLR.getNumPoints() - 1); */
             }
             CSLDestroy(papszTokens);
         }
@@ -363,8 +363,8 @@ OGRFeature *OGROpenAirLayer::GetNextRawFeature()
                 }
                 oLR.addPoint(dfSecondLon, dfSecondLat);
 
-                dfLastLat = oLR.getY(oLR.getNumPoints() - 1);
-                dfLastLon = oLR.getX(oLR.getNumPoints() - 1);
+                /* dfLastLat = oLR.getY(oLR.getNumPoints() - 1); */
+                /* dfLastLon = oLR.getX(oLR.getNumPoints() - 1); */
             }
             CSLDestroy(papszTokens);
         }
@@ -394,8 +394,8 @@ OGRFeature *OGROpenAirLayer::GetNextRawFeature()
                                          dfRADIUS, 0, &dfLat, &dfLon);
                 oLR.addPoint(dfLon, dfLat);
 
-                dfLastLat = oLR.getY(oLR.getNumPoints() - 1);
-                dfLastLon = oLR.getX(oLR.getNumPoints() - 1);
+                /* dfLastLat = oLR.getY(oLR.getNumPoints() - 1); */
+                /* dfLastLon = oLR.getX(oLR.getNumPoints() - 1); */
             }
         }
         else if (EQUALN(pszLine, "V X=", 4))
@@ -469,4 +469,3 @@ int OGROpenAirLayer::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
-
diff --git a/ogr/ogrsf_frmts/openfilegdb/filegdbindex.cpp b/ogr/ogrsf_frmts/openfilegdb/filegdbindex.cpp
index ef314d5..96bfb30 100644
--- a/ogr/ogrsf_frmts/openfilegdb/filegdbindex.cpp
+++ b/ogr/ogrsf_frmts/openfilegdb/filegdbindex.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: filegdbindex.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: filegdbindex.cpp 27751 2014-09-28 16:33:48Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements reading of FileGDB indexes
@@ -74,7 +74,7 @@ class FileGDBTrivialIterator : public FileGDBIterator
         virtual                     ~FileGDBTrivialIterator() { delete poParentIter; }
 
         virtual FileGDBTable        *GetTable() { return poTable; }
-        virtual void                 Reset() { iRow = 0; }
+        virtual void                 Reset() { iRow = 0; poParentIter->Reset(); }
         virtual int                  GetNextRowSortedByFID();
         virtual int                  GetRowCount()
                 { return poTable->GetTotalRecordCount(); }
diff --git a/ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h b/ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h
index 03acd75..4280654 100644
--- a/ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h
+++ b/ogr/ogrsf_frmts/openfilegdb/ogr_openfilegdb.h
@@ -1,5 +1,5 @@
 /******************************************************************************
-* $Id: ogr_openfilegdb.h 27044 2014-03-16 23:41:27Z rouault $
+* $Id: ogr_openfilegdb.h 27771 2014-09-30 22:45:12Z rouault $
 *
 * Project:  OpenGIS Simple Features Reference Implementation
 * Purpose:  Implements Open FileGDB OGR driver.
@@ -165,6 +165,14 @@ class OGROpenFileGDBDataSource : public OGRDataSource
                                      int nInterestTable);
 
   int                 FileExists(const char* pszFilename);
+  void                AddLayer( const CPLString& osName,
+                                int nInterestTable,
+                                int& nCandidateLayers,
+                                int& nLayersSDC,
+                                const CPLString& osDefinition,
+                                const CPLString& osDocumentation,
+                                const char* pszGeomName,
+                                OGRwkbGeometryType eGeomType );
 
 public:
            OGROpenFileGDBDataSource();
diff --git a/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource.cpp b/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource.cpp
index e759e29..ae243cb 100644
--- a/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource.cpp
+++ b/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogropenfilegdbdatasource.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogropenfilegdbdatasource.cpp 27771 2014-09-30 22:45:12Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements Open FileGDB OGR driver.
@@ -262,6 +262,55 @@ int OGROpenFileGDBDataSource::Open( const char* pszFilename )
 }
 
 /***********************************************************************/
+/*                             AddLayer()                              */
+/***********************************************************************/
+
+void OGROpenFileGDBDataSource::AddLayer( const CPLString& osName,
+                                         int nInterestTable,
+                                         int& nCandidateLayers,
+                                         int& nLayersSDC,
+                                         const CPLString& osDefinition,
+                                         const CPLString& osDocumentation,
+                                         const char* pszGeomName,
+                                         OGRwkbGeometryType eGeomType )
+{
+    std::map<std::string, int>::const_iterator oIter =
+                                    m_osMapNameToIdx.find(osName);
+    int idx = 0;
+    if( oIter != m_osMapNameToIdx.end() )
+        idx = oIter->second;
+    if( idx > 0 && (nInterestTable < 0 || nInterestTable == idx) )
+    {
+        const char* pszFilename = CPLFormFilename(
+            m_osDirName, CPLSPrintf("a%08x", idx), "gdbtable");
+        if( FileExists(pszFilename) )
+        {
+            nCandidateLayers ++;
+
+            if( m_papszFiles != NULL )
+            {
+                const char* pszSDC = CPLResetExtension(pszFilename, "gdbtable.sdc");
+                if( FileExists(pszSDC) )
+                {
+                    nLayersSDC ++;
+                    CPLError(CE_Warning, CPLE_AppDefined,
+                            "%s layer has a %s file whose format is unhandled",
+                            osName.c_str(), pszSDC);
+                    return;
+                }
+            }
+
+            m_apoLayers.push_back(
+                new OGROpenFileGDBLayer(pszFilename,
+                                        osName,
+                                        osDefinition,
+                                        osDocumentation,
+                                        pszGeomName, eGeomType));
+        }
+    }
+}
+
+/***********************************************************************/
 /*                         OpenFileGDBv10()                            */
 /***********************************************************************/
 
@@ -313,39 +362,9 @@ int OGROpenFileGDBDataSource::OpenFileGDBv10(int iGDBItems,
             psField = oTable.GetFieldValue(iName);
             if( psField != NULL )
             {
-                std::map<std::string, int>::const_iterator oIter =
-                                            m_osMapNameToIdx.find(psField->String);
-                int idx = 0;
-                if( oIter != m_osMapNameToIdx.end() )
-                    idx = oIter->second;
-                if( idx > 0 && (nInterestTable < 0 || nInterestTable == idx) )
-                {
-                    const char* pszFilename = CPLFormFilename(
-                        m_osDirName, CPLSPrintf("a%08x", idx), "gdbtable");
-                    if( FileExists(pszFilename) )
-                    {
-                        nCandidateLayers ++;
-
-                        if( m_papszFiles != NULL )
-                        {
-                            const char* pszSDC = CPLResetExtension(pszFilename, "gdbtable.sdc");
-                            if( FileExists(pszSDC) )
-                            {
-                                nLayersSDC ++;
-                                CPLError(CE_Warning, CPLE_AppDefined,
-                                        "%s layer has a %s file whose format is unhandled",
-                                        psField->String, pszSDC);
-                                continue;
-                            }
-                        }
-
-                        m_apoLayers.push_back(
-                            new OGROpenFileGDBLayer(pszFilename,
-                                                    psField->String,
-                                                    osDefinition,
-                                                    osDocumentation));
-                    }
-                }
+                AddLayer( psField->String, nInterestTable, nCandidateLayers, nLayersSDC,
+                          osDefinition, osDocumentation,
+                          NULL, wkbUnknown );
             }
         }
     }
@@ -376,33 +395,51 @@ int OGROpenFileGDBDataSource::OpenFileGDBv9(int iGDBFeatureClasses,
         return FALSE;
 
     int iName = oTable.GetFieldIdx("Name");
-    if( iName < 0 ||
-        oTable.GetField(iName)->GetType() != FGFT_STRING )
+    int iCLSID = oTable.GetFieldIdx("CLSID");
+    if( iName < 0 || oTable.GetField(iName)->GetType() != FGFT_STRING ||
+        iCLSID < 0 || oTable.GetField(iCLSID)->GetType() != FGFT_STRING )
     {
         CPLError(CE_Failure, CPLE_AppDefined,
                     "Wrong structure for GDB_ObjectClasses table");
         return FALSE;
     }
-    std::vector<std::string> aosNames;
+    
+    std::vector< std::string > aosName;
+    int nCandidateLayers = 0, nLayersSDC = 0;
     for(i=0;i<oTable.GetTotalRecordCount();i++)
     {
         if( !oTable.SelectRow(i) )
         {
             if( oTable.HasGotError() )
                 break;
-            aosNames.push_back("");
+            aosName.push_back( "" );
             continue;
         }
 
         const OGRField* psField = oTable.GetFieldValue(iName);
         if( psField != NULL )
         {
-            aosNames.push_back(psField->String);
+            std::string osName(psField->String);
+            psField = oTable.GetFieldValue(iCLSID);
+            if( psField != NULL )
+            {
+                /* Is it a non-spatial table ? */
+                if( strcmp(psField->String, "{7A566981-C114-11D2-8A28-006097AFF44E}") == 0 )
+                {
+                    AddLayer( osName, nInterestTable, nCandidateLayers, nLayersSDC,
+                              "", "", NULL, wkbNone );
+                }
+                else
+                {
+                    /* We should perhaps also check that the CLSID is the one of a spatial table */
+                    aosName.push_back( osName );
+                }
+            }
         }
     }
     oTable.Close();
 
-    /* Find tables that are layers */
+    /* Find tables that are spatial layers */
     if( !oTable.Open(CPLFormFilename(m_osDirName,
             CPLSPrintf("a%08x", iGDBFeatureClasses + 1), "gdbtable")) )
         return FALSE;
@@ -420,7 +457,6 @@ int OGROpenFileGDBDataSource::OpenFileGDBv9(int iGDBFeatureClasses,
         return FALSE;
     }
 
-    int nCandidateLayers = 0, nLayersSDC = 0;
     for(i=0;i<oTable.GetTotalRecordCount();i++)
     {
         if( !oTable.SelectRow(i) )
@@ -457,42 +493,12 @@ int OGROpenFileGDBDataSource::OpenFileGDBv9(int iGDBFeatureClasses,
             continue;
 
         int idx = psField->Integer;
-        if( psField != NULL && idx > 0 && idx <= (int)aosNames.size() &&
-            aosNames[idx-1].size() > 0 )
+        if( psField != NULL && idx > 0 && idx <= (int)aosName.size() &&
+            aosName[idx-1].size() > 0 )
         {
-            const std::string osName(aosNames[idx-1]);
-            std::map<std::string, int>::const_iterator oIter =
-                                                m_osMapNameToIdx.find(osName);
-            idx = 0;
-            if( oIter != m_osMapNameToIdx.end() )
-                idx = oIter->second;
-
-            if( idx > 0 && ( nInterestTable < 0 || nInterestTable == idx) )
-            {
-                const char* pszFilename = CPLFormFilename(
-                            m_osDirName, CPLSPrintf("a%08x", idx), "gdbtable");
-                if( FileExists(pszFilename) )
-                {
-                    nCandidateLayers ++;
-
-                    if( m_papszFiles != NULL )
-                    {
-                        const char* pszSDC = CPLResetExtension(pszFilename, "gdbtable.sdc");
-                        if( FileExists(pszSDC) )
-                        {
-                            nLayersSDC ++;
-                            CPLError(CE_Warning, CPLE_AppDefined,
-                                    "%s layer has a %s file whose format is unhandled",
-                                    osName.c_str(), pszSDC);
-                            continue;
-                        }
-                    }
-
-                    m_apoLayers.push_back(new OGROpenFileGDBLayer(
-                        pszFilename, osName.c_str(), "", "",
-                        osGeomFieldName.c_str(), eGeomType));
-                }
-            }
+            const std::string osName(aosName[idx-1]);
+            AddLayer( osName, nInterestTable, nCandidateLayers, nLayersSDC,
+                      "", "", osGeomFieldName.c_str(), eGeomType);
         }
     }
 
diff --git a/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdblayer.cpp b/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdblayer.cpp
index 249e2ec..33e916f 100644
--- a/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdblayer.cpp
+++ b/ogr/ogrsf_frmts/openfilegdb/ogropenfilegdblayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogropenfilegdblayer.cpp 27654 2014-09-09 18:28:10Z rouault $
+ * $Id: ogropenfilegdblayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements Open FileGDB OGR driver.
@@ -380,7 +380,7 @@ int OGROpenFileGDBLayer::BuildLayerDefinition()
 
         const FileGDBField* poGDBField = m_poLyrTable->GetField(i);
         OGRFieldType eType = OFTString;
-        int nWidth = 0;
+        /* int nWidth = 0; */
         switch( poGDBField->GetType() )
         {
             case FGFT_INT16:
@@ -392,7 +392,7 @@ int OGROpenFileGDBLayer::BuildLayerDefinition()
                 eType = OFTReal;
                 break;
             case FGFT_STRING:
-                nWidth = poGDBField->GetMaxWidth();
+                /* nWidth = poGDBField->GetMaxWidth(); */
                 eType = OFTString;
                 break;
             case FGFT_UUID_1:
diff --git a/ogr/ogrsf_frmts/osm/gpb.h b/ogr/ogrsf_frmts/osm/gpb.h
index 626b215..c624fc1 100644
--- a/ogr/ogrsf_frmts/osm/gpb.h
+++ b/ogr/ogrsf_frmts/osm/gpb.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gpb.h 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: gpb.h 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Author:   Even Rouault, <even dot rouault at mines dash paris dot org>
@@ -268,6 +268,7 @@ static
 int SkipUnknownField(int nKey, GByte* pabyData, GByte* pabyDataLimit, int verbose) CPL_NO_INLINE;
 
 static
+/* CPL_UNUSED */
 int SkipUnknownField(int nKey, GByte* pabyData, GByte* pabyDataLimit, int verbose)
 {
     GByte* pabyDataBefore = pabyData;
diff --git a/ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp b/ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp
index 1727b2f..b8bbf2b 100644
--- a/ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp
+++ b/ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrosmdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrosmdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGROSMDataSource class.
@@ -121,7 +121,7 @@ size_t GetMaxTotalAllocs();
 static void WriteVarInt64(GUIntBig nSVal, GByte** ppabyData);
 static void WriteVarSInt64(GIntBig nSVal, GByte** ppabyData);
 
-CPL_CVSID("$Id: ogrosmdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrosmdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 class DSToBeOpened
 {
@@ -2611,8 +2611,9 @@ void OGROSMDataSource::ProcessPolygonsStandalone()
                 bFeatureAdded = TRUE;
 
         }
-        else
+        else {
             CPLAssert(FALSE);
+        }
 
         sqlite3_reset(pahSelectWayStmt[0]);
 
diff --git a/ogr/ogrsf_frmts/osm/osm_parser.cpp b/ogr/ogrsf_frmts/osm/osm_parser.cpp
index e537daa..dae4ec0 100644
--- a/ogr/ogrsf_frmts/osm/osm_parser.cpp
+++ b/ogr/ogrsf_frmts/osm/osm_parser.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: osm_parser.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: osm_parser.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Author:   Even Rouault, <even dot rouault at mines dash paris dot org>
@@ -45,7 +45,7 @@
 
 #define XML_BUFSIZE 64*1024
 
-CPL_CVSID("$Id: osm_parser.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: osm_parser.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                            INIT_INFO()                               */
@@ -338,6 +338,7 @@ int ReadOSMHeader(GByte* pabyData, GByte* pabyDataLimit,
         }
         else if (nKey == MAKE_KEY(OSMHEADER_IDX_OSMOSIS_REPLICATION_TIMESTAMP, WT_VARINT))
         {
+            /* TODO: Do something with nVal or change this to a seek forward. */
             GIntBig nVal;
             READ_VARINT64(pabyData, pabyDataLimit, nVal);
         }
diff --git a/ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp b/ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp
index 36a8bf4..a4e01ef 100644
--- a/ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp
+++ b/ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrpgdatasource.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrpgdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRPGDataSource class.
@@ -37,7 +37,7 @@
 
 #define PQexec this_is_an_error
 
-CPL_CVSID("$Id: ogrpgdatasource.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrpgdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 static void OGRPGNoticeProcessor( void *arg, const char * pszMessage );
 
@@ -1748,8 +1748,7 @@ OGRLayer *OGRPGDataSource::GetLayerByName( const char *pszName )
 /*                        OGRPGNoticeProcessor()                        */
 /************************************************************************/
 
-static void OGRPGNoticeProcessor( void *arg, const char * pszMessage )
-
+static void OGRPGNoticeProcessor( CPL_UNUSED void *arg, const char * pszMessage )
 {
     CPLDebug( "OGR_PG_NOTICE", "%s", pszMessage );
 }
diff --git a/ogr/ogrsf_frmts/pg/ogrpglayer.cpp b/ogr/ogrsf_frmts/pg/ogrpglayer.cpp
index 4324c02..76abb29 100644
--- a/ogr/ogrsf_frmts/pg/ogrpglayer.cpp
+++ b/ogr/ogrsf_frmts/pg/ogrpglayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrpglayer.cpp 27106 2014-03-28 11:59:57Z rouault $
+ * $Id: ogrpglayer.cpp 28445 2015-02-09 18:17:24Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRPGLayer class  which implements shared handling
@@ -65,7 +65,7 @@ PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 
 #define PQexec this_is_an_error
 
-CPL_CVSID("$Id: ogrpglayer.cpp 27106 2014-03-28 11:59:57Z rouault $");
+CPL_CVSID("$Id: ogrpglayer.cpp 28445 2015-02-09 18:17:24Z rouault $");
 
 #define CURSOR_PAGE     500
 
@@ -1348,6 +1348,14 @@ void OGRPGLayer::SetInitialQueryCursor()
     CPLAssert( pszQueryStatement != NULL );
 
     poDS->FlushSoftTransaction();
+
+    // Workaround a bug in tables= mode where the spatial ref
+    // hasn't yet been resolved. Doing so later during the FETCH transaction
+    // will fail due to the BEGIN / COMMIT involved in SRS resolution
+    // Ultimately we should reconsider all this transaction logic
+    for(int i=0;i<poFeatureDefn->GetGeomFieldCount();i++)
+        poFeatureDefn->GetGeomFieldDefn(i)->GetSpatialRef();
+
     poDS->SoftStartTransaction();
 
     if ( poDS->bUseBinaryCursor && bCanUseBinaryCursor )
@@ -1817,7 +1825,8 @@ OGRErr OGRPGLayer::GetExtent( int iGeomField, OGREnvelope *psExtent, int bForce
 /*                             GetExtent()                              */
 /************************************************************************/
 
-OGRErr OGRPGLayer::RunGetExtentRequest( OGREnvelope *psExtent, int bForce,
+OGRErr OGRPGLayer::RunGetExtentRequest( OGREnvelope *psExtent,
+                                        CPL_UNUSED int bForce,
                                         CPLString osCommand)
 {
     if ( psExtent == NULL )
diff --git a/ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp b/ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp
index 54ff9aa..5013e80 100644
--- a/ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp
+++ b/ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrpgtablelayer.cpp 27697 2014-09-19 18:21:02Z rouault $
+ * $Id: ogrpgtablelayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
 
  *
  * Project:  OpenGIS Simple Features Reference Implementation
@@ -37,7 +37,7 @@
 
 #define PQexec this_is_an_error
 
-CPL_CVSID("$Id: ogrpgtablelayer.cpp 27697 2014-09-19 18:21:02Z rouault $");
+CPL_CVSID("$Id: ogrpgtablelayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 
 #define USE_COPY_UNSET  -10
@@ -2388,7 +2388,7 @@ OGRErr OGRPGTableLayer::CreateField( OGRFieldDefn *poFieldIn, int bApproxOK )
 /************************************************************************/
 
 OGRErr OGRPGTableLayer::CreateGeomField( OGRGeomFieldDefn *poGeomFieldIn,
-                                         int bApproxOK )
+                                         CPL_UNUSED int bApproxOK )
 {
     PGconn              *hPGConn = poDS->GetPGConn();
     PGresult            *hResult;
diff --git a/ogr/ogrsf_frmts/pgeo/ogrpgeodatasource.cpp b/ogr/ogrsf_frmts/pgeo/ogrpgeodatasource.cpp
index e80fe9b..35b9aba 100644
--- a/ogr/ogrsf_frmts/pgeo/ogrpgeodatasource.cpp
+++ b/ogr/ogrsf_frmts/pgeo/ogrpgeodatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrpgeodatasource.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrpgeodatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRPGeoDataSource class.
@@ -33,7 +33,7 @@
 #include "cpl_string.h"
 #include <vector>
 
-CPL_CVSID("$Id: ogrpgeodatasource.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrpgeodatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                         OGRPGeoDataSource()                          */
@@ -99,8 +99,7 @@ static int CheckDSNStringTemplate(const char* pszStr)
 /************************************************************************/
 
 int OGRPGeoDataSource::Open( const char * pszNewName, int bUpdate,
-                              int bTestOpen )
-
+                             CPL_UNUSED int bTestOpen )
 {
     CPLAssert( nLayers == 0 );
 
@@ -216,8 +215,7 @@ int OGRPGeoDataSource::Open( const char * pszNewName, int bUpdate,
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRPGeoDataSource::TestCapability( const char * pszCap )
-
+int OGRPGeoDataSource::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
diff --git a/ogr/ogrsf_frmts/pgeo/ogrpgeodriver.cpp b/ogr/ogrsf_frmts/pgeo/ogrpgeodriver.cpp
index cdbd60e..afd7de9 100644
--- a/ogr/ogrsf_frmts/pgeo/ogrpgeodriver.cpp
+++ b/ogr/ogrsf_frmts/pgeo/ogrpgeodriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrpgeodriver.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrpgeodriver.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements Personal Geodatabase driver.
@@ -31,7 +31,7 @@
 #include "ogr_pgeo.h"
 #include "cpl_conv.h"
 
-CPL_CVSID("$Id: ogrpgeodriver.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrpgeodriver.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                            ~OGRODBCDriver()                            */
@@ -144,8 +144,7 @@ OGRDataSource *OGRPGeoDriver::Open( const char * pszFilename,
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRPGeoDriver::TestCapability( const char * pszCap )
-
+int OGRPGeoDriver::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
@@ -221,7 +220,7 @@ bool OGRODBCMDBDriver::FindDriverLib()
         // Directory or file path
         strLibPath = pszDrvCfg;
 
-        VSIStatBuf sStatBuf = { 0 };
+        VSIStatBuf sStatBuf;
         if ( VSIStat( pszDrvCfg, &sStatBuf ) == 0
              && VSI_ISDIR( sStatBuf.st_mode ) ) 
         {
@@ -270,7 +269,7 @@ bool OGRODBCMDBDriver::LibraryExists(const char* pszLibPath)
 {
     CPLAssert( 0 != pszLibPath );
 
-    VSIStatBuf stb = { 0 } ;
+    VSIStatBuf stb;
 
     if ( 0 == VSIStat( pszLibPath, &stb ) )
     {
@@ -297,4 +296,3 @@ void RegisterOGRPGeo()
 {
     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRPGeoDriver );
 }
-
diff --git a/ogr/ogrsf_frmts/pgeo/ogrpgeolayer.cpp b/ogr/ogrsf_frmts/pgeo/ogrpgeolayer.cpp
index 0194913..804d1f7 100644
--- a/ogr/ogrsf_frmts/pgeo/ogrpgeolayer.cpp
+++ b/ogr/ogrsf_frmts/pgeo/ogrpgeolayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrpgeolayer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrpgeolayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRPGeoLayer class, code shared between 
@@ -34,7 +34,7 @@
 #include "cpl_string.h"
 #include "ogrpgeogeometry.h"
 
-CPL_CVSID("$Id: ogrpgeolayer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrpgeolayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                            OGRPGeoLayer()                            */
@@ -324,8 +324,7 @@ OGRFeature *OGRPGeoLayer::GetFeature( long nFeatureId )
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRPGeoLayer::TestCapability( const char * pszCap )
-
+int OGRPGeoLayer::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
diff --git a/ogr/ogrsf_frmts/pgeo/ogrpgeotablelayer.cpp b/ogr/ogrsf_frmts/pgeo/ogrpgeotablelayer.cpp
index eb9111c..2ad23d4 100644
--- a/ogr/ogrsf_frmts/pgeo/ogrpgeotablelayer.cpp
+++ b/ogr/ogrsf_frmts/pgeo/ogrpgeotablelayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrpgeotablelayer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrpgeotablelayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRPGeoTableLayer class, access to an existing table.
@@ -32,7 +32,7 @@
 #include "ogr_pgeo.h"
 #include "ogrpgeogeometry.h"
 
-CPL_CVSID("$Id: ogrpgeotablelayer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrpgeotablelayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                          OGRPGeoTableLayer()                         */
@@ -374,8 +374,7 @@ int OGRPGeoTableLayer::GetFeatureCount( int bForce )
 /*                             GetExtent()                              */
 /************************************************************************/
 
-OGRErr OGRPGeoTableLayer::GetExtent( OGREnvelope *psExtent, int bForce )
-
+OGRErr OGRPGeoTableLayer::GetExtent( OGREnvelope *psExtent, CPL_UNUSED int bForce )
 {
     *psExtent = sExtent;
     return OGRERR_NONE;
diff --git a/ogr/ogrsf_frmts/s57/ogrs57layer.cpp b/ogr/ogrsf_frmts/s57/ogrs57layer.cpp
index e00edd3..bedfb03 100644
--- a/ogr/ogrsf_frmts/s57/ogrs57layer.cpp
+++ b/ogr/ogrsf_frmts/s57/ogrs57layer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrs57layer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrs57layer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  S-57 Translator
  * Purpose:  Implements OGRS57Layer class.
@@ -32,7 +32,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: ogrs57layer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrs57layer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                            OGRS57Layer()                             */
@@ -289,7 +289,9 @@ OGRErr OGRS57Layer::CreateFeature( OGRFeature *poFeature )
         if( !poFeature->IsFieldSet( iRCNMFld ) )
             poFeature->SetField( iRCNMFld, nRCNM );
         else
+        {
             CPLAssert( poFeature->GetFieldAsInteger( iRCNMFld ) == nRCNM );
+        }
     }
 
 /* -------------------------------------------------------------------- */
@@ -302,7 +304,9 @@ OGRErr OGRS57Layer::CreateFeature( OGRFeature *poFeature )
         if( !poFeature->IsFieldSet( iOBJLFld ) )
             poFeature->SetField( iOBJLFld, nOBJL );
         else
+        {
             CPLAssert( poFeature->GetFieldAsInteger( iOBJLFld ) == nOBJL );
+        }
     }
 
 /* -------------------------------------------------------------------- */
diff --git a/ogr/ogrsf_frmts/s57/s57reader.cpp b/ogr/ogrsf_frmts/s57/s57reader.cpp
index 0b4bef8..d3bbec1 100644
--- a/ogr/ogrsf_frmts/s57/s57reader.cpp
+++ b/ogr/ogrsf_frmts/s57/s57reader.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: s57reader.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: s57reader.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  S-57 Translator
  * Purpose:  Implements S57Reader class.
@@ -36,7 +36,7 @@
 #include <string>
 #include <fstream>
 
-CPL_CVSID("$Id: s57reader.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: s57reader.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 #ifndef PI
 #define PI  3.14159265358979323846
@@ -956,7 +956,7 @@ void S57Reader::ApplyObjectClassAttributes( DDFRecord * poRecord,
         }
 
         poFldDefn = poFeature->GetDefnRef()->GetFieldDefn( iField );
-        if( poFldDefn->GetType() == OFTInteger 
+        if( poFldDefn->GetType() == OFTInteger
             || poFldDefn->GetType() == OFTReal )
         {
             if( strlen(pszValue) == 0 )
@@ -964,7 +964,9 @@ void S57Reader::ApplyObjectClassAttributes( DDFRecord * poRecord,
                 if( nOptionFlags & S57M_PRESERVE_EMPTY_NUMBERS )
                     poFeature->SetField( iField, EMPTY_NUMBER_MARKER );
                 else
-                    /* leave as null if value was empty string */;
+                {
+                    /* leave as null if value was empty string */
+                }
             }
             else
                 poFeature->SetField( iField, pszValue );
@@ -974,7 +976,7 @@ void S57Reader::ApplyObjectClassAttributes( DDFRecord * poRecord,
 
         CPLFree(pszValueToFree);
     }
-    
+
 /* -------------------------------------------------------------------- */
 /*      NATF (national) attributes                                      */
 /* -------------------------------------------------------------------- */
@@ -2170,11 +2172,13 @@ void S57Reader::AssembleLineGeometry( DDFRecord * poFRecord,
                 poLine->addPoint( dfX, dfY );
             }
             else
-                /* omit point, already present */;
+            {
+                /* omit point, already present */
+            }
 
             // remember the coordinates of the last point
             dlastfX = dfX; dlastfY = dfY;
-        
+
 /* -------------------------------------------------------------------- */
 /*      Collect the vertices.                                           */
 /*      Iterate over all the SG2D fields in the Spatial record          */
@@ -3448,4 +3452,3 @@ OGRErr S57Reader::GetExtent( OGREnvelope *psExtent, int bForce )
         return OGRERR_NONE;
     }
 }
-
diff --git a/ogr/ogrsf_frmts/s57/s57writer.cpp b/ogr/ogrsf_frmts/s57/s57writer.cpp
index 6ee0c9c..abd55b6 100644
--- a/ogr/ogrsf_frmts/s57/s57writer.cpp
+++ b/ogr/ogrsf_frmts/s57/s57writer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: s57writer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: s57writer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  S-57 Translator
  * Purpose:  Implements S57Writer class.
@@ -33,7 +33,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: s57writer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: s57writer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                             S57Writer()                              */
@@ -448,9 +448,9 @@ int S57Writer::WriteDSID( const char *pszDSNM, const char *pszISDT,
 /*      Add the DSID field.                                             */
 /* -------------------------------------------------------------------- */
     DDFRecord *poRec = MakeRecord();
-    DDFField *poField;
+    /* DDFField *poField; */
 
-    poField = poRec->AddField( poModule->FindFieldDefn( "DSID" ) );
+    /* poField = */ poRec->AddField( poModule->FindFieldDefn( "DSID" ) );
 
     poRec->SetIntSubfield   ( "DSID", 0, "RCNM", 0, 10 );
     poRec->SetIntSubfield   ( "DSID", 0, "RCID", 0, 1 );
@@ -473,7 +473,7 @@ int S57Writer::WriteDSID( const char *pszDSNM, const char *pszISDT,
 /*      Add the DSSI record.  Eventually we will need to return and     */
 /*      correct these when we are finished writing.                     */
 /* -------------------------------------------------------------------- */
-    poField = poRec->AddField( poModule->FindFieldDefn( "DSSI" ) );
+    /* poField = */ poRec->AddField( poModule->FindFieldDefn( "DSSI" ) );
 
     poRec->SetIntSubfield   ( "DSSI", 0, "DSTR", 0, 2 );
     poRec->SetIntSubfield   ( "DSSI", 0, "AALL", 0, 1 );
@@ -510,9 +510,9 @@ int S57Writer::WriteDSPM( int nScale )
 /*      Add the DSID field.                                             */
 /* -------------------------------------------------------------------- */
     DDFRecord *poRec = MakeRecord();
-    DDFField *poField;
+    /* DDFField *poField; */
 
-    poField = poRec->AddField( poModule->FindFieldDefn( "DSPM" ) );
+    /* poField = */ poRec->AddField( poModule->FindFieldDefn( "DSPM" ) );
 
     poRec->SetIntSubfield   ( "DSPM", 0, "RCNM", 0, 20 );
     poRec->SetIntSubfield   ( "DSPM", 0, "RCID", 0, 1 );
@@ -625,18 +625,18 @@ int S57Writer::WritePrimitive( OGRFeature *poFeature )
 
 {
     DDFRecord *poRec = MakeRecord();
-    DDFField *poField;
+    /* DDFField *poField; */
     OGRGeometry *poGeom = poFeature->GetGeometryRef();
 
 /* -------------------------------------------------------------------- */
 /*      Add the VRID field.                                             */
 /* -------------------------------------------------------------------- */
 
-    poField = poRec->AddField( poModule->FindFieldDefn( "VRID" ) );
+    /* poField = */ poRec->AddField( poModule->FindFieldDefn( "VRID" ) );
 
-    poRec->SetIntSubfield   ( "VRID", 0, "RCNM", 0, 
+    poRec->SetIntSubfield   ( "VRID", 0, "RCNM", 0,
                               poFeature->GetFieldAsInteger( "RCNM") );
-    poRec->SetIntSubfield   ( "VRID", 0, "RCID", 0, 
+    poRec->SetIntSubfield   ( "VRID", 0, "RCID", 0,
                               poFeature->GetFieldAsInteger( "RCID") );
     poRec->SetIntSubfield   ( "VRID", 0, "RVER", 0, 1 );
     poRec->SetIntSubfield   ( "VRID", 0, "RUIN", 0, 1 );
@@ -719,7 +719,7 @@ int S57Writer::WritePrimitive( OGRFeature *poFeature )
 
         CPLFree( padfX );
         CPLFree( padfY );
-        
+
     }
 
 /* -------------------------------------------------------------------- */
@@ -727,14 +727,14 @@ int S57Writer::WritePrimitive( OGRFeature *poFeature )
 /* -------------------------------------------------------------------- */
     if( poFeature->GetDefnRef()->GetFieldIndex( "NAME_RCNM_0" ) >= 0 )
     {
-        DDFField *poField;
+        /* DDFField *poField; */
         char     szName[5];
         int      nRCID;
 
         CPLAssert( poFeature->GetFieldAsInteger( "NAME_RCNM_0") == RCNM_VC );
 
-        poField = poRec->AddField( poModule->FindFieldDefn( "VRPT" ) );
-        
+        /* poField = */ poRec->AddField( poModule->FindFieldDefn( "VRPT" ) );
+
         nRCID = poFeature->GetFieldAsInteger( "NAME_RCID_0");
         szName[0] = RCNM_VC;
         szName[1] = nRCID & 0xff;
@@ -1052,5 +1052,3 @@ int S57Writer::WriteATTF( DDFRecord *poRec, OGRFeature *poFeature )
 
     return poRec->SetFieldRaw( poField, 0, achRawData, nRawSize );
 }
-
-
diff --git a/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp b/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp
index 71bfd4e..6ad8e79 100644
--- a/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp
+++ b/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrshapelayer.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: ogrshapelayer.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRShapeLayer class.
@@ -43,7 +43,7 @@
 
 #define UNSUPPORTED_OP_READ_ONLY "%s : unsupported operation on a read-only datasource."
 
-CPL_CVSID("$Id: ogrshapelayer.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogrshapelayer.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 
 class OGRShapeGeomFieldDefn: public OGRGeomFieldDefn
@@ -1734,11 +1734,11 @@ OGRErr OGRShapeLayer::AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn,
     char            szFieldName[20];
     int             nWidth, nPrecision;
     OGRFieldType    eType = poFieldDefn->GetType();
-    DBFFieldType    eDBFType;
+    /* DBFFieldType    eDBFType; */
 
     chNativeType = DBFGetNativeFieldType( hDBF, iField );
-    eDBFType = DBFGetFieldInfo( hDBF, iField, szFieldName,
-                                &nWidth, &nPrecision );
+    /* eDBFType = */ DBFGetFieldInfo( hDBF, iField, szFieldName,
+                                      &nWidth, &nPrecision );
 
     if ((nFlags & ALTER_TYPE_FLAG) &&
         poNewFieldDefn->GetType() != poFieldDefn->GetType())
@@ -2526,11 +2526,11 @@ OGRErr OGRShapeLayer::ResizeDBF()
         char            szFieldName[20];
         int             nOriWidth, nPrecision;
         char            chNativeType;
-        DBFFieldType    eDBFType;
+        /* DBFFieldType    eDBFType; */
 
         chNativeType = DBFGetNativeFieldType( hDBF, iField );
-        eDBFType = DBFGetFieldInfo( hDBF, iField, szFieldName,
-                                    &nOriWidth, &nPrecision );
+        /* eDBFType = */ DBFGetFieldInfo( hDBF, iField, szFieldName,
+                                          &nOriWidth, &nPrecision );
 
         if (panBestWidth[j] < nOriWidth)
         {
diff --git a/ogr/ogrsf_frmts/shape/shape2ogr.cpp b/ogr/ogrsf_frmts/shape/shape2ogr.cpp
index 7a7b481..93f98e0 100644
--- a/ogr/ogrsf_frmts/shape/shape2ogr.cpp
+++ b/ogr/ogrsf_frmts/shape/shape2ogr.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: shape2ogr.cpp 27604 2014-08-23 10:01:50Z rouault $
+ * $Id: shape2ogr.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements translation of Shapefile shapes into OGR
@@ -32,7 +32,7 @@
 #include "ogrshape.h"
 #include "cpl_conv.h"
 
-CPL_CVSID("$Id: shape2ogr.cpp 27604 2014-08-23 10:01:50Z rouault $");
+CPL_CVSID("$Id: shape2ogr.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                        RingStartEnd                                  */
@@ -1137,11 +1137,11 @@ static OGRErr GrowField(DBFHandle hDBF, int iField, OGRFieldDefn* poFieldDefn,
     char            szFieldName[20];
     int             nOriWidth, nPrecision;
     char            chNativeType;
-    DBFFieldType    eDBFType;
+    /* DBFFieldType    eDBFType; */
 
     chNativeType = DBFGetNativeFieldType( hDBF, iField );
-    eDBFType = DBFGetFieldInfo( hDBF, iField, szFieldName,
-                                &nOriWidth, &nPrecision );
+    /* eDBFType = */ DBFGetFieldInfo( hDBF, iField, szFieldName,
+                                      &nOriWidth, &nPrecision );
 
     CPLDebug("SHAPE", "Extending field %d (%s) from %d to %d characters",
                 iField, poFieldDefn->GetNameRef(), nOriWidth, nNewSize);
@@ -1382,4 +1382,3 @@ OGRErr SHPWriteOGRFeature( SHPHandle hSHP, DBFHandle hDBF,
 
     return OGRERR_NONE;
 }
-
diff --git a/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp b/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp
index 33b494a..c6db77f 100644
--- a/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp
+++ b/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrsqlitelayer.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrsqlitelayer.cpp 28178 2014-12-19 21:14:05Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRSQLiteLayer class, code shared between 
@@ -42,7 +42,7 @@
 #include "ogr_sqlite.h"
 #include <cassert>
 
-CPL_CVSID("$Id: ogrsqlitelayer.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrsqlitelayer.cpp 28178 2014-12-19 21:14:05Z rouault $");
 
 /************************************************************************/
 /*                           OGRSQLiteLayer()                           */
@@ -472,6 +472,7 @@ void OGRSQLiteLayer::BuildFeatureDefn( const char *pszLayerName,
 const char *OGRSQLiteLayer::GetFIDColumn() 
 
 {
+    GetLayerDefn();
     if( pszFIDColumn != NULL )
         return pszFIDColumn;
     else
diff --git a/ogr/ogrsf_frmts/sqlite/ogrsqliteregexp.cpp b/ogr/ogrsf_frmts/sqlite/ogrsqliteregexp.cpp
index dc36c22..81f5d81 100644
--- a/ogr/ogrsf_frmts/sqlite/ogrsqliteregexp.cpp
+++ b/ogr/ogrsf_frmts/sqlite/ogrsqliteregexp.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrsqliteregexp.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrsqliteregexp.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  SQLite REGEXP function
@@ -68,7 +68,7 @@ typedef struct {
 /************************************************************************/
 
 static
-void OGRSQLiteREGEXPFunction(sqlite3_context *ctx, int argc, sqlite3_value **argv)
+void OGRSQLiteREGEXPFunction(sqlite3_context *ctx, CPL_UNUSED int argc, sqlite3_value **argv)
 {
     const char *re, *str;
     pcre *p;
diff --git a/ogr/ogrsf_frmts/sqlite/ogrsqlitetablelayer.cpp b/ogr/ogrsf_frmts/sqlite/ogrsqlitetablelayer.cpp
index 161056e..f87c086 100644
--- a/ogr/ogrsf_frmts/sqlite/ogrsqlitetablelayer.cpp
+++ b/ogr/ogrsf_frmts/sqlite/ogrsqlitetablelayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrsqlitetablelayer.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrsqlitetablelayer.cpp 27770 2014-09-30 11:57:38Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRSQLiteTableLayer class, access to an existing table.
@@ -37,7 +37,7 @@
 
 #define UNSUPPORTED_OP_READ_ONLY "%s : unsupported operation on a read-only datasource."
 
-CPL_CVSID("$Id: ogrsqlitetablelayer.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrsqlitetablelayer.cpp 27770 2014-09-30 11:57:38Z rouault $");
 
 /************************************************************************/
 /*                        OGRSQLiteTableLayer()                         */
@@ -139,11 +139,10 @@ CPLErr OGRSQLiteTableLayer::Initialize( const char *pszTableName,
                                         OGRSpatialReference *poSRS,
                                         int nSRSId,
                                         int bHasSpatialIndex,
-                                        int bHasM, 
+                                        int bHasM,
                                         int bIsVirtualShapeIn )
-
 {
-    int rc;
+    /* int rc; */
     sqlite3 *hDB = poDS->GetDB();
 
     if( pszGeomFormat )
@@ -180,22 +179,22 @@ CPLErr OGRSQLiteTableLayer::Initialize( const char *pszTableName,
 
     pszEscapedTableName = CPLStrdup(OGRSQLiteEscape(pszTableName));
 
-    sqlite3_stmt *hColStmt = NULL;
+    // sqlite3_stmt *hColStmt = NULL;
     const char *pszSQL;
 
     if ( eGeomFormat == OSGF_SpatiaLite &&
-         poDS->IsSpatialiteLoaded() && 
+         poDS->IsSpatialiteLoaded() &&
          poDS->GetSpatialiteVersionNumber() < 24 && poDS->GetUpdate() )
     {
-    // we need to test version required by Spatialite TRIGGERs 
-        hColStmt = NULL;
+        // we need to test version required by Spatialite TRIGGERs
+        // hColStmt = NULL;
         pszSQL = CPLSPrintf( "SELECT sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name = '%s' AND sql LIKE '%%RTreeAlign%%'",
             pszEscapedTableName );
 
         int nRowTriggerCount, nColTriggerCount;
         char **papszTriggerResult, *pszErrMsg;
 
-        rc = sqlite3_get_table( hDB, pszSQL, &papszTriggerResult,
+        /* rc = */ sqlite3_get_table( hDB, pszSQL, &papszTriggerResult,
             &nRowTriggerCount, &nColTriggerCount, &pszErrMsg );
         if( nRowTriggerCount >= 1 )
         {
@@ -207,7 +206,7 @@ CPLErr OGRSQLiteTableLayer::Initialize( const char *pszTableName,
 
         sqlite3_free_table( papszTriggerResult );
     }
-	
+
     if( poSRS )
         poSRS->Reference();
 
@@ -1772,7 +1771,7 @@ OGRErr OGRSQLiteTableLayer::BindValues( OGRFeature *poFeature,
                     poFeature->GetFieldAsDateTime(iField, &nYear, &nMonth, &nDay,
                                                 &nHour, &nMinute, &nSecond, &nTZ);
                     char szBuffer[64];
-                    sprintf(szBuffer, "%04d-%02d-%02dT", nYear, nMonth, nDay);
+                    sprintf(szBuffer, "%04d-%02d-%02d", nYear, nMonth, nDay);
                     rc = sqlite3_bind_text(hStmt, nBindField++,
                                            szBuffer, -1, SQLITE_TRANSIENT);
                     break;
diff --git a/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp b/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp
index 56a3941..e3c126f 100644
--- a/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp
+++ b/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrsqlitevfs.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrsqlitevfs.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements SQLite VFS
@@ -30,7 +30,7 @@
 #include "cpl_atomic_ops.h"
 #include "ogr_sqlite.h"
 
-CPL_CVSID("$Id: ogrsqlitevfs.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrsqlitevfs.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 //#define DEBUG_IO 1
 
@@ -247,7 +247,7 @@ static const sqlite3_io_methods OGRSQLiteIOMethods =
     OGRSQLiteIODeviceCharacteristics
 #if 0
     // TODO: These are in sqlite3.
-    0, // xShmMap
+    , 0, // xShmMap
     0, // xShmLock
     0, // xShmBarrier
     0, // xShmUnmap
diff --git a/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp b/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp
index 9abda33..b1cb666 100644
--- a/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp
+++ b/ogr/ogrsf_frmts/sqlite/ogrsqlitevirtualogr.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrsqlitevirtualogr.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrsqlitevirtualogr.cpp 27950 2014-11-11 10:02:20Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  SQLite Virtual Table module using OGR layers
@@ -35,6 +35,25 @@
 
 #ifdef HAVE_SQLITE_VFS
 
+/************************************************************************/
+/*                           OGR2SQLITE_Register()                      */
+/************************************************************************/
+
+CPL_C_START
+int CPL_DLL OGR2SQLITE_static_register (sqlite3* hDB, char **pzErrMsg, void* pApi);
+CPL_C_END
+
+/* We call this function so that each time a db is created, */
+/* OGR2SQLITE_static_register is called, to initialize the sqlite3_api */
+/* structure with the right pointers. */
+/* We need to declare this function before including sqlite3ext.h, since */
+/* sqlite 3.8.7, sqlite3_auto_extension can be a macro (#5725) */
+
+void OGR2SQLITE_Register()
+{
+    sqlite3_auto_extension ((void (*)(void)) OGR2SQLITE_static_register);
+}
+
 #define VIRTUAL_OGR_DYNAMIC_EXTENSION_ENABLED
 //#define DEBUG_OGR2SQLITE
 
@@ -2400,18 +2419,13 @@ int sqlite3_extension_init (sqlite3 * hDB, char **pzErrMsg,
 /*                        OGR2SQLITE_static_register()                  */
 /************************************************************************/
 
-CPL_C_START
-int CPL_DLL OGR2SQLITE_static_register (sqlite3 * hDB, char **pzErrMsg,
-                                        const sqlite3_api_routines * pApi);
-CPL_C_END
-
 #ifndef WIN32
 extern const struct sqlite3_api_routines OGRSQLITE_static_routines;
 #endif
 
-int OGR2SQLITE_static_register (sqlite3 * hDB, char **pzErrMsg,
-                                const sqlite3_api_routines * pApi)
+int OGR2SQLITE_static_register (sqlite3 * hDB, char **pzErrMsg, void * _pApi)
 {
+    const sqlite3_api_routines * pApi = (const sqlite3_api_routines * )_pApi;
 #ifndef WIN32
     if( pApi->create_module == NULL )
     {
@@ -2447,17 +2461,4 @@ int OGR2SQLITE_static_register (sqlite3 * hDB, char **pzErrMsg,
     return SQLITE_OK;
 }
 
-/************************************************************************/
-/*                           OGR2SQLITE_Register()                      */
-/************************************************************************/
-
-/* We call this function so that each time a db is created, */
-/* OGR2SQLITE_static_register is called, to initialize the sqlite3_api */
-/* structure with the right pointers. */
-
-void OGR2SQLITE_Register()
-{
-    sqlite3_auto_extension ((void (*)(void)) OGR2SQLITE_static_register);
-}
-
 #endif // HAVE_SQLITE_VFS
diff --git a/ogr/ogrsf_frmts/sxf/ogrsxfdatasource.cpp b/ogr/ogrsf_frmts/sxf/ogrsxfdatasource.cpp
index de56747..3c5c22b 100644
--- a/ogr/ogrsf_frmts/sxf/ogrsxfdatasource.cpp
+++ b/ogr/ogrsf_frmts/sxf/ogrsxfdatasource.cpp
@@ -287,13 +287,13 @@ int OGRSXFDataSource::Open( const char * pszFilename, int bUpdateIn)
 
 OGRErr OGRSXFDataSource::ReadSXFDescription(VSILFILE* fpSXF, SXFPassport& passport)
 {
-    int nObjectsRead;
+    /* int nObjectsRead; */
 
     if (passport.version == 3)
     {
         //78
         GByte buff[62];
-        nObjectsRead = VSIFReadL(&buff, 62, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&buff, 62, 1, fpSXF);
         char date[3] = { 0 };
 
         //read year
@@ -332,7 +332,7 @@ OGRErr OGRSXFDataSource::ReadSXFDescription(VSILFILE* fpSXF, SXFPassport& passpo
     {
         //96
         GByte buff[80];
-        nObjectsRead = VSIFReadL(&buff, 80, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&buff, 80, 1, fpSXF);
         char date[5] = { 0 };
 
         //read year
@@ -369,9 +369,9 @@ OGRErr OGRSXFDataSource::ReadSXFDescription(VSILFILE* fpSXF, SXFPassport& passpo
 
 OGRErr OGRSXFDataSource::ReadSXFInformationFlags(VSILFILE* fpSXF, SXFPassport& passport)
 {
-    int nObjectsRead;
+    /* int nObjectsRead; */
     GByte val[4];
-    nObjectsRead = VSIFReadL(&val, 4, 1, fpSXF);
+    /* nObjectsRead = */ VSIFReadL(&val, 4, 1, fpSXF);
 
     if (!(CHECK_BIT(val[0], 0) && CHECK_BIT(val[0], 1)))
     {
@@ -467,14 +467,14 @@ void OGRSXFDataSource::SetVertCS(const long iVCS, SXFPassport& passport)
     if (eImportFromEPSGErr != OGRERR_NONE)
     {
         CPLError( CE_Warning, CPLE_None,
-                  CPLString().Printf("SXF. Vertical coordinate system (SXF index %ld, EPSG %d) import from EPSG error", iVCS, nEPSG) );
+                  CPLString().Printf("SXF. Vertical coordinate system (SXF index %ld, EPSG %ld) import from EPSG error", iVCS, nEPSG) );
         return;
     }
 
     if (sr->IsVertical() != 1)
     {
         CPLError( CE_Warning, CPLE_None,
-                  CPLString().Printf("SXF. Coordinate system (SXF index %ld, EPSG %d) is not Vertical", iVCS, nEPSG) );
+                  CPLString().Printf("SXF. Coordinate system (SXF index %ld, EPSG %ld) is not Vertical", iVCS, nEPSG) );
         return;
     }
 
@@ -483,13 +483,13 @@ void OGRSXFDataSource::SetVertCS(const long iVCS, SXFPassport& passport)
     if (eSetVertCSErr != OGRERR_NONE)
     {
         CPLError( CE_Warning, CPLE_None,
-                  CPLString().Printf("SXF. Vertical coordinate system (SXF index %ld, EPSG %d) set error", iVCS, nEPSG) );
+                  CPLString().Printf("SXF. Vertical coordinate system (SXF index %ld, EPSG %ld) set error", iVCS, nEPSG) );
         return;
     }
 }
 OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& passport)
 {
-    int nObjectsRead;
+    /* int nObjectsRead; */
     int i;
     passport.stMapDescription.Env.MaxX = -100000000;
     passport.stMapDescription.Env.MinX = 100000000;
@@ -502,15 +502,15 @@ OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& pas
     if (passport.version == 3)
     {
         short nNoObjClass, nNoSemClass;
-        nObjectsRead = VSIFReadL(&nNoObjClass, 2, 1, fpSXF);
-        nObjectsRead = VSIFReadL(&nNoSemClass, 2, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&nNoObjClass, 2, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&nNoSemClass, 2, 1, fpSXF);
         GByte baMask[8];
-        nObjectsRead = VSIFReadL(&baMask, 8, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&baMask, 8, 1, fpSXF);
 
         int nCorners[8];
 
         //get projected corner coords
-        nObjectsRead = VSIFReadL(&nCorners, 32, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&nCorners, 32, 1, fpSXF);
 
         for (i = 0; i < 8; i++)
         {
@@ -532,7 +532,7 @@ OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& pas
             bIsX = !bIsX;
         }
         //get geographic corner coords
-        nObjectsRead = VSIFReadL(&nCorners, 32, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&nCorners, 32, 1, fpSXF);
 
         for (i = 0; i < 8; i++)
         {
@@ -542,7 +542,7 @@ OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& pas
     else if (passport.version == 4)
     {
         int nEPSG;
-        nObjectsRead = VSIFReadL(&nEPSG, 4, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&nEPSG, 4, 1, fpSXF);
 
         if (nEPSG != 0)
         {
@@ -551,7 +551,7 @@ OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& pas
         }
 
         double dfCorners[8];
-        nObjectsRead = VSIFReadL(&dfCorners, 64, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&dfCorners, 64, 1, fpSXF);
 
         for (i = 0; i < 8; i++)
         {
@@ -574,7 +574,7 @@ OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& pas
 
         }
         //get geographic corner coords
-        nObjectsRead = VSIFReadL(&dfCorners, 64, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&dfCorners, 64, 1, fpSXF);
 
         for (i = 0; i < 8; i++)
         {
@@ -589,7 +589,7 @@ OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& pas
     }
 
     GByte anData[8] = { 0 };
-    nObjectsRead = VSIFReadL(&anData, 8, 1, fpSXF);
+    /* nObjectsRead = */ VSIFReadL(&anData, 8, 1, fpSXF);
     long iEllips = anData[0];
     long iVCS = anData[1];
     long iProjSys = anData[2];
@@ -629,14 +629,14 @@ OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& pas
             GInt16 anFrame[8];
             GUInt32 nFrameCode;
         } buff;
-        nObjectsRead = VSIFReadL(&buff, 20, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&buff, 20, 1, fpSXF);
         passport.stMapDescription.nResolution = buff.nRes; //resolution
 
         for (i = 0; i < 8; i++)
             passport.stMapDescription.stFrameCoords[i] = buff.anFrame[i];
 
         int anParams[5];
-        nObjectsRead = VSIFReadL(&anParams, 20, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&anParams, 20, 1, fpSXF);
 
         if (anParams[0] != -1)
             dfProjScale = double(anParams[0]) / 100000000.0;
@@ -682,14 +682,14 @@ OGRErr OGRSXFDataSource::ReadSXFMapDescription(VSILFILE* fpSXF, SXFPassport& pas
 
         VSIFSeekL(fpSXF, 312, SEEK_SET);
         GUInt32 buff[10];
-        nObjectsRead = VSIFReadL(&buff, 40, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&buff, 40, 1, fpSXF);
 
         passport.stMapDescription.nResolution = buff[0]; //resolution
         for (i = 0; i < 8; i++)
             passport.stMapDescription.stFrameCoords[i] = buff[1 + i];
 
         double adfParams[6];
-        nObjectsRead = VSIFReadL(&adfParams, 48, 1, fpSXF);
+        /* nObjectsRead = */ VSIFReadL(&adfParams, 48, 1, fpSXF);
 
         if (adfParams[1] != -1)
             dfProjScale = adfParams[1];
@@ -819,9 +819,9 @@ void OGRSXFDataSource::FillLayers()
 
     //2. Read all records (only classify code and offset) and add this to correspondence layer
     long nFID;
-    int nObjectsRead;
+    int nObjectsRead = 0;
     size_t i;
-    vsi_l_offset nOffset, nOffsetSemantic;
+    vsi_l_offset nOffset = 0, nOffsetSemantic;
     int nDeletedLayerIndex;
 
     //get record count
@@ -838,6 +838,7 @@ void OGRSXFDataSource::FillLayers()
         nObjectsRead = VSIFReadL(&nRecordCountMax, 4, 1, fpSXF);
         nOffset = 452;
     }
+    /* else nOffset and nObjectsRead will be 0 */
 
     if (nObjectsRead != 1)
     {
diff --git a/ogr/ogrsf_frmts/sxf/ogrsxflayer.cpp b/ogr/ogrsf_frmts/sxf/ogrsxflayer.cpp
index 3562156..12baf40 100644
--- a/ogr/ogrsf_frmts/sxf/ogrsxflayer.cpp
+++ b/ogr/ogrsf_frmts/sxf/ogrsxflayer.cpp
@@ -709,7 +709,7 @@ OGRFeature *OGRSXFLayer::GetNextRawFeature(long nFID)
     }
     stCertInfo.nSubObjectCount = stRecordHeader.nSubObjectCount;
 
-    bool bFloatType, bBigType;
+    bool bFloatType = 0, bBigType = 0;
     bool b3D(true);
     if (m_nSXFFormatVer == 3)
     {
@@ -725,6 +725,7 @@ OGRFeature *OGRSXFLayer::GetNextRawFeature(long nFID)
         bBigType = CHECK_BIT(stRecordHeader.nRef[1], 2);
         stCertInfo.bHasTextSign = CHECK_BIT(stRecordHeader.nRef[2], 3);
     }
+    // Else trouble.
 
     if (b3D) //xххххх1х
         stCertInfo.bDim = 1;
@@ -1426,4 +1427,3 @@ const char* OGRSXFLayer::GetFIDColumn()
 {
     return sFIDColumn_.c_str();
 }
-
diff --git a/ogr/ogrsf_frmts/vfk/vfkdatablocksqlite.cpp b/ogr/ogrsf_frmts/vfk/vfkdatablocksqlite.cpp
index 137f946..70f2ca0 100644
--- a/ogr/ogrsf_frmts/vfk/vfkdatablocksqlite.cpp
+++ b/ogr/ogrsf_frmts/vfk/vfkdatablocksqlite.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: vfkdatablocksqlite.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: vfkdatablocksqlite.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  VFK Reader - Data block definition (SQLite)
  * Purpose:  Implements VFKDataBlockSQLite
@@ -47,21 +47,21 @@ int VFKDataBlockSQLite::LoadGeometryPoint()
 {
     int   nInvalid, rowId, nGeometries;
     bool  bSkipInvalid;
-    long iFID;
+    /* long iFID; */
     double x, y;
 
     CPLString     osSQL;
     sqlite3_stmt *hStmt;
-    
+
     VFKFeatureSQLite *poFeature;
     VFKReaderSQLite  *poReader;
-    
+
     nInvalid  = nGeometries = 0;
     poReader  = (VFKReaderSQLite*) m_poReader;
 
     if (LoadGeometryFromDB()) /* try to load geometry from DB */
 	return 0;
-    
+
     bSkipInvalid = EQUAL(m_pszName, "OB") || EQUAL(m_pszName, "OP") || EQUAL(m_pszName, "OBBP");
     osSQL.Printf("SELECT SOURADNICE_Y,SOURADNICE_X,%s,rowid FROM %s",
                  FID_COLUMN, m_pszName);
@@ -74,19 +74,21 @@ int VFKDataBlockSQLite::LoadGeometryPoint()
         /* read values */
         x = -1.0 * sqlite3_column_double(hStmt, 0); /* S-JTSK coordinate system expected */
         y = -1.0 * sqlite3_column_double(hStmt, 1);
-	iFID = sqlite3_column_double(hStmt, 2);
+#ifdef DEBUG
+	const long iFID = sqlite3_column_double(hStmt, 2);
+#endif
 	rowId = sqlite3_column_int(hStmt, 3);
 
         poFeature = (VFKFeatureSQLite *) GetFeatureByIndex(rowId - 1);
         CPLAssert(NULL != poFeature && poFeature->GetFID() == iFID);
-        
+
         /* create geometry */
 	OGRPoint pt(x, y);
         if (!poFeature->SetGeometry(&pt)) {
             nInvalid++;
             continue;
         }
-        
+
 	/* store also geometry in DB */
 	if (poReader->IsSpatial() &&
 	    SaveGeometryToDB(&pt, rowId) != OGRERR_FAILURE)
diff --git a/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp b/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp
index ad27ee1..4a30ecd 100644
--- a/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp
+++ b/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrvrtlayer.cpp 27080 2014-03-23 00:26:43Z rouault $
+ * $Id: ogrvrtlayer.cpp 28159 2014-12-17 11:04:07Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRVRTLayer class.
@@ -34,7 +34,7 @@
 #include "ogrpgeogeometry.h"
 #include <string>
 
-CPL_CVSID("$Id: ogrvrtlayer.cpp 27080 2014-03-23 00:26:43Z rouault $");
+CPL_CVSID("$Id: ogrvrtlayer.cpp 28159 2014-12-17 11:04:07Z rouault $");
 
 #define UNSUPPORTED_OP_READ_ONLY "%s : unsupported operation on a read-only datasource."
 
@@ -1482,7 +1482,9 @@ retry:
                                 poSrcFeat->GetFieldAsDouble( apoGeomFieldProps[i]->iGeomYField ) ) );
         }
         else
-            /* add other options here. */;
+        {
+            /* add other options here. */
+        }
 
         /* In the non direct case, we need to check that the geometry intersects the source */
         /* region before an optionnal clipping */
@@ -1733,7 +1735,9 @@ OGRFeature* OGRVRTLayer::TranslateVRTFeatureToSrcFeature( OGRFeature* poVRTFeatu
             }
         }
         else
-            /* add other options here. */;
+        {
+            /* add other options here. */
+        }
 
         OGRGeometry* poGeom = poSrcFeat->GetGeomFieldRef(i);
         if ( poGeom != NULL && apoGeomFieldProps[i]->poSRS != NULL )
@@ -2262,8 +2266,26 @@ OGRErr OGRVRTLayer::SetIgnoredFields( const char **papszFields )
                 int iSrcField = anSrcField[iVRTField];
                 if (iSrcField >= 0)
                 {
-                    OGRFieldDefn *poSrcDefn = poSrcFeatureDefn->GetFieldDefn( iSrcField );
-                    papszFieldsSrc = CSLAddString(papszFieldsSrc, poSrcDefn->GetNameRef());
+                    /* If we are asked to ignore x or y for a VGS_PointFromColumns */
+                    /* geometry field, we must NOT pass that order to the underlying */
+                    /* layer */
+                    int bOKToIgnore = TRUE;
+                    for(int iGeomVRTField = 0;
+                            iGeomVRTField < GetLayerDefn()->GetGeomFieldCount(); iGeomVRTField++)
+                    {
+                        if( (iSrcField == apoGeomFieldProps[iGeomVRTField]->iGeomXField ||
+                             iSrcField == apoGeomFieldProps[iGeomVRTField]->iGeomYField ||
+                             iSrcField == apoGeomFieldProps[iGeomVRTField]->iGeomZField) )
+                        {
+                            bOKToIgnore = FALSE;
+                            break;
+                        }
+                    }
+                    if( bOKToIgnore )
+                    {
+                        OGRFieldDefn *poSrcDefn = poSrcFeatureDefn->GetFieldDefn( iSrcField );
+                        papszFieldsSrc = CSLAddString(papszFieldsSrc, poSrcDefn->GetNameRef());
+                    }
                 }
             }
             else
@@ -2299,6 +2321,8 @@ OGRErr OGRVRTLayer::SetIgnoredFields( const char **papszFields )
     {
         OGRVRTGeometryStyle eGeometryStyle =
             apoGeomFieldProps[iVRTField]->eGeometryStyle;
+        /* For a VGS_PointFromColumns geometry field, we must not ignore */
+        /* the fields that help building it */
         if( eGeometryStyle == VGS_PointFromColumns )
         {
             int iSrcField = apoGeomFieldProps[iVRTField]->iGeomXField;
@@ -2311,6 +2335,7 @@ OGRErr OGRVRTLayer::SetIgnoredFields( const char **papszFields )
             if (iSrcField >= 0)
                 panSrcFieldsUsed[iSrcField] = TRUE;
         }
+        /* Similarly for other kinds of geometry fields */
         else if( eGeometryStyle == VGS_WKT || eGeometryStyle == VGS_WKB ||
                  eGeometryStyle == VGS_Shape )
         {
diff --git a/ogr/ogrsf_frmts/walk/ogrwalkdriver.cpp b/ogr/ogrsf_frmts/walk/ogrwalkdriver.cpp
index 3f8385e..847310e 100644
--- a/ogr/ogrsf_frmts/walk/ogrwalkdriver.cpp
+++ b/ogr/ogrsf_frmts/walk/ogrwalkdriver.cpp
@@ -105,14 +105,13 @@ OGRDataSource *OGRWalkDriver::Open( const char * pszFilename, int bUpdate )
 /************************************************************************/
 
 OGRDataSource *OGRWalkDriver::CreateDataSource( const char * pszName,
-                                                 char **papszOptions )
-
+                                                CPL_UNUSED char **papszOptions )
 {
     //if( !EQUAL(CPLGetExtension(pszName), "MDB") )
     //    return NULL;
 
     OGRWalkDataSource  *poDS = new OGRWalkDataSource();
-    
+
     if( !poDS->Open( pszName, TRUE ) )
     {
         delete poDS;
@@ -129,8 +128,7 @@ OGRDataSource *OGRWalkDriver::CreateDataSource( const char * pszName,
 /*                           TestCapability()                           */
 /************************************************************************/
 
-int OGRWalkDriver::TestCapability( const char * pszCap )
-
+int OGRWalkDriver::TestCapability( CPL_UNUSED const char * pszCap )
 {
     return FALSE;
 }
@@ -144,4 +142,3 @@ void RegisterOGRWalk()
 {
     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRWalkDriver );
 }
-
diff --git a/ogr/ogrsf_frmts/walk/ogrwalktablelayer.cpp b/ogr/ogrsf_frmts/walk/ogrwalktablelayer.cpp
index dc7dc8d..93eb964 100644
--- a/ogr/ogrsf_frmts/walk/ogrwalktablelayer.cpp
+++ b/ogr/ogrsf_frmts/walk/ogrwalktablelayer.cpp
@@ -353,8 +353,7 @@ int OGRWalkTableLayer::GetFeatureCount( int bForce )
 /*                             GetExtent()                              */
 /************************************************************************/
 
-OGRErr OGRWalkTableLayer::GetExtent( OGREnvelope *psExtent, int bForce )
-
+OGRErr OGRWalkTableLayer::GetExtent( OGREnvelope *psExtent, CPL_UNUSED int bForce )
 {
     *psExtent = sExtent;
     return OGRERR_NONE;
diff --git a/ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp b/ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp
index 8dfa1f7..197c03c 100644
--- a/ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp
+++ b/ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrwfsdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrwfsdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $
  *
  * Project:  WFS Translator
  * Purpose:  Implements OGRWFSDataSource class
@@ -37,7 +37,7 @@
 #include "swq.h"
 #include "ogr_p.h"
 
-CPL_CVSID("$Id: ogrwfsdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrwfsdatasource.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 #define DEFAULT_BASE_START_INDEX     0
 #define DEFAULT_PAGE_SIZE            100
@@ -1216,7 +1216,7 @@ int OGRWFSDataSource::Open( const char * pszFilename, int bUpdateIn)
 
                 CPLXMLNode* psBBox = NULL;
                 CPLXMLNode* psLatLongBBox = NULL;
-                int bFoundBBox = FALSE;
+                /* int bFoundBBox = FALSE; */
                 double dfMinX = 0, dfMinY = 0, dfMaxX = 0, dfMaxY = 0;
                 if ((psBBox = CPLGetXMLNode(psChildIter, "WGS84BoundingBox")) != NULL)
                 {
@@ -1232,7 +1232,7 @@ int OGRWFSDataSource::Open( const char * pszFilename, int bUpdateIn)
                                             osConcat, " ,", FALSE, FALSE );
                         if (CSLCount(papszTokens) == 4)
                         {
-                            bFoundBBox = TRUE;
+                            /* bFoundBBox = TRUE; */
                             dfMinX = CPLAtof(papszTokens[0]);
                             dfMinY = CPLAtof(papszTokens[1]);
                             dfMaxX = CPLAtof(papszTokens[2]);
@@ -1255,7 +1255,7 @@ int OGRWFSDataSource::Open( const char * pszFilename, int bUpdateIn)
                     if (pszMinX != NULL && pszMinY != NULL &&
                         pszMaxX != NULL && pszMaxY != NULL)
                     {
-                        bFoundBBox = TRUE;
+                        /* bFoundBBox = TRUE; */
                         dfMinX = CPLAtof(pszMinX);
                         dfMinY = CPLAtof(pszMinY);
                         dfMaxX = CPLAtof(pszMaxX);
diff --git a/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp b/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp
index 4ba8a47..ac63bf5 100644
--- a/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp
+++ b/ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrxlsxdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $
+ * $Id: ogrxlsxdatasource.cpp 28181 2014-12-20 17:22:45Z rouault $
  *
  * Project:  XLSX Translator
  * Purpose:  Implements OGRXLSXDataSource class
@@ -32,7 +32,7 @@
 #include "cpl_conv.h"
 #include "cpl_time.h"
 
-CPL_CVSID("$Id: ogrxlsxdatasource.cpp 27729 2014-09-24 00:40:16Z goatbar $");
+CPL_CVSID("$Id: ogrxlsxdatasource.cpp 28181 2014-12-20 17:22:45Z rouault $");
 
 /************************************************************************/
 /*                            OGRXLSXLayer()                            */
@@ -1621,11 +1621,16 @@ static void WriteWorkbook(const char* pszName, OGRDataSource* poDS)
 
 static void BuildColString(char szCol[5], int nCol)
 {
+    /*
+    A Z   AA AZ   BA BZ   ZA   ZZ   AAA    ZZZ      AAAA
+    0 25  26 51   52 77   676  701  702    18277    18278
+    */
     int k = 0;
     szCol[k++] = (nCol % 26) + 'A';
     while(nCol >= 26)
     {
         nCol /= 26;
+        nCol --; /* We wouldn't need that if this was a proper base 26 numeration scheme ! */
         szCol[k++] = (nCol % 26) + 'A';
     }
     szCol[k] = 0;
diff --git a/ogr/ogrsf_frmts/xplane/ogr_xplane_apt_reader.cpp b/ogr/ogrsf_frmts/xplane/ogr_xplane_apt_reader.cpp
index e41ac76..83e9611 100644
--- a/ogr/ogrsf_frmts/xplane/ogr_xplane_apt_reader.cpp
+++ b/ogr/ogrsf_frmts/xplane/ogr_xplane_apt_reader.cpp
@@ -30,7 +30,7 @@
 #include "ogr_xplane_apt_reader.h"
 #include "ogr_xplane_geo_utils.h"
 
-CPL_CVSID("$Id: ogr_xplane_apt_reader.cpp 27118 2014-04-02 20:52:00Z rouault $");
+CPL_CVSID("$Id: ogr_xplane_apt_reader.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                   OGRXPlaneCreateAptFileReader                       */
@@ -1032,7 +1032,7 @@ int OGRXPlaneAptReader::ParsePolygonalGeometry(OGRGeometry** ppoGeom)
     double dfLastLatBezier = 0., dfLastLonBezier = 0.;
     int bIsFirst = TRUE;
     int bFirstIsBezier = TRUE;
-    int bLastIsValid = FALSE;
+    /* int bLastIsValid = FALSE; */
     int bLastIsBezier = FALSE;
     int bLastPartIsClosed = FALSE;
     const char* pszLine;
@@ -1230,7 +1230,7 @@ int OGRXPlaneAptReader::ParsePolygonalGeometry(OGRGeometry** ppoGeom)
 
         dfLastLat = dfLat;
         dfLastLon = dfLon;
-        bLastIsValid = TRUE;
+        /* bLastIsValid = TRUE; */
 
         CSLDestroy(papszTokens);
     }
@@ -1362,7 +1362,7 @@ int OGRXPlaneAptReader::ParseLinearGeometry(OGRMultiLineString& multilinestring,
     double dfLastLatBezier = 0., dfLastLonBezier = 0.;
     int bIsFirst = TRUE;
     int bFirstIsBezier = TRUE;
-    int bLastIsValid = FALSE;
+    /* int bLastIsValid = FALSE; */
     int bLastIsBezier = FALSE;
     int bLastPartIsClosedOrEnded = FALSE;
     const char* pszLine;
@@ -1583,7 +1583,7 @@ int OGRXPlaneAptReader::ParseLinearGeometry(OGRMultiLineString& multilinestring,
 
         dfLastLat = dfLat;
         dfLastLon = dfLon;
-        bLastIsValid = TRUE;
+        /* bLastIsValid = TRUE; */
 
         CSLDestroy(papszTokens);
     }
diff --git a/ogr/ogrsf_frmts/xplane/ogr_xplane_nav_reader.cpp b/ogr/ogrsf_frmts/xplane/ogr_xplane_nav_reader.cpp
index 7032e1a..fe3b1e6 100644
--- a/ogr/ogrsf_frmts/xplane/ogr_xplane_nav_reader.cpp
+++ b/ogr/ogrsf_frmts/xplane/ogr_xplane_nav_reader.cpp
@@ -29,7 +29,7 @@
 
 #include "ogr_xplane_nav_reader.h"
 
-CPL_CVSID("$Id: ogr_xplane_nav_reader.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: ogr_xplane_nav_reader.cpp 27741 2014-09-26 19:20:02Z goatbar $");
 
 /************************************************************************/
 /*                   OGRXPlaneCreateNavFileReader                       */
@@ -351,7 +351,7 @@ void    OGRXPlaneNavReader::ParseRecord(int nType)
 
         if (EQUAL(papszTokens[nTokens-1], "DME-ILS"))
         {
-            char* pszAptICAO, * pszRwyNum, * pszSubType;
+            char* pszAptICAO, * pszRwyNum /* , * pszSubType */;
             if (nTokens != 11)
             {
                 CPLDebug("XPlane", "Line %d : not enough columns : %d",
@@ -361,7 +361,7 @@ void    OGRXPlaneNavReader::ParseRecord(int nType)
 
             pszAptICAO = papszTokens[8];
             pszRwyNum = papszTokens[9];
-            pszSubType = papszTokens[10];
+            /* pszSubType = papszTokens[10]; */
 
             if (poDMEILSLayer)
                 poDMEILSLayer->AddFeature(pszNavaidId, pszAptICAO, pszRwyNum,
@@ -378,7 +378,7 @@ void    OGRXPlaneNavReader::ParseRecord(int nType)
                     EQUAL(papszTokens[nTokens-1], "TACAN") ||
                     EQUAL(papszTokens[nTokens-1], "NDB-DME"))
                 {
-                    pszSubType = papszTokens[nTokens-1];
+                    /* pszSubType = papszTokens[nTokens-1]; */
                     nTokens--;
                 }
             }
diff --git a/port/cpl_csv.cpp b/port/cpl_csv.cpp
index 72307e6..8239f8a 100644
--- a/port/cpl_csv.cpp
+++ b/port/cpl_csv.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: cpl_csv.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: cpl_csv.cpp 27958 2014-11-13 21:58:48Z goatbar $
  *
  * Project:  CPL - Common Portability Library
  * Purpose:  CSV (comma separated value) file access.
@@ -33,7 +33,7 @@
 #include "cpl_multiproc.h"
 #include "gdal_csv.h"
 
-CPL_CVSID("$Id: cpl_csv.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: cpl_csv.cpp 27958 2014-11-13 21:58:48Z goatbar $");
 
 /* ==================================================================== */
 /*      The CSVTable is a persistant set of info about an open CSV      */
@@ -1081,7 +1081,7 @@ const char * GDALDefaultCSVFilename( const char *pszBasename )
 
         if( CPLGetConfigOption("GEOTIFF_CSV",NULL) != NULL )
             CPLPushFinderLocation( CPLGetConfigOption("GEOTIFF_CSV",NULL));
-            
+
         if( CPLGetConfigOption("GDAL_DATA",NULL) != NULL )
             CPLPushFinderLocation( CPLGetConfigOption("GDAL_DATA",NULL) );
 
@@ -1090,33 +1090,25 @@ const char * GDALDefaultCSVFilename( const char *pszBasename )
         if( pszResult != NULL )
             return pszResult;
     }
-            
-    if( (fp = fopen( "csv/horiz_cs.csv", "rt" )) != NULL )
-    {
-        strcpy( pTLSData->szPath, "csv/" );
-        CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
-    }
-    else
-    {
+
 #ifdef GDAL_PREFIX
   #ifdef MACOSX_FRAMEWORK
-        strcpy( pTLSData->szPath, GDAL_PREFIX "/Resources/epsg_csv/" );
-        CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
+    strcpy( pTLSData->szPath, GDAL_PREFIX "/Resources/epsg_csv/" );
+    CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
   #else
-        strcpy( pTLSData->szPath, GDAL_PREFIX "/share/epsg_csv/" );
-        CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
+    strcpy( pTLSData->szPath, GDAL_PREFIX "/share/epsg_csv/" );
+    CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
   #endif
 #else
-        strcpy( pTLSData->szPath, "/usr/local/share/epsg_csv/" );
-        CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
+    strcpy( pTLSData->szPath, "/usr/local/share/epsg_csv/" );
+    CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
 #endif
-        if( (fp = fopen( pTLSData->szPath, "rt" )) == NULL )
-            CPLStrlcpy( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
-    }
+    if( (fp = fopen( pTLSData->szPath, "rt" )) == NULL )
+        CPLStrlcpy( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) );
 
     if( fp != NULL )
         fclose( fp );
-        
+
     return( pTLSData->szPath );
 }
 
diff --git a/port/cpl_odbc.cpp b/port/cpl_odbc.cpp
index e8a4376..a918980 100644
--- a/port/cpl_odbc.cpp
+++ b/port/cpl_odbc.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: cpl_odbc.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: cpl_odbc.cpp 27739 2014-09-25 18:49:52Z goatbar $
  *
  * Project:  OGR ODBC Driver
  * Purpose:  Declarations for ODBC Access Cover API.
@@ -36,7 +36,7 @@
 
 #ifndef WIN32CE /* ODBC is not supported on Windows CE. */
 
-CPL_CVSID("$Id: cpl_odbc.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: cpl_odbc.cpp 27739 2014-09-25 18:49:52Z goatbar $");
 
 #ifndef SQLColumns_TABLE_CAT 
 #define SQLColumns_TABLE_CAT 1
@@ -75,9 +75,10 @@ CPLODBCDriverInstaller::CPLODBCDriverInstaller()
 /************************************************************************/
 
 int CPLODBCDriverInstaller::InstallDriver( const char* pszDriver,
-        const char* pszPathIn, WORD fRequest )
+                                           CPL_UNUSED const char* pszPathIn,
+                                           WORD fRequest )
 {
-    CPLAssert( NULL != pszDriver ); 
+    CPLAssert( NULL != pszDriver );
 
     // Try to install driver to system-wide location
     if ( FALSE == SQLInstallDriverEx( pszDriver, NULL, m_szPathOut,
@@ -85,11 +86,11 @@ int CPLODBCDriverInstaller::InstallDriver( const char* pszDriver,
                     &m_nUsageCount ) )
     {
         const WORD nErrorNum = 1; // TODO - a function param?
-        RETCODE cRet = SQL_ERROR;
-        
+        CPL_UNUSED RETCODE cRet = SQL_ERROR;
+
         // Failure is likely related to no write permissions to
         // system-wide default location, so try to install to HOME
-       
+
         static char* pszEnvIni = NULL;
         if (pszEnvIni == NULL)
         {
diff --git a/port/cpl_string.cpp b/port/cpl_string.cpp
index fc1264e..f054921 100644
--- a/port/cpl_string.cpp
+++ b/port/cpl_string.cpp
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: cpl_string.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: cpl_string.cpp 28321 2015-01-16 10:33:52Z rouault $
  *
  * Name:     cpl_string.cpp
  * Project:  CPL - Common Portability Library
@@ -55,7 +55,7 @@
 #  include <wce_string.h>
 #endif
 
-CPL_CVSID("$Id: cpl_string.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: cpl_string.cpp 28321 2015-01-16 10:33:52Z rouault $");
 
 /*=====================================================================
                     StringList manipulation functions.
@@ -1912,51 +1912,54 @@ char *CPLBinaryToHex( int nBytes, const GByte *pabyData )
  * @return returns binary buffer of data - free with CPLFree().
  */
 
-GByte *CPLHexToBinary( const char *pszHex, int *pnBytes )
+static const unsigned char hex2char[256] = {
+    /* not Hex characters */
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    /* 0-9 */
+    0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,
+       /* A-F */
+    0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,
+    /* not Hex characters */
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+      /* a-f */
+    0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    /* not Hex characters (upper 128 characters) */
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+};
 
+GByte *CPLHexToBinary( const char *pszHex, int *pnBytes )
 {
-    int     iSrc = 0, iDst = 0;
     size_t  nHexLen = strlen(pszHex);
-
-    GByte *pabyWKB;
+    size_t i;
+    register unsigned char h1, h2;
+    GByte *pabyWKB; 
 
     pabyWKB = (GByte *) CPLMalloc(nHexLen / 2 + 2);
-
-    while( pszHex[iSrc] != '\0' )
+            
+    for( i = 0; i < nHexLen/2; i++ )
     {
-        if( pszHex[iSrc] >= '0' && pszHex[iSrc] <= '9' )
-            pabyWKB[iDst] = pszHex[iSrc] - '0';
-        else if( pszHex[iSrc] >= 'A' && pszHex[iSrc] <= 'F' )
-            pabyWKB[iDst] = pszHex[iSrc] - 'A' + 10;
-        else if( pszHex[iSrc] >= 'a' && pszHex[iSrc] <= 'f' )
-            pabyWKB[iDst] = pszHex[iSrc] - 'a' + 10;
-        else 
-            break;
-
-        pabyWKB[iDst] *= 16;
+        h1 = hex2char[(int)pszHex[2*i]];
+        h2 = hex2char[(int)pszHex[2*i+1]];
 
-        iSrc++;
-
-        if( pszHex[iSrc] >= '0' && pszHex[iSrc] <= '9' )
-            pabyWKB[iDst] += pszHex[iSrc] - '0';
-        else if( pszHex[iSrc] >= 'A' && pszHex[iSrc] <= 'F' )
-            pabyWKB[iDst] += pszHex[iSrc] - 'A' + 10;
-        else if( pszHex[iSrc] >= 'a' && pszHex[iSrc] <= 'f' )
-            pabyWKB[iDst] += pszHex[iSrc] - 'a' + 10;
-        else
-            break;
-
-        iSrc++;
-        iDst++;
+        /* First character is high bits, second is low bits */
+        pabyWKB[i] = (GByte)((h1 << 4) | h2);
     }
+    pabyWKB[nHexLen/2] = 0;
+    *pnBytes = nHexLen/2;
     
-    pabyWKB[iDst] = 0;
-    *pnBytes = iDst;
-
     return pabyWKB;
-}
-
 
+}
 
 /************************************************************************/
 /*                         CPLGetValueType()                            */
diff --git a/port/cpl_vsil_curl.cpp b/port/cpl_vsil_curl.cpp
index e45430d..f72504d 100644
--- a/port/cpl_vsil_curl.cpp
+++ b/port/cpl_vsil_curl.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: cpl_vsil_curl.cpp 27722 2014-09-22 15:37:31Z goatbar $
+ * $Id: cpl_vsil_curl.cpp 28190 2014-12-21 22:42:54Z rouault $
  *
  * Project:  CPL - Common Portability Library
  * Purpose:  Implement VSI large file api for HTTP/FTP files
@@ -34,7 +34,7 @@
 #include "cpl_time.h"
 #include "cpl_vsil_curl_priv.h"
 
-CPL_CVSID("$Id: cpl_vsil_curl.cpp 27722 2014-09-22 15:37:31Z goatbar $");
+CPL_CVSID("$Id: cpl_vsil_curl.cpp 28190 2014-12-21 22:42:54Z rouault $");
 
 #ifndef HAVE_CURL
 
@@ -790,9 +790,16 @@ int VSICurlHandle::DownloadRegion(vsi_l_offset startOffset, int nBlocks)
     sWriteFuncHeaderData.bIsHTTP = strncmp(pszURL, "http", 4) == 0;
     sWriteFuncHeaderData.nStartOffset = startOffset;
     sWriteFuncHeaderData.nEndOffset = startOffset + nBlocks * DOWNLOAD_CHUNCK_SIZE - 1;
+    /* Some servers don't like we try to read after end-of-file (#5786) */
+    if( cachedFileProp->bHastComputedFileSize && 
+        sWriteFuncHeaderData.nEndOffset >= cachedFileProp->fileSize )
+    {
+        sWriteFuncHeaderData.nEndOffset = cachedFileProp->fileSize - 1;
+    }
 
     char rangeStr[512];
-    sprintf(rangeStr, CPL_FRMT_GUIB "-" CPL_FRMT_GUIB, startOffset, startOffset + nBlocks * DOWNLOAD_CHUNCK_SIZE - 1);
+    sprintf(rangeStr, CPL_FRMT_GUIB "-" CPL_FRMT_GUIB, startOffset,
+            sWriteFuncHeaderData.nEndOffset);
 
     if (ENABLE_DEBUG)
         CPLDebug("VSICURL", "Downloading %s (%s)...", rangeStr, pszURL);
@@ -992,6 +999,9 @@ size_t VSICurlHandle::Read( void *pBuffer, size_t nSize, size_t nMemb )
                 }
             }
 
+            if( nBlocksToDownload > N_MAX_REGIONS )
+                nBlocksToDownload = N_MAX_REGIONS;
+
             if (DownloadRegion(nOffsetToDownload, nBlocksToDownload) == FALSE)
             {
                 if (!bInterrupted)
diff --git a/swig/include/gdal_array.i b/swig/include/gdal_array.i
index 66cd5e2..92e290c 100644
--- a/swig/include/gdal_array.i
+++ b/swig/include/gdal_array.i
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdal_array.i 26832 2014-01-15 12:46:08Z rouault $
+ * $Id: gdal_array.i 28304 2015-01-07 11:24:37Z rouault $
  *
  * Name:     gdal_array.i
  * Project:  GDAL Python Interface
@@ -82,6 +82,7 @@ class NUMPYDataset : public GDALDataset
 {
     PyArrayObject *psArray;
 
+    int           bValidGeoTransform;
     double	  adfGeoTransform[6];
     char	  *pszProjection;
 
@@ -141,6 +142,7 @@ NUMPYDataset::NUMPYDataset()
 
 {
     pszProjection = CPLStrdup("");
+    bValidGeoTransform = FALSE;
     adfGeoTransform[0] = 0.0;
     adfGeoTransform[1] = 1.0;
     adfGeoTransform[2] = 0.0;
@@ -204,7 +206,10 @@ CPLErr NUMPYDataset::GetGeoTransform( double * padfTransform )
 
 {
     memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 );
-    return CE_None;
+    if( bValidGeoTransform )
+        return CE_None;
+    else
+        return CE_Failure;
 }
 
 /************************************************************************/
@@ -214,6 +219,7 @@ CPLErr NUMPYDataset::GetGeoTransform( double * padfTransform )
 CPLErr NUMPYDataset::SetGeoTransform( double * padfTransform )
 
 {
+    bValidGeoTransform = TRUE;
     memcpy( adfGeoTransform, padfTransform, sizeof(double)*6 );
     return( CE_None );
 }
diff --git a/swig/include/perl/gdal_perl.i b/swig/include/perl/gdal_perl.i
index 255f2a6..d2db8da 100644
--- a/swig/include/perl/gdal_perl.i
+++ b/swig/include/perl/gdal_perl.i
@@ -116,8 +116,8 @@ ALTERED_DESTROY(GDALRasterAttributeTableShadow, GDALc, delete_RasterAttributeTab
     # etc.  GDAL 2.0 should then get VERSION 2.000 and 2.1 should get
     # 2.001 etc.
 
-    our $VERSION = '1.9921';
-    our $GDAL_VERSION = '1.11.1';
+    our $VERSION = '1.9922';
+    our $GDAL_VERSION = '1.11.2';
     use vars qw/
 	%TYPE_STRING2INT %TYPE_INT2STRING
 	%ACCESS_STRING2INT %ACCESS_INT2STRING
diff --git a/swig/include/python/ogr_python.i b/swig/include/python/ogr_python.i
index 17ab0dd..7c1876c 100644
--- a/swig/include/python/ogr_python.i
+++ b/swig/include/python/ogr_python.i
@@ -1,5 +1,5 @@
 /*
- * $Id: ogr_python.i 26302 2013-08-11 16:24:14Z rouault $
+ * $Id: ogr_python.i 28298 2015-01-06 09:03:37Z rouault $
  *
  * python specific code for ogr bindings.
  */
@@ -111,7 +111,7 @@ ds[0:4] would return a list of the first four layers."""
 }
 
 %extend OGRLayerShadow {
-  %pythoncode {
+  %pythoncode %{
     def Reference(self):
       "For backwards compatibility only."
       pass
@@ -183,12 +183,12 @@ layer[0:4] would return a list of the first four features."""
         return output
     schema = property(schema)
 
-  }
+  %}
 
 }
 
 %extend OGRFeatureShadow {
-  %pythoncode {
+  %pythoncode %{
     def Reference(self):
       pass
 
@@ -383,12 +383,12 @@ layer[0:4] would return a list of the first four features."""
         return output
 
 
-}
+%}
 
 }
 
 %extend OGRGeometryShadow {
-%pythoncode {
+%pythoncode %{
   def Destroy(self):
     self.__swig_destroy__(self) 
     self.__del__()
@@ -416,7 +416,7 @@ layer[0:4] would return a list of the first four features."""
           return subgeom
       else:
           raise StopIteration
-}
+%}
 }
 
 
@@ -449,12 +449,12 @@ layer[0:4] would return a list of the first four features."""
 }
 
 %extend OGRFieldDefnShadow {
-%pythoncode {
+%pythoncode %{
   def Destroy(self):
     "Once called, self has effectively been destroyed.  Do not access. For backwards compatiblity only"
     _ogr.delete_FieldDefn( self )
     self.thisown = 0
-}
+%}
 }
 
 %import typemaps_python.i
diff --git a/swig/include/python/python_exceptions.i b/swig/include/python/python_exceptions.i
index d916e95..5d22cfe 100644
--- a/swig/include/python/python_exceptions.i
+++ b/swig/include/python/python_exceptions.i
@@ -40,14 +40,20 @@ int GetUseExceptions() {
 }
 
 void UseExceptions() {
-  bUseExceptions = 1;
-  pfnPreviousHandler = 
-    CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
+  if( !bUseExceptions )
+  {
+    bUseExceptions = 1;
+    pfnPreviousHandler = 
+        CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
+  }
 }
 
 void DontUseExceptions() {
-  bUseExceptions = 0;
-  CPLSetErrorHandler( pfnPreviousHandler );
+  if( bUseExceptions )
+  {
+    bUseExceptions = 0;
+    CPLSetErrorHandler( pfnPreviousHandler );
+  }
 }
 %}
 
diff --git a/swig/perl/lib/Geo/GDAL.pm b/swig/perl/lib/Geo/GDAL.pm
index eb7b7b6..8814901 100644
--- a/swig/perl/lib/Geo/GDAL.pm
+++ b/swig/perl/lib/Geo/GDAL.pm
@@ -612,8 +612,8 @@ package Geo::GDAL;
     # etc.  GDAL 2.0 should then get VERSION 2.000 and 2.1 should get
     # 2.001 etc.
 
-    our $VERSION = '1.9921';
-    our $GDAL_VERSION = '1.11.1';
+    our $VERSION = '1.9922';
+    our $GDAL_VERSION = '1.11.2';
     use vars qw/
 	%TYPE_STRING2INT %TYPE_INT2STRING
 	%ACCESS_STRING2INT %ACCESS_INT2STRING
diff --git a/swig/python/extensions/gdal_array_wrap.cpp b/swig/python/extensions/gdal_array_wrap.cpp
index ab86ea8..d3e9989 100644
--- a/swig/python/extensions/gdal_array_wrap.cpp
+++ b/swig/python/extensions/gdal_array_wrap.cpp
@@ -3163,6 +3163,7 @@ class NUMPYDataset : public GDALDataset
 {
     PyArrayObject *psArray;
 
+    int           bValidGeoTransform;
     double	  adfGeoTransform[6];
     char	  *pszProjection;
 
@@ -3222,6 +3223,7 @@ NUMPYDataset::NUMPYDataset()
 
 {
     pszProjection = CPLStrdup("");
+    bValidGeoTransform = FALSE;
     adfGeoTransform[0] = 0.0;
     adfGeoTransform[1] = 1.0;
     adfGeoTransform[2] = 0.0;
@@ -3285,7 +3287,10 @@ CPLErr NUMPYDataset::GetGeoTransform( double * padfTransform )
 
 {
     memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 );
-    return CE_None;
+    if( bValidGeoTransform )
+        return CE_None;
+    else
+        return CE_Failure;
 }
 
 /************************************************************************/
@@ -3295,6 +3300,7 @@ CPLErr NUMPYDataset::GetGeoTransform( double * padfTransform )
 CPLErr NUMPYDataset::SetGeoTransform( double * padfTransform )
 
 {
+    bValidGeoTransform = TRUE;
     memcpy( adfGeoTransform, padfTransform, sizeof(double)*6 );
     return( CE_None );
 }
diff --git a/swig/python/extensions/gdal_wrap.cpp b/swig/python/extensions/gdal_wrap.cpp
index be8339f..6745815 100644
--- a/swig/python/extensions/gdal_wrap.cpp
+++ b/swig/python/extensions/gdal_wrap.cpp
@@ -2911,14 +2911,20 @@ int GetUseExceptions() {
 }
 
 void UseExceptions() {
-  bUseExceptions = 1;
-  pfnPreviousHandler = 
-    CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
+  if( !bUseExceptions )
+  {
+    bUseExceptions = 1;
+    pfnPreviousHandler = 
+        CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
+  }
 }
 
 void DontUseExceptions() {
-  bUseExceptions = 0;
-  CPLSetErrorHandler( pfnPreviousHandler );
+  if( bUseExceptions )
+  {
+    bUseExceptions = 0;
+    CPLSetErrorHandler( pfnPreviousHandler );
+  }
 }
 
 
diff --git a/swig/python/extensions/ogr_wrap.cpp b/swig/python/extensions/ogr_wrap.cpp
index c79f9b4..186b1cf 100644
--- a/swig/python/extensions/ogr_wrap.cpp
+++ b/swig/python/extensions/ogr_wrap.cpp
@@ -2965,14 +2965,20 @@ int GetUseExceptions() {
 }
 
 void UseExceptions() {
-  bUseExceptions = 1;
-  pfnPreviousHandler = 
-    CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
+  if( !bUseExceptions )
+  {
+    bUseExceptions = 1;
+    pfnPreviousHandler = 
+        CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
+  }
 }
 
 void DontUseExceptions() {
-  bUseExceptions = 0;
-  CPLSetErrorHandler( pfnPreviousHandler );
+  if( bUseExceptions )
+  {
+    bUseExceptions = 0;
+    CPLSetErrorHandler( pfnPreviousHandler );
+  }
 }
 
 
diff --git a/swig/python/extensions/osr_wrap.cpp b/swig/python/extensions/osr_wrap.cpp
index 5ecb8e7..4eece55 100644
--- a/swig/python/extensions/osr_wrap.cpp
+++ b/swig/python/extensions/osr_wrap.cpp
@@ -2928,14 +2928,20 @@ int GetUseExceptions() {
 }
 
 void UseExceptions() {
-  bUseExceptions = 1;
-  pfnPreviousHandler = 
-    CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
+  if( !bUseExceptions )
+  {
+    bUseExceptions = 1;
+    pfnPreviousHandler = 
+        CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
+  }
 }
 
 void DontUseExceptions() {
-  bUseExceptions = 0;
-  CPLSetErrorHandler( pfnPreviousHandler );
+  if( bUseExceptions )
+  {
+    bUseExceptions = 0;
+    CPLSetErrorHandler( pfnPreviousHandler );
+  }
 }
 
 
diff --git a/swig/python/osgeo/ogr.py b/swig/python/osgeo/ogr.py
index dba8c11..28e6f78 100644
--- a/swig/python/osgeo/ogr.py
+++ b/swig/python/osgeo/ogr.py
@@ -2025,12 +2025,12 @@ class Layer(_object):
         """Returns the number of features in the layer"""
         return self.GetFeatureCount()
 
-
-
+    # To avoid __len__ being called when testing boolean value
+    # which can have side effects (#4758)
     def __nonzero__(self):
         return True
 
-
+    # For Python 3 compat
     __bool__ = __nonzero__
 
     def __getitem__(self, value):
@@ -2041,9 +2041,9 @@ class Layer(_object):
             import sys
             output = []
             if value.stop == sys.maxint:
-                
-                
-                
+                #for an unending slice, sys.maxint is used
+                #We need to stop before that or GDAL will write an
+                ##error to stdout
                 stop = len(self) - 1
             else:
                 stop = value.stop
@@ -2944,8 +2944,8 @@ class Feature(_object):
     def __copy__(self):
         return self.Clone()
 
-
-
+    # This makes it possible to fetch fields in the form "feature.area". 
+    # This has some risk of name collisions.
     def __getattr__(self, key):
         """Returns the values of fields by the given name"""
         if key == 'this':
@@ -2961,8 +2961,8 @@ class Feature(_object):
         else:
             return self.GetField(idx)
 
-
-
+    # This makes it possible to set fields in the form "feature.area". 
+    # This has some risk of name collisions.
     def __setattr__(self, key, value):
         """Set the values of fields by the given name"""
         if key == 'this' or key == 'thisown':
@@ -2978,7 +2978,7 @@ class Feature(_object):
                 else:
                     self.__dict__[key] = value
 
-
+    # This makes it possible to fetch fields in the form "feature['area']". 
     def __getitem__(self, key):
         """Returns the values of fields by the given name / field_index"""
         if isinstance(key, str):
@@ -2993,7 +2993,7 @@ class Feature(_object):
         else:
             return self.GetField(fld_index)
 
-
+    # This makes it possible to set fields in the form "feature['area'] = 123". 
     def __setitem__(self, key, value):
         """Returns the value of a field by field name / index"""
         if isinstance(key, str):
@@ -3026,9 +3026,9 @@ class Feature(_object):
             return self.GetFieldAsIntegerList(fld_index)
         if fld_type == OFTRealList:
             return self.GetFieldAsDoubleList(fld_index)
-        
-        
-        
+        ## if fld_type == OFTDateTime or fld_type == OFTDate or fld_type == OFTTime:
+        #     return self.GetFieldAsDate(fld_index)
+        # default to returning as a string.  Should we add more types?
         return self.GetFieldAsString(fld_index)
 
     def SetField2(self, fld_index, value):
diff --git a/swig/python/setup.py b/swig/python/setup.py
index 1b5660c..bb97c7e 100644
--- a/swig/python/setup.py
+++ b/swig/python/setup.py
@@ -7,7 +7,7 @@
 # Howard Butler hobu.inc at gmail.com
 
 
-gdal_version = '1.11.1'
+gdal_version = '1.11.2'
 
 import sys
 import os

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/gdal.git



More information about the Pkg-grass-devel mailing list