[CentOS-devel] package for contrib repository

Karmanov Anton defunct41 at gmail.com
Thu Aug 6 14:33:14 UTC 2009


On Thu, Aug 6, 2009 at 7:28 AM, Manuel
Wolfshant<wolfy at nobugconsulting.ro> wrote:

> I have cleaned up a bit your package (fixed a few tags, added a few
> missing BRs, corrected %install and %files) and did a successful build
> in fedora's koji. The modified src.rpm and spec can be found at
> http://wolfy.fedorapeople.org/parcellite , while the binaries are at
> http://koji.fedoraproject.org/koji/taskinfo?taskID=1585375
>
>
> _______________________________________________
> CentOS-devel mailing list
> CentOS-devel at centos.org
> http://lists.centos.org/mailman/listinfo/centos-devel
>

Thanks Manuel, I'll study it's text. it is only third package I ever
created spec file for (previous were conky and linuxdcpp), so I don't
know all the detail.
And I found a way to return back link check by authors regular
expression (replaced GRegex by POSIX regex), plus make g_strcmp0
replacement case sensitive back, but I don't know is it normal to mess
standard strcmp and regex with glib (actually I' scared of work with
local chars can be broken). So if you want to try that version patch
here.

diff -up ./configure.fix ./configure
--- ./configure.fix	2009-03-18 21:36:15.000000000 +0500
+++ ./configure	2009-08-06 20:05:31.000000000 +0600
@@ -10044,7 +10044,8 @@ fi
     PKG_CONFIG=no
   fi

-  min_glib_version=2.14.0
+  # d41: we don't have glib 2.14
+  min_glib_version=2.12.0
   { $as_echo "$as_me:$LINENO: checking for GLIB - version >=
$min_glib_version" >&5
 $as_echo_n "checking for GLIB - version >= $min_glib_version... " >&6; }

diff -up ./src/main.c.fix ./src/main.c
--- ./src/main.c.fix	2009-03-18 21:33:03.000000000 +0500
+++ ./src/main.c	2009-08-06 20:05:31.000000000 +0600
@@ -50,6 +50,21 @@ prefs_t prefs = {DEF_USE_COPY,        DE
                  INIT_HISTORY_KEY,    INIT_ACTIONS_KEY,     INIT_MENU_KEY,
                  DEF_NO_ICON};

+/* d41: CentOS have glib 2.12 (not 2.14)  =(
+so, thereis no g_strcmp0
+from glib docs:
+Compares str1 and str2 like strcmp(). Handles NULL gracefully by
sorting it before non-NULL strings.
+str1 :	a C string or NULL
+str2 :	another C string or NULL
+Returns :	-1, 0 or 1, if str1 is <, == or > than str2.
+*/
+int g_strcmp0(const char *str1, const char *str2)
+{
+  if( str1 == NULL && str2 == NULL ) return 0;
+  if( str1 == NULL ) return -1;
+  if( str2 == NULL ) return 1;
+  return strcmp(str1, str2);
+};


 /* Called every CHECK_INTERVAL seconds to check for new items */
@@ -89,7 +104,10 @@ item_check(gpointer data)
             delete_duplicate(primary_text);
             append_item(primary_text);
           }
-          else
+          /* d41: add anything else only if hyperlinks_only disabled
+          to remove junk from history
+          */
+          else if (!prefs.hyperlinks_only)
           {
             delete_duplicate(primary_text);
             append_item(primary_text);
@@ -121,7 +139,10 @@ item_check(gpointer data)
           delete_duplicate(clipboard_text);
           append_item(clipboard_text);
         }
-        else
+        /* d41: add anything else only if hyperlinks_only disabled
+        to remove junk from history
+        */
+        else if (!prefs.hyperlinks_only)
         {
           delete_duplicate(clipboard_text);
           append_item(clipboard_text);
@@ -236,8 +257,12 @@ edit_selected(GtkMenuItem *menu_item, gp

     gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window,
                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
+
+#if GTK_CHECK_VERSION(2,14,0)
+    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
scrolled_window, TRUE, TRUE, 2);
+#else
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
scrolled_window, TRUE, TRUE, 2);
+#endif
     GtkWidget* text_view = gtk_text_view_new_with_buffer(clipboard_buffer);
     gtk_text_view_set_left_margin((GtkTextView*)text_view, 2);
     gtk_text_view_set_right_margin((GtkTextView*)text_view, 2);
diff -up ./src/main.h.fix ./src/main.h
--- ./src/main.h.fix	2009-03-18 21:33:03.000000000 +0500
+++ ./src/main.h	2009-08-06 20:05:31.000000000 +0600
@@ -64,6 +64,9 @@ actions_hotkey(char *keystring, gpointer
 void
 menu_hotkey(char *keystring, gpointer user_data);

+int g_strcmp0(const char *str1, const char *str2);
+
+
 G_END_DECLS

 #endif
diff -up ./src/preferences.c.fix ./src/preferences.c
--- ./src/preferences.c.fix	2009-03-18 21:33:03.000000000 +0500
+++ ./src/preferences.c	2009-08-06 20:05:31.000000000 +0600
@@ -422,7 +422,6 @@ show_preferences(gint tab)
   vbox = gtk_vbox_new(FALSE, 2);
   gtk_container_add((GtkContainer*)alignment, vbox);
   save_check = gtk_check_button_new_with_mnemonic(_("_Save history"));
-  gtk_widget_set_tooltip_text(save_check, _("Save and restore history
between sessions"));
   gtk_box_pack_start((GtkBox*)vbox, save_check, FALSE, FALSE, 0);
   hbox = gtk_hbox_new(FALSE, 4);
   gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
diff -up ./src/utils.c.fix ./src/utils.c
--- ./src/utils.c.fix	2009-03-18 21:33:03.000000000 +0500
+++ ./src/utils.c	2009-08-06 20:19:57.000000000 +0600
@@ -23,6 +23,8 @@
 #include "daemon.h"
 #include "history.h"
 #include "parcellite-i18n.h"
+#include <sys/types.h>
+#include <regex.h>

 /* Creates program related directories if needed */
 void
@@ -50,17 +52,22 @@ check_dirs()
 }

 /* Returns TRUE if text is a hyperlink */
+/* d41: CentOS have glib 2.12 (not 2.14)  =(
+so, thereis no gregex
+*/
 gboolean
 is_hyperlink(gchar* text)
 {
-  /* TODO: I need a better regex, this one is poor */
-  GRegex* regex = g_regex_new("([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/]" \
-
"(([A-Za-z0-9$_.+!*,;/?:@&~=-])|%[A-Fa-f0-9]{2}){1,333}" \
-
"(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)",
-                              G_REGEX_CASELESS, 0, NULL);
-
-  gboolean result = g_regex_match(regex, text, 0, NULL);
-  g_regex_unref(regex);
+  gboolean result = FALSE;
+  regex_t pattern;
+  if( regcomp(&pattern, "([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/]" \
+
"(([A-Za-z0-9$_.+!*,;/?:@&~=-])|%[A-Fa-f0-9]{2}){1,333}" \
+
"(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)",
+              REG_EXTENDED|REG_ICASE|REG_NOSUB) == 0)
+  {
+    if( regexec(&pattern, text, 0, NULL, REG_NOTEOL) == 0) result = TRUE;
+    regfree(&pattern);
+  }
   return result;
 }



More information about the CentOS-devel mailing list