Mercurial > hg > xemacs-beta
comparison src/process.c @ 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 | a216b3c2b09e |
children |
comparison
equal
deleted
inserted
replaced
5882:bbe4146603db | 5883:d93195c2c906 |
---|---|
2429 */ | 2429 */ |
2430 (var, interactivep)) | 2430 (var, interactivep)) |
2431 { | 2431 { |
2432 Ibyte *value = NULL; | 2432 Ibyte *value = NULL; |
2433 Bytecount valuelen; | 2433 Bytecount valuelen; |
2434 Lisp_Object v = Qnil; | 2434 Lisp_Object v = Qnil, formatted = Qnil; |
2435 struct gcpro gcpro1; | 2435 struct gcpro gcpro1, gcpro2; |
2436 | 2436 |
2437 CHECK_STRING (var); | 2437 CHECK_STRING (var); |
2438 GCPRO1 (v); | 2438 GCPRO2 (v, formatted); |
2439 if (getenv_internal (XSTRING_DATA (var), XSTRING_LENGTH (var), | 2439 if (getenv_internal (XSTRING_DATA (var), XSTRING_LENGTH (var), |
2440 &value, &valuelen)) | 2440 &value, &valuelen)) |
2441 v = make_string (value, valuelen); | 2441 v = make_string (value, valuelen); |
2442 if (!NILP (interactivep)) | 2442 if (!NILP (interactivep)) |
2443 { | 2443 { |
2444 if (NILP (v)) | 2444 if (NILP (v)) |
2445 message ("%s not defined in environment", XSTRING_DATA (var)); | 2445 message ("%s not defined in environment", XSTRING_DATA (var)); |
2446 else | 2446 else |
2447 /* #### Should use Fprin1_to_string or Fprin1 to handle string | 2447 { |
2448 containing quotes correctly. */ | 2448 /* Backslash any quotation marks. */ |
2449 message ("\"%s\"", value); | 2449 formatted = Fprin1_to_string (v, Qnil); |
2450 message_internal (NULL, formatted, 0, -1); | |
2451 } | |
2450 } | 2452 } |
2451 RETURN_UNGCPRO (v); | 2453 RETURN_UNGCPRO (v); |
2452 } | 2454 } |
2453 | 2455 |
2454 /* A version of getenv that consults Vprocess_environment, easily | 2456 /* A version of getenv that consults Vprocess_environment, easily |