]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - pcomplib.c
fix for SIGINT in sourced script
[thirdparty/bash.git] / pcomplib.c
index aa08fa5da452a4dcd166d19db70bba4a728c2352..70c7a17a602194c792fe91a9cf23fb456ff78d98 100644 (file)
@@ -1,22 +1,22 @@
 /* pcomplib.c - library functions for programmable completion. */
 
-/* Copyright (C) 1999-2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
-   Bash is free software; you can redistribute it and/or modify it under
-   the terms of the GNU General Public License as published by the Free
-   Software Foundation; either version 2, or (at your option) any later
-   version.
+   Bash is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-   Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-   WARRANTY; without even the implied warranty of MERCHANTABILITY or
-   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-   for more details.
+   Bash is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-   You should have received a copy of the GNU General Public License along
-   with Bash; see the file COPYING.  If not, write to the Free Software
-   Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+   You should have received a copy of the GNU General Public License
+   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
 #include <config.h>
 
 #  include <unistd.h>
 #endif
 
+#include "bashintl.h"
+
 #include "shell.h"
 #include "pcomplete.h"
 
-#define COMPLETE_HASH_BUCKETS  32      /* must be power of two */
+#define COMPLETE_HASH_BUCKETS  256     /* must be power of two */
 
 #define STRDUP(x)      ((x) ? savestring (x) : (char *)NULL)
 
@@ -60,6 +62,7 @@ compspec_create ()
   ret->suffix = (char *)NULL;
   ret->funcname = (char *)NULL;
   ret->command = (char *)NULL;
+  ret->lcommand = (char *)NULL;
   ret->filterpat = (char *)NULL;
 
   return ret;
@@ -78,6 +81,7 @@ compspec_dispose (cs)
       FREE (cs->suffix);
       FREE (cs->funcname);
       FREE (cs->command);
+      FREE (cs->lcommand);
       FREE (cs->filterpat);
 
       free (cs);
@@ -92,7 +96,7 @@ compspec_copy (cs)
 
   new = (COMPSPEC *)xmalloc (sizeof (COMPSPEC));
 
-  new->refcount = cs->refcount;
+  new->refcount = 1;   /* was cs->refcount, but this is a fresh copy */
   new->actions = cs->actions;
   new->options = cs->options;
 
@@ -102,6 +106,7 @@ compspec_copy (cs)
   new->suffix = STRDUP (cs->suffix);
   new->funcname = STRDUP (cs->funcname);
   new->command = STRDUP (cs->command);
+  new->lcommand = STRDUP (cs->lcommand);
   new->filterpat = STRDUP (cs->filterpat);
 
   return new;
@@ -174,18 +179,19 @@ progcomp_insert (cmd, cs)
   register BUCKET_CONTENTS *item;
 
   if (cs == NULL)
-    programming_error ("progcomp_insert: %s: NULL COMPSPEC", cmd);
+    programming_error (_("progcomp_insert: %s: NULL COMPSPEC"), cmd);
 
   if (prog_completes == 0)
     progcomp_create ();
 
+  cs->refcount++;
   item = hash_insert (cmd, prog_completes, 0);
   if (item->data)
     free_progcomp (item->data);
   else
     item->key = savestring (cmd);
   item->data = cs;
-  cs->refcount++;
+
   return 1;
 }