Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.422
diff -u -p -r1.422 theme.inc
--- includes/theme.inc	6 May 2008 12:18:45 -0000	1.422
+++ includes/theme.inc	9 May 2008 19:24:17 -0000
@@ -1087,53 +1087,38 @@ function theme_status_messages($display 
  *   A string containing an unordered list of links.
  */
 function theme_links($links, $attributes = array('class' => 'links')) {
-  $output = '';
-
-  if (count($links) > 0) {
-    $output = '<ul' . drupal_attributes($attributes) . '>';
+  $list = array();
 
-    $num_links = count($links);
-    $i = 1;
+  foreach ($links as $key => $link) {
+    $class = $key;
 
-    foreach ($links as $key => $link) {
-      $class = $key;
-
-      // Add first, last and active classes to the list of links to help out themers.
-      if ($i == 1) {
-        $class .= ' first';
-      }
-      if ($i == $num_links) {
-        $class .= ' last';
-      }
-      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
-        $class .= ' active';
-      }
-      $output .= '<li class="' . $class . '">';
+    if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
+      $class .= ' active';
+    }
 
-      if (isset($link['href'])) {
-        // Pass in $link as $options, they share the same keys.
-        $output .= l($link['title'], $link['href'], $link);
+    if (isset($link['href'])) {
+      // Pass in $link as $options, they share the same keys.
+      $data = l($link['title'], $link['href'], $link);
+    }
+    else if (!empty($link['title'])) {
+      // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
+      if (empty($link['html'])) {
+        $link['title'] = check_plain($link['title']);
       }
-      else if (!empty($link['title'])) {
-        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
-        if (empty($link['html'])) {
-          $link['title'] = check_plain($link['title']);
-        }
-        $span_attributes = '';
-        if (isset($link['attributes'])) {
-          $span_attributes = drupal_attributes($link['attributes']);
-        }
-        $output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
+      $span_attributes = '';
+      if (isset($link['attributes'])) {
+        $span_attributes = drupal_attributes($link['attributes']);
       }
-
-      $i++;
-      $output .= "</li>\n";
+      $data = '<span' . $span_attributes . '>' . $link['title'] . '</span>';
     }
-
-    $output .= '</ul>';
+    
+    $list[] = array(
+      'data' => $data,
+      'class' => $class,
+    );
   }
-
-  return $output;
+  
+  return theme('item_list', $list, NULL, 'ul', $attributes);
 }
 
 /**
