more KNF, mostly whitespace, this time more manual labour applying style(9)
This commit is contained in:
parent
39bb71fc54
commit
0432f97ffe
2
check.pl
2
check.pl
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.pl,v 1.22 2009/05/16 16:59:32 tg Rel $
|
# $MirOS: src/bin/mksh/check.pl,v 1.23 2009/06/10 18:12:43 tg Rel $
|
||||||
# $OpenBSD: th,v 1.13 2006/05/18 21:27:23 miod Exp $
|
# $OpenBSD: th,v 1.13 2006/05/18 21:27:23 miod Exp $
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
||||||
|
138
edit.c
138
edit.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.167 2009/06/08 20:22:19 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.168 2009/06/10 18:12:44 tg Exp $");
|
||||||
|
|
||||||
/* tty driver characters we are interested in */
|
/* tty driver characters we are interested in */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -141,8 +141,9 @@ x_putcf(int c)
|
|||||||
shf_putc(c, shl_out);
|
shf_putc(c, shl_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/*********************************
|
||||||
/* Misc common code for vi/emacs */
|
* Misc common code for vi/emacs *
|
||||||
|
*********************************/
|
||||||
|
|
||||||
/* Handle the commenting/uncommenting of a line.
|
/* Handle the commenting/uncommenting of a line.
|
||||||
* Returns:
|
* Returns:
|
||||||
@ -192,8 +193,9 @@ x_do_comment(char *buf, int bsize, int *lenp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/****************************************************
|
||||||
/* Common file/command completion code for vi/emacs */
|
* Common file/command completion code for vi/emacs *
|
||||||
|
****************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
x_print_expansions(int nwords, char * const *words, bool is_command)
|
x_print_expansions(int nwords, char * const *words, bool is_command)
|
||||||
@ -239,7 +241,7 @@ x_print_expansions(int nwords, char * const *words, bool is_command)
|
|||||||
XPfree(l); /* not x_free_words() */
|
XPfree(l); /* not x_free_words() */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Do file globbing:
|
* Do file globbing:
|
||||||
* - appends * to (copy of) str if no globbing chars found
|
* - appends * to (copy of) str if no globbing chars found
|
||||||
* - does expansion, checks for no match, etc.
|
* - does expansion, checks for no match, etc.
|
||||||
@ -513,8 +515,8 @@ x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp,
|
|||||||
return (nwords);
|
return (nwords);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Given a string, copy it and possibly add a '*' to the end. The
|
/* Given a string, copy it and possibly add a '*' to the end.
|
||||||
* new string is returned.
|
* The new string is returned.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
add_glob(const char *str, int slen)
|
add_glob(const char *str, int slen)
|
||||||
@ -537,8 +539,8 @@ add_glob(const char *str, int slen)
|
|||||||
for (s = toglob; *s; s++) {
|
for (s = toglob; *s; s++) {
|
||||||
if (*s == '\\' && s[1])
|
if (*s == '\\' && s[1])
|
||||||
s++;
|
s++;
|
||||||
else if (*s == '*' || *s == '[' || *s == '?' || *s == '$'
|
else if (*s == '*' || *s == '[' || *s == '?' || *s == '$' ||
|
||||||
|| (s[1] == '(' && vstrchr("*+?@!", *s)))
|
(s[1] == '(' && vstrchr("*+?@!", *s)))
|
||||||
break;
|
break;
|
||||||
else if (*s == '/')
|
else if (*s == '/')
|
||||||
saw_slash = true;
|
saw_slash = true;
|
||||||
@ -962,7 +964,7 @@ utf_wctomb(char *dst, unsigned int wc)
|
|||||||
static Area aedit;
|
static Area aedit;
|
||||||
#define AEDIT &aedit /* area for kill ring and macro defns */
|
#define AEDIT &aedit /* area for kill ring and macro defns */
|
||||||
|
|
||||||
#define MKCTRL(x) ((x) == '?' ? 0x7F : (x) & 0x1F) /* ASCII */
|
#define CTRL(x) ((x) == '?' ? 0x7F : (x) & 0x1F) /* ASCII */
|
||||||
#define UNCTRL(x) ((x) ^ 0x40) /* ASCII */
|
#define UNCTRL(x) ((x) ^ 0x40) /* ASCII */
|
||||||
|
|
||||||
/* values returned by keyboard functions */
|
/* values returned by keyboard functions */
|
||||||
@ -1274,56 +1276,56 @@ static const struct x_ftab x_ftab[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct x_defbindings const x_defbindings[] = {
|
static struct x_defbindings const x_defbindings[] = {
|
||||||
{ XFUNC_del_back, 0, MKCTRL('?') },
|
{ XFUNC_del_back, 0, CTRL('?') },
|
||||||
{ XFUNC_del_bword, 1, MKCTRL('?') },
|
{ XFUNC_del_bword, 1, CTRL('?') },
|
||||||
{ XFUNC_eot_del, 0, MKCTRL('D') },
|
{ XFUNC_eot_del, 0, CTRL('D') },
|
||||||
{ XFUNC_del_back, 0, MKCTRL('H') },
|
{ XFUNC_del_back, 0, CTRL('H') },
|
||||||
{ XFUNC_del_bword, 1, MKCTRL('H') },
|
{ XFUNC_del_bword, 1, CTRL('H') },
|
||||||
{ XFUNC_del_bword, 1, 'h' },
|
{ XFUNC_del_bword, 1, 'h' },
|
||||||
{ XFUNC_mv_bword, 1, 'b' },
|
{ XFUNC_mv_bword, 1, 'b' },
|
||||||
{ XFUNC_mv_fword, 1, 'f' },
|
{ XFUNC_mv_fword, 1, 'f' },
|
||||||
{ XFUNC_del_fword, 1, 'd' },
|
{ XFUNC_del_fword, 1, 'd' },
|
||||||
{ XFUNC_mv_back, 0, MKCTRL('B') },
|
{ XFUNC_mv_back, 0, CTRL('B') },
|
||||||
{ XFUNC_mv_forw, 0, MKCTRL('F') },
|
{ XFUNC_mv_forw, 0, CTRL('F') },
|
||||||
{ XFUNC_search_char_forw, 0, MKCTRL(']') },
|
{ XFUNC_search_char_forw, 0, CTRL(']') },
|
||||||
{ XFUNC_search_char_back, 1, MKCTRL(']') },
|
{ XFUNC_search_char_back, 1, CTRL(']') },
|
||||||
{ XFUNC_newline, 0, MKCTRL('M') },
|
{ XFUNC_newline, 0, CTRL('M') },
|
||||||
{ XFUNC_newline, 0, MKCTRL('J') },
|
{ XFUNC_newline, 0, CTRL('J') },
|
||||||
{ XFUNC_end_of_text, 0, MKCTRL('_') },
|
{ XFUNC_end_of_text, 0, CTRL('_') },
|
||||||
{ XFUNC_abort, 0, MKCTRL('G') },
|
{ XFUNC_abort, 0, CTRL('G') },
|
||||||
{ XFUNC_prev_com, 0, MKCTRL('P') },
|
{ XFUNC_prev_com, 0, CTRL('P') },
|
||||||
{ XFUNC_next_com, 0, MKCTRL('N') },
|
{ XFUNC_next_com, 0, CTRL('N') },
|
||||||
{ XFUNC_nl_next_com, 0, MKCTRL('O') },
|
{ XFUNC_nl_next_com, 0, CTRL('O') },
|
||||||
{ XFUNC_search_hist, 0, MKCTRL('R') },
|
{ XFUNC_search_hist, 0, CTRL('R') },
|
||||||
{ XFUNC_beg_hist, 1, '<' },
|
{ XFUNC_beg_hist, 1, '<' },
|
||||||
{ XFUNC_end_hist, 1, '>' },
|
{ XFUNC_end_hist, 1, '>' },
|
||||||
{ XFUNC_goto_hist, 1, 'g' },
|
{ XFUNC_goto_hist, 1, 'g' },
|
||||||
{ XFUNC_mv_end, 0, MKCTRL('E') },
|
{ XFUNC_mv_end, 0, CTRL('E') },
|
||||||
{ XFUNC_mv_begin, 0, MKCTRL('A') },
|
{ XFUNC_mv_begin, 0, CTRL('A') },
|
||||||
{ XFUNC_draw_line, 0, MKCTRL('L') },
|
{ XFUNC_draw_line, 0, CTRL('L') },
|
||||||
{ XFUNC_cls, 1, MKCTRL('L') },
|
{ XFUNC_cls, 1, CTRL('L') },
|
||||||
{ XFUNC_meta1, 0, MKCTRL('[') },
|
{ XFUNC_meta1, 0, CTRL('[') },
|
||||||
{ XFUNC_meta2, 0, MKCTRL('X') },
|
{ XFUNC_meta2, 0, CTRL('X') },
|
||||||
{ XFUNC_kill, 0, MKCTRL('K') },
|
{ XFUNC_kill, 0, CTRL('K') },
|
||||||
{ XFUNC_yank, 0, MKCTRL('Y') },
|
{ XFUNC_yank, 0, CTRL('Y') },
|
||||||
{ XFUNC_meta_yank, 1, 'y' },
|
{ XFUNC_meta_yank, 1, 'y' },
|
||||||
{ XFUNC_literal, 0, MKCTRL('^') },
|
{ XFUNC_literal, 0, CTRL('^') },
|
||||||
{ XFUNC_comment, 1, '#' },
|
{ XFUNC_comment, 1, '#' },
|
||||||
{ XFUNC_transpose, 0, MKCTRL('T') },
|
{ XFUNC_transpose, 0, CTRL('T') },
|
||||||
{ XFUNC_complete, 1, MKCTRL('[') },
|
{ XFUNC_complete, 1, CTRL('[') },
|
||||||
{ XFUNC_comp_list, 0, MKCTRL('I') },
|
{ XFUNC_comp_list, 0, CTRL('I') },
|
||||||
{ XFUNC_comp_list, 1, '=' },
|
{ XFUNC_comp_list, 1, '=' },
|
||||||
{ XFUNC_enumerate, 1, '?' },
|
{ XFUNC_enumerate, 1, '?' },
|
||||||
{ XFUNC_expand, 1, '*' },
|
{ XFUNC_expand, 1, '*' },
|
||||||
{ XFUNC_comp_file, 1, MKCTRL('X') },
|
{ XFUNC_comp_file, 1, CTRL('X') },
|
||||||
{ XFUNC_comp_comm, 2, MKCTRL('[') },
|
{ XFUNC_comp_comm, 2, CTRL('[') },
|
||||||
{ XFUNC_list_comm, 2, '?' },
|
{ XFUNC_list_comm, 2, '?' },
|
||||||
{ XFUNC_list_file, 2, MKCTRL('Y') },
|
{ XFUNC_list_file, 2, CTRL('Y') },
|
||||||
{ XFUNC_set_mark, 1, ' ' },
|
{ XFUNC_set_mark, 1, ' ' },
|
||||||
{ XFUNC_kill_region, 0, MKCTRL('W') },
|
{ XFUNC_kill_region, 0, CTRL('W') },
|
||||||
{ XFUNC_xchg_point_mark, 2, MKCTRL('X') },
|
{ XFUNC_xchg_point_mark, 2, CTRL('X') },
|
||||||
{ XFUNC_literal, 0, MKCTRL('V') },
|
{ XFUNC_literal, 0, CTRL('V') },
|
||||||
{ XFUNC_version, 1, MKCTRL('V') },
|
{ XFUNC_version, 1, CTRL('V') },
|
||||||
{ XFUNC_prev_histword, 1, '.' },
|
{ XFUNC_prev_histword, 1, '.' },
|
||||||
{ XFUNC_prev_histword, 1, '_' },
|
{ XFUNC_prev_histword, 1, '_' },
|
||||||
{ XFUNC_set_arg, 1, '0' },
|
{ XFUNC_set_arg, 1, '0' },
|
||||||
@ -2114,13 +2116,13 @@ x_search_hist(int c)
|
|||||||
if ((c = x_e_getc()) < 0)
|
if ((c = x_e_getc()) < 0)
|
||||||
return (KSTD);
|
return (KSTD);
|
||||||
f = x_tab[0][c];
|
f = x_tab[0][c];
|
||||||
if (c == MKCTRL('[')) {
|
if (c == CTRL('[')) {
|
||||||
if ((f & 0x7F) == XFUNC_meta1) {
|
if ((f & 0x7F) == XFUNC_meta1) {
|
||||||
if ((c = x_e_getc()) < 0)
|
if ((c = x_e_getc()) < 0)
|
||||||
return (KSTD);
|
return (KSTD);
|
||||||
f = x_tab[1][c] & 0x7F;
|
f = x_tab[1][c] & 0x7F;
|
||||||
if (f == XFUNC_meta1 || f == XFUNC_meta2)
|
if (f == XFUNC_meta1 || f == XFUNC_meta2)
|
||||||
x_meta1(MKCTRL('['));
|
x_meta1(CTRL('['));
|
||||||
x_e_ungetc(c);
|
x_e_ungetc(c);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2560,7 +2562,7 @@ x_mapin(const char *cp, Area *ap)
|
|||||||
if (*cp == '^') {
|
if (*cp == '^') {
|
||||||
cp++;
|
cp++;
|
||||||
if (*cp >= '?') /* includes '?'; ASCII */
|
if (*cp >= '?') /* includes '?'; ASCII */
|
||||||
*op++ = MKCTRL(*cp);
|
*op++ = CTRL(*cp);
|
||||||
else {
|
else {
|
||||||
*op++ = '^';
|
*op++ = '^';
|
||||||
cp--;
|
cp--;
|
||||||
@ -2606,7 +2608,7 @@ x_print(int prefix, int key)
|
|||||||
if (prefix)
|
if (prefix)
|
||||||
/* prefix == 1 || prefix == 2 */
|
/* prefix == 1 || prefix == 2 */
|
||||||
shf_puts(x_mapout(prefix == 1 ?
|
shf_puts(x_mapout(prefix == 1 ?
|
||||||
MKCTRL('[') : MKCTRL('X')), shl_stdout);
|
CTRL('[') : CTRL('X')), shl_stdout);
|
||||||
shprintf("%s%s = ", x_mapout(key), (f & 0x80) ? "~" : "");
|
shprintf("%s%s = ", x_mapout(key), (f & 0x80) ? "~" : "");
|
||||||
if ((f & 0x7F) != XFUNC_ins_string)
|
if ((f & 0x7F) != XFUNC_ins_string)
|
||||||
shprintf("%s\n", x_ftab[f & 0x7F].xf_name);
|
shprintf("%s\n", x_ftab[f & 0x7F].xf_name);
|
||||||
@ -3501,35 +3503,35 @@ static const unsigned char classify[128] = {
|
|||||||
/* 0 1 2 3 4 5 6 7 */
|
/* 0 1 2 3 4 5 6 7 */
|
||||||
/* 0 ^@ ^A ^B ^C ^D ^E ^F ^G */
|
/* 0 ^@ ^A ^B ^C ^D ^E ^F ^G */
|
||||||
B_, 0, 0, 0, 0, C_|U_, C_|Z_, 0,
|
B_, 0, 0, 0, 0, C_|U_, C_|Z_, 0,
|
||||||
/* 01 ^H ^I ^J ^K ^L ^M ^N ^O */
|
/* 1 ^H ^I ^J ^K ^L ^M ^N ^O */
|
||||||
M_, C_|Z_, 0, 0, C_|U_, 0, C_, 0,
|
M_, C_|Z_, 0, 0, C_|U_, 0, C_, 0,
|
||||||
/* 02 ^P ^Q ^R ^S ^T ^U ^V ^W */
|
/* 2 ^P ^Q ^R ^S ^T ^U ^V ^W */
|
||||||
C_, 0, C_|U_, 0, 0, 0, C_, 0,
|
C_, 0, C_|U_, 0, 0, 0, C_, 0,
|
||||||
/* 03 ^X ^Y ^Z ^[ ^\ ^] ^^ ^_ */
|
/* 3 ^X ^Y ^Z ^[ ^\ ^] ^^ ^_ */
|
||||||
C_, 0, 0, C_|Z_, 0, 0, 0, 0,
|
C_, 0, 0, C_|Z_, 0, 0, 0, 0,
|
||||||
/* 04 <space> ! " # $ % & ' */
|
/* 4 <space> ! " # $ % & ' */
|
||||||
M_, 0, 0, C_, M_, M_, 0, 0,
|
M_, 0, 0, C_, M_, M_, 0, 0,
|
||||||
/* 05 ( ) * + , - . / */
|
/* 5 ( ) * + , - . / */
|
||||||
0, 0, C_, C_, M_, C_, 0, C_|S_,
|
0, 0, C_, C_, M_, C_, 0, C_|S_,
|
||||||
/* 06 0 1 2 3 4 5 6 7 */
|
/* 6 0 1 2 3 4 5 6 7 */
|
||||||
M_, 0, 0, 0, 0, 0, 0, 0,
|
M_, 0, 0, 0, 0, 0, 0, 0,
|
||||||
/* 07 8 9 : ; < = > ? */
|
/* 7 8 9 : ; < = > ? */
|
||||||
0, 0, 0, M_, 0, C_, 0, C_|S_,
|
0, 0, 0, M_, 0, C_, 0, C_|S_,
|
||||||
/* 010 @ A B C D E F G */
|
/* 8 @ A B C D E F G */
|
||||||
C_|X_, C_, M_, C_, C_, M_, M_|X_, C_|U_|Z_,
|
C_|X_, C_, M_, C_, C_, M_, M_|X_, C_|U_|Z_,
|
||||||
/* 011 H I J K L M N O */
|
/* 9 H I J K L M N O */
|
||||||
0, C_, 0, 0, 0, 0, C_|U_, 0,
|
0, C_, 0, 0, 0, 0, C_|U_, 0,
|
||||||
/* 012 P Q R S T U V W */
|
/* A P Q R S T U V W */
|
||||||
C_, 0, C_, C_, M_|X_, C_, 0, M_,
|
C_, 0, C_, C_, M_|X_, C_, 0, M_,
|
||||||
/* 013 X Y Z [ \ ] ^ _ */
|
/* B X Y Z [ \ ] ^ _ */
|
||||||
C_, C_|U_, 0, 0, C_|Z_, 0, M_, C_|Z_,
|
C_, C_|U_, 0, 0, C_|Z_, 0, M_, C_|Z_,
|
||||||
/* 014 ` a b c d e f g */
|
/* C ` a b c d e f g */
|
||||||
0, C_, M_, E_, E_, M_, M_|X_, C_|Z_,
|
0, C_, M_, E_, E_, M_, M_|X_, C_|Z_,
|
||||||
/* 015 h i j k l m n o */
|
/* D h i j k l m n o */
|
||||||
M_, C_, C_|U_, C_|U_, M_, 0, C_|U_, 0,
|
M_, C_, C_|U_, C_|U_, M_, 0, C_|U_, 0,
|
||||||
/* 016 p q r s t u v w */
|
/* E p q r s t u v w */
|
||||||
C_, 0, X_, C_, M_|X_, C_|U_, C_|U_|Z_, M_,
|
C_, 0, X_, C_, M_|X_, C_|U_, C_|U_|Z_, M_,
|
||||||
/* 017 x y z { | } ~ ^? */
|
/* F x y z { | } ~ ^? */
|
||||||
C_, E_|U_, 0, 0, M_|Z_, 0, C_, 0
|
C_, E_|U_, 0, 0, M_|Z_, 0, C_, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4386,8 +4388,8 @@ vi_cmd(int argcnt, const char *cmd)
|
|||||||
histsave(&source->line, es->cbuf, true,
|
histsave(&source->line, es->cbuf, true,
|
||||||
true);
|
true);
|
||||||
} else
|
} else
|
||||||
argcnt = source->line + 1
|
argcnt = source->line + 1 -
|
||||||
- (hlast - hnum);
|
(hlast - hnum);
|
||||||
}
|
}
|
||||||
if (argcnt)
|
if (argcnt)
|
||||||
shf_snprintf(es->cbuf, es->cbufsize, "%s %d",
|
shf_snprintf(es->cbuf, es->cbufsize, "%s %d",
|
||||||
|
11
eval.c
11
eval.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.58 2009/06/08 20:06:45 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.59 2009/06/10 18:12:45 tg Exp $");
|
||||||
|
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
#define MKSH_NOPWNAM
|
#define MKSH_NOPWNAM
|
||||||
@ -312,13 +312,12 @@ expand(const char *cp, /* input word */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case OSUBST: /* ${{#}var{:}[=+-?#%]word} */
|
case OSUBST: { /* ${{#}var{:}[=+-?#%]word} */
|
||||||
/* format is:
|
/* format is:
|
||||||
* OSUBST [{x] plain-variable-part \0
|
* OSUBST [{x] plain-variable-part \0
|
||||||
* compiled-word-part CSUBST [}x]
|
* compiled-word-part CSUBST [}x]
|
||||||
* This is where all syntax checking gets done...
|
* This is where all syntax checking gets done...
|
||||||
*/
|
*/
|
||||||
{
|
|
||||||
const char *varname = ++sp; /* skip the { or x (}) */
|
const char *varname = ++sp; /* skip the { or x (}) */
|
||||||
int stype;
|
int stype;
|
||||||
int slen = 0;
|
int slen = 0;
|
||||||
@ -629,8 +628,7 @@ expand(const char *cp, /* input word */
|
|||||||
doblank++;
|
doblank++;
|
||||||
st = st->prev;
|
st = st->prev;
|
||||||
continue;
|
continue;
|
||||||
case '?':
|
case '?': {
|
||||||
{
|
|
||||||
char *s = Xrestpos(ds, dp, st->base);
|
char *s = Xrestpos(ds, dp, st->base);
|
||||||
|
|
||||||
errorf("%s: %s", st->var->name,
|
errorf("%s: %s", st->var->name,
|
||||||
@ -734,7 +732,8 @@ expand(const char *cp, /* input word */
|
|||||||
} else {
|
} else {
|
||||||
while ((c = shf_getc(x.u.shf)) == 0 || c == '\n')
|
while ((c = shf_getc(x.u.shf)) == 0 || c == '\n')
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
newlines++; /* Save newlines */
|
/* Save newlines */
|
||||||
|
newlines++;
|
||||||
if (newlines && c != EOF) {
|
if (newlines && c != EOF) {
|
||||||
shf_ungetc(c, x.u.shf);
|
shf_ungetc(c, x.u.shf);
|
||||||
c = '\n';
|
c = '\n';
|
||||||
|
22
exec.c
22
exec.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.57 2009/06/08 20:06:45 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.58 2009/06/10 18:12:45 tg Exp $");
|
||||||
|
|
||||||
static int comexec(struct op *, struct tbl *volatile, const char **,
|
static int comexec(struct op *, struct tbl *volatile, const char **,
|
||||||
int volatile, volatile int *);
|
int volatile, volatile int *);
|
||||||
@ -136,7 +136,8 @@ execute(struct op *volatile t,
|
|||||||
while (t->type == TPIPE) {
|
while (t->type == TPIPE) {
|
||||||
openpipe(pv);
|
openpipe(pv);
|
||||||
ksh_dup2(pv[1], 1, false); /* stdout of curr */
|
ksh_dup2(pv[1], 1, false); /* stdout of curr */
|
||||||
/* Let exchild() close pv[0] in child
|
/**
|
||||||
|
* Let exchild() close pv[0] in child
|
||||||
* (if this isn't done, commands like
|
* (if this isn't done, commands like
|
||||||
* (: ; cat /etc/termcap) | sleep 1
|
* (: ; cat /etc/termcap) | sleep 1
|
||||||
* will hang forever).
|
* will hang forever).
|
||||||
@ -164,8 +165,7 @@ execute(struct op *volatile t,
|
|||||||
rv = execute(t, flags & XERROK, xerrok);
|
rv = execute(t, flags & XERROK, xerrok);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TCOPROC:
|
case TCOPROC: {
|
||||||
{
|
|
||||||
sigset_t omask;
|
sigset_t omask;
|
||||||
|
|
||||||
/* Block sigchild as we are using things changed in the
|
/* Block sigchild as we are using things changed in the
|
||||||
@ -248,8 +248,7 @@ execute(struct op *volatile t,
|
|||||||
*xerrok = 1;
|
*xerrok = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TDBRACKET:
|
case TDBRACKET: {
|
||||||
{
|
|
||||||
Test_env te;
|
Test_env te;
|
||||||
|
|
||||||
te.flags = TEF_DBRACKET;
|
te.flags = TEF_DBRACKET;
|
||||||
@ -264,8 +263,7 @@ execute(struct op *volatile t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case TFOR:
|
case TFOR:
|
||||||
case TSELECT:
|
case TSELECT: {
|
||||||
{
|
|
||||||
volatile bool is_first = true;
|
volatile bool is_first = true;
|
||||||
ap = (t->vars == NULL) ? e->loc->argv + 1 :
|
ap = (t->vars == NULL) ? e->loc->argv + 1 :
|
||||||
(const char **)eval((const char **)t->vars,
|
(const char **)eval((const char **)t->vars,
|
||||||
@ -301,8 +299,8 @@ execute(struct op *volatile t,
|
|||||||
rv = execute(t->left, flags & XERROK, xerrok);
|
rv = execute(t->left, flags & XERROK, xerrok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case TWHILE:
|
case TWHILE:
|
||||||
case TUNTIL:
|
case TUNTIL:
|
||||||
@ -538,8 +536,7 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
|
|||||||
rv = call_builtin(tp, (const char **)ap);
|
rv = call_builtin(tp, (const char **)ap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CFUNC: /* function call */
|
case CFUNC: { /* function call */
|
||||||
{
|
|
||||||
volatile char old_xflag;
|
volatile char old_xflag;
|
||||||
volatile Tflag old_inuse;
|
volatile Tflag old_inuse;
|
||||||
const char *volatile old_kshname;
|
const char *volatile old_kshname;
|
||||||
@ -1148,8 +1145,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
|||||||
/* cp may have wrong name */
|
/* cp may have wrong name */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IODUP:
|
case IODUP: {
|
||||||
{
|
|
||||||
const char *emsg;
|
const char *emsg;
|
||||||
|
|
||||||
do_open = 0;
|
do_open = 0;
|
||||||
|
2
expr.c
2
expr.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.28 2009/06/08 20:13:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.29 2009/06/10 18:12:45 tg Exp $");
|
||||||
|
|
||||||
/* The order of these enums is constrained by the order of opinfo[] */
|
/* The order of these enums is constrained by the order of opinfo[] */
|
||||||
enum token {
|
enum token {
|
||||||
|
29
funcs.c
29
funcs.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.113 2009/06/10 18:11:26 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.114 2009/06/10 18:12:46 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -168,8 +168,7 @@ static const char *ptest_getopnd(Test_env *, Test_op, bool);
|
|||||||
static void ptest_error(Test_env *, int, const char *);
|
static void ptest_error(Test_env *, int, const char *);
|
||||||
static char *kill_fmt_entry(const void *, int, char *, int);
|
static char *kill_fmt_entry(const void *, int, char *, int);
|
||||||
static void p_time(struct shf *, bool, long, int, int,
|
static void p_time(struct shf *, bool, long, int, int,
|
||||||
const char *, const char *)
|
const char *, const char *) __attribute__((nonnull (6, 7)));
|
||||||
__attribute__((nonnull (6, 7)));
|
|
||||||
|
|
||||||
int
|
int
|
||||||
c_cd(const char **wp)
|
c_cd(const char **wp)
|
||||||
@ -465,8 +464,10 @@ c_print(const char **wp)
|
|||||||
*/
|
*/
|
||||||
case 'a': c = '\007'; break;
|
case 'a': c = '\007'; break;
|
||||||
case 'b': c = '\b'; break;
|
case 'b': c = '\b'; break;
|
||||||
case 'c': flags &= ~PO_NL;
|
case 'c':
|
||||||
continue; /* AT&T brain damage */
|
flags &= ~PO_NL;
|
||||||
|
/* AT&T brain damage */
|
||||||
|
continue;
|
||||||
case 'f': c = '\f'; break;
|
case 'f': c = '\f'; break;
|
||||||
case 'n': c = '\n'; break;
|
case 'n': c = '\n'; break;
|
||||||
case 'r': c = '\r'; break;
|
case 'r': c = '\r'; break;
|
||||||
@ -559,7 +560,7 @@ c_print(const char **wp)
|
|||||||
int opipe = 0;
|
int opipe = 0;
|
||||||
|
|
||||||
/* Ensure we aren't killed by a SIGPIPE while writing to
|
/* Ensure we aren't killed by a SIGPIPE while writing to
|
||||||
* a coprocess. at&t ksh doesn't seem to do this (seems
|
* a coprocess. AT&T ksh doesn't seem to do this (seems
|
||||||
* to just check that the co-process is alive which is
|
* to just check that the co-process is alive which is
|
||||||
* not enough).
|
* not enough).
|
||||||
*/
|
*/
|
||||||
@ -1683,16 +1684,21 @@ c_umask(const char **wp)
|
|||||||
case 'r': new_val |= 04; break;
|
case 'r': new_val |= 04; break;
|
||||||
case 'w': new_val |= 02; break;
|
case 'w': new_val |= 02; break;
|
||||||
case 'x': new_val |= 01; break;
|
case 'x': new_val |= 01; break;
|
||||||
case 'u': new_val |= old_umask >> 6;
|
case 'u':
|
||||||
|
new_val |= old_umask >> 6;
|
||||||
break;
|
break;
|
||||||
case 'g': new_val |= old_umask >> 3;
|
case 'g':
|
||||||
|
new_val |= old_umask >> 3;
|
||||||
break;
|
break;
|
||||||
case 'o': new_val |= old_umask >> 0;
|
case 'o':
|
||||||
|
new_val |= old_umask >> 0;
|
||||||
break;
|
break;
|
||||||
case 'X': if (old_umask & 0111)
|
case 'X':
|
||||||
|
if (old_umask & 0111)
|
||||||
new_val |= 01;
|
new_val |= 01;
|
||||||
break;
|
break;
|
||||||
case 's': /* ignored */
|
case 's':
|
||||||
|
/* ignored */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
new_val = (new_val & 07) * positions;
|
new_val = (new_val & 07) * positions;
|
||||||
@ -1978,6 +1984,7 @@ c_eval(const char **wp)
|
|||||||
*
|
*
|
||||||
* A strict reading of POSIX says we don't do this (though
|
* A strict reading of POSIX says we don't do this (though
|
||||||
* it is traditionally done). [from 1003.2-1992]
|
* it is traditionally done). [from 1003.2-1992]
|
||||||
|
*
|
||||||
* 3.9.1: Simple Commands
|
* 3.9.1: Simple Commands
|
||||||
* ... If there is a command name, execution shall
|
* ... If there is a command name, execution shall
|
||||||
* continue as described in 3.9.1.1. If there
|
* continue as described in 3.9.1.1. If there
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.83 2009/06/08 20:06:46 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.84 2009/06/10 18:12:46 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* MirOS: This is the default mapping type, and need not be specified.
|
* MirOS: This is the default mapping type, and need not be specified.
|
||||||
@ -642,7 +642,8 @@ histsave(int *lnp, const char *cmd, bool dowrite __unused, bool ignoredups)
|
|||||||
/*
|
/*
|
||||||
* Open a history file
|
* Open a history file
|
||||||
* Format is:
|
* Format is:
|
||||||
* Bytes 1, 2: HMAGIC - just to check that we are dealing with
|
* Bytes 1, 2:
|
||||||
|
* HMAGIC - just to check that we are dealing with
|
||||||
* the correct object
|
* the correct object
|
||||||
* Then follows a number of stored commands
|
* Then follows a number of stored commands
|
||||||
* Each command is
|
* Each command is
|
||||||
|
2
jobs.c
2
jobs.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.55 2009/06/08 20:34:40 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.56 2009/06/10 18:12:47 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
#define mksh_killpg killpg
|
#define mksh_killpg killpg
|
||||||
|
11
lex.c
11
lex.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.86 2009/06/08 20:06:47 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.87 2009/06/10 18:12:47 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* states while lexing word
|
* states while lexing word
|
||||||
@ -141,7 +141,7 @@ static int ignore_backslash_newline;
|
|||||||
state = statep->ls_state; \
|
state = statep->ls_state; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Lexical analyser
|
* Lexical analyser
|
||||||
*
|
*
|
||||||
* tokens are not regular expressions, they are LL(1).
|
* tokens are not regular expressions, they are LL(1).
|
||||||
@ -260,8 +260,8 @@ yylex(int cf)
|
|||||||
|
|
||||||
s = pushs(SREREAD,
|
s = pushs(SREREAD,
|
||||||
source->areap);
|
source->areap);
|
||||||
s->start = s->str
|
s->start = s->str =
|
||||||
= s->u.freeme = tmp;
|
s->u.freeme = tmp;
|
||||||
s->next = source;
|
s->next = source;
|
||||||
source = s;
|
source = s;
|
||||||
}
|
}
|
||||||
@ -1406,8 +1406,7 @@ get_brace_var(XString *wsp, char *wp)
|
|||||||
enum parse_state {
|
enum parse_state {
|
||||||
PS_INITIAL, PS_SAW_HASH, PS_IDENT,
|
PS_INITIAL, PS_SAW_HASH, PS_IDENT,
|
||||||
PS_NUMBER, PS_VAR1, PS_END
|
PS_NUMBER, PS_VAR1, PS_END
|
||||||
}
|
} state;
|
||||||
state;
|
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
state = PS_INITIAL;
|
state = PS_INITIAL;
|
||||||
|
2
main.c
2
main.c
@ -33,7 +33,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.131 2009/06/08 20:06:47 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.132 2009/06/10 18:12:47 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
|
8
misc.c
8
misc.c
@ -29,7 +29,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.109 2009/06/08 20:06:48 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.110 2009/06/10 18:12:48 tg Exp $");
|
||||||
|
|
||||||
#undef USE_CHVT
|
#undef USE_CHVT
|
||||||
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
||||||
@ -138,7 +138,7 @@ const struct shoption options[] = {
|
|||||||
{ "posix", 0, OF_ANY }, /* non-standard */
|
{ "posix", 0, OF_ANY }, /* non-standard */
|
||||||
{ "privileged", 'p', OF_ANY },
|
{ "privileged", 'p', OF_ANY },
|
||||||
{ "restricted", 'r', OF_CMDLINE },
|
{ "restricted", 'r', OF_CMDLINE },
|
||||||
{ "stdin", 's', OF_CMDLINE }, /* pseudo non-standard */
|
{ "stdin", 's', OF_CMDLINE }, /* pseudo non-st.. */
|
||||||
{ "trackall", 'h', OF_ANY },
|
{ "trackall", 'h', OF_ANY },
|
||||||
{ "utf8-mode", 'U', OF_ANY }, /* non-standard */
|
{ "utf8-mode", 'U', OF_ANY }, /* non-standard */
|
||||||
{ "verbose", 'v', OF_ANY },
|
{ "verbose", 'v', OF_ANY },
|
||||||
@ -287,7 +287,7 @@ change_flag(enum sh_flag f,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse command line & set command arguments. returns the index of
|
/* Parse command line & set command arguments. Returns the index of
|
||||||
* non-option arguments, -1 if there is an error.
|
* non-option arguments, -1 if there is an error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -644,7 +644,7 @@ do_gmatch(const unsigned char *s, const unsigned char *se,
|
|||||||
} while (s++ < se);
|
} while (s++ < se);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* [*+?@!](pattern|pattern|..)
|
* [*+?@!](pattern|pattern|..)
|
||||||
* This is also needed for ${..%..}, etc.
|
* This is also needed for ${..%..}, etc.
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/** $MirOS: src/bin/mksh/setmode.c,v 1.12 2009/04/07 18:41:37 tg Rel $ */
|
|
||||||
/* $OpenBSD: setmode.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */
|
/* $OpenBSD: setmode.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */
|
||||||
/* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */
|
/* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */
|
||||||
|
|
||||||
@ -57,7 +56,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
__SCCSID("@(#)setmode.c 8.2 (Berkeley) 3/25/94");
|
__SCCSID("@(#)setmode.c 8.2 (Berkeley) 3/25/94");
|
||||||
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.12 2009/04/07 18:41:37 tg Rel $");
|
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.14 2009/06/10 18:12:48 tg Rel $");
|
||||||
__RCSID("$miros: src/lib/libc/gen/setmode.c,v 1.12 2009/06/10 18:12:42 tg Exp $");
|
__RCSID("$miros: src/lib/libc/gen/setmode.c,v 1.12 2009/06/10 18:12:42 tg Exp $");
|
||||||
|
|
||||||
/* for mksh */
|
/* for mksh */
|
||||||
|
10
sh.h
10
sh.h
@ -122,7 +122,7 @@
|
|||||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.309 2009/06/10 18:11:27 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.310 2009/06/10 18:12:48 tg Rel $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R38 2009/06/10"
|
#define MKSH_VERSION "R38 2009/06/10"
|
||||||
|
|
||||||
@ -667,11 +667,11 @@ EXTERN int really_exit;
|
|||||||
*/
|
*/
|
||||||
#define C_ALPHA BIT(0) /* a-z_A-Z */
|
#define C_ALPHA BIT(0) /* a-z_A-Z */
|
||||||
#define C_DIGIT BIT(1) /* 0-9 */
|
#define C_DIGIT BIT(1) /* 0-9 */
|
||||||
#define C_LEX1 BIT(2) /* \0 \t\n|&;<>() */
|
#define C_LEX1 BIT(2) /* \t \n\0|&;<>() */
|
||||||
#define C_VAR1 BIT(3) /* *@#!$-? */
|
#define C_VAR1 BIT(3) /* *@#!$-? */
|
||||||
#define C_IFSWS BIT(4) /* \t \n (IFS white space) */
|
#define C_IFSWS BIT(4) /* \t \n (IFS white space) */
|
||||||
#define C_SUBOP1 BIT(5) /* "=-+?" */
|
#define C_SUBOP1 BIT(5) /* "=-+?" */
|
||||||
#define C_QUOTE BIT(6) /* \n\t"#$&'()*;<>?[]\`| (needing quoting) */
|
#define C_QUOTE BIT(6) /* \t \n"#$&'()*;<>?[]\`| (needing quoting) */
|
||||||
#define C_IFS BIT(7) /* $IFS */
|
#define C_IFS BIT(7) /* $IFS */
|
||||||
#define C_SUBOP2 BIT(8) /* "#%" (magic, see below) */
|
#define C_SUBOP2 BIT(8) /* "#%" (magic, see below) */
|
||||||
|
|
||||||
@ -885,8 +885,8 @@ struct tbl { /* table item */
|
|||||||
/* Attributes that can be set by the user (used to decide if an unset param
|
/* Attributes that can be set by the user (used to decide if an unset param
|
||||||
* should be repoted by set/typeset). Does not include ARRAY or LOCAL.
|
* should be repoted by set/typeset). Does not include ARRAY or LOCAL.
|
||||||
*/
|
*/
|
||||||
#define USERATTRIB (EXPORT|INTEGER|RDONLY|LJUST|RJUST|ZEROFIL\
|
#define USERATTRIB (EXPORT|INTEGER|RDONLY|LJUST|RJUST|ZEROFIL|\
|
||||||
|LCASEV|UCASEV_AL|INT_U|INT_L)
|
LCASEV|UCASEV_AL|INT_U|INT_L)
|
||||||
|
|
||||||
/* command types */
|
/* command types */
|
||||||
#define CNONE 0 /* undefined */
|
#define CNONE 0 /* undefined */
|
||||||
|
5
shf.c
5
shf.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.29 2009/06/08 20:06:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.30 2009/06/10 18:12:49 tg Exp $");
|
||||||
|
|
||||||
/* flags to shf_emptybuf() */
|
/* flags to shf_emptybuf() */
|
||||||
#define EB_READSW 0x01 /* about to switch to reading */
|
#define EB_READSW 0x01 /* about to switch to reading */
|
||||||
@ -905,8 +905,7 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
case 'x':
|
case 'x': {
|
||||||
{
|
|
||||||
const char *digits = (flags & FL_UPPER) ?
|
const char *digits = (flags & FL_UPPER) ?
|
||||||
"0123456789ABCDEF" :
|
"0123456789ABCDEF" :
|
||||||
"0123456789abcdef";
|
"0123456789abcdef";
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.6 2009/05/27 09:58:24 tg Rel $");
|
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.7 2009/06/10 18:12:50 tg Rel $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy src to string dst of size siz. At most siz-1 characters
|
* Copy src to string dst of size siz. At most siz-1 characters
|
||||||
|
5
syn.c
5
syn.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.36 2009/06/08 20:06:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.37 2009/06/10 18:12:50 tg Exp $");
|
||||||
|
|
||||||
struct nesting_state {
|
struct nesting_state {
|
||||||
int start_token; /* token than began nesting (eg, FOR) */
|
int start_token; /* token than began nesting (eg, FOR) */
|
||||||
@ -353,8 +353,7 @@ get_command(int cf)
|
|||||||
t = nested(TBRACE, '{', '}');
|
t = nested(TBRACE, '{', '}');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MDPAREN:
|
case MDPAREN: {
|
||||||
{
|
|
||||||
static const char let_cmd[] = {
|
static const char let_cmd[] = {
|
||||||
CHAR, 'l', CHAR, 'e',
|
CHAR, 'l', CHAR, 'e',
|
||||||
CHAR, 't', EOS
|
CHAR, 't', EOS
|
||||||
|
5
tree.c
5
tree.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.27 2009/06/08 20:06:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.28 2009/06/10 18:12:50 tg Exp $");
|
||||||
|
|
||||||
#define INDENT 4
|
#define INDENT 4
|
||||||
|
|
||||||
@ -84,8 +84,7 @@ ptree(struct op *t, int indent, struct shf *shf)
|
|||||||
shf_puts("! ", shf);
|
shf_puts("! ", shf);
|
||||||
t = t->right;
|
t = t->right;
|
||||||
goto Chain;
|
goto Chain;
|
||||||
case TDBRACKET:
|
case TDBRACKET: {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
shf_puts("[[", shf);
|
shf_puts("[[", shf);
|
||||||
|
9
var.c
9
var.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.73 2009/06/08 20:06:50 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.74 2009/06/10 18:12:51 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables
|
* Variables
|
||||||
@ -303,8 +303,9 @@ str_val(struct tbl *vp)
|
|||||||
else if (!(vp->flag&INTEGER)) /* string source */
|
else if (!(vp->flag&INTEGER)) /* string source */
|
||||||
s = vp->val.s + vp->type;
|
s = vp->val.s + vp->type;
|
||||||
else { /* integer source */
|
else { /* integer source */
|
||||||
/* worst case number length is when base=2, so use BITS(long) */
|
/* worst case number length is when base=2 */
|
||||||
/* minus base # number NUL */
|
/* 1 (minus) + 2 (base, up to 36) + 1 ('#') + number of bits
|
||||||
|
* in the mksh_uari_t + 1 (NUL) */
|
||||||
char strbuf[1 + 2 + 1 + 8 * sizeof(mksh_uari_t) + 1];
|
char strbuf[1 + 2 + 1 + 8 * sizeof(mksh_uari_t) + 1];
|
||||||
const char *digits = (vp->flag & UCASEV_AL) ?
|
const char *digits = (vp->flag & UCASEV_AL) ?
|
||||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" :
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" :
|
||||||
@ -820,7 +821,7 @@ skip_varname(const char *s, int aok)
|
|||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a pointer to the first character past any legal variable name. */
|
/* Return a pointer to the first character past any legal variable name */
|
||||||
const char *
|
const char *
|
||||||
skip_wdvarname(const char *s,
|
skip_wdvarname(const char *s,
|
||||||
int aok) /* skip array de-reference? */
|
int aok) /* skip array de-reference? */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user