Merge pull request #3319 from Stunkymonkey/format_placholders-case_sensitive

make format_placeholders case-sensitive
This commit is contained in:
Ingo Bürk 2018-08-04 09:23:11 +02:00 committed by GitHub
commit 65eb54c0ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -11,8 +11,8 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#ifndef STARTS_WITH #ifndef CS_STARTS_WITH
#define STARTS_WITH(string, needle) (strncasecmp((string), (needle), strlen((needle))) == 0) #define CS_STARTS_WITH(string, needle) (strncmp((string), (needle), strlen((needle))) == 0)
#endif #endif
/* /*
@ -28,7 +28,7 @@ char *format_placeholders(char *format, placeholder_t *placeholders, int num) {
int buffer_len = strlen(format) + 1; int buffer_len = strlen(format) + 1;
for (char *walk = format; *walk != '\0'; walk++) { for (char *walk = format; *walk != '\0'; walk++) {
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
if (!STARTS_WITH(walk, placeholders[i].name)) if (!CS_STARTS_WITH(walk, placeholders[i].name))
continue; continue;
buffer_len = buffer_len - strlen(placeholders[i].name) + strlen(placeholders[i].value); buffer_len = buffer_len - strlen(placeholders[i].name) + strlen(placeholders[i].value);
@ -48,7 +48,7 @@ char *format_placeholders(char *format, placeholder_t *placeholders, int num) {
bool matched = false; bool matched = false;
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
if (!STARTS_WITH(walk, placeholders[i].name)) { if (!CS_STARTS_WITH(walk, placeholders[i].name)) {
continue; continue;
} }