summaryrefslogtreecommitdiff
path: root/Src/Zle
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/compcore.c4
-rw-r--r--Src/Zle/complist.c9
-rw-r--r--Src/Zle/computil.c4
-rw-r--r--Src/Zle/zle.h4
-rw-r--r--Src/Zle/zle_refresh.c31
-rw-r--r--Src/Zle/zle_tricky.c9
6 files changed, 32 insertions, 29 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 8eca39447..0a454ad5f 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -3160,9 +3160,7 @@ matcheq(Cmatch a, Cmatch b)
matchstreq(a->ppre, b->ppre) &&
matchstreq(a->psuf, b->psuf) &&
matchstreq(a->suf, b->suf) &&
- ((!a->disp && !b->disp && matchstreq(a->str, b->str)) ||
- (a->disp && b->disp && !strcmp(a->disp, b->disp) &&
- matchstreq(a->str, b->str)));
+ matchstreq(a->str, b->str);
}
/* Make an array from a linked list. The second argument says whether *
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index e768aee5d..429c8159f 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1096,6 +1096,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
p += len;
if (*p) {
int arg = 0, is_fg;
+ zattr atr;
if (idigit(*p))
arg = zstrtol(p, &p, 10);
@@ -1159,13 +1160,13 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
/* colours must be ASCII */
if (*p == '{') {
p++;
- arg = match_colour((const char **)&p, is_fg, 0);
+ atr = match_colour((const char **)&p, is_fg, 0);
if (*p == '}')
p++;
} else
- arg = match_colour(NULL, is_fg, arg);
- if (arg >= 0 && dopr)
- set_colour_attribute(arg, is_fg ? COL_SEQ_FG :
+ atr = match_colour(NULL, is_fg, arg);
+ if (atr != TXT_ERROR && dopr)
+ set_colour_attribute(atr, is_fg ? COL_SEQ_FG :
COL_SEQ_BG, 0);
break;
case ZWC('f'):
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 5526e0ad0..cb1c01042 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -561,9 +561,9 @@ cd_init(char *nam, char *hide, char *mlen, char *sep,
if (str->str == str->match)
str->str = ztrdup(str->str);
if (hide[1] && str->str[0] == '-' && str->str[1] == '-')
- strcpy(str->str, str->str + 2);
+ memmove(str->str, str->str + 2, strlen(str->str) - 1);
else if (str->str[0] == '-' || str->str[0] == '+')
- strcpy(str->str, str->str + 1);
+ memmove(str->str, str->str + 1, strlen(str->str));
}
}
for (ap = args; *args &&
diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h
index 8261da92b..f06c56483 100644
--- a/Src/Zle/zle.h
+++ b/Src/Zle/zle.h
@@ -430,7 +430,7 @@ enum {
*/
struct region_highlight {
/* Attributes turned on in the region */
- int atr;
+ zattr atr;
/* Start of the region */
int start;
/* Start of the region in metafied ZLE line */
@@ -488,7 +488,7 @@ typedef struct {
* need the effect; 'off' attributes are only present for the
* last character in the sequence.
*/
- int atr;
+ zattr atr;
} REFRESH_ELEMENT;
/* A string of screen cells */
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index d0dd1ef06..1f293845f 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -149,7 +149,7 @@ char *lpromptbuf, *rpromptbuf;
/* Text attributes after displaying prompts */
/**/
-unsigned pmpt_attr, rpmpt_attr;
+zattr pmpt_attr, rpmpt_attr;
/* number of lines displayed */
@@ -208,7 +208,7 @@ int predisplaylen, postdisplaylen;
* displayed on screen.
*/
-static int default_atr_on, special_atr_on;
+static zattr default_atr_on, special_atr_on;
/*
* Array of region highlights, no special termination.
@@ -521,7 +521,7 @@ unset_region_highlight(Param pm, int exp)
/* The last attributes that were on. */
-static int lastatr;
+static zattr lastatr;
/*
* Clear the last attributes that we set: used when we're going
@@ -560,7 +560,7 @@ tcoutclear(int cap)
/**/
void
-zwcputc(const REFRESH_ELEMENT *c, int *curatrp)
+zwcputc(const REFRESH_ELEMENT *c, zattr *curatrp)
{
/*
* Safety: turn attributes off if last heard of turned on.
@@ -638,7 +638,7 @@ static int
zwcwrite(const REFRESH_STRING s, size_t i)
{
size_t j;
- int curatr = 0;
+ zattr curatr = 0;
for (j = 0; j < i; j++)
zwcputc(s + j, &curatr);
@@ -891,7 +891,7 @@ snextline(Rparams rpms)
/**/
static void
-settextattributes(int atr)
+settextattributes(zattr atr)
{
if (txtchangeisset(atr, TXTNOBOLDFACE))
tsetcap(TCALLATTRSOFF, 0);
@@ -992,7 +992,7 @@ zrefresh(void)
int tmppos; /* t - tmpline */
int tmpalloced; /* flag to free tmpline when finished */
int remetafy; /* flag that zle line is metafied */
- int txtchange; /* attributes set after prompts */
+ zattr txtchange; /* attributes set after prompts */
int rprompt_off = 1; /* Offset of rprompt from right of screen */
struct rparams rpms;
#ifdef MULTIBYTE_SUPPORT
@@ -1212,8 +1212,9 @@ zrefresh(void)
rpms.s = nbuf[rpms.ln = 0] + lpromptw;
rpms.sen = *nbuf + winw;
for (t = tmpline, tmppos = 0; tmppos < tmpll; t++, tmppos++) {
- int base_atr_on = default_atr_on, base_atr_off = 0, ireg;
- int all_atr_on, all_atr_off;
+ unsigned ireg;
+ zattr base_atr_on = default_atr_on, base_atr_off = 0;
+ zattr all_atr_on, all_atr_off;
struct region_highlight *rhp;
/*
* Calculate attribute based on region.
@@ -1446,7 +1447,8 @@ zrefresh(void)
more_end = 1;
if (statusline) {
- int outll, outsz, all_atr_on, all_atr_off;
+ int outll, outsz;
+ zattr all_atr_on, all_atr_off;
char *statusdup = ztrdup(statusline);
ZLE_STRING_T outputline =
stringaszleline(statusdup, 0, &outll, &outsz, NULL);
@@ -1672,7 +1674,7 @@ zrefresh(void)
/* output the right-prompt if appropriate */
if (put_rpmpt && !iln && !oput_rpmpt) {
- int attrchange;
+ zattr attrchange;
moveto(0, winw - rprompt_off - rpromptw);
zputs(rpromptbuf, shout);
@@ -1926,7 +1928,7 @@ refreshline(int ln)
/* 3: main display loop - write out the buffer using whatever tricks we can */
for (;;) {
- int now_off;
+ zattr now_off;
#ifdef MULTIBYTE_SUPPORT
if ((!nl->chr || nl->chr != WEOF) && (!ol->chr || ol->chr != WEOF)) {
@@ -2506,8 +2508,9 @@ singlerefresh(ZLE_STRING_T tmpline, int tmpll, int tmpcs)
*vp = zr_zr;
for (t0 = 0; t0 < tmpll; t0++) {
- int base_atr_on = 0, base_atr_off = 0, ireg;
- int all_atr_on, all_atr_off;
+ unsigned ireg;
+ zattr base_atr_on = 0, base_atr_off = 0;
+ zattr all_atr_on, all_atr_off;
struct region_highlight *rhp;
/*
* Calculate attribute based on region.
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 22c381237..2b25d6b2e 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2431,6 +2431,7 @@ printfmt(char *fmt, int n, int dopr, int doesc)
/* Handle the `%' stuff (%% == %, %n == <number of matches>). */
if (doesc && *p == '%') {
int arg = 0, is_fg;
+ zattr atr;
if (idigit(*++p))
arg = zstrtol(p, &p, 10);
if (*p) {
@@ -2482,13 +2483,13 @@ printfmt(char *fmt, int n, int dopr, int doesc)
is_fg = (*p == 'F');
if (p[1] == '{') {
p += 2;
- arg = match_colour((const char **)&p, is_fg, 0);
+ atr = match_colour((const char **)&p, is_fg, 0);
if (*p != '}')
p--;
} else
- arg = match_colour(NULL, is_fg, arg);
- if (arg >= 0)
- set_colour_attribute(arg, is_fg ? COL_SEQ_FG :
+ atr = match_colour(NULL, is_fg, arg);
+ if (atr != TXT_ERROR)
+ set_colour_attribute(atr, is_fg ? COL_SEQ_FG :
COL_SEQ_BG, 0);
break;
case 'f':