~ubuntu-branches/ubuntu/karmic/mksh/karmic

« back to all changes in this revision

Viewing changes to setmode.c

  • Committer: Bazaar Package Importer
  • Author(s): Thorsten Glaser
  • Date: 2007-04-25 11:36:42 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070425113642-84xnxqdkzau1qrlf
Tags: 29.2-1
* New upstream formal release; summary of changes:
  + a plethora of UTF-8 fixes:
  - display control characters U+0080..U+009F the same as U+0000..U+001F,
    i.e. a caret followed by the character corresponding to the control
    character XOR 0x0040, treat their width as 2 subsequently
  - fix crash (cpu hog in spinning loop) on meta-tab + backspace
  - strip off UTF-8 byte order mark at beginning of input
  - if a BOM is encountered, switch on utf-8 command line editing mode
  + in utf-8 command line editing mode, handle invalid input more strictly:
  - if in x_literal(), i.e. the ^V mode (bind to quote), allow it as before
  - if it's the start of an invalid multibyte sequence, reject with a beep
    (e.g. if trying to input latin1 chars)
  - if it's an invalid or partial multibyte sequence, reject silently
  -> this makes command line editing much more robust
  + other bug fixes:
  - in a rare condition (error path), the wrong function was used to copy
    a string that could contain embedded NULs (encoded format), leading to
    memory access past malloc'd area
  - in the same path, fix an out-of-bounds access inherited from openbsd ksh
  -> discovered on Debian GNU/Linux experimental ia64, glibc 2.5-beta
  + new functionality:
  - if execve() fails, before passing the file to $EXECSHELL, open it and
    try to parse a shebang line; if we find one, do it ourselves
    (the good part of this is that it even works when there is a UTF-8 BOM
    before the shebang magic sequence)
  - for shebang processing, not only NUL or LF but also CR terminate the line
  - enhancements to the "dot.mkshrc" sample file (which is now regularily
    used upstream as well)
  - if the internal function exchild() fails, don't just tell the user that
    it failed, tell him WHAT failed (unless -DMKSH_SMALL)
  + code cleanup changes:
  - remove unused functions, macros
  - fix typos, errors, etc.
  - shut up gcc 4.1.2 warnings
  - Build.sh cygwin vs unix cleanup/simplification
  - shrink manual page to 39 DIN A4 pages when output as postscript
  + reliability changes:
  - if $CC supports -fstack-protector-all, add it to $CFLAGS
  - if $CC supports -fno-tree-vrp, add it to $CFLAGS if $CC is subject to
    the bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30785
  - add mirtoconf check for "large file support", requested by bsiegert@,
    needed for some *nix, idea and implementation hints from GNU autoconf
  - add zsh workaround to Build.sh, just in case (untested)
* disable the possible workaround mentioned in the changes for 28.9.20070309
  because I was unable to verify/test it; maybe it only applies to the glibc
  in experimental anyway, we'll see to that later
* add a comment about the regression test needing openpty() to debian/rules
* remove non-ASCII (i.e. high-bit7) characters from diff/changelog
* slightly enhance package description
* properly indent homepage link in description, thanks KiBi (kfreebsd team)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**     _MirOS: src/lib/libc/gen/setmode.c,v 1.5 2006/07/03 12:13:52 tg Exp $ */
 
1
/**     $MirOS: src/bin/mksh/setmode.c,v 1.8 2007/03/04 03:47:37 tg Exp $ */
 
2
/**     $miros: src/lib/libc/gen/setmode.c,v 1.8 2007/03/04 03:47:14 tg Exp $ */
2
3
/*      $OpenBSD: setmode.c,v 1.17 2005/08/08 08:05:34 espie Exp $      */
3
4
/*      $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $    */
4
5
 
34
35
 * SUCH DAMAGE.
35
36
 */
36
37
 
 
38
#if defined(HAVE_CONFIG_H) && (HAVE_CONFIG_H != 0)
 
39
/* usually when packaged with third-party software */
 
40
#ifdef CONFIG_H_FILENAME
 
41
#include CONFIG_H_FILENAME
 
42
#else
 
43
#include "config.h"
 
44
#endif
 
45
#endif
 
46
 
37
47
#include <sys/types.h>
38
48
#include <sys/stat.h>
39
49
 
48
58
#endif
49
59
 
50
60
__SCCSID("@(#)setmode.c 8.2 (Berkeley) 3/25/94");
51
 
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.3 2006/08/01 13:43:28 tg Exp $");
 
61
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.8 2007/03/04 03:47:37 tg Exp $");
 
62
 
 
63
/* for mksh */
 
64
#ifdef ksh_isdigit
 
65
#undef isdigit
 
66
#define isdigit ksh_isdigit
 
67
#endif
52
68
 
53
69
#define SET_LEN 6               /* initial # of bitcmd struct to malloc */
54
70
#define SET_LEN_INCR 4          /* # of bitcmd structs to add as needed */
169
185
        int perm, who;
170
186
        char op, *ep;
171
187
        BITCMD *set, *saveset, *endset;
172
 
        sigset_t sigset, sigoset;
 
188
        sigset_t signset, sigoset;
173
189
        mode_t mask;
174
190
        int equalopdone = 0, permXbits, setlen;
175
191
        u_long perml;
183
199
         * the caller is opening files inside a signal handler, protect them
184
200
         * as best we can.
185
201
         */
186
 
        sigfillset(&sigset);
187
 
        (void)sigprocmask(SIG_BLOCK, &sigset, &sigoset);
 
202
        sigfillset(&signset);
 
203
        (void)sigprocmask(SIG_BLOCK, &signset, &sigoset);
188
204
        (void)umask(mask = umask(0));
189
205
        mask = ~mask;
190
206
        (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);