/* ARGSUSED */ size_t cli_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) { struct rerr *r; size_t len; int target = errcode &~ REG_ITOA; const char *s; char convbuf[50]; if (errcode == REG_ATOI) s = regatoi(preg, convbuf, sizeof convbuf); else { for (r = rerrs; r->code != 0; r++) if (r->code == target) break; if (errcode®_ITOA) { if (r->code != 0) { assert(strlen(r->name) < sizeof(convbuf)); (void) cli_strlcpy(convbuf, r->name, sizeof convbuf); } else (void)snprintf(convbuf, sizeof convbuf, "REG_0x%x", target); s = convbuf; } else s = r->explain; } len = strlen(s) + 1; if (errbuf_size > 0) { cli_strlcpy(errbuf, s, errbuf_size); } return(len); }
/* - mcadd - add a collating element to a cset */ static void mcadd( struct parse *p, cset *cs, const char *cp) { size_t oldend = cs->smultis; void *np; cs->smultis += strlen(cp) + 1; np = cli_realloc(cs->multis, cs->smultis); if (np == NULL) { if (cs->multis) free(cs->multis); cs->multis = NULL; SETERROR(REG_ESPACE); return; } cs->multis = np; cli_strlcpy(cs->multis + oldend - 1, cp, cs->smultis - oldend + 1); }