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é GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
bdc0db1a
Vérifiée
Valider
bdc0db1a
rédigé
Il y a 5 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
WIP: Removes PCRE, prepare for POSIX regex, NOT WORKING
parent
89ed2e9a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!63
Resolve "Drop libpcre dependency"
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
meson.build
+0
-1
0 ajout, 1 suppression
meson.build
src/mkv/write.c
+20
-69
20 ajouts, 69 suppressions
src/mkv/write.c
avec
20 ajouts
et
70 suppressions
meson.build
+
0
−
1
Voir le fichier @
bdc0db1a
...
@@ -53,7 +53,6 @@ includes = include_directories('inc')
...
@@ -53,7 +53,6 @@ includes = include_directories('inc')
# Server
# Server
core_deps
=
[
dependency
(
'sqlite3'
,
version
:
'>= 3.31.0'
)
core_deps
=
[
dependency
(
'sqlite3'
,
version
:
'>= 3.31.0'
)
,
dependency
(
'libpcre'
)
,
dependency
(
'libcurl'
)
,
dependency
(
'libcurl'
)
,
dependency
(
'json-c'
)
,
dependency
(
'json-c'
)
,
dependency
(
'threads'
,
required
:
true
)
,
dependency
(
'threads'
,
required
:
true
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/mkv/write.c
+
20
−
69
Voir le fichier @
bdc0db1a
#define _POSIX_C_SOURCE 200809L
#define _POSIX_C_SOURCE 200809L
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include
<lektor/macro.h>
#include
<lektor/defines.h>
#include
<lektor/mkv.h>
#include
<lektor/mkv.h>
#include
<stdbool.h>
#include
<stdbool.h>
#include
<stdio.h>
#include
<stdio.h>
...
@@ -16,8 +18,6 @@
...
@@ -16,8 +18,6 @@
#include
<sys/types.h>
#include
<sys/types.h>
#include
<regex.h>
#include
<regex.h>
#include
<pcre.h>
static
const
char
*
METADATA_TEMPLATE
=
static
const
char
*
METADATA_TEMPLATE
=
" <?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?> "
" <?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?> "
" <Tags> "
" <Tags> "
...
@@ -141,88 +141,39 @@ error:
...
@@ -141,88 +141,39 @@ error:
static
bool
static
bool
metadata_from_path
(
char
*
const
mkvfile
,
struct
kara_metadata
*
meta
)
metadata_from_path
(
char
*
const
mkvfile
,
struct
kara_metadata
*
meta
)
{
{
pcre
*
regex
=
NULL
;
regex_t
regex
;
pcre_extra
*
pcre_extra
=
NULL
;
const
size_t
nmatch
=
10
;
bool
sta
=
false
;
regmatch_t
pmatch
[
nmatch
];
const
int
sub_str_vec_len
=
30
;
int
reti
,
sta
=
false
;
int
pcre_error_offset
,
pcre_exec_ret
,
sub_str_vec
[
sub_str_vec_len
],
i
,
num
;
char
msgbuf
[
LEKTOR_TAG_MAX
];
char
num_str
[
LEKTOR_TAG_MAX
];
const
char
*
substr
;
char
*
copy_to
;
static
const
char
*
rgx
=
static
const
char
*
rgx
=
"^
\\
/(?:.+)
\\
/(vo|va|amv|cdg|autres|vocaloid)
\\
/"
"^
\\
/(?:.+)
\\
/(vo|va|amv|cdg|autres|vocaloid)
\\
/"
"(jp|fr|en|ru|sp|it|ch|latin|multi|undefined)
\\
/(.+)
\\
/"
"(jp|fr|en|ru|sp|it|ch|latin|multi|undefined)
\\
/(.+)
\\
/"
"(.+) - (OP|ED|IS|AMV|VOCA|PV|MV|LIVE)(
\\
d*) - (.+)
\\
.mkv$"
;
"(.+) - (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
);
RETURN_IF
(
regcomp
(
&
regex
,
rgx
,
REG_EXTENDED
),
"Failed to compile regex"
,
false
);
if
(
pcre_error_str
!=
NULL
)
{
fprintf
(
stderr
,
" ! metadata_from_path: failed to study regex: %s
\n
"
,
pcre_error_str
);
goto
error
;
}
memset
(
meta
,
0
,
sizeof
(
struct
kara_metadata
));
memset
(
meta
,
0
,
sizeof
(
struct
kara_metadata
));
memset
(
num_str
,
0
,
LEKTOR_TAG_MAX
*
sizeof
(
char
));
memset
(
msgbuf
,
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
);
if
(
pcre_exec_ret
<
0
)
{
reti
=
regexec
(
&
regex
,
mkvfile
,
nmatch
,
pmatch
,
0
);
fprintf
(
stderr
,
" ! metadata_from_path: PCRE error
\n
"
);
goto
error
;
}
if
(
pcre_exec_ret
==
0
)
{
if
(
!
reti
)
{
// To much -> error in our case //
/* Match */
fprintf
(
stderr
,
" ! metadata_from_path: To much matches found for file: %s
\n
"
,
mkvfile
);
exit
(
100
);
}
else
if
(
REG_NOMATCH
==
reti
)
{
fprintf
(
stderr
,
"No match for: %s
\n
"
,
mkvfile
);
goto
error
;
goto
error
;
}
}
else
{
regerror
(
reti
,
&
regex
,
msgbuf
,
sizeof
(
msgbuf
));
for
(
i
=
1
;
i
<
pcre_exec_ret
;
++
i
)
{
fprintf
(
stderr
,
"Failed to execute regex: %s
\n
"
,
msgbuf
);
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
;
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
;
sta
=
true
;
error:
error:
pcre_free
(
regex
);
regfree
(
&
regex
);
if
(
pcre_extra
!=
NULL
)
{
#ifdef PCRE_CONFIG_JIT
pcre_free_study
(
pcre_extra
);
#else
pcre_free
(
pcre_extra
);
#endif
}
return
sta
;
return
sta
;
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter