removing NeedFunctionPrototypes and NeedNestedPrototypes patch (1/3)

Warren Turkal wt@midsouth.rr.com
Sun, 15 Feb 2004 17:33:41 -0600


Ely Levy wrote:

> this one does the dix dir and few other files

This patch does too much. Stick to one job, either ansify or reformat. Don't
do both. For instance, the first file in the patch is all reformatting. I
also don't like having var names in the prototypes. I have left comments in
my work because they were already there. Here is an example from
dix/devices.c. First, an example where you did it right:

@@ -200,12 +200,7 @@
 }
 
 static void
-#if NeedFunctionPrototypes
 CloseDevice(register DeviceIntPtr dev)
-#else
-CloseDevice(dev)
-    register DeviceIntPtr dev;
-#endif
 {
     KbdFeedbackPtr k, knext;
     PtrFeedbackPtr p, pnext;

Now and overzealous example:

@@ -1715,17 +1705,8 @@
 #ifdef AddInputDevice
 #undef AddInputDevice
 
-#if NeedFunctionPrototypes
-DevicePtr
-AddInputDevice(
-    DeviceProc deviceProc,
-    Bool autoStart)
-#else
 DevicePtr
-AddInputDevice(deviceProc, autoStart)
-    DeviceProc deviceProc;
-    Bool autoStart;
-#endif
+AddInputDevice(DeviceProc deviceProc,Bool autoStart)
 {
     return (DevicePtr)_AddInputDevice(deviceProc, autoStart);
 }

What you did wrong in this patch is you reformatted the already written
line. It should have looked more like the following.

@@ -1715,17 +1705,8 @@
 #ifdef AddInputDevice
 #undef AddInputDevice
 
-#if NeedFunctionPrototypes
DevicePtr
AddInputDevice(
    DeviceProc deviceProc,
    Bool autoStart)
-#else
-DevicePtr
-AddInputDevice(deviceProc, autoStart)
-    DeviceProc deviceProc;
-    Bool autoStart;
-#endif
 {
     return (DevicePtr)_AddInputDevice(deviceProc, autoStart);
 }

On a side note, when we eventually reformat the source, I think it would be
useful to follow the format that a lot of new X code seems to use like the
following template.

Prototypes:
function_type function_name (arg1_type, arg2_type, so_on );

Function declarations:
function_type
function_name (arg1_type arg1_name, arg2_type arg2_name, so_on)
{
  function_body;
}

This keeps the function name in a declaration at the start of the line and
makes it much easier to grep for a function declaration instead of all uses
of the function and the declaration.

wt
-- 
Warren Turkal
President, GOLUM, Inc.
http://www.golum.org