[haiku-commits] r34028 - in haiku/vendor/bash/current: . builtins doc lib/glob lib/readline ...

  • From: korli@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 14 Nov 2009 12:57:11 +0100 (CET)

Author: korli
Date: 2009-11-14 12:57:10 +0100 (Sat, 14 Nov 2009)
New Revision: 34028
Changeset: http://dev.haiku-os.org/changeset/34028/haiku

Modified:
   haiku/vendor/bash/current/arrayfunc.c
   haiku/vendor/bash/current/bashline.c
   haiku/vendor/bash/current/builtins/declare.def
   haiku/vendor/bash/current/builtins/exit.def
   haiku/vendor/bash/current/builtins/fc.def
   haiku/vendor/bash/current/builtins/read.def
   haiku/vendor/bash/current/doc/bash.1
   haiku/vendor/bash/current/doc/bashref.texi
   haiku/vendor/bash/current/execute_cmd.c
   haiku/vendor/bash/current/externs.h
   haiku/vendor/bash/current/jobs.c
   haiku/vendor/bash/current/jobs.h
   haiku/vendor/bash/current/lib/glob/glob.c
   haiku/vendor/bash/current/lib/readline/display.c
   haiku/vendor/bash/current/lib/readline/readline.h
   haiku/vendor/bash/current/lib/readline/terminal.c
   haiku/vendor/bash/current/lib/sh/winsize.c
   haiku/vendor/bash/current/parse.y
   haiku/vendor/bash/current/patchlevel.h
   haiku/vendor/bash/current/pcomplete.c
   haiku/vendor/bash/current/sig.c
   haiku/vendor/bash/current/subst.c
   haiku/vendor/bash/current/trap.c
   haiku/vendor/bash/current/variables.c
Log:
applied patches 001-035


Modified: haiku/vendor/bash/current/arrayfunc.c
===================================================================
--- haiku/vendor/bash/current/arrayfunc.c       2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/arrayfunc.c       2009-11-14 11:57:10 UTC (rev 
34028)
@@ -98,7 +98,7 @@
   oldval = value_cell (var);
   hash = assoc_create (0);
   if (oldval)
-    assoc_insert (hash, "0", oldval);
+    assoc_insert (hash, savestring ("0"), oldval);
 
   FREE (value_cell (var));
   var_setassoc (var, hash);
@@ -604,65 +604,8 @@
     }
 }
 
-/* This function assumes s[i] == '['; returns with s[ret] == ']' if
-   an array subscript is correctly parsed. */
-int
-skipsubscript (s, i)
-     const char *s;
-     int i;
-{
-  int count, c;
-#if defined (HANDLE_MULTIBYTE)
-  mbstate_t state, state_bak;
-  size_t slength, mblength;
-#endif
+/* skipsubscript moved to subst.c to use private functions. 2009/02/24. */
 
-#if defined (HANDLE_MULTIBYTE)
-  memset (&state, '\0', sizeof (mbstate_t));
-  slength = strlen (s + i);
-#endif
-  
-  count = 1;
-  while (count)
-    {
-      /* Advance one (possibly multibyte) character in S starting at I. */
-#if defined (HANDLE_MULTIBYTE)
-      if (MB_CUR_MAX > 1)
-       {
-         state_bak = state;
-         mblength = mbrlen (s + i, slength, &state);
-
-         if (MB_INVALIDCH (mblength))
-           {
-             state = state_bak;
-             i++;
-             slength--;
-           }
-         else if (MB_NULLWCH (mblength))
-           return i;
-         else
-           {
-             i += mblength;
-             slength -= mblength;
-           }
-       }
-      else
-#endif
-      ++i;
-
-      c = s[i];
-
-      if (c == 0)
-       break;
-      else if (c == '[')
-       count++;
-      else if (c == ']')
-       count--;
-    }
-
-  return i;
-}
-
 /* This function is called with SUB pointing to just after the beginning
    `[' of an array subscript and removes the array element to which SUB
    expands from array VAR.  A subscript of `*' or `@' unsets the array. */

Modified: haiku/vendor/bash/current/bashline.c
===================================================================
--- haiku/vendor/bash/current/bashline.c        2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/bashline.c        2009-11-14 11:57:10 UTC (rev 
34028)
@@ -3388,7 +3388,6 @@
   Keymap xkmap;                /* unix command executing keymap */
   register int i;
   intmax_t mi;
-  int save_point;
   sh_parser_state_t ps;
   char *cmd, *value, *l;
   SHELL_VAR *v;
@@ -3432,7 +3431,6 @@
   if (v)
     VSETATTR (v, att_exported);
   l = value_cell (v);
-  save_point = rl_point;
   value = inttostr (rl_point, ibuf, sizeof (ibuf));
   v = bind_int_variable ("READLINE_POINT", value);
   if (v)
