]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - include/MKkey_defs.sh
ncurses 6.4 - patch 20240420
[ncurses.git] / include / MKkey_defs.sh
index 6a173f5afb4f8e8daebaf76847be9b9ea8528446..e58ee2b65d799c3f6129f14f13b2c5ec0c5ef730 100755 (executable)
@@ -1,7 +1,8 @@
 #! /bin/sh
-# $Id: MKkey_defs.sh,v 1.18 2019/04/06 23:38:16 tom Exp $
+# $Id: MKkey_defs.sh,v 1.24 2024/01/19 12:26:17 tom Exp $
 ##############################################################################
-# Copyright (c) 2001-2017,2019 Free Software Foundation, Inc.                #
+# Copyright 2019-2022,2024 Thomas E. Dickey                                  #
+# Copyright 2001-2013,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -34,7 +35,7 @@
 #
 # Extract function-key definitions from the Caps file
 #
-: ${AWK-awk}
+: "${AWK-awk}"
 
 test $# = 0 && set Caps
 
@@ -43,7 +44,8 @@ pass1=pass1_$$
 pass2=pass2_$$
 pass3=pass3_$$
 pass4=pass4_$$
-trap 'rm -f $data pass[1234]_$$' EXIT INT QUIT TERM HUP
+trap 'rm -f $data pass[1234]_$$; exit 1' 1 2 3 15
+trap 'rm -f $data pass[1234]_$$' 0
 
 # change repeated tabs (used for readability) to single tabs (needed to make
 # awk see the right field alignment of the corresponding columns):
@@ -62,11 +64,10 @@ fi
 
 # add keys that we generate automatically:
 cat >>$data <<EOF
-key_resize     kr1     str     R1      KEY_RESIZE      +       -----   Terminal resize event
-key_event      kv1     str     V1      KEY_EVENT       +       -----   We were interrupted by an event
+key_resize     kr1     str     R1      KEY_RESIZE      +       NCURSES_SIGWINCH        Terminal resize event
 EOF
 
-THIS=./`basename $0`
+THIS=./`basename "$0"`
 
 cat <<EOF
 /*
@@ -141,6 +142,12 @@ $5 != "-" && $6 != "-" {
                        maxkey = thiskey;
                if (pass == 2 || pass == 3) {
                        showkey=sprintf(octal_fmt, thiskey);
+                       ifdef = 0;
+                       if (index($7,"NCURSES_") == 1) {
+                               ifdef = 1;
+                               printf "\n";
+                               printf "#if %s\n", $7;
+                       }
                        if ($5 == "KEY_F(0)" ) {
                                printf "#define "
                                print_cols("KEY_F0", 16);
@@ -159,6 +166,9 @@ $5 != "-" && $6 != "-" {
                                        printf " %s", $i
                                print " */"
                        }
+                       if (ifdef != 0) {
+                               printf "#endif\n";
+                       }
                }
        }
 END    {