Revision: 41063
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41063&view=rev
Author:   brlcad
Date:     2010-10-18 22:18:37 +0000 (Mon, 18 Oct 2010)

Log Message:
-----------
quellage and de-k&r cleanup

Modified Paths:
--------------
    brlcad/trunk/src/tab/script-tab.c
    brlcad/trunk/src/tab/tabsub.c

Modified: brlcad/trunk/src/tab/script-tab.c
===================================================================
--- brlcad/trunk/src/tab/script-tab.c   2010-10-18 21:58:13 UTC (rev 41062)
+++ brlcad/trunk/src/tab/script-tab.c   2010-10-18 22:18:37 UTC (rev 41063)
@@ -39,217 +39,222 @@
 #include "raytrace.h"
 
 
-point_t        eye_model;              /* model-space location of eye */
-mat_t  Viewrotscale;
-fastf_t        viewsize;
-int    curframe;               /* current frame number */
+point_t eye_model;             /* model-space location of eye */
+mat_t Viewrotscale;
+fastf_t viewsize;
+int curframe;          /* current frame number */
 
 /*
- *                     C M _ S T A R T
+ * C M _ S T A R T
  *
- *  Process "start" command in new format input stream
+ * Process "start" command in new format input stream
  */
 int
-cm_start( argc, argv )
-    int        argc;
-    char       **argv;
+cm_start(int argc, char **argv)
 {
+    if (argc < 2)
+       return -1;
+
     curframe = atoi(argv[1]);
     return 0;
 }
 
+
 int
-cm_vsize( argc, argv )
-    int        argc;
-    char       **argv;
+cm_vsize(int argc, char **argv)
 {
-    viewsize = atof( argv[1] );
+    if (argc < 2)
+       return -1;
+
+    viewsize = atof(argv[1]);
     return 0;
 }
 
+
 int
-cm_eyept( argc, argv )
-    int        argc;
-    char       **argv;
+cm_eyept(int argc, char **argv)
 {
     int i;
 
-    for ( i=0; i<3; i++ )
-       eye_model[i] = atof( argv[i+1] );
+    if (argc < 3)
+       return -1;
+
+    for (i=0; i<3; i++) {
+       eye_model[i] = atof(argv[i+1]);
+    }
     return 0;
 }
 
+
 int
-cm_lookat_pt( argc, argv )
-    int        argc;
-    char       **argv;
+cm_lookat_pt(int argc, char **argv)
 {
-    point_t    pt;
-    vect_t     dir;
-    int        yflip = 0;
+    point_t pt;
+    vect_t dir;
+    int yflip = 0;
 
-    if ( argc < 4 )
+    if (argc < 4)
        return -1;
+
     pt[X] = atof(argv[1]);
     pt[Y] = atof(argv[2]);
     pt[Z] = atof(argv[3]);
-    if ( argc > 4 )
+    if (argc > 4)
        yflip = atoi(argv[4]);
 
     /*
-     *  eye_pt must have been specified before here (for now)
+     * eye_pt must have been specified before here (for now)
      */
-    VSUB2( dir, pt, eye_model );
-    VUNITIZE( dir );
-    bn_mat_lookat( Viewrotscale, dir, yflip );
+    VSUB2(dir, pt, eye_model);
+    VUNITIZE(dir);
+    bn_mat_lookat(Viewrotscale, dir, yflip);
     return 0;
 }
 
+
 int
-cm_vrot( argc, argv )
-    int        argc;
-    char       **argv;
+cm_vrot(int argc, char **argv)
 {
     int i;
 
-    for ( i=0; i<16; i++ )
-       Viewrotscale[i] = atof( argv[i+1] );
+    if (argc < 17) {
+       return -1;
+    }
+
+    for (i=0; i<16; i++) {
+       Viewrotscale[i] = atof(argv[i+1]);
+    }
     return 0;
 }
 
+
 int
-cm_orientation( argc, argv )
-    int        argc;
-    char       **argv;
+cm_orientation(int argc, char **argv)
 {
-    int        i;
-    quat_t             quat;
+    int i;
+    quat_t quat;
 
-    for ( i=0; i<4; i++ )
-       quat[i] = atof( argv[i+1] );
-    quat_quat2mat( Viewrotscale, quat );
+    if (argc < 4)
+       return -1;
+
+    for (i=0; i<4; i++)
+       quat[i] = atof(argv[i+1]);
+    quat_quat2mat(Viewrotscale, quat);
     return 0;
 }
 
+
 /*
- *                     C M _ E N D
+ * C M _ E N D
  *
- *  The output occurs here.
+ * The output occurs here.
  *
- *  framenumber, viewsize, eye x y z, orientation x y z w
+ * framenumber, viewsize, eye x y z, orientation x y z w
  */
 int
-cm_end( argc, argv )
-    int        argc;
-    char       **argv;
+cm_end(int UNUSED(argc), char **UNUSED(argv))
 {
-    quat_t     orient;
+    quat_t orient;
 
     /* If no matrix or az/el specified yet, use params from cmd line */
-    if ( Viewrotscale[15] <= 0.0 )
+    if (Viewrotscale[15] <= 0.0)
        bu_exit(EXIT_FAILURE, "cm_end:  matrix not specified\n");
 
-    quat_mat2quat( orient, Viewrotscale );
+    quat_mat2quat(orient, Viewrotscale);
 
     /* Output information about this frame */
     printf("%d %.15e %.15e %.15e %.15e %.15e %.15e %.15e %.15e\n",
           curframe,
           viewsize,
           V3ARGS(eye_model),
-          V4ARGS(orient) );
+          V4ARGS(orient));
 
     return 0;
 }
 
+
 int
-cm_tree( argc, argv )
-    int                argc;
-    const char **argv;
+cm_tree(int UNUSED(argc), const char **UNUSED(argv))
 {
     /* No-op */
     return 0;
 }
 
+
 int
-cm_multiview( argc, argv )
-    int        argc;
-    char       **argv;
+cm_multiview(int UNUSED(argc), char **UNUSED(argv))
 {
     bu_exit(EXIT_FAILURE, "cm_multiview: not supported\n");
     return 0;  /* for the compilers */
 }
 
+
 /*
- *                     C M _ A N I M
+ * C M _ A N I M
  *
- *  Experimental animation code
+ * Experimental animation code
  *
- *  Usage:  anim <path> <type> args
+ * Usage:  anim <path> <type> args
  */
 int
-cm_anim( argc, argv )
-    int        argc;
-    char       **argv;
+cm_anim(int UNUSED(argc), char **UNUSED(argv))
 {
     /* No-op */
     return 0;
 }
 
+
 /*
- *                     C M _ C L E A N
+ * C M _ C L E A N
  *
- *  Clean out results of last rt_prep(), and start anew.
+ * Clean out results of last rt_prep(), and start anew.
  */
 int
-cm_clean( argc, argv )
-    int        argc;
-    char       **argv;
+cm_clean(int UNUSED(argc), char **UNUSED(argv))
 {
     /* No-op */
     return 0;
 }
 
+
 /*
- *                     C M _ S E T
+ * C M _ S E T
  *
- *  Allow variable values to be set or examined.
+ * Allow variable values to be set or examined.
  */
 int
-cm_set( argc, argv )
-    int        argc;
-    char       **argv;
+cm_set(int UNUSED(argc), char **UNUSED(argv))
 {
     /* No-op */
     return 0;
 }
 
+
 /*
- *                     C M _ A E
+ * C M _ A E
  */
 int
-cm_ae( argc, argv )
-    int        argc;
-    char       **argv;
+cm_ae(int UNUSED(argc), char **UNUSED(argv))
 {
     bu_exit(EXIT_FAILURE, "cm_ae: Unable to compute model min/max RPP\n");
     return 0;
 }
 
+
 /*
- *                     C M _ O P T
+ * C M _ O P T
  */
 int
-cm_opt( argc, argv )
-    int        argc;
-    char       **argv;
+cm_opt(int UNUSED(argc), char **UNUSED(argv))
 {
     /* No-op */
     return 0;
 }
 
+
 /*
- *  Command table for RT control script language
- *  Copied verbatim from ../rt/do.c
+ * Command table for RT control script language
+ * Copied verbatim from ../rt/do.c
  */
 
 struct command_tab rt_cmdtab[] = {
@@ -285,19 +290,18 @@
      0,                0, 0}   /* END */
 };
 
+
 /*
- *                     M A I N
+ * M A I N
  */
 int
