Remove building with NOCRYPTO option
[minix.git] / external / bsd / nvi / dist / vi / v_util.c
blobb1c2a4bcf48278210a99db0ed325f38af634d349
1 /* $NetBSD: v_util.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
2 /*-
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
9 */
11 #include "config.h"
13 #include <sys/cdefs.h>
14 #if 0
15 #ifndef lint
16 static const char sccsid[] = "Id: v_util.c,v 10.14 2001/06/25 15:19:36 skimo Exp (Berkeley) Date: 2001/06/25 15:19:36 ";
17 #endif /* not lint */
18 #else
19 __RCSID("$NetBSD: v_util.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
20 #endif
22 #include <sys/types.h>
23 #include <sys/queue.h>
24 #include <sys/time.h>
26 #include <bitstring.h>
27 #include <ctype.h>
28 #include <limits.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
34 #include "../common/common.h"
35 #include "vi.h"
38 * v_eof --
39 * Vi end-of-file error.
41 * PUBLIC: void v_eof __P((SCR *, MARK *));
43 void
44 v_eof(SCR *sp, MARK *mp)
46 db_recno_t lno;
48 if (mp == NULL)
49 v_emsg(sp, NULL, VIM_EOF);
50 else {
51 if (db_last(sp, &lno))
52 return;
53 if (mp->lno >= lno)
54 v_emsg(sp, NULL, VIM_EOF);
55 else
56 msgq(sp, M_BERR, "195|Movement past the end-of-file");
61 * v_eol --
62 * Vi end-of-line error.
64 * PUBLIC: void v_eol __P((SCR *, MARK *));
66 void
67 v_eol(SCR *sp, MARK *mp)
69 size_t len;
71 if (mp == NULL)
72 v_emsg(sp, NULL, VIM_EOL);
73 else {
74 if (db_get(sp, mp->lno, DBG_FATAL, NULL, &len))
75 return;
76 if (mp->cno == len - 1)
77 v_emsg(sp, NULL, VIM_EOL);
78 else
79 msgq(sp, M_BERR, "196|Movement past the end-of-line");
84 * v_nomove --
85 * Vi no cursor movement error.
87 * PUBLIC: void v_nomove __P((SCR *));
89 void
90 v_nomove(SCR *sp)
92 msgq(sp, M_BERR, "197|No cursor movement made");
96 * v_sof --
97 * Vi start-of-file error.
99 * PUBLIC: void v_sof __P((SCR *, MARK *));
101 void
102 v_sof(SCR *sp, MARK *mp)
104 if (mp == NULL || mp->lno == 1)
105 msgq(sp, M_BERR, "198|Already at the beginning of the file");
106 else
107 msgq(sp, M_BERR, "199|Movement past the beginning of the file");
111 * v_sol --
112 * Vi start-of-line error.
114 * PUBLIC: void v_sol __P((SCR *));
116 void
117 v_sol(SCR *sp)
119 msgq(sp, M_BERR, "200|Already in the first column");
123 * v_isempty --
124 * Return if the line contains nothing but white-space characters.
126 * PUBLIC: int v_isempty __P((CHAR_T *, size_t));
129 v_isempty(CHAR_T *p, size_t len)
131 for (; len--; ++p)
132 if (!ISBLANK((UCHAR_T)*p))
133 return (0);
134 return (1);
138 * v_emsg --
139 * Display a few common vi messages.
141 * PUBLIC: void v_emsg __P((SCR *, const char *, vim_t));
143 void
144 v_emsg(SCR *sp, const char *p, vim_t which)
146 switch (which) {
147 case VIM_COMBUF:
148 msgq(sp, M_ERR,
149 "201|Buffers should be specified before the command");
150 break;
151 case VIM_EMPTY:
152 msgq(sp, M_BERR, "209|The file is empty");
153 break;
154 case VIM_EOF:
155 msgq(sp, M_BERR, "202|Already at end-of-file");
156 break;
157 case VIM_EOL:
158 msgq(sp, M_BERR, "203|Already at end-of-line");
159 break;
160 case VIM_NOCOM:
161 case VIM_NOCOM_B:
162 msgq(sp,
163 which == VIM_NOCOM_B ? M_BERR : M_ERR,
164 "204|%s isn't a vi command", p);
165 break;
166 case VIM_WRESIZE:
167 msgq(sp, M_ERR, "Window resize interrupted text input mode");
168 break;
169 case VIM_USAGE:
170 msgq(sp, M_ERR, "205|Usage: %s", p);
171 break;