diff options
author | algernon <algernon> | 2001-02-15 21:46:36 +0000 |
---|---|---|
committer | algernon <algernon> | 2001-02-15 21:46:36 +0000 |
commit | 54bb3dc8882487d38c15d93043943448d8b1b108 (patch) | |
tree | 6f1bc14175d9cfbb2b55955922d8142fb3361523 /src/events.c | |
parent | 81d8534454703493c70fa7d6d1acacc4c7105f79 (diff) | |
download | ratpoison-54bb3dc8882487d38c15d93043943448d8b1b108.zip |
(handle_key): use dynamic strings
Diffstat (limited to 'src/events.c')
-rw-r--r-- | src/events.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/events.c b/src/events.c index be6123b..57ab937 100644 --- a/src/events.c +++ b/src/events.c @@ -1,11 +1,14 @@ -/* Copyright (C) 2000 Shawn Betts - * - * This program is free software; you can redistribute it and/or modify +/* Ratpoison X events + * Copyright (C) 2000, 2001 Shawn Betts + * + * This file is part of ratpoison. + * + * ratpoison is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * - * This program is distributed in the hope that it will be useful, + * ratpoison is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -13,7 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA */ + * Boston, MA 02111-1307 USA + */ #include <X11/X.h> #include <X11/Xlib.h> @@ -282,7 +286,7 @@ static void handle_key (screen_info *s) { char *keysym_name; - char msg[100]; + char *msg; const rp_action *i; int revert; Window fwin; /* Window currently in focus */ @@ -316,14 +320,22 @@ handle_key (screen_info *s) } keysym_name = keysym_to_string (keysym, mod); - snprintf (msg, 100, "%s unbound key!", keysym_name); + msg = (char *) malloc ( strlen ( keysym_name ) + 20 ); + if ( msg == NULL ) + { + PRINT_ERROR ("Out of memory\n"); + exit (EXIT_FAILURE); + } + snprintf (msg, strlen (keysym_name) + 13, "%s unbound key!", keysym_name); free (keysym_name); - PRINT_DEBUG ("%s\n", msg) + PRINT_DEBUG ("%s\n", msg); /* No key match, notify user. */ XSetInputFocus (dpy, fwin, revert, CurrentTime); display_msg_in_bar (s, msg, 0, 0); + + free (msg); } void |