Skip to content

Commit 11725f2

Browse files
clang-format 21.1.3hartwork
authored andcommitted
Mass-apply clang-format 21.1.3
1 parent 080ca88 commit 11725f2

18 files changed

Lines changed: 448 additions & 464 deletions

src/UriCommon.c

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -671,30 +671,29 @@ static UriBool URI_FUNC(PrependNewDotSegment)(URI_TYPE(Uri) * uri,
671671
assert(uri != NULL);
672672
assert(memory != NULL);
673673

674-
URI_TYPE(PathSegment) * const segment =
675-
memory->malloc(memory, 1 * sizeof(URI_TYPE(PathSegment)));
674+
URI_TYPE(PathSegment) * const segment =
675+
memory->malloc(memory, 1 * sizeof(URI_TYPE(PathSegment)));
676676

677-
if (segment == NULL) {
678-
return URI_FALSE; /* i.e. raise malloc error */
679-
}
677+
if (segment == NULL) {
678+
return URI_FALSE; /* i.e. raise malloc error */
679+
}
680680

681-
segment->next = uri->pathHead;
681+
segment->next = uri->pathHead;
682682

683-
URI_TYPE(TextRange) dotRange;
684-
dotRange.first = URI_FUNC(ConstPwd);
685-
dotRange.afterLast = URI_FUNC(ConstPwd) + 1;
683+
URI_TYPE(TextRange) dotRange;
684+
dotRange.first = URI_FUNC(ConstPwd);
685+
dotRange.afterLast = URI_FUNC(ConstPwd) + 1;
686686

687-
if (uri->owner == URI_TRUE) {
688-
if (URI_FUNC(CopyRange)(&(segment->text), &dotRange, memory)
689-
== URI_FALSE) {
690-
memory->free(memory, segment);
691-
return URI_FALSE; /* i.e. raise malloc error */
692-
}
693-
} else {
694-
segment->text = dotRange; /* copies all members */
695-
}
687+
if (uri->owner == URI_TRUE) {
688+
if (URI_FUNC(CopyRange)(&(segment->text), &dotRange, memory) == URI_FALSE) {
689+
memory->free(memory, segment);
690+
return URI_FALSE; /* i.e. raise malloc error */
691+
}
692+
} else {
693+
segment->text = dotRange; /* copies all members */
694+
}
696695

697-
uri->pathHead = segment;
696+
uri->pathHead = segment;
698697

699698
return URI_TRUE;
700699
}
@@ -726,22 +725,22 @@ UriBool URI_FUNC(FixPathNoScheme)(URI_TYPE(Uri) * uri, UriMemoryManager * memory
726725
}
727726

728727
/* Check for troublesome first path segment containing a colon */
729-
UriBool colonFound = URI_FALSE;
730-
const URI_CHAR * walker = uri->pathHead->text.first;
728+
UriBool colonFound = URI_FALSE;
729+
const URI_CHAR * walker = uri->pathHead->text.first;
731730

