emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r113776: Use xstrdup and build_unibyte_string where


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r113776: Use xstrdup and build_unibyte_string where applicable.
Date: Fri, 09 Aug 2013 12:28:38 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113776
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2013-08-09 16:25:34 +0400
message:
  Use xstrdup and build_unibyte_string where applicable.
  * alloc.c (xstrdup): Tiny cleanup.  Add eassert.
  * xfns.c (x_window):
  * xrdb.c (x_get_customization_string):
  * xterm.c (xim_initialize):
  * w32fns.c (w32_window): Use xstrdup.
  (w32_display_monitor_attributes_list):
  * emacs.c (init_cmdargs):
  * keyboard.c (PUSH_C_STR):
  * nsfont.m (nsfont_open):
  * sysdep.c (system_process_attributes):
  * w32.c (system_process_attributes):
  * xdisp.c (message1, message1_nolog): Use build_unibyte_string.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/alloc.c                    alloc.c-20091113204419-o5vbwnq5f7feedwu-252
  src/emacs.c                    emacs.c-20091113204419-o5vbwnq5f7feedwu-241
  src/keyboard.c                 keyboard.c-20091113204419-o5vbwnq5f7feedwu-449
  src/nsfont.m                   nsfont.m-20091113204419-o5vbwnq5f7feedwu-8748
  src/sysdep.c                   sysdep.c-20091113204419-o5vbwnq5f7feedwu-448
  src/w32.c                      w32.c-20091113204419-o5vbwnq5f7feedwu-808
  src/w32fns.c                   w32fns.c-20091113204419-o5vbwnq5f7feedwu-945
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
  src/xfns.c                     xfns.c-20091113204419-o5vbwnq5f7feedwu-274
  src/xrdb.c                     xrdb.c-20091113204419-o5vbwnq5f7feedwu-177
  src/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-08-09 10:18:48 +0000
+++ b/src/ChangeLog     2013-08-09 12:25:34 +0000
@@ -1,3 +1,19 @@
+2013-08-09  Dmitry Antipov  <address@hidden>
+
+       Use xstrdup and build_unibyte_string where applicable.
+       * alloc.c (xstrdup): Tiny cleanup.  Add eassert.
+       * xfns.c (x_window):
+       * xrdb.c (x_get_customization_string):
+       * xterm.c (xim_initialize):
+       * w32fns.c (w32_window): Use xstrdup.
+       (w32_display_monitor_attributes_list):
+       * emacs.c (init_cmdargs):
+       * keyboard.c (PUSH_C_STR):
+       * nsfont.m (nsfont_open):
+       * sysdep.c (system_process_attributes):
+       * w32.c (system_process_attributes):
+       * xdisp.c (message1, message1_nolog): Use build_unibyte_string.
+
 2013-08-09  Eli Zaretskii  <address@hidden>
 
        * w32.c (PEXCEPTION_POINTERS, PEXCEPTION_RECORD, PCONTEXT): Define

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2013-07-24 15:11:30 +0000
+++ b/src/alloc.c       2013-08-09 12:25:34 +0000
@@ -796,10 +796,8 @@
 char *
 xstrdup (const char *s)
 {
-  size_t len = strlen (s) + 1;
-  char *p = xmalloc (len);
-  memcpy (p, s, len);
-  return p;
+  eassert (s);
+  return strcpy (xmalloc (strlen (s) + 1), s);
 }
 
 /* Like putenv, but (1) use the equivalent of xmalloc and (2) the

=== modified file 'src/emacs.c'
--- a/src/emacs.c       2013-07-16 07:05:41 +0000
+++ b/src/emacs.c       2013-08-09 12:25:34 +0000
@@ -517,8 +517,7 @@
           They are decoded in the function command-line after we know
           locale-coding-system.  */
        Vcommand_line_args
-         = Fcons (make_unibyte_string (argv[i], strlen (argv[i])),
-                  Vcommand_line_args);
+         = Fcons (build_unibyte_string (argv[i]), Vcommand_line_args);
     }
 
   unbind_to (count, Qnil);

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2013-08-03 03:29:03 +0000
+++ b/src/keyboard.c    2013-08-09 12:25:34 +0000
@@ -8431,7 +8431,7 @@
     return Qnil;
 
 #define PUSH_C_STR(str, listvar) \
-  listvar = Fcons (make_unibyte_string (str, strlen (str)), listvar)
+  listvar = Fcons (build_unibyte_string (str), listvar)
 
   /* Prompt string always starts with map's prompt, and a space.  */
   prompt_strings = Fcons (name, prompt_strings);

=== modified file 'src/nsfont.m'
--- a/src/nsfont.m      2013-08-03 03:29:03 +0000
+++ b/src/nsfont.m      2013-08-09 12:25:34 +0000
@@ -920,8 +920,7 @@
     font->underline_thickness = lrint (font_info->underwidth);
 
     font->props[FONT_NAME_INDEX] = Ffont_xlfd_name (font_object, Qnil);
-    font->props[FONT_FULLNAME_INDEX] =
-      make_unibyte_string (font_info->name, strlen (font_info->name));
+    font->props[FONT_FULLNAME_INDEX] = build_unibyte_string (font_info->name);
   }
   unblock_input ();
 

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2013-07-22 15:30:54 +0000
+++ b/src/sysdep.c      2013-08-09 12:25:34 +0000
@@ -3243,13 +3243,11 @@
                     attrs);
 
       decoded_cmd = (code_convert_string_norecord
-                    (make_unibyte_string (pinfo.pr_fname,
-                                          strlen (pinfo.pr_fname)),
+                    (build_unibyte_string (pinfo.pr_fname),
                      Vlocale_coding_system, 0));
       attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs);
       decoded_cmd = (code_convert_string_norecord
-                    (make_unibyte_string (pinfo.pr_psargs,
-                                          strlen (pinfo.pr_psargs)),
+                    (build_unibyte_string (pinfo.pr_psargs),
                      Vlocale_coding_system, 0));
       attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs);
     }
