diff lib/misc.c @ 460:075f89b4395c

2004-4-14 Brian Masney <masneyb@gftp.org> * lib/sshv2.c lib/gftp.h src/text/textui.c src/gtk/gtkui.c - when connecting with the SSH protocol, if the user is asked a question, relay that question back to the user and allow them to answer it. * doc/gftp-faq.sgml - moved the SSH troubleshooting section to the issues for older releases section. All of the issues that this talks about have been fixed in CVS. * src/gtk/gftp-gtk.c (main) - call gdk_threads_init() on startup * lib/cache.c lib/config_file.c lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c - removed some uses of strlen() so that they only occur once on a string instead of multiple times in some cases * lib/sslcommon.c - fixed typo * configure.in lib/gftp.h - added configure check for inttypes.h * docs/gftp.lsm - updated with 2.0.17 information
author masneyb
date Thu, 15 Apr 2004 00:59:23 +0000
parents 83cfffb2878a
children 4376ffeab64e
line wrap: on
line diff
--- a/lib/misc.c	Sat Apr 10 20:39:06 2004 +0000
+++ b/lib/misc.c	Thu Apr 15 00:59:23 2004 +0000
@@ -53,7 +53,8 @@
 insert_commas (off_t number, char *dest_str, size_t dest_len)
 {
   char *frompos, *topos, src[50], *dest;
-  int len, num, rem, i;
+  size_t num, rem, srclen;
+  int len, i;
 
 #if defined (_LARGEFILE_SOURCE)
   g_snprintf (src, sizeof (src), "%lld", (long long) number);
@@ -93,8 +94,10 @@
   else
     dest = dest_str;
 
-  num = strlen (src) / 3 - 1;
-  rem = strlen (src) % 3;
+  srclen = strlen (src);
+  num = srclen / 3 - 1;
+  rem = srclen % 3;
+
   frompos = src;
   topos = dest;
   for (i = 0; i < rem; i++)
@@ -1018,7 +1021,8 @@
 
   char *newstr, *newpos, *fillpos, *pos;
   unsigned char table[64], encode[3];
-  int i, num;
+  size_t slen, num;
+  int i;
 
   for (i = 0; i < 26; i++)
     {
@@ -1032,9 +1036,11 @@
   table[62] = '+';
   table[63] = '/';
 
-  num = strlen (str) / 3;
-  if (strlen (str) % 3 > 0)
+  slen = strlen (str);
+  num = slen / 3;
+  if (slen % 3 > 0)
     num++;
+
   newstr = g_malloc (num * 4 + 1);
   newstr[num * 4] = '\0';
   newpos = newstr;
@@ -1266,7 +1272,7 @@
   if (strcmp (password, "@EMAIL@") == 0)
     return (g_strdup (password));
 
-  newstr = g_malloc (strlen(password) * 2 + 2);
+  newstr = g_malloc (strlen (password) * 2 + 2);
   newpos = newstr;
   
   *newpos++ = '$';