* emul_netbsd.c (emul_netbsd_create): Quote file-name property.
* emul_unix.c (emul_unix_create): Likewise. * tree.c (libiberty.h): Include it. (tree_quote_property): New function. * tree.h (tree_quote_property): Declare.
This commit is contained in:
parent
e26af52fd1
commit
59f6d9d6f8
@ -1,3 +1,11 @@
|
||||
2006-02-01 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
* emul_netbsd.c (emul_netbsd_create): Quote file-name property.
|
||||
* emul_unix.c (emul_unix_create): Likewise.
|
||||
* tree.c (libiberty.h): Include it.
|
||||
(tree_quote_property): New function.
|
||||
* tree.h (tree_quote_property): Declare.
|
||||
|
||||
2006-01-25 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
* words.h (natural32): Define as "int".
|
||||
|
@ -1383,6 +1383,7 @@ emul_netbsd_create(device *root,
|
||||
int elf_binary;
|
||||
os_emul_data *bsd_data;
|
||||
device *vm;
|
||||
char *filename;
|
||||
|
||||
/* check that this emulation is really for us */
|
||||
if (name != NULL && strcmp(name, "netbsd") != 0)
|
||||
@ -1417,8 +1418,10 @@ emul_netbsd_create(device *root,
|
||||
(unsigned long)(top_of_stack - stack_size));
|
||||
tree_parse(vm, "./nr-bytes 0x%x", stack_size);
|
||||
|
||||
filename = tree_quote_property (bfd_get_filename(image));
|
||||
tree_parse(root, "/openprom/vm/map-binary/file-name %s",
|
||||
bfd_get_filename(image));
|
||||
filename);
|
||||
free (filename);
|
||||
|
||||
/* finish the init */
|
||||
tree_parse(root, "/openprom/init/register/pc 0x%lx",
|
||||
|
@ -951,6 +951,7 @@ emul_unix_create(device *root,
|
||||
int elf_binary;
|
||||
os_emul_data *data;
|
||||
device *vm;
|
||||
char *filename;
|
||||
|
||||
/* merge any emulation specific entries into the device tree */
|
||||
|
||||
@ -979,8 +980,10 @@ emul_unix_create(device *root,
|
||||
(unsigned long)(top_of_stack - stack_size));
|
||||
tree_parse(vm, "./nr-bytes 0x%x", stack_size);
|
||||
|
||||
filename = tree_quote_property (bfd_get_filename(image));
|
||||
tree_parse(root, "/openprom/vm/map-binary/file-name %s",
|
||||
bfd_get_filename(image));
|
||||
filename);
|
||||
free (filename);
|
||||
|
||||
/* finish the init */
|
||||
tree_parse(root, "/openprom/init/register/pc 0x%lx",
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "libiberty.h"
|
||||
|
||||
/* manipulate/lookup device names */
|
||||
|
||||
@ -625,6 +626,50 @@ parse_integer_property(device *current,
|
||||
}
|
||||
}
|
||||
|
||||
/* PROPERTY_VALUE is a raw property value. Quote it as required by
|
||||
parse_string_property. It is the caller's responsibility to free
|
||||
the memory returned. */
|
||||
|
||||
EXTERN_TREE\
|
||||
(char *)
|
||||
tree_quote_property(const char *property_value)
|
||||
{
|
||||
char *p;
|
||||
char *ret;
|
||||
const char *chp;
|
||||
int quotees;
|
||||
|
||||
/* Count characters needing quotes in PROPERTY_VALUE. */
|
||||
quotees = 0;
|
||||
for (chp = property_value; *chp; ++chp)
|
||||
if (*chp == '\\' || *chp == '"')
|
||||
++quotees;
|
||||
|
||||
ret = (char *) xmalloc (strlen (property_value)
|
||||
+ 2 /* quotes */
|
||||
+ quotees
|
||||
+ 1 /* terminator */);
|
||||
|
||||
p = ret;
|
||||
/* Add the opening quote. */
|
||||
*p++ = '"';
|
||||
/* Copy the value. */
|
||||
for (chp = property_value; *chp; ++chp)
|
||||
if (*chp == '\\' || *chp == '"')
|
||||
{
|
||||
/* Quote this character. */
|
||||
*p++ = '\\';
|
||||
*p++ = *chp;
|
||||
}
|
||||
else
|
||||
*p++ = *chp;
|
||||
/* Add the closing quote. */
|
||||
*p++ = '"';
|
||||
/* Terminate the string. */
|
||||
*p++ = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* <string> ... */
|
||||
|
||||
|
@ -41,6 +41,10 @@
|
||||
|
||||
*/
|
||||
|
||||
EXTERN_TREE\
|
||||
(char*) tree_quote_property
|
||||
(const char *property_value);
|
||||
|
||||
EXTERN_TREE\
|
||||
(device *) tree_parse
|
||||
(device *root,
|
||||
|
Loading…
Reference in New Issue
Block a user