~ubuntu-branches/ubuntu/precise/eglibc/precise

« back to all changes in this revision

Viewing changes to posix/wordexp.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-10-04 17:48:26 UTC
  • mfrom: (216.1.23 oneiric)
  • Revision ID: package-import@ubuntu.com-20111004174826-2cyb9ewn3ucymlsx
Tags: 2.13-20ubuntu5
libc6-dev: Don't break the current {gnat,gcj}-4.4-base versons. LP: #853688.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* POSIX.2 wordexp implementation.
2
 
   Copyright (C) 1997-2003,2005,2006,2008,2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 1997-2003, 2005, 2006, 2008 Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
   Contributed by Tim Waugh <tim@cyberelk.demon.co.uk>.
5
5
 
38
38
#include <sys/types.h>
39
39
#include <sys/wait.h>
40
40
#include <unistd.h>
41
 
#include <wchar.h>
 
41
#ifdef USE_IN_LIBIO
 
42
# include <wchar.h>
 
43
#endif
42
44
#include <wordexp.h>
43
45
#include <kernel-features.h>
44
46
 
852
854
          __close (fd);
853
855
        }
854
856
      /* Be paranoid.  Check that we actually opened the /dev/null
855
 
         device.  */
 
857
         device.  */
856
858
      if (__builtin_expect (__fxstat64 (_STAT_VER, STDERR_FILENO, &st), 0) != 0
857
859
          || __builtin_expect (S_ISCHR (st.st_mode), 1) == 0
858
860
#if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR
860
862
#endif
861
863
          )
862
864
        /* It's not the /dev/null device.  Stop right here.  The
863
 
           problem is: how do we stop?  We use _exit() with an
864
 
           hopefully unusual exit code.  */
 
865
           problem is: how do we stop?  We use _exit() with an
 
866
           hopefully unusual exit code.  */
865
867
        _exit (90);
866
868
    }
867
869
 
1060
1062
                  if (copying == 3)
1061
1063
                    {
1062
1064
                      /* Nothing but (IFS) newlines since the last field,
1063
 
                         so delimit it here before starting new word */
 
1065
                         so delimit it here before starting new word */
1064
1066
                      if (w_addword (pwordexp, *word) == WRDE_NOSPACE)
1065
1067
                        goto no_space;
1066
1068
 
1087
1089
  /* Ensure we don't go back further than the beginning of the
1088
1090
     substitution (i.e. remove maxnewlines bytes at most) */
1089
1091
  while (maxnewlines-- != 0 &&
1090
 
         *word_length > 0 && (*word)[*word_length - 1] == '\n')
 
1092
         *word_length > 0 && (*word)[*word_length - 1] == '\n')
1091
1093
    {
1092
1094
      (*word)[--*word_length] = '\0';
1093
1095
 
1575
1577
      if (expand_pattern)
1576
1578
        {
1577
1579
          /* We need to perform tilde expansion, parameter expansion,
1578
 
             command substitution, and arithmetic expansion.  We also
 
1580
             command substitution, and arithmetic expansion.  We also
1579
1581
             have to be a bit careful with wildcard characters, as
1580
1582
             pattern might be given to fnmatch soon.  To do this, we
1581
1583
             convert quotes to escapes. */
1980
1982
          field_end = field_begin + strcspn (field_begin, ifs);
1981
1983
 
1982
1984
          /* Set up pointer to the character after end of field and
1983
 
             skip whitespace IFS after it. */
 
1985
             skip whitespace IFS after it. */
1984
1986
          next_field = field_end + strspn (field_end, ifs_white);
1985
1987
 
1986
1988
          /* Skip at most one non-whitespace IFS character after the field */