Hello community,

here is the log from the commit of package weechat.1106 for 
openSUSE:12.1:Update checked in at 2012-11-28 12:04:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:12.1:Update/weechat.1106 (Old)
 and      /work/SRC/openSUSE:12.1:Update/.weechat.1106.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "weechat.1106", Maintainer is ""

Changes:
--------
New Changes file:

--- /dev/null   2012-11-26 11:02:30.307549147 +0100
+++ /work/SRC/openSUSE:12.1:Update/.weechat.1106.new/weechat.changes    
2012-11-28 12:04:56.000000000 +0100
@@ -0,0 +1,199 @@
+-------------------------------------------------------------------
+Mon Nov 19 10:10:30 UTC 2012 - g...@opensuse.org
+
+- added weechat-fix-hook_process-shell-injection.patch which fixes
+  a shell injection vulnerability in the hook_process function
+  (bnc#790217, CVE-2012-5534)
+
+-------------------------------------------------------------------
+Sat Nov 10 15:17:33 UTC 2012 - g...@opensuse.org
+
+- added weechat-fix-buffer-overflow-in-irc-color-decoding.patch
+  which fixes a heap-based overflow when decoding IRC colors in
+  strings (bnc#789146)
+
+-------------------------------------------------------------------
+Sun Oct 23 08:07:47 UTC 2011 - g...@opensuse.org
+
+- removed weechat-remove_build_timestamp.patch and use previous
+  code again to deal with timestamps
+
+-------------------------------------------------------------------
+Sat Oct 22 22:33:19 UTC 2011 - pascal.ble...@opensuse.org
+
+- update to 0.3.6:
+  * mouse support
+  * cursor mode (free movement of cursor on screen)
+  * contexts for keys (default, search, cursor, mouse)
+  * hdata in API (direct access to WeeChat data)
+  * "inactive" colors for inactive windows and lines in merged
+     buffers
+  * support of merged buffers in /layout, save layout of
+    buffers/windows on /upgrade
+  * horizontal scrolling in buffers with free content
+  * split of outgoing IRC messages
+  * options for "more" chars in bars
+  * bold not used any more for basic colors (if terminal has more
+    than 16 colors)
+  * automatic zoom on current window when terminal becomes too
+    small for windows
+  * new command /repeat
+  * local variable "highlight_regex" in buffers
+- added weechat-remove_build_timestamp.patch
+
+-------------------------------------------------------------------
+Mon May 16 08:24:44 UTC 2011 - g...@opensuse.org
+
+- update to version 0.3.5:
+  * 256 colors support improved (dynamic allocation of colors)
+  * attributes for colors (bold/reverse/underline)
+  * better scroll of input (with long text)
+  * output of /help improved for list of commands and their
+    arguments
+  * remember scroll position of buffers in windows
+  * list of buffers in filters
+  * count of messages in hotlist buffers
+  * swap buffers of windows
+  * balance of windows
+  * new API function to set help on plugin/script options
+  * speller options in aspell plugin
+  * option for SSL priorities in IRC servers
+  * color nicks in nicklist and output of /names
+- dropped weechat-0.3.4-fix-array-overflow.patch which has been
+  included upstream
+
+-------------------------------------------------------------------
+Wed Mar 23 23:38:19 UTC 2011 - g...@opensuse.org
+
+- dropped weechat-0.3.4-remove-date-time.patch, use date/time from
+  last changelog entry rather than removing it completely
+- use %desktop_database_post/un
+
+-------------------------------------------------------------------
+Mon Mar 21 16:49:05 UTC 2011 - co...@novell.com
+
+- licenses package is about to die
+
+-------------------------------------------------------------------
+Wed Feb 17 08:02:54 UTC 2011 - g...@opensuse.org
+
+- added weechat-0.3.4-fix-array-overflow.patch which fixes an
+  array overflow
+
+-------------------------------------------------------------------
+Sun Jan 16 15:08:54 UTC 2011 - pascal.ble...@opensuse.org
+
+- update to 0.3.4:
+  * adds 256-color support
+  * adds IRC proxy support
+  * adds redirection of IRC commands
+  * adds new /notify command
+  * adds the rmodifier plugin
+  * adds regular expression support for highlights
+  * adds sharing of the input line between buffers
+  * many bugfixes
+
+-------------------------------------------------------------------
+Mon Nov  8 11:48:18 UTC 2010 - g...@opensuse.org
+
+- cleanup
+  * added specfile header
+  * added more accurate summary and description
+  * removed support for obsolete openSUSE versions
+  * split off -lang subpackage
+  * added patch to remove __DATE__ and __TIME__ macros
+  * enabled make output
+  * build with $RPM_OPT_FLAGS
+
+-------------------------------------------------------------------
+Mon Oct 11 19:16:10 UTC 2010 - g...@opensuse.org
+
+- fixed build for Python > 2.6
+
+-------------------------------------------------------------------
+Sun Aug  8 07:02:19 UTC 2010 - pascal.ble...@opensuse.org
+
+- update to 0.3.3:
+  * new features:
+    + keys to undo/redo changes on the command line
+    + a better lag indicator
+    + the /wallchops IRC command
+    + display of messages in IRC private buffers when the nick is back on a 
server after a /quit
+    + reverse regex in a filter
+    + hash tables in the plugin API
+  * many bugfixes
+
+-------------------------------------------------------------------
+Sun Apr 18 20:18:36 UTC 2010 - pascal.ble...@opensuse.org
+
+- update to 0.3.2:
+  * add SASL authentication with IRC servers
+  * add new commands /mute and /map
+  * add custom completion for aliases
+  * add date format in log filenames
+  * autoloading of plugins was improved
+  * many bugs were fixed
+
+-------------------------------------------------------------------
+Sun Jan 31 19:13:22 UTC 2010 - pascal.ble...@opensuse.org
+
+- update to 0.3.1.1:
+  * fixes crashes with SSL connection and purge of old DCC chats
+
+-------------------------------------------------------------------
+Sat Jan 23 20:18:34 UTC 2010 - pascal.ble...@opensuse.org
+
+- update to 0.3.1:
+  * new features
+  * options were added to customize CTCP replies and the target
+    buffer for IRC messages
+  * SSL certificates are now checked
+  * CertFP was added for automatic identification on servers
+  * anti-flood measures were improved
+  * new expansions were added for alias arguments
+  * many bugs were fixed
+
+-------------------------------------------------------------------
+Mon Sep 14 00:00:00 CEST 2009 - pascal.ble...@opensuse.org
+
+- update to 0.3.0:
+  * externalization of IRC as a plugin
+  * new display engine (faster)
+  * NES plugins
+  * new plugin API
+  * buffers with free content
+  * dynamic filtering
+  * smart join/part/quit filter
+  * custom bars with custom items
+  * buffer merging
+  * group support in nicklist
+  * less CPU usage
+
+-------------------------------------------------------------------
+Sat Jun 13 00:00:00 CEST 2009 - pascal.ble...@opensuse.org
+
+- update to 0.2.6.3:
+  * fixes a bug with detection of the gnutls library
+
+-------------------------------------------------------------------
+Sun Apr 19 00:00:00 CEST 2009 - pascal.ble...@opensuse.org
+
+- update to 0.2.6.2:
+  * fixes a charset decoding problem
+
+-------------------------------------------------------------------
+Tue Mar 17 00:00:00 CET 2009 - pascal.ble...@opensuse.org
+
+- update to 0.2.6.1:
+  * fixes a crash with some special characters in IRC messages
+
+-------------------------------------------------------------------
+Thu Sep  6 00:00:00 CEST 2007 - g...@unixtech.be
+
+- update to 0.2.6
+
+-------------------------------------------------------------------
+Sat Jun  9 00:00:00 CEST 2007 - g...@unixtech.be
+
++++ 2 more lines (skipped)
++++ between /dev/null
++++ and /work/SRC/openSUSE:12.1:Update/.weechat.1106.new/weechat.changes

New:
----
  weechat-0.3.3-fix-strftime.patch
  weechat-0.3.6.tar.bz2
  weechat-fix-buffer-overflow-in-irc-color-decoding.patch
  weechat-fix-hook_process-shell-injection.patch
  weechat.changes
  weechat.desktop
  weechat.spec

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ weechat.spec ++++++
#
# spec file for package weechat
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           weechat
Version:        0.3.6
Release:        0
Summary:        Portable, Fast, Light and Extensible Chat Client
License:        GNU General Public License (GPL)
Group:          Productivity/Networking/IRC
Source:         http://www.weechat.org/files/src/weechat-%{version}.tar.bz2
Source1:        weechat.desktop
Patch1:         weechat-0.3.3-fix-strftime.patch
# PATCH-FIX-UPSTREAM weechat-fix-buffer-overflow-in-irc-color-decoding.patch 
bnc#789146 g...@opensuse.org -- Fixes heap-based overflow when decoding IRC 
colors in strings
Patch2:         weechat-fix-buffer-overflow-in-irc-color-decoding.patch
# PATCH-FIX-UPSTREAM weechat-fix-hook_process-shell-injection.patch 
CVE-2012-5534 bnc#790217 g...@opensuse.org -- Fixes a shell injection 
vulnerability in the hook_process function
Patch3:         weechat-fix-hook_process-shell-injection.patch
Url:            http://www.weechat.org
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  aspell-devel
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  glibc-devel
BuildRequires:  gnutls
BuildRequires:  gnutls-devel
BuildRequires:  libgcrypt
BuildRequires:  libgcrypt-devel
BuildRequires:  libgpg-error
BuildRequires:  libgpg-error-devel
BuildRequires:  libstdc++-devel
BuildRequires:  libtool
BuildRequires:  lua-devel
BuildRequires:  lzo-devel
BuildRequires:  ncurses-devel
BuildRequires:  perl
BuildRequires:  pkgconfig
BuildRequires:  python-devel
BuildRequires:  ruby
BuildRequires:  ruby-devel
BuildRequires:  tcl-devel
%if 0%{?suse_version:1}
BuildRequires:  update-desktop-files
%endif

%description
WeeChat (Wee Enhanced Environment for Chat) is a fast and light cross-platform
chat environment. It can be entirely controlled with the keyboard, has a
plugin-based architecture and is customizable and extensible with scripts in
several scripting languages.

%lang_package

%package devel
Summary:        Development Environment for %{name} Plugins
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}-%{release}

%description devel
Development environment for authoring %{name} plugins.

%package lua
Summary:        Lua Scripting Support for %{name}
Group:          Productivity/Networking/IRC
Requires:       %{name} = %{version}-%{release}

%description lua
Support for %{name} scripts written in the Lua language.

%package perl
Summary:        Perl Scripting Support for %{name}
Group:          Productivity/Networking/IRC
Requires:       %{name} = %{version}-%{release}

%description perl
Support for %{name} scripts written in the Perl language.

%package python
Summary:        Python Scripting Support for %{name}
Group:          Productivity/Networking/IRC
Requires:       %{name} = %{version}-%{release}

%description python
Support for %{name} scripts written in the Python language.

%package tcl
Summary:        Tcl Scripting Support for %{name}
Group:          Productivity/Networking/IRC
Requires:       %{name} = %{version}-%{release}

%description tcl
Support for %{name} scripts written in the Tcl language.

%package ruby
Summary:        Ruby Scripting Support for %{name}
Group:          Productivity/Networking/IRC
Requires:       %{name} = %{version}-%{release}

%description ruby
Support for %{name} scripts written in the Ruby language.

%package aspell
Summary:        Aspell Spell-Checking Support for %{name}
Group:          Productivity/Networking/IRC
Requires:       %{name} = %{version}-%{release}

%description aspell
Spell-checking support for %{name}, using the aspell library.

%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
modified="$(sed -n '/^----/n;s/ - .*$//;p;q' "%{_sourcedir}/%{name}.changes")"
DATE="\"$(date -d "${modified}" "+%%b %%e %%Y")\""
TIME="\"$(date -d "${modified}" "+%%R")\""
find .  -name '*.[ch]' |\
    xargs sed -i "s/__DATE__/${DATE}/g;s/__TIME__/${TIME}/g"

%build
export CFLAGS="%{optflags}"
%__mkdir build
pushd build
cmake \
    -DCMAKE_INSTALL_PREFIX="%{_prefix}" \
    -DLIBDIR="%{_libdir}" \
    -DPYTHON_LIBRARY="%{_libdir}/libpython%{py_ver}.so" ..
%__make %{?_smp_flags} VERBOSE=1
popd #build

%install
pushd build
%makeinstall
popd #build

%__install -D -m 0644 "%{SOURCE1}" 
"%{buildroot}%{_datadir}/applications/%{name}.desktop"
%__install -D -m 0644 weechat_icon_32.png 
"%{buildroot}%{_datadir}/pixmaps/%{name}.png"
%if 0%{?suse_version}
%suse_update_desktop_file -r "%{name}" Network IRCClient
%endif

%find_lang "%{name}"

%clean
%{?buildroot:%__rm -rf "%{buildroot}"}

%if 0%{?suse_version} >= 1140

%post
%desktop_database_post

%postun
%desktop_database_postun
%endif

%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS README
%{_bindir}/weechat-curses
%dir %{_libdir}/weechat
%dir %{_libdir}/weechat/plugins
%{_libdir}/weechat/plugins/alias.so
%{_libdir}/weechat/plugins/charset.so
%{_libdir}/weechat/plugins/fifo.so
%{_libdir}/weechat/plugins/irc.so
%{_libdir}/weechat/plugins/logger.so
%{_libdir}/weechat/plugins/relay.so
%{_libdir}/weechat/plugins/rmodifier.so
%{_libdir}/weechat/plugins/xfer.so
%doc %{_mandir}/man1/weechat-curses.1*
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.png

%files -f "%{name}.lang" lang

%files devel
%defattr(-,root,root)
%{_includedir}/weechat
%{_libdir}/pkgconfig/weechat.pc

%files lua
%defattr(-,root,root)
%{_libdir}/weechat/plugins/lua.so

%files perl
%defattr(-,root,root)
%{_libdir}/weechat/plugins/perl.so

%files python
%defattr(-,root,root)
%{_libdir}/weechat/plugins/python.so

%files tcl
%defattr(-,root,root)
%{_libdir}/weechat/plugins/tcl.so

%files ruby
%defattr(-,root,root)
%{_libdir}/weechat/plugins/ruby.so

%files aspell
%defattr(-,root,root)
%{_libdir}/weechat/plugins/aspell.so

%changelog
++++++ weechat-0.3.3-fix-strftime.patch ++++++
diff -urN weechat-0.3.3.orig/src/plugins/scripts/ruby/weechat-ruby.c 
weechat-0.3.3/src/plugins/scripts/ruby/weechat-ruby.c
--- weechat-0.3.3.orig/src/plugins/scripts/ruby/weechat-ruby.c  2010-06-21 
12:33:42.000000000 +0200
+++ weechat-0.3.3/src/plugins/scripts/ruby/weechat-ruby.c       2010-11-08 
16:33:02.000000000 +0100
@@ -32,6 +32,7 @@
 #include <stdarg.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <time.h>
 
 #include "../../weechat-plugin.h"
 #include "../script.h"
++++++ weechat-fix-buffer-overflow-in-irc-color-decoding.patch ++++++
Index: weechat-0.3.6/src/plugins/irc/irc-color.c
===================================================================
--- weechat-0.3.6.orig/src/plugins/irc/irc-color.c
+++ weechat-0.3.6/src/plugins/irc/irc-color.c
@@ -62,12 +62,14 @@ char *irc_color_to_weechat[IRC_NUM_COLOR
 char *
 irc_color_decode (const char *string, int keep_colors)
 {
-    unsigned char *out, *ptr_string;
-    int out_length, length, out_pos;
-    char str_fg[3], str_bg[3], str_color[128];
+    unsigned char *out, *out2, *ptr_string;
+    int out_length, length, out_pos, length_to_add;
+    char str_fg[3], str_bg[3], str_color[128], str_to_add[128];
     int fg, bg, bold, reverse, italic, underline, rc;
     
     out_length = (strlen (string) * 2) + 1;
+    if (out_length < 128)
+        out_length = 128;
     out = malloc (out_length);
     if (!out)
         return NULL;
@@ -79,20 +81,27 @@ irc_color_decode (const char *string, in
     
     ptr_string = (unsigned char *)string;
     out[0] = '\0';
+    out_pos = 0;
     while (ptr_string && ptr_string[0])
     {
+        str_to_add[0] = '\0';
         switch (ptr_string[0])
         {
             case IRC_COLOR_BOLD_CHAR:
                 if (keep_colors)
-                    strcat ((char *)out,
-                            weechat_color((bold) ? "-bold" : "bold"));
+                {
+                    snprintf (str_to_add, sizeof (str_to_add), "%s",
+                              weechat_color ((bold) ? "-bold" : "bold"));
+                }
                 bold ^= 1;
                 ptr_string++;
                 break;
             case IRC_COLOR_RESET_CHAR:
                 if (keep_colors)
-                    strcat ((char *)out, weechat_color("reset"));
+                {
+                    snprintf (str_to_add, sizeof (str_to_add), "%s",
+                              weechat_color ("reset"));
+                }
                 bold = 0;
                 reverse = 0;
                 italic = 0;
@@ -105,22 +114,28 @@ irc_color_decode (const char *string, in
             case IRC_COLOR_REVERSE_CHAR:
             case IRC_COLOR_REVERSE2_CHAR:
                 if (keep_colors)
-                    strcat ((char *)out,
-                            weechat_color((reverse) ? "-reverse" : "reverse"));
+                {
+                    snprintf (str_to_add, sizeof (str_to_add), "%s",
+                              weechat_color ((reverse) ? "-reverse" : 
"reverse"));
+                }
                 reverse ^= 1;
                 ptr_string++;
                 break;
             case IRC_COLOR_ITALIC_CHAR:
                 if (keep_colors)
-                    strcat ((char *)out,
-                            weechat_color((italic) ? "-italic" : "italic"));
+                {
+                    snprintf (str_to_add, sizeof (str_to_add), "%s",
+                              weechat_color ((italic) ? "-italic" : "italic"));
+                }
                 italic ^= 1;
                 ptr_string++;
                 break;
             case IRC_COLOR_UNDERLINE_CHAR:
                 if (keep_colors)
-                    strcat ((char *)out,
-                            weechat_color((underline) ? "-underline" : 
"underline"));
+                {
+                    snprintf (str_to_add, sizeof (str_to_add), "%s",
+                              weechat_color ((underline) ? "-underline" : 
"underline"));
+                }
                 underline ^= 1;
                 ptr_string++;
                 break;
@@ -180,24 +195,41 @@ irc_color_decode (const char *string, in
                                   (fg >= 0) ? irc_color_to_weechat[fg] : "",
                                   (bg >= 0) ? "," : "",
                                   (bg >= 0) ? irc_color_to_weechat[bg] : "");
-                        strcat ((char *)out, weechat_color(str_color));
+                        snprintf (str_to_add, sizeof (str_to_add), "%s",
+                                  weechat_color (str_color));
                     }
                     else
-                        strcat ((char *)out, weechat_color("resetcolor"));
+                    {
+                        snprintf (str_to_add, sizeof (str_to_add), "%s",
+                                  weechat_color ("resetcolor"));
+                    }
                 }
                 break;
             default:
                 length = weechat_utf8_char_size ((char *)ptr_string);
                 if (length == 0)
                     length = 1;
-                out_pos = strlen ((char *)out);
-                memcpy (out + out_pos, ptr_string, length);
-                out[out_pos + length] = '\0';
+                memcpy (str_to_add, ptr_string, length);
+                str_to_add[length] = '\0';
                 ptr_string += length;
                 break;
         }
+        if (str_to_add[0])
+        {
+            length_to_add = strlen (str_to_add);
+            if (out_pos + length_to_add >= out_length)
+            {
+                out_length *= 2;
+                out2 = realloc (out, out_length);
+                if (!out2)
+                    return (char *)out;
+                out = out2;
+            }
+            memcpy (out + out_pos, str_to_add, length_to_add + 1);
+            out_pos += length_to_add;
+        }
     }
-    
+
     return (char *)out;
 }
 
++++++ weechat-fix-hook_process-shell-injection.patch ++++++
Index: weechat-0.3.6/src/core/wee-hook.c
===================================================================
--- weechat-0.3.6.orig/src/core/wee-hook.c
+++ weechat-0.3.6/src/core/wee-hook.c
@@ -1370,7 +1370,8 @@ hook_process (struct t_weechat_plugin *p
 void
 hook_process_child (struct t_hook *hook_process)
 {
-    char *exec_args[4] = { "sh", "-c", NULL, NULL };
+    char **exec_args;
+    int i;
     
     /*
      * close stdin, so that process will fail to read stdin (process reading
@@ -1393,10 +1394,25 @@ hook_process_child (struct t_hook *hook_
     }
     
     /* launch command */
-    exec_args[2] = HOOK_PROCESS(hook_process, command);
-    execvp (exec_args[0], exec_args);
+    exec_args = string_split_shell (HOOK_PROCESS(hook_process, command));
+    if (exec_args)
+    {
+        if (weechat_debug_core >= 1)
+        {
+            log_printf ("hook_process, command='%s'",
+                        HOOK_PROCESS(hook_process, command));
+            for (i = 0; exec_args[i]; i++)
+            {
+                log_printf ("  args[%02d] == '%s'", i, exec_args[i]);
+            }
+        }
+        execvp (exec_args[0], exec_args);
+    }
     
     /* should not be executed if execvp was ok */
+    if (exec_args)
+        string_free_split (exec_args);
+
     fprintf (stderr, "Error with command '%s'\n",
              HOOK_PROCESS(hook_process, command));
     _exit (EXIT_FAILURE);
Index: weechat-0.3.6/src/core/wee-string.c
===================================================================
--- weechat-0.3.6.orig/src/core/wee-string.c
+++ weechat-0.3.6/src/core/wee-string.c
@@ -971,6 +971,196 @@ string_split (const char *string, const
 }
 
 /*
+ * string_split_shell: split a string like the shell does for a command with
+ *                     arguments.
+ *                     Note: result must be freed with string_free_split.
+ *                     This function is a C conversion of python class "shlex"
+ *                     (file: Lib/shlex.py in python repository)
+ *                     Doc: http://docs.python.org/3/library/shlex.html
+ *                     Copyrights in shlex.py:
+ *                       Module and documentation by Eric S. Raymond, 21 Dec 
1998
+ *                       Input stacking and error message cleanup added by 
ESR, March 2000
+ *                       push_source() and pop_source() made explicit by ESR, 
January 2001.
+ *                       Posix compliance, split(), string arguments, and
+ *                       iterator interface by Gustavo Niemeyer, April 2003.
+ */
+
+char **
+string_split_shell (const char *string)
+{
+    int temp_len, num_args, add_char_to_temp, add_temp_to_args, quoted;
+    char *string2, *temp, **args, **args2, state, escapedstate;
+    char *ptr_string, *ptr_next, saved_char;
+
+    if (!string)
+        return NULL;
+
+    string2 = strdup (string);
+    if (!string2)
+        return NULL;
+
+    /*
+     * prepare "args" with one pointer to NULL, the "args" will be reallocated
+     * later, each time a new argument is added
+     */
+    num_args = 0;
+    args = malloc ((num_args + 1) * sizeof (args[0]));
+    if (!args)
+    {
+        free (string2);
+        return NULL;
+    }
+    args[0] = NULL;
+
+    /* prepare a temp string for working (adding chars one by one) */
+    temp = malloc ((2 * strlen (string)) + 1);
+    if (!temp)
+    {
+        free (string2);
+        free (args);
+        return NULL;
+    }
+    temp[0] = '\0';
+    temp_len = 0;
+
+    state = ' ';
+    escapedstate = ' ';
+    quoted = 0;
+    ptr_string = string2;
+    while (ptr_string[0])
+    {
+        add_char_to_temp = 0;
+        add_temp_to_args = 0;
+        ptr_next = utf8_next_char (ptr_string);
+        saved_char = ptr_next[0];
+        ptr_next[0] = '\0';
+        if (state == ' ')
+        {
+            if ((ptr_string[0] == ' ') || (ptr_string[0] == '\t')
+                || (ptr_string[0] == '\r') || (ptr_string[0] == '\n'))
+            {
+                if (temp[0] || quoted)
+                    add_temp_to_args = 1;
+            }
+            else if (ptr_string[0] == '\\')
+            {
+                escapedstate = 'a';
+                state = ptr_string[0];
+            }
+            else if ((ptr_string[0] == '\'') || (ptr_string[0] == '"'))
+            {
+                state = ptr_string[0];
+            }
+            else
+            {
+                add_char_to_temp = 1;
+                state = 'a';
+            }
+        }
+        else if ((state == '\'') || (state == '"'))
+        {
+            quoted = 1;
+            if (ptr_string[0] == state)
+            {
+                state = 'a';
+            }
+            else if ((state == '"') && (ptr_string[0] == '\\'))
+            {
+                escapedstate = state;
+                state = ptr_string[0];
+            }
+            else
+            {
+                add_char_to_temp = 1;
+            }
+        }
+        else if (state == '\\')
+        {
+            if (((escapedstate == '\'') || (escapedstate == '"'))
+                && (ptr_string[0] != state) && (ptr_string[0] != escapedstate))
+            {
+                temp[temp_len] = state;
+                temp_len++;
+                temp[temp_len] = '\0';
+            }
+            add_char_to_temp = 1;
+            state = escapedstate;
+        }
+        else if (state == 'a')
+        {
+            if ((ptr_string[0] == ' ') || (ptr_string[0] == '\t')
+                || (ptr_string[0] == '\r') || (ptr_string[0] == '\n'))
+            {
+                state = ' ';
+                if (temp[0] || quoted)
+                    add_temp_to_args = 1;
+            }
+            else if (ptr_string[0] == '\\')
+            {
+                escapedstate = 'a';
+                state = ptr_string[0];
+            }
+            else if ((ptr_string[0] == '\'') || (ptr_string[0] == '"'))
+            {
+                state = ptr_string[0];
+            }
+            else
+            {
+                add_char_to_temp = 1;
+            }
+        }
+        if (add_char_to_temp)
+        {
+            memcpy (temp + temp_len, ptr_string, ptr_next - ptr_string);
+            temp_len += (ptr_next - ptr_string);
+            temp[temp_len] = '\0';
+        }
+        if (add_temp_to_args)
+        {
+            num_args++;
+            args2 = realloc (args, (num_args + 1) * sizeof (args[0]));
+            if (!args2)
+            {
+                free (string2);
+                free (temp);
+                return args;
+            }
+            args = args2;
+            args[num_args - 1] = strdup (temp);
+            args[num_args] = NULL;
+            temp[0] = '\0';
+            temp_len = 0;
+            escapedstate = ' ';
+            quoted = 0;
+        }
+        ptr_next[0] = saved_char;
+        ptr_string = ptr_next;
+    }
+
+    if (temp[0] || (state != ' '))
+    {
+        num_args++;
+        args2 = realloc (args, (num_args + 1) * sizeof (args[0]));
+        if (!args2)
+        {
+            free (string2);
+            free (temp);
+            return args;
+        }
+        args = args2;
+        args[num_args - 1] = strdup (temp);
+        args[num_args] = NULL;
+        temp[0] = '\0';
+        temp_len = 0;
+    }
+
+    free (string2);
+    free (temp);
+
+    return args;
+}
+
+/*
  * string_free_split: free a split string
  */
 
Index: weechat-0.3.6/src/core/wee-string.h
===================================================================
--- weechat-0.3.6.orig/src/core/wee-string.h
+++ weechat-0.3.6/src/core/wee-string.h
@@ -52,6 +52,7 @@ extern int string_has_highlight_regex (c
 extern char *string_mask_to_regex (const char *mask);
 extern char **string_split (const char *string, const char *separators,
                             int keep_eol, int num_items_max, int *num_items);
+extern char **string_split_shell (const char *string);
 extern void string_free_split (char **split_string);
 extern char *string_build_with_split_string (const char **split_string,
                                              const char *separator);
++++++ weechat.desktop ++++++
[Desktop Entry]
Encoding=UTF-8
Terminal=true
Exec=weechat-curses
Icon=weechat
Type=Application
Categories=
StartupNotify=false
Name=Weechat
GenericName=IRC Client

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to