42 char *
insnsep(
char* num,
char sep,
unsigned w ) {
43 char *first,*from,*to;
44 size_t nSkip,nDig,nSep,nLead;
46 if ( num==NULL ) {
return NULL; }
47 if ( w==0 ) {
return NULL; }
50 if (
'0'<=*first && *first<=
'9' ) {
break; }
53 if (*first==0) {
return NULL; }
56 while (
'0'<=*from && *from<=
'9' ) {
60 if (w==1) { nSep=nDig-1; nLead=1; }
64 if (nLead==0) { --nSep; nLead=w; }
66 if (nSkip>0)
if (*(first-1)==
'-' ||
'+'==*(first-1)) {
67 --first; --nSkip; ++nLead;
71 if ( nSep>nSkip ) {
return NULL; }
78 ++to; ++from; --nLead;
99 char *last, *first=num;
100 if (num==NULL) {
return NULL; }
102 if (
'0'<=*first && *first<=
'9' ) {
break; }
105 if (*first==0) {
return NULL; }
107 while (
'0'<=*last && *last<=
'9' ) {
113 char remember = *last;
135 char *from, *first=num;
137 if (num==NULL) {
return NULL; }
139 if (
'0'<=*first && *first<=
'9' ) {
break; }
142 if ( ( n<2 ) ) {
return NULL; }
143 if (*first==0) {
return NULL; }
146 while (
'0'<=*from && *from<=
'9' ) {
149 if ( n<8 ) {
return NULL; }
153 memmove( first+0, first+2, 4 );
155 memmove( first+5, first+6, 2 );
159 memmove( first+0, first+2, 2 );
161 memmove( first+3, first+4, 2 );
178 size_t atou_vec(
const char* str, uintmax_t VEC[],
size_t N ) {
182 if ( *str==0 ) {
break; }
184 if (
'0'<=*str && *str<=
'9' ) {
break; }
187 if ( *str==0 ) {
break; }
190 while (
'0'<=*str && *str<=
'9' ) {
191 val = 10*val + (*str-
'0');
214 size_t atoi_vec(
const char *str, intmax_t VEC[],
size_t N ) {
215 bool isNegative =
false;
219 if ( *str==0 ) {
break; }
221 if (
'0'<=*str && *str<=
'9' ) {
break; }
222 else if (
'-' == *str ) {
224 if ( 0==*str ) {
break; }
225 else if (
'0'<=*str && *str<=
'9' ) {
232 if ( *str==0 ) {
break; }
235 while (
'0'<=*str && *str<=
'9' ) {
236 val = 10*val + (*str-
'0');
239 VEC[i] = ( isNegative ? -val : val );
261 if (str==0) {
return 0; }
262 if (*str==0) {
return 0; }
265 if (
'0'<=**str && **str<=
'9' ) {
break; }
271 while (
'0'<=**str && **str<='9' && N>0 ) {
272 val = 10*val + (**str-
'0');
303 char*
utoa_sz( uintmax_t val,
char *dst,
unsigned base,
size_t sz ) {
306 if ( dst!=0 && (base>0) && (sz>1) ) { }
307 else { ;
return dst; }
310 else { ;
return dst; }
320 }
while ( val!=0 && p!=dst );
323 for (
char* lead=p-1; sz>0; --sz ) {
348 char* insnsep_date8_old(
char *num,
char sep,
bool YMD ) {
349 char *from, *first=num;
351 if (num==NULL) {
return NULL; }
353 if (
'0'<=*first && *first<=
'9' ) {
break; }
356 if ( ( n<2 ) ) {
return NULL; }
357 if (*first==0) {
return NULL; }
360 while (
'0'<=*from && *from<=
'9' ) {
363 if ( n!=8 ) {
return NULL; }
365 first =
insnsep( num, sep, 4 );
368 memmove( first ,first+1, 7 ); *(first+7) = sep;
371 memmove( first ,first+1, 2 ); *(first+2) = sep;
384 uintmax_t
atouint(
const char * str ) {
385 return strtoull( str,NULL,0);
388 size_t atoi_vec_old(
const char *str, intmax_t VEC[],
size_t N ) {
389 size_t LEN = strlen( str );
390 bool isNegative =
false;
393 while ( k<LEN && nxt<N ) {
395 if ( (
'0'<=str[k] && str[k]<=
'9') ) {
break; }
396 else if (
'-'==str[k] ) {
400 else if ( (
'0'<=str[k+1] && str[k+1]<=
'9') ) {
408 if ( k==LEN ) {
break; }
411 while ( (
'0'<=str[k] && str[k]<=
'9') ) {
412 val = 10*val + (str[k]-
'0');
414 if (k==LEN) {
break; }
416 VEC[nxt] = ( isNegative ? -val : val );
434 size_t atou_vec_old(
const char *str, uintmax_t VEC[],
size_t N ) {
435 size_t LEN = strlen( str );
438 while ( k<LEN && nxt<N ) {
440 if ( (
'0'<=str[k] && str[k]<=
'9') ) {
break; }
443 if ( k==LEN ) {
break; }
447 while ( (
'0'<=str[k] && str[k]<=
'9') ) {
448 val = 10*val + (str[k]-
'0');
450 if (k==LEN) {
break; }
461 size_t atou_vec_UGLY(
const char str[], uintmax_t* VEC ) {
462 size_t LEN = strlen(str);
463 size_t idx=0, i=0, num=0;
464 bool inNumber =
true;
468 if ( (
'0'<=str[i] && str[i]<=
'9') ) {
break; }
471 if ( i==LEN ) {
return 0; }
478 if ( (
'0'<=str[i] && str[i]<=
'9') ) {
479 num = num * 10 + (str[i]-
'0');
482 VEC[idx] = num; num=0;
488 if ( (
'0'<=str[i] && str[i]<=
'9') ) {
489 num = num * 10 + (str[i]-
'0');
495 if ( inNumber ) { VEC[idx] = num; ++idx; }
499 uintmax_t atouint_old(
const char * str ) {
501 size_t N = strlen(str);
503 if ( ! (
'0'<=str[i] && str[i]<=
'9') ) { ++i; }
509 if ( ! (
'0'<=str[i] && str[i]<=
'9') ) {
break; }
510 n = 10 * n + (str[i]-
'0');