Index: /trunk/src/sh_database.c
===================================================================
--- /trunk/src/sh_database.c	(revision 12)
+++ /trunk/src/sh_database.c	(revision 13)
@@ -1438,5 +1438,5 @@
       attr_tab[i].attr = malloc (j+1); /* only once */
       if (NULL == attr_tab[i].attr)
-	SL_RETURN (NULL, _("sh_database_parse"));
+	return;
       for (k = 0; k < j; ++k)
 	attr_tab[i].attr[k] = attr_tab[i].attr_o[k] ^ XOR_CODE;
@@ -1503,9 +1503,5 @@
 	  escp = (escp == 1) ? 0 : 1;
 	}
-      else if (*p == '\'' && escp == 0)
-	{
-	  retv = S_FALSE;
-	}
-      else if (*p == '\"' && escp == 0)
+      else if ((*p == '\'' || *p == '\"') && escp == 0)
 	{
 	  retv = S_FALSE;
@@ -1573,8 +1569,8 @@
  parse:
 
-  while ((p != NULL) && (*p == ' ' || *p == '>'))
+  while (*p == ' ' || *p == '>')
     ++p;
 
-  if (!p || *p == '\0')
+  if (*p == '\0')
     SL_RETURN(NULL, _("sh_database_parse"));
 
@@ -1673,5 +1669,4 @@
 	    }
 	}
-      ++i;
     }
 
Index: /trunk/src/sh_utils.c
===================================================================
--- /trunk/src/sh_utils.c	(revision 12)
+++ /trunk/src/sh_utils.c	(revision 13)
@@ -245,5 +245,5 @@
 
 
-/* returned string must be free'd by caller
+/* returned string must be free'd by caller.
  */
 char * sh_util_formatted (const char * formatt, st_format * ftab)
@@ -260,10 +260,11 @@
   time_t inpp;
 
-  char * clist[16];
+  char * clist[16] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+		       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
   int    nn = 0;
 
   SL_ENTER(_("sh_util_formatted"));
 
-  if (formatt == NULL || ftab == NULL)
+  if (formatt == NULL || ftab == NULL || *formatt == '\0')
     SL_RETURN(NULL, _("sh_util_formatted"));
 
@@ -271,25 +272,17 @@
    */
   size = sl_strlen(formatt);
-  if (size > 0)
-    {
-      fmt = (char *) SH_ALLOC(size + 1);
-      (void) sl_strlcpy(fmt, formatt, size + 1);
-    }
-  else
-    SL_RETURN(NULL, _("sh_util_formatted"));
+
+  fmt = (char *) SH_ALLOC(size + 1);
+  (void) sl_strlcpy(fmt, formatt, size + 1);
 
   p = fmt;
 
   j = 0;
-  while (ftab[j].fchar != '\0')
-    {
-      if (ftab[j].type != S_FMT_STRING)
-	ftab[j].data_str = NULL;
-      ++j;
-    }
-
-  for (j = 0; j < 16; ++j)
-    clist[j] = NULL;
-
+  while (ftab[j].fchar != '\0') {
+    if (ftab[j].type != S_FMT_STRING)
+      ftab[j].data_str = NULL;
+    ++j;
+  }
+ 
   while (p != NULL && *p != '\0' && NULL != (q = strchr(p, '%')))
     {
@@ -324,5 +317,7 @@
 	      i  = 1;
 	      
-	      if (ftab[j].type == S_FMT_STRING)
+	      switch(ftab[j].type) {
+
+	      case S_FMT_STRING:
 		{
 		  isiz = sl_strlen(ftab[j].data_str);
@@ -335,7 +330,9 @@
 		  else
 		    *q = '%';
-		  break;
+		  goto endsrch;
 		}
-	      else if (ftab[j].type == S_FMT_ULONG)
+		break;
+
+	      case S_FMT_ULONG:
 		{
 		  ftab[j].data_str = (char *) SH_ALLOC(64);
@@ -353,7 +350,9 @@
 		  else
 		    *q = '%';
-		  break;
+		  goto endsrch;
 		}
-	      else if (ftab[j].type == S_FMT_LONG)
+		break;
+
+	      case S_FMT_LONG:
 		{
 		  ftab[j].data_str = (char *) SH_ALLOC(64);
@@ -371,7 +370,9 @@
 		  else
 		    *q = '%';
-		  break;
+		  goto endsrch;
 		}
-	      else if (ftab[j].type == S_FMT_TIME)
+		break;
+
+	      case S_FMT_TIME:
 		{
 		  ftab[j].data_str = (char *) SH_ALLOC(64);
@@ -401,11 +402,19 @@
 		  else
 		    *q = '%';
-		  break;
+		  goto endsrch;
 		}
+		break;
+
+	      default:
+		/* do nothing */;
+	      }
 
 	    }
-	  else
-	    ++j;
-	}
+	  ++j;
+	}
+
+    endsrch:
+
+      p = q;
 
       /* -- not found -- */
@@ -413,11 +422,7 @@
 	{
 	  *q = '%';
-	  p = q;
 	  ++p;
 	}
-      else
-	{
-	  p = q;
-	}
+
     }
 
@@ -443,10 +448,9 @@
    */
   j = 0;
-  while (ftab[j].fchar != '\0')
-    {
-      if (ftab[j].type != S_FMT_STRING && ftab[j].data_str != NULL)
-	SH_FREE(ftab[j].data_str);
-      ++j;
-    }
+  while (ftab[j].fchar != '\0') {
+    if (ftab[j].type != S_FMT_STRING && ftab[j].data_str != NULL)
+      SH_FREE(ftab[j].data_str);
+    ++j;
+  }
   SH_FREE(fmt);
 
@@ -474,4 +478,17 @@
 {
   int i = 0, j, k, l = 0;
+  char c;
+
+#define SH_HEXCHAR(x, y) \
+    c = (x); \
+    if ( c >= '0' && c <= '9' ) \
+      y = c - '0'; \
+    else if ( c >= 'a' && c <= 'f' ) \
+      y = c - 'a' + 10; \
+    else if ( c >= 'A' && c <= 'F' ) \
+      y = c - 'A' + 10; \
+    else \
+      SL_RETURN((-1), _("sh_util_hextobinary"))
+
 
   SL_ENTER(_("sh_util_hextobinary"));
@@ -479,5 +496,11 @@
   while (i < bytes)
     {
-      k = sh_util_hexchar(hex[i]); j = sh_util_hexchar(hex[i+1]); 
+      SH_HEXCHAR(hex[i],   k);
+      SH_HEXCHAR(hex[i+1], j);
+      
+      binary[l] = (char)(k * 16 + j);
+      ++l; i+= 2;
+
+      /* k = sh_util_hexchar(hex[i]); j = sh_util_hexchar(hex[i+1]); 
       if (k != -1 && j != -1) 
         {
@@ -489,4 +512,5 @@
 	  SL_RETURN((-1), _("sh_util_hextobinary"));
         }
+      */
     }
   
@@ -654,5 +678,4 @@
 }    
 
-  
  
 /* a simple compressor
@@ -785,5 +808,14 @@
   UINT32   retval;
   UINT32 * res;
+  static   UINT32   res_vec[6];
+  static   int      res_num = 0;
   register int i;
+
+  if (res_num > 0)
+    {
+      retval  = res_vec[res_num];
+      res_num = (res_num == 5) ? 0 : (res_num + 1);
+      return  retval;
+    }
 
   taus_svec[0] = taus_get_long (state1);
@@ -798,10 +830,10 @@
 				   (unsigned long)(6 * sizeof(UINT32)));
 
-  for (i = 1; i < KEY_BYT/4; ++i)
+  for (i = 1; i < 6; ++i)
     { 
-      res[0] ^= res[i];
-      res[i]  = 0;
-    }
-  retval = res[0];
+      res_vec[i] = res[i];
+    }
+  retval  = taus_svec[0];
+  res_num = 1;
 
   taus_svec[0] = 0; taus_svec[1] = 0; taus_svec[2] = 0; 
