bheadp = bp;
bp->b_dotline = bp->b_markline = 1;
bp->b_lines = 1;
+ bp->b_nlseq = "\n"; /* use unix default */
+ bp->b_nlchr = bp->b_nlseq;
if ((bp->b_bname = strdup(bname)) == NULL) {
dobeep();
ewprintf("Can't get %d bytes", strlen(bname) + 1);
ttext += llength(lp);
}
if (lforw(lp) != lpend) /* no implied \n on last line */
- *ttext++ = '\n';
+ *ttext++ = *curbp->b_nlchr;
}
bp = bfind("*Diff*", TRUE);
-/* $OpenBSD: cscope.c,v 1.19 2021/02/28 15:30:35 lum Exp $ */
+/* $OpenBSD: cscope.c,v 1.20 2021/03/01 10:51:14 lum Exp $ */
/*
* This file is in the public domain.
addline(bp, title);
addline(bp, "");
while ((len = getline(&line, &sz, fpipe)) != -1) {
- if (line[len - 1] == '\n')
+ if (line[len - 1] == *bp->b_nlchr)
line[len - 1] = '\0';
addline(bp, line);
}
addline(bp, "");
addline(bp, "-------------------------------------------------------------------------------");
while ((len = getline(&buf, &sz, fpipe)) != -1) {
- if (buf[len - 1] == '\n')
+ if (buf[len - 1] == *bp->b_nlchr)
buf[len - 1] = '\0';
if (addentry(bp, buf) != TRUE) {
free(buf);
-/* $OpenBSD: def.h,v 1.167 2021/02/23 08:10:51 lum Exp $ */
+/* $OpenBSD: def.h,v 1.168 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
char b_flag; /* Flags */
char b_fname[NFILEN]; /* File name */
char b_cwd[NFILEN]; /* working directory */
+ char *b_nlseq; /* Newline sequence of chars */
+ char *b_nlchr; /* 1st newline character */
struct fileinfo b_fi; /* File attributes */
struct undoq b_undo; /* Undo actions list */
struct undo_rec *b_undoptr;
-/* $OpenBSD: dired.c,v 1.96 2021/02/26 07:21:23 lum Exp $ */
+/* $OpenBSD: dired.c,v 1.97 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
if ((fin = fdopen(fds[0], "r")) == NULL)
goto out;
while (fgets(buf, sizeof(buf), fin) != NULL) {
- cp = strrchr(buf, '\n');
+ cp = strrchr(buf, *bp->b_nlchr);
if (cp == NULL && !feof(fin)) { /* too long a line */
int c;
addlinef(bp, "%*s%s...", space, "", buf);
- while ((c = getc(fin)) != EOF && c != '\n')
+ while ((c = getc(fin)) != EOF &&
+ c != *bp->b_nlchr)
;
continue;
} else if (cp)
-/* $OpenBSD: echo.c,v 1.66 2016/10/24 17:18:42 jasper Exp $ */
+/* $OpenBSD: echo.c,v 1.67 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
break;
case CCHR('Y'): /* yank from kill buffer */
i = 0;
- while ((y = kremove(i++)) >= 0 && y != '\n') {
+ while ((y = kremove(i++)) >= 0 && y != *curbp->b_nlchr) {
int t;
if (dynbuf && epos + 1 >= nbuf) {
void *newp;
-/* $OpenBSD: extend.c,v 1.71 2019/07/18 15:52:11 lum Exp $ */
+/* $OpenBSD: extend.c,v 1.72 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
/*
if (inmacro) {
while (--n >= 0) {
for (count = 0; count < maclcur->l_used; count++) {
- if ((((c = maclcur->l_text[count]) == '\n')
+ if ((((c = maclcur->l_text[count]) ==
+ *curbp->b_nlchr)
? lnewline() : linsert(1, c)) != TRUE)
return (FALSE);
}
while (--n >= 0) {
cp = buf;
while (*cp) {
- if (((*cp == '\n') ? lnewline() : linsert(1, *cp))
+ if (((*cp == *curbp->b_nlchr) ?
+ lnewline() : linsert(1, *cp))
!= TRUE)
return (FALSE);
cp++;
break;
case 'n':
case 'N':
- key.k_chars[i] = '\n';
+ key.k_chars[i] = *curbp->b_nlchr;
break;
case 'r':
case 'R':
-/* $OpenBSD: fileio.c,v 1.107 2021/02/23 08:10:51 lum Exp $ */
+/* $OpenBSD: fileio.c,v 1.108 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
return (FIOERR);
}
if (lforw(lp) != lpend) /* no implied \n on last line */
- putc('\n', ffp);
+ putc(*bp->b_nlchr, ffp);
}
if (eobnl) {
lnewline_at(lback(lpend), llength(lback(lpend)));
- putc('\n', ffp);
+ putc(*bp->b_nlchr, ffp);
}
return (FIOSUC);
}
int c, i;
i = 0;
- while ((c = getc(ffp)) != EOF && c != '\n') {
+ while ((c = getc(ffp)) != EOF && c != *curbp->b_nlchr) {
buf[i++] = c;
if (i >= nbuf)
return (FIOLONG);
-/* $OpenBSD: grep.c,v 1.48 2019/07/11 18:20:18 lum Exp $ */
+/* $OpenBSD: grep.c,v 1.49 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain */
return (NULL);
}
while ((len = getline(&buf, &sz, fpipe)) != -1) {
- if (buf[len - 1] == '\n')
+ if (buf[len - 1] == *bp->b_nlchr)
buf[len - 1] = '\0';
addline(bp, buf);
}
-/* $OpenBSD: kbd.c,v 1.34 2020/02/09 10:13:13 florian Exp $ */
+/* $OpenBSD: kbd.c,v 1.35 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
}
thisflag |= CFINS;
}
- if (c == '\n') {
+ if (c == *curbp->b_nlchr) {
do {
count = lnewline();
} while (--n && count == TRUE);
-/* $OpenBSD: line.c,v 1.62 2020/07/22 13:22:53 tb Exp $ */
+/* $OpenBSD: line.c,v 1.63 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
lchange(WFFULL);
if (ldelnewline() == FALSE)
goto out;
- end = strlcat(sv, "\n", len + 1);
+ end = strlcat(sv, curbp->b_nlchr, len + 1);
--n;
continue;
}
-/* $OpenBSD: match.c,v 1.21 2019/07/02 16:25:39 lum Exp $ */
+/* $OpenBSD: match.c,v 1.22 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
cbo = llength(clp) + 1;
}
if (--cbo == llength(clp))
- c = '\n'; /* end of line */
+ c = *curbp->b_nlchr; /* end of line */
else
c = lgetc(clp, cbo); /* somewhere in middle */
-/* $OpenBSD: region.c,v 1.38 2019/06/17 11:39:26 lum Exp $ */
+/* $OpenBSD: region.c,v 1.39 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
while (region.r_size--) {
if (loffs == llength(linep)) { /* End of line. */
- if ((s = kinsert('\n', KFORW)) != TRUE)
+ if ((s = kinsert(*curbp->b_nlchr, KFORW)) != TRUE)
return (s);
linep = lforw(linep);
loffs = 0;
if (lp == curbp->b_headp)
break;
off = 0;
- buf[i] = '\n';
+ buf[i] = *curbp->b_nlchr;
} else {
buf[i] = lgetc(lp, off);
off++;
int i;
for (i = 0; buf[i] != '\0' && i < len; i++) {
- if (buf[i] == '\n')
+ if (buf[i] == *curbp->b_nlchr)
lnewline();
else
linsert(1, buf[i]);
buf[len] = '\0';
p = q = buf;
- if (leftover[0] != '\0' && ((q = strchr(p, '\n')) != NULL)) {
+ if (leftover[0] != '\0' && ((q = strchr(p, *bp->b_nlchr)) != NULL)) {
*q++ = '\0';
if (strlcat(leftover, p, sizeof(leftover)) >=
sizeof(leftover)) {
leftover[0] = '\0';
p = q;
}
- while ((q = strchr(p, '\n')) != NULL) {
+ while ((q = strchr(p, *bp->b_nlchr)) != NULL) {
*q++ = '\0';
addline(bp, p);
p = q;
-/* $OpenBSD: tty.c,v 1.37 2020/02/09 10:13:13 florian Exp $ */
+/* $OpenBSD: tty.c,v 1.38 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
static int cci;
static int insdel; /* Do we have both insert & delete line? */
-static const char *scroll_fwd; /* How to scroll forward. */
+static char *scroll_fwd; /* How to scroll forward. */
static void winchhandler(int);
/* this is what GNU Emacs does */
scroll_fwd = parm_down_cursor;
if (scroll_fwd == NULL || *scroll_fwd == '\0')
- scroll_fwd = "\n";
+ scroll_fwd = curbp->b_nlchr;
}
if (cursor_address == NULL || cursor_up == NULL)
-/* $OpenBSD: ttyio.c,v 1.38 2019/06/28 13:35:02 deraadt Exp $ */
+/* $OpenBSD: ttyio.c,v 1.39 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
ttclose();
(void) fputs("panic: ", stderr);
(void) fputs(s, stderr);
- (void) fputc('\n', stderr);
+ (void) fputc('\n', stderr); /* Use '\n' as no buffers now. */
exit(1);
}
-/* $OpenBSD: util.c,v 1.42 2019/06/22 15:38:15 lum Exp $ */
+/* $OpenBSD: util.c,v 1.43 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
cchar = nchar + curwp->w_doto;
if (curwp->w_doto == llength(clp))
/* fake a \n at end of line */
- cbyte = '\n';
+ cbyte = *curbp->b_nlchr;
else
cbyte = lgetc(clp, curwp->w_doto);
}
nchar += llength(clp);
clp = lforw(clp);
if (clp == curbp->b_headp) {
- if (cbyte == '\n' && cline == curbp->b_lines) {
+ if (cbyte == *curbp->b_nlchr &&
+ cline == curbp->b_lines) {
/* swap faked \n for EOB msg */
cbyte = EOF;
msg = "(EOB)";
-/* $OpenBSD: yank.c,v 1.14 2015/12/11 20:21:23 mmcc Exp $ */
+/* $OpenBSD: yank.c,v 1.15 2021/03/01 10:51:14 lum Exp $ */
/* This file is in the public domain. */
isetmark();
i = 0;
while ((c = kremove(i)) >= 0) {
- if (c == '\n') {
+ if (c == *curbp->b_nlchr) {
if (enewline(FFRAND, 1) == FALSE)
return (FALSE);
++nline;