]> Pileus Git - ~andy/gtk/commitdiff
provide usefull default specifications for identifier_spec and
authorTim Janik <timj@gtk.org>
Sun, 17 May 1998 11:35:55 +0000 (11:35 +0000)
committerTim Janik <timj@src.gnome.org>
Sun, 17 May 1998 11:35:55 +0000 (11:35 +0000)
Sun May 17 10:48:27 1998  Tim Janik  <timj@gtk.org>

        * gscanner.c (g_scanner_unexp_token): provide usefull default
        specifications for identifier_spec and symbol_spec.

        * glib.h: new functions g_slist_nth_data and g_list_nth_data to return
        the data of the nth element in the list.

glib/ChangeLog
glib/glib.h
glib/glist.c
glib/gscanner.c
glib/gslist.c

index d7a276ba833f3e95cdcb3a37b29f85ec7411076b..541430f3c3f90f575477dbd0d1489a10899522c6 100644 (file)
@@ -1,8 +1,16 @@
+Sun May 17 10:48:27 1998  Tim Janik  <timj@gtk.org>
+
+       * gscanner.c (g_scanner_unexp_token): provide usefull default
+       specifications for identifier_spec and symbol_spec.
+
+       * glib.h: new functions g_slist_nth_data and g_list_nth_data to return
+       the data of the nth element in the list.
+
 Fri May 15 22:31:49 1998  Tim Janik  <timj@gtk.org>
 
-       * gscanner.c (g_scanner_unexp_token): removed sputious va_end(args) that
-       for some reason didn't produce a compiler wrning on my machine (is
-       va_end undefined for i386?).
+       * gscanner.c (g_scanner_unexp_token): removed spurious va_end(args)
+       that for some reason didn't produce a compiler wrning on my machine
+       (is va_end undefined for i386?).
 
 Fri May 15 12:32:08 1998  rodo  <doulik@karlin.mff.cuni.cz>
 
index 9ee044f7454731038cf0fe24c3211a858b70b278..282288c977991d8cccf866b31f89d26c186746d7 100644 (file)
@@ -518,6 +518,8 @@ guint  g_list_length          (GList     *list);
 void   g_list_foreach    (GList     *list,
                           GFunc      func,
                           gpointer   user_data);
+gpointer g_list_nth_data  (GList     *list,
+                          guint      n);
 
 #define g_list_previous(list) ((list) ? (((GList *)list)->prev) : NULL)
 #define g_list_next(list) ((list) ? (((GList *)list)->next) : NULL)
@@ -558,6 +560,8 @@ guint       g_slist_length      (GSList   *list);
 void   g_slist_foreach     (GSList   *list,
                             GFunc     func,
                             gpointer  user_data);
+gpointer g_slist_nth_data   (GSList   *list,
+                            guint     n);
 
 #define g_slist_next(list) ((list) ? (((GSList *)list)->next) : NULL)
 
index 06cfd54905795c37ff85d2934a86877eef919cfe..a24751cbc3e7eab76f0675f72780847d06f5c465 100644 (file)
@@ -300,6 +300,16 @@ g_list_nth (GList *list,
   return list;
 }
 
+gpointer
+g_list_nth_data (GList     *list,
+                guint      n)
+{
+  while ((n-- > 0) && list)
+    list = list->next;
+  
+  return list ? list->data : NULL;
+}
+
 GList*
 g_list_find (GList    *list,
             gpointer  data)
index 529d7e76e0371d43da8f87dc1fc54ed9368d8cdb..d8f7f6805a555a2ba7c869240bb1b521b7f2027b 100644 (file)
@@ -665,6 +665,11 @@ g_scanner_unexp_token (GScanner            *scanner,
     msg_handler = g_scanner_error;
   else
     msg_handler = g_scanner_warn;
+
+  if (!identifier_spec)
+    identifier_spec = "identifier";
+  if (!symbol_spec)
+    symbol_spec = "symbol";
   
   token_string_len = 56;
   token_string = g_new (gchar, token_string_len + 1);
index e608f131e86a4d56b35d8c1ac875c1490aea7718..636dd37dc4bf4f4a8da818d01074bfcaa47281f0 100644 (file)
@@ -289,6 +289,16 @@ g_slist_nth (GSList *list,
   return list;
 }
 
+gpointer
+g_slist_nth_data (GSList   *list,
+                 guint     n)
+{
+  while ((n-- > 0) && list)
+    list = list->next;
+
+  return list ? list->data : NULL;
+}
+
 GSList*
 g_slist_find (GSList   *list,
              gpointer  data)