/* * Concatenate a directory path and a filename. Note that this function * currently does NOT handle the case where file itself contains * directory components (except on Unix platforms, because it is trivial.) */ char *nasm_catfile(const char *dir, const char *file) { #ifndef catsep return nasm_strcat(dir, file); #else size_t dl = strlen(dir); size_t fl = strlen(file); char *p; bool dosep = true; if (!dl || ismatch(separators, dir[dl-1])) { /* No separator necessary */ dosep = false; } p = nasm_malloc(dl + fl + dosep + 1); memcpy(p, dir, dl); p += dl; if (dosep) *p++ = catsep; memcpy(p, file, fl+1); return p; #endif }
/* * Internal routine: finds the `union label' corresponding to the * given label name. Creates a new one, if it isn't found, and if * `create' is true. */ static union label *find_label(const char *label, bool create, bool *created) { union label *lptr, **lpp; char *label_str = NULL; struct hash_insert ip; nasm_assert(label != NULL); if (islocal(label)) label = label_str = nasm_strcat(prevlabel, label); lpp = (union label **) hash_find(<ab, label, &ip); lptr = lpp ? *lpp : NULL; if (lptr || !create) { if (created) *created = false; return lptr; } /* Create a new label... */ if (lfree->admin.movingon == END_BLOCK) { /* * must allocate a new block */ lfree->admin.next = nasm_malloc(LBLK_SIZE); lfree = lfree->admin.next; init_block(lfree); } if (created) *created = true; nasm_zero(*lfree); lfree->defn.label = perm_copy(label); lfree->defn.subsection = NO_SEG; if (label_str) nasm_free(label_str); hash_add(&ip, lfree->defn.label, lfree); return lfree++; }