Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dsscanf(string[], format[], {Float,_}:...)
- {
- if(!string[0] || (string[0] && !string[1]))
- return format[0];
- static
- i, // string
- p, pos = 0x2, // params
- f = 0x0, // format
- n, np, v, // 'i', 'd'
- d; // 's'
- for(i = 0x0; string[i] && string[i] <= 0x20; i++) {}
- for(p = numargs(); pos < p && string[i]; )
- {
- switch(format[f++])
- {
- case '\0':
- return 0;
- case 'i', 'd':
- {
- n = 0x0,
- np = 0x1,
- v = string[i];
- if(v == 0x2d)
- np = -1, v = string[++i];
- for(; (v = string[i]) > 0x20 && v != 0x20; i++)
- {
- if (0x30 <= v <= 0x39)
- n = (n * 0xA) + (v - 0x30);
- else
- return -1;
- }
- setarg(pos, 0x0, n * np);
- }
- case 'c':
- setarg(pos, 0x0, string[i++]);
- case 's', 'z':
- {
- d = 0;
- if(format[f])
- {
- for(; (v = string[i++]) && v != 0x20; )
- setarg(pos, d++, v);
- if(!d)
- return -1;
- }
- else
- {
- for(; (v = string[i++]); )
- setarg(pos, d++, v);
- }
- i--;
- setarg(pos, d, '\0');
- }
- default:
- continue;
- }
- for(; string[i] && string[i] != 0x20 && string[i] > 0x20; i++) {}
- for(; string[i] && (string[i] == 0x20 || string[i] <= 0x20); i++) {}
- pos++;
- }
- return 0;
- }
- // Optimized: DanDRT
- // Original: Y_Less
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement