~ubuntu-branches/ubuntu/maverick/ekiga/maverick

« back to all changes in this revision

Viewing changes to lib/toolbox/toolbox-common.c

  • Committer: Bazaar Package Importer
  • Author(s): Eugen Dedu, Eugen Dedu, Loic Minier
  • Date: 2008-09-27 10:00:00 UTC
  • mfrom: (1.1.8 upstream)
  • mto: (1.4.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20080927100000-l5k5werb6czr5b3h
Tags: 3.0.1-1
[ Eugen Dedu ]
* New version.  (Closes: #500089).
* Add our own changelog file in /usr/share/doc.
* Remove gnomemeeting transitional package.
* Discover new interfaces.  (Closes: #488199).
* Compile with dbus support.  (Closes: #467212).
* Numeric keypad inserts digits at correct position.  (Closes: #440159).
* Use libnotify upon call.  (Closes: #412604).
* Symlink identical GNOME help files, to reduce size.  (Closes: #505536).
* Explicitely build-depends on a few dev packages, even if they were
  pulled out anyway by the other dependencies.

[ Loic Minier ]
* Use clean:: instead of clean: in rules.
* Don't disable Uploaders: generation for control.in -> control generation
  in rules.
* Fix some tabs which were size 4 anyway.
* Generate a PO template during build by calling intltool-update -p in
  install; thanks Ubuntu and Martin Pitt; closes: #505535.
* Also let the -dbg depend on ${misc:Depends}.
* Cleanup rules; in particular, use dpkg-parsechangelog and honor
  distclean/clean failures, remove old clean rules, commented out stuff,
  gtk-only stuff.
* Pass -s to dh_* in binary-arch.
* Use debian/*.links and debian/*.manpages instead of symlink manually or
  passing files to dh_installman.
* Use ftp.gnome.org in copyright.
* Switch to quilt and fix target deps in the process; build-dep on quilt
  instead of dpatch; rename news.dpatch to 00_news.patch and refresh;
  replace 00list with series.
* Install autotools-dev config.guess and .sub after patching.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
#include "toolbox.h"
38
38
 
39
 
/* gm_mkdir_with_parents taken more or less 1:1 from glib 2.8 */
40
 
gboolean
41
 
gm_mkdir_with_parents (const gchar *pathname,
42
 
                        int mode)
 
39
#include <string.h>
 
40
 
 
41
GSList
 
42
*gm_string_gslist_remove_dups (GSList *origlist)
43
43
{
44
 
  gchar *fn, *p;
45
 
 
46
 
  if (pathname == NULL)
47
 
    return FALSE;
48
 
 
49
 
  fn = g_strdup (pathname);
50
 
 
51
 
  if (g_path_is_absolute (fn))
52
 
    p = (gchar *) g_path_skip_root (fn);
53
 
    /* p is now a pointer INSIDE the memory of fn, not a new string, see GLib doc
54
 
     * for g_path_skip_root()
55
 
     */
56
 
  else
57
 
    p = fn;
58
 
 
59
 
  /* the following loop means for fn="/dir1/dir2/dir3" per iteration:
60
 
   * fn == "/dir1"
61
 
   * fn == "/dir1/dir2"
62
 
   * fn == "/dir1/dir2/dir3"
63
 
   *
64
 
   * This is done by setting the terminating \0 at the position of
65
 
   * every found dir separator per iteration.
66
 
   */
67
 
  do {
68
 
    /* increase p, until we reach the first dir separator */
69
 
    while (*p && !G_IS_DIR_SEPARATOR (*p))
70
 
      p++;
71
 
 
72
 
    if (!*p)
73
 
      /* did we reach the end? */
74
 
      p = NULL;
75
 
    else
76
 
      /* this has the effect to give fn a new \0 at
77
 
       * the dir separator for termination */
78
 
      *p = '\0';
79
 
 
80
 
    if (!g_file_test (fn, G_FILE_TEST_EXISTS)) {
81
 
      if (g_mkdir (fn, mode) == -1) {
82
 
        g_free (fn);
83
 
        return FALSE;
84
 
      }
85
 
    }
86
 
    
87
 
    else if (!g_file_test (fn, G_FILE_TEST_IS_DIR)) {
88
 
      g_free (fn);
89
 
      return FALSE;
90
 
    }
91
 
    
92
 
    if (p) {
93
 
      /* restore the dir separator and search the next one */
94
 
      *p++ = G_DIR_SEPARATOR;
95
 
      while (*p && G_IS_DIR_SEPARATOR (*p))
96
 
        p++;
97
 
    }
98
 
  } while (p);
99
 
 
100
 
  /* we only need to free fn here, as p doesn't point to extra
101
 
   * allocated memory, it points "inside" fn
102
 
   */
103
 
  g_free (fn);
104
 
 
105
 
  return TRUE;
 
44
   /* from a GSList* of gchar*, remove all dup strings
 
45
   * (C) Jan Schampera <jan.schampera@web.de> */
 
46
  GSList *origlist_iter = NULL;
 
47
  GSList *seenlist = NULL;
 
48
  GSList *seenlist_iter = NULL;
 
49
  gboolean seen = FALSE;
 
50
 
 
51
  /* iterate through the original list and compare every stored gchar* to
 
52
   * our "seen list", if not there, append it */
 
53
  if (!origlist) return NULL;
 
54
 
 
55
  for (origlist_iter = origlist;
 
56
       origlist_iter != NULL;
 
57
       origlist_iter = g_slist_next (origlist_iter))
 
58
    {
 
59
      if (origlist_iter->data)
 
60
        {
 
61
          seen = FALSE;
 
62
          /* check if the string is already in the "seen list" */
 
63
          for (seenlist_iter = seenlist;
 
64
               seenlist_iter != NULL;
 
65
               seenlist_iter = g_slist_next (seenlist_iter))
 
66
            {
 
67
              if (seenlist_iter->data &&
 
68
                  !strcmp ((const char*) origlist_iter->data,
 
69
                           (const char*) seenlist_iter->data))
 
70
                {
 
71
                  seen = TRUE;
 
72
                }
 
73
            }
 
74
          if (!seen)
 
75
            {
 
76
              /* not in list? append it... */
 
77
              seenlist = g_slist_append (seenlist,
 
78
                                         (gpointer) g_strdup
 
79
                                         ((const gchar*) origlist_iter->data));
 
80
            }
 
81
        }
 
82
    }
 
83
 
 
84
  /* free the memory of the original list */
 
85
  g_slist_foreach (origlist, (GFunc) g_free, NULL);
 
86
  g_slist_free (origlist);
 
87
 
 
88
  return seenlist;
106
89
}
107