Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Requêtes de fusion
!63
Resolve "Drop libpcre dependency"
Code
Examiner les modifications
Extraire la branche
Télécharger
Correctifs
Diff brut
Fusionnées
Resolve "Drop libpcre dependency"
drop-pcre
vers
master
Vue d'ensemble
0
Validations
7
Pipelines
0
Modifications
2
Fusionnées
Kubat
a demandé de fusionner
drop-pcre
vers
master
5 years ago
Vue d'ensemble
0
Validations
7
Pipelines
0
Modifications
2
Étendre
Closes
#32 (closed)
Modification effectuée
5 years ago
par
Kubat
0
0
Rapports de requête de fusion
Affichage du commit
bdc0db1a
Précédent
Suivant
Afficher la dernière version
2 fichiers
+
20
−
70
En ligne
Comparer les modifications
Côte à côte
En ligne
Afficher les modifications des espaces
Afficher un fichier à la fois
Fichiers
2
Rechercher (par ex. *.vue) (Ctrl+P)
Vérifiée
bdc0db1a
WIP: Removes PCRE, prepare for POSIX regex, NOT WORKING
· bdc0db1a
Kubat
rédigé
5 years ago
src/mkv/write.c
+
20
−
69
Options
#define _POSIX_C_SOURCE 200809L
#define _DEFAULT_SOURCE
#include
<lektor/macro.h>
#include
<lektor/defines.h>
#include
<lektor/mkv.h>
#include
<stdbool.h>
#include
<stdio.h>
@@ -16,8 +18,6 @@
#include
<sys/types.h>
#include
<regex.h>
#include
<pcre.h>
static
const
char
*
METADATA_TEMPLATE
=
" <?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?> "
" <Tags> "
@@ -141,88 +141,39 @@ error:
static
bool
metadata_from_path
(
char
*
const
mkvfile
,
struct
kara_metadata
*
meta
)
{
pcre
*
regex
=
NULL
;
pcre_extra
*
pcre_extra
=
NULL
;
bool
sta
=
false
;
const
int
sub_str_vec_len
=
30
;
int
pcre_error_offset
,
pcre_exec_ret
,
sub_str_vec
[
sub_str_vec_len
],
i
,
num
;
char
num_str
[
LEKTOR_TAG_MAX
];
const
char
*
substr
;
char
*
copy_to
;
regex_t
regex
;
const
size_t
nmatch
=
10
;
regmatch_t
pmatch
[
nmatch
];
int
reti
,
sta
=
false
;
char
msgbuf
[
LEKTOR_TAG_MAX
];
static
const
char
*
rgx
=
"^
\\
/(?:.+)
\\
/(vo|va|amv|cdg|autres|vocaloid)
\\
/"
"(jp|fr|en|ru|sp|it|ch|latin|multi|undefined)
\\
/(.+)
\\
/"
"(.+) - (OP|ED|IS|AMV|VOCA|PV|MV|LIVE)(
\\
d*) - (.+)
\\
.mkv$"
;
const
char
*
pcre_error_str
=
NULL
;
if
((
regex
=
pcre_compile
(
rgx
,
0
,
&
pcre_error_str
,
&
pcre_error_offset
,
NULL
))
==
NULL
)
{
fprintf
(
stderr
,
" ! metadata_from_path: failed to compile regex
\n
"
);
return
false
;
}
pcre_extra
=
pcre_study
(
regex
,
0
,
&
pcre_error_str
);
if
(
pcre_error_str
!=
NULL
)
{
fprintf
(
stderr
,
" ! metadata_from_path: failed to study regex: %s
\n
"
,
pcre_error_str
);
goto
error
;
}
RETURN_IF
(
regcomp
(
&
regex
,
rgx
,
REG_EXTENDED
),
"Failed to compile regex"
,
false
);
memset
(
meta
,
0
,
sizeof
(
struct
kara_metadata
));
memset
(
num_str
,
0
,
LEKTOR_TAG_MAX
*
sizeof
(
char
));
pcre_exec_ret
=
pcre_exec
(
regex
,
pcre_extra
,
mkvfile
,
strlen
(
mkvfile
),
0
,
0
,
sub_str_vec
,
sub_str_vec_len
);
memset
(
msgbuf
,
0
,
LEKTOR_TAG_MAX
*
sizeof
(
char
));
if
(
pcre_exec_ret
<
0
)
{
fprintf
(
stderr
,
" ! metadata_from_path: PCRE error
\n
"
);
goto
error
;
}
reti
=
regexec
(
&
regex
,
mkvfile
,
nmatch
,
pmatch
,
0
);
if
(
pcre_exec_ret
==
0
)
{
// To much -> error in our case //
fprintf
(
stderr
,
" ! metadata_from_path: To much matches found for file: %s
\n
"
,
mkvfile
);
if
(
!
reti
)
{
/* Match */
exit
(
100
);
}
else
if
(
REG_NOMATCH
==
reti
)
{
fprintf
(
stderr
,
"No match for: %s
\n
"
,
mkvfile
);
goto
error
;
}
else
{
regerror
(
reti
,
&
regex
,
msgbuf
,
sizeof
(
msgbuf
));
fprintf
(
stderr
,
"Failed to execute regex: %s
\n
"
,
msgbuf
);
goto
error
;
}
for
(
i
=
1
;
i
<
pcre_exec_ret
;
++
i
)
{
pcre_get_substring
(
mkvfile
,
sub_str_vec
,
pcre_exec_ret
,
i
,
&
substr
);
if
(
i
==
1
)
copy_to
=
meta
->
song_type
;
else
if
(
i
==
2
)
copy_to
=
meta
->
language
;
else
if
(
i
==
3
)
copy_to
=
meta
->
author_name
;
else
if
(
i
==
4
)
copy_to
=
meta
->
source_name
;
else
if
(
i
==
5
)
copy_to
=
meta
->
category
;
else
if
(
i
==
6
)
copy_to
=
num_str
;
else
if
(
i
==
7
)
copy_to
=
meta
->
song_name
;
else
{
pcre_free_substring
(
substr
);
goto
error
;
}
snprintf
(
copy_to
,
LEKTOR_TAG_MAX
,
"%s"
,
substr
);
pcre_free_substring
(
substr
);
}
meta
->
song_number
=
((
num
=
atoi
(
num_str
))
<=
0
)
?
1
:
num
;
sta
=
true
;
error:
pcre_free
(
regex
);
if
(
pcre_extra
!=
NULL
)
{
#ifdef PCRE_CONFIG_JIT
pcre_free_study
(
pcre_extra
);
#else
pcre_free
(
pcre_extra
);
#endif
}
regfree
(
&
regex
);
return
sta
;
}
Chargement en cours