@@ -3450,7 +3448,7 @@
   if (v && legal_number (value_cell (v), &mi))
     {
       i = mi;
-      if (i != save_point)
+      if (i != rl_point)
        {
          rl_point = i;
          if (rl_point > rl_end)

Modified: haiku/vendor/bash/current/builtins/declare.def
===================================================================
--- haiku/vendor/bash/current/builtins/declare.def      2009-11-14 11:51:33 UTC 
(rev 34027)
+++ haiku/vendor/bash/current/builtins/declare.def      2009-11-14 11:57:10 UTC 
(rev 34028)
@@ -295,6 +295,13 @@
       subscript_start = (char *)NULL;
       if (t = strchr (name, '['))      /* ] */
        {
+         /* If offset != 0 we have already validated any array reference */
+         if (offset == 0 && valid_array_reference (name) == 0)
+           {
+             sh_invalidid (name);
+             assign_error++;
+             NEXT_VARIABLE ();
+           }
          subscript_start = t;
          *t = '\0';
          making_array_special = 1;
@@ -484,7 +491,7 @@
            }
          /* declare -a name[[n]] or declare name[n] makes name an indexed
             array variable. */
-         else if ((making_array_special || (flags_on & att_array)) && array_p 
(var) == 0)
+         else if ((making_array_special || (flags_on & att_array)) && array_p 
(var) == 0 && assoc_p (var) == 0)
            var = convert_var_to_array (var);
 #endif /* ARRAY_VARS */
 

Modified: haiku/vendor/bash/current/builtins/exit.def
===================================================================
--- haiku/vendor/bash/current/builtins/exit.def 2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/builtins/exit.def 2009-11-14 11:57:10 UTC (rev 
34028)
@@ -113,7 +113,7 @@
       for (i = stopmsg = 0; i < js.j_jobslots; i++)
        if (jobs[i] && STOPPED (i))
          stopmsg = JSTOPPED;
-       else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i))
+       else if (check_jobs_at_exit && stopmsg == 0 && jobs[i] && RUNNING (i))
          stopmsg = JRUNNING;
 
       if (stopmsg == JSTOPPED)

Modified: haiku/vendor/bash/current/builtins/fc.def
===================================================================
--- haiku/vendor/bash/current/builtins/fc.def   2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/builtins/fc.def   2009-11-14 11:57:10 UTC (rev 
34028)
@@ -88,6 +88,7 @@
 extern int current_command_line_count;
 extern int literal_history;
 extern int posixly_correct;
+extern int subshell_environment, interactive_shell;
 
 extern int unlink __P((const char *));
 
@@ -172,7 +173,7 @@
   register int i;
   register char *sep;
   int numbering, reverse, listing, execute;
-  int histbeg, histend, last_hist, retval, opt;
+  int histbeg, histend, last_hist, retval, opt, rh;
   FILE *stream;
   REPL *rlist, *rl;
   char *ename, *command, *newcom, *fcedit;
@@ -275,6 +276,8 @@
 
       fprintf (stderr, "%s\n", command);
       fc_replhist (command);   /* replace `fc -s' with command */
+      /* Posix says that the re-executed commands should be entered into the
+        history. */
       return (parse_and_execute (command, "fc", SEVAL_NOHIST));
     }
 
@@ -293,7 +296,12 @@
      line was actually added (HISTIGNORE may have caused it to not be),
      so we check hist_last_line_added. */
 
-  last_hist = i - remember_on_history - hist_last_line_added;
+  /* Even though command substitution through parse_and_execute turns off
+     remember_on_history, command substitution in a shell when set -o history
+     has been enabled (interactive or not) should use it in the last_hist
+     calculation as if it were on. */
+  rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && 
enable_history_list);
+  last_hist = i - rh - hist_last_line_added;
 
   if (list)
     {
@@ -456,7 +464,7 @@
      char *command;
      HIST_ENTRY **hlist;
 {
-  int sign, n, clen;
+  int sign, n, clen, rh;
   register int i, j;
   register char *s;
 
@@ -472,7 +480,12 @@
      line was actually added (HISTIGNORE may have caused it to not be),
      so we check hist_last_line_added.  This needs to agree with the
      calculation of last_hist in fc_builtin above. */
-  i -= remember_on_history + hist_last_line_added;
+  /* Even though command substitution through parse_and_execute turns off
+     remember_on_history, command substitution in a shell when set -o history
+     has been enabled (interactive or not) should use it in the last_hist
+     calculation as if it were on. */
+  rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && 
enable_history_list);
+  i -= rh + hist_last_line_added;
 
   /* No specification defaults to most recent command. */
   if (command == NULL)

Modified: haiku/vendor/bash/current/builtins/read.def
===================================================================
--- haiku/vendor/bash/current/builtins/read.def 2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/builtins/read.def 2009-11-14 11:57:10 UTC (rev 
34028)
@@ -369,14 +369,14 @@
       code = setjmp (alrmbuf);
       if (code)
        {
-#if 0
+         /* Tricky.  The top of the unwind-protect stack is the free of
+            input_string.  We want to run all the rest and use input_string,
+            so we have to remove it from the stack. */
+         remove_unwind_protect ();
          run_unwind_frame ("read_builtin");
-         return (EXECUTION_FAILURE);
-#else
          input_string[i] = '\0';       /* make sure it's terminated */
-         retval = 128+SIGALRM;;
+         retval = 128+SIGALRM;
          goto assign_vars;
-#endif
        }
       old_alrm = set_signal_handler (SIGALRM, sigalrm);
       add_unwind_protect (reset_alarm, (char *)NULL);
@@ -763,7 +763,10 @@
       if (*input_string == 0)
        tofree = input_string = t;
       else
-       input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, 
saw_escape);
+       {
+         input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, 
saw_escape);
+         tofree = t;
+       }
     }
 #endif
 

Modified: haiku/vendor/bash/current/doc/bash.1
===================================================================
--- haiku/vendor/bash/current/doc/bash.1        2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/doc/bash.1        2009-11-14 11:57:10 UTC (rev 
34028)
@@ -8257,9 +8257,10 @@
 Exit after reading and executing one command.
 .TP 8
 .B \-u
-Treat unset variables as an error when performing
+Treat unset variables and parameters other than the special
+parameters "@" and "*" as an error when performing
 parameter expansion.  If expansion is attempted on an
-unset variable, the shell prints an error message, and,
+unset variable or parameter, the shell prints an error message, and,
 if not interactive, exits with a non-zero status.
 .TP 8
 .B \-v

Modified: haiku/vendor/bash/current/doc/bashref.texi
===================================================================
--- haiku/vendor/bash/current/doc/bashref.texi  2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/doc/bashref.texi  2009-11-14 11:57:10 UTC (rev 
34028)
@@ -4138,7 +4138,8 @@
 Exit after reading and executing one command.
 
 @item -u
-Treat unset variables as an error when performing parameter expansion.
+Treat unset variables and parameters other than the special parameters
+@samp{@@} or @samp{*} as an error when performing parameter expansion.
 An error message will be written to the standard error, and a non-interactive
 shell will exit.
 

Modified: haiku/vendor/bash/current/execute_cmd.c
===================================================================
--- haiku/vendor/bash/current/execute_cmd.c     2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/execute_cmd.c     2009-11-14 11:57:10 UTC (rev 
34028)
@@ -568,6 +568,7 @@
 
       /* Fork a subshell, turn off the subshell bit, turn off job
         control and call execute_command () on the command again. */
+      line_number_for_err_trap = line_number;
       paren_pid = make_child (savestring (make_command_string (command)),
                              asynchronous);
       if (paren_pid == 0)
@@ -610,7 +611,10 @@
              if (user_subshell && was_error_trap && ignore_return == 0 && 
invert == 0 && exec_result != EXECUTION_SUCCESS)
                {
                  last_command_exit_value = exec_result;
+                 save_line_number = line_number;
+                 line_number = line_number_for_err_trap;
                  run_error_trap ();
+                 line_number = save_line_number;
                }
 
              if (user_subshell && ignore_return == 0 && invert == 0 && 
exit_immediately_on_error && exec_result != EXECUTION_SUCCESS)
@@ -766,7 +770,9 @@
       if (was_error_trap && ignore_return == 0 && invert == 0 && pipe_in == 
NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS)
        {
          last_command_exit_value = exec_result;
+         line_number = line_number_for_err_trap;
          run_error_trap ();
+         line_number = save_line_number;
        }
 
       if (ignore_return == 0 && invert == 0 &&
@@ -2105,6 +2111,7 @@
   REDIRECT *rp;
   COMMAND *tc, *second;
   int ignore_return, exec_result, was_error_trap, invert;
+  volatile int save_line_number;
 
   ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0;
 
@@ -2174,12 +2181,16 @@
       invert = (command->flags & CMD_INVERT_RETURN) != 0;
       ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0;
 
+      line_number_for_err_trap = line_number;
       exec_result = execute_pipeline (command, asynchronous, pipe_in, 
pipe_out, fds_to_close);
 
       if (was_error_trap && ignore_return == 0 && invert == 0 && exec_result 
!= EXECUTION_SUCCESS)
        {
          last_command_exit_value = exec_result;
+         save_line_number = line_number;
+         line_number = line_number_for_err_trap;
          run_error_trap ();
+         line_number = save_line_number;
        }
 
       if (ignore_return == 0 && invert == 0 && exit_immediately_on_error && 
exec_result != EXECUTION_SUCCESS)
@@ -2930,7 +2941,7 @@
                  retval = execute_command (clauses->action);
                }
              while ((clauses->flags & CASEPAT_FALLTHROUGH) && (clauses = 
clauses->next));
-             if ((clauses->flags & CASEPAT_TESTNEXT) == 0)
+             if (clauses == 0 || (clauses->flags & CASEPAT_TESTNEXT) == 0)
                EXIT_CASE ();
              else
                break;

Modified: haiku/vendor/bash/current/externs.h
===================================================================
--- haiku/vendor/bash/current/externs.h 2009-11-14 11:51:33 UTC (rev 34027)
+++ haiku/vendor/bash/current/externs.h 2009-11-14 11:57:10 UTC (rev 34028)
@@ -192,6 +192,8 @@
 extern char *fmtumax __P((uintmax_t, int, char *, size_t, int));
 
 /* Declarations for functions defined in lib/sh/fpurge.c */
+
+#if defined NEED_FPURGE_DECL
 #if !HAVE_DECL_FPURGE
 
 #if HAVE_FPURGE
@@ -200,8 +202,8 @@
 extern int fpurge __P((FILE *stream));
 
 #endif /* HAVE_DECL_FPURGE */
+#endif /* NEED_FPURGE_DECL */
 
-
 /* Declarations for functions defined in lib/sh/getcwd.c */
 #if !defined (HAVE_GETCWD)
 extern char *getcwd __P((char *, size_t));

Modified: haiku/vendor/bash/current/jobs.c
===================================================================
--- haiku/vendor/bash/current/jobs.c    2009-11-14 11:51:33 UTC (rev 34027)
+++ haiku/vendor/bash/current/jobs.c    2009-11-14 11:57:10 UTC (rev 34028)
@@ -442,7 +442,7 @@
   old_pipeline = the_pipeline;
   the_pipeline = saved_pipeline;
   already_making_children = saved_already_making_children;
-  if (discard)
+  if (discard && old_pipeline)
     discard_pipeline (old_pipeline);
 }
 
@@ -4202,4 +4202,23 @@
   sh_closepipe (pgrp_pipe);
 }
 
+void
+save_pgrp_pipe (p, clear)
+     int *p;
+     int clear;
+{
+  p[0] = pgrp_pipe[0];
+  p[1] = pgrp_pipe[1];
+  if (clear)
+    pgrp_pipe[0] = pgrp_pipe[1] = -1;
+}
+
+void
+restore_pgrp_pipe (p)
+     int *p;
+{
+  pgrp_pipe[0] = p[0];
+  pgrp_pipe[1] = p[1];
+}
+
 #endif /* PGRP_PIPE */

Modified: haiku/vendor/bash/current/jobs.h
===================================================================
--- haiku/vendor/bash/current/jobs.h    2009-11-14 11:51:33 UTC (rev 34027)
+++ haiku/vendor/bash/current/jobs.h    2009-11-14 11:57:10 UTC (rev 34028)
@@ -235,6 +235,8 @@
 extern void init_job_stats __P((void));
 
 extern void close_pgrp_pipe __P((void));
+extern void save_pgrp_pipe __P((int *, int));
+extern void restore_pgrp_pipe __P((int *));
 
 #if defined (JOB_CONTROL)
 extern int job_control;

Modified: haiku/vendor/bash/current/lib/glob/glob.c
===================================================================
--- haiku/vendor/bash/current/lib/glob/glob.c   2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/lib/glob/glob.c   2009-11-14 11:57:10 UTC (rev 
34028)
@@ -356,7 +356,7 @@
        *np = 0;
       if (ep)
         *ep = 0;
-      if (r)
+      if (r && r != &glob_error_return)
        free (r);
       return (struct globval *)0;
     }
@@ -665,7 +665,9 @@
       (void) closedir (d);
     }
 
-  /* compat: if GX_ALLDIRS, add the passed directory also */
+  /* compat: if GX_ADDCURDIR, add the passed directory also.  Add an empty
+     directory name as a placeholder if GX_NULLDIR (in which case the passed
+     directory name is "."). */
   if (add_current)
     {
       sdlen = strlen (dir);
@@ -917,11 +919,14 @@
        {
          char **temp_results;
 
+         /* XXX -- we've recursively scanned any directories resulting from
+            a `**', so turn off the flag.  We turn it on again below if
+            filename is `**' */
          /* Scan directory even on a NULL filename.  That way, `*h/'
             returns only directories ending in `h', instead of all
             files ending in `h' with a `/' appended. */
          dname = directories[i];
-         dflags = flags & ~GX_MARKDIRS;
+         dflags = flags & ~(GX_MARKDIRS|GX_ALLDIRS|GX_ADDCURDIR);
          if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' 
&& filename[2] == '\0')
            dflags |= GX_ALLDIRS|GX_ADDCURDIR;
          if (dname[0] == '\0' && filename[0])
@@ -942,7 +947,12 @@
              char **array;
              register unsigned int l;
 
-             array = glob_dir_to_array (directories[i], temp_results, flags);
+             /* If we're expanding **, we don't need to glue the directory
+                name to the results; we've already done it in glob_vector */
+             if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == 
'*' && filename[2] == '\0')
+               array = temp_results;
+             else
+               array = glob_dir_to_array (directories[i], temp_results, flags);
              l = 0;
              while (array[l] != NULL)
                ++l;
@@ -959,7 +969,8 @@
              result[result_size - 1] = NULL;
 
              /* Note that the elements of ARRAY are not freed.  */
-             free ((char *) array);
+             if (array != temp_results)
+               free ((char *) array);
            }
        }
       /* Free the directories.  */
@@ -1003,11 +1014,24 @@
 
       /* Just return what glob_vector () returns appended to the
         directory name. */
+      /* If flags & GX_ALLDIRS, we're called recursively */
       dflags = flags & ~GX_MARKDIRS;
       if (directory_len == 0)
        dflags |= GX_NULLDIR;
       if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' && 
