Skip to content

Commit 996376e

Browse files
committed
Updates
1 parent b686a57 commit 996376e

4 files changed

Lines changed: 27 additions & 4 deletions

File tree

file/file_path.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <boolean.h>
3232
#include <file/file_path.h>
3333
#include <retro_assert.h>
34+
#include <retro_miscellaneous.h>
3435
#include <string/stdstring.h>
3536
#include <time/rtime.h>
3637

@@ -961,7 +962,7 @@ size_t fill_pathname_join_delim_concat(char *out_path, const char *dir,
961962
size_t fill_short_pathname_representation(char* out_rep,
962963
const char *in_path, size_t size)
963964
{
964-
char path_short[PATH_MAX_LENGTH];
965+
char path_short[NAME_MAX_LENGTH];
965966

966967
path_short[0] = '\0';
967968

include/retro_miscellaneous.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count)
8282
#endif
8383
#endif
8484

85+
#ifndef NAME_MAX_LENGTH
86+
#define NAME_MAX_LENGTH 256
87+
#endif
88+
8589
#ifndef MAX
8690
#define MAX(a, b) ((a) > (b) ? (a) : (b))
8791
#endif

include/string/stdstring.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ static INLINE bool string_is_equal_case_insensitive(const char *a,
130130
return (result == 0);
131131
}
132132

133+
static INLINE bool string_starts_with_case_insensitive(const char *str,
134+
const char *prefix)
135+
{
136+
int result = 0;
137+
const unsigned char *p1 = (const unsigned char*)str;
138+
const unsigned char *p2 = (const unsigned char*)prefix;
139+
140+
if (!str || !prefix)
141+
return false;
142+
if (p1 == p2)
143+
return true;
144+
145+
while ((result = tolower (*p1++) - tolower (*p2)) == 0)
146+
if (*p2++ == '\0')
147+
break;
148+
149+
return (result == 0 || *p2 == '\0');
150+
}
151+
133152
char *string_to_upper(char *s);
134153

135154
char *string_to_lower(char *s);

net/net_http.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,14 +898,13 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total)
898898
}
899899
else
900900
{
901-
if (!strncmp(state->data, "Content-Length: ",
902-
STRLEN_CONST("Content-Length: ")))
901+
if (string_starts_with_case_insensitive(state->data, "Content-Length: "))
903902
{
904903
state->bodytype = T_LEN;
905904
state->len = strtol(state->data +
906905
STRLEN_CONST("Content-Length: "), NULL, 10);
907906
}
908-
if (string_is_equal(state->data, "Transfer-Encoding: chunked"))
907+
if (string_is_equal_case_insensitive(state->data, "Transfer-Encoding: chunked"))
909908
state->bodytype = T_CHUNK;
910909

911910
/* TODO: save headers somewhere */

0 commit comments

Comments
 (0)