changeset 1578:5bb4b580f229

Merge main and crew
author Mikael Berthe <mikael@lilotux.net>
date Mon, 13 Apr 2009 01:16:23 +0200
parents ece4f26bf9ff (diff) e1a642472f4e (current diff)
children a2dd83167bc9
files mcabber/src/jabglue.c
diffstat 10 files changed, 73 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sun Apr 12 20:20:56 2009 +0200
+++ b/.hgignore	Mon Apr 13 01:16:23 2009 +0200
@@ -23,6 +23,8 @@
 config.h*
 config.{log,cache,guess,status}
 
+mcabber/doc/guide/guide.{aux,bbl,blg,log,out,pdf,toc}
+
 *.sw?
 cscope.out
 tags
--- a/mcabber/configure.ac	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/configure.ac	Mon Apr 13 01:16:23 2009 +0200
@@ -56,7 +56,8 @@
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([alarm arc4random bzero gethostbyname gethostname inet_ntoa \
                 isascii memmove memset modf select setlocale socket strcasecmp \
-                strchr strdup strncasecmp strrchr strstr strcasestr vsnprintf])
+                strchr strdup strncasecmp strrchr strstr strcasestr vsnprintf \
+                iswblank])
 
 
 AC_CHECK_DECLS([strptime],,,
@@ -73,7 +74,7 @@
         [with_sigwinch=$with_ext_funcs])
 AC_MSG_RESULT($with_sigwinch)
 if test "$with_sigwinch" = yes; then
-    AC_DEFINE(USE_SIGWINCH, [], [Provide own SIGWINCH handler])
+    AC_DEFINE([USE_SIGWINCH], [], [Provide own SIGWINCH handler])
 fi
 
 # Checks for libraries.
@@ -123,13 +124,13 @@
                             [mc_cv_ncurses_escdelay=no])
                ])
 if test "$mc_cv_ncurses_escdelay" = yes; then
-    AC_DEFINE(HAVE_ESCDELAY, 1,
+    AC_DEFINE([HAVE_ESCDELAY], 1,
               [Define if ncurses has ESCDELAY variable])
 fi
 
 # Check for glib
 AM_PATH_GLIB_2_0(2.14.0,
-                 [AC_DEFINE(HAVE_GLIB_REGEX, 1,
+                 [AC_DEFINE([HAVE_GLIB_REGEX], 1,
                             [Define if GLib has regex support])],
                  [AM_PATH_GLIB_2_0(2.0.0, , AC_MSG_ERROR([glib is required]),
                                   [g_list_append])],
@@ -143,7 +144,7 @@
     ])
 
 if test x"${enable_gpgme}" != x"no"; then
-    AM_PATH_GPGME(1.0.0, AC_DEFINE(HAVE_GPGME, 1,
+    AM_PATH_GPGME(1.0.0, AC_DEFINE([HAVE_GPGME], 1,
         [Define if you use GPGME to support OpenPGP]))
 fi
 
@@ -206,7 +207,7 @@
     if test "x$have_aspell_includes" = "xyes"; then
         AC_CHECK_LIB(aspell, new_aspell_config, [ have_aspell_libs=yes ])
         if test "x$have_aspell_libs" = "xyes"; then
-            AC_DEFINE(WITH_ASPELL, 1, [define if you want aspell support])
+            AC_DEFINE([WITH_ASPELL], 1, [define if you want aspell support])
             LIBS="$LIBS -laspell"
         else
             enable_aspell=no
@@ -216,7 +217,7 @@
     fi
 fi
 
-AC_DEFINE(BUILD_JABBER, 1, [build with jabber support])
+AC_DEFINE([BUILD_JABBER], 1, [build with jabber support])
 
 # Export $datadir to the source tree.
 if test x"${datadir}" != x""; then
@@ -246,7 +247,7 @@
     hgcset=$enableval, hgcset="yes")
 AM_CONDITIONAL(HGCSET, [test x$hgcset = xyes])
 if test "${hgcset}" = "yes"; then
-    AC_DEFINE(ENABLE_HGCSET, 1, [Use Mercurial changeset])
+    AC_DEFINE([ENABLE_HGCSET], 1, [Use Mercurial changeset])
 fi
 
 AM_CONDITIONAL([OTR], [test x$libotr_found = xyes])
--- a/mcabber/src/commands.c	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/src/commands.c	Mon Apr 13 01:16:23 2009 +0200
@@ -633,6 +633,21 @@
   }
 }
 
+//  roster_updown(updown, nitems)
+// updown: -1=up, +1=down
+inline static void roster_updown(int updown, char *nitems)
+{
+  int nbitems;
+
+  if (!nitems || !*nitems)
+    nbitems = 1;
+  else
+    nbitems = strtol(nitems, NULL, 10);
+
+  if (nbitems > 0)
+    scr_RosterUpDown(updown, nbitems);
+}
+
 /* Commands callback functions */
 /* All these do_*() functions will be called with a "arg" parameter */
 /* (with arg not null)                                              */
@@ -701,9 +716,9 @@
     scr_RosterSearch(arg);
     update_roster = TRUE;
   } else if (!strcasecmp(subcmd, "up")) {
-    scr_RosterUp();
+    roster_updown(-1, arg);
   } else if (!strcasecmp(subcmd, "down")) {
-    scr_RosterDown();
+    roster_updown(1, arg);
   } else if (!strcasecmp(subcmd, "group_prev")) {
     scr_RosterPrevGroup();
   } else if (!strcasecmp(subcmd, "group_next")) {
@@ -1534,7 +1549,7 @@
   if (!nlines || !*nlines)
     nblines = 0;
   else
-    nblines = atoi(nlines);
+    nblines = strtol(nlines, NULL, 10);
 
   if (nblines >= 0)
     scr_BufferScrollUpDown(updown, nblines);
@@ -1934,7 +1949,7 @@
     foreach_group_member(bud, &move_group_member, name_utf8);
     // Let's jump to the previous buddy, because this group name should
     // disappear when we receive the server answer.
-    scr_RosterUp();
+    scr_RosterUpDown(-1, 1);
   } else {
     // Rename a single buddy
     guint del_name = 0;
@@ -1988,7 +2003,7 @@
     guint msgflag;
 
     jb_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL);
-    scr_RosterUp();
+    scr_RosterUpDown(-1, 1);
 
     // If the buddy has a pending message flag,
     // we remove it temporarily in order to reset the global group
--- a/mcabber/src/compl.c	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/src/compl.c	Mon Apr 13 01:16:23 2009 +0200
@@ -128,7 +128,7 @@
     char *wc;
     c->len_compl = 0;
     for (wc = r; *wc; wc = next_char(wc))
-      c->len_compl += get_char_width(wc);
+      c->len_compl++;
   }
   return r;
 }
--- a/mcabber/src/fifo.c	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/src/fifo.c	Mon Apr 13 01:16:23 2009 +0200
@@ -39,6 +39,7 @@
 static FILE *sfd;
 static char *fifo_name;
 
+static const char *FIFO_ENV_NAME = "MCABBER_FIFO";
 
 //  fifo_init(fifo_path)
 // Create and open the FIFO file.
@@ -93,6 +94,8 @@
   if (!fd)
     return -1;
 
+  setenv(FIFO_ENV_NAME, fifo_name, 1);
+
   sfd = fdopen(fd, "r");
   if (fifo_path)
     scr_LogPrint(LPRINT_LOGNORM, "FIFO initialized (%s)", fifo_name);
@@ -103,6 +106,7 @@
 // Close the current FIFO pipe and delete it.
 void fifo_deinit(void)
 {
+  unsetenv(FIFO_ENV_NAME);
   if (sfd) {
     fclose(sfd);
     sfd = NULL;
--- a/mcabber/src/jabglue.c	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/src/jabglue.c	Mon Apr 13 01:16:23 2009 +0200
@@ -264,11 +264,13 @@
       scr_DoUpdate();
     }
     // If we're not connected, sleep for a while...
-    select(maxfd + 1, &fds, NULL, NULL, &tv);
-    if (!online)
+    if (!online) {
+      select(1, &fds, NULL, NULL, &tv);
       check_connection();
-    else
+    } else {
+      select(maxfd + 1, &fds, NULL, NULL, &tv);
       jab_start(jc);
+    }
     return;
   }
 
