mirror of https://github.com/MidnightCommander/mc
(extract_line): optionally return the lengh of the line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
9a1593473e
commit
bd934d22a2
|
@ -634,8 +634,8 @@ load_mc_home_file (const char *from, const char *filename, char **allocated_file
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
const char *
|
||||
extract_line (const char *s, const char *top)
|
||||
const const char *
|
||||
extract_line (const char *s, const char *top, size_t *len)
|
||||
{
|
||||
static char tmp_line[BUF_MEDIUM];
|
||||
char *t = tmp_line;
|
||||
|
@ -643,6 +643,10 @@ extract_line (const char *s, const char *top)
|
|||
while (*s != '\0' && *s != '\n' && (size_t) (t - tmp_line) < sizeof (tmp_line) - 1 && s < top)
|
||||
*t++ = *s++;
|
||||
*t = '\0';
|
||||
|
||||
if (len != NULL)
|
||||
*len = (size_t) (t - tmp_line);
|
||||
|
||||
return tmp_line;
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ const char *get_group (gid_t gid);
|
|||
const char *get_owner (uid_t uid);
|
||||
|
||||
/* Returns a copy of *s until a \n is found and is below top */
|
||||
const char *extract_line (const char *s, const char *top);
|
||||
const const char *extract_line (const char *s, const char *top, size_t *len);
|
||||
|
||||
/* Process spawning */
|
||||
int my_system (int flags, const char *shell, const char *command);
|
||||
|
|
|
@ -1149,7 +1149,7 @@ user_menu_cmd (const Widget *edit_widget, const char *menu_file, int selected_en
|
|||
{
|
||||
p = entries[i];
|
||||
LISTBOX_APPEND_TEXT (listbox, (unsigned char) p[0],
|
||||
extract_line (p, p + MAX_ENTRY_LEN), p, FALSE);
|
||||
extract_line (p, p + MAX_ENTRY_LEN, NULL), p, FALSE);
|
||||
}
|
||||
/* Select the default entry */
|
||||
listbox_set_current (listbox->list, selected);
|
||||
|
|
Loading…
Reference in New Issue