Patchwork parsers: fix compiler errors on MSVC 2008

login
register
mail settings
Submitter Matt Harbison
Date March 20, 2014, 4:25 a.m.
Message ID <e286ab22e46157e0d159.1395289542@Envy>
Download mbox | patch
Permalink /patch/4002/
State Accepted
Commit e286ab22e46157e0d159982e85bf32d704c44420
Headers show

Comments

Matt Harbison - March 20, 2014, 4:25 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1395288119 14400
#      Thu Mar 20 00:01:59 2014 -0400
# Node ID e286ab22e46157e0d159982e85bf32d704c44420
# Parent  131f7fe06e9ef6684a38f21df13289da1b891714
parsers: fix compiler errors on MSVC 2008

This broke in 3681de20b0a7.
David Soria Parra - March 20, 2014, 5:26 p.m.
Matt Harbison <matt_harbison@yahoo.com> writes:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1395288119 14400
> #      Thu Mar 20 00:01:59 2014 -0400
> # Node ID e286ab22e46157e0d159982e85bf32d704c44420
> # Parent  131f7fe06e9ef6684a38f21df13289da1b891714
> parsers: fix compiler errors on MSVC 2008
>
> This broke in 3681de20b0a7.
>
> diff --git a/mercurial/parsers.c b/mercurial/parsers.c
> --- a/mercurial/parsers.c
> +++ b/mercurial/parsers.c
> @@ -1969,18 +1969,22 @@
>  
>  PyMODINIT_FUNC PyInit_parsers(void)
>  {
> +	PyObject *mod;
> +
>  	if (check_python_version() == -1)
>  		return;
> -	PyObject *mod = PyModule_Create(&parsers_module);
> +	mod = PyModule_Create(&parsers_module);
>  	module_init(mod);
>  	return mod;
>  }
>  #else
>  PyMODINIT_FUNC initparsers(void)
>  {
> +	PyObject *mod;
> +
>  	if (check_python_version() == -1)
>  		return;
> -	PyObject *mod = Py_InitModule3("parsers", methods, parsers_doc);
> +	mod = Py_InitModule3("parsers", methods, parsers_doc);
>  	module_init(mod);
>  }
>  #endif

Looks good to me. Generally speaking I would say we want to stick with
C89 whenever possible to ensure compatibility with ancient systems.
Matt Mackall - March 20, 2014, 7:28 p.m.
On Thu, 2014-03-20 at 00:25 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1395288119 14400
> #      Thu Mar 20 00:01:59 2014 -0400
> # Node ID e286ab22e46157e0d159982e85bf32d704c44420
> # Parent  131f7fe06e9ef6684a38f21df13289da1b891714
> parsers: fix compiler errors on MSVC 2008
> 
> This broke in 3681de20b0a7.

Queued for default, thanks.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1969,18 +1969,22 @@ 
 
 PyMODINIT_FUNC PyInit_parsers(void)
 {
+	PyObject *mod;
+
 	if (check_python_version() == -1)
 		return;
-	PyObject *mod = PyModule_Create(&parsers_module);
+	mod = PyModule_Create(&parsers_module);
 	module_init(mod);
 	return mod;
 }
 #else
 PyMODINIT_FUNC initparsers(void)
 {
+	PyObject *mod;
+
 	if (check_python_version() == -1)
 		return;
-	PyObject *mod = Py_InitModule3("parsers", methods, parsers_doc);
+	mod = Py_InitModule3("parsers", methods, parsers_doc);
 	module_init(mod);
 }
 #endif