static unsigned char * lem_utf8(const unsigned char *lem, const char *f, ssize_t ln) { const unsigned char *uni; if (!lem) return NULL; if (strpbrk(cc(lem),"0123456789")) { unsigned char *slow_uni = slow_lem_utf8(lem, f, ln); if (slow_uni) { unsigned char *ret = pool_copy(slow_uni); free(slow_uni); return ret; } else return pool_copy(lem); } else { uni = natf2utf2(lem,lem+strlen((const char *)lem), NULL, f, ln); if (uni) return pool_copy(uni); else return pool_copy(lem); } }
void xcl_sentence_labels(struct xcl_context *xc, struct xcl_c *c) { const char *first = NULL, *last = NULL; int n_lems = 0; if (c->type != xcl_c_sentence || !c->nchildren) return; first = first_l(c); last = last_l(c); if (first) { if (last) { char *l = malloc(strlen(first)+strlen(last)+4); sprintf(l,"%s - %s",first,last); c->label = cc(pool_copy(ucc(l))); free(l); } else c->label = cc(pool_copy(ucc(first))); } else if (n_lems) /* sentences that don't have lemmata don't matter */ { vwarning("couldn't compute label for sentence with id=%s",c->ref); } }
/* * backup_nonpoolset_overwrite -- (internal) overwrite pool */ static int backup_nonpoolset_overwrite(PMEMpoolcheck *ppc, location *loc, uint32_t question, void *context) { LOG(3, NULL); ASSERTne(loc, NULL); switch (question) { case Q_OVERWRITE_EXISTING_FILE: if (pool_copy(ppc->pool, ppc->backup_path, 1 /* overwrite */)) { location_release(loc); ppc->result = CHECK_RESULT_ERROR; return CHECK_ERR(ppc, "cannot perform backup"); } location_release(loc); loc->step = CHECK_STEP_COMPLETE; return 0; default: ERR("not implemented question id: %u", question); } return 0; }
static void * hash_insert(unsigned char *keyp, void *datap, Hash_table *tablep) { if (!hash_find(tablep,keyp)) hash_add(tablep,pool_copy(keyp),datap); return datap; }
void ez_psu_store(unsigned char *line, struct lang *lang) { struct ez_psu_save *psave = malloc(sizeof(struct ez_psu_save)); List *lp = NULL; const char *langname = NULL; if (lang && lang->name) langname = lang->name; while (isspace(*line)) ++line; if (*line == '%') { langname = (char*)++line; while (*line && !isspace(*line)) ++line; if (*line) *line++ = '\0'; } if (!psu_save_lists) psu_save_lists = hash_create(1); if ((lp != hash_find(psu_save_lists,(unsigned char *)langname))) { lp = list_create(LIST_SINGLE); hash_add(psu_save_lists,(unsigned char *)langname,lp); } psave->line = pool_copy(line); psave->lnum = lnum; psave->lang = lang; if (lp) list_add(lp, psave); }
/* * backup_nonpoolset_create -- (internal) create backup */ static int backup_nonpoolset_create(PMEMpoolcheck *ppc, location *loc) { CHECK_INFO(ppc, "creating backup file: %s", ppc->backup_path); if (pool_copy(ppc->pool, ppc->backup_path, 0)) { location_release(loc); ppc->result = CHECK_RESULT_ERROR; return CHECK_ERR(ppc, "cannot perform backup"); } location_release(loc); loc->step = CHECK_STEP_COMPLETE; return 0; }
/* We have to treat line as const here because it is included in the output */ void link_check_protocol(const char *line) { const char *idp; while (isspace(*line)) ++line; if (!strncmp(line,"def",3)) { line += 3; while (isspace(*line)) ++line; if (*line) { char symbuf[10]; int i = 0; while (*line && !isspace(*line) && i < 10) symbuf[i++] = *line++; if (i == 10) { symbuf[9] = '\0'; vwarning("malformed link: protocol: symbol '%s' too long (max 9 characters)", symbuf); } else { symbuf[i] = '\0'; while (isspace(*line)) ++line; if ('=' == *line && isspace(line[1])) { line += 2; while (isspace(*line)) ++line; idp = scan_pair(line); if (idp) { idp = (char*)pool_copy((unsigned char*)idp); define_labels_symbol(symbuf,idp); if (doctype == e_score) symbolattr_put(textid,symbuf,idp,last_pname); if (check_links) load_labels(idp); } } else warning("malformed link: protocol: expected ' = ' after def's symbol"); } } else warning("malformed link: protocol: expected symbol (e.g., 'A')"); } else if (!strncmp(line,"parallel", 8) || !strncmp(line,"source",6)) { int is_source = *line == 's'; const char *colon = NULL; line += (is_source ? 6 : 8); while (isspace(*line)) ++line; if ((colon = strchr(line, ':'))) ++colon; else colon = line; if (*colon == 'P' || *colon == 'Q' || *colon == 'X') (void)scan_pair(line); else vwarning("bad link: %s: expected P-id or Q-id (or X-id)", is_source ? "source" : "parallel"); } else { char ebuf[10]; int i = 0; while (*line && i < 10) ebuf[i++] = *line++; ebuf[i] = '\0'; vwarning("bad link: protocol '%s' (expected def, source or parallel)", ebuf); } }