Skip to content

Commit

Permalink
g.proj: fix reading input WKT (OSGeo#1582)
Browse files Browse the repository at this point in the history
properly terminate input WKT string

Co-authored-by: Marc Jansen <[email protected]>
  • Loading branch information
a0x8o and marcjansen committed Sep 5, 2024
1 parent fdc992f commit 2907ec2
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
44 changes: 44 additions & 0 deletions general/g.proj/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,16 @@ int input_wkt(char *wktfile)
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 4a47cb15ef (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 8dce6e5f7e (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> 29af9b668b (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> main
=======
<<<<<<< HEAD
Expand Down Expand Up @@ -301,8 +304,18 @@ int input_wkt(char *wktfile)
=======
=======
>>>>>>> b5acd78515 (wxpyimgview: explicit conversion to int (#2704))
<<<<<<< HEAD
>>>>>>> adc008a3ff (wxpyimgview: explicit conversion to int (#2704))
<<<<<<< HEAD
>>>>>>> 29af9b668b (wxpyimgview: explicit conversion to int (#2704))
=======
=======
=======
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
>>>>>>> fe152a67bd (g.proj: fix reading input WKT (#1582))
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
size_t wktlen;

wktlen = fread(buff, 1, sizeof(buff), infd);
Expand Down Expand Up @@ -465,11 +478,23 @@ int input_wkt(char *wktfile)
=======
=======
=======
<<<<<<< HEAD
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
<<<<<<< HEAD
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))
<<<<<<< HEAD
>>>>>>> 01fcce31dc (g.proj: fix reading input WKT (#1582))
<<<<<<< HEAD
>>>>>>> 4a47cb15ef (g.proj: fix reading input WKT (#1582))
=======
=======
=======
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
>>>>>>> fe152a67bd (g.proj: fix reading input WKT (#1582))
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
size_t wktlen;

wktlen = fread(buff, 1, sizeof(buff), infd);
Expand Down Expand Up @@ -499,6 +524,9 @@ int input_wkt(char *wktfile)
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 250c6900d1 (g.proj: fix reading input WKT (#1582))
=======
Expand All @@ -522,9 +550,17 @@ int input_wkt(char *wktfile)
=======
>>>>>>> osgeo-main
=======
<<<<<<< HEAD
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
=======
<<<<<<< HEAD
>>>>>>> osgeo-main
=======
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
>>>>>>> fe152a67bd (g.proj: fix reading input WKT (#1582))
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
>>>>>>> b3579a4902 (g.proj: fix reading input WKT (#1582))
=======
size_t wktlen;
Expand Down Expand Up @@ -833,8 +869,16 @@ int input_wkt(char *wktfile)
=======
>>>>>>> 8422103f4c (wxpyimgview: explicit conversion to int (#2704))
>>>>>>> b5acd78515 (wxpyimgview: explicit conversion to int (#2704))
<<<<<<< HEAD
>>>>>>> adc008a3ff (wxpyimgview: explicit conversion to int (#2704))
<<<<<<< HEAD
>>>>>>> 29af9b668b (wxpyimgview: explicit conversion to int (#2704))
=======
=======
=======
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
>>>>>>> fe152a67bd (g.proj: fix reading input WKT (#1582))
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
}
else
G_fatal_error(_("Unable to open file '%s' for reading"), wktfile);
Expand Down
25 changes: 25 additions & 0 deletions python/grass/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ignore =
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 22bd3e549d (g.proj: fix reading input WKT (#1582))
=======
Expand All @@ -55,6 +56,8 @@ ignore =
=======
>>>>>>> 0bb8874099 (pythonlib: Remove star imports (#1546))
=======
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> main
=======
<<<<<<< HEAD
Expand Down Expand Up @@ -150,6 +153,10 @@ ignore =
>>>>>>> 01fcce31dc (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546))
=======
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
=======
E722, # do not use bare 'except'
>>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546))
Expand Down Expand Up @@ -178,13 +185,18 @@ ignore =
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 0bb8874099 (pythonlib: Remove star imports (#1546))
=======
=======
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 95f198e1e0 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> main
Expand Down Expand Up @@ -265,6 +277,9 @@ ignore =
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
<<<<<<< HEAD
Expand Down Expand Up @@ -438,8 +453,18 @@ ignore =
=======
=======
>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546))
<<<<<<< HEAD
>>>>>>> 92ab37e7e5 (pythonlib: Remove star imports (#1546))
<<<<<<< HEAD
>>>>>>> 0bb8874099 (pythonlib: Remove star imports (#1546))
=======
=======
=======
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
>>>>>>> fe152a67bd (g.proj: fix reading input WKT (#1582))
>>>>>>> d75bff88a3 (g.proj: fix reading input WKT (#1582))

per-file-ignores =
# C wrappers call libgis.G_gisinit before importing other modules.
Expand Down
23 changes: 23 additions & 0 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,29 @@ def replace_shebang_win(python_file):
os.rename(tmp_name, python_file) # rename temp to original name


def replace_shebang_win(python_file):
"""
Replaces "python" with "python3" in python files
using UTF8 encoding on MS Windows
"""

cur_dir = os.path.dirname(python_file)
tmp_name = os.path.join(cur_dir, gscript.tempname(12))

with codecs.open(python_file, "r", encoding="utf8") as in_file, codecs.open(
tmp_name, "w", encoding="utf8"
) as out_file:

for line in in_file:
new_line = line.replace(
"#!/usr/bin/env python\n", "#!/usr/bin/env python3\n"
)
out_file.write(new_line)

os.remove(python_file) # remove original
os.rename(tmp_name, python_file) # rename temp to original name


def urlretrieve(url, filename, *args, **kwargs):
"""Same function as 'urlretrieve', but with the ability to
define headers.
Expand Down

0 comments on commit 2907ec2

Please sign in to comment.