MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_parseURLHostIPv4

Function fx_parseURLHostIPv4

modules/data/url/url.c:923–1044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

921}
922
923txBoolean fx_parseURLHostIPv4(txMachine* the, txStringStream* src, txInteger from, txInteger to, txStringStream* dst)
924{
925 txS8 pieces[4];
926 txS8 value;
927 txS8 sum;
928 txInteger pieceCount = 0;
929 txInteger pieceIndex;
930 txString p = dst->slot->value.string;
931 txString q = dst->slot->value.string + dst->offset;
932 while (p < q) {
933 value = -1;
934 if (*p == '0') {
935 value = 0;
936 p++;
937 if ((p < q) && ((*p == 'x') || (*p == 'X'))) {
938 p++;
939 while (p < q) {
940 if (('0' <= *p) && (*p <= '9'))
941 value = (value * 16) + (*p - '0');
942 else if (('a' <= *p) && (*p <= 'f'))
943 value = (value * 16) + (10 + *p - 'a');
944 else if (('A' <= *p) && (*p <= 'F'))
945 value = (value * 16) + (10 + *p - 'A');
946 else
947 break;
948 p++;
949
950 }
951 }
952 else {
953 while (p < q) {
954 if (('0' <= *p) && (*p <= '7'))
955 value = (value * 8) + (*p - '0');
956 else if (('8' <= *p) && (*p <= '9'))
957 value += 0x0000000100000000;
958 else
959 break;
960 p++;
961 }
962 }
963 }
964 else if (('1' <= *p) && (*p <= '9')) {
965 value = *p - '0';
966 p++;
967 while (p < q) {
968 if (('0' <= *p) && (*p <= '9'))
969 value = (value * 10) + (*p - '0');
970 else
971 break;
972 p++;
973 }
974 }
975 if ((p < q) && (*p != '.')) {
976 value = -1;
977 while ((p < q) && (*p != '.'))
978 p++;
979 }
980 if (pieceCount < 4)

Callers 1

fx_parseURLHostFunction · 0.85

Calls 1

fx_parseURLEncodeFunction · 0.85

Tested by

no test coverage detected