File PrintableString.diff of Package openmotif22-libs

--- lib/Xm/TextF.c
+++ lib/Xm/TextF.c
@@ -3723,15 +3723,15 @@
       cache_ptr = tmp = XmStackAlloc(buf_size, cache);
    
       tmp_str = (wchar_t *)str;
-      ret_val = wctomb(tmp, *tmp_str);
+      ret_val = 0;
       count = 0;
-      while ( (ret_val > 0)&& (buf_size >= MB_CUR_MAX) && (count < n) )
+      while (count < n && buf_size >= MB_CUR_MAX &&
+	     (ret_val = wctomb(tmp, *tmp_str)) > 0)
 	{
 	  count += 1;
 	  tmp += ret_val;
 	  buf_size -= ret_val;
 	  tmp_str++;
-	  ret_val = wctomb(tmp, *tmp_str);
 	}
          
       if (ret_val == -1)    /* bad character */