~ubuntu-branches/ubuntu/trusty/kbd/trusty

« back to all changes in this revision

Viewing changes to src/loadkeys.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2013-02-18 13:25:55 UTC
  • mfrom: (1.1.22 sid)
  • Revision ID: package-import@ubuntu.com-20130218132555-9aiwvswlo12fo32s
Tags: 1.15.5-1ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Add setfont, kbd_mode, and loadkeys to initramfs for console-setup.
  - Use ckbcomp to get the keyboard layout if other data files are not
    available.
  - Depend on console-setup, and remove config file; we now only support
    systems using console-setup and so it no longer serves a purpose. The
    removed config file for console-screen has changed names from
    /etc/init.d/console-screen.kbd.sh to /etc/init.d/kbd.
  - Change loadkeys to find any console not in raw mode when invoked
    without an explicit console parameter, in case the foreground console
    is in raw mode.
  - Simplify maintainer scripts for conffile removal, using new features
    in debhelper 8.1.0.
  - Add setvtrgb to kbd-udeb.
* Fix incorrect keymap sanity check in loadkeys_ckbcomp.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* A Bison parser, made by GNU Bison 2.4.3.  */
 
1
/* A Bison parser, made by GNU Bison 2.6.4.  */
2
2
 
3
 
/* Skeleton implementation for Bison's Yacc-like parsers in C
 
3
/* Bison implementation for Yacc-like parsers in C
4
4
   
5
 
      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6
 
   2009, 2010 Free Software Foundation, Inc.
 
5
      Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
7
6
   
8
7
   This program is free software: you can redistribute it and/or modify
9
8
   it under the terms of the GNU General Public License as published by
45
44
#define YYBISON 1
46
45
 
47
46
/* Bison version.  */
48
 
#define YYBISON_VERSION "2.4.3"
 
47
#define YYBISON_VERSION "2.6.4"
49
48
 
50
49
/* Skeleton name.  */
51
50
#define YYSKELETON_NAME "yacc.c"
59
58
/* Pull parsers.  */
60
59
#define YYPULL 1
61
60
 
62
 
/* Using locations.  */
63
 
#define YYLSP_NEEDED 0
64
61
 
65
62
 
66
63
 
67
64
/* Copy the first part of user declarations.  */
68
 
 
69
 
/* Line 189 of yacc.c  */
 
65
/* Line 358 of yacc.c  */
70
66
#line 12 "loadkeys.y"
71
67
 
 
68
#define YY_HEADER_EXPORT_START_CONDITIONS 1
 
69
 
72
70
#include <errno.h>
73
71
#include <stdio.h>
74
72
#include <getopt.h>
92
90
#include "nls.h"
93
91
#include "version.h"
94
92
 
 
93
#include "loadkeys.analyze.h"
 
94
 
95
95
#define U(x) ((x) ^ 0xf000)
96
96
 
97
97
#ifdef KDSKBDIACRUC
142
142
extern int prefer_unicode;
143
143
 
144
144
#include "ksyms.h"
145
 
int yylex(void);
146
145
 
147
146
static void attr_noreturn usage(void)
148
147
{
155
154
                          "  -a --ascii         force conversion to ASCII\n"
156
155
                          "  -b --bkeymap       output a binary keymap to stdout\n"
157
156
                          "  -c --clearcompose  clear kernel compose table\n"
158
 
                          "  -C <cons1,cons2,...> --console=<cons1,cons2,...>\n"
159
 
                          "                     the console device(s) to be used\n"
 
157
                          "  -C --console=file\n"
 
158
                          "                     the console device to be used\n"
160
159
                          "  -d --default       load \"%s\"\n"
161
160
                          "  -h --help          display this help text\n"
162
161
                          "  -m --mktable       output a \"defkeymap.c\" to stdout\n"
411
410
                                                        j, (key_map[i])[j]);
412
411
                                }
413
412
                        }
414
 
                        xfree(key_map[i]);
415
 
                        xfree(keymap_was_set[i]);
416
413
 
417
414
                } else if (keymaps_line_seen && !defining[i]) {
418
415
                        /* deallocate keymap */
464
461
        return ct;
465
462
}
466
463
 
 
464
static void freekeys(void)
 
465
{
 
466
        int i;
 
467
        for (i = 0; i < MAX_NR_KEYMAPS; i++) {
 
468
                xfree(keymap_was_set[i]);
 
469
                xfree(key_map[i]);
 
470
        }
 
471
}
 
472
 
467
473
static char *ostr(char *s)
468
474
{
469
475
        int lth = strlen(s);
494
500
static int deffuncs(int fd)
495
501
{
496
502
        int i, ct = 0;
497
 
        char *ptr;
 
503
        char *ptr, *s;
498
504
 
499
505
        for (i = 0; i < MAX_NR_FUNC; i++) {
500
506
                kbs_buf.kb_func = i;
501
507
 
502
508
                if ((ptr = func_table[i])) {
503
509
                        strcpy((char *)kbs_buf.kb_string, ptr);
504
 
                        if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs_buf))
 
510
                        if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs_buf)) {
 
511
                                s = ostr((char *)kbs_buf.kb_string);
505
512
                                fprintf(stderr,
506
513
                                        _("failed to bind string '%s' to function %s\n"),
507
 
                                        ostr((char *)kbs_buf.kb_string),
508
 
                                        syms[KT_FN].table[kbs_buf.kb_func]);
509
 
                        else
 
514
                                        s, syms[KT_FN].table[kbs_buf.kb_func]);
 
515
                                xfree(s);
 
516
                        } else {
510
517
                                ct++;
 
518
                        }
511
519
                } else if (opts) {
512
520
                        kbs_buf.kb_string[0] = 0;
513
 
                        if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs_buf))
 
521
                        if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs_buf)) {
514
522
                                fprintf(stderr, _("failed to clear string %s\n"),
515
523
                                        syms[KT_FN].table[kbs_buf.kb_func]);
516
 
                        else
 
524
                        } else {
517
525
                                ct++;
 
526
                        }
518
527
                }
519
528
        }
520
529
        return ct;
631
640
        }
632
641
}
633
642
 
634
 
static void loadkeys(char *console, int kbd_mode)
 
643
static void loadkeys(int fd, int kbd_mode)
635
644
{
636
 
        int fd;
637
645
        int keyct, funcct, diacct = 0;
638
646
 
639
 
        fd = getfd(console);
640
647
        keyct = defkeys(fd, kbd_mode);
641
648
        funcct = deffuncs(fd);
642
649
 
657
664
        } else if (verbose) {
658
665
                printf(_("(No change in compose definitions.)\n"));
659
666
        }
 
667
 
 
668
        freekeys();
660
669
}
661
670
 
662
671
static void strings_as_usual(void)
897
906
        }
898
907
        printf("unsigned int accent_table_size = %d;\n", accent_table_size);
899
908
 
 
909
        freekeys();
 
910
 
900
911
        exit(0);
901
912
}
902
913
 
924
935
                        }
925
936
                }
926
937
        }
 
938
        freekeys();
927
939
        exit(0);
928
940
 
929
941
 fail:  fprintf(stderr, _("Error writing map to file\n"));
 
942
        freekeys();
930
943
        exit(1);
931
944
}
932
945
 
933
946
 
934
 
 
935
 
/* Line 189 of yacc.c  */
936
 
#line 937 "loadkeys.c"
937
 
 
938
 
/* Enabling traces.  */
939
 
#ifndef YYDEBUG
940
 
# define YYDEBUG 0
941
 
#endif
 
947
/* Line 358 of yacc.c  */
 
948
#line 949 "loadkeys.c"
 
949
 
 
950
# ifndef YY_NULL
 
951
#  if defined __cplusplus && 201103L <= __cplusplus
 
952
#   define YY_NULL nullptr
 
953
#  else
 
954
#   define YY_NULL 0
 
955
#  endif
 
956
# endif
942
957
 
943
958
/* Enabling verbose error messages.  */
944
959
#ifdef YYERROR_VERBOSE
948
963
# define YYERROR_VERBOSE 0
949
964
#endif
950
965
 
951
 
