Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use multibyte.h macros for CHAR_T #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common/cut.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ cut(
int flags)
{
CB *cbp;
CHAR_T name = '\0';
CHAR_T name = L('\0');
recno_t lno;
int append, copy_one, copy_def;

Expand Down Expand Up @@ -106,10 +106,10 @@ cut(
copy_one = 1;
cb_rotate(sp);
}
if ((append = isupper(name))) {
if ((append = ISUPPER(name))) {
if (!copy_one)
copy_def = 1;
name = tolower(name);
name = TOLOWER(name);
}
namecb: CBNAME(sp, cbp, name);
} else if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) &&
Expand Down
2 changes: 1 addition & 1 deletion common/cut.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct _text { /* Text: a linked list of lines. */
*/
#define CBNAME(sp, cbp, nch) { \
CHAR_T L__name; \
L__name = isupper(nch) ? tolower(nch) : (nch); \
L__name = ISUPPER(nch) ? TOLOWER(nch) : (nch); \
SLIST_FOREACH(cbp, sp->gp->cutq, q) \
if (cbp->name == L__name) \
break; \
Expand Down
4 changes: 2 additions & 2 deletions ex/ex.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ loop: ecp = SLIST_FIRST(gp->ecq);
break;
case 'E': case 'F': case 'N': case 'P': case 'T': case 'V':
newscreen = 1;
p[0] = tolower(p[0]);
p[0] = TOLOWER(p[0]);
break;
}

Expand Down Expand Up @@ -477,7 +477,7 @@ loop: ecp = SLIST_FIRST(gp->ecq);
/* FALLTHROUGH */
default:
unknown: if (newscreen)
p[0] = toupper(p[0]);
p[0] = TOUPPER(p[0]);
ex_unknown(sp, p, namelen);
goto err;
}
Expand Down
10 changes: 5 additions & 5 deletions ex/ex_cscope.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ ex_cscope(SCR *sp, EXCMD *cmdp)

/* Skip leading whitespace. */
for (p = cmdp->argv[0]->bp, i = cmdp->argv[0]->len; i > 0; --i, ++p)
if (!isspace(*p))
if (!ISSPACE(*p))
break;
if (i == 0)
goto usage;

