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 <jansen@terrestris.de>
  • Loading branch information
a0x8o and marcjansen committed Sep 5, 2024
1 parent fc0cb3e commit 01fcce3
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,7 @@ RUN apk add curl && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && p
=======
>>>>>>> 75dcc66eed (Dockerfile_alpine: fix broken pip six installation (#1568))
<<<<<<< HEAD:docker/alpine/Dockerfile
<<<<<<< HEAD:docker/alpine/Dockerfile
RUN pip3 install --upgrade pip six grass-session --ignore-installed six
=======
RUN pip3 install --upgrade grass-session
Expand All @@ -2466,6 +2467,7 @@ RUN pip3 install --upgrade grass-session
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> osgeo-main
Expand Down Expand Up @@ -2754,6 +2756,11 @@ RUN pip3 install --upgrade pip six grass-session --ignore-installed six
>>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 75dcc66eed (Dockerfile_alpine: fix broken pip six installation (#1568))
=======
=======
RUN pip3 install --upgrade pip six grass-session --ignore-installed six
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582)):docker/alpine/Dockerfile_alpine
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))
RUN ln -s /usr/local/grass /usr/local/grass7
RUN ln -s /usr/local/grass `grass --config path`
Expand Down
8 changes: 8 additions & 0 deletions general/g.proj/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ int input_wkt(char *wktfile)
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> main
=======
Expand Down Expand Up @@ -229,6 +230,8 @@ int input_wkt(char *wktfile)
>>>>>>> osgeo-main
=======
>>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))
size_t wktlen;

wktlen = fread(buff, 1, sizeof(buff), infd);
Expand Down Expand Up @@ -257,6 +260,7 @@ int input_wkt(char *wktfile)
<<<<<<< HEAD
=======
<<<<<<< HEAD
<<<<<<< HEAD
>>>>>>> main
=======
<<<<<<< HEAD
Expand Down Expand Up @@ -348,6 +352,10 @@ int input_wkt(char *wktfile)
=======
=======
>>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582))
=======
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))
size_t wktlen;

wktlen = fread(buff, 1, sizeof(buff), infd);
Expand Down
6 changes: 6 additions & 0 deletions gui/wxpython/gui_core/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __init__(self, parent, giface, menuModel):
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
<<<<<<< HEAD
<<<<<<< HEAD
Expand Down Expand Up @@ -166,6 +167,11 @@ def __init__(self, parent, giface, menuModel):
=======
=======
>>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582))
=======
=======
=======
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))

def _readHistory(self):
"""Get list of commands from history file"""
Expand Down
6 changes: 6 additions & 0 deletions python/grass/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ignore =
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> main
=======
Expand Down Expand Up @@ -104,6 +105,8 @@ ignore =
=======
>>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582))
>>>>>>> osgeo-main
=======
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))
=======
E722, # do not use bare 'except'
>>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546))
Expand All @@ -125,6 +128,7 @@ ignore =
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 95f198e1e0 (g.proj: fix reading input WKT (#1582))
=======
Expand Down Expand Up @@ -291,6 +295,8 @@ ignore =
E722, # do not use bare 'except'
>>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546))
>>>>>>> 3ced907ea6 (pythonlib: Remove star imports (#1546))
=======
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))

per-file-ignores =
# C wrappers call libgis.G_gisinit before importing other modules.
Expand Down
32 changes: 32 additions & 0 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,29 @@ def replace_shebang_win(python_file):
>>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582))


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 Expand Up @@ -3766,6 +3789,7 @@ def install_extension_win(name):
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file):
=======
Expand Down Expand Up @@ -3805,6 +3829,8 @@ def install_extension_win(name):
>>>>>>> osgeo-main
=======
>>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582))
=======
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))
if re.search(module_name_pattern, file):
=======
if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file):
Expand All @@ -3821,6 +3847,7 @@ def install_extension_win(name):
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file):
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
Expand Down Expand Up @@ -3891,6 +3918,11 @@ def install_extension_win(name):
>>>>>>> osgeo-main
=======
>>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582))
=======
=======
if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file):
>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582))
>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582))
modulename = os.path.splitext(file)[0]
module_list.append(modulename)
# remove duplicates in case there are .exe wrappers for python scripts
Expand Down

0 comments on commit 01fcce3

Please sign in to comment.