run a bit of indent over it

not really suitable tho
This commit is contained in:
tg
2005-06-08 22:22:24 +00:00
parent 521da70fc8
commit d518ab0023
2 changed files with 256 additions and 262 deletions

89
edit.c
View File

@ -1,4 +1,4 @@
/** $MirOS: src/bin/mksh/edit.c,v 1.6 2005/06/08 21:51:20 tg Exp $ */
/** $MirOS: src/bin/mksh/edit.c,v 1.7 2005/06/08 22:22:23 tg Exp $ */
/* $OpenBSD: edit.c,v 1.29 2005/04/13 02:33:08 deraadt Exp $ */
/* $OpenBSD: edit.h,v 1.8 2005/03/28 21:28:22 deraadt Exp $ */
/* $OpenBSD: emacs.c,v 1.37 2005/03/30 17:16:37 deraadt Exp $ */
@ -10,7 +10,7 @@
#include <ctype.h>
#include <libgen.h>
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.6 2005/06/08 21:51:20 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.7 2005/06/08 22:22:23 tg Exp $");
#define BEL 0x07
@ -70,7 +70,8 @@ x_init(void)
/* default value for deficient systems */
edchars.werase = 027; /* ^W */
if (setsig(&sigtraps[SIGWINCH], x_sigwinch, SS_RESTORE_ORIG|SS_SHTRAP))
if (setsig(&sigtraps[SIGWINCH], x_sigwinch,
SS_RESTORE_ORIG | SS_SHTRAP))
sigtraps[SIGWINCH].flags |= TF_SHELL_USES;
check_sigwinch(); /* force initial check */
@ -247,7 +248,6 @@ promptlen(const char *cp, const char **spp)
delimiter = *cp;
cp += 2;
}
for (; *cp; cp++) {
if (indelimit && *cp != delimiter)
;
@ -380,7 +380,6 @@ x_print_expansions(int nwords, char *const *words, int is_command)
XPput(l, NULL);
}
}
/*
* Enumerate expansions
*/
@ -427,7 +426,8 @@ x_file_glob(int flags __attribute__((unused)), const char *str,
toglob[idx] = toglob[i];
idx++;
if (escaping) escaping = 0;
if (escaping)
escaping = 0;
}
toglob[idx] = '\0';
@ -534,7 +534,6 @@ x_command_glob(int flags, const char *str, int slen, char ***wordsp)
XPfree(w);
return 0;
}
/* Sort entries */
if (flags & XCF_FULLPATH) {
/* Sort by basename, then path order */
@ -635,7 +634,6 @@ x_locate_word(const char *buf, int buflen, int pos, int *startp,
}
*is_commandp = iscmd;
}
*startp = start;
return end - start;
@ -666,7 +664,6 @@ x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp,
*wordsp = NULL;
return 0;
}
if (is_commandp)
*is_commandp = is_command;
*wordsp = words;
@ -701,7 +698,7 @@ add_glob(const char *str, int slen)
if (*s == '\\' && s[1])
s++;
else if (*s == '*' || *s == '[' || *s == '?' || *s == '$'
|| (s[1] == '(' /*)*/ && strchr("*+?@!", *s)))
|| (s[1] == '(' && strchr("*+?@!", *s)))
break;
else if (*s == '/')
saw_slash = true;
@ -710,7 +707,6 @@ add_glob(const char *str, int slen)
toglob[slen] = '*';
toglob[slen + 1] = '\0';
}
return toglob;
}
@ -880,7 +876,6 @@ x_escape(const char *s, size_t len, int (*putbuf_func) (const char *, size_t))
rval = -1;
break;
}
putbuf_func("\\", 1);
putbuf_func(&s[add], 1);
@ -1315,7 +1310,6 @@ x_emacs(char *buf, size_t len)
x_load_hist(histptr - off);
x_nextcmd = -1;
}
while (1) {
x_flush();
if ((c = x_e_getc()) < 0)
@ -1325,7 +1319,6 @@ x_emacs(char *buf, size_t len)
c = META(c);
x_curprefix = 1;
}
f = x_curprefix == -1 ? XFUNC_insert :
x_tab[x_curprefix][c & CHARMASK];
@ -1395,7 +1388,6 @@ x_do_ins(const char *cp, int len)
x_e_putc(BEL);
return -1;
}
memmove(xcp + len, xcp, xep - xcp + 1);
memmove(xcp, cp, len);
xcp += len;
@ -1424,7 +1416,6 @@ x_ins(char *s)
for (cp = xlp; cp > xcp; )
x_bs(*--cp);
}
x_adj_ok = 1;
return 0;
}
@ -1488,7 +1479,6 @@ x_delete(int nc, int push)
else
xmp -= nc;
}
/*
* This lets us yank a word we have deleted.
*/
@ -2290,7 +2280,6 @@ x_bind( const char *a1, const char *a2,
bi_errorf("cannot bind, not a tty");
return 1;
}
/* List function names */
if (list) {
for (f = 0; f < NELEM(x_ftab); f++)
@ -2299,7 +2288,6 @@ x_bind( const char *a1, const char *a2,
shprintf("%s\n", x_ftab[f].xf_name);
return 0;
}
if (a1 == NULL) {
for (prefix = 0; prefix < X_NTABS; prefix++)
for (key = 0; key < X_TABSZ; key++) {
@ -2311,7 +2299,6 @@ x_bind( const char *a1, const char *a2,
}
return 0;
}
m1 = x_mapin(a1);
prefix = key = 0;
for (;; m1++) {
@ -2328,7 +2315,6 @@ x_bind( const char *a1, const char *a2,
x_print(prefix, key);
return 0;
}
if (*a2 == 0)
f = XFUNC_insert;
else if (!macro) {
@ -2569,7 +2555,6 @@ x_expand(int c __attribute__((unused)))
x_e_putc(BEL);
return KSTD;
}
x_goto(xbuf + start);
x_delete(end - start, false);
for (i = 0; i < nwords;) {
@ -2602,14 +2587,12 @@ do_complete(int flags, /* XCF_{COMMAND,FILE,COMMAND_FILE} */
x_e_putc(BEL);
return;
}
if (type == CT_LIST) {
x_print_expansions(nwords, words, is_command);
x_redraw(0);
x_free_words(nwords, words);
return;
}
olen = end - start;
nlen = x_longest_prefix(nwords, words);
/* complete */
@ -2625,12 +2608,10 @@ do_complete(int flags, /* XCF_{COMMAND,FILE,COMMAND_FILE} */
x_ins(space);
completed = 1;
}
if (type == CT_COMPLIST && !completed) {
x_print_expansions(nwords, words, is_command);
completed = 1;
}
if (completed)
x_redraw(0);
@ -3127,7 +3108,9 @@ struct macro_state {
};
static struct macro_state macro;
enum expand_mode { NONE, EXPAND, COMPLETE, PRINT };
enum expand_mode {
NONE, EXPAND, COMPLETE, PRINT
};
static enum expand_mode expanded = NONE; /* last input was expanded */
int
@ -3177,7 +3160,9 @@ x_vi(char *buf, size_t len)
x_flush();
}
x_putc('\r'); x_putc('\n'); x_flush();
x_putc('\r');
x_putc('\n');
x_flush();
if (c == -1 || (ssize_t)len <= es->linelen)
return -1;
@ -3694,14 +3679,16 @@ vi_cmd(int argcnt, const char *cmd)
break;
case 'a':
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
if (es->linelen != 0)
es->cursor++;
insert = INSERT;
break;
case 'A':
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
del_range(0, 0);
es->cursor = es->linelen;
insert = INSERT;
@ -3710,7 +3697,8 @@ vi_cmd(int argcnt, const char *cmd)
case 'S':
es->cursor = domove(1, "^", 1);
del_range(es->cursor, es->linelen);
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
insert = INSERT;
break;
@ -3752,13 +3740,15 @@ vi_cmd(int argcnt, const char *cmd)
es->cursor = c1;
}
if (*cmd == 'c') {
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
insert = INSERT;
}
break;
case 'p':
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
if (es->linelen != 0)
es->cursor++;
while (putbuf(ybuf, yanklen, 0) == 0 && --argcnt > 0)
@ -3770,7 +3760,8 @@ vi_cmd(int argcnt, const char *cmd)
break;
case 'P':
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
any = 0;
while (putbuf(ybuf, yanklen, 0) == 0 && --argcnt > 0)
any = 1;
@ -3781,7 +3772,8 @@ vi_cmd(int argcnt, const char *cmd)
break;
case 'C':
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
del_range(es->cursor, es->linelen);
insert = INSERT;
break;
@ -3811,12 +3803,14 @@ vi_cmd(int argcnt, const char *cmd)
break;
case 'i':
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
insert = INSERT;
break;
case 'I':
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
es->cursor = domove(1, "^", 1);
insert = INSERT;
break;
@ -3846,7 +3840,8 @@ vi_cmd(int argcnt, const char *cmd)
case 'r':
if (es->linelen == 0)
return -1;
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
if (cmd[1] == 0)
vi_error();
else {
@ -3861,14 +3856,16 @@ vi_cmd(int argcnt, const char *cmd)
break;
case 'R':
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
insert = REPLACE;
break;
case 's':
if (es->linelen == 0)
return -1;
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
if (es->cursor + argcnt > es->linelen)
argcnt = es->linelen - es->cursor;
del_range(es->cursor, es->cursor + argcnt);
@ -3897,7 +3894,8 @@ vi_cmd(int argcnt, const char *cmd)
case 'x':
if (es->linelen == 0)
return -1;
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
if (es->cursor + argcnt > es->linelen)
argcnt = es->linelen - es->cursor;
yank_range(es->cursor, es->cursor + argcnt);
@ -3906,7 +3904,8 @@ vi_cmd(int argcnt, const char *cmd)
case 'X':
if (es->cursor > 0) {
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
if (es->cursor < argcnt)
argcnt = es->cursor;
yank_range(es->cursor - argcnt, es->cursor);
@ -4860,7 +4859,8 @@ expand_word(int cmd)
i = buf->cursor - end;
if (rval == 0 && i > 0)
es->cursor += i;
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
insert = INSERT;
lastac = 0;
refresh(0);
@ -4964,7 +4964,8 @@ complete_word(int cmd, int count)
}
x_free_words(nwords, words);
modified = 1; hnum = hlast;
modified = 1;
hnum = hlast;
insert = INSERT;
lastac = 0; /* prevent this from being redone... */
refresh(0);

15
main.c
View File

@ -1,4 +1,4 @@
/** $MirOS: src/bin/mksh/main.c,v 1.11 2005/06/08 21:51:21 tg Exp $ */
/** $MirOS: src/bin/mksh/main.c,v 1.12 2005/06/08 22:22:24 tg Exp $ */
/* $OpenBSD: main.c,v 1.38 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: tty.c,v 1.8 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: io.c,v 1.21 2005/03/30 17:16:37 deraadt Exp $ */
@ -13,7 +13,7 @@
#include <time.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.11 2005/06/08 21:51:21 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.12 2005/06/08 22:22:24 tg Exp $");
const char ksh_version[] = "@(#)MIRBSD KSH R23 2005/06/08";
@ -254,7 +254,8 @@ main(int argc, char *argv[])
} else if (argi < argc && !Flag(FSTDIN)) {
s = pushs(SFILE, ATEMP);
s->file = kshname = argv[argi++];
s->u.shf = shf_open(s->file, O_RDONLY, 0, SHF_MAPHI|SHF_CLEXEC);
s->u.shf = shf_open(s->file, O_RDONLY, 0,
SHF_MAPHI | SHF_CLEXEC);
if (s->u.shf == NULL) {
exstat = 127; /* POSIX */
errorf("%s: %s", s->file, strerror(errno));
@ -315,7 +316,6 @@ main(int argc, char *argv[])
include(substitute("$HOME/.profile", 0), 0,
NULL, 1);
}
if (Flag(FPRIVILEGED))
include("/etc/suid_profile", 0, NULL, 1);
else {
@ -483,7 +483,6 @@ shell(Source *volatile s, volatile int toplevel)
/*NOREACHED*/
}
}
while (1) {
if (trap)
runtraps(0);
@ -494,12 +493,10 @@ shell(Source *volatile s, volatile int toplevel)
else
s->flags &= ~SF_ECHO;
}
if (interactive) {
j_notify();
set_prompt(PS1, s);
}
t = compile(s);
if (t != NULL && t->type == TEOF) {
if (wastty && Flag(FIGNOREEOF) && --attempts > 0) {
@ -520,7 +517,6 @@ shell(Source *volatile s, volatile int toplevel)
break;
}
}
if (t && (!Flag(FNOEXEC) || (s->flags & SF_TTY)))
exstat = execute(t, 0);
@ -600,7 +596,6 @@ quitenv(struct shf *shf)
if (ep->savefd[2]) /* Clear any write errors */
shf_reopen(2, SHF_WR, shl_out);
}
/* Bottom of the stack.
* Either main shell is exiting or cleanup_parents_env() was called.
*/
@ -736,7 +731,6 @@ tty_init(int init_ttystate)
strerror(errno));
}
}
if (tfd < 0) {
do_close = 0;
if (isatty(0))
@ -1230,7 +1224,6 @@ tenter(struct table *tp, const char *n, unsigned int h)
texpand(tp, 2 * tp->size);
goto Search;
}
/* create new tbl entry */
len = strlen(n) + 1;
p = (struct tbl *)alloc(offsetof(struct tbl, name[0])+len,