]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - include/MKkey_defs.sh
ncurses 6.2 - patch 20200926
[ncurses.git] / include / MKkey_defs.sh
index 56c1f36566604e8b257e127e25bbf3ceeaed6e89..86d6891c369316d14781aef8cde087f95a8379ee 100755 (executable)
@@ -1,7 +1,8 @@
 #! /bin/sh
 #! /bin/sh
-# $Id: MKkey_defs.sh,v 1.17 2019/03/02 22:51:42 tom Exp $
+# $Id: MKkey_defs.sh,v 1.21 2020/08/17 10:45:33 tom Exp $
 ##############################################################################
 ##############################################################################
-# Copyright (c) 2001-2017,2019 Free Software Foundation, Inc.                #
+# Copyright 2019,2020 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"), #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -35,7 +36,8 @@
 # Extract function-key definitions from the Caps file
 #
 : ${AWK-awk}
 # Extract function-key definitions from the Caps file
 #
 : ${AWK-awk}
-DATA=${1-Caps}
+
+test $# = 0 && set Caps
 
 data=data$$
 pass1=pass1_$$
 
 data=data$$
 pass1=pass1_$$
@@ -46,14 +48,14 @@ trap 'rm -f $data pass[1234]_$$' EXIT INT QUIT TERM HUP
 
 # change repeated tabs (used for readability) to single tabs (needed to make
 # awk see the right field alignment of the corresponding columns):
 
 # change repeated tabs (used for readability) to single tabs (needed to make
 # awk see the right field alignment of the corresponding columns):
-if sort -k 6 $DATA >$data 2>/dev/null
+if sort -k 6 "$@" >$data 2>/dev/null
 then
        # POSIX
 then
        # POSIX
-       sed -e 's/[     ][      ]*/     /g' < $DATA |sort -n -k 6 >$data
-elif sort -n +5 $DATA >$data 2>/dev/null
+       sed -e 's/[     ][      ]*/     /g' "$@" |sort -n -k 6 >$data
+elif sort -n +5 "$@" >$data 2>/dev/null
 then
        # SunOS (and SVr4, marked as obsolete but still recognized)
 then
        # SunOS (and SVr4, marked as obsolete but still recognized)
-       sed -e 's/[     ][      ]*/     /g' < $DATA |sort -n +5 >$data
+       sed -e 's/[     ][      ]*/     /g' "$@" |sort -n +5 >$data
 else
        echo "Your sort utility is broken.  Please install one that works." >&2
        exit 1
 else
        echo "Your sort utility is broken.  Please install one that works." >&2
        exit 1
@@ -61,16 +63,14 @@ fi
 
 # add keys that we generate automatically:
 cat >>$data <<EOF
 
 # 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_EXT_FUNCS       Terminal resize event
 EOF
 
 THIS=./`basename $0`
 EOF
 
 THIS=./`basename $0`
-PARM=./`basename $DATA`
 
 cat <<EOF
 /*
 
 cat <<EOF
 /*
- * These definitions were generated by $THIS $PARM
+ * These definitions were generated by $THIS $*
  */
 EOF
 
  */
 EOF
 
@@ -124,6 +124,8 @@ BEGIN       {
 /^#/           {next;}
 /^capalias/    {next;}
 /^infoalias/   {next;}
 /^#/           {next;}
 /^capalias/    {next;}
 /^infoalias/   {next;}
+/^used_by/     {next;}
+/^userdef/     {next;}
 
 $5 != "-" && $6 != "-" {
                if ($6 == "+") {
 
 $5 != "-" && $6 != "-" {
                if ($6 == "+") {
@@ -139,6 +141,12 @@ $5 != "-" && $6 != "-" {
                        maxkey = thiskey;
                if (pass == 2 || pass == 3) {
                        showkey=sprintf(octal_fmt, thiskey);
                        maxkey = thiskey;
                if (pass == 2 || pass == 3) {
                        showkey=sprintf(octal_fmt, thiskey);
+                       ifdef = 0;
+                       if (index($7,"NCURSES_") == 1) {
+                               ifdef = 1;
+                               printf "\n";
+                               printf "#ifdef %s\n", $7;
+                       }
                        if ($5 == "KEY_F(0)" ) {
                                printf "#define "
                                print_cols("KEY_F0", 16);
                        if ($5 == "KEY_F(0)" ) {
                                printf "#define "
                                print_cols("KEY_F0", 16);
@@ -157,6 +165,9 @@ $5 != "-" && $6 != "-" {
                                        printf " %s", $i
                                print " */"
                        }
                                        printf " %s", $i
                                print " */"
                        }
+                       if (ifdef != 0) {
+                               printf "#endif\n";
+                       }
                }
        }
 END    {
                }
        }
 END    {