aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorPaul Eggert2016-04-04 10:30:41 -0700
committerPaul Eggert2016-04-04 10:31:25 -0700
commit17cb263adb7c37803140604f0a2e4df8a38fbcff (patch)
treebd57929386123132847718e2d30a528c8b19d1a3 /src/sysdep.c
parent0322457e2bec0b9409a03887a8235dbe14e357f4 (diff)
downloademacs-17cb263adb7c37803140604f0a2e4df8a38fbcff.tar.gz
emacs-17cb263adb7c37803140604f0a2e4df8a38fbcff.zip
New C macro AUTO_STRING_WITH_LEN
Put a bit less pressure on the garbage collector by defining a macro that is like AUTO_STRING but also allows null bytes in strings, and by extending AUTO_STRING to work with any unibyte string. * src/alloc.c (verify_ascii): Remove; all uses removed. AUTO_STRING can now be used on non-ASCII unibyte strings. * src/lisp.h (AUTO_STRING): Now allows non-ASCII unibyte strings. (AUTO_STRING_WITH_LEN): New macro. * src/coding.c (from_unicode_buffer): * src/editfns.c (format_time_string): * src/emacs-module.c (module_make_string, module_format_fun_env): * src/fileio.c (Fexpand_file_name): * src/font.c (font_parse_family_registry): * src/ftfont.c (ftfont_get_charset): * src/keymap.c (silly_event_symbol_error): * src/menu.c (single_menu_item): * src/sysdep.c (system_process_attributes): Use AUTO_STRING_WITH_LEN if possible. * src/emacs-module.c (module_make_function): * src/fileio.c (report_file_errno, report_file_notify_error): * src/fns.c (Flocale_info): * src/sysdep.c (system_process_attributes): Use AUTO_STRING if possible. This is doable more often now that AUTO_STRING works on any unibyte string.
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 67c9bd90df7..1e3b9f12128 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3050,7 +3050,7 @@ system_process_attributes (Lisp_Object pid)
3050 struct timespec tnow, tstart, tboot, telapsed, us_time; 3050 struct timespec tnow, tstart, tboot, telapsed, us_time;
3051 double pcpu, pmem; 3051 double pcpu, pmem;
3052 Lisp_Object attrs = Qnil; 3052 Lisp_Object attrs = Qnil;
3053 Lisp_Object cmd_str, decoded_cmd; 3053 Lisp_Object decoded_cmd;
3054 ptrdiff_t count; 3054 ptrdiff_t count;
3055 3055
3056 CHECK_NUMBER_OR_FLOAT (pid); 3056 CHECK_NUMBER_OR_FLOAT (pid);
@@ -3107,7 +3107,7 @@ system_process_attributes (Lisp_Object pid)
3107 else 3107 else
3108 q = NULL; 3108 q = NULL;
3109 /* Command name is encoded in locale-coding-system; decode it. */ 3109 /* Command name is encoded in locale-coding-system; decode it. */
3110 cmd_str = make_unibyte_string (cmd, cmdsize); 3110 AUTO_STRING_WITH_LEN (cmd_str, cmd, cmdsize);
3111 decoded_cmd = code_convert_string_norecord (cmd_str, 3111 decoded_cmd = code_convert_string_norecord (cmd_str,
3112 Vlocale_coding_system, 0); 3112 Vlocale_coding_system, 0);
3113 attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs); 3113 attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs);
@@ -3240,7 +3240,7 @@ system_process_attributes (Lisp_Object pid)
3240 sprintf (cmdline, "[%.*s]", cmdsize, cmd); 3240 sprintf (cmdline, "[%.*s]", cmdsize, cmd);
3241 } 3241 }
3242 /* Command line is encoded in locale-coding-system; decode it. */ 3242 /* Command line is encoded in locale-coding-system; decode it. */
3243 cmd_str = make_unibyte_string (q, nread); 3243 AUTO_STRING_WITH_LEN (cmd_str, q, nread);
3244 decoded_cmd = code_convert_string_norecord (cmd_str, 3244 decoded_cmd = code_convert_string_norecord (cmd_str,
3245 Vlocale_coding_system, 0); 3245 Vlocale_coding_system, 0);
3246 unbind_to (count, Qnil); 3246 unbind_to (count, Qnil);
@@ -3375,13 +3375,13 @@ system_process_attributes (Lisp_Object pid)
3375 make_float (100.0 / 0x8000 * pinfo.pr_pctmem)), 3375 make_float (100.0 / 0x8000 * pinfo.pr_pctmem)),
3376 attrs); 3376 attrs);
3377 3377
3378 decoded_cmd = (code_convert_string_norecord 3378 AUTO_STRING (fname, pinfo.pr_fname);
3379 (build_unibyte_string (pinfo.pr_fname), 3379 decoded_cmd = code_convert_string_norecord (fname,
3380 Vlocale_coding_system, 0)); 3380 Vlocale_coding_system, 0);
3381 attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs); 3381 attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs);
3382 decoded_cmd = (code_convert_string_norecord 3382 AUTO_STRING (psargs, pinfo.pr_psargs);
3383 (build_unibyte_string (pinfo.pr_psargs), 3383 decoded_cmd = code_convert_string_norecord (psargs,
3384 Vlocale_coding_system, 0)); 3384 Vlocale_coding_system, 0);
3385 attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs); 3385 attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs);
3386 } 3386 }
3387 unbind_to (count, Qnil); 3387 unbind_to (count, Qnil);
@@ -3446,9 +3446,8 @@ system_process_attributes (Lisp_Object pid)
3446 if (gr) 3446 if (gr)
3447 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); 3447 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
3448 3448
3449 decoded_comm = (code_convert_string_norecord 3449 AUTO_STRING (comm, proc.ki_comm);
3450 (build_unibyte_string (proc.ki_comm), 3450 decoded_comm = code_convert_string_norecord (comm, Vlocale_coding_system, 0);
3451 Vlocale_coding_system, 0));
3452 3451
3453 attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs); 3452 attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs);
3454 { 3453 {
@@ -3559,10 +3558,9 @@ system_process_attributes (Lisp_Object pid)
3559 args[i] = ' '; 3558 args[i] = ' ';
3560 } 3559 }
3561 3560
3562 decoded_comm = 3561 AUTO_STRING (comm, args);
3563 (code_convert_string_norecord 3562 decoded_comm = code_convert_string_norecord (comm,
3564 (build_unibyte_string (args), 3563 Vlocale_coding_system, 0);
3565 Vlocale_coding_system, 0));
3566 3564
3567 attrs = Fcons (Fcons (Qargs, decoded_comm), attrs); 3565 attrs = Fcons (Fcons (Qargs, decoded_comm), attrs);
3568 } 3566 }