[nas] [patch] convert more K&R code to ANSI C

Stefan Huehner stefan at huehner.org
Sat Jul 15 15:28:38 MDT 2006


On Wed, Jul 12, 2006 at 11:31:55PM -0600, Jon Trulson wrote:
> On Thu, 13 Jul 2006, Erik Auerswald wrote:
> 
> >Hi,
> >
> >On Wed, Jul 12, 2006 at 10:43:33PM -0600, Jon Trulson wrote:
> >>On Wed, 12 Jul 2006, Stefan Huehner wrote:
> >>>attached patch converts some of the client programs to ANSI C.
> >>>
> >>
> >>        Try as I might, I was unable to convince 'patch' to deal with
> >>        this patch... I did not see anything obviously wrong.  I had
> >>        no problem with your earlier patches.  I noticed it was not
> >>        rooted in nas-*/, unlike your other patches (which I prefer).
> >>
> >>        What magic is required to apply this?  It didn't matter what
> >>        directory
> >>        this was run in (clients/audio, whatever)...
> >>
> >>Output was (patch --dry-run):
> >>$ patch --dry-run -p1 <StefanHuehner_nas_old_style2.diff
> >>
> >>can't find file to patch at input line 5
> >>Perhaps you should have used the -p or --strip option?
> >>The text leading up to this was:
> >>--------------------------
> >>|Index: auinfo/auinfo.c
> >
> >I'd say you have to apply it in the nas-1.8/clients/audio directory with
> >patch -p0 as there is no leading directory to strip. But I did not test
> >this.
> >
> 
>         -p0.. huh.  Never had to do that one before... The patch does
>          not apply cleanly though (this was a --dry-run so nothing
>          actually done):
> 

Hi Jon,

attached is an updated version of the patch. It is against your
svn-tree. Should be applyable without problem with 'patch -p0'.

I've dropped the parts which do not apply and will resent these parts
later.

Regards,
Stefan
-------------- next part --------------
Index: clients/audio/auinfo/auinfo.c
===================================================================
--- clients/audio/auinfo/auinfo.c	(revision 152)
+++ clients/audio/auinfo/auinfo.c	(working copy)
@@ -64,9 +64,7 @@
 static _AuConst char *INDENTPAD = INDENTPADSTR;
 
 int
