--- /home/sseverin/drupal/path_redirect-5.x-1.x/path_redirect.module	2007-12-01 21:12:55.000000000 -0600
+++ path_redirect.module	2007-12-01 21:11:24.000000000 -0600
@@ -114,7 +114,7 @@ function path_redirect_admin($rid = FALS
         return drupal_get_form('path_redirect_edit', $redirect);
       }
       elseif ($redirect && $op == 'delete') {
-        return drupal_get_form('path_redirect_delete', $redirect);
+        return drupal_get_form('path_redirect_delete_confirm', $redirect);
       }
       else {
         drupal_not_found();
@@ -299,7 +299,7 @@ function path_redirect_save($edit) {
     $edit['rid'] = db_next_id('{path_redirect}_rid');
   }
   else {
-    path_redirect_delete_do($edit['rid']);
+    path_redirect_delete(NULL, NULL, $edit['rid']);
   }
   // remove any other redirects from the same path
   db_query("DELETE FROM {path_redirect} WHERE path = '%s'", $edit['path']);
@@ -309,11 +309,40 @@ function path_redirect_save($edit) {
   return $return;
 }
 
-function path_redirect_delete_do($rid) {
-  return db_query("DELETE FROM {path_redirect} WHERE rid = %d", $rid);
+/**
+ * Delete the specified path redirect. This will delete as specifically as
+ * possible, in order: by $rid, by ($from, $to), by $from, or by $to.
+ * Multiple redirects may be deleted if the $to parameter matches more than
+ * one entry.
+ *
+ * This function is part of an API available for external code to use.
+ *
+ * @param $from
+ *   Source path of redirect to delete.
+ * @param $to
+ *   Destination path or URL of redirect to delete.
+ * @param $rid
+ *   Unique ID of redirect to delete.
+ */
+function path_redirect_delete($from = NULL, $to = NULL, $rid = NULL) {
+  if (!empty($rid)) {
+    $result =  db_query("DELETE FROM {path_redirect} WHERE rid = %d", $rid);
+  }
+  else if (!empty($from)) {
+    if (!empty($to)) {
+      $result =  db_query("DELETE FROM {path_redirect} WHERE path = '%s' AND redirect = '%s'", $from, $to);
+    }
+    else {
+      $result =  db_query("DELETE FROM {path_redirect} WHERE path = '%s'", $from);
+    }
+  }
+  else if (!empty($to)) {
+    $result =  db_query("DELETE FROM {path_redirect} WHERE redirect = '%s'", $to);
+  }
+  return $result;
 }
 
-function path_redirect_delete($redirect) {
+function path_redirect_delete_confirm($redirect) {
   $form['rid'] = array(
     '#type' => 'value',
     '#value' => check_plain($redirect['rid']),
@@ -321,8 +350,8 @@ function path_redirect_delete($redirect)
   return confirm_form($form, t('Are you sure you want to delete this redirect?'), 'admin/build/path_redirect', NULL, t('Delete it!'), t('Cancel'));
 }
 
-function path_redirect_delete_submit($form_id, $form_values) {
-  path_redirect_delete_do($form_values['rid']);
+function path_redirect_delete_confirm_submit($form_id, $form_values) {
+  path_redirect_delete(NULL, NULL, $form_values['rid']);
   drupal_set_message(t('Redirect item has been deleted.'));
   drupal_goto('admin/build/path_redirect');
 }
