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 c5d3b09 commit c1a5635
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions general/g.proj/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ int input_wkt(char *wktfile)
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
size_t wktlen;

wktlen = fread(buff, 1, sizeof(buff), infd);
Expand All @@ -133,8 +136,11 @@ int input_wkt(char *wktfile)
/* Get rid of newlines */
G_squeeze(buff);
=======
<<<<<<< HEAD
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
size_t wktlen;

wktlen = fread(buff, 1, sizeof(buff), infd);
Expand All @@ -148,6 +154,7 @@ int input_wkt(char *wktfile)
buff[wktlen] = '\0';
/* Get rid of newlines */
G_squeeze(buff);
<<<<<<< HEAD
>>>>>>> b3579a4902 (g.proj: fix reading input WKT (#1582))
=======
size_t wktlen;
Expand All @@ -171,6 +178,9 @@ int input_wkt(char *wktfile)
>>>>>>> 6cf60c76a4 (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> 8422103f4c (wxpyimgview: explicit conversion to int (#2704))
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
}
else
G_fatal_error(_("Unable to open file '%s' for reading"), wktfile);
Expand Down
6 changes: 6 additions & 0 deletions python/grass/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ ignore =
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
=======
E722, # do not use bare 'except'
>>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546))
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
<<<<<<< HEAD
=======
=======
E722, # do not use bare 'except'
>>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546))
>>>>>>> 57aff3a06a (pythonlib: Remove star imports (#1546))
=======
>>>>>>> 7e7871fd90 (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 @@ -583,6 +583,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 c1a5635

Please sign in to comment.