Commit Diff
Commit:
d2d73a094eb58f7ecf091d401f4d33ca905e17cd
From:
Omar Polo <op@omarpolo.com>
Date:
Mon Dec 26 17:41:56 2022 UTC
Message
iri: change remove_dot_segmens to take a buffer instead of an iri
commit - 6d0918263815f42917efe14158e8f1c21b1aae22
commit + d2d73a094eb58f7ecf091d401f4d33ca905e17cd
blob - 752936b447d350244418b89e47c9861bf9797ef1
blob + 3ef5adffb4966a3003b993abc2656429566e5baf
--- iri.c
+++ iri.c
@@ -507,13 +507,11 @@ remove_dot_segments(struct iri *i)
}
static inline int
-remove_dot_segments(struct iri *i)
+remove_dot_segments(char *buf, ptrdiff_t bufsize)
{
- char *p, *q, *buf;
- ptrdiff_t bufsize;
+ char *p, *q;
- buf = p = q = i->iri_path;
- bufsize = sizeof(i->iri_path);
+ p = q = buf;
while (*p && (q - buf < bufsize)) {
if (p[0] == '/' && p[1] == '.' &&
(p[2] == '/' || p[2] == '\0')) {
@@ -598,7 +596,7 @@ iri_parse(const char *base, const char *str, struct ir
if (iparsed.iri_flags & IH_SCHEME) {
cpfields(iri, &iparsed, iparsed.iri_flags);
- remove_dot_segments(iri);
+ remove_dot_segments(iri->iri_path, sizeof(iri->iri_path));
return (0);
}
@@ -606,7 +604,7 @@ iri_parse(const char *base, const char *str, struct ir
if (iparsed.iri_flags & IH_HOST) {
cpfields(iri, &iparsed, IH_AUTHORITY|IH_PATH|IH_QUERY);
- remove_dot_segments(iri);
+ remove_dot_segments(iri->iri_path, sizeof(iri->iri_path));
return (0);
}
@@ -632,7 +630,7 @@ iri_parse(const char *base, const char *str, struct ir
if (mergepath(iri, &ibase, &iparsed) == -1)
return (-1);
}
- if (remove_dot_segments(iri) == -1)
+ if (remove_dot_segments(iri->iri_path, sizeof(iri->iri_path)) == -1)
return (-1);
return (0);
}
Omar Polo