-main( argc, argv )
-    int        argc;
-    char       **argv;
+main(int argc, char **argv)
 {
-    char       *buf;
-    int        ret;
+    char *buf;
+    int ret;
 
-    if ( argc != 1 || isatty(fileno(stdin)) )  {
-       fprintf(stderr, "Usage: script-tab < script > table\n");
+    if (argc != 1 || isatty(fileno(stdin))) {
+       fprintf(stderr, "Usage: %s < script > table\n", argv[0]);
        return 1;
     }
 
@@ -307,21 +311,22 @@
      * All the work happens in the functions
      * called by rt_do_cmd().
      */
-    while ( (buf = rt_read_cmd( stdin )) != (char *)0 )  {
-#if            0
-       fprintf(stderr, "cmd: %s\n", buf );
+    while ((buf = rt_read_cmd(stdin)) != (char *)0) {
+#if 0
+       fprintf(stderr, "cmd: %s\n", buf);
 #endif
-       ret = rt_do_cmd( NULL, buf, rt_cmdtab );
-       if ( ret < 0 )  {
+       ret = rt_do_cmd(NULL, buf, rt_cmdtab);
+       if (ret < 0) {
            bu_log("Command failure on '%s'\n", buf);
-           bu_free( buf, "cmd buf" );
+           bu_free(buf, "cmd buf");
            break;
        }
-       bu_free( buf, "cmd buf" );
+       bu_free(buf, "cmd buf");
     }
     return 0;
 }
 
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/tab/tabsub.c
===================================================================
--- brlcad/trunk/src/tab/tabsub.c       2010-10-18 21:58:13 UTC (rev 41062)
+++ brlcad/trunk/src/tab/tabsub.c       2010-10-18 22:18:37 UTC (rev 41063)
@@ -270,14 +270,14 @@
  *      0      OK
  */
 int
-multi_words( char *words[], int        nwords )
+multi_words( char *words[], int        word_count )
 {
 
     if ( strcmp( words[0], "rot" ) == 0 )  {
        mat_t   mat;
 
        /* Expects rotations rx, ry, rz, in degrees */
-       if ( nwords < 4 )  return -1;
+       if ( word_count < 4 )  return -1;
        MAT_IDN( mat );
        bn_mat_angles( mat,
                       atof( words[1] ),
@@ -289,7 +289,7 @@
     if ( strcmp( words[0], "xlate" ) == 0 )  {
        mat_t   mat;
 
-       if ( nwords < 4 )  return -1;
+       if ( word_count < 4 )  return -1;
        /* Expects translations tx, ty, tz */
        MAT_IDN( mat );
        MAT_DELTAS( mat,
@@ -310,7 +310,7 @@
        /* is done first, then the rotation, and finally  */
        /* back into the original position by (+x, +y, +z). */
 
-       if ( nwords < 7 )  return -1;
+       if ( word_count < 7 )  return -1;
 
        MAT_IDN( mat1 );
        MAT_IDN( mat2 );
@@ -345,11 +345,11 @@
        /* Expects tx, ty, tz, rx, ry, rz, [scale]. */
        /* All rotation is done first, then translation */
        /* Note: word[0] and args[0] are the keyword */
-       if ( nwords < 6+1 )  return -1;
+       if ( word_count < 6+1 )  return -1;
        for ( i=1; i<6+1; i++ )
            args[i] = 0;
        args[7] = 1.0;  /* optional arg, default to 1 */
-       for ( i=1; i<nwords; i++ )
+       for ( i=1; i<word_count; i++ )
            args[i] = atof( words[i] );
        MAT_IDN( mat );
        bn_mat_angles( mat, args[4], args[5], args[6] );
@@ -369,12 +369,12 @@
        mat_t   mat;
        fastf_t az, el;
 
-       if ( nwords < 3 )  return -1;
+       if ( word_count < 3 )  return -1;
        /* Expects azimuth, elev, optional twist */
        az = atof(words[1]);
        el = atof(words[2]);
 #if 0
-       if ( nwords == 3 )
+       if ( word_count == 3 )
            twist = 0.0;
        else
            twist = atof(words[3]);
@@ -391,7 +391,7 @@
        vect_t  dir;
        fastf_t ang;
 
-       if ( nwords < 1+3+3+1 )  return -1;
+       if ( word_count < 1+3+3+1 )  return -1;
        /* Expects point1, point2, angle */
        VSET( pt1, atof(words[1]), atof(words[2]), atof(words[3]) );
        VSET( pt2, atof(words[4]), atof(words[5]), atof(words[6]) );
@@ -409,7 +409,7 @@
        vect_t  dir;
        fastf_t ang;
 
-       if ( nwords < 1+3+3+1 )  return -1;
+       if ( word_count < 1+3+3+1 )  return -1;
        /* Expects point1, dir, angle */
        VSET( pt1, atof(words[1]), atof(words[2]), atof(words[3]) );
        VSET( dir, atof(words[4]), atof(words[5]), atof(words[6]) );
@@ -425,7 +425,7 @@
        quat_t  quat;
 
        /* Usage: quat x, y, z, w */
-       if ( nwords < 5 ) return -1;
+       if ( word_count < 5 ) return -1;
        QSET( quat, atof(words[1]), atof(words[2]),
              atof(words[3]), atof(words[4]) );
 
@@ -441,7 +441,7 @@
        vect_t  to;
 
        /* Usage: fromto +Z cur_xyz next_xyz */
-       if ( nwords < 8 )  return -1;
+       if ( word_count < 8 )  return -1;
        if ( strcmp( words[1], "+X" ) == 0 )  {
            VSET( from, 1, 0, 0 );
        } else if ( strcmp( words[1], "-X" ) == 0 )  {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to