@@ -3319,9 +3317,9 @@
   if (gr)
     attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
 
-  decoded_comm = code_convert_string_norecord
-    (make_unibyte_string (proc.ki_comm, strlen (proc.ki_comm)),
-     Vlocale_coding_system, 0);
+  decoded_comm = (code_convert_string_norecord
+                 (build_unibyte_string (proc.ki_comm),
+                  Vlocale_coding_system, 0));
 
   attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs);
   {

=== modified file 'src/w32.c'
--- a/src/w32.c 2013-08-09 10:18:48 +0000
+++ b/src/w32.c 2013-08-09 12:25:34 +0000
@@ -5769,8 +5769,8 @@
                {
                  /* Decode the command name from locale-specific
                     encoding.  */
-                 cmd_str = make_unibyte_string (pe.szExeFile,
-                                                strlen (pe.szExeFile));
+                 cmd_str = build_unibyte_string (pe.szExeFile);
+
                  decoded_cmd =
                    code_convert_string_norecord (cmd_str,
                                                  Vlocale_coding_system, 0);

=== modified file 'src/w32fns.c'
--- a/src/w32fns.c      2013-08-03 03:29:03 +0000
+++ b/src/w32fns.c      2013-08-09 12:25:34 +0000
@@ -4124,12 +4124,7 @@
      for the window manager, so GC relocation won't bother it.
 
      Elsewhere we specify the window name for the window manager.  */
-
-  {
-    char *str = SSDATA (Vx_resource_name);
-    f->namebuf = xmalloc (strlen (str) + 1);
-    strcpy (f->namebuf, str);
-  }
+  f->namebuf = xstrdup (SSDATA (Vx_resource_name));
 
   my_create_window (f);
 
@@ -4992,8 +4987,8 @@
       attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
                          attributes);
 
-      name = DECODE_SYSTEM (make_unibyte_string (mi.szDevice,
-                                                strlen (mi.szDevice)));
+      name = DECODE_SYSTEM (build_unibyte_string (mi.szDevice));
+
       attributes = Fcons (Fcons (Qname, name), attributes);
 
       attributes = Fcons (Fcons (Qmm_size, list2i (width_mm, height_mm)),

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-08-08 14:51:07 +0000
+++ b/src/xdisp.c       2013-08-09 12:25:34 +0000
@@ -9789,7 +9789,7 @@
 void
 message1 (const char *m)
 {
-  message3 (m ? make_unibyte_string (m, strlen (m)) : Qnil);
+  message3 (m ? build_unibyte_string (m) : Qnil);
 }
 
 
@@ -9798,7 +9798,7 @@
 void
 message1_nolog (const char *m)
 {
-  message3_nolog (m ? make_unibyte_string (m, strlen (m)) : Qnil);
+  message3_nolog (m ? build_unibyte_string (m) : Qnil);
 }
 
 /* Display a message M which contains a single %s

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2013-08-03 03:29:03 +0000
+++ b/src/xfns.c        2013-08-09 12:25:34 +0000
@@ -2313,12 +2313,7 @@
      for the window manager, so GC relocation won't bother it.
 
      Elsewhere we specify the window name for the window manager.  */
-
-  {
-    char *str = SSDATA (Vx_resource_name);
-    f->namebuf = xmalloc (strlen (str) + 1);
-    strcpy (f->namebuf, str);
-  }
+  f->namebuf = xstrdup (SSDATA (Vx_resource_name));
 
   ac = 0;
   XtSetArg (al[ac], XtNallowShellResize, 1); ac++;

=== modified file 'src/xrdb.c'
--- a/src/xrdb.c        2013-07-09 07:04:48 +0000
+++ b/src/xrdb.c        2013-08-09 12:25:34 +0000
@@ -75,18 +75,9 @@
   sprintf (full_class, "%s.%s", class, "Customization");
 
   result = x_get_string_resource (db, full_name, full_class);
-
-  if (result)
-    {
-      char *copy = xmalloc (strlen (result) + 1);
-      strcpy (copy, result);
-      return copy;
-    }
-  else
-    return 0;
+  return result ? xstrdup (result) : NULL;
 }
 
-
 /* Expand all the Xt-style %-escapes in STRING, whose length is given
    by STRING_LEN.  Here are the escapes we're supposed to recognize:
 

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2013-08-08 14:51:07 +0000
+++ b/src/xterm.c       2013-08-09 12:25:34 +0000
@@ -8081,13 +8081,10 @@
     {
 #ifdef HAVE_X11R6_XIM
       struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst);
-      ptrdiff_t len;
 
       dpyinfo->xim_callback_data = xim_inst;
       xim_inst->dpyinfo = dpyinfo;
-      len = strlen (resource_name);
-      xim_inst->resource_name = xmalloc (len + 1);
-      memcpy (xim_inst->resource_name, resource_name, len + 1);
+      xim_inst->resource_name = xstrdup (resource_name);
       XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
                                      resource_name, emacs_class,
                                      xim_instantiate_callback,


reply via email to

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