-AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" -DLOCALEDIR=\"$(localedir)\"
+WERROR = -Werror
+
+WARNINGS = -Wall -Wextra -Wmissing-noreturn -Wdisabled-optimization \
+ -Wcast-align -Wshadow -Wmissing-format-attribute -Wmissing-prototypes \
+ -Wstrict-prototypes -Wmissing-declarations $(WERROR)
+
+AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" -DLOCALEDIR=\"$(localedir)\" $(WARNINGS) \
+ -funit-at-a-time
OLDPROGS = mapscrn loadunimap
PROGS = \
README.cad README.init README.openvt \
cad
-ALL_S = modifiers.h nls.h paths.h version.h
+ALL_S = modifiers.h nls.h paths.h version.h kbd.h
FIND_S = findfile.c findfile.h
GETFD_S = getfd.c getfd.h
KDMA_S = kdmapop.c kdmapop.h
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
#define UINT32_MAX (4294967295U)
#endif
+#endif /* ! C99 */
+
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
#define unput(c) yyunput( c, (yytext_ptr) )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
+typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
+#ifdef __GNUC__
+static void yy_fatal_error (yyconst char msg[] ) __attribute__((noreturn));
+#else
static void yy_fatal_error (yyconst char msg[] );
+#endif
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
#line 1 "analyze.l"
-#line 2 "analyze.l"
+#line 4 "analyze.l"
+#define YY_NO_INPUT 1
+
#include <stdlib.h>
#include <linux/kd.h>
#include "ksyms.h"
-#line 819 "analyze.c"
+#line 830 "analyze.c"
#define INITIAL 0
#define RVALUE 1
static int yy_init_globals (void );
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy (void );
+
+int yyget_debug (void );
+
+void yyset_debug (int debug_flag );
+
+YY_EXTRA_TYPE yyget_extra (void );
+
+void yyset_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *yyget_in (void );
+
+void yyset_in (FILE * in_str );
+
+FILE *yyget_out (void );
+
+void yyset_out (FILE * out_str );
+
+int yyget_leng (void );
+
+char *yyget_text (void );
+
+int yyget_lineno (void );
+
+void yyset_lineno (int line_number );
+
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#endif
#endif
- static void yyunput (int c,char *buf_ptr );
-
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
YY_DECL
{
register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
+ register char *yy_cp = NULL, *yy_bp = NULL;
register int yy_act;
-#line 60 "analyze.l"
+#line 64 "analyze.l"
/* To protect from wrong code in the higher level parser (loadkeys.y),
* yylval to YYLVAL_UNDEF. Then it might be overwritten by specific rules. */
yylval = YYLVAL_UNDEF;
-#line 990 "analyze.c"
+#line 1033 "analyze.c"
if ( !(yy_init) )
{
case 1:
YY_RULE_SETUP
-#line 74 "analyze.l"
+#line 78 "analyze.l"
{BEGIN(INCLSTR);}
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 75 "analyze.l"
+#line 79 "analyze.l"
{ int l; char *s;
l = strlen(yytext);
s = xmalloc(l);
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
-#line 83 "analyze.l"
+#line 87 "analyze.l"
{
yyerror("expected filename between quotes");
BEGIN(0); }
case 4:
/* rule 4 can match eol */
YY_RULE_SETUP
-#line 86 "analyze.l"
+#line 90 "analyze.l"
{line_nr++;}
YY_BREAK
case 5:
/* rule 5 can match eol */
YY_RULE_SETUP
-#line 87 "analyze.l"
+#line 91 "analyze.l"
{line_nr++;BEGIN(0);return(EOL);}
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 88 "analyze.l"
+#line 92 "analyze.l"
; /* do nothing */
YY_BREAK
case 7:
(yy_c_buf_p) = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 89 "analyze.l"
+#line 93 "analyze.l"
; /* do nothing */
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 90 "analyze.l"
+#line 94 "analyze.l"
{BEGIN(RVALUE);rvalct=0;return(EQUALS);}
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 91 "analyze.l"
+#line 95 "analyze.l"
{return(DASH);}
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 92 "analyze.l"
+#line 96 "analyze.l"
{return(COMMA);}
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 93 "analyze.l"
+#line 97 "analyze.l"
{return(PLUS);}
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 94 "analyze.l"
+#line 98 "analyze.l"
{yylval=strtol(yytext+1,NULL,16);if(yylval>=0xf000)lkfatal1("unicode keysym out of range: %s",yytext);return(UNUMBER);}
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 95 "analyze.l"
+#line 99 "analyze.l"
{yylval=strtol(yytext,NULL,0);return(NUMBER);}
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 96 "analyze.l"
+#line 100 "analyze.l"
{return((yylval=ksymtocode(yytext))==-1?ERROR:LITERAL);}
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 97 "analyze.l"
+#line 101 "analyze.l"
{return(CHARSET);}
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 98 "analyze.l"
+#line 102 "analyze.l"
{return(KEYMAPS);}
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 99 "analyze.l"
+#line 103 "analyze.l"
{return(KEYCODE);}
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 100 "analyze.l"
+#line 104 "analyze.l"
{BEGIN(RVALUE);return(STRING);}
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 101 "analyze.l"
+#line 105 "analyze.l"
{return(PLAIN);}
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 102 "analyze.l"
+#line 106 "analyze.l"
{return(SHIFT);}
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 103 "analyze.l"
+#line 107 "analyze.l"
{return(CONTROL);}
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 104 "analyze.l"
+#line 108 "analyze.l"
{return(ALT);}
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 105 "analyze.l"
+#line 109 "analyze.l"
{return(ALTGR);}
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 106 "analyze.l"
+#line 110 "analyze.l"
{return(SHIFTL);}
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 107 "analyze.l"
+#line 111 "analyze.l"
{return(SHIFTR);}
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 108 "analyze.l"
+#line 112 "analyze.l"
{return(CTRLL);}
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 109 "analyze.l"
+#line 113 "analyze.l"
{return(CTRLR);}
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 110 "analyze.l"
+#line 114 "analyze.l"
{return(CAPSSHIFT);}
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 111 "analyze.l"
+#line 115 "analyze.l"
{return(ALT_IS_META);}
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 112 "analyze.l"
+#line 116 "analyze.l"
{return(STRINGS);}
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 113 "analyze.l"
+#line 117 "analyze.l"
{return(COMPOSE);}
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 114 "analyze.l"
+#line 118 "analyze.l"
{return(AS);}
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 115 "analyze.l"
+#line 119 "analyze.l"
{return(USUAL);}
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 116 "analyze.l"
+#line 120 "analyze.l"
{BEGIN(RVALUE); return(TO);}
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 117 "analyze.l"
+#line 121 "analyze.l"
{return(ON);}
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 118 "analyze.l"
+#line 122 "analyze.l"
{return(FOR);}
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 119 "analyze.l"
+#line 123 "analyze.l"
{yylval = strtol(yytext+2,NULL,8); return(CCHAR);}
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 120 "analyze.l"
+#line 124 "analyze.l"
{yylval = yytext[2]; return(CCHAR);}
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 121 "analyze.l"
+#line 125 "analyze.l"
{yylval = yytext[1]; return(CCHAR);}
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 122 "analyze.l"
+#line 126 "analyze.l"
{p=(char *) kbs_buf.kb_string;
pmax=p+sizeof(kbs_buf.kb_string)-1;
BEGIN(STR);}
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 125 "analyze.l"
+#line 129 "analyze.l"
{if(p>=pmax)stringovfl();*p++=strtol(yytext+1,NULL,8);}
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 126 "analyze.l"
+#line 130 "analyze.l"
{if(p>=pmax)stringovfl();*p++='"';}
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 127 "analyze.l"
+#line 131 "analyze.l"
{if(p>=pmax)stringovfl();*p++='\\';}
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 128 "analyze.l"
+#line 132 "analyze.l"
{if(p>=pmax)stringovfl();*p++='\n';}
YY_BREAK
case 45:
/* rule 45 can match eol */
YY_RULE_SETUP
-#line 129 "analyze.l"
+#line 133 "analyze.l"
{char *ptmp=p;p+=strlen(yytext);
if(p>pmax)stringovfl();strcpy(ptmp,yytext);}
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 131 "analyze.l"
+#line 135 "analyze.l"
{*p='\0';BEGIN(0);return(STRLITERAL);}
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 132 "analyze.l"
+#line 136 "analyze.l"
{return(ERROR); /* report any unknown characters */}
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 133 "analyze.l"
+#line 137 "analyze.l"
ECHO;
YY_BREAK
-#line 1333 "analyze.c"
+#line 1376 "analyze.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(RVALUE):
case YY_STATE_EOF(STR):
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
(yy_n_chars) += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
return yy_is_jam ? 0 : yy_current_state;
}
- static void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up yytext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
-
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
((yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
);
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
#define YYTABLES_NAME "yytables"
-#line 133 "analyze.l"
+#line 137 "analyze.l"
#include "ksyms.h"
#include <linux/keyboard.h>
-void
+void attr_noreturn
stringovfl(void) {
lkfatal("string too long");
}
+%option outfile="analyze.c"
+%option nounput
%{
+#define YY_NO_INPUT 1
+
#include <stdlib.h>
#include <linux/kd.h>
#include "ksyms.h"
+#include "kbd.h"
#include "xmalloc.h"
extern int line_nr;
#include "ksyms.h"
#include <linux/keyboard.h>
-void
+void attr_noreturn
stringovfl(void) {
lkfatal("string too long");
}
}
static int
-get_bind(u_char index, u_char table) {
+get_bind(u_char kb_index, u_char kb_table) {
struct kbentry ke;
- ke.kb_index = index;
- ke.kb_table = table;
+ ke.kb_index = kb_index;
+ ke.kb_table = kb_table;
if (ioctl(fd, KDGKBENT, (unsigned long)&ke)) {
- if (index < 128) {
+ if (kb_index < 128) {
perror("KDGKBENT");
fprintf(stderr, _("KDGKBENT error at index %d in table %d\n"),
- index, table);
+ kb_index, kb_table);
exit(1);
} else
return -1;
static void
print_keysym(int code, char numeric) {
- int t;
+ unsigned int t;
int v;
const char *p;
int plus;
static void
dump_diacs(void) {
- int i;
+ unsigned int i;
get_diacs();
for (i = 0; i < kd.kb_cnt; i++) {
static void
dump_symbols(void) {
- int t;
+ unsigned int t;
int v;
const char *p;
static void
print_mod(int x) {
- int t;
+ unsigned int t;
if (!x)
printf("plain\t");
zapped[j] = 0;
if (alt_is_meta) {
for(j = 0; j < keymapnr; j++) {
- int ka, ja, typ;
+ int ka, ja, ktyp;
k = good_keymap[j];
ka = (k | M_ALT);
ja = keymap_index[ka];
if (k != ka && ja >= 0
- && ((typ=KTYP(buf[j])) == KT_LATIN || typ == KT_LETTER)
+ && ((ktyp=KTYP(buf[j])) == KT_LATIN || ktyp == KT_LETTER)
&& KVAL(buf[j]) < 128) {
if (buf[ja] != K(KT_META, KVAL(buf[j])))
fprintf(stderr, _("impossible: not meta?\n"));
}
}
-static void
+static void attr_noreturn
usage(void) {
fprintf(stderr, _("dumpkeys version %s"), PACKAGE_VERSION);
fprintf(stderr, _("\
#include "nls.h"
#include "version.h"
-static void usage(void)
+static void attr_noreturn
+usage(void)
{
fprintf(stderr, _("%s version %s\n"
"\n"
+#ifndef _FINDFILE_H
+#define _FINDFILE_H
+
extern void fpclose(FILE *fp);
extern FILE *findfile(char *fnam, char **dirpath, char **suffixes);
+
+#endif /* _FINDFILE_H */
+#ifndef _GETFD_H
+#define _GETFD_H
+
extern int getfd(const char *fnam);
+
+#endif /* _GETFD_H */
#include "nls.h"
#include "version.h"
-static void
+static void attr_noreturn
usage(void) {
fprintf(stderr, _("usage: getkeycodes\n"));
exit(1);
int
main(int argc, char **argv) {
- int fd, sc, sc0;
+ int fd;
+ unsigned int sc, sc0;
struct kbkeycode a;
int old_kernel = 0;
return (int) fp1 - (int) fp2;
}
-static void
+static void attr_noreturn
usage(void) {
fprintf(stderr, _("Usage:\n\t%s [-s] [-C console]\n"), progname);
exit(1);
--- /dev/null
+#ifndef _KBD_H
+#define _KBD_H
+
+#define attr_noreturn __attribute__ ((noreturn))
+#define attr_unused __attribute__ ((unused))
+
+#endif /* _KBD_H */
#include "nls.h"
#include "version.h"
-static void
+static void attr_noreturn
usage(void){
fprintf(stderr, _("usage: kbd_mode [-a|-u|-k|-s] [-C device]\n"));
exit(1);
return 1; /* success! */
}
+#ifndef KIOCSRATE
+#define arg_state attr_unused
+#else
+#define arg_state
+#endif
+
static int
-KIOCSRATE_ioctl_ok(double rate, int delay, int silent) {
+KIOCSRATE_ioctl_ok(arg_state double rate, arg_state int delay, arg_state int silent) {
#ifdef KIOCSRATE
struct kbd_rate kbdrate_s;
int fd;
}
static void
-sigalrmhandler( int sig ) {
+sigalrmhandler( attr_unused int sig ) {
fprintf( stderr, "kbdrate: Failed waiting for kbd controller!\n" );
raise( SIGINT );
}
int fd;
char data;
int c;
- int i;
+ unsigned int i;
extern char *optarg;
set_progname(argv[0]);
+#ifndef _KDFONTOP_H
+#define _KDFONTOP_H
/*
* Read kernel font into BUF with room for COUNT 32x32 glyphs.
* Return 0 on success -1 on failure.
* Restore font (doesn't work).
*/
extern int restorefont(int fd);
+
+#endif /* _KDFONTOP_H */
+#ifndef _KDMAPOP_H
+#define _KDMAPOP_H
+
extern int getscrnmap(int fd, char *map);
extern int loadscrnmap(int fd, char *map);
extern int getuniscrnmap(int fd, unsigned short *map);
extern int loaduniscrnmap(int fd, unsigned short *map);
extern int getunimap(int fd, struct unimapdesc *ud);
extern int loadunimap(int fd, struct unimapinit *ui, struct unimapdesc *ud);
+
+#endif /* _KDMAPOP_H */
{ "rightanglequote", "guillemotright" }
};
-const int syms_size = sizeof(syms) / sizeof(syms_entry);
-const int syn_size = sizeof(synonyms) / sizeof(synonyms[0]);
+const unsigned int syms_size = sizeof(syms) / sizeof(syms_entry);
+const unsigned int syn_size = sizeof(synonyms) / sizeof(synonyms[0]);
struct cs {
const char *charset;
void
list_charsets(FILE *f) {
- int i,j,lth,ct;
+ int lth,ct;
+ unsigned int i, j;
char *mm[] = { "iso-8859-", "koi8-" };
for (j=0; j<sizeof(mm)/sizeof(mm[0]); j++) {
int
set_charset(const char *charset) {
sym *p;
- int i;
+ unsigned int i;
if (!strcasecmp(charset, "unicode")) {
prefer_unicode = 1;
const char *
unicodetoksym(int code) {
- int i, j;
+ unsigned int i;
+ int j;
sym *p;
if (code < 0)
int
ksymtocode(const char *s) {
- int i;
+ unsigned int i;
int j, jmax;
int keycode;
sym *p;
if (KTYP(code) == KT_LATIN)
return K(KT_LETTER, KVAL(code));
- if (KTYP(code) >= syms_size) {
+ if ((unsigned) KTYP(code) >= syms_size) {
if ((p = unicodetoksym(code ^ 0xf000)) == NULL) {
sprintf(buf, "U+%04x", code ^ 0xf000);
p = buf;
};
extern struct syn synonyms[];
-extern const int syms_size;
-extern const int syn_size;
+extern const unsigned int syms_size;
+extern const unsigned int syn_size;
/* Returned by ksymtocode to report an unknown symbol */
#define CODE_FOR_UNKNOWN_KSYM (-1)
int yyerror(const char *s);
extern void lkfatal(const char *s);
extern void lkfatal1(const char *s, const char *s2);
+void lk_push(void);
+int lk_pop(void);
+void lk_scan_string(char *s);
+void lk_end_string(void);
+
+FILE *find_incl_file_near_fn(char *s, char *fn);
+FILE *find_standard_incl_file(char *s);
+FILE *find_incl_file(char *s);
#include "ksyms.h"
int yylex (void);
/* Line 216 of yacc.c. */
-#line 256 "loadkeys.c"
+#line 264 "loadkeys.c"
#ifdef short
# undef short
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 93, 93, 94, 96, 97, 98, 99, 100, 101,
- 102, 103, 104, 105, 107, 112, 117, 122, 126, 131,
- 136, 137, 139, 145, 150, 159, 163, 168, 168, 173,
- 178, 179, 181, 182, 183, 184, 185, 186, 187, 188,
- 189, 191, 224, 225, 227, 234, 236, 238, 240, 242
+ 0, 101, 101, 102, 104, 105, 106, 107, 108, 109,
+ 110, 111, 112, 113, 115, 120, 125, 130, 134, 139,
+ 144, 145, 147, 153, 158, 167, 171, 176, 176, 181,
+ 186, 187, 189, 190, 191, 192, 193, 194, 195, 196,
+ 197, 199, 232, 233, 235, 242, 244, 246, 248, 250
};
#endif
switch (yyn)
{
case 14:
-#line 108 "loadkeys.y"
+#line 116 "loadkeys.y"
{
set_charset((char *) kbs_buf.kb_string);
}
break;
case 15:
-#line 113 "loadkeys.y"
+#line 121 "loadkeys.y"
{
alt_is_meta = 1;
}
break;
case 16:
-#line 118 "loadkeys.y"
+#line 126 "loadkeys.y"
{
strings_as_usual();
}
break;
case 17:
-#line 123 "loadkeys.y"
+#line 131 "loadkeys.y"
{
compose_as_usual((char *) kbs_buf.kb_string);
}
break;
case 18:
-#line 127 "loadkeys.y"
+#line 135 "loadkeys.y"
{
compose_as_usual(0);
}
break;
case 19:
-#line 132 "loadkeys.y"
+#line 140 "loadkeys.y"
{
keymaps_line_seen = 1;
}
break;
case 22:
-#line 140 "loadkeys.y"
+#line 148 "loadkeys.y"
{
int i;
for (i = (yyvsp[(1) - (3)]); i<= (yyvsp[(3) - (3)]); i++)
break;
case 23:
-#line 146 "loadkeys.y"
+#line 154 "loadkeys.y"
{
addmap((yyvsp[(1) - (1)]),1);
}
break;
case 24:
-#line 151 "loadkeys.y"
+#line 159 "loadkeys.y"
{
if (KTYP((yyvsp[(2) - (5)])) != KT_FN)
lkfatal1(_("'%s' is not a function key symbol"),
break;
case 25:
-#line 160 "loadkeys.y"
+#line 168 "loadkeys.y"
{
compose((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
}
break;
case 26:
-#line 164 "loadkeys.y"
+#line 172 "loadkeys.y"
{
compose((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
}
break;
case 27:
-#line 168 "loadkeys.y"
+#line 176 "loadkeys.y"
{ mod = 0; }
break;
case 28:
-#line 170 "loadkeys.y"
+#line 178 "loadkeys.y"
{
addkey((yyvsp[(4) - (7)]), mod, (yyvsp[(6) - (7)]));
}
break;
case 29:
-#line 174 "loadkeys.y"
+#line 182 "loadkeys.y"
{
addkey((yyvsp[(3) - (6)]), 0, (yyvsp[(5) - (6)]));
}
break;
case 32:
-#line 181 "loadkeys.y"
+#line 189 "loadkeys.y"
{ mod |= M_SHIFT; }
break;
case 33:
-#line 182 "loadkeys.y"
+#line 190 "loadkeys.y"
{ mod |= M_CTRL; }
break;
case 34:
-#line 183 "loadkeys.y"
+#line 191 "loadkeys.y"
{ mod |= M_ALT; }
break;
case 35:
-#line 184 "loadkeys.y"
+#line 192 "loadkeys.y"
{ mod |= M_ALTGR; }
break;
case 36:
-#line 185 "loadkeys.y"
+#line 193 "loadkeys.y"
{ mod |= M_SHIFTL; }
break;
case 37:
-#line 186 "loadkeys.y"
+#line 194 "loadkeys.y"
{ mod |= M_SHIFTR; }
break;
case 38:
-#line 187 "loadkeys.y"
+#line 195 "loadkeys.y"
{ mod |= M_CTRLL; }
break;
case 39:
-#line 188 "loadkeys.y"
+#line 196 "loadkeys.y"
{ mod |= M_CTRLR; }
break;
case 40:
-#line 189 "loadkeys.y"
+#line 197 "loadkeys.y"
{ mod |= M_CAPSSHIFT; }
break;
case 41:
-#line 192 "loadkeys.y"
+#line 200 "loadkeys.y"
{
int i, j;
break;
case 44:
-#line 228 "loadkeys.y"
+#line 236 "loadkeys.y"
{
if (rvalct >= MAX_NR_KEYMAPS)
lkfatal(_("too many key definitions on one line"));
break;
case 45:
-#line 235 "loadkeys.y"
+#line 243 "loadkeys.y"
{(yyval)=(yyvsp[(1) - (1)]);}
break;
case 46:
-#line 237 "loadkeys.y"
+#line 245 "loadkeys.y"
{(yyval)=((yyvsp[(1) - (1)]) ^ 0xf000); unicode_used=1;}
break;
case 47:
-#line 239 "loadkeys.y"
+#line 247 "loadkeys.y"
{(yyval)=add_capslock((yyvsp[(2) - (2)]));}
break;
case 48:
-#line 241 "loadkeys.y"
+#line 249 "loadkeys.y"
{(yyval)=(yyvsp[(1) - (1)]);}
break;
case 49:
-#line 243 "loadkeys.y"
+#line 251 "loadkeys.y"
{(yyval)=add_capslock((yyvsp[(2) - (2)]));}
break;
/* Line 1267 of yacc.c. */
-#line 1736 "loadkeys.c"
+#line 1744 "loadkeys.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
}
-#line 245 "loadkeys.y"
+#line 253 "loadkeys.y"
#include "analyze.c"
-void
+static void attr_noreturn
usage(void) {
fprintf(stderr, _("loadkeys version %s\n"
"\n"
while ( *s == ' ' || *s == '\t' || *s == ',') s++;
e = s;
while (*e && *e != ' ' && *e != '\t' && *e != ',') e++;
- char c = *e;
+ char ch = *e;
*e = '\0';
if (verbose) printf("%s\n", s);
loadkeys(s, &warned);
- *e = c;
+ *e = ch;
s = e;
}
free(buf);
}
/* fatal errors - change to varargs next time */
-void
+void attr_noreturn
lkfatal(const char *s) {
fprintf(stderr, "%s: %s:%d: %s\n", progname, filename, line_nr, s);
exit(1);
}
-void
+void attr_noreturn
lkfatal0(const char *s, int d) {
fprintf(stderr, "%s: %s:%d: ", progname, filename, line_nr);
fprintf(stderr, s, d);
exit(1);
}
-void
+void attr_noreturn
lkfatal1(const char *s, const char *s2) {
fprintf(stderr, "%s: %s:%d: ", progname, filename, line_nr);
fprintf(stderr, s, s2);
/* If filename is a symlink, also look near its target. */
if (!f) {
- char buf[1024], path[1024], *p;
- int n;
+ char buf[1024], path[1024], *ptr;
+ unsigned int n;
n = readlink(filename, buf, sizeof(buf));
if (n > 0 && n < sizeof(buf)) {
else if (strlen(filename) + n < sizeof(path)) {
strcpy(path, filename);
path[sizeof(path)-1] = 0;
- p = rindex(path, '/');
- if (p)
- p[1] = 0;
+ ptr = rindex(path, '/');
+ if (ptr)
+ ptr[1] = 0;
strcat(path, buf);
f = find_incl_file_near_fn(s, path);
}
/* unset a key */
static void
-killkey(int index, int table) {
- /* roughly: addkey(index, table, K_HOLE); */
-
- if (index < 0 || index >= NR_KEYS)
- lkfatal0(_("killkey called with bad index %d"), index);
- if (table < 0 || table >= MAX_NR_KEYMAPS)
- lkfatal0(_("killkey called with bad table %d"), table);
- if (key_map[table])
- (key_map[table])[index] = K_HOLE;
- if (keymap_was_set[table])
- (keymap_was_set[table])[index] = 0;
+killkey(int k_index, int k_table) {
+ /* roughly: addkey(k_index, k_table, K_HOLE); */
+
+ if (k_index < 0 || k_index >= NR_KEYS)
+ lkfatal0(_("killkey called with bad index %d"), k_index);
+ if (k_table < 0 || k_table >= MAX_NR_KEYMAPS)
+ lkfatal0(_("killkey called with bad table %d"), k_table);
+ if (key_map[k_table])
+ (key_map[k_table])[k_index] = K_HOLE;
+ if (keymap_was_set[k_table])
+ (keymap_was_set[k_table])[k_index] = 0;
}
static void
-addkey(int index, int table, int keycode) {
+addkey(int k_index, int k_table, int keycode) {
int i;
if (keycode == CODE_FOR_UNKNOWN_KSYM)
/* is safer not to be silent in this case,
* it can be caused by coding errors as well. */
lkfatal0(_("addkey called with bad keycode %d"), keycode);
- if (index < 0 || index >= NR_KEYS)
- lkfatal0(_("addkey called with bad index %d"), index);
- if (table < 0 || table >= MAX_NR_KEYMAPS)
- lkfatal0(_("addkey called with bad table %d"), table);
-
- if (!defining[table])
- addmap(table, 0);
- if (!key_map[table]) {
- key_map[table] = (u_short *)xmalloc(NR_KEYS * sizeof(u_short));
+ if (k_index < 0 || k_index >= NR_KEYS)
+ lkfatal0(_("addkey called with bad index %d"), k_index);
+ if (k_table < 0 || k_table >= MAX_NR_KEYMAPS)
+ lkfatal0(_("addkey called with bad table %d"), k_table);
+
+ if (!defining[k_table])
+ addmap(k_table, 0);
+ if (!key_map[k_table]) {
+ key_map[k_table] = (u_short *)xmalloc(NR_KEYS * sizeof(u_short));
for (i = 0; i < NR_KEYS; i++)
- (key_map[table])[i] = K_HOLE;
+ (key_map[k_table])[i] = K_HOLE;
}
- if (!keymap_was_set[table]) {
- keymap_was_set[table] = (char *) xmalloc(NR_KEYS);
+ if (!keymap_was_set[k_table]) {
+ keymap_was_set[k_table] = (char *) xmalloc(NR_KEYS);
for (i = 0; i < NR_KEYS; i++)
- (keymap_was_set[table])[i] = 0;
+ (keymap_was_set[k_table])[i] = 0;
}
- if (alt_is_meta && keycode == K_HOLE && (keymap_was_set[table])[index])
+ if (alt_is_meta && keycode == K_HOLE && (keymap_was_set[k_table])[k_index])
return;
- (key_map[table])[index] = keycode;
- (keymap_was_set[table])[index] = 1;
+ (key_map[k_table])[k_index] = keycode;
+ (keymap_was_set[k_table])[k_index] = 1;
if (alt_is_meta) {
- int alttable = table | M_ALT;
+ int alttable = k_table | M_ALT;
int type = KTYP(keycode);
int val = KVAL(keycode);
- if (alttable != table && defining[alttable] &&
+ if (alttable != k_table && defining[alttable] &&
(!keymap_was_set[alttable] ||
- !(keymap_was_set[alttable])[index]) &&
+ !(keymap_was_set[alttable])[k_index]) &&
(type == KT_LATIN || type == KT_LETTER) && val < 128)
- addkey(index, alttable, K(KT_META, val));
+ addkey(k_index, alttable, K(KT_META, val));
}
}
static void
addfunc(struct kbsentry kbs) {
int sh, i, x;
- char *p, *q, *r;
+ char *ptr, *q, *r;
x = kbs.kb_func;
q = func_table[x];
if (q) { /* throw out old previous def */
sh = strlen(q) + 1;
- p = q + sh;
- while (p < fp)
- *q++ = *p++;
+ ptr = q + sh;
+ while (ptr < fp)
+ *q++ = *ptr++;
fp -= sh;
for (i = x + 1; i < MAX_NR_FUNC; i++)
func_table[i] -= sh;
}
- p = func_buf; /* find place for new def */
+ ptr = func_buf; /* find place for new def */
for (i = 0; i < x; i++)
if (func_table[i]) {
- p = func_table[i];
- while(*p++);
+ ptr = func_table[i];
+ while(*ptr++);
}
- func_table[x] = p;
+ func_table[x] = ptr;
sh = strlen((char *) kbs.kb_string) + 1;
if (fp + sh > func_buf + sizeof(func_buf)) {
fprintf(stderr,
q = fp;
fp += sh;
r = fp;
- while (q > p)
+ while (q > ptr)
*--r = *--q;
- strcpy(p, (char *) kbs.kb_string);
+ strcpy(ptr, (char *) kbs.kb_string);
for (i = x + 1; i < MAX_NR_FUNC; i++)
if (func_table[i])
func_table[i] += sh;
static void
compose(int diacr, int base, int res) {
- struct kbdiacr *p;
+ struct kbdiacr *ptr;
if (accent_table_size == MAX_DIACR) {
fprintf(stderr, _("compose table overflow\n"));
exit(1);
}
- p = &accent_table[accent_table_size++];
- p->diacr = diacr;
- p->base = base;
- p->result = res;
+ ptr = &accent_table[accent_table_size++];
+ ptr->diacr = diacr;
+ ptr->base = base;
+ ptr->result = res;
}
static int
static int
deffuncs(int fd){
int i, ct = 0;
- char *p;
+ char *ptr;
for (i = 0; i < MAX_NR_FUNC; i++) {
kbs_buf.kb_func = i;
- if ((p = func_table[i])) {
- strcpy((char *) kbs_buf.kb_string, p);
+ if ((ptr = func_table[i])) {
+ strcpy((char *) kbs_buf.kb_string, ptr);
if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs_buf))
fprintf(stderr, _("failed to bind string '%s' to function %s\n"),
- ostr(kbs_buf.kb_string), syms[KT_FN].table[kbs_buf.kb_func]);
+ ostr((char *) kbs_buf.kb_string), syms[KT_FN].table[kbs_buf.kb_func]);
else
ct++;
} else if (opts) {
static int
defdiacs(int fd){
struct kbdiacrs kd;
- int i;
+ unsigned int i;
kd.kb_cnt = accent_table_size;
if (kd.kb_cnt > MAX_DIACR) {
};
int i;
for(i=0; i<68; i++) {
- struct ccc p = def_latin1_composes[i];
- compose(p.c1, p.c2, p.c3);
+ struct ccc ptr = def_latin1_composes[i];
+ compose(ptr.c1, ptr.c2, ptr.c3);
}
}
}
"shift", "altgr", "ctrl", "alt", "shl", "shr", "ctl", "ctr"
};
-static char *mk_mapname(char mod) {
+static char *mk_mapname(char modifier) {
static char buf[60];
int i;
- if (!mod)
+ if (!modifier)
return "plain";
buf[0] = 0;
for (i=0; i<8; i++)
- if (mod & (1<<i)) {
+ if (modifier & (1<<i)) {
if (buf[0])
strcat(buf, "_");
strcat(buf, modifiers[i]);
printf(comma ? "', " : "'");
}
-static void
+static void attr_noreturn
mktable () {
- int i, imax, j;
+ int j;
+ unsigned int i, imax;
- u_char *p;
- int maxfunc;
+ char *ptr;
+ unsigned int maxfunc;
unsigned int keymap_count = 0;
printf(
printf("char func_buf[] = {\n");
for (i = 0; i < maxfunc; i++) {
- p = func_table[i];
- if (p) {
+ ptr = func_table[i];
+ if (ptr) {
printf("\t");
- for ( ; *p; p++)
- outchar(*p, 1);
+ for ( ; *ptr; ptr++)
+ outchar(*ptr, 1);
printf("0, \n");
}
}
exit(0);
}
-static void
+static void attr_noreturn
bkeymap () {
int i, j;
- u_char *p;
+ //u_char *p;
char flag, magic[] = "bkeymap";
unsigned short v;
int yyerror(const char *s);
extern void lkfatal(const char *s);
extern void lkfatal1(const char *s, const char *s2);
+void lk_push(void);
+int lk_pop(void);
+void lk_scan_string(char *s);
+void lk_end_string(void);
+
+FILE *find_incl_file_near_fn(char *s, char *fn);
+FILE *find_standard_incl_file(char *s);
+FILE *find_incl_file(char *s);
#include "ksyms.h"
int yylex (void);
#include "analyze.c"
-void
+static void attr_noreturn
usage(void) {
fprintf(stderr, _("loadkeys version %s\n"
"\n"
while ( *s == ' ' || *s == '\t' || *s == ',') s++;
e = s;
while (*e && *e != ' ' && *e != '\t' && *e != ',') e++;
- char c = *e;
+ char ch = *e;
*e = '\0';
if (verbose) printf("%s\n", s);
loadkeys(s, &warned);
- *e = c;
+ *e = ch;
s = e;
}
free(buf);
}
/* fatal errors - change to varargs next time */
-void
+void attr_noreturn
lkfatal(const char *s) {
fprintf(stderr, "%s: %s:%d: %s\n", progname, filename, line_nr, s);
exit(1);
}
-void
+void attr_noreturn
lkfatal0(const char *s, int d) {
fprintf(stderr, "%s: %s:%d: ", progname, filename, line_nr);
fprintf(stderr, s, d);
exit(1);
}
-void
+void attr_noreturn
lkfatal1(const char *s, const char *s2) {
fprintf(stderr, "%s: %s:%d: ", progname, filename, line_nr);
fprintf(stderr, s, s2);
/* If filename is a symlink, also look near its target. */
if (!f) {
- char buf[1024], path[1024], *p;
- int n;
+ char buf[1024], path[1024], *ptr;
+ unsigned int n;
n = readlink(filename, buf, sizeof(buf));
if (n > 0 && n < sizeof(buf)) {
else if (strlen(filename) + n < sizeof(path)) {
strcpy(path, filename);
path[sizeof(path)-1] = 0;
- p = rindex(path, '/');
- if (p)
- p[1] = 0;
+ ptr = rindex(path, '/');
+ if (ptr)
+ ptr[1] = 0;
strcat(path, buf);
f = find_incl_file_near_fn(s, path);
}
/* unset a key */
static void
-killkey(int index, int table) {
- /* roughly: addkey(index, table, K_HOLE); */
-
- if (index < 0 || index >= NR_KEYS)
- lkfatal0(_("killkey called with bad index %d"), index);
- if (table < 0 || table >= MAX_NR_KEYMAPS)
- lkfatal0(_("killkey called with bad table %d"), table);
- if (key_map[table])
- (key_map[table])[index] = K_HOLE;
- if (keymap_was_set[table])
- (keymap_was_set[table])[index] = 0;
+killkey(int k_index, int k_table) {
+ /* roughly: addkey(k_index, k_table, K_HOLE); */
+
+ if (k_index < 0 || k_index >= NR_KEYS)
+ lkfatal0(_("killkey called with bad index %d"), k_index);
+ if (k_table < 0 || k_table >= MAX_NR_KEYMAPS)
+ lkfatal0(_("killkey called with bad table %d"), k_table);
+ if (key_map[k_table])
+ (key_map[k_table])[k_index] = K_HOLE;
+ if (keymap_was_set[k_table])
+ (keymap_was_set[k_table])[k_index] = 0;
}
static void
-addkey(int index, int table, int keycode) {
+addkey(int k_index, int k_table, int keycode) {
int i;
if (keycode == CODE_FOR_UNKNOWN_KSYM)
/* is safer not to be silent in this case,
* it can be caused by coding errors as well. */
lkfatal0(_("addkey called with bad keycode %d"), keycode);
- if (index < 0 || index >= NR_KEYS)
- lkfatal0(_("addkey called with bad index %d"), index);
- if (table < 0 || table >= MAX_NR_KEYMAPS)
- lkfatal0(_("addkey called with bad table %d"), table);
-
- if (!defining[table])
- addmap(table, 0);
- if (!key_map[table]) {
- key_map[table] = (u_short *)xmalloc(NR_KEYS * sizeof(u_short));
+ if (k_index < 0 || k_index >= NR_KEYS)
+ lkfatal0(_("addkey called with bad index %d"), k_index);
+ if (k_table < 0 || k_table >= MAX_NR_KEYMAPS)
+ lkfatal0(_("addkey called with bad table %d"), k_table);
+
+ if (!defining[k_table])
+ addmap(k_table, 0);
+ if (!key_map[k_table]) {
+ key_map[k_table] = (u_short *)xmalloc(NR_KEYS * sizeof(u_short));
for (i = 0; i < NR_KEYS; i++)
- (key_map[table])[i] = K_HOLE;
+ (key_map[k_table])[i] = K_HOLE;
}
- if (!keymap_was_set[table]) {
- keymap_was_set[table] = (char *) xmalloc(NR_KEYS);
+ if (!keymap_was_set[k_table]) {
+ keymap_was_set[k_table] = (char *) xmalloc(NR_KEYS);
for (i = 0; i < NR_KEYS; i++)
- (keymap_was_set[table])[i] = 0;
+ (keymap_was_set[k_table])[i] = 0;
}
- if (alt_is_meta && keycode == K_HOLE && (keymap_was_set[table])[index])
+ if (alt_is_meta && keycode == K_HOLE && (keymap_was_set[k_table])[k_index])
return;
- (key_map[table])[index] = keycode;
- (keymap_was_set[table])[index] = 1;
+ (key_map[k_table])[k_index] = keycode;
+ (keymap_was_set[k_table])[k_index] = 1;
if (alt_is_meta) {
- int alttable = table | M_ALT;
+ int alttable = k_table | M_ALT;
int type = KTYP(keycode);
int val = KVAL(keycode);
- if (alttable != table && defining[alttable] &&
+ if (alttable != k_table && defining[alttable] &&
(!keymap_was_set[alttable] ||
- !(keymap_was_set[alttable])[index]) &&
+ !(keymap_was_set[alttable])[k_index]) &&
(type == KT_LATIN || type == KT_LETTER) && val < 128)
- addkey(index, alttable, K(KT_META, val));
+ addkey(k_index, alttable, K(KT_META, val));
}
}
static void
addfunc(struct kbsentry kbs) {
int sh, i, x;
- char *p, *q, *r;
+ char *ptr, *q, *r;
x = kbs.kb_func;
q = func_table[x];
if (q) { /* throw out old previous def */
sh = strlen(q) + 1;
- p = q + sh;
- while (p < fp)
- *q++ = *p++;
+ ptr = q + sh;
+ while (ptr < fp)
+ *q++ = *ptr++;
fp -= sh;
for (i = x + 1; i < MAX_NR_FUNC; i++)
func_table[i] -= sh;
}
- p = func_buf; /* find place for new def */
+ ptr = func_buf; /* find place for new def */
for (i = 0; i < x; i++)
if (func_table[i]) {
- p = func_table[i];
- while(*p++);
+ ptr = func_table[i];
+ while(*ptr++);
}
- func_table[x] = p;
+ func_table[x] = ptr;
sh = strlen((char *) kbs.kb_string) + 1;
if (fp + sh > func_buf + sizeof(func_buf)) {
fprintf(stderr,
q = fp;
fp += sh;
r = fp;
- while (q > p)
+ while (q > ptr)
*--r = *--q;
- strcpy(p, (char *) kbs.kb_string);
+ strcpy(ptr, (char *) kbs.kb_string);
for (i = x + 1; i < MAX_NR_FUNC; i++)
if (func_table[i])
func_table[i] += sh;
static void
compose(int diacr, int base, int res) {
- struct kbdiacr *p;
+ struct kbdiacr *ptr;
if (accent_table_size == MAX_DIACR) {
fprintf(stderr, _("compose table overflow\n"));
exit(1);
}
- p = &accent_table[accent_table_size++];
- p->diacr = diacr;
- p->base = base;
- p->result = res;
+ ptr = &accent_table[accent_table_size++];
+ ptr->diacr = diacr;
+ ptr->base = base;
+ ptr->result = res;
}
static int
static int
deffuncs(int fd){
int i, ct = 0;
- char *p;
+ char *ptr;
for (i = 0; i < MAX_NR_FUNC; i++) {
kbs_buf.kb_func = i;
- if ((p = func_table[i])) {
- strcpy((char *) kbs_buf.kb_string, p);
+ if ((ptr = func_table[i])) {
+ strcpy((char *) kbs_buf.kb_string, ptr);
if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs_buf))
fprintf(stderr, _("failed to bind string '%s' to function %s\n"),
- ostr(kbs_buf.kb_string), syms[KT_FN].table[kbs_buf.kb_func]);
+ ostr((char *) kbs_buf.kb_string), syms[KT_FN].table[kbs_buf.kb_func]);
else
ct++;
} else if (opts) {
static int
defdiacs(int fd){
struct kbdiacrs kd;
- int i;
+ unsigned int i;
kd.kb_cnt = accent_table_size;
if (kd.kb_cnt > MAX_DIACR) {
};
int i;
for(i=0; i<68; i++) {
- struct ccc p = def_latin1_composes[i];
- compose(p.c1, p.c2, p.c3);
+ struct ccc ptr = def_latin1_composes[i];
+ compose(ptr.c1, ptr.c2, ptr.c3);
}
}
}
"shift", "altgr", "ctrl", "alt", "shl", "shr", "ctl", "ctr"
};
-static char *mk_mapname(char mod) {
+static char *mk_mapname(char modifier) {
static char buf[60];
int i;
- if (!mod)
+ if (!modifier)
return "plain";
buf[0] = 0;
for (i=0; i<8; i++)
- if (mod & (1<<i)) {
+ if (modifier & (1<<i)) {
if (buf[0])
strcat(buf, "_");
strcat(buf, modifiers[i]);
printf(comma ? "', " : "'");
}
-static void
+static void attr_noreturn
mktable () {
- int i, imax, j;
+ int j;
+ unsigned int i, imax;
- u_char *p;
- int maxfunc;
+ char *ptr;
+ unsigned int maxfunc;
unsigned int keymap_count = 0;
printf(
printf("char func_buf[] = {\n");
for (i = 0; i < maxfunc; i++) {
- p = func_table[i];
- if (p) {
+ ptr = func_table[i];
+ if (ptr) {
printf("\t");
- for ( ; *p; p++)
- outchar(*p, 1);
+ for ( ; *ptr; ptr++)
+ outchar(*ptr, 1);
printf("0, \n");
}
}
exit(0);
}
-static void
+static void attr_noreturn
bkeymap () {
int i, j;
- u_char *p;
+ //u_char *p;
char flag, magic[] = "bkeymap";
unsigned short v;
int force = 0;
int debug = 0;
-static void
+static void attr_noreturn
usage(void) {
fprintf(stderr,
_("Usage:\n\t%s [-C console] [-o map.orig]\n"), progname);
static struct unimapdesc
getunicodemap(int fd) {
- struct unimapdesc descr;
+ struct unimapdesc unimap_descr;
- if (getunimap(fd, &descr))
+ if (getunimap(fd, &unimap_descr))
exit(1);
#ifdef MAIN
- fprintf(stderr, "# %d %s\n", descr.entry_ct,
- (descr.entry_ct == 1) ? _("entry") : _("entries"));
+ fprintf(stderr, "# %d %s\n", unimap_descr.entry_ct,
+ (unimap_descr.entry_ct == 1) ? _("entry") : _("entries"));
#endif
- return descr;
+ return unimap_descr;
}
void
saveunicodemap(int fd, char *oufil) {
FILE *fpo;
- struct unimapdesc descr;
- struct unipair *list;
+ struct unimapdesc unimap_descr;
+ struct unipair *unilist;
int i;
if ((fpo = fopen(oufil, "w")) == NULL) {
exit(1);
}
- descr = getunicodemap(fd);
- list = descr.entries;
+ unimap_descr = getunicodemap(fd);
+ unilist = unimap_descr.entries;
- for(i=0; i<descr.entry_ct; i++)
- fprintf(fpo, "0x%02x\tU+%04x\n", list[i].fontpos, list[i].unicode);
+ for(i=0; i<unimap_descr.entry_ct; i++)
+ fprintf(fpo, "0x%02x\tU+%04x\n", unilist[i].fontpos, unilist[i].unicode);
fclose(fpo);
if (verbose)
void
appendunicodemap(int fd, FILE *fp, int fontsize, int utf8) {
- struct unimapdesc descr;
- struct unipair *list;
+ struct unimapdesc unimap_descr;
+ struct unipair *unilist;
int i, j;
- descr = getunicodemap(fd);
- list = descr.entries;
+ unimap_descr = getunicodemap(fd);
+ unilist = unimap_descr.entries;
for(i=0; i<fontsize; i++) {
#if 0
/* More than one mapping is not a sequence! */
int no = 0;
- for(j=0; j<descr.entry_ct; j++)
- if (list[j].fontpos == i)
+ for(j=0; j<unimap_descr.entry_ct; j++)
+ if (unilist[j].fontpos == i)
no++;
if (no > 1)
appendseparator(fp, 1, utf8);
#endif
if (debug) printf ("\nchar %03x: ", i);
- for(j=0; j<descr.entry_ct; j++)
- if (list[j].fontpos == i) {
+ for(j=0; j<unimap_descr.entry_ct; j++)
+ if (unilist[j].fontpos == i) {
if (debug)
- printf ("%04x ", list[j].unicode);
- appendunicode(fp, list[j].unicode, utf8);
+ printf ("%04x ", unilist[j].unicode);
+ appendunicode(fp, unilist[j].unicode, utf8);
}
appendseparator(fp, 0, utf8);
}
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/kd.h>
+#include "kbd.h"
#include "paths.h"
#include "findfile.h"
#include "kdmapop.h"
}
static int
-readnewmapfromfile(int fd, char *mfil, char *buf, unsigned short *ubuf) {
+readnewmapfromfile(attr_unused int fd, char *mfil, char *buf, unsigned short *ubuf) {
FILE *fp;
struct stat stbuf;
int u = 0;
+#ifndef _MODIFIERS_H
+#define _MODIFIERS_H
+
#define M_PLAIN 0
#define M_SHIFT (1 << KG_SHIFT)
#define M_CTRL (1 << KG_CTRL)
#define M_CTRLL (1 << KG_CTRLL)
#define M_CTRLR (1 << KG_CTRLR)
#define M_CAPSSHIFT (1 << KG_CAPSSHIFT)
+
+#endif /* _MODIFIERS_H */
* Applied patch by damjan@legolas (-e option), aeb, 2004-01-03.
*/
+#include "kbd.h"
#include "openvt.h"
#include "nls.h"
to the kernel, but we cannot open it. Maybe X
used it and did a chown. Try a few vt's more
before giving up. Note: the 16 is a kernel limitation. */
- int i;
for (i=vtno+1; i<16; i++) {
if((vtstat.v_state & (1<<i)) == 0) {
sprintf(vtname, VTNAME, i);
}
-void usage(int stat)
+void attr_noreturn
+usage(int ret)
{
fprintf(stderr, _(
"Usage: openvt [-c vtnumber] [-f] [-l] [-u] [-s] [-v] [-w] -- command_line\n"));
- exit (stat);
+ exit (ret);
}
/*
+#ifndef _OPENVT_H
+#define _OPENVT_H
+
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#ifdef ESIX_5_3_2_D
#define VTBASE "/dev/vt%02d"
#endif
+
+#endif /* _OPENVT_H */
/* assumes a little-endian machine */
#include <stdio.h>
#include <stdlib.h> /* exit */
+#include "kbd.h"
#include "psf.h"
-static void
+static void attr_noreturn
usage(void) {
fprintf(stderr, "call: outpsfheader psftype fontsize charsize hastable\n");
exit(1);
+#ifndef _PATHS_H
+#define _PATHS_H
/*
* All data is in subdirectories of DATADIR, by default /usr/lib/kbd
* The following five subdirectories are defined:
extern int verbose;
extern int debug;
+
+#endif /* _PATHS_H */
int *fontwidthp, int *fontlenp, int fontpos0,
struct unicode_list **uclistheadsp) {
char *inputbuf = NULL;
- int inputbuflth = 0;
- int inputlth, fontlen, fontwidth, charsize, hastable, ftoffset, utf8;
- int i, k, n;
+ size_t inputbuflth = 0;
+ size_t inputlth, fontlen, fontwidth, charsize, hastable, ftoffset, utf8;
+ size_t i, k, n;
/*
* We used to look at the length of the input file
int
-writepsffont(FILE *ofil, char *fontbuf, int width, int height, int fontlen,
+writepsffont(FILE *ofil, char *fontbuf, int width, int height, size_t fontlen,
int psftype, struct unicode_list *uclistheads) {
- int bytewidth, charsize, flags, utf8, i;
+ int bytewidth, charsize, flags, utf8;
+ size_t i;
bytewidth = (width+7)/8;
charsize = bytewidth * height;
struct unicode_list **uclistheadsp);
extern int writepsffont(FILE *ofil, char *fontbuf,
- int width, int height, int fontlen, int psftype,
+ int width, int height, size_t fontlen, int psftype,
struct unicode_list *uclistheads);
#define WPSFH_HASTAB 1
return 0;
}
-static void
+static void attr_noreturn
usage() {
fprintf(stderr,
_("resizecons:\n"
char infile[20];
unsigned char header[4];
unsigned int rows, cols;
- int fd, i, j;
+ int fd;
+ unsigned int i, j;
char *inbuf, *outbuf, *p, *q;
set_progname(argv[0]);
inbuf = xmalloc(rows*cols*2);
outbuf = xmalloc(rows*(cols+1));
- if (read(fd, inbuf, rows*cols*2) != rows*cols*2) {
+ if (read(fd, inbuf, rows*cols*2) != (ssize_t) (rows*cols*2)) {
fprintf(stderr, _("Error reading %s\n"), infile);
exit(1);
}
return findfile(fnam, partfontdirpath, partfontsuffixes);
}
-static void
+static void attr_noreturn
usage(void)
{
fprintf(stderr, _(
static void
do_loadfont(int fd, char *inbuf, int width, int height, int hwunit,
- int fontsize, char *pathname) {
+ int fontsize, char *filename) {
unsigned char *buf;
int i, buflen;
int bytewidth = (width+7)/8;
}
if (verbose) {
- if (height == hwunit && pathname)
+ if (height == hwunit && filename)
printf(_("Loading %d-char %dx%d font from file %s\n"),
- fontsize, width, height, pathname);
+ fontsize, width, height, filename);
else if (height == hwunit)
printf(_("Loading %d-char %dx%d font\n"),
fontsize, width, height);
- else if (pathname)
+ else if (filename)
printf(_("Loading %d-char %dx%d (%d) font from file %s\n"),
- fontsize, width, height, hwunit, pathname);
+ fontsize, width, height, hwunit, filename);
else
printf(_("Loading %d-char %dx%d (%d) font\n"),
fontsize, width, height, hwunit);
#include "nls.h"
#include "version.h"
-static void
+static void attr_noreturn
usage(char *s) {
fprintf(stderr, "setkeycode: %s\n", s);
fprintf(stderr, _(
#include "nls.h"
#include "version.h"
-static void
+static void attr_noreturn
usage(void)
{
fprintf(stderr, _(
};
static void
-getleds(char *leds) {
- if (ioctl(0, KDGETLED, leds)) {
+getleds(char *cur_leds) {
+ if (ioctl(0, KDGETLED, cur_leds)) {
perror("KDGETLED");
fprintf(stderr,
_("Error reading current led setting. Maybe stdin is not a VT?\n"));
}
static int
-setleds(char leds) {
- if (ioctl(0, KDSETLED, leds)) {
+setleds(char cur_leds) {
+ if (ioctl(0, KDSETLED, cur_leds)) {
perror("KDSETLED");
return -1;
}
static int sunkbdfd = -1;
-static void
-sungetleds(char *leds) {
+#ifndef KIOCGLED
+#define arg_state attr_unused
+#else
+#define arg_state
+#endif
+
+static void attr_noreturn
+sungetleds(arg_state char *cur_leds) {
#ifdef KIOCGLED
- if (ioctl(sunkbdfd, KIOCGLED, leds)) {
+ if (ioctl(sunkbdfd, KIOCGLED, cur_leds)) {
perror("KIOCGLED");
fprintf(stderr,
_("Error reading current led setting from /dev/kbd.\n"));
#endif
}
-static void
-sunsetleds(char *leds) {
+#ifndef KIOCSLED
+#define arg_state attr_unused
+#else
+#define arg_state
+#endif
+
+static void attr_noreturn
+sunsetleds(arg_state char *cur_leds) {
#ifdef KIOCSLED
- if (ioctl(sunkbdfd, KIOCSLED, leds)) {
+ if (ioctl(sunkbdfd, KIOCSLED, cur_leds)) {
perror("KIOCSLED");
fprintf(stderr,
_("Error reading current led setting from /dev/kbd.\n"));
sign = 0;
ap++;
}
- for (lp = leds; lp-leds < sizeof(leds)/sizeof(leds[0]); lp++) {
+ for (lp = leds; (unsigned) (lp-leds) < sizeof(leds)/sizeof(leds[0]); lp++) {
if(!strcmp(ap, lp->name)) {
if(sign) {
nval |= lp->bit;
#include "nls.h"
#include "version.h"
-static void
+static void attr_noreturn
usage(void)
{
fprintf(stderr, _(
}
nmeta = 0; /* make gcc happy */
- for (mp = metas; mp-metas < SIZE(metas); mp++) {
+ for (mp = metas; (unsigned) (mp-metas) < SIZE(metas); mp++) {
if(!strcmp(argv[1], mp->name)) {
nmeta = mp->val;
goto fnd;
int have_obuf = 0;
int have_ounimap = 0;
-static void
+static void attr_noreturn
leave(int n) {
if (have_obuf && loaduniscrnmap(fd,obuf)) {
fprintf(stderr,
}
}
-static void
+static void attr_noreturn
out_of_memory(void) {
fprintf(stderr, _("%s: out of memory?\n"), progname);
leave(1);
leave(1);
}
-static void
+static void attr_noreturn
usage(void) {
fprintf(stderr,
_("usage: showconsolefont -V|--version\n"
close(fd);
}
-static void
+static void attr_noreturn
die(int x) {
printf(_("caught signal %d, cleaning up...\n"), x);
clean_up();
exit(1);
}
-static void
-watch_dog(int x) {
+static void attr_noreturn
+watch_dog(attr_unused int x) {
clean_up();
exit(0);
}
-static void
+static void attr_noreturn
usage(void) {
fprintf(stderr, _(
"showkey version %s\n\n"
#include <sys/ioctl.h> /* ioctl */
#include <unistd.h> /* sleep */
+#include "kbd.h"
+
static void
-sighup(int n) {
+sighup(attr_unused int n) {
if (system("openvt -s -l bash") == -1) {
perror("system");
exit(1);
#include <sys/ioctl.h>
#include <linux/kd.h>
+#include "kbd.h"
+
static void
-sighup(int n) {
+sighup(attr_unused int n) {
if (system("openvt -s -l -- login -h spawn") == -1) {
perror("system");
exit(1);
+#ifndef _UTF8_H
+#define _UTF8_H
+
extern unsigned long from_utf8(char **inptr, int cnt, int *err);
#define UTF8_BAD (-1)
#define UTF8_SHORT (-2)
+
+#endif /* _UTF8_H */
#include <string.h>
#include <stdlib.h>
+#include "kbd.h"
#include "../config.h"
char *progname;
progname = (p ? p+1 : name);
}
-static inline void
+static inline void attr_noreturn
print_version_and_exit(void) {
printf(_("%s from %s\n"), progname, PACKAGE_STRING);
exit(0);
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
+#include "kbd.h"
#include "nls.h"
#include "xmalloc.h"
extern char *progname;
-static void
+static void attr_noreturn
nomem(void) {
fprintf(stderr, _("%s: out of memory\n"), progname);
exit(EX_OSERR);
+#ifndef _XMALLOC_H
+#define _XMALLOC_H
+
/* Error-free versions of some libc routines */
extern void *xmalloc(size_t sz);
extern void *xrealloc(void *p, size_t sz);
extern char *xstrdup(char *p);
+
+#endif /* _XMALLOC_H */