filename[2] == '\0')
-       dflags |= GX_ALLDIRS|GX_ADDCURDIR;
+       {
+         dflags |= GX_ALLDIRS|GX_ADDCURDIR;
+#if 0
+         /* If we want all directories (dflags & GX_ALLDIRS) and we're not
+            being called recursively as something like `echo **/*.o'
+            ((flags & GX_ALLDIRS) == 0), we want to prevent glob_vector from
+            adding a null directory name to the front of the temp_results
+            array.  We turn off ADDCURDIR if not called recursively and
+            dlen == 0 */
+#endif
+         if (directory_len == 0 && (flags & GX_ALLDIRS) == 0)
+           dflags &= ~GX_ADDCURDIR;
+       }
       temp_results = glob_vector (filename,
                                  (directory_len == 0 ? "." : directory_name),
                                  dflags);

Modified: haiku/vendor/bash/current/lib/readline/display.c
===================================================================
--- haiku/vendor/bash/current/lib/readline/display.c    2009-11-14 11:51:33 UTC 
(rev 34027)
+++ haiku/vendor/bash/current/lib/readline/display.c    2009-11-14 11:57:10 UTC 
(rev 34028)
@@ -512,6 +512,7 @@
   /* Block keyboard interrupts because this function manipulates global
      data structures. */
   _rl_block_sigint ();  
+  RL_SETSTATE (RL_STATE_REDISPLAYING);
 
   if (!rl_display_prompt)
     rl_display_prompt = "";
@@ -1188,9 +1189,11 @@
       if (t < out)
        line[t - 1] = '>';
 
-      if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
+      if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin)
        {
          forced_display = 0;
+         o_cpos = _rl_last_c_pos;
+         cpos_adjusted = 0;
          update_line (&visible_line[last_lmargin],
                       &invisible_line[lmargin],
                       0,
@@ -1198,6 +1201,13 @@
                       _rl_screenwidth + (lmargin ? 0 : wrap_offset),
                       0);
 
+         if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+             cpos_adjusted == 0 &&
+             _rl_last_c_pos != o_cpos &&
+             _rl_last_c_pos > wrap_offset &&
+             o_cpos < prompt_last_invisible)
+               _rl_last_c_pos -= prompt_invis_chars_first_line;        /* XXX 
- was wrap_offset */
+
          /* If the visible new line is shorter than the old, but the number
             of invisible characters is greater, and we are at the end of
             the new line, we need to clear to eol. */
@@ -1236,6 +1246,7 @@
       visible_wrap_offset = wrap_offset;
   }
 
+  RL_UNSETSTATE (RL_STATE_REDISPLAYING);
   _rl_release_sigint ();
 }
 
@@ -1772,7 +1783,7 @@
             space_to_eol will insert too many spaces.  XXX - maybe we should
             adjust col_lendiff based on the difference between _rl_last_c_pos
             and _rl_screenwidth */
