aboutsummaryrefslogtreecommitdiffstats
path: root/src/tr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tr.c')
-rw-r--r--src/tr.c68
1 files changed, 29 insertions, 39 deletions
diff --git a/src/tr.c b/src/tr.c
index db669a7d4..af47021dc 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -24,8 +24,6 @@
#include "system.h"
#include "assure.h"
-#include "die.h"
-#include "error.h"
#include "fadvise.h"
#include "quote.h"
#include "safe-read.h"
@@ -1198,8 +1196,8 @@ validate_case_classes (struct Spec_list *s1, struct Spec_list *s2)
c1 must also transition at the same time. */
if (s2_new_element && class_s2 != UL_NONE
&& !(s1_new_element && class_s1 != UL_NONE))
- die (EXIT_FAILURE, 0,
- _("misaligned [:upper:] and/or [:lower:] construct"));
+ error (EXIT_FAILURE, 0,
+ _("misaligned [:upper:] and/or [:lower:] construct"));
/* If case converting, quickly skip over the elements. */
if (class_s2 != UL_NONE)
@@ -1303,7 +1301,7 @@ get_spec_stats (struct Spec_list *s)
indefinite element. */
new_length = length + len;
if (! (length <= new_length && new_length <= REPEAT_COUNT_MAXIMUM))
- die (EXIT_FAILURE, 0, _("too many characters in set"));
+ error (EXIT_FAILURE, 0, _("too many characters in set"));
length = new_length;
}
@@ -1386,9 +1384,9 @@ string2_extend (const struct Spec_list *s1, struct Spec_list *s2)
tr '[:upper:]0-9' '[:lower:]'
That's not portable however, contradicts POSIX and is dependent
on your collating sequence. */
- die (EXIT_FAILURE, 0,
- _("when translating with string1 longer than string2,\nthe\
- latter string must not end with a character class"));
+ error (EXIT_FAILURE, 0,
+ _("when translating with string1 longer than string2,\n"
+ "the latter string must not end with a character class"));
case RE_REPEATED_CHAR:
char_to_repeat = p->u.repeated_char.the_repeated_char;
@@ -1441,36 +1439,29 @@ validate (struct Spec_list *s1, struct Spec_list *s2)
{
get_s1_spec_stats (s1);
if (s1->n_indefinite_repeats > 0)
- {
- die (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("the [c*] repeat construct may not appear in string1"));
- }
if (s2)
{
get_s2_spec_stats (s2, s1->length);
if (s2->n_indefinite_repeats > 1)
- {
- die (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("only one [c*] repeat construct may appear in string2"));
- }
if (translating)
{
if (s2->has_equiv_class)
- {
- die (EXIT_FAILURE, 0,
- _("[=c=] expressions may not appear in string2\
- when translating"));
- }
+ error (EXIT_FAILURE, 0,
+ _("[=c=] expressions may not appear in string2"
+ " when translating"));
if (s2->has_restricted_char_class)
- {
- die (EXIT_FAILURE, 0,
- _("when translating, the only character classes that may\
- appear in\nstring2 are 'upper' and 'lower'"));
- }
+ error (EXIT_FAILURE, 0,
+ _("when translating, the only character classes"
+ " that may appear in\n"
+ "string2 are 'upper' and 'lower'"));
validate_case_classes (s1, s2);
@@ -1482,27 +1473,26 @@ validate (struct Spec_list *s1, struct Spec_list *s2)
given or string1 is empty. */
if (s2->length == 0)
- die (EXIT_FAILURE, 0,
- _("when not truncating set1, string2 must be non-empty"));
+ error (EXIT_FAILURE, 0,
+ _("when not truncating set1,"
+ " string2 must be non-empty"));
string2_extend (s1, s2);
}
}
if (complement && s1->has_char_class
&& ! (s2->length == s1->length && homogeneous_spec_list (s2)))
- {
- die (EXIT_FAILURE, 0,
- _("when translating with complemented character classes,\
-\nstring2 must map all characters in the domain to one"));
- }
+ error (EXIT_FAILURE, 0,
+ _("when translating with complemented character classes,\n"
+ "string2 must map all characters in the domain to one"));
}
else
/* Not translating. */
{
if (s2->n_indefinite_repeats > 0)
- die (EXIT_FAILURE, 0,
- _("the [c*] construct may appear in string2 only\
- when translating"));
+ error (EXIT_FAILURE, 0,
+ _("the [c*] construct may appear in string2"
+ " only when translating"));
}
}
}
@@ -1581,7 +1571,7 @@ squeeze_filter (char *buf, size_t size, size_t (*reader) (char *, size_t))
}
if (out_len > 0
&& fwrite (&buf[begin], 1, out_len, stdout) != out_len)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
if (char_to_squeeze != NOT_A_CHAR)
@@ -1605,7 +1595,7 @@ plain_read (char *buf, size_t size)
{
size_t nr = safe_read (STDIN_FILENO, buf, size);
if (nr == SAFE_READ_ERROR)
- die (EXIT_FAILURE, errno, _("read error"));
+ error (EXIT_FAILURE, errno, _("read error"));
return nr;
}
@@ -1807,7 +1797,7 @@ main (int argc, char **argv)
if (nr == 0)
break;
if (fwrite (io_buf, 1, nr, stdout) != nr)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
}
else if (squeeze_repeats && delete && non_option_args == 2)
@@ -1899,13 +1889,13 @@ main (int argc, char **argv)
if (bytes_read == 0)
break;
if (fwrite (io_buf, 1, bytes_read, stdout) != bytes_read)
- die (EXIT_FAILURE, errno, _("write error"));
+ error (EXIT_FAILURE, errno, _("write error"));
}
}
}
if (close (STDIN_FILENO) != 0)
- die (EXIT_FAILURE, errno, _("standard input"));
+ error (EXIT_FAILURE, errno, _("standard input"));
main_exit (EXIT_SUCCESS);
}