1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

Don't divide by zero (empty files)

While there, also increase buf[]

OK claudio@
This commit is contained in:
job 2024-04-25 09:58:17 +00:00
parent 64bdd17f81
commit 39e743a585

View File

@ -1,4 +1,4 @@
/* $OpenBSD: vs_refresh.c,v 1.24 2024/04/24 15:15:40 job Exp $ */
/* $OpenBSD: vs_refresh.c,v 1.25 2024/04/25 09:58:17 job Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -781,7 +781,7 @@ vs_modeline(SCR *sp)
size_t cols, curcol, curlen, endpoint, len, midpoint;
const char *t = NULL;
int ellipsis;
char *p, buf[20];
char *p, buf[30];
recno_t last;
/*
@ -859,7 +859,7 @@ vs_modeline(SCR *sp)
if (O_ISSET(sp, O_RULER)) {
vs_column(sp, &curcol);
if (db_last(sp, &last))
if (db_last(sp, &last) || last == 0)
len = snprintf(buf, sizeof(buf), "%lu,%zu",
(ulong)sp->lno, curcol + 1);
else