-main (argc, argv)
-    int argc;
-    char **argv;
+main (int argc, char **argv)
 {
     int i;
     char *audioname = NULL;
@@ -268,9 +266,7 @@
 
 #if TEXT_ALIGNMENT == TA_INDIVIDUAL
 #define ROUNDUP(n) ((((n) + 7) >> 3) << 3)
-static int _table_maxlen (tab, nents)
-    register NameTable *tab;
-    register int nents;
+static int _table_maxlen (register NameTable *tab, register int nents)
 {
     register int m = 0;
 
@@ -288,11 +284,8 @@
 #define ALL_COLUMN_WIDTH 24
 #endif
 
-static NameTable *_lookup_name (tab, nents, val, isbit)
-    register NameTable *tab;
-    register int nents;
-    register int val;
-    register AuBool isbit;		/* use bit compare instead of equal? */
+static NameTable *_lookup_name (register NameTable *tab, register int nents, register int val, register AuBool isbit)
+/* isbit: use bit compare instead of equal? */
 {
     static NameTable nttmp;
     static char tmpbuf[20];
@@ -390,16 +383,12 @@
 
 
 /* ARGSUSED2 */
-static int _get_format (aud, i, p)
-    AuServer *aud;
-    int i;
-    AuPointer p;
+static int _get_format (AuServer *aud, int i, AuPointer p)
 {
     return AuServerFormat (aud, i);
 }
 
-static void print_formats (aud)
-    AuServer *aud;
+static void print_formats (AuServer *aud)
 {
     _print_names (aud, _nt_formats, NENTRIES(_nt_formats), 
 		  "Formats:", AuServerNumFormats(aud), _get_format, 
@@ -407,26 +396,18 @@
 }
 
 /* ARGSUSED */
-static int _get_use (aud, i, p)
-    AuServer *aud;
-    int i;
-    AuPointer p;
+static int _get_use (AuServer *aud, int i, AuPointer p)
 {
     return (1 << i) & AuCommonUse ((AuCommonPart *) p);
 }
 
 /* ARGSUSED */
-static int _get_access (aud, i, p)
-    AuServer *aud;
-    int i;
-    AuPointer p;
+static int _get_access (AuServer *aud, int i, AuPointer p)
 {
     return (1 << i) & AuCommonAccess ((AuCommonPart *) p);
 }
 
-static void print_comp (aud, c)
-    AuServer *aud;
-    register AuCommonPart *c;
+static void print_comp (AuServer *aud, register AuCommonPart *c)
 {
     register AuMask vmask = AuCommonValueMask (c);
 
@@ -461,27 +442,19 @@
 
 
 /* ARGSUSED */
-static int _get_devicechangables (aud, i, p)
-    AuServer *aud;
-    int i;
-    AuPointer p;
+static int _get_devicechangables (AuServer *aud, int i, AuPointer p)
 {
     return (1 << i) & AuDeviceChangableMask((AuDeviceAttributes *) p);
 }
 
 /* ARGSUSED */
-static int _get_locations (aud, i, p)
-    AuServer *aud;
-    int i;
-    AuPointer p;
+static int _get_locations (AuServer *aud, int i, AuPointer p)
 {
     return (1 << i) & AuDeviceLocation ((AuDeviceAttributes *) p);
 }
 
 
-static void print_device (aud, d)
-    AuServer *aud;
-    AuDeviceAttributes *d;
+static void print_device (AuServer *aud, AuDeviceAttributes *d)
 {
     AuMask vmask = AuDeviceValueMask (d);
 
@@ -525,8 +498,7 @@
     }
 }
 
-static void print_devices (aud)
-    AuServer *aud;
+static void print_devices (AuServer *aud)
 {
 
     int i;
@@ -538,9 +510,7 @@
 }
 
 static void
-print_bucket(aud, ba)
-    AuServer	*aud;
-    AuBucketAttributes	*ba;
+print_bucket(AuServer *aud, AuBucketAttributes *ba)
 {
     AuMask vmask = AuBucketValueMask (ba);
 
@@ -554,8 +524,7 @@
 }
 
 
-static void print_server_buckets (aud)
-    AuServer *aud;
+static void print_server_buckets (AuServer *aud)
 {
     int i;
 
@@ -566,8 +535,7 @@
 }
 
 
-static void print_client_buckets (aud)
-    AuServer *aud;
+static void print_client_buckets (AuServer *aud)
 {
     int	num, i;
     AuBucketAttributes	*bas;
@@ -593,16 +561,12 @@
 
 
 /* ARGSUSED2 */
-static int _get_elem_type (aud, i, p)
-    AuServer *aud;
-    int i;
-    AuPointer p;
+static int _get_elem_type (AuServer *aud, int i, AuPointer p)
 {
     return AuServerElementType (aud, i);
 }
 
-static void print_elem_types (aud)
-    AuServer *aud;
+static void print_elem_types (AuServer *aud)
 {
     _print_names (aud, _nt_elemtypes, NENTRIES(_nt_elemtypes),
 		  "Element Types:", AuServerNumElementTypes(aud),
@@ -611,16 +575,12 @@
 
 
 /* ARGSUSED2 */
-static int _get_wave_form (aud, i, p)
-    AuServer *aud;
-    int i;
-    AuPointer p;
+static int _get_wave_form (AuServer *aud, int i, AuPointer p)
 {
     return AuServerWaveForm (aud, i);
 }
 
-static void print_wave_forms (aud)
-    AuServer *aud;
+static void print_wave_forms (AuServer *aud)
 {
     _print_names (aud, _nt_waveforms, NENTRIES(_nt_waveforms), 
 		  "Wave Forms:", AuServerNumWaveForms(aud), _get_wave_form,
@@ -629,16 +589,12 @@
 
 
 /* ARGSUSED2 */
-static int _get_action (aud, i, p)
-    AuServer *aud;
-    int i;
-    AuPointer p;
+static int _get_action (AuServer *aud, int i, AuPointer p)
 {
     return AuServerAction (aud, i);
 }
 
-static void print_actions (aud)
-    AuServer *aud;
+static void print_actions (AuServer *aud)
 {
     _print_names (aud, _nt_actions, NENTRIES(_nt_actions), 
 		  "Actions:", AuServerNumActions(aud), _get_action, 
Index: clients/audio/aupanel/aupanel.c
===================================================================
--- clients/audio/aupanel/aupanel.c	(revision 152)
+++ clients/audio/aupanel/aupanel.c	(working copy)
@@ -159,17 +159,13 @@
 }
 
 static void
-quitCB(w, gp, call_data)
-Widget          w;
-XtPointer       gp;
-XtPointer       call_data;
+quitCB(Widget w, XtPointer gp, XtPointer call_data)
 {
     exit(0);
 }
 
 static void
-showDevice(g)
-GlobalDataPtr   g;
+showDevice(GlobalDataPtr g)
 {
     Boolean         inputModeEnable, outputModeEnable,
                     gainEnable;
@@ -244,10 +240,7 @@
 }
 
 static void
-queryCB(w, gp, call_data)
-Widget          w;
-XtPointer       gp;
-XtPointer       call_data;
+queryCB(Widget w, XtPointer gp, XtPointer call_data)
 {
     GlobalDataPtr   g = (GlobalDataPtr) gp;
 
@@ -257,10 +250,7 @@
 }
 
 static void
-inputModeCB(w, gp, call_data)
-Widget          w;
-XtPointer       gp;
-XtPointer       call_data;
+inputModeCB(Widget w, XtPointer gp, XtPointer call_data)
 {
     GlobalDataPtr   g = (GlobalDataPtr) gp;
     AuDeviceAttributes *da = &g->da[g->deviceNum];
@@ -279,10 +269,7 @@
 }
 
 static void
-outputModeCB(w, gp, call_data)
-Widget          w;
-XtPointer       gp;
-XtPointer       call_data;
+outputModeCB(Widget w, XtPointer gp, XtPointer call_data)
 {
     GlobalDataPtr   g = (GlobalDataPtr) gp;
     AuDeviceAttributes *da = &g->da[g->deviceNum];
@@ -306,10 +293,7 @@
 }
 
 static void
-menuCB(w, gp, call_data)
-Widget          w;
-XtPointer       gp;
-XtPointer       call_data;
+menuCB(Widget w, XtPointer gp, XtPointer call_data)
 {
     GlobalDataPtr   g = (GlobalDataPtr) gp;
     int             i;
@@ -328,10 +312,7 @@
 }
 
 static void
-setGain(w, gp, valuep)
-Widget          w;
-XtPointer       gp;
-XtPointer       valuep;
+setGain(Widget w, XtPointer gp, XtPointer valuep)
 {
     GlobalDataPtr   g = (GlobalDataPtr) gp;
     AuDeviceAttributes *da = &g->da[g->deviceNum];
@@ -349,10 +330,7 @@
 }
 
 static void
-muteCB(w, gp, call_data)
-Widget          w;
-XtPointer       gp;
-XtPointer       call_data;
+muteCB(Widget w, XtPointer gp, XtPointer call_data)
 {
     GlobalDataPtr g = (GlobalDataPtr) gp;
     AuDeviceAttributes *da;
@@ -373,8 +351,7 @@
 }
 
 static void
-createWidgets(g)
-GlobalDataPtr   g;
+createWidgets(GlobalDataPtr g)
 {
     int             i;
     Widget          w;
@@ -429,8 +406,7 @@
 }
 
 static void
-alignWidgets(g)
-GlobalDataPtr   g;
+alignWidgets(GlobalDataPtr g)
 {
     Dimension       w,
                     w1;
@@ -453,9 +429,7 @@
 }
 
 int
-main(argc, argv)
-int             argc;
-char          **argv;
+main(int argc, char **argv)
 {
     GlobalDataRec   globals;
     GlobalDataPtr   g = &globals;
Index: clients/audio/audial/audial.c
===================================================================
--- clients/audio/audial/audial.c	(revision 152)
+++ clients/audio/audial/audial.c	(working copy)
@@ -93,8 +93,7 @@
  * indicate a relative time. OBH-4/16/91
  */
 static void
-usleep(usecs)
-unsigned int    usecs;
+usleep(unsigned int usecs)
 {
     double          s1;
     AuUint32   quad[2];
@@ -115,8 +114,7 @@
 #include <poll.h>
 
 int
-usleep(usec)
-unsigned int    usec;
+usleep(unsigned int usec)
 {
     struct pollfd   f;
     return poll(&f, (unsigned long) 0, usec / 1000);
@@ -137,15 +135,13 @@
 #include <sys/time.h>
 
 static void
-stopme(sig)
-int sig;
+stopme(int sig)
 {
     signal(SIGALRM, SIG_DFL);
 }
 
 static void
-usleep(usecs)
-unsigned int    usecs;
+usleep(unsigned int usecs)
 {
     void            stopme();
     struct itimerval ntval,
@@ -215,11 +211,7 @@
 }
 
 static          AuFlowID
-createDTMFflow(aud, outputDevice, volume, duration)
-AuServer       *aud;
-AuDeviceID      outputDevice;
-int             volume,
-                duration;
+createDTMFflow(AuServer *aud, AuDeviceID outputDevice, int volume, int duration)
 {
     AuFlowID        flow;
     AuElement       elements[18];
@@ -263,12 +255,7 @@
 }
 
 static void
-dial(aud, flow, dialString, pause, spacing)
-AuServer       *aud;
-AuFlowID        flow;
-char           *dialString;
-int             pause,
-                spacing;
+dial(AuServer *aud, AuFlowID flow, char *dialString, int pause, int spacing)
 {
     AuEvent         event;
     AuElementState  states[3];
@@ -313,13 +300,7 @@
 }
 
 static void
-doDial(aud, dialString, volume, pause, spacing, duration)
-AuServer       *aud;
-char           *dialString;
-int             volume,
-                pause,
-                spacing,
-                duration;
+doDial(AuServer *aud, char *dialString, int volume, int pause, int spacing, int duration)
 {
     AuDeviceID      outputDevice = AuNone;
     AuFlowID        flow;
@@ -364,9 +345,7 @@
 #define THRESHHOLD 	3
 
 static void
-recognize(p, n)
-unsigned char  *p;
-int             n;
+recognize(unsigned char *p, int n)
 {
     static int      freqs[8] = {697, 770, 852, 941, 1209, 1336, 1477, 1633},
                     sums[8][NBINS],
@@ -482,11 +461,7 @@
 }
 
 static void
-doRecognize(aud, mic, gain, time)
-AuServer       *aud;
-AuBool          mic;
-int             gain,
-                time;
+doRecognize(AuServer *aud, AuBool mic, int gain, int time)
 {
     AuElementAction actions[1];
     AuEvent         event;
@@ -592,9 +567,7 @@
 }
 
 int
-main(argc, argv)
-int             argc;
-char          **argv;
+main(int argc, char **argv)
 {
     int             i,
                     time = 0,
Index: clients/audio/widgets/Slider.c
===================================================================
--- clients/audio/widgets/Slider.c	(revision 152)
+++ clients/audio/widgets/Slider.c	(working copy)
@@ -123,11 +123,7 @@
 WidgetClass     sliderWidgetClass = (WidgetClass) & sliderClassRec;
 
 static void
-setValue(w, value, setThumb, force)
-SliderWidget    w;
-int             value;
-Boolean         setThumb,
-                force;
+setValue(SliderWidget w, int value, Boolean setThumb, Boolean force)
 {
     if (value < w->slider.min)
 	value = w->slider.min;
@@ -155,10 +151,7 @@
 }
 
 static void
-scroll(w, swp, positionp)
-Widget          w;
-XtPointer       swp,
-                positionp;
+scroll(Widget w, XtPointer swp, XtPointer positionp)
 {
     SliderWidget    sw = (SliderWidget) swp;
     int             position = (int) positionp;
@@ -167,10 +160,7 @@
 }
 
 static void
-jump(w, swp, percentp)
-Widget          w;
-XtPointer       swp,
-                percentp;
+jump(Widget w, XtPointer swp, XtPointer percentp)
 {
     SliderWidget    sw = (SliderWidget) swp;
     float          *percent = (float *) percentp;
@@ -179,11 +169,7 @@
 }
 
 static void
-Initialize(request, new, args, num_args)
-Widget          request,
-                new;
-ArgList         args;
-Cardinal       *num_args;
+Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args)
 {
     SliderWidget    w = (SliderWidget) new;
 
@@ -224,12 +210,7 @@
 }
 
 static Boolean
-SetValues(current, request, new, in_args, in_num_args)
-Widget          current,
-                request,
-                new;
-ArgList         in_args;
-Cardinal       *in_num_args;
+SetValues(Widget current, Widget request, Widget new, ArgList in_args, Cardinal *in_num_args)
 {
     SliderWidget    w = (SliderWidget) new,
                     old = (SliderWidget) current;
Index: clients/audio/auctl/auctl.c
===================================================================
--- clients/audio/auctl/auctl.c	(revision 152)
+++ clients/audio/auctl/auctl.c	(working copy)
@@ -40,9 +40,7 @@
 static int do_command_loop PROTO((AuServer *, AuBool));
 
 int
-main (argc, argv)
-    int argc;
-    char **argv;
+main (int argc, char **argv)
 {
     int i;
     char *audioname = NULL;
@@ -99,8 +97,7 @@
 }
 
 
-static char *skip_space (s)
-    register char *s;
+static char *skip_space (register char *s)
 {
     if (!s) return NULL;
 
@@ -110,8 +107,7 @@
 }
 
 
-static char *skip_nonspace (s)
-    register char *s;
+static char *skip_nonspace (register char *s)
 {
     if (!s) return NULL;
 
@@ -122,9 +118,7 @@
 }
 
 
-static char **split_into_words (src, argcp)  /* argvify string */
-    char *src;
-    int *argcp;
+static char **split_into_words (char *src, int *argcp)  /* argvify string */
 {
     char *jword;
     char savec;
@@ -164,9 +158,7 @@
 }
 
 
-static int do_command_loop (aud, doprompt)
-    AuServer *aud;
-    AuBool doprompt;
+static int do_command_loop (AuServer *aud, AuBool doprompt)
 {
     char buf[256];
     int len;
Index: clients/audio/util/issndfile.c
===================================================================
--- clients/audio/util/issndfile.c	(revision 152)
+++ clients/audio/util/issndfile.c	(working copy)
@@ -28,9 +28,7 @@
 #include <audio/soundlib.h>
 
 int
-main(argc, argv)
-int             argc;
-char          **argv;
+main(int argc, char **argv)
 {
     return (argc == 2 && SoundOpenFileForReading(argv[1]) ? 0 : 1);
 }
Index: clients/audio/util/playbucket.c
===================================================================
--- clients/audio/util/playbucket.c	(revision 152)
+++ clients/audio/util/playbucket.c	(working copy)
@@ -41,11 +41,7 @@
 }
 
 static void
-doneCB(aud, handler, ev, data)
-AuServer       *aud;
-AuEvent        *ev;
-AuEventHandlerRec *handler;
-AuPointer       data;
+doneCB(AuServer *aud, AuEventHandlerRec *handler, AuEvent *ev, AuPointer data)
 {
     AuBool         *done = (AuBool *) data;
 
@@ -53,9 +49,7 @@
 }
 
 int
-main(argc, argv)
-int             argc;
-char          **argv;
+main(int argc, char **argv)
 {
     Sound           s;
     char           *audioServer = NULL,
Index: clients/audio/util/soundtoh.c
===================================================================
--- clients/audio/util/soundtoh.c	(revision 152)
+++ clients/audio/util/soundtoh.c	(working copy)
@@ -54,8 +54,7 @@
 }
 
 static char    *
-convertQuotes(str)
-char           *str;
+convertQuotes(char *str)
 {
     int             len = strlen(str) * 2 + 1;	/* more then enough for
 						 * string */
@@ -78,9 +77,7 @@
 }
 
 int
-main(argc, argv)
-int             argc;
-char          **argv;
+main(int argc, char **argv)
 {
     Sound           s;
     char           *p,


More information about the Nas mailing list