/* Skip the command to any arguments. */
for (cmd = p; i > 0; --i, ++p)
if (isspace(*p))
if (ISSPACE(*p))
break;
if (*p != '\0') {
*p++ = '\0';
for (; *p && isspace(*p); ++p);
if (*p != L('\0')) {
*p++ = L('\0');
for (; *p && ISSPACE(*p); ++p);
}

INT2CHAR(sp, cmd, STRLEN(cmd) + 1, np, nlen);
Expand Down
4 changes: 2 additions & 2 deletions ex/ex_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bdisplay(SCR *sp)

/* Display regular cut buffers. */
SLIST_FOREACH(cbp, sp->gp->cutq, q) {
if (isdigit(cbp->name))
if (ISDIGIT(cbp->name))
continue;
if (!TAILQ_EMPTY(cbp->textq))
db(sp, cbp, NULL);
Expand All @@ -103,7 +103,7 @@ bdisplay(SCR *sp)
}
/* Display numbered buffers. */
SLIST_FOREACH(cbp, sp->gp->cutq, q) {
if (!isdigit(cbp->name))
if (!ISDIGIT(cbp->name))
continue;
if (!TAILQ_EMPTY(cbp->textq))
db(sp, cbp, NULL);
Expand Down
9 changes: 5 additions & 4 deletions ex/ex_join.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ ex_join(SCR *sp, EXCMD *cmdp)
{
recno_t from, to;
size_t blen, clen, len, tlen;
int echar = 0, extra, first;
CHAR_T echar = 0;
int extra, first;
CHAR_T *bp, *tbp = NULL;
CHAR_T *p;

Expand Down Expand Up @@ -104,8 +105,8 @@ ex_join(SCR *sp, EXCMD *cmdp)
*/
extra = 0;
if (!first && !FL_ISSET(cmdp->iflags, E_C_FORCE)) {
if (isblank(echar))
for (; len && isblank(*p); --len, ++p);
if (ISBLANK(echar))
for (; len && ISBLANK(*p); --len, ++p);
else if (p[0] != ')') {
if (STRCHR(L(".?!"), echar)) {
*tbp++ = ' ';
Expand All @@ -114,7 +115,7 @@ ex_join(SCR *sp, EXCMD *cmdp)
}
*tbp++ = ' ';
++clen;
for (; len && isblank(*p); --len, ++p);
for (; len && ISBLANK(*p); --len, ++p);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ex/ex_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ ex_map(SCR *sp, EXCMD *cmdp)
* call it as well. Note, the SEQ_FUNCMAP type is persistent across
* screen types, maybe the next screen type will get it right.
*/
if (input[0] == '#' && isdigit(input[1])) {
for (p = input + 2; isdigit(*p); ++p);
if (input[0] == L('#') && ISDIGIT(input[1])) {
for (p = input + 2; ISDIGIT(*p); ++p);
if (p[0] != '\0')
goto nofunc;

Expand Down
6 changes: 3 additions & 3 deletions vi/v_increment.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ v_increment(SCR *sp, VICMD *vp)
base = 10;
end = beg + 1;
ntype = fmt[SDEC];
if (!isdigit(p[end]))
if (!ISDIGIT(p[end]))
goto nonum;
} else {
decimal: base = 10;
end = beg;
ntype = fmt[DEC];
if (!isdigit(p[end])) {
if (!ISDIGIT(p[end])) {
nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
return (1);
}
Expand All @@ -152,7 +152,7 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
}
break;
case 10:
if (isdigit(p[end]))
if (ISDIGIT(p[end]))
continue;
break;
case 16:
Expand Down
2 changes: 1 addition & 1 deletion vi/v_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ nomatch: msgq(sp, M_BERR, "184|No match character on this line");
if (db_get(sp, mp->lno, DBG_FATAL, &p, &len))
return (1);
for (p += mp->cno + 1, len -= mp->cno; --len; ++p)
if (!isblank(*p))
if (!ISBLANK(*p))
return (0);
F_SET(vp, VM_LMODE);
return (0);
Expand Down
2 changes: 1 addition & 1 deletion vi/v_replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ next: if (v_event_get(sp, &ev, 0, 0))
p += vp->m_start.cno + cnt;
len -= vp->m_start.cno + cnt;
if (len != 0 && O_ISSET(sp, O_AUTOINDENT))
for (; len && isblank(*p); --len, ++p);
for (; len && ISBLANK(*p); --len, ++p);

if ((tp = text_init(sp, p, len, len)) == NULL)
goto err_ret;
Expand Down
5 changes: 3 additions & 2 deletions vi/v_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,11 @@ v_exaddr(SCR *sp, VICMD *vp, dir_t dir)

/* No blanks, just like the z command. */
for (t = cmd + 1, tlen = len - 1; tlen > 0; ++t, --tlen)
if (!isdigit(*t))
if (!ISDIGIT(*t))
break;
if (tlen &&
(*t == '-' || *t == '.' || *t == '+' || *t == '^')) {
(*t == L('-') || *t == L('.') || *t == L('+') ||
*t == L('^'))) {
++t;
--tlen;
type = 1;
Expand Down
14 changes: 7 additions & 7 deletions vi/v_sentence.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ v_sentencef(SCR *sp, VICMD *vp)
* This may not handle " . " correctly, but it's real unclear
* what correctly means in that case.
*/
if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && isblank(cs.cs_ch))) {
if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && ISBLANK(cs.cs_ch))) {
if (cs_fblank(sp, &cs))
return (1);
if (--cnt == 0) {
Expand All @@ -93,7 +93,7 @@ v_sentencef(SCR *sp, VICMD *vp)
if (cs_next(sp, &cs))
return (1);
if (cs.cs_flags == 0 &&
isblank(cs.cs_ch) && cs_fblank(sp, &cs))
ISBLANK(cs.cs_ch) && cs_fblank(sp, &cs))
return (1);
goto okret;
}
Expand Down Expand Up @@ -233,11 +233,11 @@ v_sentenceb(SCR *sp, VICMD *vp)
if (cs.cs_flags != CS_EOL)
break;
}
} else if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
} else if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch))
for (;;) {
if (cs_prev(sp, &cs))
return (1);
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
break;
}