-         if (col_lendiff && (_rl_last_c_pos < _rl_screenwidth))
+         if (col_lendiff && ((MB_CUR_MAX == 1 || rl_byte_oriented) || 
(_rl_last_c_pos < _rl_screenwidth)))
 #endif
            {     
              if (_rl_term_autowrap && current_line < inv_botlin)
@@ -1892,6 +1903,10 @@
 
   woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
   cpos = _rl_last_c_pos;
+
+  if (cpos == 0 && cpos == new)
+    return;
+
 #if defined (HANDLE_MULTIBYTE)
   /* If we have multibyte characters, NEW is indexed by the buffer point in
      a multibyte string, but _rl_last_c_pos is the display position.  In
@@ -1905,9 +1920,9 @@
         prompt string, since they're both buffer indices and DPOS is a
         desired display position. */
       if ((new > prompt_last_invisible) ||             /* XXX - don't use woff 
here */
-         (prompt_physical_chars > _rl_screenwidth &&
+         (prompt_physical_chars >= _rl_screenwidth &&
           _rl_last_v_pos == prompt_last_screen_line &&
-          wrap_offset >= woff &&
+          wrap_offset >= woff && dpos >= woff &&
           new > 
(prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset)))
           /* XXX last comparison might need to be >= */
        {

Modified: haiku/vendor/bash/current/lib/readline/readline.h
===================================================================
--- haiku/vendor/bash/current/lib/readline/readline.h   2009-11-14 11:51:33 UTC 
(rev 34027)
+++ haiku/vendor/bash/current/lib/readline/readline.h   2009-11-14 11:57:10 UTC 
(rev 34028)
@@ -814,8 +814,9 @@
 #define RL_STATE_VIMOTION      0x100000        /* reading vi motion arg */
 #define RL_STATE_MULTIKEY      0x200000        /* reading multiple-key command 
*/
 #define RL_STATE_VICMDONCE     0x400000        /* entered vi command mode at 
least once */
+#define RL_STATE_REDISPLAYING  0x800000        /* updating terminal display */
 
-#define RL_STATE_DONE          0x800000        /* done; accepted line */
+#define RL_STATE_DONE          0x1000000       /* done; accepted line */
 
 #define RL_SETSTATE(x)         (rl_readline_state |= (x))
 #define RL_UNSETSTATE(x)       (rl_readline_state &= ~(x))

Modified: haiku/vendor/bash/current/lib/readline/terminal.c
===================================================================
--- haiku/vendor/bash/current/lib/readline/terminal.c   2009-11-14 11:51:33 UTC 
(rev 34027)
+++ haiku/vendor/bash/current/lib/readline/terminal.c   2009-11-14 11:57:10 UTC 
(rev 34028)
@@ -355,7 +355,7 @@
       _rl_get_screen_size (fileno (rl_instream), 1);
       if (CUSTOM_REDISPLAY_FUNC ())
        rl_forced_update_display ();
-      else
+      else if (RL_ISSTATE(RL_STATE_REDISPLAYING) == 0)
        _rl_redisplay_after_sigwinch ();
     }
 }

Modified: haiku/vendor/bash/current/lib/sh/winsize.c
===================================================================
--- haiku/vendor/bash/current/lib/sh/winsize.c  2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/lib/sh/winsize.c  2009-11-14 11:57:10 UTC (rev 
34028)
@@ -30,16 +30,29 @@
 
 #include <sys/ioctl.h>
 
-#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
-/* For struct winsize on SCO */
-/*   sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
-#  if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
-#    if defined (HAVE_SYS_STREAM_H)
-#      include <sys/stream.h>
-#    endif
+/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */
+
+#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
+#  include <sys/ioctl.h>
+#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
+
+#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined 
(STRUCT_WINSIZE_IN_SYS_IOCTL)
+#  include <termios.h>
+#endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
+
+/* Not in either of the standard places, look around. */
+#if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined 
(STRUCT_WINSIZE_IN_SYS_IOCTL)
+#  if defined (HAVE_SYS_STREAM_H)
+#    include <sys/stream.h>
+#  endif /* HAVE_SYS_STREAM_H */
+#  if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */
 #    include <sys/ptem.h>
-#  endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
-#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
+#    define _IO_PTEM_H          /* work around SVR4.2 1.1.4 bug */
+#  endif /* HAVE_SYS_PTEM_H */
+#  if defined (HAVE_SYS_PTE_H)  /* ??? */
+#    include <sys/pte.h>
+#  endif /* HAVE_SYS_PTE_H */
+#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
 
 #include <stdio.h>
 

Modified: haiku/vendor/bash/current/parse.y
===================================================================
--- haiku/vendor/bash/current/parse.y   2009-11-14 11:51:33 UTC (rev 34027)
+++ haiku/vendor/bash/current/parse.y   2009-11-14 11:57:10 UTC (rev 34028)
@@ -1122,7 +1122,7 @@
                          REDIRECTEE rd;
                          REDIRECT *r;
 
-                         tc = $1;
+                         tc = $1->type == cm_simple ? (COMMAND 
*)$1->value.Simple : $1;
                          rd.dest = 1;
                          r = make_redirection (2, r_duplicating_output, rd);
                          if (tc->redirects)
@@ -1615,10 +1615,11 @@
 {
   int *ret;
 
-  ret = (int *)xmalloc (3 * sizeof (int));
+  ret = (int *)xmalloc (4 * sizeof (int));
   ret[0] = last_read_token;
   ret[1] = token_before_that;
   ret[2] = two_tokens_ago;
+  ret[3] = current_token;
   return ret;
 }
 
@@ -1631,6 +1632,7 @@
   last_read_token = ts[0];
   token_before_that = ts[1];
   two_tokens_ago = ts[2];
+  current_token = ts[3];
 }
 
 /*
@@ -1877,7 +1879,7 @@
     prompt_again ();
   ret = read_a_line (remove_quoted_newline);
 #if defined (HISTORY)
-  if (remember_on_history && (parser_state & PST_HEREDOC))
+  if (ret && remember_on_history && (parser_state & PST_HEREDOC))
     {
       /* To make adding the the here-document body right, we need to rely
         on history_delimiting_chars() returning \n for the first line of
@@ -2668,6 +2670,7 @@
   FREE (word_desc_to_read);
   word_desc_to_read = (WORD_DESC *)NULL;
 
+  current_token = '\n';                /* XXX */
   last_read_token = '\n';
   token_to_read = '\n';
 }
@@ -2915,6 +2918,7 @@
 #define P_DQUOTE       0x04
 #define P_COMMAND      0x08    /* parsing a command, so look for comments */
 #define P_BACKQUOTE    0x10    /* parsing a backquoted command substitution */
+#define P_ARRAYSUB     0x20    /* parsing a [...] array subscript for 
assignment */
 
 /* Lexical state while parsing a grouping construct or $(...). */
 #define LEX_WASDOL     0x001
@@ -2927,6 +2931,7 @@
 #define LEX_INHEREDOC  0x080
 #define LEX_HEREDELIM  0x100           /* reading here-doc delimiter */
 #define LEX_STRIPDOC   0x200           /* <<- strip tabs from here doc delim */
+#define LEX_INWORD     0x400
 
 #define COMSUB_META(ch)                ((ch) == ';' || (ch) == '&' || (ch) == 
'|')
 
@@ -3129,6 +3134,8 @@
              APPEND_NESTRET ();
              FREE (nestret);
            }
+         else if ((flags & P_ARRAYSUB) && (tflags & LEX_WASDOL) && (ch == '(' 
|| ch == '{' || ch == '['))      /* ) } ] */
+           goto parse_dollar_word;
        }
       /* Parse an old-style command substitution within double quotes as a
         single word. */
