* Build.sh: fix accidental CR-LF catastrophe

(yeah, that's what you get from developing with a
  16-bit MS-DOS(R) executable of your favourite text editor)
* lex.c, mksh.1: do not print the delimiting character for
  not-to-be-counted character sequences (i.e. ANSI escapes)
  in prompts any more, mostly because ASCII 01h is printable
  on both Interix and Cygwin and I'm lazy
  (this also fixes prompt width counting if a printable character
  such as 'x' is used as delimiting character)
* lex.c: through printing the prompt character by character,
  also print the delimited sequences if skipping, fixes some
  prompt redrawal not honouring colours stuff while not totally
  redrawing the entire prompt
This commit is contained in:
tg 2006-08-02 10:41:03 +00:00
parent ce8fd25903
commit df54522223
3 changed files with 18 additions and 17 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirOS: src/bin/mksh/Build.sh,v 1.35 2006/08/02 10:02:21 tg Exp $
# $MirOS: src/bin/mksh/Build.sh,v 1.36 2006/08/02 10:41:03 tg Exp $
#-
# This script recognises CC, CFLAGS, CPPFLAGS, LDFLAGS, LIBS and NROFF.
@ -53,11 +53,11 @@ SRCS="alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c $SRCS"
SRCS="$SRCS jobs.c lex.c main.c misc.c shf.c syn.c tree.c var.c"
[ $x = 1 ] || case "`uname -s 2>/dev/null || uname`" in
CYGWIN*)
CYGWIN*)
LDSTATIC= # they don't want it
SRCS="$SRCS compat.c"
CPPFLAGS="$CPPFLAGS -DNEED_COMPAT"
;;
;;
Darwin)
LDSTATIC= # never works
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"

15
lex.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.18 2006/08/01 14:59:51 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.19 2006/08/02 10:41:03 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state. */
@ -1106,13 +1106,6 @@ dopprompt(const char *cp, int ntruncate, const char **spp, int doprint)
cp += 2;
}
for (; *cp; cp++) {
if (ntruncate) {
if (!(indelimit || (*cp == delimiter)))
--ntruncate;
} else if (doprint) {
shf_puts(cp, shl_out);
doprint = 0;
}
if (indelimit && *cp != delimiter)
;
else if (*cp == '\n' || *cp == '\r') {
@ -1128,6 +1121,12 @@ dopprompt(const char *cp, int ntruncate, const char **spp, int doprint)
indelimit = !indelimit;
else
count++;
if (*cp != delimiter) {
if (ntruncate && !indelimit)
--ntruncate;
else if (doprint)
shf_putc(*cp, shl_out);
}
}
if (spp)
*spp = sp;

14
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.43 2006/08/01 14:09:19 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.44 2006/08/02 10:41:03 tg Exp $
.\" $OpenBSD: ksh.1,v 1.116 2006/07/26 10:13:25 jmc Exp $
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
.\"
@ -1485,13 +1485,15 @@ Note that since the command-line editors try to figure out how long the prompt
is (so they know how far it is to the edge of the screen), escape codes in
the prompt tend to mess things up.
You can tell the shell not to count certain
sequences (such as escape codes) by prefixing your prompt with a non-printing
sequences (such as escape codes) by prefixing your prompt with a
character (such as control-A) followed by a carriage return and then delimiting
the escape codes with this non-printing character.
If you don't have any non-printing characters, you're out of luck.
the escape codes with this character.
Any occurences of that character in the prompt are not printed.
By the way, don't blame me for
this hack; it's in the original
.Xr ksh88 1 .
this hack; it's derived from the original
.Xr ksh88 1 ,
which did print the delimiter character so you were out of luck
if you did not have any non-printing characters.
The default prompt is
.Sq $\ \&
for non-root users,