732-
while (walker < uri->pathHead->text.afterLast) {
733-
if (walker[0] == _UT(':')) {
734-
colonFound = URI_TRUE;
735-
break;
736-
}
737-
walker++;
731+
while (walker < uri->pathHead->text.afterLast) {
732+
if (walker[0] == _UT(':')) {
733+
colonFound = URI_TRUE;
734+
break;
738735
}
736+
walker++;
737+
}
739738

740-
assert((walker == uri->pathHead->text.afterLast) || (colonFound == URI_TRUE));
739+
assert((walker == uri->pathHead->text.afterLast) || (colonFound == URI_TRUE));
741740

742-
if (colonFound == URI_FALSE) {
743-
return URI_TRUE; /* i.e. nothing to do */
744-
}
741+
if (colonFound == URI_FALSE) {
742+
return URI_TRUE; /* i.e. nothing to do */
743+
}
745744

746745
/* Insert "." segment in front */
747746
return URI_FUNC(PrependNewDotSegment)(uri, memory);

src/UriFile.c

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -140,54 +140,51 @@ static URI_INLINE int URI_FUNC(UriStringToFilename)(const URI_CHAR * uriString,
140140
return URI_ERROR_NULL;
141141
}
142142

143-
const UriBool file_unknown_slashes =
144-
URI_STRNCMP(uriString, _UT("file:"), URI_STRLEN(_UT("file:"))) == 0;
145-
const UriBool file_one_or_more_slashes =
146-
file_unknown_slashes
147-
&& (URI_STRNCMP(uriString, _UT("file:/"), URI_STRLEN(_UT("file:/"))) == 0);
148-
const UriBool file_two_or_more_slashes =
149-
file_one_or_more_slashes
150-
&& (URI_STRNCMP(uriString, _UT("file://"), URI_STRLEN(_UT("file://"))) == 0);
151-
const UriBool file_three_or_more_slashes =
152-
file_two_or_more_slashes
153-
&& (URI_STRNCMP(uriString, _UT("file:///"), URI_STRLEN(_UT("file:///")))
154-
== 0);
155-
156-
const size_t charsToSkip =
157-
file_two_or_more_slashes
158-
? file_three_or_more_slashes
159-
? toUnix
160-
/* file:///bin/bash */
161-
? URI_STRLEN(_UT("file://"))
162-
/* file:///E:/Documents%20and%20Settings */
163-
: URI_STRLEN(_UT("file:///"))
164-
/* file://Server01/Letter.txt */
165-
: URI_STRLEN(_UT("file://"))
166-
: ((file_one_or_more_slashes && toUnix)
167-
/* file:/bin/bash */
168-
/* https://tools.ietf.org/html/rfc8089#appendix-B */
169-
? URI_STRLEN(_UT("file:"))
170-
: ((!toUnix && file_unknown_slashes && !file_one_or_more_slashes)
171-
/* file:c:/path/to/file */
172-
/* https://tools.ietf.org/html/rfc8089#appendix-E.2 */
173-
? URI_STRLEN(_UT("file:"))
174-
: 0));
175-
const size_t charsToCopy = URI_STRLEN(uriString + charsToSkip) + 1;
176-
177-
const UriBool is_windows_network_with_authority = (toUnix == URI_FALSE)
178-
&& file_two_or_more_slashes
179-
&& !file_three_or_more_slashes;
180-
181-
URI_CHAR * const unescape_target =
182-
is_windows_network_with_authority ? (filename + 2) : filename;
183-
184-
if (is_windows_network_with_authority) {
185-
filename[0] = '\\';
186-
filename[1] = '\\';
187-
}
143+
const UriBool file_unknown_slashes =
144+
URI_STRNCMP(uriString, _UT("file:"), URI_STRLEN(_UT("file:"))) == 0;
145+
const UriBool file_one_or_more_slashes =
146+
file_unknown_slashes
147+
&& (URI_STRNCMP(uriString, _UT("file:/"), URI_STRLEN(_UT("file:/"))) == 0);
148+
const UriBool file_two_or_more_slashes =
149+
file_one_or_more_slashes
150+
&& (URI_STRNCMP(uriString, _UT("file://"), URI_STRLEN(_UT("file://"))) == 0);
151+
const UriBool file_three_or_more_slashes =
152+
file_two_or_more_slashes
153+
&& (URI_STRNCMP(uriString, _UT("file:///"), URI_STRLEN(_UT("file:///"))) == 0);
154+
155+
const size_t charsToSkip =
156+
file_two_or_more_slashes
157+
? file_three_or_more_slashes ? toUnix
158+
/* file:///bin/bash */
159+
? URI_STRLEN(_UT("file://"))
160+
/* file:///E:/Documents%20and%20Settings */
161+
: URI_STRLEN(_UT("file:///"))
162+
/* file://Server01/Letter.txt */
163+
: URI_STRLEN(_UT("file://"))
164+
: ((file_one_or_more_slashes && toUnix)
165+
/* file:/bin/bash */
166+
/* https://tools.ietf.org/html/rfc8089#appendix-B */
167+
? URI_STRLEN(_UT("file:"))
168+
: ((!toUnix && file_unknown_slashes && !file_one_or_more_slashes)
169+
/* file:c:/path/to/file */
170+
/* https://tools.ietf.org/html/rfc8089#appendix-E.2 */
171+
? URI_STRLEN(_UT("file:"))
172+
: 0));
173+
const size_t charsToCopy = URI_STRLEN(uriString + charsToSkip) + 1;
174+
175+
const UriBool is_windows_network_with_authority =
176+
(toUnix == URI_FALSE) && file_two_or_more_slashes && !file_three_or_more_slashes;
177+
178+
URI_CHAR * const unescape_target =
179+
is_windows_network_with_authority ? (filename + 2) : filename;
180+
181+
if (is_windows_network_with_authority) {
182+
filename[0] = '\\';
183+
filename[1] = '\\';
184+
}
188185

189-
memcpy(unescape_target, uriString + charsToSkip, charsToCopy * sizeof(URI_CHAR));
190-
URI_FUNC(UnescapeInPlaceEx)(filename, URI_FALSE, URI_BR_DONT_TOUCH);
186+
memcpy(unescape_target, uriString + charsToSkip, charsToCopy * sizeof(URI_CHAR));
187+
URI_FUNC(UnescapeInPlaceEx)(filename, URI_FALSE, URI_BR_DONT_TOUCH);
191188

192189
/* Convert forward slashes to backslashes */
193190
if (!toUnix) {

src/UriMemory.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,15 @@ int uriTestMemoryManagerEx(UriMemoryManager * memory, UriBool challengeAlignment
436436
ptr[2] = 2.2L;
437437
ptr[3] = 3.3L;
438438

439-
long double * const ptrNew =
440-
memory->realloc(memory, ptr, 8 * sizeof(long double));
441-
if (ptrNew != NULL) {
442-
ptr = ptrNew;
443-
ptr[4] = 4.4L;
444-
ptr[5] = 5.5L;
445-
ptr[6] = 6.6L;
446-
ptr[7] = 7.7L;
447-
}
439+
long double * const ptrNew =
440+
memory->realloc(memory, ptr, 8 * sizeof(long double));
441+
if (ptrNew != NULL) {
442+
ptr = ptrNew;
443+
ptr[4] = 4.4L;
444+
ptr[5] = 5.5L;
445+
ptr[6] = 6.6L;
446+
ptr[7] = 7.7L;
447+
}
448448

449449
memory->free(memory, ptr);
450450
}

src/UriNormalize.c

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -524,22 +524,22 @@ static const URI_CHAR * URI_FUNC(PastLeadingZeros)(const URI_CHAR * first,
524524
assert(afterLast != NULL);
525525
assert(first != afterLast);
526526

527-
/* Find the first non-zero character */
528-
const URI_CHAR * remainderFirst = first;
529-
while ((remainderFirst < afterLast) && (remainderFirst[0] == _UT('0'))) {
530-
remainderFirst++;
531-
}
527+
/* Find the first non-zero character */
528+
const URI_CHAR * remainderFirst = first;
529+
while ((remainderFirst < afterLast) && (remainderFirst[0] == _UT('0'))) {
530+
remainderFirst++;
531+
}
532532

533-
/* Is the string /all/ zeros? */
534-
if (remainderFirst == afterLast) {
535-
/* Yes, and length is >=1 because we ruled out the empty string earlier;
536-
* pull back onto rightmost zero */
537-
assert(remainderFirst > first);
538-
remainderFirst--;
539-
assert(remainderFirst[0] == _UT('0'));
540-
}
533+
/* Is the string /all/ zeros? */
534+
if (remainderFirst == afterLast) {
535+
/* Yes, and length is >=1 because we ruled out the empty string earlier;
536+
* pull back onto rightmost zero */
537+
assert(remainderFirst > first);
538+
remainderFirst--;
539+
assert(remainderFirst[0] == _UT('0'));
540+
}
541541

542-
return remainderFirst;
542+
return remainderFirst;
543543
}
544544

545545
static void URI_FUNC(DropLeadingZerosInplace)(URI_CHAR * first,
@@ -552,15 +552,14 @@ static void URI_FUNC(DropLeadingZerosInplace)(URI_CHAR * first,
552552
return;
553553
}
554554

555-
const URI_CHAR * const remainderFirst =
556-
URI_FUNC(PastLeadingZeros)(first, *afterLast);
555+
const URI_CHAR * const remainderFirst = URI_FUNC(PastLeadingZeros)(first, *afterLast);
557556

558-
if (remainderFirst > first) {
559-
const size_t remainderLen = *afterLast - remainderFirst;
560-
memmove(first, remainderFirst, remainderLen * sizeof(URI_CHAR));
561-
first[remainderLen] = _UT('\0');
562-
*afterLast = first + remainderLen;
563-
}
557+
if (remainderFirst > first) {
558+
const size_t remainderLen = *afterLast - remainderFirst;
559+
memmove(first, remainderFirst, remainderLen * sizeof(URI_CHAR));
560+
first[remainderLen] = _UT('\0');
561+
*afterLast = first + remainderLen;
562+
}
564563
}
565564

566565
static void URI_FUNC(AdvancePastLeadingZeros)(const URI_CHAR ** first,
@@ -573,11 +572,10 @@ static void URI_FUNC(AdvancePastLeadingZeros)(const URI_CHAR ** first,
573572
return;
574573
}
575574

576-
const URI_CHAR * const remainderFirst =
577-
URI_FUNC(PastLeadingZeros)(*first, afterLast);
575+
const URI_CHAR * const remainderFirst = URI_FUNC(PastLeadingZeros)(*first, afterLast);
578576

579-
/* Cut off leading zeros */
580-
*first = remainderFirst;
577+
/* Cut off leading zeros */
578+
*first = remainderFirst;
581579
}
582580

583581
static URI_INLINE int URI_FUNC(NormalizeSyntaxEngine)(URI_TYPE(Uri) * uri,

src/UriParse.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,12 +1361,12 @@ static const URI_CHAR * URI_FUNC(ParseOwnPortUserInfo)(URI_TYPE(ParserState) * s
13611361

13621362
case _UT('%'):
13631363
state->uri->portText.first = NULL; /* Not a port, reset */
1364-
const URI_CHAR * const afterPct =
1365-
URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1366-
if (afterPct == NULL) {
1367-
return NULL;
1368-
}
1369-
return URI_FUNC(ParseOwnUserInfo)(state, afterPct, afterLast, memory);
1364+
const URI_CHAR * const afterPct =
1365+
URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1366+
if (afterPct == NULL) {
1367+
return NULL;
1368+
}
1369+
return URI_FUNC(ParseOwnUserInfo)(state, afterPct, afterLast, memory);
13701370

13711371
case _UT('@'):
13721372
state->uri->hostText.afterLast = NULL; /* Not a host, reset */

src/UriRecompose.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -520,23 +520,23 @@ static URI_INLINE int URI_FUNC(ToStringEngine)(URI_CHAR * dest, const URI_TYPE(U
520520
/* clang-format off */
521521
/* [13/19] append query to result; */
522522
/* clang-format on */
523-
const int charsToWrite =
524-
(int)(uri->query.afterLast - uri->query.first);
525-
if (dest != NULL) {
526-
if (written + charsToWrite <= maxChars) {
527-
memcpy(dest + written, uri->query.first,
528-
charsToWrite * sizeof(URI_CHAR));
529-
written += charsToWrite;
530-
} else {
531-
dest[0] = _UT('\0');
532-
if (charsWritten != NULL) {
533-
*charsWritten = 0;
534-
}
535-
return URI_ERROR_TOSTRING_TOO_LONG;
536-
}
523+
const int charsToWrite =
524+
(int)(uri->query.afterLast - uri->query.first);
525+
if (dest != NULL) {
526+
if (written + charsToWrite <= maxChars) {
527+
memcpy(dest + written, uri->query.first,
528+
charsToWrite * sizeof(URI_CHAR));
529+
written += charsToWrite;
537530
} else {
538-
(*charsRequired) += charsToWrite;
531+
dest[0] = _UT('\0');
532+
if (charsWritten != NULL) {
533+
*charsWritten = 0;
534+
}
535+
return URI_ERROR_TOSTRING_TOO_LONG;
539536
}
537+
} else {
538+
(*charsRequired) += charsToWrite;
539+
}
540540
/* clang-format off */
541541
/* [14/19] endif; */
542542
/* clang-format on */
@@ -565,23 +565,23 @@ static URI_INLINE int URI_FUNC(ToStringEngine)(URI_CHAR * dest, const URI_TYPE(U
565565
/* clang-format off */
566566
/* [17/19] append fragment to result; */
567567
/* clang-format on */
568-
const int charsToWrite =
569-
(int)(uri->fragment.afterLast - uri->fragment.first);
570-
if (dest != NULL) {
571-
if (written + charsToWrite <= maxChars) {
572-
memcpy(dest + written, uri->fragment.first,
573-
charsToWrite * sizeof(URI_CHAR));
574-
written += charsToWrite;
575-
} else {
576-
dest[0] = _UT('\0');
577-
if (charsWritten != NULL) {
578-
*charsWritten = 0;
579-
}
580-
return URI_ERROR_TOSTRING_TOO_LONG;
581-
}
568+
const int charsToWrite =
569+
(int)(uri->fragment.afterLast - uri->fragment.first);
570+
if (dest != NULL) {
571+
if (written + charsToWrite <= maxChars) {
572+
memcpy(dest + written, uri->fragment.first,
573+
charsToWrite * sizeof(URI_CHAR));
574+
written += charsToWrite;
582575
} else {
583-
(*charsRequired) += charsToWrite;
576+
dest[0] = _UT('\0');
577+
if (charsWritten != NULL) {
578+
*charsWritten = 0;
579+
}
580+
return URI_ERROR_TOSTRING_TOO_LONG;
584581
}
582+
} else {
583+
(*charsRequired) += charsToWrite;
584+
}
585585
/* clang-format off */
586586
/* [18/19] endif; */
587587
/* clang-format on */

0 commit comments

Comments
 (0)