@@ -3145,6 +3152,7 @@
       else if MBTEST(open != '`' && (tflags & LEX_WASDOL) && (ch == '(' || ch 
== '{' || ch == '['))    /* ) } ] */
        /* check for $(), $[], or ${} inside quoted string. */
        {
+parse_dollar_word:
          if (open == ch)       /* undo previous increment */
            count--;
          if (ch == '(')                /* ) */
@@ -3179,7 +3187,7 @@
      int open, close;
      int *lenp, flags;
 {
-  int count, ch, peekc, tflags, lex_rwlen, lex_firstind;
+  int count, ch, peekc, tflags, lex_rwlen, lex_wlen, lex_firstind;
   int nestlen, ttranslen, start_lineno;
   char *ret, *nestret, *ttrans, *heredelim;
   int retind, retsize, rflags, hdlen;
@@ -3200,7 +3208,7 @@
   retind = 0;
 
   start_lineno = line_number;
-  lex_rwlen = 0;
+  lex_rwlen = lex_wlen = 0;
 
   heredelim = 0;
   lex_firstind = -1;
@@ -3267,6 +3275,46 @@
          continue;
        }
 
+      if (tflags & LEX_PASSNEXT)               /* last char was backslash */
+       {
+/*itrace("parse_comsub:%d: lex_passnext -> 0 ch = `%c' (%d)", line_number, ch, 
__LINE__);*/
+         tflags &= ~LEX_PASSNEXT;
+         if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. 
*/
+           {
+             if (retind > 0)
+               retind--;       /* swallow previously-added backslash */
+             continue;
+           }
+
+         RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
+         if MBTEST(ch == CTLESC || ch == CTLNUL)
+           ret[retind++] = CTLESC;
+         ret[retind++] = ch;
+         continue;
+       }
+
+      /* If this is a shell break character, we are not in a word.  If not,
+        we either start or continue a word. */
+      if MBTEST(shellbreak (ch))
+       {
+         tflags &= ~LEX_INWORD;
+/*itrace("parse_comsub:%d: lex_inword -> 0 ch = `%c' (%d)", line_number, ch, 
__LINE__);*/
+       }
+      else
+       {
+         if (tflags & LEX_INWORD)
+           {
+             lex_wlen++;
+/*itrace("parse_comsub:%d: lex_inword == 1 ch = `%c' lex_wlen = %d (%d)", 
line_number, ch, lex_wlen, __LINE__);*/
+           }         
+         else
+           {
+/*itrace("parse_comsub:%d: lex_inword -> 1 ch = `%c' (%d)", line_number, ch, 
__LINE__);*/
+             tflags |= LEX_INWORD;
+             lex_wlen = 0;
+           }
+       }
+
       /* Skip whitespace */
       if MBTEST(shellblank (ch) && lex_rwlen == 0)
         {
@@ -3306,7 +3354,7 @@
        }
 
       /* Meta-characters that can introduce a reserved word.  Not perfect yet. 
*/
-      if MBTEST((tflags & LEX_RESWDOK) == 0 && (tflags & LEX_CKCASE) && 
(tflags & LEX_INCOMMENT) == 0 && shellmeta(ch))
+      if MBTEST((tflags & LEX_RESWDOK) == 0 && (tflags & LEX_CKCASE) && 
(tflags & LEX_INCOMMENT) == 0 && (shellmeta(ch) || ch == '\n'))
        {
          /* Add this character. */
          RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
@@ -3364,9 +3412,21 @@
 }              
              tflags &= ~LEX_RESWDOK;
            }
-         else if (shellbreak (ch) == 0)
+         else if MBTEST((tflags & LEX_CKCOMMENT) && ch == '#' && (lex_rwlen == 
0 || ((tflags & LEX_INWORD) && lex_wlen == 0)))
+           ;   /* don't modify LEX_RESWDOK if we're starting a comment */
+         else if MBTEST((tflags & LEX_INCASE) && ch != '\n')
+           /* If we can read a reserved word and we're in case, we're at the
+              point where we can read a new pattern list or an esac.  We
+              handle the esac case above.  If we read a newline, we want to
+              leave LEX_RESWDOK alone.  If we read anything else, we want to
+              turn off LEX_RESWDOK, since we're going to read a pattern list. 
*/
 {
-             tflags &= ~LEX_RESWDOK;
+           tflags &= ~LEX_RESWDOK;
+/*itrace("parse_comsub:%d: lex_incase == 1 found `%c', lex_reswordok -> 0", 
line_number, ch);*/
+}
+         else if MBTEST(shellbreak (ch) == 0)
+{
+           tflags &= ~LEX_RESWDOK;
 /*itrace("parse_comsub:%d: found `%c', lex_reswordok -> 0", line_number, ch);*/
 }
        }
@@ -3394,38 +3454,25 @@
                }
              else
                shell_ungetc (peekc);
-             tflags |= LEX_HEREDELIM;
-             lex_firstind = -1;
+             if (peekc != '<')
+               {
+                 tflags |= LEX_HEREDELIM;
+                 lex_firstind = -1;
+               }
              continue;
            }
          else
