Introduction
Introduction Statistics Contact Development Disclaimer Help
error.c - 9base - revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log
Files
Refs
README
LICENSE
---
error.c (2226B)
---
1 #include "sam.h"
2
3 static char *emsg[]={
4 /* error_s */
5 "can't open",
6 "can't create",
7 "not in menu:",
8 "changes to",
9 "I/O error:",
10 "can't write while changing:",
11 /* error_c */
12 "unknown command",
13 "no operand for",
14 "bad delimiter",
15 /* error */
16 "can't fork",
17 "interrupt",
18 "address",
19 "search",
20 "pattern",
21 "newline expected",
22 "blank expected",
23 "pattern expected",
24 "can't nest X or Y",
25 "unmatched `}'",
26 "command takes no address",
27 "addresses overlap",
28 "substitution",
29 "& match too long",
30 "bad \\ in rhs",
31 "address range",
32 "changes not in sequence",
33 "addresses out of order",
34 "no file name",
35 "unmatched `('",
36 "unmatched `)'",
37 "malformed `[]'",
38 "malformed regexp",
39 "reg. exp. list overflow",
40 "plan 9 command",
41 "can't pipe",
42 "no current file",
43 "string too long",
44 "changed files",
45 "empty string",
46 "file search",
47 "non-unique match for \"\"",
48 "tag match too long",
49 "too many subexpressions",
50 "temporary file too large",
51 "file is append-only",
52 "no destination for plumb message",
53 "internal read error in buffer load"
54 };
55 static char *wmsg[]={
56 /* warn_s */
57 "duplicate file name",
58 "no such file",
59 "write might change good version of",
60 /* warn_S */
61 "files might be aliased",
62 /* warn */
63 "null characters elided",
64 "can't run pwd",
65 "last char not newline",
66 "exit status not 0"
67 };
68
69 void
70 error(Err s)
71 {
72 char buf[512];
73
74 sprint(buf, "?%s", emsg[s]);
75 hiccough(buf);
76 }
77
78 void
79 error_s(Err s, char *a)
80 {
81 char buf[512];
82
83 sprint(buf, "?%s \"%s\"", emsg[s], a);
84 hiccough(buf);
85 }
86
87 void
88 error_r(Err s, char *a)
89 {
90 char buf[512];
91
92 sprint(buf, "?%s \"%s\": %r", emsg[s], a);
93 hiccough(buf);
94 }
95
96 void
97 error_c(Err s, int c)
98 {
99 char buf[512];
100
101 sprint(buf, "?%s `%C'", emsg[s], c);
102 hiccough(buf);
103 }
104
105 void
106 warn(Warn s)
107 {
108 dprint("?warning: %s\n", wmsg[s]);
109 }
110
111 void
112 warn_S(Warn s, String *a)
113 {
114 print_s(wmsg[s], a);
115 }
116
117 void
118 warn_SS(Warn s, String *a, String *b)
119 {
120 print_ss(wmsg[s], a, b);
121 }
122
123 void
124 warn_s(Warn s, char *a)
125 {
126 dprint("?warning: %s `%s'\n", wmsg[s], a);
127 }
128
129 void
130 termwrite(char *s)
131 {
132 String *p;
133
134 if(downloaded){
135 p = tmpcstr(s);
136 if(cmd)
137 loginsert(cmd, cmdpt, p->s, p->n);
138 else
139 Strinsert(&cmdstr, p, cmdstr.n);
140 cmdptadv += p->n;
141 free(p);
142 }else
143 Write(2, s, strlen(s));
144 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.