Skip to content

Commit

Permalink
vcardtime.c: wrap some line lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ksmurchison committed Apr 24, 2024
1 parent 945559d commit e69d40b
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/libicalvcard/vcardtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ static const char *sscanf_date(const char *str, vcardtimetype *t)
ndig = num_digits(month);

if (ndig == 4) {
sscanf(str, "--%2u%2u%n", (unsigned *)&t->month, (unsigned *)&t->day, &nchar);
sscanf(str, "--%2u%2u%n",
(unsigned *)&t->month, (unsigned *)&t->day, &nchar);
}
else if (ndig == 2) {
sscanf(str, "--%2u%n", (unsigned *)&t->month, &nchar);
Expand All @@ -327,7 +328,9 @@ static const char *sscanf_date(const char *str, vcardtimetype *t)
ndig = num_digits(str);

if (ndig == 8) {
sscanf(str, "%4u%2u%2u%n", (unsigned *)&t->year, (unsigned *)&t->month, (unsigned *)&t->day, &nchar);
sscanf(str, "%4u%2u%2u%n",
(unsigned *)&t->year, (unsigned *)&t->month,
(unsigned *)&t->day, &nchar);
}
else if (ndig == 4) {
month = str + 4;
Expand All @@ -341,11 +344,13 @@ static const char *sscanf_date(const char *str, vcardtimetype *t)
if (ndig == 2) {
if (month[2] == '-') {
sscanf(str, "%4u-%2u-%2u%n",
(unsigned *)&t->year, (unsigned *)&t->month, (unsigned *)&t->day, &nchar);
(unsigned *)&t->year, (unsigned *)&t->month,
(unsigned *)&t->day, &nchar);
}
else {
sscanf(str, "%4u-%2u%n",
(unsigned *)&t->year, (unsigned *)&t->month, &nchar);
(unsigned *)&t->year, (unsigned *)&t->month,
&nchar);
}
}
}
Expand Down Expand Up @@ -431,7 +436,8 @@ static const char *sscanf_time(const char *str, vcardtimetype *t)
ndig = num_digits(str+1);

if (ndig == 4) {
sscanf(str, "-%2u%2u%n", (unsigned *)&t->minute, (unsigned *)&t->second, &nchar);
sscanf(str, "-%2u%2u%n",
(unsigned *)&t->minute, (unsigned *)&t->second, &nchar);
}
else if (ndig == 2) {
sscanf(str, "-%2u%n", (unsigned *)&t->minute, &nchar);
Expand All @@ -443,21 +449,26 @@ static const char *sscanf_time(const char *str, vcardtimetype *t)
ndig = num_digits(str);

if (ndig == 6) {
sscanf(str, "%2u%2u%2u%n", (unsigned *)&t->hour, (unsigned *)&t->minute, (unsigned *)&t->second, &nchar);
sscanf(str, "%2u%2u%2u%n",
(unsigned *)&t->hour, (unsigned *)&t->minute,
(unsigned *)&t->second, &nchar);
}
else if (ndig == 4) {
sscanf(str, "%2u%2u%n", (unsigned *)&t->hour, (unsigned *)&t->minute, &nchar);
sscanf(str, "%2u%2u%n",
(unsigned *)&t->hour, (unsigned *)&t->minute, &nchar);
t->second = 0;
}
else if (ndig == 2) {
if (str[2] == ':') {
if (str[8] == '.') {
sscanf(str, "%2u:%2u:%2u.%u%n",
(unsigned *)&t->hour, (unsigned *)&t->minute, (unsigned *)&t->second, (unsigned *)&secfrac, &nchar);
(unsigned *)&t->hour, (unsigned *)&t->minute,
(unsigned *)&t->second, (unsigned *)&secfrac, &nchar);
}
else {
sscanf(str, "%2u:%2u:%2u%n",
(unsigned *)&t->hour, (unsigned *)&t->minute, (unsigned *)&t->second, &nchar);
(unsigned *)&t->hour, (unsigned *)&t->minute,
(unsigned *)&t->second, &nchar);
}
}
else {
Expand Down

0 comments on commit e69d40b

Please sign in to comment.