mirror of
https://github.com/troglobit/editline.git
synced 2025-05-06 04:21:24 +08:00
examples/fileman.c: Remove unnecessary code
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
5c8429dcee
commit
3cb74b6d87
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include "editline.h"
|
#include "editline.h"
|
||||||
|
|
||||||
void *xmalloc(size_t size);
|
|
||||||
void too_dangerous(char *caller);
|
void too_dangerous(char *caller);
|
||||||
void initialize_readline();
|
void initialize_readline();
|
||||||
int execute_line(char *line);
|
int execute_line(char *line);
|
||||||
@ -70,27 +69,13 @@ COMMAND commands[] = {
|
|||||||
char *stripwhite();
|
char *stripwhite();
|
||||||
COMMAND *find_command();
|
COMMAND *find_command();
|
||||||
|
|
||||||
/* The name of this program, as taken from argv[0]. */
|
|
||||||
char *progname;
|
|
||||||
|
|
||||||
/* When non-zero, this means the user is done using this program. */
|
/* When non-zero, this means the user is done using this program. */
|
||||||
int done;
|
int done;
|
||||||
|
|
||||||
char *dupstr(char *s)
|
|
||||||
{
|
|
||||||
char *r;
|
|
||||||
|
|
||||||
r = xmalloc(strlen(s) + 1);
|
|
||||||
strcpy(r, s);
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc __attribute__ ((__unused__)), char **argv)
|
int main(int argc __attribute__ ((__unused__)), char **argv)
|
||||||
{
|
{
|
||||||
char *line, *s;
|
char *line, *s;
|
||||||
|
|
||||||
progname = argv[0];
|
|
||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
|
|
||||||
initialize_readline(); /* Bind our completer. */
|
initialize_readline(); /* Bind our completer. */
|
||||||
@ -126,7 +111,6 @@ int main(int argc __attribute__ ((__unused__)), char **argv)
|
|||||||
#endif
|
#endif
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
exit(0);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -265,7 +249,7 @@ int state;
|
|||||||
list_index++;
|
list_index++;
|
||||||
|
|
||||||
if (strncmp(name, text, len) == 0)
|
if (strncmp(name, text, len) == 0)
|
||||||
return (dupstr(name));
|
return strdup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no names matched, then return NULL. */
|
/* If no names matched, then return NULL. */
|
||||||
@ -439,14 +423,6 @@ int valid_argument(char *caller, char *arg)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *xmalloc(size_t size)
|
|
||||||
{
|
|
||||||
register void *value = (void *)malloc(size);
|
|
||||||
if (value == 0)
|
|
||||||
fprintf(stderr, "virtual memory exhausted");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* c-file-style: "k&r"
|
* c-file-style: "k&r"
|
||||||
|
Loading…
Reference in New Issue
Block a user