Expand Down Expand Up @@ -280,7 +280,7 @@ ret: slno = cs.cs_lno;
} while (!cs.cs_flags &&
(cs.cs_ch == ')' || cs.cs_ch == ']' ||
cs.cs_ch == '"' || cs.cs_ch == '\''));
if ((cs.cs_flags || isblank(cs.cs_ch)) &&
if ((cs.cs_flags || ISBLANK(cs.cs_ch)) &&
cs_fblank(sp, &cs))
return (1);

Expand All @@ -303,7 +303,7 @@ ret: slno = cs.cs_lno;
return (1);
if (cs.cs_flags == CS_EOL)
continue;
if (cs.cs_flags == 0 && isblank(cs.cs_ch))
if (cs.cs_flags == 0 && ISBLANK(cs.cs_ch))
continue;
break;
}
Expand All @@ -321,7 +321,7 @@ ret: slno = cs.cs_lno;
break;
default:
last =
cs.cs_flags == CS_EOL || isblank(cs.cs_ch) ||
cs.cs_flags == CS_EOL || ISBLANK(cs.cs_ch) ||
cs.cs_ch == ')' || cs.cs_ch == ']' ||
cs.cs_ch == '"' || cs.cs_ch == '\'' ? 1 : 0;
}
Expand Down
24 changes: 12 additions & 12 deletions vi/v_txt.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,16 +749,16 @@ k_cr: if (LF_ISSET(TXT_CR)) {
owrite = tp->owrite;
insert = tp->insert;
if (LF_ISSET(TXT_REPLACE) && owrite != 0) {
for (p = tp->lb + tp->cno; owrite > 0 && isblank(*p);
for (p = tp->lb + tp->cno; owrite > 0 && ISBLANK(*p);
++p, --owrite, ++tp->R_erase);
if (owrite == 0)
for (; insert > 0 && isblank(*p);
for (; insert > 0 && ISBLANK(*p);
++p, ++tp->R_erase, --insert);
} else {
p = tp->lb + tp->cno + owrite;
if (O_ISSET(sp, O_AUTOINDENT))
for (; insert > 0 &&
isblank(*p); ++p, --insert);
ISBLANK(*p); ++p, --insert);
owrite = 0;
}

Expand Down Expand Up @@ -1291,7 +1291,7 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
goto resolve;
}
}
if (isblank(evp->e_c) && UNMAP_TST)
if (ISBLANK(evp->e_c) && UNMAP_TST)
txt_unmap(sp, tp, &ec_flags);
}
if (abb != AB_NOTSET)
Expand Down Expand Up @@ -1341,7 +1341,7 @@ insl_ch: if (txt_insch(sp, tp, &evp->e_c, flags))
if (txt_margin(sp, tp, &wmt, &tmp, flags))
goto err;
if (tmp) {
if (isblank(evp->e_c))
if (ISBLANK(evp->e_c))
wm_skip = 1;
wm_set = 1;
goto k_cr;
Expand Down Expand Up @@ -1507,7 +1507,7 @@ txt_abbrev(SCR *sp, TEXT *tp, CHAR_T *pushcp, int isinfoline, int *didsubp, int
off = tp->cno - 1; /* Previous character. */
p = tp->lb + off;
len = 1; /* One character test. */
if (off == tp->offset || isblank(p[-1]))
if (off == tp->offset || ISBLANK(p[-1]))
goto search;
if (inword(p[-1])) /* Move backward to change. */
for (;;) {
Expand All @@ -1519,7 +1519,7 @@ txt_abbrev(SCR *sp, TEXT *tp, CHAR_T *pushcp, int isinfoline, int *didsubp, int
for (;;) {
--off; --p; ++len;
if (off == tp->offset ||
inword(p[-1]) || isblank(p[-1]))
inword(p[-1]) || ISBLANK(p[-1]))
break;
}

Expand Down Expand Up @@ -1643,7 +1643,7 @@ txt_unmap(SCR *sp, TEXT *tp, u_int32_t *ec_flagsp)

/* Find the beginning of this "word". */
for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --p, --off) {
if (isblank(*p)) {
if (ISBLANK(*p)) {
++p;
break;
}
Expand Down Expand Up @@ -1710,7 +1710,7 @@ txt_ai_resolve(SCR *sp, TEXT *tp, int *changedp)

/* Figure out the last <blank> screen column. */
for (p = tp->lb, scno = 0, len = tp->len,
spaces = tab_after_sp = 0; len-- && isblank(*p); ++p)
spaces = tab_after_sp = 0; len-- && ISBLANK(*p); ++p)
if (*p == '\t') {
if (spaces)
tab_after_sp = 1;
Expand Down Expand Up @@ -1785,7 +1785,7 @@ v_txt_auto(SCR *sp, recno_t lno, TEXT *aitp, size_t len, TEXT *tp)

/* Count whitespace characters. */
for (p = t; len > 0; ++p, --len)
if (!isblank(*p))
if (!ISBLANK(*p))
break;

/* Set count, check for no indentation. */
Expand Down Expand Up @@ -2794,7 +2794,7 @@ txt_margin(SCR *sp, TEXT *tp, TEXT *wmtp, int *didbreak, u_int32_t flags)

/* Find the nearest previous blank. */
for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --off, --p, ++len) {
if (isblank(*p)) {
if (ISBLANK(*p)) {
wp = p + 1;
break;
}
Expand Down Expand Up @@ -2846,7 +2846,7 @@ txt_margin(SCR *sp, TEXT *tp, TEXT *wmtp, int *didbreak, u_int32_t flags)
* Delete any trailing whitespace from the current line.
*/
for (;; --p, --off) {
if (!isblank(*p))
if (!ISBLANK(*p))
break;
--tp->cno;
--tp->len;
Expand Down
2 changes: 1 addition & 1 deletion vi/v_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int
v_isempty(CHAR_T *p, size_t len)
{
for (; len--; ++p)
if (!isblank(*p))
if (!ISBLANK(*p))
return (0);
return (1);
}
Expand Down