summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/calcurse.h2
-rw-r--r--src/io.c43
-rw-r--r--src/utils.c9
3 files changed, 25 insertions, 29 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 095c0f7..c8c6b85 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -873,7 +873,7 @@ char *new_tempfile (const char *, int);
void erase_note (char **, enum eraseflg);
int parse_date (char *, enum datefmt, int *, int *, int *,
struct date *);
-char *str_toupper (char *);
+void str_toupper (char *);
void file_close (FILE *, const char *);
void psleep (unsigned);
diff --git a/src/io.c b/src/io.c
index 84c4c76..1c17c5a 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1916,32 +1916,31 @@ ical_chk_header (FILE *fd, unsigned *lineno)
(void)fgets (buf, BUFSIZ, fd);
(*lineno)++;
- if (buf == NULL
- || strncmp (str_toupper (buf), icalheader.str, icalheader.len) != 0)
- {
- return HEADER_MALFORMED;
- }
- else
- {
- const int AWAITED = 1;
- float version = HEADER_MALFORMED;
- int read;
- do
+ if (buf == NULL) return HEADER_MALFORMED;
+
+ str_toupper (buf);
+ if (strncmp (buf, icalheader.str, icalheader.len) != 0)
+ return HEADER_MALFORMED;
+
+ const int AWAITED = 1;
+ float version = HEADER_MALFORMED;
+ int read;
+
+ do
+ {
+ if (fgets (buf, BUFSIZ, fd) == NULL)
{
- if (fgets (buf, BUFSIZ, fd) == NULL)
- {
- return HEADER_MALFORMED;
- }
- else
- {
- (*lineno)++;
- read = sscanf (buf, "VERSION:%f", &version);
- }
+ return HEADER_MALFORMED;
+ }
+ else
+ {
+ (*lineno)++;
+ read = sscanf (buf, "VERSION:%f", &version);
}
- while (read != AWAITED);
- return version;
}
+ while (read != AWAITED);
+ return version;
}
/*
diff --git a/src/utils.c b/src/utils.c
index 00fafea..630b6bf 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -957,14 +957,11 @@ parse_date (char *date_string, enum datefmt datefmt, int *year, int *month,
return 1;
}
-char *
+void
str_toupper (char *s)
{
- int len;
-
- for (len = 0; s && s[len]; len++)
- s[len] = toupper (s[len]);
- return s;
+ if (!s) return;
+ for (; *s; s++) *s = toupper (*s);
}
void