Changeset View
Changeset View
Standalone View
Standalone View
lib/libedit/TEST/tc1.c
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
#include <signal.h> | #include <signal.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include "histedit.h" | #include "histedit.h" | ||||
#ifndef __UNCONST | |||||
#define __UNCONST(a) ((void*)(const void*)a) | |||||
#endif | |||||
static int continuation = 0; | static int continuation = 0; | ||||
volatile sig_atomic_t gotsig = 0; | volatile sig_atomic_t gotsig = 0; | ||||
static unsigned char complete(EditLine *, int); | static unsigned char complete(EditLine *, int); | ||||
int main(int, char **); | int main(int, char **); | ||||
static char *prompt(EditLine *); | static char *prompt(EditLine *); | ||||
static void sig(int); | static void sig(int); | ||||
Show All 14 Lines | |||||
static unsigned char | static unsigned char | ||||
complete(EditLine *el, int ch) | complete(EditLine *el, int ch) | ||||
{ | { | ||||
DIR *dd = opendir("."); | DIR *dd = opendir("."); | ||||
struct dirent *dp; | struct dirent *dp; | ||||
const char* ptr; | const char* ptr; | ||||
const LineInfo *lf = el_line(el); | const LineInfo *lf = el_line(el); | ||||
int len; | size_t len; | ||||
int res = CC_ERROR; | int res = CC_ERROR; | ||||
/* | /* | ||||
* Find the last word | * Find the last word | ||||
*/ | */ | ||||
for (ptr = lf->cursor - 1; | for (ptr = lf->cursor - 1; | ||||
!isspace((unsigned char)*ptr) && ptr > lf->buffer; ptr--) | !isspace((unsigned char)*ptr) && ptr > lf->buffer; ptr--) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | if (strcmp(av[0], "history") == 0) { | ||||
default: | default: | ||||
(void) fprintf(stderr, | (void) fprintf(stderr, | ||||
"Bad history arguments\n"); | "Bad history arguments\n"); | ||||
break; | break; | ||||
} | } | ||||
} else if (el_parse(el, ac, av) == -1) { | } else if (el_parse(el, ac, av) == -1) { | ||||
switch (fork()) { | switch (fork()) { | ||||
case 0: | case 0: | ||||
execvp(av[0], __DECONST(char **, av)); | execvp(av[0], (char *const *)__UNCONST(av)); | ||||
perror(av[0]); | perror(av[0]); | ||||
_exit(1); | _exit(1); | ||||
/*NOTREACHED*/ | /*NOTREACHED*/ | ||||
break; | break; | ||||
case -1: | case -1: | ||||
perror("fork"); | perror("fork"); | ||||
break; | break; | ||||
Show All 18 Lines |