--- a/mcabber/src/screen.c	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/src/screen.c	Mon Apr 13 01:16:23 2009 +0200
@@ -2253,20 +2253,20 @@
     scr_ShowBuddyWindow();
 }
 
-//  scr_RosterUp()
-// Go to the previous buddy in the buddylist
-void scr_RosterUp(void)
+//  scr_RosterUpDown(updown, n)
+// Go to the nth next buddy in the buddylist
+// (up if updown == -1, down if updown == 1)
+void scr_RosterUpDown(int updown, unsigned int n)
 {
-  set_current_buddy(g_list_previous(current_buddy));
-  if (chatmode)
-    scr_ShowBuddyWindow();
-}
-
-//  scr_RosterDown()
-// Go to the next buddy in the buddylist
-void scr_RosterDown(void)
-{
-  set_current_buddy(g_list_next(current_buddy));
+  unsigned int i;
+
+  if (updown < 0) {
+    for (i = 0; i < n; i++)
+      set_current_buddy(g_list_previous(current_buddy));
+  } else {
+    for (i = 0; i < n; i++)
+      set_current_buddy(g_list_next(current_buddy));
+  }
   if (chatmode)
     scr_ShowBuddyWindow();
 }
@@ -3583,6 +3583,7 @@
 {
   char *wprint_char_fmt = "%c";
   int point;
+  int nrchar = maxX;
   char *ptrCur = inputLine + inputline_offset;
 
 #ifdef UNICODE
@@ -3593,7 +3594,7 @@
 
   wmove(inputWnd, 0, 0); // problem with backspace
 
-  while (*ptrCur) {
+  while (*ptrCur && nrchar-- > 0) {
     point = ptrCur - inputLine;
     if (maskLine[point])
       wattrset(inputWnd, A_UNDERLINE);
--- a/mcabber/src/screen.h	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/src/screen.h	Mon Apr 13 01:16:23 2009 +0200
@@ -130,8 +130,7 @@
 // For commands...
 void scr_RosterTop(void);
 void scr_RosterBottom(void);
-void scr_RosterUp(void);
-void scr_RosterDown(void);
+void scr_RosterUpDown(int updown, unsigned int n);
 void scr_RosterPrevGroup(void);
 void scr_RosterNextGroup(void);
 void scr_RosterSearch(char *);
--- a/mcabber/src/utf8.h	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/src/utf8.h	Mon Apr 13 01:16:23 2009 +0200
@@ -17,6 +17,17 @@
 
 #ifdef HAVE_WCTYPE_H
 # include <wctype.h>
+
+/* The following bit is a hack for Solaris 8&9 systems that don't have
+ * iswblank().
+ * For now i made sure it comes after wctype.h so it doesn't create
+ * problems (wctype.h has calls to iswblank() before wctype() is declared).
+ * (Sebastian Kayser)
+ */
+# ifndef HAVE_ISWBLANK
+#  define iswblank(wc) iswctype(wc, wctype("blank"))
+# endif
+
 #else
 # define iswblank(c) (c == ' ')
 # define iswalnum(c) isalnum(c)
--- a/mcabber/src/utils.c	Sun Apr 12 20:20:56 2009 +0200
+++ b/mcabber/src/utils.c	Mon Apr 13 01:16:23 2009 +0200
@@ -495,7 +495,7 @@
 // string after use.
 char *ut_expand_tabs(const char *text)
 {
-  char *xtext;
+  char *xtext, *linestart;
   char *p, *q;
   guint n = 0, bc = 0;
 
@@ -512,12 +512,14 @@
 
   xtext = g_new(char, strlen(text) + 1 + 8*n);
   p = (char*)text;
-  q = xtext;
+  q = linestart = xtext;
   do {
     if (*p == '\t') {
-      do { *q++ = ' '; } while ((q-xtext)%8);
+      do { *q++ = ' '; } while ((q-linestart)%8);
     } else if (*p != '\x0d') {
       *q++ = *p;
+      if (*p =='\n')
+        linestart = q;
     }
   } while (*p++);