summaryrefslogtreecommitdiff
path: root/lib/quotearg.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-01-01 07:02:16 +0000
committerJim Meyering <jim@meyering.net>1999-01-01 07:02:16 +0000
commitdd16dfb3e37b3af112ca1ccfbf16c096c13b84c3 (patch)
tree7d2f79b34e7edf8e1c018df3c5fe06126d4802fc /lib/quotearg.c
parent2d4f0fea3ad11fb7fcd40f003227e62d06d9605e (diff)
downloadcoreutils-dd16dfb3e37b3af112ca1ccfbf16c096c13b84c3.tar.xz
(quotearg_buffer): Cast -1 to size_t before comparing.
(quotearg_n): Change type of 1st parameter from int to unsigned int. (quotearg_n_options): Likewise. From Akim Demaille.
Diffstat (limited to 'lib/quotearg.c')
-rw-r--r--lib/quotearg.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/quotearg.c b/lib/quotearg.c
index 4f21abb1c..a0863606b 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -1,5 +1,5 @@
/* quotearg.c - quote arguments for output
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -71,7 +71,22 @@ struct quoting_options
/* Names of quoting styles. */
char const *const quoting_style_args[] =
{
- "literal", "shell", "shell-always", "c", "escape", 0
+ "literal",
+ "shell",
+ "shell-always",
+ "c",
+ "escape",
+ 0
+};
+
+/* Correspondances to quoting style names. */
+enum quoting_style const quoting_style_vals[] =
+{
+ literal_quoting_style,
+ shell_quoting_style,
+ shell_always_quoting_style,
+ c_quoting_style,
+ escape_quoting_style
};
/* The default quoting options. */
@@ -151,7 +166,7 @@ quotearg_buffer (char *buffer, size_t buffersize,
switch (quoting_style)
{
case shell_quoting_style:
- if (! (argsize == -1 ? arg[0] == '\0' : argsize == 0))
+ if (! (argsize == (size_t) -1 ? arg[0] == '\0' : argsize == 0))
{
switch (arg[0])
{
@@ -162,7 +177,7 @@ quotearg_buffer (char *buffer, size_t buffersize,
len = 0;
for (i = 0; ; i++)
{
- if (argsize == -1 ? arg[i] == '\0' : i == argsize)
+ if (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize)
goto done;
c = arg[i];
@@ -209,7 +224,7 @@ quotearg_buffer (char *buffer, size_t buffersize,
if (quote_mark)
STORE (quote_mark);
- for (i = 0; ! (argsize == -1 ? arg[i] == '\0' : i == argsize); i++)
+ for (i = 0; ! (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize); i++)
{
c = arg[i];
@@ -291,9 +306,10 @@ quotearg_buffer (char *buffer, size_t buffersize,
reused by the next call to this function with the same value of N.
N must be nonnegative. */
static char *
-quotearg_n_options (int n, char const *arg, struct quoting_options *options)
+quotearg_n_options (unsigned int n, char const *arg,
+ struct quoting_options *options)
{
- static unsigned nslots;
+ static unsigned int nslots;
static struct slotvec
{
size_t size;
@@ -328,7 +344,7 @@ quotearg_n_options (int n, char const *arg, struct quoting_options *options)
}
char *
-quotearg_n (int n, char const *arg)
+quotearg_n (unsigned int n, char const *arg)
{
return quotearg_n_options (n, arg, &default_quoting_options);
}