/* Enabling the token table.  */
952
 
#ifndef YYTOKEN_TABLE
953
 
# define YYTOKEN_TABLE 0
954
 
#endif
955
 
 
 
966
/* In a future release of Bison, this section will be replaced
 
967
   by #include "y.tab.h".  */
 
968
#ifndef YY_YY_Y_TAB_H_INCLUDED
 
969
# define YY_YY_Y_TAB_H_INCLUDED
 
970
/* Enabling traces.  */
 
971
#ifndef YYDEBUG
 
972
# define YYDEBUG 0
 
973
#endif
 
974
#if YYDEBUG
 
975
extern int yydebug;
 
976
#endif
956
977
 
957
978
/* Tokens.  */
958
979
#ifndef YYTOKENTYPE
1032
1053
 
1033
1054
 
1034
1055
 
1035
 
 
1036
1056
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1037
1057
typedef int YYSTYPE;
1038
1058
# define YYSTYPE_IS_TRIVIAL 1
1040
1060
# define YYSTYPE_IS_DECLARED 1
1041
1061
#endif
1042
1062
 
 
1063
extern YYSTYPE yylval;
 
1064
 
 
1065
#ifdef YYPARSE_PARAM
 
1066
#if defined __STDC__ || defined __cplusplus
 
1067
int yyparse (void *YYPARSE_PARAM);
 
1068
#else
 
1069
int yyparse ();
 
1070
#endif
 
1071
#else /* ! YYPARSE_PARAM */
 
1072
#if defined __STDC__ || defined __cplusplus
 
1073
int yyparse (void);
 
1074
#else
 
1075
int yyparse ();
 
1076
#endif
 
1077
#endif /* ! YYPARSE_PARAM */
 
1078
 
 
1079
#endif /* !YY_YY_Y_TAB_H_INCLUDED  */
1043
1080
 
1044
1081
/* Copy the second part of user declarations.  */
1045
1082
 
1046
 
 
1047
 
/* Line 264 of yacc.c  */
1048
 
#line 1049 "loadkeys.c"
 
1083
/* Line 377 of yacc.c  */
 
1084
#line 1085 "loadkeys.c"
1049
1085
 
1050
1086
#ifdef short
1051
1087
# undef short
1098
1134
# if defined YYENABLE_NLS && YYENABLE_NLS
1099
1135
#  if ENABLE_NLS
1100
1136
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1101
 
#   define YY_(msgid) dgettext ("bison-runtime", msgid)
 
1137
#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
1102
1138
#  endif
1103
1139
# endif
1104
1140
# ifndef YY_
1105
 
#  define YY_(msgid) msgid
 
1141
#  define YY_(Msgid) Msgid
1106
1142
# endif
1107
1143
#endif
1108
1144
 
1109
1145
/* Suppress unused-variable warnings by "using" E.  */
1110
1146
#if ! defined lint || defined __GNUC__
1111
 
# define YYUSE(e) ((void) (e))
 
1147
# define YYUSE(E) ((void) (E))
1112
1148
#else
1113
 
# define YYUSE(e) /* empty */
 
1149
# define YYUSE(E) /* empty */
1114
1150
#endif
1115
1151
 
1116
1152
/* Identity function, used to suppress warnings about constant conditions.  */
1117
1153
#ifndef lint
1118
 
# define YYID(n) (n)
 
1154
# define YYID(N) (N)
1119
1155
#else
1120
1156
#if (defined __STDC__ || defined __C99__FUNC__ \
1121
1157
     || defined __cplusplus || defined _MSC_VER)
1148
1184
#    define alloca _alloca
1149
1185
#   else
1150
1186
#    define YYSTACK_ALLOC alloca
1151
 
#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
 
1187
#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
1152
1188
     || defined __cplusplus || defined _MSC_VER)
1153
1189
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1154
 
#     ifndef _STDLIB_H
1155
 
#      define _STDLIB_H 1
 
1190
      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
 
1191
#     ifndef EXIT_SUCCESS
 
1192
#      define EXIT_SUCCESS 0
1156
1193
#     endif
1157
1194
#    endif
1158
1195
#   endif
1175
1212
#  ifndef YYSTACK_ALLOC_MAXIMUM
1176
1213
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1177
1214
#  endif
1178
 
#  if (defined __cplusplus && ! defined _STDLIB_H \
 
1215
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
1179
1216
       && ! ((defined YYMALLOC || defined malloc) \
1180
1217
             && (defined YYFREE || defined free)))
1181
1218
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1182
 
#   ifndef _STDLIB_H
1183
 
#    define _STDLIB_H 1
 
1219
#   ifndef EXIT_SUCCESS
 
1220
#    define EXIT_SUCCESS 0
1184
1221
#   endif
1185
1222
#  endif
1186
1223
#  ifndef YYMALLOC
1187
1224
#   define YYMALLOC malloc
1188
 
#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
 
1225
#   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
1189
1226
     || defined __cplusplus || defined _MSC_VER)
1190
1227
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1191
1228
#   endif
1192
1229
#  endif
1193
1230
#  ifndef YYFREE
1194
1231
#   define YYFREE free
1195
 
#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
 
1232
#   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
1196
1233
     || defined __cplusplus || defined _MSC_VER)
1197
1234
void free (void *); /* INFRINGES ON USER NAME SPACE */
1198
1235
#   endif
1221
1258
     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1222
1259
      + YYSTACK_GAP_MAXIMUM)
1223
1260
 
1224
 
/* Copy COUNT objects from FROM to TO.  The source and destination do
1225
 
   not overlap.  */
1226
 
# ifndef YYCOPY
1227
 
#  if defined __GNUC__ && 1 < __GNUC__
1228
 
#   define YYCOPY(To, From, Count) \
1229
 
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1230
 
#  else
1231
 
#   define YYCOPY(To, From, Count)              \
1232
 
      do                                        \
1233
 
        {                                       \
1234
 
          YYSIZE_T yyi;                         \
1235
 
          for (yyi = 0; yyi < (Count); yyi++)   \
1236
 
            (To)[yyi] = (From)[yyi];            \
1237
 
        }                                       \
1238
 
      while (YYID (0))
1239
 
#  endif
1240
 
# endif
 
1261
# define YYCOPY_NEEDED 1
1241
1262
 
1242
1263
/* Relocate STACK from its old location to the new one.  The
1243
1264
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
1257
1278
 
1258
1279
#endif
1259
1280
 
 
1281
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
 
1282
/* Copy COUNT objects from SRC to DST.  The source and destination do
 
1283
   not overlap.  */
 
1284
# ifndef YYCOPY
 
1285
#  if defined __GNUC__ && 1 < __GNUC__
 
1286
#   define YYCOPY(Dst, Src, Count) \
 
1287
      __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
 
1288
#  else
 
1289
#   define YYCOPY(Dst, Src, Count)              \
 
1290
      do                                        \
 
1291
        {                                       \
 
1292
          YYSIZE_T yyi;                         \
 
1293
          for (yyi = 0; yyi < (Count); yyi++)   \
 
1294
            (Dst)[yyi] = (Src)[yyi];            \
 
1295
        }                                       \
 
1296
      while (YYID (0))
 
1297
#  endif
 
1298
# endif
 
1299
#endif /* !YYCOPY_NEEDED */
 
1300
 
1260
1301
/* YYFINAL -- State number of the termination state.  */
1261
1302
#define YYFINAL  2
1262
1303
/* YYLAST -- Last index in YYTABLE.  */
1350
1391
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
1351
1392
static const yytype_uint16 yyrline[] =
1352
1393
{
1353
 
       0,   877,   877,   878,   880,   881,   882,   883,   884,   885,
1354
 
     886,   887,   888,   889,   891,   896,   901,   906,   910,   915,
1355
 
     920,   921,   923,   929,   934,   943,   947,   952,   953,   955,
1356
 
     955,   962,   967,   968,   970,   971,   972,   973,   974,   975,
1357
 
     976,   977,   978,   980,  1019,  1020,  1022,  1029,  1030,  1031,
1358
 
    1032,  1033,  1034
 
1394
       0,   894,   894,   895,   897,   898,   899,   900,   901,   902,
 
1395
     903,   904,   905,   906,   908,   913,   918,   923,   927,   932,
 
1396
     937,   938,   940,   946,   951,   960,   964,   969,   970,   972,
 
1397
     972,   979,   984,   985,   987,   988,   989,   990,   991,   992,
 
1398
     993,   994,   995,   997,  1036,  1037,  1039,  1046,  1047,  1048,
 
1399
    1049,  1050,  1051
1359
1400
};
1360
1401
#endif
1361
1402
 
