#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <locale.h>
#ifndef errno
extern int errno;
#endif
#if defined (READLINE_LIBRARY)
# include "readline.h"
# include "history.h"
#else
# include <readline/readline.h>
# include <readline/history.h>
#endif
static char *line_read = (char *)NULL;
char *
rl_gets (void)
{
if (line_read)
{
free (line_read);
line_read = (char *)NULL;
}
line_read = readline ("");
if (line_read && *line_read)
add_history (line_read);
return (line_read);
}
int
invert_case_line (int count, int key)
{
int start, end;
int direction;
start = rl_point;
end = start + count;
if (end > rl_end)
end = rl_end;
else if (end < 0)
end = -1;
if (start == end)
return 0;
rl_point = end;
if (start > end)
{
int temp = start;
start = end;
end = temp;
}
rl_modifying (start, end);
for (; start != end; start++)
{
if (_rl_uppercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = _rl_to_lower (rl_line_buffer[start]);
else if (_rl_lowercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = _rl_to_upper (rl_line_buffer[start]);
}
return 0;
}