mail_menu.c: Remove external lines counter in editor.

The pointer vector maintaining `content` in `editor` already
keeps track of the number of lines and makes it available via
a call to `ptr_vector_len` (or one could look at th `len`
member of the ptr_vector struct...this is C, not some fancy
object oriented language with data hiding).  Delete the `lines`
local variable and just use ptr_vector_len where necessary.

Sorry; I should have done that in the first sweep through that
code.  My bad!

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
This commit is contained in:
Dan Cross 2018-10-11 12:55:00 +00:00 committed by Andrew Pamment
parent 37e728b749
commit e548c94750

View File

@ -546,7 +546,6 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot
}
char *editor(struct user_record *user, char *quote, int quotelen, char *from, int email, int sig) {
int lines = 0;
char buffer[256];
char linebuffer[80];
int doquit = 0;
@ -593,7 +592,7 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
s_printf(get_string(87));
while (!doquit) {
s_printf(get_string(88), lines, "");
s_printf(get_string(88), ptr_vector_len(&content), "");
strlcpy(linebuffer, next_line_buffer, sizeof(linebuffer));
s_readstring_inject(linebuffer, 70, next_line_buffer);
memset(next_line_buffer, 0, 70);
@ -712,7 +711,6 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
for (i = qfrom; i <= qto; i++) {
char *copy = strdup(ptr_vector_get(&quotecontent, i));
ptr_vector_append(&content, copy);
lines++;
}
s_printf(get_string(86));
@ -745,7 +743,7 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
s_printf(get_string(39));
} else {
z = atoi(buffer);
if (z < 0 || z >= lines) {
if (z < 0 || z >= ptr_vector_len(&content)) {
s_printf(get_string(39));
} else {
free(ptr_vector_del(&content, i));
@ -758,7 +756,7 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
s_printf(get_string(39));
} else {
z = atoi(buffer);
if (z < 0 || z >= lines) {
if (z < 0 || z >= ptr_vector_len(&content)) {
s_printf(get_string(39));
} else {
s_printf(get_string(88), z, ptr_vector_get(&content, z));
@ -775,7 +773,7 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
s_printf(get_string(39));
} else {
z = atoi(buffer);
if (z < 0 || z >= lines) {
if (z < 0 || z >= ptr_vector_len(&content)) {
s_printf(get_string(39));
} else {
s_printf(get_string(103), z);
@ -786,7 +784,6 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
}
} else {
ptr_vector_append(&content, strdup(linebuffer));
lines++;
}
}
if (quote != NULL) {