Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 03855144 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Working

parent 79b1e7bf
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!63Resolve "Drop libpcre dependency"
Ce commit fait partie de la requête de fusion !63. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
......@@ -55,6 +55,12 @@
fprintf(stderr, " ! %s: %s\n", __func__, msg); \
return ret; \
}
#define GOTO_IF(cond, msg, label) \
if (cond) { \
fprintf(stderr, " ! %s: %s\n", __func__, msg); \
goto label; \
}
#define GOTO_UNLESS(cond, msg, label) GOTO_IF(!(cond), msg, ret)
#define RETURN_UNLESS(cond, msg, ret) RETURN_IF(!(cond), msg, ret)
#define NOTHING /* Usefull to return nothing. */
......@@ -152,16 +152,20 @@ metadata_from_path(char *const mkvfile, struct kara_metadata *meta)
"(jp|fr|en|ru|sp|it|ch|latin|multi|undefined)/(.+)/"
"(.+) - (OP|ED|IS|AMV|VOCA|PV|MV|LIVE)([[:digit:]]*) - (.+)\\.mkv$";
RETURN_IF(regcomp(&regex, rgx, REG_EXTENDED), "Failed to compile regex", false);
GOTO_IF(regcomp(&regex, rgx, REG_EXTENDED), "Failed to compile regex", error);
memset(meta, 0, sizeof(struct kara_metadata));
memset(msgbuf, 0, LEKTOR_TAG_MAX * sizeof(char));
reti = regexec(&regex, mkvfile, nmatch, pmatch, 0);
if (!reti) {
/* Match */
exit(100);
memcpy(meta->category, mkvfile + pmatch[2].rm_so, pmatch[2].rm_eo - pmatch[2].rm_so);
memcpy(meta->language, mkvfile + pmatch[3].rm_so, pmatch[3].rm_eo - pmatch[3].rm_so);
memcpy(meta->author_name, mkvfile + pmatch[4].rm_so, pmatch[4].rm_eo - pmatch[4].rm_so);
memcpy(meta->source_name, mkvfile + pmatch[5].rm_so, pmatch[5].rm_eo - pmatch[5].rm_so);
memcpy(meta->song_type, mkvfile + pmatch[6].rm_so, pmatch[6].rm_eo - pmatch[6].rm_so);
memcpy(msgbuf, mkvfile + pmatch[7].rm_so, pmatch[7].rm_eo - pmatch[7].rm_so);
memcpy(meta->song_name, mkvfile + pmatch[8].rm_so, pmatch[8].rm_eo - pmatch[8].rm_so);
} else if (REG_NOMATCH == reti) {
fprintf(stderr, "No match for: %s\n", mkvfile);
goto error;
......@@ -171,6 +175,12 @@ metadata_from_path(char *const mkvfile, struct kara_metadata *meta)
goto error;
}
if (msgbuf[0] != '\0') {
meta->song_number = atoi(msgbuf); /* TODO: Use strtol */
meta->song_number = MAX(1, meta->song_number);
} else
meta->song_number = 1;
sta = true;
error:
regfree(&regex);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter