Package init

This commit is contained in:
overweight 2019-09-30 10:54:20 -04:00
commit b6da39fe25
20 changed files with 906 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From 7e665ed238d01917e40430680b1181c668772756 Mon Sep 17 00:00:00 2001
From: Oleg Bulatov <obulatov@redhat.com>
Date: Wed, 25 Apr 2018 18:19:42 +0200
Subject: [PATCH] Check existance of map before dumping it
---
src/libkeymap/dump.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/libkeymap/dump.c b/src/libkeymap/dump.c
index c4e2513..8bc5d70 100644
--- a/src/libkeymap/dump.c
+++ b/src/libkeymap/dump.c
@@ -520,8 +520,10 @@ no_shorthands:
defs[j] = K(KT_META, KVAL(defs[j - 8]));
for (j = 0; j < keymapnr; j++) {
- if ((j >= 16 && buf[j] != K_HOLE) || (j < 16 && buf[j] != defs[j]))
- goto unexpected;
+ if (lk_map_exists(ctx, j)) {
+ if ((j >= 16 && buf[j] != K_HOLE) || (j < 16 && buf[j] != defs[j]))
+ goto unexpected;
+ }
}
isasexpected = 1;
@@ -577,8 +579,10 @@ no_shorthands:
fprintf(fd, "\n");
for (j = 1; j < keymapnr; j++) {
- if (buf[j] != buf[0] && !zapped[j]) {
- print_bind(ctx, fd, buf[j], i, j, numeric);
+ if (lk_map_exists(ctx, j)) {
+ if (buf[j] != buf[0] && !zapped[j]) {
+ print_bind(ctx, fd, buf[j], i, j, numeric);
+ }
}
}
} else {
--
2.21.0.windows.1

View File

@ -0,0 +1,28 @@
From afb661b80441b6e3fa8cfa3b69f50e4805ebf8be Mon Sep 17 00:00:00 2001
From: Vitezslav Crhonek <vcrhonek@redhat.com>
Date: Mon, 14 May 2018 11:21:45 +0200
Subject: [PATCH] Fix infinite loop of vlock if locked VC is closed
---
src/vlock/auth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/vlock/auth.c b/src/vlock/auth.c
index 25efb5e..4cbc685 100644
--- a/src/vlock/auth.c
+++ b/src/vlock/auth.c
@@ -140,9 +140,9 @@ int get_password(pam_handle_t *pamh, const char *username, const char *tty)
fflush(stdout);
/*
* EOF encountered on read?
- * If not on VT, check stdin.
+ * Check stdin.
*/
- if (is_vt || isatty(STDIN_FILENO)) {
+ if (isatty(STDIN_FILENO)) {
/* Ignore error. */
sleep(SHORT_DELAY);
break;
--
2.21.0.windows.1

43
Fix-memory-leak.patch Normal file
View File

@ -0,0 +1,43 @@
From ca317cb7bd17792ff9f16a3c0eb49e11e963c63f Mon Sep 17 00:00:00 2001
From: luochunsheng <luochunsheng@huawei.com>
Date: Sat, 13 Apr 2019 16:24:11 +0800
Subject: [PATCH] Subject: [PATCH] Fix memory leak
---
src/libkeymap/parser.y | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/libkeymap/parser.y b/src/libkeymap/parser.y
index d9efbf8..50c4f14 100644
--- a/src/libkeymap/parser.y
+++ b/src/libkeymap/parser.y
@@ -11,6 +11,7 @@
*/
%{
#define YY_HEADER_EXPORT_START_CONDITIONS 1
+#define YY_YY_Y_TAB_H_INCLUDED 1
#include "config.h"
#include "nls.h"
@@ -411,7 +412,6 @@ lk_parse_keymap(struct lk_ctx *ctx, lkfile_t *f)
ctx->mod = 0;
- yylex_init(&scanner);
yylex_init_extra(ctx, &scanner);
INFO(ctx, _("Loading %s"), f->pathname);
@@ -424,8 +424,9 @@ lk_parse_keymap(struct lk_ctx *ctx, lkfile_t *f)
rc = 0;
+fail:
stack_pop(ctx, scanner);
- fail: yylex_destroy(scanner);
+ yylex_destroy(scanner);
return rc;
}
--
1.8.3.1

View File

@ -0,0 +1,28 @@
From f7f357ef079b6d185f340e716d7c72a98d82bad0 Mon Sep 17 00:00:00 2001
From: Garry Filakhtov <filakhtov@gmail.com>
Date: Fri, 20 Jul 2018 15:58:56 +0200
Subject: [PATCH] configure.ac: Fix logic of vlock configure switch
Downstream bug report: https://bugs.gentoo.org/661650
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 87eb63c..07098cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,7 +119,7 @@ AM_CONDITIONAL(BUILD_LIBKEYMAP, test "$BUILD_LIBKEYMAP" = "yes")
AC_ARG_ENABLE(vlock,
AS_HELP_STRING(--disable-vlock, [do not build vlock]),
- [VLOCK_PROG=no],[VLOCK_PROG=yes])
+ [VLOCK_PROG=$enableval],[VLOCK_PROG=yes])
AM_CONDITIONAL(VLOCK, test "$VLOCK_PROG" = "yes")
if test "$VLOCK_PROG" = "yes"; then
--
2.21.0.windows.1

61
cz-map.patch Normal file
View File

@ -0,0 +1,61 @@
--- cz.map.orig 2016-10-11 13:11:15.000000000 +0200
+++ cz.map 2016-10-11 13:12:03.093565772 +0200
@@ -39,7 +39,7 @@
keycode 38 = +U+006c +U+004c +U+0141 +U+0141 Control_l Control_l Control_l Control_l Meta_l Meta_L Meta_l Meta_L Meta_Control_l Meta_Control_l Meta_Control_l Meta_Control_l +U+006c +U+004c +U+0141 +U+0141 Control_l Control_l Control_l Control_l Meta_l Meta_L Meta_l Meta_L Meta_Control_l Meta_Control_l Meta_Control_l Meta_Control_l +U+006c +U+004c +U+0141 +U+0141 Control_l Control_l Control_l Control_l Meta_l Meta_L Meta_l Meta_L Meta_Control_l Meta_Control_l Meta_Control_l Meta_Control_l +U+006c +U+004c +U+0141 +U+0141 Control_l Control_l Control_l Control_l Meta_l Meta_L Meta_l Meta_L Meta_Control_l Meta_Control_l Meta_Control_l Meta_Control_l +U+004c +U+006c +U+0142 +U+0142 Control_l Control_l Control_l Control_l Meta_l Meta_L Meta_l Meta_L Meta_Control_l Meta_Control_l Meta_Control_l Meta_Control_l +U+004c +U+006c +U+0142 +U+0142 Control_l Control_l Control_l Control_l Meta_l Meta_L Meta_l Meta_L Meta_Control_l Meta_Control_l Meta_Control_l Meta_Control_l +U+004c +U+006c +U+0142 +U+0142 Control_l Control_l Control_l Control_l Meta_l Meta_L Meta_l Meta_L Meta_Control_l Meta_Control_l Meta_Control_l Meta_Control_l +U+004c +U+006c +U+0142 +U+0142 Control_l Control_l Control_l Control_l Meta_l Meta_L Meta_l Meta_L Meta_Control_l Meta_Control_l Meta_Control_l Meta_Control_l
keycode 39 = +U+016f U+0022 U+0024 dead_doubleacute +U+016f U+0022 U+0024 dead_doubleacute Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar +U+016f U+0022 U+0024 dead_doubleacute +U+016f U+0022 U+0024 dead_doubleacute Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar +U+016f U+0022 U+0024 dead_doubleacute +U+016f U+0022 U+0024 dead_doubleacute Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar +U+016f U+0022 U+0024 dead_doubleacute +U+016f U+0022 U+0024 dead_doubleacute Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar +U+016e U+0022 U+0024 dead_doubleacute +U+016e U+0022 U+0024 dead_doubleacute Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar +U+016e U+0022 U+0024 dead_doubleacute +U+016e U+0022 U+0024 dead_doubleacute Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar +U+016e U+0022 U+0024 dead_doubleacute +U+016e U+0022 U+0024 dead_doubleacute Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar +U+016e U+0022 U+0024 dead_doubleacute +U+016e U+0022 U+0024 dead_doubleacute Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar Meta_quotedbl Meta_quotedbl Meta_dollar Meta_dollar
keycode 40 = U+00a7 U+0021 U+0027 +U+00df U+00a7 U+0021 U+0027 +U+00df Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe U+00a7 U+0021 U+0027 +U+00df U+00a7 U+0021 U+0027 +U+00df Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe U+00a7 U+0021 U+0027 +U+00df U+00a7 U+0021 U+0027 +U+00df Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe U+00a7 U+0021 U+0027 +U+00df U+00a7 U+0021 U+0027 +U+00df Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe U+00a7 U+0021 U+0027 +U+0053 U+00a7 U+0021 U+0027 +U+0053 Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe U+00a7 U+0021 U+0027 +U+0053 U+00a7 U+0021 U+0027 +U+0053 Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe U+00a7 U+0021 U+0027 +U+0053 U+00a7 U+0021 U+0027 +U+0053 Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe U+00a7 U+0021 U+0027 +U+0053 U+00a7 U+0021 U+0027 +U+0053 Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe Meta_exclam Meta_exclam Meta_apostrophe Meta_apostrophe
-keycode 41 = U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum
+keycode 41 = U+003b dead_grave U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum U+003b U+00b0 U+0060 U+007e nul Control_asciicircum nul Control_asciicircum Meta_semicolon Meta_semicolon Meta_grave Meta_asciitilde Meta_nul Meta_Control_asciicircum Meta_nul Meta_Control_asciicircum
keycode 42 = Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift Shift
keycode 43 = dead_diaeresis U+0027 U+005c U+007c Control_backslash Control_backslash Control_backslash Control_backslash Meta_apostrophe Meta_apostrophe Meta_backslash Meta_bar Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash dead_diaeresis U+0027 U+005c U+007c Control_backslash Control_backslash Control_backslash Control_backslash Meta_apostrophe Meta_apostrophe Meta_backslash Meta_bar Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash dead_diaeresis U+0027 U+005c U+007c Control_backslash Control_backslash Control_backslash Control_backslash Meta_apostrophe Meta_apostrophe Meta_backslash Meta_bar Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash dead_diaeresis U+0027 U+005c U+007c Control_backslash Control_backslash Control_backslash Control_backslash Meta_apostrophe Meta_apostrophe Meta_backslash Meta_bar Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash dead_diaeresis U+0027 U+005c U+007c Control_backslash Control_backslash Control_backslash Control_backslash Meta_apostrophe Meta_apostrophe Meta_backslash Meta_bar Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash dead_diaeresis U+0027 U+005c U+007c Control_backslash Control_backslash Control_backslash Control_backslash Meta_apostrophe Meta_apostrophe Meta_backslash Meta_bar Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash dead_diaeresis U+0027 U+005c U+007c Control_backslash Control_backslash Control_backslash Control_backslash Meta_apostrophe Meta_apostrophe Meta_backslash Meta_bar Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash dead_diaeresis U+0027 U+005c U+007c Control_backslash Control_backslash Control_backslash Control_backslash Meta_apostrophe Meta_apostrophe Meta_backslash Meta_bar Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash Meta_Control_backslash
keycode 44 = +U+0079 +U+0059 U+00b0 U+003c Control_y Control_y Control_y Control_y Meta_y Meta_Y Meta_less Meta_less Meta_Control_y Meta_Control_y Meta_Control_y Meta_Control_y +U+0079 +U+0059 U+00b0 U+003c Control_y Control_y Control_y Control_y Meta_y Meta_Y Meta_less Meta_less Meta_Control_y Meta_Control_y Meta_Control_y Meta_Control_y +U+0079 +U+0059 U+00b0 U+003c Control_y Control_y Control_y Control_y Meta_y Meta_Y Meta_less Meta_less Meta_Control_y Meta_Control_y Meta_Control_y Meta_Control_y +U+0079 +U+0059 U+00b0 U+003c Control_y Control_y Control_y Control_y Meta_y Meta_Y Meta_less Meta_less Meta_Control_y Meta_Control_y Meta_Control_y Meta_Control_y +U+0059 +U+0079 U+00b0 U+003c Control_y Control_y Control_y Control_y Meta_y Meta_Y Meta_less Meta_less Meta_Control_y Meta_Control_y Meta_Control_y Meta_Control_y +U+0059 +U+0079 U+00b0 U+003c Control_y Control_y Control_y Control_y Meta_y Meta_Y Meta_less Meta_less Meta_Control_y Meta_Control_y Meta_Control_y Meta_Control_y +U+0059 +U+0079 U+00b0 U+003c Control_y Control_y Control_y Control_y Meta_y Meta_Y Meta_less Meta_less Meta_Control_y Meta_Control_y Meta_Control_y Meta_Control_y +U+0059 +U+0079 U+00b0 U+003c Control_y Control_y Control_y Control_y Meta_y Meta_Y Meta_less Meta_less Meta_Control_y Meta_Control_y Meta_Control_y Meta_Control_y
@@ -108,3 +108,49 @@
keycode 127 = VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol VoidSymbol
keycode 121 = KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period KP_Period
strings as usual
+# dead_grave
+compose '`' 'u' to U+016F
+compose '`' 'U' to U+016E
+compose '`' 'z' to U+00B0
+compose '`' 'Z' to U+00B0
+# dead_acute
+compose '\'' 'a' to U+00E1
+compose '\'' 'A' to U+00C1
+compose '\'' 'e' to U+00E9
+compose '\'' 'E' to U+00C9
+compose '\'' 'i' to U+00ED
+compose '\'' 'I' to U+00CD
+compose '\'' 'o' to U+00F3
+compose '\'' 'O' to U+00D3
+compose '\'' 'u' to U+00FA
+compose '\'' 'U' to U+00DA
+compose '\'' 'y' to U+00FD
+compose '\'' 'Y' to U+00DD
+# dead_caron
+compose '^' 'u' to U+016F
+compose '^' 'U' to U+016E
+compose '^' 'c' to U+010D
+compose '^' 'C' to U+010C
+compose '^' 'd' to U+010F
+compose '^' 'D' to U+010E
+compose '^' 'e' to U+011B
+compose '^' 'E' to U+011A
+compose '^' 'n' to U+0148
+compose '^' 'N' to U+0147
+compose '^' 'r' to U+0159
+compose '^' 'R' to U+0158
+compose '^' 's' to U+0161
+compose '^' 'S' to U+0160
+compose '^' 't' to U+0165
+compose '^' 'T' to U+0164
+compose '^' 'z' to U+017E
+compose '^' 'Z' to U+017D
+# dead_diaeresis
+compose '"' 'a' to U+00E4
+compose '"' 'A' to U+00C4
+compose '"' 'e' to U+00EB
+compose '"' 'E' to U+00CB
+compose '"' 'o' to U+00F6
+compose '"' 'O' to U+00D6
+compose '"' 'u' to U+00FC
+compose '"' 'U' to U+00DC

View File

@ -0,0 +1,52 @@
diff -up kbd-2.0.4/docs/man/man1/showkey.1.orig kbd-2.0.4/docs/man/man1/showkey.1
--- kbd-2.0.4/docs/man/man1/showkey.1.orig 2016-10-31 16:56:02.000000000 +0100
+++ kbd-2.0.4/docs/man/man1/showkey.1 2017-01-11 10:45:03.763312393 +0100
@@ -84,6 +84,19 @@ corresponds to what the keyboard hardwar
to know the scan codes sent by various keys it is better to boot a
2.4 kernel. Since 2.6.9 there also is the boot option atkbd.softraw=0
that tells the 2.6 kernel to return the actual scan codes.
+
+.SH NOTES
+The raw scan codes are available only on AT and PS/2 keyboards,
+and even then they are disabled unless the
+.B atkbd.softraw=0
+kernel parameter is used.
+When the raw scan codes are not available, the kernel uses a fixed built-in
+table to produce scan codes from keycodes. Thus,
+.BR setkeycodes (8)
+can affect the output of
+.B showkey
+in scan code dump mode.
+
.SH "SEE ALSO"
.BR loadkeys (1),
.BR dumpkeys (1),
diff -up kbd-2.0.4/docs/man/man8/setkeycodes.8.orig kbd-2.0.4/docs/man/man8/setkeycodes.8
--- kbd-2.0.4/docs/man/man8/setkeycodes.8.orig 2016-10-31 16:56:02.000000000 +0100
+++ kbd-2.0.4/docs/man/man8/setkeycodes.8 2017-01-11 10:45:03.763312393 +0100
@@ -38,6 +38,10 @@ to showkey(1), the command
.RE
will assign the keycode 112 to it, and then loadkeys(1) can be used
to define the function of this key.
+
+USB keyboards have standardized keycodes and
+.B setkeycodes
+doesn't affect them at all.
.LP
Some older kernels might hardwire a low scancode range to the
equivalent keycodes; setkeycodes will fail when you try to remap
@@ -56,6 +60,14 @@ None.
.SH BUGS
The keycodes of X have nothing to do with those of Linux.
Unusual keys can be made visible under Linux, but not under X.
+
+.B setkeycodes
+affects only the "first" input device
+that has modifiable scancode-to-keycode mapping.
+If there is more than one such device,
+.B setkeycodes
+cannot change the mapping of other devices than the "first" one.
+
.SH "SEE ALSO"
.I "dumpkeys (1), loadkeys (1), showkey (1), getkeycodes (8)"

65
kbd-1.15-sparc.patch Normal file
View File

@ -0,0 +1,65 @@
diff -up kbd-2.0.4/docs/man/man8/kbdrate.8.orig kbd-2.0.4/docs/man/man8/kbdrate.8
--- kbd-2.0.4/docs/man/man8/kbdrate.8.orig 2017-01-11 11:04:50.114831348 +0100
+++ kbd-2.0.4/docs/man/man8/kbdrate.8 2017-01-11 11:05:35.619851252 +0100
@@ -22,7 +22,7 @@ Using
without any options will reset the repeat rate to 10.9 characters per second (cps)
and the delay to 250 milliseconds (ms) for Intel- and M68K-based systems.
These are the IBM defaults. On SPARC-based systems it will reset the repeat rate
-to 5 cps and the delay to 200 ms.
+to 20 cps and the delay to 200 ms.
.SH OPTIONS
.TP
diff -up kbd-2.0.4/src/kbdrate.c.orig kbd-2.0.4/src/kbdrate.c
--- kbd-2.0.4/src/kbdrate.c.orig 2017-01-11 11:05:10.226840148 +0100
+++ kbd-2.0.4/src/kbdrate.c 2017-01-11 11:05:56.832860537 +0100
@@ -111,9 +111,12 @@ static int valid_delays[] = { 250, 500,
static int
KDKBDREP_ioctl_ok(double rate, int delay, int silent)
{
+#if defined(KDKBDREP) && !defined(__sparc__)
/*
* This ioctl is defined in <linux/kd.h> but is not
* implemented anywhere - must be in some m68k patches.
+ * We cannot blindly try unimplemented ioctls on sparc64 -
+ * the 32<->64bit transition layer does not like it.
* Since 2.4.9 also on i386.
*/
struct my_kbd_repeat kbdrep_s;
@@ -176,6 +179,9 @@ KDKBDREP_ioctl_ok(double rate, int delay
rate, kbdrep_s.delay);
return 1; /* success! */
+#else /* no KDKBDREP or __sparc__ */
+ return 0;
+#endif /* KDKBDREP */
}
#ifndef KIOCSRATE
@@ -226,7 +232,7 @@ sigalrmhandler(int sig __attribute__((un
int main(int argc, char **argv)
{
#ifdef __sparc__
- double rate = 5.0; /* Default rate */
+ double rate = 20.0; /* Default rate */
int delay = 200; /* Default delay */
#else
double rate = 10.9; /* Default rate */
@@ -275,8 +281,9 @@ int main(int argc, char **argv)
if (KIOCSRATE_ioctl_ok(rate, delay, silent)) /* sparc? */
return 0;
- /* The ioport way */
+ /* The ioport way - will crash on sparc */
+#ifndef __sparc__
for (i = 0; i < RATE_COUNT; i++)
if (rate * 10 >= valid_rates[i]) {
value &= 0x60;
@@ -333,5 +340,6 @@ int main(int argc, char **argv)
valid_rates[value & 0x1f] / 10.0,
valid_delays[(value & 0x60) >> 5]);
+#endif
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,21 @@
diff -up kbd-1.15.2/src/unicode_start.orig kbd-1.15.2/src/unicode_start
--- kbd-1.15.2/src/unicode_start.orig 2011-01-05 13:28:22.079662644 +0100
+++ kbd-1.15.2/src/unicode_start 2011-01-05 13:29:01.327353698 +0100
@@ -72,6 +72,9 @@ stty iutf8
# have a Unicode map attached, or explicitly specified, e.g.,
# by giving `def.uni' as a second argument.
+DEFAULT_UNICODE_FONT=latarcyrheb-sun16
+# Also drdos8x16 is a good candidate.
+
case "$#" in
2)
setfont "$1" -u "$2"
@@ -80,6 +83,7 @@ case "$#" in
setfont "$1"
;;
0)
+ setfont $DEFAULT_UNICODE_FONT
;;
*)
echo "usage: unicode_start [font [unicode map]]"

View File

@ -0,0 +1,18 @@
diff -up kbd-2.0.4/docs/man/man1/dumpkeys.1.in.orig kbd-2.0.4/docs/man/man1/dumpkeys.1.in
--- kbd-2.0.4/docs/man/man1/dumpkeys.1.in.orig 2017-01-11 11:12:22.884029413 +0100
+++ kbd-2.0.4/docs/man/man1/dumpkeys.1.in 2017-01-11 11:12:47.537040194 +0100
@@ -164,6 +164,14 @@ output of
.BI \-S shape " " " " \-\-shape= shape
.LP
.TP
+.B \-1 \-\-separate-lines
+This forces
+.B dumpkeys
+to write one line per (modifier,keycode) pair. It prefixes the word
+.I plain
+for plain keycodes.
+.LP
+.TP
.B \-t \-\-funcs-only
When this option is given,
.B dumpkeys

View File

@ -0,0 +1,24 @@
diff -up kbd-2.0.4/src/loadkeys.c.orig kbd-2.0.4/src/loadkeys.c
--- kbd-2.0.4/src/loadkeys.c.orig 2017-01-11 11:14:48.308093019 +0100
+++ kbd-2.0.4/src/loadkeys.c 2017-01-11 11:15:18.018106020 +0100
@@ -27,7 +27,7 @@
#include "keymap.h"
static const char *progname = NULL;
-static const char *const dirpath1[] = { "", DATADIR "/" KEYMAPDIR "/**", KERNDIR "/", 0 };
+static const char *const dirpath1[] = { "", DATADIR "/" KEYMAPDIR "/**", DATADIR "/" XKBKEYMAPDIR "/", DATADIR "/" LEGACYKEYMAPDIR "/**", KERNDIR "/", 0 };
static const char *const suffixes[] = { "", ".kmap", ".map", 0 };
static void __attribute__((noreturn))
diff -up kbd-2.0.4/src/paths.h.orig kbd-2.0.4/src/paths.h
--- kbd-2.0.4/src/paths.h.orig 2017-01-11 11:15:40.404115812 +0100
+++ kbd-2.0.4/src/paths.h 2017-01-11 11:15:59.730124274 +0100
@@ -5,6 +5,8 @@
* The following five subdirectories are defined:
*/
#define KEYMAPDIR "keymaps"
+#define XKBKEYMAPDIR "keymaps/xkb"
+#define LEGACYKEYMAPDIR "keymaps/legacy"
#define UNIMAPDIR "unimaps"
#define TRANSDIR "consoletrans"
#define VIDEOMODEDIR "videomodes"

View File

@ -0,0 +1,12 @@
diff -up kbd-1.15.5/data/keymaps/i386/qwertz/sg.map.orig kbd-1.15.5/data/keymaps/i386/qwertz/sg.map
--- kbd-1.15.5/data/keymaps/i386/qwertz/sg.map.orig 2013-02-21 15:54:39.362799094 +0100
+++ kbd-1.15.5/data/keymaps/i386/qwertz/sg.map 2013-02-21 15:54:46.448838554 +0100
@@ -1,7 +1,7 @@
keymaps 0-2,4-6,8,12
include "qwertz-layout"
include "linux-with-alt-and-altgr.inc"
- plain keycode 83 = KP_Comma
+ plain keycode 83 = KP_Period
strings as usual
keycode 1 = Escape Escape

View File

@ -0,0 +1,15 @@
diff -up kbd-2.0.2/src/unicode_start.orig kbd-2.0.2/src/unicode_start
--- kbd-2.0.2/src/unicode_start.orig 2014-08-12 14:47:53.019028849 +0200
+++ kbd-2.0.2/src/unicode_start 2014-08-12 14:54:42.631427602 +0200
@@ -72,7 +72,10 @@ stty iutf8
# have a Unicode map attached, or explicitly specified, e.g.,
# by giving `def.uni' as a second argument.
-DEFAULT_UNICODE_FONT=latarcyrheb-sun16
+# Source /etc/vconsole.conf to get default font
+. /etc/vconsole.conf
+
+DEFAULT_UNICODE_FONT=$FONT
# Also drdos8x16 is a good candidate.
case "$#" in

BIN
kbd-2.0.4.tar.xz Normal file

Binary file not shown.

BIN
kbd-latarcyrheb-32.tar.bz2 Normal file

Binary file not shown.

BIN
kbd-latsun-fonts.tar.bz2 Normal file

Binary file not shown.

185
kbd.spec Normal file
View File

@ -0,0 +1,185 @@
Name: kbd
Version: 2.0.4
Release: 10
Summary: Tools for managing Linux console(keyboard, virtual terminals, etc.)
License: GPLv2+
URL: https://www.%{name}-project.org/
Source0: http://ftp.altlinux.org/pub/people/legion/%{name}/%{name}-%{version}.tar.xz
Source1: %{name}-latsun-fonts.tar.bz2
Source2: %{name}-latarcyrheb-32.tar.bz2
Source3: xml2lst.pl
Source4: vlock.pamd
Source5: kbdinfo.1
Source6: cz-map.patch
Patch0: %{name}-1.15-keycodes-man.patch
Patch1: %{name}-1.15-sparc.patch
Patch2: %{name}-1.15-unicode_start.patch
Patch3: %{name}-1.15.3-dumpkeys-man.patch
Patch4: %{name}-1.15.5-sg-decimal-separator.patch
Patch5: %{name}-1.15.5-loadkeys-search-path.patch
Patch6: %{name}-2.0.2-unicode-start-font.patch
Patch6000: Check-existance-of-map-before-dumping-it.patch
Patch6001: Fix-infinite-loop-of-vlock-if-locked-VC-is-closed.patch
Patch6002: setmetamode-use-unsigned-int-type-for-KDGKBMETA-KDSK.patch
Patch6003: Fix-memory-leak.patch
Patch6004: configure.ac-Fix-logic-of-vlock-configure-switch.patch
BuildRequires: bison flex gettext pam-devel check-devel
BuildRequires: gcc console-setup xkeyboard-config
Requires: %{name}-misc = %{version}-%{release}
Requires: %{name}-legacy = %{version}-%{release}
Provides: vlock = %{version}
Conflicts: vlock <= 1.3
Obsoletes: vlock
%description
The %{name} project contains tools for managing Linux console ,including
Linux console,virtual terminals, keyboard, etc, mainly, what they do
is loading console fonts and keyboard maps.
%package misc
Summary: Data for %{name} package
BuildArch: noarch
%description misc
The %{name}-misc package contains data for %{name} package,including console fonts,
keymaps and so on. But %{name}-misc can do nothing without %{name}.
%package legacy
Summary: Legacy data for %{name} package
BuildArch: noarch
%description legacy
The %{name}-legacy package contains original keymaps for %{name} package.
But %{name}-legacy can do nothing without %{name}.
%package_help
%prep
%setup -q -a 1 -a 2
cp -fp %{SOURCE3} .
cp -fp %{SOURCE6} .
%patch0 -p1 -b .keycodes-man
%patch1 -p1 -b .sparc
%patch2 -p1 -b .unicode_start
%patch3 -p1 -b .dumpkeys-man
%patch4 -p1 -b .sg-decimal-separator
%patch5 -p1 -b .loadkeys-search-path
%patch6 -p1 -b .unicode-start-font
%patch6000 -p1
%patch6001 -p1
%patch6002 -p1
%patch6003 -p1
%patch6004 -p1
pushd data/keymaps/i386
cp qwerty/pt-latin9.map qwerty/pt.map
cp qwerty/sv-latin1.map qwerty/se-latin1.map
mv azerty/fr.map azerty/fr-old.map
cp azerty/fr-latin9.map azerty/fr.map
cp azerty/fr-latin9.map azerty/fr-latin0.map
mv dvorak/no.map dvorak/no-dvorak.map
mv fgGIod/trf.map fgGIod/trf-fgGIod.map
mv olpc/es.map olpc/es-olpc.map
mv olpc/pt.map olpc/pt-olpc.map
mv qwerty/cz.map qwerty/cz-qwerty.map
popd
pushd po
rm -f gr.po gr.gmo
popd
iconv -f iso-8859-1 -t utf-8 < "ChangeLog" > "ChangeLog_"
mv "ChangeLog_" "ChangeLog"
%build
%configure --prefix=%{_prefix} --datadir=/lib/%{name} --mandir=%{_mandir} --localedir=%{_datadir}/locale --enable-nls
%make_build
%install
%make_install
rm -f %{buildroot}/lib/%{name}/keymaps/i386/qwerty/ro_win.map.gz
ln -s sr-cy.map.gz %{buildroot}/lib/%{name}/keymaps/i386/qwerty/sr-latin.map.gz
ln -s us.map.gz %{buildroot}/lib/%{name}/keymaps/i386/qwerty/ko.map.gz
mkdir -p %{buildroot}/bin
for binary in setfont dumpkeys %{name}_mode unicode_start unicode_stop loadkeys ; do
mv %{buildroot}%{_bindir}/$binary %{buildroot}/bin/
done
sed -i -e 's,\<%{name}_mode\>,/bin/%{name}_mode,g;s,\<setfont\>,/bin/setfont,g' \
%{buildroot}/bin/unicode_start
gzip -c %SOURCE5 > %{buildroot}/%{_mandir}/man1/kbdinfo.1.gz
cp -r %{buildroot}/lib/%{name}/locale/ %{buildroot}%{_datadir}/locale
rm -rf %{buildroot}/lib/%{name}/locale
mkdir -p %{buildroot}%{_sysconfdir}/pam.d
install -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/pam.d/vlock
mkdir -p %{buildroot}/lib/%{name}/keymaps/legacy
mv %{buildroot}/lib/%{name}/keymaps/{amiga,atari,i386,include,mac,ppc,sun} %{buildroot}/lib/%{name}/keymaps/legacy
mkdir -p %{buildroot}/lib/%{name}/keymaps/xkb
perl xml2lst.pl < /usr/share/X11/xkb/rules/base.xml > layouts-variants.lst
while read line; do
XKBLAYOUT=`echo "$line" | cut -d " " -f 1`
echo "$XKBLAYOUT" >> layouts-list.lst
XKBVARIANT=`echo "$line" | cut -d " " -f 2`
ckbcomp "$XKBLAYOUT" "$XKBVARIANT" | gzip > %{buildroot}/lib/%{name}/keymaps/xkb/"$XKBLAYOUT"-"$XKBVARIANT".map.gz
done < layouts-variants.lst
cat layouts-list.lst | sort -u >> layouts-list-uniq.lst
while read line; do
ckbcomp "$line" | gzip > %{buildroot}/lib/%{name}/keymaps/xkb/"$line".map.gz
done < layouts-list-uniq.lst
zgrep -L "U+0041" %{buildroot}/lib/%{name}/keymaps/xkb/* | xargs rm -f
gunzip %{buildroot}/lib/%{name}/keymaps/xkb/fi.map.gz
mv %{buildroot}/lib/%{name}/keymaps/xkb/fi.map %{buildroot}/lib/%{name}/keymaps/xkb/fi-kotoistus.map
gzip %{buildroot}/lib/%{name}/keymaps/xkb/fi-kotoistus.map
gunzip %{buildroot}/lib/%{name}/keymaps/xkb/cz.map.gz
patch %{buildroot}/lib/%{name}/keymaps/xkb/cz.map < %{SOURCE6}
gzip %{buildroot}/lib/%{name}/keymaps/xkb/cz.map
%files
%defattr(-,root,root)
%license COPYING
%doc AUTHORS
/bin/*
%{_datadir}/locale/*
%{_bindir}/*
%{_mandir}/*/*
%config(noreplace) %{_sysconfdir}/pam.d/vlock
%files misc
%defattr(-,root,root)
/lib/%{name}/*
%exclude /lib/%{name}/keymaps/legacy
%files legacy
%defattr(-,root,root)
/lib/%{name}/keymaps/legacy/*
%files help
%defattr(-,root,root)
%doc ChangeLog README docs/doc/%{name}.FAQ*.html docs/doc/font-formats/*.html docs/doc/utf/utf* docs/doc/dvorak/*
%{_mandir}/man1/*.1.gz
%{_mandir}/man5/keymaps.5.gz
%{_mandir}/man8/*.8.gz
%changelog
* Wed Sep 18 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.4-10
- Package init

33
kbdinfo.1 Normal file
View File

@ -0,0 +1,33 @@
.TH KBDINFO 1 "June 2011"
.SH NAME
kbdinfo \- obtain information about the status of a console
.SH SYNOPSIS
\fBkbdinfo\fR [\-C \fIDEVICE\fR] getmode [text|graphics]
.LP
\fBkbdinfo\fR [\-C \fIDEVICE\fR] gkbmode [raw|xlate|mediumraw|unicode]
.LP
\fBkbdinfo\fR [\-C \fIDEVICE\fR] gkbmeta [metabit|escprefix]
.LP
\fBkbdinfo\fR [\-C \fIDEVICE\fR] gkbled [scrolllock|numlock|capslock]
.SH DESCRIPTION
.B kbdinfo
is an interface to KDGETMODE, GKBMODE, GKBMETA and GKBLED ioctls. Its
primary use case is to query the status of the given
.I CONSOLE
(or the currently active one, if no \-C option is present) from a shell
script.
.LP
If the final value argument is not specified,
.B kbdinfo
will print the result of the desired ioctl to the standard output.
Otherwise, the given value is compared to the actual result, and the
utility will exit with a status code of 0 for a match, 1 otherwise. No
text is printed for this style of invocation.
.SH "SEE ALSO"
.BR kbd_mode (1)
.SH AUTHOR
kbdinfo is Copyright \(co 2011 Alexey Gladkov
<gladkov.alexey@gmail.com>.
.LP
This manual page was written by Michael Schutte <michi@debian.org> for
the Debian GNU/Linux system (but may be used by others).

View File

@ -0,0 +1,45 @@
From 6613abc26a853293c12f4e146a27606f02c8dd03 Mon Sep 17 00:00:00 2001
From: Andreas Henriksson <andreas@fatal.se>
Date: Mon, 28 May 2018 21:19:22 +0200
Subject: [PATCH] setmetamode: use unsigned int type for KDGKBMETA / KDSKBMETA
alsauser@pragmasoft.com reported that he detected a stack smash
and analyzed the problem as allocating too little space for
the resulting put_user after calling ioctl KDGKBMETA.
The ometa variable should be defined as unsigned int.
While at it and for correctness, also nmeta and thus the
val member of the struct meta where changed to unsigned
int as it seems the kernel wants to take this type
(but should be harmless to use char).
Original bug report at https://bugs.debian.org/872623
---
src/setmetamode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/setmetamode.c b/src/setmetamode.c
index 8d75b94..adec0e9 100644
--- a/src/setmetamode.c
+++ b/src/setmetamode.c
@@ -50,7 +50,7 @@ report(int meta)
struct meta {
char *name;
- int val;
+ unsigned int val;
} metas[] = {
{ "metabit", K_METABIT },
{ "meta", K_METABIT },
@@ -64,7 +64,7 @@ struct meta {
int main(int argc, char **argv)
{
- char ometa, nmeta;
+ unsigned int ometa, nmeta;
struct meta *mp;
set_progname(argv[0]);
--
2.21.0.windows.1

3
vlock.pamd Normal file
View File

@ -0,0 +1,3 @@
#%PAM-1.0
auth include system-auth
account required pam_permit.so

231
xml2lst.pl Normal file
View File

@ -0,0 +1,231 @@
#!/usr/bin/perl
# converts the <rules>.xml file to the old format <rules>.lst file
#
# Usage:
#
# perl xml2lst.pl < filename.xml > filename.lst
#
# author Ivan Pascal
# modified by Vitezslav Crhonek
$doc = new_document( 0, '');
parse('', $doc);
($reg) = node_by_name($doc, '/xkbConfigRegistry');
@models = node_by_name($reg, 'modelList/model/configItem');
@layouts = node_by_name($reg, 'layoutList/layout/configItem');
@options = node_by_name($reg, 'optionList/group/configItem');
for $i (@layouts) {
($name) = node_by_name($i, 'name');
@variants = node_by_name($i, '../variantList/variant/configItem');
for $v (@variants) {
($variant) = node_by_name($v, 'name');
printf("%s %s\n", text_child($name), text_child($variant));
}
}
sub with_attribute {
local ($nodelist, $attrexpr) = @_;
local ($attr, $value) = split (/=/, $attrexpr);
local ($node, $attrvalue);
if (defined $value && $value ne '') {
$value =~ s/"//g;
foreach $node (@{$nodelist}) {
$attrvalue = node_attribute($node, $attr);
if (defined $attrvalue && $attrvalue eq $value) {
return $node;
}
}
} else {
foreach $node (@{$nodelist}) {
if (! defined node_attribute($node, $attr)) {
return $node;
}
}
}
undef;
}
# Subroutines
sub parse {
local $intag = 0;
my (@node_stack, $parent);
$parent = @_[1];
local ($tag, $text);
while (<>) {
chomp;
@str = split /([<>])/;
shift @str if ($str[0] eq '' || $str[0] =~ /^[ \t]*$/);
while (scalar @str) {
$token = shift @str;
if ($token eq '<') {
$intag = 1;
if (defined $text) {
add_text_node($parent, $text);
undef $text;
}
} elsif ($token eq '>') {
$intag = 0;
if ($tag =~ /^\/(.*)/) { # close tag
$parent = pop @node_stack;
} elsif ($tag =~ /^([^\/]*)\/$/) {
empty_tag($parent, $1);
} else {
if (defined ($node = open_tag($parent, $tag))) {
push @node_stack, $parent;
$parent = $node;
}
}
undef $tag;
} else {
if ($intag == 1) {
if (defined $tag) {
$tag .= ' '. $token;
} else {
$tag = $token;
}
} else {
if (defined $text) {
$text .= "\n" . $token;
} else {
$text = $token;
}
}
}
}
}
}
sub new_document {
$doc = new_node( 0, '', 'DOCUMENT');
$doc->{CHILDREN} = [];
return $doc;
}
sub new_node {
local ($parent_node, $tag, $type) = @_;
my %node;
$node{PARENT} = $parent_node;
$node{TYPE} = $type;
if ($type eq 'COMMENT' || $type eq 'TEXT') {
$node{TEXT} = $tag;
$node{NAME} = $type;
return \%node;
}
local ($tname, $attr) = split(' ', $tag, 2);
$node{NAME} = $tname;
if (defined $attr && $attr ne '') {
my %attr_table;
local @attr_list = split ( /"/, $attr);
local ($name, $value);
while (scalar @attr_list) {
$name = shift @attr_list;
$name =~ s/[ =]//g;
next if ($name eq '');
$value = shift @attr_list;
$attr_table{$name} =$value;
}
$node{ATTRIBUTES} = \%attr_table;
}
return \%node;
}
sub add_node {
local ($parent_node, $node) = @_;
push @{$parent_node->{CHILDREN}}, $node;
local $tname = $node->{NAME};
if (defined $parent_node->{$tname}) {
push @{$parent_node->{$tname}}, $node
} else {
$parent_node->{$tname} = [ $node ];
}
}
sub empty_tag {
local ($parent_node, $tag) = @_;
local $node = new_node($parent_node, $tag, 'EMPTY');
add_node($parent_node, $node);
}
sub open_tag {
local ($parent_node, $tag) = @_;
local $node;
if ($tag =~ /^\?.*/ || $tag =~ /^\!.*/) {
$node = new_node($parent_node, $tag, 'COMMENT');
add_node($parent_node, $node);
undef; return;
} else {
$node = new_node($parent_node, $tag, 'NODE');
$node->{CHILDREN} = [];
add_node($parent_node, $node);
return $node;
}
}
sub add_text_node {
local ($parent_node, $text) = @_;
local $node = new_node($parent_node, $text, 'TEXT');
add_node($parent_node, $node);
}
sub node_by_name {
local ($node, $name) = @_;
local ($tagname, $path) = split(/\//, $name, 2);
my @nodelist;
if ($tagname eq '') {
while ($node->{PARENT} != 0) {
$node = $node->{PARENT};
}
sublist_by_name($node, $path, \@nodelist);
} else {
sublist_by_name($node, $name, \@nodelist);
}
return @nodelist;
}
sub sublist_by_name {
local ($node, $name, $res) = @_;
local ($tagname, $path) = split(/\//, $name, 2);
if (! defined $path) {
push @{$res}, (@{$node->{$tagname}});
return;
}
if ($tagname eq '..' && $node->{PARENT} != 0) {
$node = $node->{PARENT};
sublist_by_name($node, $path, $res);
} else {
local $n;
for $n (@{$node->{$tagname}}) {
sublist_by_name($n, $path, $res);
}
}
}
sub node_attribute {
local $node = @_[0];
if (defined $node->{ATTRIBUTES}) {
return $node->{ATTRIBUTES}{@_[1]};
}
undef;
}
sub text_child {
local ($node) = @_;
local ($child) = node_by_name($node, 'TEXT');
return $child->{TEXT};
}