From c9ce571c203987c9033de3683e41d9ead1104ce0 Mon Sep 17 00:00:00 2001 From: Damon Chaplin Date: Wed, 31 Oct 2001 14:13:29 +0000 Subject: use MAX_LINE_LEN rather than magic numbers all over the place. 2001-10-31 Damon Chaplin * src/libical/icalproperty.c (get_next_line_start): use MAX_LINE_LEN rather than magic numbers all over the place. svn path=/trunk/; revision=14536 --- libical/ChangeLog | 5 +++++ libical/src/libical/icalproperty.c | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'libical') diff --git a/libical/ChangeLog b/libical/ChangeLog index 44cc7bef5d..b00c82defe 100644 --- a/libical/ChangeLog +++ b/libical/ChangeLog @@ -1,3 +1,8 @@ +2001-10-31 Damon Chaplin + + * src/libical/icalproperty.c (get_next_line_start): use MAX_LINE_LEN + rather than magic numbers all over the place. + 2001-10-31 Damon Chaplin * src/libical/icalproperty.c (icalproperty_as_ical_string): had to diff --git a/libical/src/libical/icalproperty.c b/libical/src/libical/icalproperty.c index bd361aecc2..8cd34f1413 100644 --- a/libical/src/libical/icalproperty.c +++ b/libical/src/libical/icalproperty.c @@ -265,6 +265,9 @@ icalproperty_free (icalproperty* prop) /* This returns where the start of the next line should be. chars_left does not include the trailing '\0'. */ +#define MAX_LINE_LEN 75 +/*#define MAX_LINE_LEN 120*/ + static char* get_next_line_start (char *line_start, int chars_left) { @@ -272,7 +275,7 @@ get_next_line_start (char *line_start, int chars_left) /* If we have 74 chars or less left, we can output all of them. we return a pointer to the '\0' at the end of the string. */ - if (chars_left <= 74) { + if (chars_left < MAX_LINE_LEN) { return line_start + chars_left; } @@ -280,7 +283,7 @@ get_next_line_start (char *line_start, int chars_left) trying to find a ';' ':' or ' '. If we find one, we return the character after it. If not, we break at 74 chars (the 75th char is the space at the start of the line). */ - pos = line_start + 73; + pos = line_start + MAX_LINE_LEN - 2; while (pos > line_start) { if (*pos == ';' || *pos == ':' || *pos == ' ') { return pos + 1; @@ -288,7 +291,7 @@ get_next_line_start (char *line_start, int chars_left) pos--; } - return line_start + 74; + return line_start + MAX_LINE_LEN - 1; } -- cgit