Index: trunk/doc-rnd/TODO =================================================================== --- trunk/doc-rnd/TODO (revision 1478) +++ trunk/doc-rnd/TODO (revision 1479) @@ -1,3 +1,5 @@ +- check why util/ broke + - vemdordrill conversion: - test vendordrill if it works - vendordrill: free at exit Index: trunk/src/file.c =================================================================== --- trunk/src/file.c (revision 1478) +++ trunk/src/file.c (revision 1479) @@ -374,7 +374,7 @@ start = clock(); #endif - resolve_path(Filename, &new_filename); + resolve_path(Filename, &new_filename, 0); oldPCB = PCB; PCB = newPCB; Index: trunk/src/hid_cfg.c =================================================================== --- trunk/src/hid_cfg.c (revision 1478) +++ trunk/src/hid_cfg.c (revision 1479) @@ -126,19 +126,20 @@ return n->data.text.value; } -hid_cfg_t *hid_cfg_load(const char *hidname, int exact_fn, const char *embedded_fallback) +hid_cfg_t *hid_cfg_load(const char *fn, int exact_fn, const char *embedded_fallback) { lht_doc_t *doc; hid_cfg_t *hr; //static const char *pcbmenu_paths_in[] = { "gpcb-menu.res", "gpcb-menu.res", PCBSHAREDIR "/gpcb-menu.res", NULL }; - char *hidfn = strdup(hidname); /* TODO: search for the file */ + char *hidfn = strdup(fn); if (!exact_fn) { static const char *hid_cfg_paths_in[] = { ".", PCBSHAREDIR "/", NULL }; char **paths = NULL; + int fn_len = strlen(fn); - resolve_all_paths(hid_cfg_paths_in, paths); + resolve_all_paths(hid_cfg_paths_in, paths, fn_len+32); for(doc = NULL; doc == NULL;) { } Index: trunk/src/hid_cfg.h =================================================================== --- trunk/src/hid_cfg.h (revision 1478) +++ trunk/src/hid_cfg.h (revision 1479) @@ -36,7 +36,7 @@ /* Search and load the menu res for hidname; if not found, and embedded_fallback is not NULL, parse that string instead. Returns NULL on error */ -hid_cfg_t *hid_cfg_load(const char *hidname, int exact_fn, const char *embedded_fallback); +hid_cfg_t *hid_cfg_load(const char *fn, int exact_fn, const char *embedded_fallback); /* Generic, low level lihata loader */ lht_doc_t *hid_cfg_load_lht(const char *filename); Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 1478) +++ trunk/src/main.c (revision 1479) @@ -1534,7 +1534,7 @@ paths_init_homedir(); - resolve_all_paths(fontfile_paths_in, fontfile_paths); + resolve_all_paths(fontfile_paths_in, fontfile_paths, 0); } static void set_fontfile(void) Index: trunk/src/paths.c =================================================================== --- trunk/src/paths.c (revision 1478) +++ trunk/src/paths.c (revision 1479) @@ -19,7 +19,7 @@ } -void resolve_paths(const char **in, char **out, int numpaths) +void resolve_paths(const char **in, char **out, int numpaths, unsigned int extra_room) { for (out; numpaths > 0; numpaths--, in++, out++) { if (*in != NULL) { @@ -32,11 +32,13 @@ /* avoid Concat() here to reduce dependencies for external tools */ l1 = strlen(homedir); l2 = strlen((*in) + 1); - *out = malloc(l1 + l2 + 4); + *out = malloc(l1 + l2 + 4 + extra_room); sprintf(*out, "%s/%s", homedir, (*in) + 1); } - else - *out = strdup(*in); + else { + *out = malloc(strlen(*in) + 1 + extra_room); + strcpy(*out, *in); + } } else *out = NULL; @@ -43,15 +45,15 @@ } } -void resolve_path(const char *in, char **out) +void resolve_path(const char *in, char **out, unsigned int extra_room) { - resolve_paths(&in, out, 1); + resolve_paths(&in, out, 1, extra_room); } -char *resolve_path_inplace(char *in) +char *resolve_path_inplace(char *in, unsigned int extra_room) { char *out; - resolve_path(in, &out); + resolve_path(in, &out, extra_room); free(in); return out; } Index: trunk/src/paths.h =================================================================== --- trunk/src/paths.h (revision 1478) +++ trunk/src/paths.h (revision 1479) @@ -1,22 +1,24 @@ -/* Allocate *out and copy the path from in to out, replacing ~ with homedir */ -void resolve_path(const char *in, char **out); +/* Allocate *out and copy the path from in to out, replacing ~ with homedir + If extra_room is non-zero, allocate this many bytes extra for each slot; + this leaves some room to append a file name. */ +void resolve_path(const char *in, char **out, unsigned int extra_room); /* Same as resolve_path, but it returns the pointer to the new path and calls free() on in */ -char *resolve_path_inplace(char *in); +char *resolve_path_inplace(char *in, unsigned int extra_room); /* Resolve all paths from a in[] into out[](should be large enough) */ -void resolve_paths(const char **in, char **out, int numpaths); +void resolve_paths(const char **in, char **out, int numpaths, unsigned int extra_room); /* Resolve all paths from a char *in[] into a freshly allocated char **out */ -#define resolve_all_paths(in, out) \ +#define resolve_all_paths(in, out, extra_room) \ do { \ int __numpath__ = sizeof(in) / sizeof(char *); \ if (__numpath__ > 0) { \ out = malloc(sizeof(char *) * __numpath__); \ - resolve_paths(in, out, __numpath__); \ + resolve_paths(in, out, __numpath__, extra_room); \ } \ } while(0) Index: trunk/src_plugins/fp_fs/fp_fs.c =================================================================== --- trunk/src_plugins/fp_fs/fp_fs.c (revision 1478) +++ trunk/src_plugins/fp_fs/fp_fs.c (revision 1479) @@ -217,7 +217,7 @@ int menuidx; sprintf(working_, "%s%c%s", toppath, PCB_DIR_SEPARATOR_C, subdir); - resolve_path(working_, &working); + resolve_path(working_, &working, 0); l.menu = fp_append_topdir(pcb_basename(toppath), pcb_basename(subdir), &menuidx); l.subdirs = NULL; @@ -293,7 +293,7 @@ memcpy(path, p, end - p); path[end - p] = '\0'; - resolve_path(path, &fpath); + resolve_path(path, &fpath, 0); /* fprintf(stderr, " in '%s'\n", fpath);*/ fp_fs_list(fpath, 1, fp_search_cb, &ctx, 1, 0);