kopia lustrzana https://github.com/micropython/micropython
all: Apply code formatting to new paths.
Run code formatting to apply rules to: * drivers/**/*.[ch] * examples/**/*.[ch] * shared/libc/*.[ch] * shared/readline/*.[ch] Signed-off-by: Phil Howard <phil@gadgetoid.com>pull/14046/head
rodzic
18574e4f43
commit
20451850a2
|
@ -80,8 +80,7 @@ static void esp_hosted_macstr_to_bytes(const uint8_t *mac_str, size_t mac_len, u
|
|||
// to avoid bleeding the protocol buffer API into the public interface, convert esp_hosted_security_t
|
||||
// to/from CtrlWifiSecProt here.
|
||||
|
||||
static esp_hosted_security_t sec_prot_to_hosted_security(CtrlWifiSecProt sec_prot)
|
||||
{
|
||||
static esp_hosted_security_t sec_prot_to_hosted_security(CtrlWifiSecProt sec_prot) {
|
||||
switch (sec_prot) {
|
||||
case CTRL__WIFI_SEC_PROT__Open:
|
||||
return ESP_HOSTED_SEC_OPEN;
|
||||
|
@ -104,8 +103,7 @@ static esp_hosted_security_t sec_prot_to_hosted_security(CtrlWifiSecProt sec_pro
|
|||
}
|
||||
}
|
||||
|
||||
static CtrlWifiSecProt hosted_security_to_sec_prot(esp_hosted_security_t hosted_security)
|
||||
{
|
||||
static CtrlWifiSecProt hosted_security_to_sec_prot(esp_hosted_security_t hosted_security) {
|
||||
switch (hosted_security) {
|
||||
case ESP_HOSTED_SEC_OPEN:
|
||||
return CTRL__WIFI_SEC_PROT__Open;
|
||||
|
|
|
@ -115,8 +115,11 @@ int memcmp(const void *s1, const void *s2, size_t n) {
|
|||
while (n--) {
|
||||
char c1 = *s1_8++;
|
||||
char c2 = *s2_8++;
|
||||
if (c1 < c2) return -1;
|
||||
else if (c1 > c2) return 1;
|
||||
if (c1 < c2) {
|
||||
return -1;
|
||||
} else if (c1 > c2) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -126,8 +129,9 @@ void *memchr(const void *s, int c, size_t n) {
|
|||
const unsigned char *p = s;
|
||||
|
||||
do {
|
||||
if (*p++ == c)
|
||||
return ((void *)(p - 1));
|
||||
if (*p++ == c) {
|
||||
return (void *)(p - 1);
|
||||
}
|
||||
} while (--n != 0);
|
||||
}
|
||||
return 0;
|
||||
|
@ -145,12 +149,19 @@ int strcmp(const char *s1, const char *s2) {
|
|||
while (*s1 && *s2) {
|
||||
char c1 = *s1++; // XXX UTF8 get char, next char
|
||||
char c2 = *s2++; // XXX UTF8 get char, next char
|
||||
if (c1 < c2) return -1;
|
||||
else if (c1 > c2) return 1;
|
||||
if (c1 < c2) {
|
||||
return -1;
|
||||
} else if (c1 > c2) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (*s2) {
|
||||
return -1;
|
||||
} else if (*s1) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
if (*s2) return -1;
|
||||
else if (*s1) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
int strncmp(const char *s1, const char *s2, size_t n) {
|
||||
|
@ -158,13 +169,21 @@ int strncmp(const char *s1, const char *s2, size_t n) {
|
|||
char c1 = *s1++; // XXX UTF8 get char, next char
|
||||
char c2 = *s2++; // XXX UTF8 get char, next char
|
||||
n--;
|
||||
if (c1 < c2) return -1;
|
||||
else if (c1 > c2) return 1;
|
||||
if (c1 < c2) {
|
||||
return -1;
|
||||
} else if (c1 > c2) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
} else if (*s2) {
|
||||
return -1;
|
||||
} else if (*s1) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
if (n == 0) return 0;
|
||||
else if (*s2) return -1;
|
||||
else if (*s1) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
char *strcpy(char *dest, const char *src) {
|
||||
|
@ -218,29 +237,31 @@ char *strcat(char *dest, const char *src) {
|
|||
|
||||
// Public Domain implementation of strchr from:
|
||||
// http://en.wikibooks.org/wiki/C_Programming/Strings#The_strchr_function
|
||||
char *strchr(const char *s, int c)
|
||||
{
|
||||
char *strchr(const char *s, int c) {
|
||||
/* Scan s for the character. When this loop is finished,
|
||||
s will either point to the end of the string or the
|
||||
character we were looking for. */
|
||||
while (*s != '\0' && *s != (char)c)
|
||||
while (*s != '\0' && *s != (char)c) {
|
||||
s++;
|
||||
return ((*s == c) ? (char *) s : 0);
|
||||
}
|
||||
return (*s == c) ? (char *)s : 0;
|
||||
}
|
||||
|
||||
|
||||
// Public Domain implementation of strstr from:
|
||||
// http://en.wikibooks.org/wiki/C_Programming/Strings#The_strstr_function
|
||||
char *strstr(const char *haystack, const char *needle)
|
||||
{
|
||||
char *strstr(const char *haystack, const char *needle) {
|
||||
size_t needlelen;
|
||||
/* Check for the null needle case. */
|
||||
if (*needle == '\0')
|
||||
if (*needle == '\0') {
|
||||
return (char *)haystack;
|
||||
}
|
||||
needlelen = strlen(needle);
|
||||
for (; (haystack = strchr(haystack, *needle)) != 0; haystack++)
|
||||
if (strncmp(haystack, needle, needlelen) == 0)
|
||||
for (; (haystack = strchr(haystack, *needle)) != 0; haystack++) {
|
||||
if (strncmp(haystack, needle, needlelen) == 0) {
|
||||
return (char *)haystack;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue