On Saturday 01 October 2005 02:26:21 Nick Glencross wrote: > > I've been wanting to relax the dependency that parrot's core has on > > parrot_config. > I'm not sure that the patch made it into RT. Here it is again, with a > small tweak to a Makefile dependency. > src/config.c will need to be 'svn add'ed when applying the patch, and > Configure rerun to recreate the top-level Makefile. Thanks! I'll check in this patch in a little bit. Meanwhile I want to comment on a few small nits that I'll clean up before I apply it. + + print << "EOF"; +const char* parrot_config_ptr = 0; Per coding standards, the pointer star needs to go on the variable name. + printf "0x%02x", ord($_); + ++$i; + print ', ', if ($i < scalar(@c)); + print "\n " unless $i % 8; The scalar() here is unnecessary. No big deal. Index: src/config.c =================================================================== --- src/config.c (revision 0) +++ src/config.c (revision 0) @@ -0,0 +1,63 @@ +/* + Copyright: 2005 The Perl Foundation. All Rights Reserved. + $Id$ I'll change the date to 2007. +static const char *parrot_config_private_ptr = NULL; +static unsigned int parrot_config_private_size = 0; Eventually it might be better to move these variables into the parent interpreter. For now, I don't think anyone's embedding multiple Parrots into a single program. +parrot_get_config_string(Interp* interpreter) +{ + if (!parrot_config_private_ptr) + return NULL; + + return string_from_const_cstring(interpreter, + parrot_config_private_ptr, + parrot_config_private_size); +} I don't remember what the memory allocation characteristics are of string_from_const_cstring(), so these functions may need comments saying "It's your responsibility to free this string." Index: src/pmc_freeze.c =================================================================== --- src/pmc_freeze.c (revision 9273) +++ src/pmc_freeze.c (working copy) @@ -712,7 +712,7 @@ else { if (string_length(interpreter, s) < PACKFILE_HEADER_BYTES) { real_exception(interpreter, NULL, E_IOError, - "bad string too thaw"); + "bad string to thaw"); } mem_sys_memcopy(pf->header, s->strstart, PACKFILE_HEADER_BYTES); PackFile_assign_transforms(pf); This looks like part of a separate patch. =================================================================== --- imcc/main.c (revision 9273) +++ imcc/main.c (working copy) @@ -459,6 +459,8 @@ char *sourcefile; char *output; + parrot_set_config_string(parrot_config_ptr,parrot_config_size); + Interp *interp = Parrot_new(NULL); The new line should come after the variable declarations, per my understanding of C89. This is difficult to remember. Stupid C89. Good patch! -- cThread Previous | Thread Next