Clean up updatestring() in "utils.c".
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
a778706791
commit
0e5a9f1620
29
src/utils.c
29
src/utils.c
@ -372,23 +372,26 @@ getstring (WINDOW *win, char *str, int l, int x, int y)
|
|||||||
int
|
int
|
||||||
updatestring (WINDOW *win, char **str, int x, int y)
|
updatestring (WINDOW *win, char **str, int x, int y)
|
||||||
{
|
{
|
||||||
char *newstr;
|
int len = strlen (*str);
|
||||||
int escape, len = strlen (*str) + 1;
|
char *buf;
|
||||||
|
enum getstr ret;
|
||||||
|
|
||||||
EXIT_IF (len > BUFSIZ, _("Internal error: line too long"));
|
EXIT_IF (len + 1 > BUFSIZ, _("Internal error: line too long"));
|
||||||
|
|
||||||
newstr = mem_malloc (BUFSIZ);
|
buf = mem_malloc (BUFSIZ);
|
||||||
(void) memcpy (newstr, *str, len);
|
(void)memcpy (buf, *str, len + 1);
|
||||||
escape = getstring (win, newstr, BUFSIZ, x, y);
|
|
||||||
if (!escape)
|
ret = getstring (win, buf, BUFSIZ, x, y);
|
||||||
{
|
|
||||||
len = strlen (newstr) + 1;
|
if (ret == GETSTRING_VALID) {
|
||||||
*str = mem_realloc (*str, len, 1);
|
len = strlen (buf);
|
||||||
|
*str = mem_realloc (*str, len + 1, 1);
|
||||||
EXIT_IF (*str == 0, _("out of memory"));
|
EXIT_IF (*str == 0, _("out of memory"));
|
||||||
(void) memcpy (*str, newstr, len);
|
(void)memcpy (*str, buf, len + 1);
|
||||||
}
|
}
|
||||||
mem_free (newstr);
|
|
||||||
return escape;
|
mem_free (buf);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* checks if a string is only made of digits */
|
/* checks if a string is only made of digits */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user