-           ch = peekc;         /* fall through and continue XXX - this skips 
comments if peekc == '#' */
+           ch = peekc;         /* fall through and continue XXX */
        }
-      /* Not exactly right yet, should handle shell metacharacters, too.  If
-        any changes are made to this test, make analogous changes to subst.c:
-        extract_delimited_string(). */
-      else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 
&& ch == '#' && (retind == 0 || ret[retind-1] == '\n' || shellblank (ret[retind 
- 1])))
+      else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 
&& ch == '#' && (((tflags & LEX_RESWDOK) && lex_rwlen == 0) || ((tflags & 
LEX_INWORD) && lex_wlen == 0)))
+{
+/*itrace("parse_comsub:%d: lex_incomment -> 1 (%d)", line_number, __LINE__);*/
        tflags |= LEX_INCOMMENT;
+}
 
-      if (tflags & LEX_PASSNEXT)               /* last char was backslash */
+      if MBTEST(ch == CTLESC || ch == CTLNUL)  /* special shell escapes */
        {
-         tflags &= ~LEX_PASSNEXT;
-         if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. 
*/
-           {
-             if (retind > 0)
-               retind--;       /* swallow previously-added backslash */
-             continue;
-           }
-
          RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
-         if MBTEST(ch == CTLESC || ch == CTLNUL)
-           ret[retind++] = CTLESC;
-         ret[retind++] = ch;
-         continue;
-       }
-      else if MBTEST(ch == CTLESC || ch == CTLNUL)     /* special shell 
escapes */
-       {
-         RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
          ret[retind++] = CTLESC;
          ret[retind++] = ch;
          continue;
@@ -4248,7 +4295,7 @@
                     ((token_index > 0 && assignment_acceptable 
(last_read_token) && token_is_ident (token, token_index)) ||
                      (token_index == 0 && (parser_state&PST_COMPASSIGN))))
         {
-         ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);
+         ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB);
          if (ttok == &matched_pair_error)
            return -1;          /* Bail immediately. */
          RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
@@ -4449,6 +4496,7 @@
     case '}':          /* XXX */
     case AND_AND:
     case BANG:
+    case BAR_AND:
     case DO:
     case DONE:
     case ELIF:

Modified: haiku/vendor/bash/current/patchlevel.h
===================================================================
--- haiku/vendor/bash/current/patchlevel.h      2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/patchlevel.h      2009-11-14 11:57:10 UTC (rev 
34028)
@@ -25,6 +25,6 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 0
+#define PATCHLEVEL 35
 
 #endif /* _PATCHLEVEL_H_ */

Modified: haiku/vendor/bash/current/pcomplete.c
===================================================================
--- haiku/vendor/bash/current/pcomplete.c       2009-11-14 11:51:33 UTC (rev 
34027)
+++ haiku/vendor/bash/current/pcomplete.c       2009-11-14 11:57:10 UTC (rev 
34028)
@@ -1032,6 +1032,7 @@
   cmdlist = build_arg_list (funcname, text, lwords, cw);
 
   pps = &ps;
+  save_parser_state (pps);
   begin_unwind_frame ("gen-shell-function-matches");
   add_unwind_protect (restore_parser_state, (char *)pps);
   add_unwind_protect (dispose_words, (char *)cmdlist);
@@ -1174,13 +1175,15 @@
 {
   WORD_LIST *ret;
   char *delims;
+  int i, j;
 
-#if 0
-  delims = "()<>;&| \t\n";     /* shell metacharacters break words */
-#else
-  delims = rl_completer_word_break_characters;
-#endif
+  delims = xmalloc (strlen (rl_completer_word_break_characters) + 1);
+  for (i = j = 0; rl_completer_word_break_characters[i]; i++)
+    if (rl_completer_word_break_characters[i] != '\'' && 
rl_completer_word_break_characters[i] != '"')
+      delims[j++] = rl_completer_word_break_characters[i];
+  delims[j] = '\0';
   ret = split_at_delims (line, llen, delims, sentinel, nwp, cwp);
+  free (delims);
   return (ret);
 }
 

Modified: haiku/vendor/bash/current/sig.c
===================================================================
--- haiku/vendor/bash/current/sig.c     2009-11-14 11:51:33 UTC (rev 34027)
+++ haiku/vendor/bash/current/sig.c     2009-11-14 11:57:10 UTC (rev 34028)
@@ -448,6 +448,48 @@
 termsig_sighandler (sig)
      int sig;
 {
+  /* If we get called twice with the same signal before handling it,
+     terminate right away. */
+  if (
+#ifdef SIGHUP
+    sig != SIGHUP &&
+#endif
+#ifdef SIGINT
+    sig != SIGINT &&
+#endif
+#ifdef SIGDANGER
+    sig != SIGDANGER &&
+#endif
+#ifdef SIGPIPE
+    sig != SIGPIPE &&
+#endif

[... truncated: 419 lines follow ...]

Other related posts:

  • » [haiku-commits] r34028 - in haiku/vendor/bash/current: . builtins doc lib/glob lib/readline ... - korli