Skip to content

Commit 65c3419

Browse files
author
Franklin Pierce Johnston
committed
Renamed SYS error to ERR, and changed format of message (TECO-32 compatibility).
1 parent e208126 commit 65c3419

File tree

22 files changed

+56
-48
lines changed

22 files changed

+56
-48
lines changed

etc/errors.pl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,15 @@ sub make_errcodes_h
173173
{
174174
my $message = $errors{$code}{message};
175175

176-
$message =~ s/%s/foo/gmsx;
176+
if ($code eq 'ERR')
177+
{
178+
$message =~ s/%s/(error message)/gmsx;
179+
}
180+
else
181+
{
182+
$message =~ s/%s/foo/gmsx;
183+
}
184+
177185
$message =~ s/%c/x/gmsx;
178186

179187
$errcodes .= sprintf " E_%s, ///< %s\n", $code, $message;

etc/errors.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@
8282
<detail>An O command found a duplicate tag within the</detail>
8383
<detail>command string.</detail>
8484
</error>
85+
<error>
86+
<code>ERR</code>
87+
<message>%s</message>
88+
<detail>A system call failed. The error message text</detail>
89+
<detail>explains the error.</detail>
90+
</error>
8591
<error>
8692
<code>EXT</code>
8793
<message>Extended feature not enabled</message>
@@ -431,12 +437,6 @@
431437
<detail>search it is usually necessary to close</detail>
432438
<detail>the output file and reopen it.</detail>
433439
</error>
434-
<error>
435-
<code>SYS</code>
436-
<message>System error: &apos;%s&apos;</message>
437-
<detail>A system call failed. The error message</detail>
438-
<detail>text explains the error.</detail>
439-
</error>
440440
<error>
441441
<code>TAG</code>
442442
<message>Missing tag: &apos;!%s!&apos;</message>

include/errcodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ enum errcodes
5151
E_DPY, ///< Display mode error
5252
E_DTB, ///< Delete too big
5353
E_DUP, ///< Duplicate tag '!foo!'
54+
E_ERR, ///< (error message)
5455
E_EXT, ///< Extended feature not enabled
5556
E_FIL, ///< Invalid file 'foo'
5657
E_FNF, ///< File not found 'foo'
@@ -103,7 +104,6 @@ enum errcodes
103104
E_POP, ///< Attempt to move pointer off page with 'x'
104105
E_SNI, ///< Semi-colon not in iteration
105106
E_SRH, ///< Search failure: 'foo'
106-
E_SYS, ///< System error: 'foo'
107107
E_TAG, ///< Missing tag: '!foo!'
108108
E_TXT, ///< Invalid text delimiter 'x'
109109
E_UTC, ///< Unterminated command string

include/errtables.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static struct errlist errlist[] =
5555
[E_DPY] = { "DPY", "Display mode error" },
5656
[E_DTB] = { "DTB", "Delete too big" },
5757
[E_DUP] = { "DUP", "Duplicate tag '!%s!'" },
58+
[E_ERR] = { "ERR", "%s" },
5859
[E_EXT] = { "EXT", "Extended feature not enabled" },
5960
[E_FIL] = { "FIL", "Invalid file '%s'" },
6061
[E_FNF] = { "FNF", "File not found '%s'" },
@@ -107,7 +108,6 @@ static struct errlist errlist[] =
107108
[E_POP] = { "POP", "Attempt to move pointer off page with '%s'" },
108109
[E_SNI] = { "SNI", "Semi-colon not in iteration" },
109110
[E_SRH] = { "SRH", "Search failure: '%s'" },
110-
[E_SYS] = { "SYS", "System error: '%s'" },
111111
[E_TAG] = { "TAG", "Missing tag: '!%s!'" },
112112
[E_TXT] = { "TXT", "Invalid text delimiter '%s'" },
113113
[E_UTC] = { "UTC", "Unterminated command string" },
@@ -152,6 +152,8 @@ static const char *errhelp[] =
152152
"the current page.",
153153
[E_DUP] = "An O command found a duplicate tag within the "
154154
"command string.",
155+
[E_ERR] = "A system call failed. The error message text "
156+
"explains the error.",
155157
[E_EXT] = "A command attempted to use an extended feature "
156158
"which is not currently enabled.",
157159
[E_FIL] = "An attempt was made to open a directory, FIFO, "
@@ -293,8 +295,6 @@ static const char *errhelp[] =
293295
"buffer is cleared. In the case of an N "
294296
"search it is usually necessary to close "
295297
"the output file and reopen it.",
296-
[E_SYS] = "A system call failed. The error message "
297-
"text explains the error.",
298298
[E_TAG] = "The tag specified by an O command cannot "
299299
"be found. This tag must be in the same macro "
300300
"level as the O command referencing it.",

src/e_pct_cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void exec_E_pct(struct cmd *cmd)
7676

7777
if (fwrite(qreg->text.data, 1uL, size, ofile->fp) != size)
7878
{
79-
throw(E_SYS, ofile->name); // Unexpected system error
79+
throw(E_ERR, ofile->name); // General error
8080
}
8181
}
8282

src/ek_cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ void exec_EK(struct cmd *unused)
5757
{
5858
if (remove(ofile->temp) != 0)
5959
{
60-
throw(E_SYS, ofile->temp);
60+
throw(E_ERR, ofile->temp);
6161
}
6262
}
6363
else if (ofile->name != NULL)
6464
{
6565
if (remove(ofile->name) != 0)
6666
{
67-
throw(E_SYS, ofile->name);
67+
throw(E_ERR, ofile->name);
6868
}
6969
}
7070

src/errors.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static void print_error(int error, const char *err_str, const char *file_str)
211211
tprint(" ");
212212
tprint(text, err_str ?: "");
213213

214-
if (error == E_SYS && file_str != NULL)
214+
if (error == E_ERR && file_str != NULL)
215215
{
216216
tprint(" for '%s'", file_str);
217217
}
@@ -313,7 +313,7 @@ void print_verbose(int error)
313313
/// character, it is output as [xx]; if it is a control character,
314314
/// it is output as ^x.
315315
///
316-
/// 3. The E_SYS error code, which includes a string that contains
316+
/// 3. The E_ERR error code, which includes a string that contains
317317
/// the name of a file (or which is NULL) that is appended after
318318
/// the error message.
319319
///
@@ -357,7 +357,7 @@ noreturn void throw(int error, ...)
357357

358358
break;
359359

360-
case E_SYS:
360+
case E_ERR:
361361
err_str = strerror(errno); // Convert errno to string
362362
file_str = va_arg(args, const char *);
363363

src/ez_cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void exec_EZ(struct cmd *cmd)
8484
return;
8585
}
8686

87-
throw(E_SYS, syscmd); // Unexpected system error
87+
throw(E_ERR, syscmd); // General error
8888
}
8989

9090
ez.len = EZ_SIZE;
@@ -112,7 +112,7 @@ void exec_EZ(struct cmd *cmd)
112112
return;
113113
}
114114

115-
throw(E_SYS, syscmd); // Unexpected system error
115+
throw(E_ERR, syscmd); // General error
116116
}
117117

118118
ez.len = pos; // Length = total bytes read

src/file.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ bool open_command(const char *name, uint stream, bool colon, tbuffer *text)
303303
{
304304
close_input(stream);
305305

306-
throw(E_SYS, last_file); // Unexpected system error
306+
throw(E_ERR, last_file); // General error
307307
}
308308

309309
size_t size = (size_t)file_stat.st_size;
@@ -318,7 +318,7 @@ bool open_command(const char *name, uint stream, bool colon, tbuffer *text)
318318
{
319319
close_input(stream);
320320

321-
throw(E_SYS, ifile->name); // Unexpected system error
321+
throw(E_ERR, ifile->name); // General error
322322
}
323323

324324
text->pos = 0;
@@ -381,7 +381,7 @@ struct ifile *open_input(const char *name, uint stream, bool colon)
381381
{
382382
errno = EPERM;
383383

384-
throw(E_SYS, name); // System error
384+
throw(E_ERR, name); // General error
385385
}
386386

387387
struct ifile *ifile = &ifiles[stream];
@@ -390,7 +390,7 @@ struct ifile *open_input(const char *name, uint stream, bool colon)
390390

391391
if ((ifile->fp = fopen(name, "r")) == NULL)
392392
{
393-
throw(E_SYS, name); // Unexpected system error
393+
throw(E_ERR, name); // General error
394394
}
395395

396396
ifile->size = (uint_t)file_stat.st_size;
@@ -441,7 +441,7 @@ struct ofile *open_output(const char *name, uint stream, bool colon, int c)
441441
}
442442
else if (access(name, W_OK) != 0) // File exists - is it writeable?
443443
{
444-
throw(E_SYS, name); // Unexpected system error
444+
throw(E_ERR, name); // General error
445445
}
446446
else
447447
{
@@ -467,7 +467,7 @@ struct ofile *open_output(const char *name, uint stream, bool colon, int c)
467467
return NULL;
468468
}
469469

470-
throw(E_SYS, name); // Unexpected system error
470+
throw(E_ERR, name); // General error
471471
}
472472

473473
// Here when we've either just opened a new file that didn't previously

src/file_sys.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ int get_wild(void)
187187
{
188188
next_file = NULL; // Make sure we can't repeat this
189189

190-
throw(E_SYS, filename);// Unexpected system error
190+
throw(E_ERR, filename); // General error
191191
}
192192

193193
if (S_ISREG(file_stat.st_mode))
@@ -234,7 +234,7 @@ FILE *open_temp(const char *oname, uint stream)
234234

235235
if (stat(oname, &statbuf) != 0)
236236
{
237-
throw(E_SYS, oname); // Unexpected system error
237+
throw(E_ERR, oname); // General error
238238
}
239239

240240
char dir[strlen(oname) + 1];
@@ -248,7 +248,7 @@ FILE *open_temp(const char *oname, uint stream)
248248

249249
if (fd == -1)
250250
{
251-
throw(E_SYS, tempfile); // Unexpected system error
251+
throw(E_ERR, tempfile); // General error
252252
}
253253

254254
(void)fchmod(fd, statbuf.st_mode); // Use same permissions as old file
@@ -390,19 +390,19 @@ void rename_output(struct ofile *ofile)
390390

391391
if (rename(ofile->name, saved_name) != 0)
392392
{
393-
throw(E_SYS, ofile->name); // Unexpected system error
393+
throw(E_ERR, ofile->name); // General error
394394
}
395395
}
396396
else if (remove(ofile->name) != 0)
397397
{
398-
throw(E_SYS, ofile->name); // Unexpected system error
398+
throw(E_ERR, ofile->name); // General error
399399
}
400400

401401
// Rename temp. file name to actual name
402402

403403
if (rename(ofile->temp, ofile->name) != 0)
404404
{
405-
throw(E_SYS, ofile->name); // Unexpected system error
405+
throw(E_ERR, ofile->name); // General error
406406
}
407407
}
408408

@@ -442,7 +442,7 @@ bool set_wild(const char *filename)
442442
return false; // No matches
443443

444444
default: // Something unexpected
445-
throw(E_SYS, filename);// Unexpected system error
445+
throw(E_ERR, filename);// General error
446446
}
447447
}
448448

0 commit comments

Comments
 (0)