Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: fusl/src/network/inet_aton.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <ctype.h> 1 #include <ctype.h>
2 #include <sys/socket.h> 2 #include <sys/socket.h>
3 #include <netinet/in.h> 3 #include <netinet/in.h>
4 #include <arpa/inet.h> 4 #include <arpa/inet.h>
5 #include "libc.h" 5 #include "libc.h"
6 6
7 int __inet_aton(const char *s0, struct in_addr *dest) 7 int __inet_aton(const char* s0, struct in_addr* dest) {
8 { 8 const char* s = s0;
9 » const char *s = s0; 9 unsigned char* d = (void*)dest;
10 » unsigned char *d = (void *)dest; 10 unsigned long a[4] = {0};
11 » unsigned long a[4] = { 0 }; 11 char* z;
12 » char *z; 12 int i;
13 » int i;
14 13
15 » for (i=0; i<4; i++) { 14 for (i = 0; i < 4; i++) {
16 » » a[i] = strtoul(s, &z, 0); 15 a[i] = strtoul(s, &z, 0);
17 » » if (z==s || (*z && *z != '.') || !isdigit(*s)) 16 if (z == s || (*z && *z != '.') || !isdigit(*s))
18 » » » return 0; 17 return 0;
19 » » if (!*z) break; 18 if (!*z)
20 » » s=z+1; 19 break;
21 » } 20 s = z + 1;
22 » if (i==4) return 0; 21 }
23 » switch (i) { 22 if (i == 4)
24 » case 0: 23 return 0;
25 » » a[1] = a[0] & 0xffffff; 24 switch (i) {
26 » » a[0] >>= 24; 25 case 0:
27 » case 1: 26 a[1] = a[0] & 0xffffff;
28 » » a[2] = a[1] & 0xffff; 27 a[0] >>= 24;
29 » » a[1] >>= 16; 28 case 1:
30 » case 2: 29 a[2] = a[1] & 0xffff;
31 » » a[3] = a[2] & 0xff; 30 a[1] >>= 16;
32 » » a[2] >>= 8; 31 case 2:
33 » } 32 a[3] = a[2] & 0xff;
34 » for (i=0; i<4; i++) { 33 a[2] >>= 8;
35 » » if (a[i] > 255) return 0; 34 }
36 » » d[i] = a[i]; 35 for (i = 0; i < 4; i++) {
37 » } 36 if (a[i] > 255)
38 » return 1; 37 return 0;
38 d[i] = a[i];
39 }
40 return 1;
39 } 41 }
40 42
41 weak_alias(__inet_aton, inet_aton); 43 weak_alias(__inet_aton, inet_aton);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698