changeset 1597:287550eb5c15

(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.
author Jim Meyering <jim@meyering.net>
date Fri, 01 Jan 1999 07:02:16 +0000
parents ca73757a0183
children d0dff44eca51
files lib/quotearg.c
diffstat 1 files changed, 24 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 /* 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 @@
   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 @@
 	      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 @@
   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 @@
    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 @@
 }
 
 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);
 }