|
From: | grischka |
Subject: | Re: [Tinycc-devel] Allow configuration of tcc libraries search path |
Date: | Tue, 05 Jul 2011 19:04:22 +0200 |
User-agent: | Thunderbird 2.0.0.24 (Windows/20100228) |
Thomas Preud'homme wrote:
#ifdef CONFIG_TCC_EXTRA_LDDIR { const char delim[] = ":"; char *tok, *tok_extra_libdir = NULL, *tok_save_ptr, *extra_libdir_str; size_t toklen = 0, old_toklen = 0; extra_libdir_str = tcc_strdup(CONFIG_TCC_EXTRA_LDDIR); tok = strtok_r(extra_libdir_str, delim, &tok_save_ptr); while (tok != NULL) { toklen = strlen(CONFIG_SYSROOT "/usr/local") + strlen(tok); if (toklen > old_toklen) tok_extra_libdir = tcc_realloc(tok_extra_libdir, toklen * sizeof(char)); /* No need for snprintf: value in tok comes from tcc compilation */ sprintf(tok_extra_libdir, CONFIG_SYSROOT "%s", tok); tcc_add_library_path(s, tok_extra_libdir); sprintf(tok_extra_libdir, CONFIG_SYSROOT "/usr/local%s", tok); tcc_add_library_path(s, tok_extra_libdir); tok = strtok_r(NULL, delim, &tok_save_ptr); } tcc_free(tok_extra_libdir); } #endif
Well, whatever you do, please try to give us new structure and not just new features! For example, this "extra" functionality could well live in its own function rather than as just another spaghetti inline hack. Also, splitting path components at colons is a general task, so it can have its own general purpose utility. For example: int tcc_split_path_components(const char *in, char ***out); which in tcc would probably return the components as a 'dynarray'. Also, I'd claim that using strtok is somehow un-tcc'ish, seen that there are zero occurrences anywhere else. ;) Also, I don't see extra_libdir_str free'd in your patch ;) Btw, I'm still thinking about 0.9.26. Best regards, --- grischka
[Prev in Thread] | Current Thread | [Next in Thread] |