Make array-printing code easier to follow
[platform/upstream/dbus.git] / tools / dbus-print-message.c
index ea15769..749fca6 100644 (file)
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 #include "dbus-print-message.h"
@@ -186,12 +186,17 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
 
            dbus_message_iter_recurse (iter, &subiter);
 
+           current_type = dbus_message_iter_get_arg_type (&subiter);
+
            printf("array [\n");
-           while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
+           while (current_type != DBUS_TYPE_INVALID)
              {
                print_iter (&subiter, literal, depth+1);
+
                dbus_message_iter_next (&subiter);
-               if (dbus_message_iter_get_arg_type (&subiter) != DBUS_TYPE_INVALID)
+               current_type = dbus_message_iter_get_arg_type (&subiter);
+
+               if (current_type != DBUS_TYPE_INVALID)
                  printf (",");
              }
            indent(depth);