1362
 
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
 
1403
#if YYDEBUG || YYERROR_VERBOSE || 0
1363
1404
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1364
1405
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
1365
1406
static const char *const yytname[] =
1372
1413
  "$accept", "keytable", "line", "charsetline", "altismetaline",
1373
1414
  "usualstringsline", "usualcomposeline", "keymapline", "range", "range0",
1374
1415
  "strline", "compline", "compsym", "singleline", "$@1", "modifiers",
1375
 
  "modifier", "fullline", "rvalue0", "rvalue1", "rvalue", 0
 
1416
  "modifier", "fullline", "rvalue0", "rvalue1", "rvalue", YY_NULL
1376
1417
};
1377
1418
#endif
1378
1419
 
1410
1451
       2,     1,     2
1411
1452
};
1412
1453
 
1413
 
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1414
 
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
 
1454
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
 
1455
   Performed when YYTABLE doesn't specify something else to do.  Zero
1415
1456
   means the default is an error.  */
1416
1457
static const yytype_uint8 yydefact[] =
1417
1458
{
1462
1503
 
1463
1504
/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
1464
1505
   positive, shift that token.  If negative, reduce the rule which
1465
 
   number is the opposite.  If zero, do what YYDEFACT says.
1466
 
   If YYTABLE_NINF, syntax error.  */
 
1506
   number is the opposite.  If YYTABLE_NINF, syntax error.  */
1467
1507
#define YYTABLE_NINF -1
1468
1508
static const yytype_uint8 yytable[] =
1469
1509
{
1478
1518
      86,    89,    90,    92,    58,    79,    60
1479
1519
};
1480
1520
 
 
1521
#define yypact_value_is_default(Yystate) \
 
1522
  (!!((Yystate) == (-49)))
 
1523
 
 
1524
#define yytable_value_is_error(Yytable_value) \
 
1525
  YYID (0)
 
1526
 
1481
1527
static const yytype_uint8 yycheck[] =
1482
1528
{
1483
1529
      33,     3,    23,     4,     0,     4,     5,     3,     3,     3,
1534
1580
 
1535
1581
#define YYRECOVERING()  (!!yyerrstatus)
1536
1582
 
1537
 
#define YYBACKUP(Token, Value)                                  \
1538
 
do                                                              \
1539
 
  if (yychar == YYEMPTY && yylen == 1)                          \
1540
 
    {                                                           \
1541
 
      yychar = (Token);                                         \
1542
 
      yylval = (Value);                                         \
1543
 
      yytoken = YYTRANSLATE (yychar);                           \
1544
 
      YYPOPSTACK (1);                                           \
1545
 
      goto yybackup;                                            \
1546
 
    }                                                           \
1547
 
  else                                                          \
1548
 
    {                                                           \
 
1583
#define YYBACKUP(Token, Value)                                  \
 
1584
do                                                              \
 
1585
  if (yychar == YYEMPTY)                                        \
 
1586
    {                                                           \
 
1587
      yychar = (Token);                                         \
 
1588
      yylval = (Value);                                         \
 
1589
      YYPOPSTACK (yylen);                                       \
 
1590
      yystate = *yyssp;                                         \
 
1591
      goto yybackup;                                            \
 
1592
    }                                                           \
 
1593
  else                                                          \
 
1594
    {                                                           \
1549
1595
      yyerror (YY_("syntax error: cannot back up")); \
1550
1596
      YYERROR;                                                  \
1551
1597
    }                                                           \
1555
1601
#define YYTERROR        1
1556
1602
#define YYERRCODE       256
1557
1603
 
1558
 
 
1559
1604
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1560
1605
   If N is 0, then set CURRENT to the empty location which ends
1561
1606
   the previous symbol: RHS[0] (always defined).  */
1562
1607
 
 
1608
#ifndef YYLLOC_DEFAULT
 
1609
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
 
1610
    do                                                                  \
 
1611
      if (YYID (N))                                                     \
 
1612
        {                                                               \
 
1613
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
 
1614
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
 
1615
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
 
1616
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
 
1617
        }                                                               \
 
1618
      else                                                              \
 
1619
        {                                                               \
 
1620
          (Current).first_line   = (Current).last_line   =              \
 
1621
            YYRHSLOC (Rhs, 0).last_line;                                \
 
1622
          (Current).first_column = (Current).last_column =              \
 
1623
            YYRHSLOC (Rhs, 0).last_column;                              \
 
1624
        }                                                               \
 
1625
    while (YYID (0))
 
1626
#endif
 
1627
 
1563
1628
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
1564
 
#ifndef YYLLOC_DEFAULT
1565
 
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
1566
 
    do                                                                  \
1567
 
      if (YYID (N))                                                    \
1568
 
        {                                                               \
1569
 
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
1570
 
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
1571
 
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
1572
 
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
1573
 
        }                                                               \
1574
 
      else                                                              \
1575
 
        {                                                               \
1576
 
          (Current).first_line   = (Current).last_line   =              \
1577
 
            YYRHSLOC (Rhs, 0).last_line;                                \
1578
 
          (Current).first_column = (Current).last_column =              \
1579
 
            YYRHSLOC (Rhs, 0).last_column;                              \
1580
 
        }                                                               \
1581
 
    while (YYID (0))
1582
 
#endif
1583
 
 
1584
 
 
1585
 
/* YY_LOCATION_PRINT -- Print the location on the stream.
1586
 
   This macro was not mandated originally: define only if we know
1587
 
   we won't break user code: when these are the locations we know.  */
 
1629
 
 
1630
 
 
1631
 
 
1632
/* This macro is provided for backward compatibility. */
1588
1633
 
1589
1634
#ifndef YY_LOCATION_PRINT
1590
 
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1591
 
#  define YY_LOCATION_PRINT(File, Loc)                  \
1592
 
     fprintf (File, "%d.%d-%d.%d",                      \
1593
 
              (Loc).first_line, (Loc).first_column,     \
1594
 
              (Loc).last_line,  (Loc).last_column)
1595
 
# else
1596
 
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1597
 
# endif
 
1635
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1598
1636
#endif
1599
1637
 
1600
1638
 
1649
1687
    YYSTYPE const * const yyvaluep;
1650
1688
#endif
1651
1689
{
 
1690
  FILE *yyo = yyoutput;
 
1691
  YYUSE (yyo);
1652
1692
  if (!yyvaluep)
1653
1693
    return;
1654
1694
# ifdef YYPRINT
1786
1826
# define YYMAXDEPTH 10000
1787
1827
#endif
1788
1828
 
1789
 
 
1790
1829
 
1791
1830
#if YYERROR_VERBOSE
1792
1831
 
1889
1928
}
1890
1929
# endif
1891
1930
 
1892
 
/* Copy into YYRESULT an error message about the unexpected token
1893
 
   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1894
 
   including the terminating null byte.  If YYRESULT is null, do not
1895
 
   copy anything; just return the number of bytes that would be
1896
 
   copied.  As a special case, return 0 if an ordinary "syntax error"
1897
 
   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1898
 
   size calculation.  */
1899
 
static YYSIZE_T
1900
 
yysyntax_error (char *yyresult, int yystate, int yychar)
 
1931
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
 
1932
   about the unexpected token YYTOKEN for the state stack whose top is
 
1933
   YYSSP.
 
1934
 
 
1935
   Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
 
1936
   not large enough to hold the message.  In that case, also set
 
1937
   *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
 
1938
   required number of bytes is too large to store.  */
 
1939
static int
 
1940
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
 
1941
                yytype_int16 *yyssp, int yytoken)
1901
1942
{
1902
 
  int yyn = yypact[yystate];
1903
 
 
1904
 
  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1905
 
    return 0;
1906
 
  else
1907
 
    {
1908
 
      int yytype = YYTRANSLATE (yychar);
1909
 
      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1910
 
      YYSIZE_T yysize = yysize0;
1911
 
      YYSIZE_T yysize1;
1912
 
      int yysize_overflow = 0;
1913
 
      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1914
 
      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1915
 
      int yyx;
1916
 
 
1917
 
# if 0
1918
 
      /* This is so xgettext sees the translatable formats that are
1919
 
         constructed on the fly.  */
1920
 
      YY_("syntax error, unexpected %s");
1921
 
      YY_("syntax error, unexpected %s, expecting %s");
1922
 
      YY_("syntax error, unexpected %s, expecting %s or %s");
1923
 
      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1924
 
      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1925
 
# endif
1926
 
      char *yyfmt;
1927
 
      char const *yyf;
1928
 
      static char const yyunexpected[] = "syntax error, unexpected %s";
1929
 
      static char const yyexpecting[] = ", expecting %s";
1930
 
      static char const yyor[] = " or %s";
1931
 
      char yyformat[sizeof yyunexpected
1932
 
                    + sizeof yyexpecting - 1
1933
 
                    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1934
 
                       * (sizeof yyor - 1))];
1935
 
      char const *yyprefix = yyexpecting;
1936
 
 
1937
 
      /* Start YYX at -YYN if negative to avoid negative indexes in
1938
 
         YYCHECK.  */
1939
 
      int yyxbegin = yyn < 0 ? -yyn : 0;
1940
 
 
1941
 
      /* Stay within bounds of both yycheck and yytname.  */
1942
 
      int yychecklim = YYLAST - yyn + 1;
1943
 
      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1944
 
      int yycount = 1;
1945
 
 
1946
 
      yyarg[0] = yytname[yytype];
1947
 
      yyfmt = yystpcpy (yyformat, yyunexpected);
1948
 
 
1949
 
      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1950
 
        if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1951
 
          {
1952
 
            if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1953
 
              {
1954
 
                yycount = 1;
1955
 
                yysize = yysize0;
1956
 
                yyformat[sizeof yyunexpected - 1] = '\0';
1957
 
                break;
1958
 
              }
1959
 
            yyarg[yycount++] = yytname[yyx];
1960
 
            yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1961
 
            yysize_overflow |= (yysize1 < yysize);
1962
 
            yysize = yysize1;
1963
 
            yyfmt = yystpcpy (yyfmt, yyprefix);
1964
 
            yyprefix = yyor;
1965
 
          }
1966
 
 
1967
 
      yyf = YY_(yyformat);
1968
 
      yysize1 = yysize + yystrlen (yyf);
1969
 
      yysize_overflow |= (yysize1 < yysize);
1970
 
      yysize = yysize1;
1971
 
 
1972
 
      if (yysize_overflow)
1973
 
        return YYSIZE_MAXIMUM;
1974
 
 
1975
 
      if (yyresult)
1976
 
        {
1977
 
          /* Avoid sprintf, as that infringes on the user's name space.
1978
 
             Don't have undefined behavior even if the translation
1979
 
             produced a string with the wrong number of "%s"s.  */
1980
 
          char *yyp = yyresult;
1981
 
          int yyi = 0;
1982
 
          while ((*yyp = *yyf) != '\0')
1983
 
            {
1984
 
              if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1985
 
                {
1986
 
                  yyp += yytnamerr (yyp, yyarg[yyi++]);
1987
 
                  yyf += 2;
1988
 
                }
1989
 
              else
1990
 
                {
1991
 
                  yyp++;
1992
 
                  yyf++;
1993
 
                }
1994
 
            }
1995
 
        }
1996
 
      return yysize;
1997
 
    }
 
1943
  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
 
1944
  YYSIZE_T yysize = yysize0;
 
1945
  YYSIZE_T yysize1;
 
1946
  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
 
1947
  /* Internationalized format string. */
 
1948
  const char *yyformat = YY_NULL;
 
1949
  /* Arguments of yyformat. */
 
1950
  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
 
1951
  /* Number of reported tokens (one for the "unexpected", one per
 
1952
     "expected"). */
 
1953
  int yycount = 0;
 
1954
 
 
1955
  /* There are many possibilities here to consider:
 
1956
     - Assume YYFAIL is not used.  It's too flawed to consider.  See
 
1957
       <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
 
1958
       for details.  YYERROR is fine as it does not invoke this
 
1959
       function.
 
1960
     - If this state is a consistent state with a default action, then
 
1961
       the only way this function was invoked is if the default action
 
1962
       is an error action.  In that case, don't check for expected
 
1963
       tokens because there are none.
 
1964
     - The only way there can be no lookahead present (in yychar) is if
 
1965
       this state is a consistent state with a default action.  Thus,
 
1966
       detecting the absence of a lookahead is sufficient to determine
 
1967
       that there is no unexpected or expected token to report.  In that
 
1968
       case, just report a simple "syntax error".
 
1969
     - Don't assume there isn't a lookahead just because this state is a
 
1970
       consistent state with a default action.  There might have been a
 
1971
       previous inconsistent state, consistent state with a non-default
 
1972
       action, or user semantic action that manipulated yychar.
 
1973
     - Of course, the expected token list depends on states to have
 
1974
       correct lookahead information, and it depends on the parser not
 
1975
       to perform extra reductions after fetching a lookahead from the
 
1976
       scanner and before detecting a syntax error.  Thus, state merging
 
1977
       (from LALR or IELR) and default reductions corrupt the expected
 
1978
       token list.  However, the list is correct for canonical LR with
 
1979
       one exception: it will still contain any token that will not be
 
1980
       accepted due to an error action in a later state.
 
1981
  */
 
1982
  if (yytoken != YYEMPTY)
 
1983
    {
 
1984
      int yyn = yypact[*yyssp];
 
1985
      yyarg[yycount++] = yytname[yytoken];
 
1986
      if (!yypact_value_is_default (yyn))
 
1987
        {
 
1988
          /* Start YYX at -YYN if negative to avoid negative indexes in
 
1989
             YYCHECK.  In other words, skip the first -YYN actions for
 
1990
             this state because they are default actions.  */
 
1991
          int yyxbegin = yyn < 0 ? -yyn : 0;
 
1992
          /* Stay within bounds of both yycheck and yytname.  */
 
1993
          int yychecklim = YYLAST - yyn + 1;
 
1994
          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
 
1995
          int yyx;
 
1996
 
 
1997
          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
 
1998
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
 
1999
                && !yytable_value_is_error (yytable[yyx + yyn]))
 
2000
              {
 
2001
                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
 
2002
                  {
 
2003
                    yycount = 1;
 
2004
                    yysize = yysize0;
 
2005
                    break;
 
2006
                  }
 
2007
                yyarg[yycount++] = yytname[yyx];
 
2008
                yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
 
2009
                if (! (yysize <= yysize1
 
2010
                       && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
 
2011
                  return 2;
 
2012
                yysize = yysize1;
 
2013
              }
 
2014
        }
 
2015
    }
 
2016
 
 
2017
  switch (yycount)
 
2018
    {
 
2019
# define YYCASE_(N, S)                      \
 
2020
      case N:                               \
 
2021
        yyformat = S;                       \
 
2022
      break
 
2023
      YYCASE_(0, YY_("syntax error"));
 
2024
      YYCASE_(1, YY_("syntax error, unexpected %s"));
 
2025
      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
 
2026
      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
 
2027
      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
 
2028
      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
 
2029
# undef YYCASE_
 
2030
    }
 
2031
 
 
2032
  yysize1 = yysize + yystrlen (yyformat);
 
2033
  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
 
2034
    return 2;
 
2035
  yysize = yysize1;
 
2036
 
 
2037
  if (*yymsg_alloc < yysize)
 
2038
    {
 
2039
      *yymsg_alloc = 2 * yysize;
 
2040
      if (! (yysize <= *yymsg_alloc
 
2041
             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
 
2042
        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
 
2043
      return 1;
 
2044
    }
 
2045
 
 
2046
  /* Avoid sprintf, as that infringes on the user's name space.
 
2047
     Don't have undefined behavior even if the translation
 
2048
     produced a string with the wrong number of "%s"s.  */
 
2049
  {
 
2050
    char *yyp = *yymsg;
 
2051
    int yyi = 0;
 
2052
    while ((*yyp = *yyformat) != '\0')
 
2053
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
 
2054
        {
 
2055
          yyp += yytnamerr (yyp, yyarg[yyi++]);
 
2056
          yyformat += 2;
 
2057
        }
 
2058
      else
 
2059
        {
 
2060
          yyp++;
 
2061
          yyformat++;
 
2062
        }
 
2063
  }
 
2064
  return 0;
1998
2065
}
1999
2066
#endif /* YYERROR_VERBOSE */
2000
 
 
2001
2067
 
2002
2068
/*-----------------------------------------------.
2003
2069
| Release the memory associated to this symbol.  |
2030
2096
    }
2031
2097
}
2032
2098
 
2033
 
/* Prevent warnings from -Wmissing-prototypes.  */
2034
 
#ifdef YYPARSE_PARAM
2035
 
#if defined __STDC__ || defined __cplusplus
2036
 
int yyparse (void *YYPARSE_PARAM);
2037
 
#else
2038
 
int yyparse ();
2039
 
#endif
2040
 
#else /* ! YYPARSE_PARAM */
2041
 
#if defined __STDC__ || defined __cplusplus
2042
 
int yyparse (void);
2043
 
#else
2044
 
int yyparse ();
2045
 
#endif
2046
 
#endif /* ! YYPARSE_PARAM */
 
2099
 
2047
2100
 
2048
2101
 
2049
2102
/* The lookahead symbol.  */
2050
2103
int yychar;
2051
2104
 
 
2105
 
 
2106
#ifndef YYLVAL_INITIALIZE
 
2107
# define YYLVAL_INITIALIZE()
 
2108
#endif
 
2109
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
 
2110
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
 
2111
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
 
2112
#endif
 
2113
 
2052
2114
/* The semantic value of the lookahead symbol.  */
2053
2115
YYSTYPE yylval;
2054
2116
 
2056
2118
int yynerrs;
2057
2119
 
2058
2120
 
2059
 
 
2060
 
/*-------------------------.
2061
 
| yyparse or yypush_parse.  |
2062
 
`-------------------------*/
 
2121
/*----------.
 
2122
| yyparse.  |
 
2123
`----------*/
2063
2124
 
2064
2125
#ifdef YYPARSE_PARAM
2065
2126
#if (defined __STDC__ || defined __C99__FUNC__ \
2083
2144
#endif
2084
2145
#endif
2085
2146
{
2086
 
 
2087
 
 
2088
2147
    int yystate;
2089
2148
    /* Number of tokens to shift before error messages enabled.  */
2090
2149
    int yyerrstatus;
2093
2152
       `yyss': related to states.
2094
2153
       `yyvs': related to semantic values.
2095
2154
 
2096
 
       Refer to the stacks thru separate pointers, to allow yyoverflow
 
2155
       Refer to the stacks through separate pointers, to allow yyoverflow
2097
2156
       to reallocate them elsewhere.  */
2098
2157
 
2099
2158
    /* The state stack.  */
2111
2170
  int yyn;
2112
2171
  int yyresult;
2113
2172
  /* Lookahead token as an internal (translated) token number.  */
2114
 
  int yytoken;
 
2173
  int yytoken = 0;
2115
2174
  /* The variables used to return semantic value and location from the
2116
2175
     action routines.  */
2117
2176
  YYSTYPE yyval;
2129
2188
     Keep to zero when no symbol should be popped.  */
2130
2189
  int yylen = 0;
2131
2190
 
2132
 
  yytoken = 0;
2133
2191
  yyss = yyssa;
2134
2192
  yyvs = yyvsa;
2135
2193
  yystacksize = YYINITDEPTH;
2148
2206
  yyssp = yyss;
2149
2207
  yyvsp = yyvs;
2150
2208
 
 
2209
  YYLVAL_INITIALIZE ();
2151
2210
  goto yysetstate;
2152
2211
 
2153
2212
/*------------------------------------------------------------.
2239
2298
 
2240
2299
  /* First try to decide what to do without reference to lookahead token.  */
2241
2300
  yyn = yypact[yystate];
2242
 
  if (yyn == YYPACT_NINF)
 
2301
  if (yypact_value_is_default (yyn))
2243
2302
    goto yydefault;
2244
2303
 
2245
2304
  /* Not known => get a lookahead token if don't already have one.  */
2270
2329
  yyn = yytable[yyn];
2271
2330
  if (yyn <= 0)
2272
2331
    {
2273
 
      if (yyn == 0 || yyn == YYTABLE_NINF)
2274
 
        goto yyerrlab;
 
2332
      if (yytable_value_is_error (yyn))
 
2333
        goto yyerrlab;
2275
2334
      yyn = -yyn;
2276
2335
      goto yyreduce;
2277
2336
    }
2288
2347
  yychar = YYEMPTY;
2289
2348
 
2290
2349
  yystate = yyn;
 
2350
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2291
2351
  *++yyvsp = yylval;
 
2352
  YY_IGNORE_MAYBE_UNINITIALIZED_END
2292
2353
 
2293
2354
  goto yynewstate;
2294
2355
 
2325
2386
  switch (yyn)
2326
2387
    {
2327
2388
        case 14:
2328
 
 
2329
 
/* Line 1464 of yacc.c  */
2330
 
#line 892 "loadkeys.y"
 
2389
/* Line 1813 of yacc.c  */
 
2390
#line 909 "loadkeys.y"
2331
2391
    {
2332
2392
                                set_charset((char *) kbs_buf.kb_string);
2333
2393
                        }
2334
2394
    break;
2335
2395
 
2336
2396
  case 15:
2337
 
 
2338
 
/* Line 1464 of yacc.c  */
2339
 
#line 897 "loadkeys.y"
 
2397
/* Line 1813 of yacc.c  */
 
2398
#line 914 "loadkeys.y"
2340
2399
    {
2341
2400
                                alt_is_meta = 1;
2342
2401
                        }
2343
2402
    break;
2344
2403
 
2345
2404
  case 16:
2346
 
 
2347
 
/* Line 1464 of yacc.c  */
2348
 
#line 902 "loadkeys.y"
 
2405
/* Line 1813 of yacc.c  */
 
2406
#line 919 "loadkeys.y"
2349
2407
    {
2350
2408
                                strings_as_usual();
2351
2409
                        }
2352
2410
    break;
2353
2411
 
2354
2412
  case 17:
2355
 
 
2356
 
/* Line 1464 of yacc.c  */
2357
 
#line 907 "loadkeys.y"
 
2413
/* Line 1813 of yacc.c  */
 
2414
#line 924 "loadkeys.y"
2358
2415
    {
2359
2416
                                compose_as_usual((char *) kbs_buf.kb_string);
2360
2417
                        }
2361
2418
    break;
2362
2419
 
2363
2420
  case 18:
2364
 
 
2365
 
/* Line 1464 of yacc.c  */
2366
 
#line 911 "loadkeys.y"
 
2421
/* Line 1813 of yacc.c  */
 
2422
#line 928 "loadkeys.y"
2367
2423
    {
2368
2424
                                compose_as_usual(0);
2369
2425
                        }
2370
2426
    break;
2371
2427
 
2372
2428
  case 19:
2373
 
 
2374
 
/* Line 1464 of yacc.c  */
2375
 
#line 916 "loadkeys.y"
 
2429
/* Line 1813 of yacc.c  */
 
2430
#line 933 "loadkeys.y"
2376
2431
    {
2377
2432
                                keymaps_line_seen = 1;
2378
2433
                        }
2379
2434
    break;
2380
2435
 
2381
2436
  case 22:
2382
 
 
2383
 
/* Line 1464 of yacc.c  */
2384
 
#line 924 "loadkeys.y"
 
2437
/* Line 1813 of yacc.c  */
 
2438
#line 941 "loadkeys.y"
2385
2439
    {
2386
2440
                                int i;
2387
2441
                                for (i = (yyvsp[(1) - (3)]); i <= (yyvsp[(3) - (3)]); i++)
2390
2444
    break;
2391
2445
 
2392
2446
  case 23:
2393
 
 
2394
 
/* Line 1464 of yacc.c  */
2395
 
#line 930 "loadkeys.y"
 
2447
/* Line 1813 of yacc.c  */
 
2448
#line 947 "loadkeys.y"
2396
2449
    {
2397
2450
                                addmap((yyvsp[(1) - (1)]),1);
2398
2451
                        }
2399
2452
    break;
2400
2453
 
2401
2454
  case 24:
2402
 
 
2403
 
/* Line 1464 of yacc.c  */
2404
 
#line 935 "loadkeys.y"
 
2455
/* Line 1813 of yacc.c  */
 
2456
#line 952 "loadkeys.y"
2405
2457
    {
2406
2458
                                if (KTYP((yyvsp[(2) - (5)])) != KT_FN)
2407
2459
                                        lkfatal(_("'%s' is not a function key symbol"),
2412
2464
    break;
2413
2465
 
2414
2466
  case 25:
2415
 
 
2416
 
/* Line 1464 of yacc.c  */
2417
 
#line 944 "loadkeys.y"
 
2467
/* Line 1813 of yacc.c  */
 
2468
#line 961 "loadkeys.y"
2418
2469
    {
2419
2470
                                compose((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
2420
2471
                        }
2421
2472
    break;
2422
2473
 
2423
2474
  case 26:
2424
 
 
2425
 
/* Line 1464 of yacc.c  */
2426
 
#line 948 "loadkeys.y"
 
2475
/* Line 1813 of yacc.c  */
 
2476
#line 965 "loadkeys.y"
2427
2477
    {
2428
2478
                                compose((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
2429
2479
                        }
2430
2480
    break;
2431
2481
 
2432
2482
  case 27:
2433
 
 
2434
 
/* Line 1464 of yacc.c  */
2435
 
#line 952 "loadkeys.y"
 
2483
/* Line 1813 of yacc.c  */
 
2484
#line 969 "loadkeys.y"
2436
2485
    {   (yyval) = (yyvsp[(1) - (1)]);           }
2437
2486
    break;
2438
2487
 
2439
2488
  case 28:
2440
 
 
2441
 
/* Line 1464 of yacc.c  */
2442
 
#line 953 "loadkeys.y"
 
2489
/* Line 1813 of yacc.c  */
 
2490
#line 970 "loadkeys.y"
2443
2491
    {   (yyval) = (yyvsp[(1) - (1)]) ^ 0xf000;  }
2444
2492
    break;
2445
2493
 
2446
2494
  case 29:
2447
 
 
2448
 
/* Line 1464 of yacc.c  */
2449
 
#line 955 "loadkeys.y"
 
2495
/* Line 1813 of yacc.c  */
 
2496
#line 972 "loadkeys.y"
2450
2497
    {
2451
2498
                                mod = 0;
2452
2499
                        }
2453
2500
    break;
2454
2501
 
2455
2502
  case 30:
2456
 
 
2457
 
/* Line 1464 of yacc.c  */
2458
 
#line 959 "loadkeys.y"
 
2503
/* Line 1813 of yacc.c  */
 
2504
#line 976 "loadkeys.y"
2459
2505
    {
2460
2506
                                addkey((yyvsp[(4) - (7)]), mod, (yyvsp[(6) - (7)]));
2461
2507
                        }
2462
2508
    break;
2463
2509
 
2464
2510
  case 31:
2465
 
 
2466
 
/* Line 1464 of yacc.c  */
2467
 
#line 963 "loadkeys.y"
 
2511
/* Line 1813 of yacc.c  */
 
2512
#line 980 "loadkeys.y"
2468
2513
    {
2469
2514
                                addkey((yyvsp[(3) - (6)]), 0, (yyvsp[(5) - (6)]));
2470
2515
                        }
2471
2516
    break;
2472
2517
 
2473
2518
  case 34:
2474
 
 
2475
 
/* Line 1464 of yacc.c  */
2476
 
#line 970 "loadkeys.y"
 
2519
/* Line 1813 of yacc.c  */
 
2520
#line 987 "loadkeys.y"
2477
2521
    { mod |= M_SHIFT;   }
2478
2522
    break;
2479
2523
 
2480
2524
  case 35:
2481
 
 
2482
 
/* Line 1464 of yacc.c  */
2483
 
#line 971 "loadkeys.y"
 
2525
/* Line 1813 of yacc.c  */
 
2526
#line 988 "loadkeys.y"
2484
2527
    { mod |= M_CTRL;    }
2485
2528
    break;
2486
2529
 
2487
2530
  case 36:
2488
 
 
2489
 
/* Line 1464 of yacc.c  */
2490
 
#line 972 "loadkeys.y"
 
2531
/* Line 1813 of yacc.c  */
 
2532
#line 989 "loadkeys.y"
2491
2533
    { mod |= M_ALT;             }
2492
2534
    break;
2493
2535
 
2494
2536
  case 37:
2495
 
 
2496
 
/* Line 1464 of yacc.c  */
2497
 
#line 973 "loadkeys.y"
 
2537
/* Line 1813 of yacc.c  */
 
2538
#line 990 "loadkeys.y"
2498
2539
    { mod |= M_ALTGR;   }
2499
2540
    break;
2500
2541
 
2501
2542
  case 38:
2502
 
 
2503
 
/* Line 1464 of yacc.c  */
2504
 
#line 974 "loadkeys.y"
 
2543
/* Line 1813 of yacc.c  */
 
2544
#line 991 "loadkeys.y"
2505
2545
    { mod |= M_SHIFTL;  }
2506
2546
    break;
2507
2547
 
2508
2548
  case 39:
2509
 
 
2510
 
/* Line 1464 of yacc.c  */
2511
 
#line 975 "loadkeys.y"
 
2549
/* Line 1813 of yacc.c  */
 
2550
#line 992 "loadkeys.y"
2512
2551
    { mod |= M_SHIFTR;  }
2513
2552
    break;
2514
2553
 
2515
2554
  case 40:
2516
 
 
2517
 
/* Line 1464 of yacc.c  */
2518
 
#line 976 "loadkeys.y"
 
2555
/* Line 1813 of yacc.c  */
 
2556
#line 993 "loadkeys.y"
2519
2557
    { mod |= M_CTRLL;   }
2520
2558
    break;
2521
2559
 
2522
2560
  case 41:
2523
 
 
2524
 
/* Line 1464 of yacc.c  */
2525
 
#line 977 "loadkeys.y"
 
2561
/* Line 1813 of yacc.c  */
 
2562
#line 994 "loadkeys.y"
2526
2563
    { mod |= M_CTRLR;   }
2527
2564
    break;
2528
2565
 
2529
2566
  case 42:
2530
 
 
2531
 
/* Line 1464 of yacc.c  */
2532
 
#line 978 "loadkeys.y"
 
2567
/* Line 1813 of yacc.c  */
 
2568
#line 995 "loadkeys.y"
2533
2569
    { mod |= M_CAPSSHIFT;       }
2534
2570
    break;
2535
2571
 
2536
2572
  case 43:
2537
 
 
2538
 
/* Line 1464 of yacc.c  */
2539
 
#line 981 "loadkeys.y"
 
2573
/* Line 1813 of yacc.c  */
 
2574
#line 998 "loadkeys.y"
2540
2575
    {
2541
2576
                                int i, j;
2542
2577
 
2576
2611
    break;
2577
2612
 
2578
2613
  case 46:
2579
 
 
2580
 
/* Line 1464 of yacc.c  */
2581
 
#line 1023 "loadkeys.y"
 
2614
/* Line 1813 of yacc.c  */
 
2615
#line 1040 "loadkeys.y"
2582
2616
    {
2583
2617
                                if (rvalct >= MAX_NR_KEYMAPS)
2584
2618
                                        lkfatal(_("too many key definitions on one line"));
2587
2621
    break;
2588
2622
 
2589
2623
  case 47:
2590
 
 
2591
 
/* Line 1464 of yacc.c  */
2592
 
#line 1029 "loadkeys.y"
 
2624
/* Line 1813 of yacc.c  */
 
2625
#line 1046 "loadkeys.y"
2593
2626
    { (yyval) = convert_code((yyvsp[(1) - (1)]), TO_AUTO);              }
2594
2627
    break;
2595
2628
 
2596
2629
  case 48:
2597
 
 
2598
 
/* Line 1464 of yacc.c  */
2599
 
#line 1030 "loadkeys.y"
 
2630
/* Line 1813 of yacc.c  */
 
2631
#line 1047 "loadkeys.y"
2600
2632
    { (yyval) = add_capslock((yyvsp[(2) - (2)]));                       }
2601
2633
    break;
2602
2634
 
2603
2635
  case 49:
2604
 
 
2605
 
/* Line 1464 of yacc.c  */
2606
 
#line 1031 "loadkeys.y"
 
2636
/* Line 1813 of yacc.c  */
 
2637
#line 1048 "loadkeys.y"
2607
2638
    { (yyval) = convert_code((yyvsp[(1) - (1)])^0xf000, TO_AUTO);       }
2608
2639
    break;
2609
2640
 
2610
2641
  case 50:
2611
 
 
2612
 
/* Line 1464 of yacc.c  */
2613
 
#line 1032 "loadkeys.y"
 
2642
/* Line 1813 of yacc.c  */
 
2643
#line 1049 "loadkeys.y"
2614
2644
    { (yyval) = add_capslock((yyvsp[(2) - (2)])^0xf000);                        }
2615
2645
    break;
2616
2646
 
2617
2647
  case 51:
2618
 
 
2619
 
/* Line 1464 of yacc.c  */
2620
 
#line 1033 "loadkeys.y"
 
2648
/* Line 1813 of yacc.c  */
 
2649
#line 1050 "loadkeys.y"
2621
2650
    { (yyval) = (yyvsp[(1) - (1)]);                                     }
2622
2651
    break;
2623
2652
 
2624
2653
  case 52:
2625
 
 
2626
 
/* Line 1464 of yacc.c  */
2627
 
#line 1034 "loadkeys.y"
 
2654
/* Line 1813 of yacc.c  */
 
2655
#line 1051 "loadkeys.y"
2628
2656
    { (yyval) = add_capslock((yyvsp[(2) - (2)]));                       }
2629
2657
    break;
2630
2658
 
2631
2659
 
2632
 
 
2633
 
/* Line 1464 of yacc.c  */
2634
 
#line 2635 "loadkeys.c"
 
2660
/* Line 1813 of yacc.c  */
 
2661
#line 2662 "loadkeys.c"
2635
2662
      default: break;
2636
2663
    }
 
2664
  /* User semantic actions sometimes alter yychar, and that requires
 
2665
     that yytoken be updated with the new translation.  We take the
 
2666
     approach of translating immediately before every use of yytoken.
 
2667
     One alternative is translating here after every semantic action,
 
2668
     but that translation would be missed if the semantic action invokes
 
2669
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
 
2670
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
 
2671
     incorrect destructor might then be invoked immediately.  In the
 
2672
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
 
2673
     to an incorrect destructor call or verbose syntax error message
 
2674
     before the lookahead is translated.  */
2637
2675
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2638
2676
 
2639
2677
  YYPOPSTACK (yylen);
2661
2699
| yyerrlab -- here on detecting error |
2662
2700
`------------------------------------*/
2663
2701
yyerrlab:
 
2702
  /* Make sure we have latest lookahead translation.  See comments at
 
2703
     user semantic actions for why this is necessary.  */
 
2704
  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
 
2705
 
2664
2706
  /* If not already recovering from an error, report this error.  */
2665
2707
  if (!yyerrstatus)
2666
2708
    {
2668
2710
#if ! YYERROR_VERBOSE
2669
2711
      yyerror (YY_("syntax error"));
2670
2712
#else
 
2713
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
 
2714
                                        yyssp, yytoken)
2671
2715
      {
2672
 
        YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2673
 
        if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2674
 
          {
2675
 
            YYSIZE_T yyalloc = 2 * yysize;
2676
 
            if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2677
 
              yyalloc = YYSTACK_ALLOC_MAXIMUM;
2678
 
            if (yymsg != yymsgbuf)
2679
 
              YYSTACK_FREE (yymsg);
2680
 
            yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2681
 
            if (yymsg)
2682
 
              yymsg_alloc = yyalloc;
2683
 
            else
2684
 
              {
2685
 
                yymsg = yymsgbuf;
2686
 
                yymsg_alloc = sizeof yymsgbuf;
2687
 
              }
2688
 
          }
2689
 
 
2690
 
        if (0 < yysize && yysize <= yymsg_alloc)
2691
 
          {
2692
 
            (void) yysyntax_error (yymsg, yystate, yychar);
2693
 
            yyerror (yymsg);
2694
 
          }
2695
 
        else
2696
 
          {
2697
 
            yyerror (YY_("syntax error"));
2698
 
            if (yysize != 0)
2699
 
              goto yyexhaustedlab;
2700
 
          }
 
2716
        char const *yymsgp = YY_("syntax error");
 
2717
        int yysyntax_error_status;
 
2718
        yysyntax_error_status = YYSYNTAX_ERROR;
 
2719
        if (yysyntax_error_status == 0)
 
2720
          yymsgp = yymsg;
 
2721
        else if (yysyntax_error_status == 1)
 
2722
          {
 
2723
            if (yymsg != yymsgbuf)
 
2724
              YYSTACK_FREE (yymsg);
 
2725
            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
 
2726
            if (!yymsg)
 
2727
              {
 
2728
                yymsg = yymsgbuf;
 
2729
                yymsg_alloc = sizeof yymsgbuf;
 
2730
                yysyntax_error_status = 2;
 
2731
              }
 
2732
            else
 
2733
              {
 
2734
                yysyntax_error_status = YYSYNTAX_ERROR;
 
2735
                yymsgp = yymsg;
 
2736
              }
 
2737
          }
 
2738
        yyerror (yymsgp);
 
2739
        if (yysyntax_error_status == 2)
 
2740
          goto yyexhaustedlab;
2701
2741
      }
 
2742
# undef YYSYNTAX_ERROR
2702
2743
#endif
2703
2744
    }
2704
2745
 
2757
2798
  for (;;)
2758
2799
    {
2759
2800
      yyn = yypact[yystate];
2760
 
      if (yyn != YYPACT_NINF)
 
2801
      if (!yypact_value_is_default (yyn))
2761
2802
        {
2762
2803
          yyn += YYTERROR;
2763
2804
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2780
2821
      YY_STACK_PRINT (yyss, yyssp);
2781
2822
    }
2782
2823
 
 
2824
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2783
2825
  *++yyvsp = yylval;
 
2826
  YY_IGNORE_MAYBE_UNINITIALIZED_END
2784
2827
 
2785
2828
 
2786
2829
  /* Shift the error token.  */
2804
2847
  yyresult = 1;
2805
2848
  goto yyreturn;
2806
2849
 
2807
 
#if !defined(yyoverflow) || YYERROR_VERBOSE
 
2850
#if !defined yyoverflow || YYERROR_VERBOSE
2808
2851
/*-------------------------------------------------.
2809
2852
| yyexhaustedlab -- memory exhaustion comes here.  |
2810
2853
`-------------------------------------------------*/
2816
2859
 
2817
2860
yyreturn:
2818
2861
  if (yychar != YYEMPTY)
2819
 
     yydestruct ("Cleanup: discarding lookahead",
2820
 
                 yytoken, &yylval);
 
2862
    {
 
2863
      /* Make sure we have latest lookahead translation.  See comments at
 
2864
         user semantic actions for why this is necessary.  */
 
2865
      yytoken = YYTRANSLATE (yychar);
 
2866
      yydestruct ("Cleanup: discarding lookahead",
 
2867
                  yytoken, &yylval);
 
2868
    }
2821
2869
  /* Do not reclaim the symbols of the rule which action triggered
2822
2870
     this YYABORT or YYACCEPT.  */
2823
2871
  YYPOPSTACK (yylen);
2841
2889
}
2842
2890
 
2843
2891
 
2844
 
 
2845
 
/* Line 1684 of yacc.c  */
2846
 
#line 1036 "loadkeys.y"
2847
 
 
 
2892
/* Line 2076 of yacc.c  */
 
2893
#line 1053 "loadkeys.y"
 
2894
 
 
2895
 
 
2896
static void parse_keymap(FILE *fd) {
 
2897
        if (!quiet && !optm)
 
2898
                fprintf(stdout, _("Loading %s\n"), pathname);
 
2899
 
 
2900
        stack_push(fd, 0, pathname);
 
2901
 
 
2902
        if (yyparse()) {
 
2903
                fprintf(stderr, _("syntax error in map file\n"));
 
2904
 
 
2905
                if (!optm)
 
2906
                        fprintf(stderr,
 
2907
                                _("key bindings not changed\n"));
 
2908
                exit(EXIT_FAILURE);
 
2909
        }
 
2910
}
2848
2911
 
2849
2912
int main(int argc, char *argv[])
2850
2913
{
2869
2932
        int kbd_mode;
2870
2933
        int kd_mode;
2871
2934
        char *console = NULL;
 
2935
        char *ev;
 
2936
        FILE *f;
2872
2937
 
2873
2938
        set_progname(argv[0]);
2874
2939
 
2901
2966
                        break;
2902
2967
                case 'u':
2903
2968
                        optu = 1;
 
2969
                        prefer_unicode = 1;
2904
2970
                        break;
2905
2971
                case 'q':
2906
2972
                        quiet = 1;
2923
2989
                exit(EXIT_FAILURE);
2924
2990
        }
2925
2991
 
2926
 
        prefer_unicode = optu;
 
2992
        /* get console */
 
2993
        fd = getfd(console);
2927
2994
 
2928
2995
        if (!optm && !optb) {
2929
2996
                /* check whether the keyboard is in Unicode mode */
2930
 
                fd = getfd(console);
2931
 
 
2932
 
                if (ioctl(fd, KDGKBMODE, &kbd_mode)) {
2933
 
                        perror("KDGKBMODE");
2934
 
                        fprintf(stderr, _("%s: error reading keyboard mode\n"),
 
2997
                if (ioctl(fd, KDGKBMODE, &kbd_mode) ||
 
2998
                    ioctl(fd, KDGETMODE, &kd_mode)) {
 
2999
                        fprintf(stderr, _("%s: error reading keyboard mode: %m\n"),
2935
3000
                                progname);
2936
3001
                        exit(EXIT_FAILURE);
2937
3002
                }
2948
3013
 
2949
3014
                        /* reset -u option if keyboard is in K_UNICODE anyway */
2950
3015
                        optu = 0;
2951
 
                } else if (optu
2952
 
                           && (ioctl(fd, KDGETMODE, &kd_mode) || (kd_mode != KD_GRAPHICS)))
 
3016
 
 
3017
                } else if (optu && kd_mode != KD_GRAPHICS) {
2953
3018
                        fprintf(stderr,
2954
3019
                                _("%s: warning: loading Unicode keymap on non-Unicode console\n"
2955
3020
                                  "    (perhaps you want to do `kbd_mode -u'?)\n"),
2956
3021
                                progname);
2957
 
 
2958
 
                close(fd);
 
3022
                }
 
3023
        }
 
3024
 
 
3025
        dirpath = dirpath1;
 
3026
        if ((ev = getenv("LOADKEYS_KEYMAP_PATH")) != NULL) {
 
3027
                if (!quiet && !optm)
 
3028
                        fprintf(stdout, _("Searching in %s\n"), ev);
 
3029
 
 
3030
                dirpath2[0] = ev;
 
3031
                dirpath = dirpath2;
 
3032
        }
 
3033
 
 
3034
        if (optd) {
 
3035
                /* first read default map - search starts in . */
 
3036
 
 
3037
                if ((f = findfile(DEFMAP, dirpath, suffixes)) == NULL) {
 
3038
                        fprintf(stderr, _("Cannot find %s\n"), DEFMAP);
 
3039
                        exit(EXIT_FAILURE);
 
3040
                }
 
3041
                parse_keymap(f);
 
3042
 
 
3043
        } else if (optind == argc) {
 
3044
                strcpy(pathname, "<stdin>");
 
3045
                parse_keymap(stdin);
2959
3046
        }
2960
3047
 
2961
3048
        for (i = optind; argv[i]; i++) {
2962
 
                FILE *f;
2963
 
                char *ev;
2964
 
 
2965
 
                dirpath = dirpath1;
2966
 
                if ((ev = getenv("LOADKEYS_KEYMAP_PATH")) != NULL) {
2967
 
                        if (!quiet && !optm)
2968
 
                                fprintf(stdout, _("Searching in %s\n"), ev);
2969
 
 
2970
 
                        dirpath2[0] = ev;
2971
 
                        dirpath = dirpath2;
2972
 
                }
2973
 
 
2974
 
                if (optd) {
2975
 
                        /* first read default map - search starts in . */
2976
 
                        optd = 0;
2977
 
                        if ((f = findfile(DEFMAP, dirpath, suffixes)) == NULL) {
2978
 
                                fprintf(stderr, _("Cannot find %s\n"), DEFMAP);
2979
 
                                exit(EXIT_FAILURE);
2980
 
                        }
2981
 
                        goto gotf;
2982
 
                }
2983
 
 
2984
3049
                if (!strcmp(argv[i], "-")) {
2985
3050
                        f = stdin;
2986
3051
                        strcpy(pathname, "<stdin>");
2990
3055
                        exit(EXIT_FAILURE);
2991
3056
                }
2992
3057
 
2993
 
 gotf:
2994
 
                if (!quiet && !optm)
2995
 
                        fprintf(stdout, _("Loading %s\n"), pathname);
2996
 
 
2997
 
                stack_push(f, 0, pathname);
2998
 
 
2999
 
                if (yyparse()) {
3000
 
                        fprintf(stderr, _("syntax error in map file\n"));
3001
 
 
3002
 
                        if (!optm)
3003
 
                                fprintf(stderr,
3004
 
                                        _("key bindings not changed\n"));
3005
 
                        exit(EXIT_FAILURE);
3006
 
                }
 
3058
                parse_keymap(f);
3007
3059
        }
3008
3060
 
3009
3061
        do_constant();
3010
3062
 
3011
 
        if (optb) {
 
3063
        if (optb)
3012
3064
                bkeymap();
3013
3065
 
3014
 
        } else if (optm) {
 
3066
        if (optm)
3015
3067
                mktable();
3016
3068
 
3017
 
        } else if (console) {
3018
 
                char *buf = strdup(console);    /* make writable */
3019
 
                char *e, *s = buf;
3020
 
                while (*s) {
3021
 
                        char ch;
3022
 
 
3023
 
                        while (*s == ' ' || *s == '\t' || *s == ',')
3024
 
                                s++;
3025
 
                        e = s;
3026
 
                        while (*e && *e != ' ' && *e != '\t' && *e != ',')
3027
 
                                e++;
3028
 
                        ch = *e;
3029
 
                        *e = '\0';
3030
 
 
3031
 
                        if (verbose)
3032
 
                                printf("%s\n", s);
3033
 
 
3034
 
                        loadkeys(s, kbd_mode);
3035
 
 
3036
 
                        *e = ch;
3037
 
                        s = e;
3038
 
                }
3039
 
                free(buf);
3040
 
 
3041
 
        } else {
3042
 
                loadkeys(NULL, kbd_mode);
3043
 
        }
 
3069
        loadkeys(fd, kbd_mode);
 
3070
 
 
3071
        close(fd);
 
3072
 
3044
3073
        exit(EXIT_SUCCESS);
3045
3074
}
3046