35 std::vector<int> v(nkeyword);
37 for (
size_t i = 0; i < nkeyword; ++i) {
38 Filename::keyvalue_type::const_iterator p = kv.find(
keywords_[i]);
60 return format_(3, v[0], v[1], v[2]);
63 return format_(4, v[0], v[1], v[2], v[3]);
66 return format_(5, v[0], v[1], v[2], v[3], v[4]);
69 return format_(6, v[0], v[1], v[2], v[3], v[4], v[5]);
84 static const int buf_size = 4096;
85 static char buf[buf_size];
93 return std::string(buf);
102 const char pattern[] =
"\\{([._[:alnum:]]+)(:([[:digit:]]+))?\\}";
103 const int num_regmatch = 4;
107 if (
int retv = regcomp(®, pattern, REG_EXTENDED)) {
108 vout.
crucial(
"regcomp failed. %s(%d)\n", strerror(retv), retv);
112 regmatch_t regmatch[num_regmatch];
114 memset(fmt,
'\0', fmt_size);
122 int v = regexec(®, msg +
idx, num_regmatch, regmatch, 0);
128 strncpy(bufp, msg +
idx, regmatch[0].rm_so);
129 bufp += regmatch[0].rm_so;
132 memset(keyword,
'\0', 128);
133 strncpy(keyword, msg +
idx + regmatch[1].rm_so, regmatch[1].rm_eo - regmatch[1].rm_so);
138 if (regmatch[3].rm_so != (regoff_t)-1) {
139 width = atoi(msg +
idx + regmatch[3].rm_so);
144 memset(tmp,
'\0', 128);
146 snprintf(tmp, 128,
"%%0%dd", width);
148 strncpy(bufp, tmp, strlen(tmp));
151 strncpy(bufp,
"%d", strlen(
"%d"));
152 bufp += strlen(
"%d");
155 idx += regmatch[0].rm_eo;
158 strncpy(bufp, msg +
idx, strlen(msg) -
idx);