~ubuntu-branches/ubuntu/precise/ncurses/precise

« back to all changes in this revision

Viewing changes to progs/tset.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2008-11-11 16:40:32 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20081111164032-dudxd0hy2im0f2bj
Tags: 5.7-2ubuntu1
* Merge from debian unstable, remaining changes:
  - On amd64, use /{,usr/}lib32 instead of /emul/ia32-linux/.
  - Link using -Bsymbolic-functions.
  - Don't install the upstream changelog in the runtime library packages.

* Install wide-character patches into /{,usr/}lib32 as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
 
 * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
 
2
 * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
3
3
 *                                                                          *
4
4
 * Permission is hereby granted, free of charge, to any person obtaining a  *
5
5
 * copy of this software and associated documentation files (the            *
89
89
char *ttyname(int fd);
90
90
#endif
91
91
 
92
 
/* this is just to stifle a missing-prototype warning */
93
 
#ifdef linux
94
 
# include <sys/ioctl.h>
 
92
#if HAVE_SIZECHANGE
 
93
# if !defined(sun) || !TERMIOS
 
94
#  if HAVE_SYS_IOCTL_H
 
95
#   include <sys/ioctl.h>
 
96
#  endif
 
97
# endif
95
98
#endif
96
99
 
97
100
#if NEED_PTEM_H
104
107
#include <dump_entry.h>
105
108
#include <transform.h>
106
109
 
107
 
MODULE_ID("$Id: tset.c,v 1.70 2007/10/13 22:22:04 tom Exp $")
 
110
MODULE_ID("$Id: tset.c,v 1.76 2008/10/11 19:26:19 tom Exp $")
 
111
 
 
112
/*
 
113
 * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
 
114
 * Solaris, IRIX) define TIOCGWINSZ and struct winsize.
 
115
 */
 
116
#ifdef TIOCGSIZE
 
117
# define IOCTL_GET_WINSIZE TIOCGSIZE
 
118
# define IOCTL_SET_WINSIZE TIOCSSIZE
 
119
# define STRUCT_WINSIZE struct ttysize
 
120
# define WINSIZE_ROWS(n) n.ts_lines
 
121
# define WINSIZE_COLS(n) n.ts_cols
 
122
#else
 
123
# ifdef TIOCGWINSZ
 
124
#  define IOCTL_GET_WINSIZE TIOCGWINSZ
 
125
#  define IOCTL_SET_WINSIZE TIOCSWINSZ
 
126
#  define STRUCT_WINSIZE struct winsize
 
127
#  define WINSIZE_ROWS(n) n.ws_row
 
128
#  define WINSIZE_COLS(n) n.ws_col
 
129
# endif
 
130
#endif
108
131
 
109
132
extern char **environ;
110
133
 
168
191
    char temp[BUFSIZ];
169
192
    unsigned len = strlen(_nc_progname) + 2;
170
193
 
171
 
    if (len < sizeof(temp) - 12) {
 
194
    if ((int) len < (int) sizeof(temp) - 12) {
172
195
        strcpy(temp, _nc_progname);
173
196
        strcat(temp, ": ");
174
197
    } else {
440
463
        mapp->conditional = ~mapp->conditional & (EQ | GT | LT);
441
464
 
442
465
    /* If user specified a port with an option flag, set it. */
443
 
  done:if (port) {
444
 
        if (mapp->porttype)
445
 
          badmopt:err("illegal -m option format: %s", copy);
 
466
  done:
 
467
    if (port) {
 
468
        if (mapp->porttype) {
 
469
          badmopt:
 
470
            err("illegal -m option format: %s", copy);
 
471
        }
446
472
        mapp->porttype = port;
447
473
    }
 
474
    free(copy);
448
475
#ifdef MAPDEBUG
449
476
    (void) printf("port: %s\n", mapp->porttype ? mapp->porttype : "ANY");
450
477
    (void) printf("type: %s\n", mapp->type);
780
807
#ifdef NLDLY
781
808
                      | NLDLY
782
809
#endif
783
 
#ifdef CRDLY 
 
810
#ifdef CRDLY
784
811
                      | CRDLY
785
812
#endif
786
 
#ifdef TABDLY 
 
813
#ifdef TABDLY
787
814
                      | TABDLY
788
815
#endif
789
 
#ifdef BSDLY 
 
816
#ifdef BSDLY
790
817
                      | BSDLY
791
818
#endif
792
 
#ifdef VTDLY 
 
819
#ifdef VTDLY
793
820
                      | VTDLY
794
821
#endif
795
822
#ifdef FFDLY
863
890
{
864
891
#ifdef TERMIOS
865
892
    if (DISABLED(mode.c_cc[VERASE]) || terasechar >= 0)
866
 
        mode.c_cc[VERASE] = terasechar >= 0 ? terasechar : default_erase();
 
893
        mode.c_cc[VERASE] = (terasechar >= 0) ? terasechar : default_erase();
867
894
 
868
895
    if (DISABLED(mode.c_cc[VINTR]) || intrchar >= 0)
869
 
        mode.c_cc[VINTR] = intrchar >= 0 ? intrchar : CINTR;
 
896
        mode.c_cc[VINTR] = (intrchar >= 0) ? intrchar : CINTR;
870
897
 
871
898
    if (DISABLED(mode.c_cc[VKILL]) || tkillchar >= 0)
872
 
        mode.c_cc[VKILL] = tkillchar >= 0 ? tkillchar : CKILL;
 
899
        mode.c_cc[VKILL] = (tkillchar >= 0) ? tkillchar : CKILL;
873
900
#endif
874
901
}
875
902
 
1128
1155
static char
1129
1156
arg_to_char(void)
1130
1157
{
1131
 
    return (optarg[0] == '^' && optarg[1] != '\0')
1132
 
        ? ((optarg[1] == '?') ? '\177' : CTRL(optarg[1]))
1133
 
        : optarg[0];
 
1158
    return (char) ((optarg[0] == '^' && optarg[1] != '\0')
 
1159
                   ? ((optarg[1] == '?') ? '\177' : CTRL(optarg[1]))
 
1160
                   : optarg[0]);
1134
1161
}
1135
1162
 
1136
1163
int
1137
1164
main(int argc, char **argv)
1138
1165
{
1139
 
#if defined(TIOCGWINSZ) && defined(TIOCSWINSZ)
1140
 
    struct winsize win;
1141
 
#endif
1142
1166
    int ch, noinit, noset, quiet, Sflag, sflag, showterm;
1143
1167
    const char *p;
1144
1168
    const char *ttype;
1218
1242
    can_restore = TRUE;
1219
1243
    original = oldmode = mode;
1220
1244
#ifdef TERMIOS
1221
 
    ospeed = cfgetospeed(&mode);
 
1245
    ospeed = (NCURSES_OSPEED) cfgetospeed(&mode);
1222
1246
#else
1223
 
    ospeed = mode.sg_ospeed;
 
1247
    ospeed = (NCURSES_OSPEED) mode.sg_ospeed;
1224
1248
#endif
1225
1249
 
1226
1250
    if (!strcmp(_nc_progname, PROG_RESET)) {
1234
1258
        tcolumns = columns;
1235
1259
        tlines = lines;
1236
1260
 
1237
 
#if defined(TIOCGWINSZ) && defined(TIOCSWINSZ)
 
1261
#if HAVE_SIZECHANGE
1238
1262
        if (opt_w) {
1239
 
            /* Set window size */
1240
 
            (void) ioctl(STDERR_FILENO, TIOCGWINSZ, &win);
1241
 
            if (win.ws_row == 0 && win.ws_col == 0 &&
 
1263
            STRUCT_WINSIZE win;
 
1264
            /* Set window size if not set already */
 
1265
            (void) ioctl(STDERR_FILENO, IOCTL_GET_WINSIZE, &win);
 
1266
            if (WINSIZE_ROWS(win) == 0 &&
 
1267
                WINSIZE_COLS(win) == 0 &&
1242
1268
                tlines > 0 && tcolumns > 0) {
1243
 
                win.ws_row = tlines;
1244
 
                win.ws_col = tcolumns;
1245
 
                (void) ioctl(STDERR_FILENO, TIOCSWINSZ, &win);
 
1269
                WINSIZE_ROWS(win) = tlines;
 
1270
                WINSIZE_COLS(win) = tcolumns;
 
1271
                (void) ioctl(STDERR_FILENO, IOCTL_SET_WINSIZE, &win);
1246
1272
            }
1247
1273
        }
1248
1274
#endif
1293
1319
         * environmental variable SHELL ending in "csh".
1294
1320
         */
1295
1321
        if ((var = getenv("SHELL")) != 0
1296
 
            && ((len = strlen(leaf = _nc_basename(var))) >= 3)
 
1322
            && ((len = (int) strlen(leaf = _nc_basename(var))) >= 3)
1297
1323
            && !strcmp(leaf + len - 3, "csh"))
1298
1324
            p = "set noglob;\nsetenv TERM %s;\nunset noglob;\n";
1299
1325
        else