xbindkeys-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xbindkeys-devel] [PATCH 2/2] Replace some deprecated guile functions


From: Hans-Peter Deifel
Subject: [Xbindkeys-devel] [PATCH 2/2] Replace some deprecated guile functions
Date: Wed, 9 Mar 2011 14:51:10 +0100

---
 options.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/options.c b/options.c
index 5b0c2ac..3387015 100644
--- a/options.c
+++ b/options.c
@@ -861,7 +861,7 @@ get_rc_guile_file (void)
   fclose (stream);
 
   init_xbk_guile_fns();
-  scm_primitive_load(scm_makfrom0str(rc_guile_file));
+  scm_primitive_load(scm_from_locale_string(rc_guile_file));
   return 0;
 }
 
@@ -896,10 +896,13 @@ SCM extract_key (SCM key, KeyType_t *type, EventType_t 
*event_type,
 
     //So copy it:
     //Guile strings are not \0 terminated. hence we must copy.
-    len = SCM_LENGTH(SCM_CAR(key));
-    str = malloc(sizeof(char)*(len+1));
-    strncpy(str, SCM_CHARS(SCM_CAR(key)), len);
-    str[len] = '\0';
+    if (scm_is_true(scm_symbol_p(SCM_CAR(key)))) {
+      SCM newkey = scm_symbol_to_string(SCM_CAR(key));
+      str = scm_to_locale_string(newkey);
+    } else {
+      str = scm_to_locale_string(SCM_CAR(key));
+    }
+    len = strlen(str);
 
     if(verbose) //extra verbosity here.
       printf("xbindkey_wrapper debug: modifier = %s.\n", str);
@@ -940,10 +943,13 @@ SCM extract_key (SCM key, KeyType_t *type, EventType_t 
*event_type,
 
   //So copy it:
   //Guile strings are not \0 terminated. hence we must copy.
-  len = SCM_LENGTH(key);
-  str = malloc(sizeof(char)*(len+1));
-  strncpy(str, SCM_CHARS(key), len);
-  str[len] = '\0';
+  if (scm_is_true(scm_symbol_p(key))) {
+    SCM newkey = scm_symbol_to_string(key);
+    str = scm_to_locale_string(newkey);
+  } else {
+    str = scm_to_locale_string(key);
+  }
+  len = strlen(str);
   if(verbose)
     printf("xbindkey_wrapper debug: key = %s\n", str);
 
@@ -999,9 +1005,7 @@ SCM xbindkey_wrapper(SCM key, SCM cmd)
   char *cmdstr;
 
   //Guile strings are not \0 terminated. hence we must copy.
-  cmdstr = malloc(sizeof(char) * SCM_LENGTH(cmd) + 1);
-  strncpy(cmdstr, SCM_CHARS(cmd), SCM_LENGTH(cmd));
-  cmdstr[SCM_LENGTH(cmd)] = '\0';
+  cmdstr = scm_to_locale_string(cmd);
   if(verbose)
     printf("xbindkey_wrapper debug: cmd=%s.\n", cmdstr);
 
@@ -1091,9 +1095,7 @@ SCM run_command_wrapper (SCM command)
 {
   char *cmdstr;
 
-  cmdstr = malloc(sizeof(char) * SCM_LENGTH(command) + 1);
-  strncpy(cmdstr, SCM_CHARS(command), SCM_LENGTH(command));
-  cmdstr[SCM_LENGTH(command)] = '\0';
+  cmdstr = scm_to_locale_string(command);
 
   run_command (cmdstr);
 
-- 
1.7.3.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]