Mercurial > hg > xemacs-beta
changeset 5883:d93195c2c906
Escape quotation marks when printing values interactively, #'getenv
src/ChangeLog addition:
2015-04-01 Aidan Kehoe <kehoea@parhasard.net>
* process.c (Fgetenv):
When interactively showing a variable's value, use %S in the
format string so quotation marks are escaped correctly.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 03 Apr 2015 00:15:18 +0100 |
parents | bbe4146603db |
children | 5a93f519accc |
files | src/ChangeLog src/process.c |
diffstat | 2 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Wed Apr 01 14:28:20 2015 +0100 +++ b/src/ChangeLog Fri Apr 03 00:15:18 2015 +0100 @@ -1,3 +1,9 @@ +2015-04-01 Aidan Kehoe <kehoea@parhasard.net> + + * process.c (Fgetenv): + When interactively showing a variable's value, use %S in the + format string so quotation marks are escaped correctly. + 2015-03-31 Aidan Kehoe <kehoea@parhasard.net> * event-stream.c (Faccept_process_output):
--- a/src/process.c Wed Apr 01 14:28:20 2015 +0100 +++ b/src/process.c Fri Apr 03 00:15:18 2015 +0100 @@ -2431,11 +2431,11 @@ { Ibyte *value = NULL; Bytecount valuelen; - Lisp_Object v = Qnil; - struct gcpro gcpro1; + Lisp_Object v = Qnil, formatted = Qnil; + struct gcpro gcpro1, gcpro2; CHECK_STRING (var); - GCPRO1 (v); + GCPRO2 (v, formatted); if (getenv_internal (XSTRING_DATA (var), XSTRING_LENGTH (var), &value, &valuelen)) v = make_string (value, valuelen); @@ -2444,9 +2444,11 @@ if (NILP (v)) message ("%s not defined in environment", XSTRING_DATA (var)); else - /* #### Should use Fprin1_to_string or Fprin1 to handle string - containing quotes correctly. */ - message ("\"%s\"", value); + { + /* Backslash any quotation marks. */ + formatted = Fprin1_to_string (v, Qnil); + message_internal (NULL, formatted, 0, -1); + } } RETURN_UNGCPRO (v); }