Store into RESULT a proleptic TZ string that represent the future predictions for the zone ZPFIRST with ZONECOUNT entries. Return a compatibility indicator (a TZDB release year) if successful, a negative integer if no such TZ string exists. */
| 3284 | return 1; |
| 3285 | if (a->r_hiyear != b->r_hiyear) |
| 3286 | return a->r_hiyear < b->r_hiyear ? -1 : 1; |
| 3287 | if (a->r_hiyear == ZIC_MAX) |
| 3288 | return 0; |
| 3289 | if (a->r_month - b->r_month != 0) |
| 3290 | return a->r_month - b->r_month; |
| 3291 | return a->r_dayofmonth - b->r_dayofmonth; |
| 3292 | } |
| 3293 | |
| 3294 | /* Store into RESULT a proleptic TZ string that represent the future |
| 3295 | predictions for the zone ZPFIRST with ZONECOUNT entries. Return a |
| 3296 | compatibility indicator (a TZDB release year) if successful, a |
| 3297 | negative integer if no such TZ string exists. */ |
| 3298 | static int |
| 3299 | stringzone(char *result, struct zone const *zpfirst, ptrdiff_t zonecount) |
| 3300 | { |
| 3301 | register const struct zone * zp; |
| 3302 | register struct rule * rp; |
| 3303 | register struct rule * stdrp; |
| 3304 | register struct rule * dstrp; |
| 3305 | register ptrdiff_t i; |
| 3306 | register int compat = 0; |
| 3307 | register int c; |
| 3308 | int offsetlen; |
| 3309 | struct rule stdr, dstr; |
| 3310 | ptrdiff_t len; |
| 3311 | int dstcmp; |
| 3312 | struct rule *lastrp[2] = { NULL, NULL }; |
| 3313 | struct zone zstr[2]; |
| 3314 | struct zone const *stdzp; |
| 3315 | struct zone const *dstzp; |
| 3316 | |
| 3317 | result[0] = '\0'; |
| 3318 | |
| 3319 | /* Internet RFC 9636 section 6.1 says to use an empty TZ string if |
| 3320 | future timestamps are truncated. */ |
| 3321 | if (hi_time < max_time) |
| 3322 | return -1; |
| 3323 | |
| 3324 | zp = zpfirst + zonecount - 1; |
| 3325 | for (i = 0; i < zp->z_nrules; ++i) { |
| 3326 | struct rule **last; |
| 3327 | int cmp; |
| 3328 | rp = &zp->z_rules[i]; |
| 3329 | last = &lastrp[rp->r_isdst]; |
| 3330 | cmp = rule_cmp(*last, rp); |
| 3331 | if (cmp < 0) |
| 3332 | *last = rp; |
| 3333 | else if (cmp == 0) |
| 3334 | return -1; |
| 3335 | } |
| 3336 | stdrp = lastrp[false]; |
| 3337 | dstrp = lastrp[true]; |
| 3338 | dstcmp = zp->z_nrules ? rule_cmp(dstrp, stdrp) : zp->z_isdst ? 1 : -1; |
| 3339 | stdzp = dstzp = zp; |
| 3340 | |
| 3341 | if (dstcmp < 0) { |
| 3342 | /* Standard time all year. */ |
| 3343 | dstrp = NULL; |
no test coverage detected