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
64aecb75
Vérifiée
Valider
64aecb75
rédigé
Il y a 4 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
BASE: Can now escape the '"' and the escape '\"' is decoded into '"'
parent
0af2ea79
Branches
Branches contenant la validation
Étiquettes
Étiquettes contenant la validation
1 requête de fusion
!130
Resolve "Remove json-c"
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/base/json.c
+46
-2
46 ajouts, 2 suppressions
src/base/json.c
avec
46 ajouts
et
2 suppressions
src/base/json.c
+
46
−
2
Voir le fichier @
64aecb75
...
@@ -36,14 +36,58 @@ skip(char *s)
...
@@ -36,14 +36,58 @@ skip(char *s)
is_paren = 0; \
is_paren = 0; \
if (str[0] == __JSON_SEP) { \
if (str[0] == __JSON_SEP) { \
++str; \
++str; \
char *end = strchr(str, __JSON_SEP); \
const char *begin = str, *end; \
for (;;) { \
end = strchr(begin, __JSON_SEP); \
if (*(end - 1) == '\\') { \
begin = end + 1; \
continue; \
} \
break; \
} \
len = (end - str); \
len = (end - str); \
is_paren = 1; \
is_paren = 1; \
} else \
} else \
len = strcspn(str, __JSON_SPACE __JSON_BEGIN __JSON_END); \
len = strcspn(str, __JSON_SPACE __JSON_BEGIN __JSON_END); \
if (level == asked_level && len < LKT_LINE_MAX - 1) \
if (level == asked_level && len < LKT_LINE_MAX - 1) \
strncpy(dest, str, len); \
strncpy(dest, str, len); \
str += len + is_paren; \
str += len; \
/* Also decode '\"' => '"' */
\
if (is_paren) { \
++str; \
__replace(key, "\\\"", "\""); \
__replace(val, "\\\"", "\""); \
} \
}
/* WARN: strlen(from) >= strlen(to) */
static
inline
int
__replace
(
char
*
string
,
const
char
*
from
,
const
char
*
to
)
{
if
(
strlen
(
from
)
<
strlen
(
to
))
{
LOG_ERROR
(
"JSON"
,
"The size of the 'to' string must be inferior "
"or equal to the size of the 'from' string"
);
return
1
;
}
if
(
strstr
(
to
,
from
))
{
LOG_ERROR
(
"JSON"
,
"At least one string '%s' has been found in '%s', exit "
"before looping until the end of the universe"
,
from
,
to
);
return
1
;
}
size_t
step
=
strlen
(
from
)
-
strlen
(
to
);
char
*
start
=
string
;
for
(;;)
{
start
=
strstr
(
start
,
from
);
if
(
start
==
NULL
||
*
start
==
'\0'
)
break
;
strncpy
(
start
,
to
,
strlen
(
to
));
start
+=
strlen
(
to
);
memmove
(
start
,
start
+
step
,
strlen
(
start
+
step
)
*
sizeof
(
char
));
start
[
strlen
(
start
)
-
step
]
=
'\0'
;
}
return
0
;
}
}
int
int
...
...
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