changeset 868:3c3569894b23

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 09 Nov 2012 03:59:19 +0200
parents 051ef70d0123
children 3a9bf45178ff
files src/xs_support.c src/xs_support.h
diffstat 2 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_support.c	Fri Nov 09 03:59:02 2012 +0200
+++ b/src/xs_support.c	Fri Nov 09 03:59:19 2012 +0200
@@ -180,21 +180,17 @@
 /* Concatenate a given string up to given dest size or \n.
  * If size max is reached, change the end to "..."
  */
-void xs_pnstrcat(gchar *dest, size_t iSize, const gchar *str)
+void xs_pnstrcat(gchar *dest, const size_t size, const gchar *str)
 {
     size_t i, n;
     const gchar *s;
     gchar *d;
 
-    d = dest;
-    i = 0;
-    while (*d && (i < iSize)) {
-        i++;
-        d++;
-    }
+    for (d = dest, i = 0; *d && i < size; i++, d++);
 
     s = str;
-    while (*s && (*s != '\n') && (i < iSize)) {
+    while (*s && *s != '\n' && i < size)
+    {
         *d = *s;
         d++;
         s++;
@@ -203,16 +199,12 @@
 
     *d = 0;
 
-    if (i >= iSize) {
+    if (i >= size)
+    {
         i--;
         d--;
-        n = 3;
-        while ((i > 0) && (n > 0)) {
+        for (n = 3; i > 0 && n > 0; d--, i--, n--)
             *d = '.';
-            d--;
-            i--;
-            n--;
-        }
     }
 }
 
@@ -256,7 +248,8 @@
 static void xs_md5_bytereverse(guint8 *buf, guint l)
 {
     guint32 t;
-    do {
+    do
+    {
         t = (guint32) ((guint) buf[3] << 8 | buf[2]) << 16 | ((guint) buf[1] << 8 | buf[0]);
         *(guint32 *) buf = t;
         buf += sizeof(guint32);
@@ -290,8 +283,7 @@
 #define F2(x, y, z) F1(z, x, y)
 #define F3(x, y, z) (x ^ y ^ z)
 #define F4(x, y, z) (y ^ (x | ~z))
-#define MD5STEP(f, w, x, y, z, data, s) \
-    ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
+#define MD5STEP(f, w, x, y, z, data, s) ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
 
 static void xs_md5_transform(guint32 buf[4], guint32 const in[16])
 {
@@ -393,11 +385,13 @@
     t = (t >> 3) & 0x3f;    /* Bytes already in shsInfo->data */
 
     /* Handle any leading odd-sized chunks */
-    if (t) {
+    if (t)
+    {
         guint8 *p = (guint8 *) ctx->in + t;
 
         t = 64 - t;
-        if (len < t) {
+        if (len < t)
+        {
             memcpy(p, buf, len);
             return;
         }
@@ -409,7 +403,8 @@
     }
 
     /* Process data in 64-byte chunks */
-    while (len >= 64) {
+    while (len >= 64)
+    {
         memcpy(ctx->in, buf, 64);
         xs_md5_bytereverse(ctx->in, 16);
         xs_md5_transform(ctx->buf, (guint32 *) ctx->in);
@@ -421,6 +416,7 @@
     memcpy(ctx->in, buf, len);
 }
 
+
 /* Final wrapup - pad to 64-byte boundary with the bit pattern 
  * 1 0* (64-bit count of bits processed, MSB-first)
  */
@@ -441,7 +437,8 @@
     count = 64 - 1 - count;
 
     /* Pad out to 56 mod 64 */
-    if (count < 8) {
+    if (count < 8)
+    {
         /* Two lots of padding:  Pad the first block to 64 bytes */
         memset(p, 0, count);
         xs_md5_bytereverse(ctx->in, 16);
@@ -449,7 +446,9 @@
 
         /* Now fill the next block with 56 bytes */
         memset(ctx->in, 0, 56);
-    } else {
+    }
+    else
+    {
         /* Pad block to 56 bytes */
         memset(p, 0, count - 8);
     }
--- a/src/xs_support.h	Fri Nov 09 03:59:02 2012 +0200
+++ b/src/xs_support.h	Fri Nov 09 03:59:19 2012 +0200
@@ -114,6 +114,7 @@
 #define xs_ftell(a) ftell(a)
 #define xs_fseek(a,b,c) fseek(a,b,c)
 #endif
+
 guint16 xs_fread_be16(XSFile *);
 guint32 xs_fread_be32(XSFile *);
 gboolean xs_fload_buffer(const gchar *filename,