summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1999-06-06 21:31:01 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1999-06-06 21:31:01 +0000
commit245b958e84ea1478a8103b8c47892a6f763d68ab (patch)
tree27c47672bb0201dcfba5aa93318c58c6ff6624ba /apps
parent75bf383eb150c6ca5d8f62db82245df9d131045f (diff)
downloadATCD-245b958e84ea1478a8103b8c47892a6f763d68ab.tar.gz
.
Diffstat (limited to 'apps')
-rw-r--r--apps/gperf/ChangeLog9
-rw-r--r--apps/gperf/src/Key_List.cpp72
-rw-r--r--apps/gperf/src/Key_List.h4
-rw-r--r--apps/gperf/tests/c-parse.gperf2
-rw-r--r--apps/gperf/tests/gpc.gperf2
-rw-r--r--apps/gperf/tests/gplus.gperf2
-rw-r--r--apps/gperf/tests/irc.gperf2
-rw-r--r--apps/gperf/tests/test-1.exp2
-rw-r--r--apps/gperf/tests/test-2.exp4
-rw-r--r--apps/gperf/tests/test-3.exp2
-rw-r--r--apps/gperf/tests/test-4.exp2
-rw-r--r--apps/gperf/tests/test-5.exp2
-rw-r--r--apps/gperf/tests/test.cpp3
13 files changed, 67 insertions, 41 deletions
diff --git a/apps/gperf/ChangeLog b/apps/gperf/ChangeLog
index 63b75b166b2..1a6f84a534c 100644
--- a/apps/gperf/ChangeLog
+++ b/apps/gperf/ChangeLog
@@ -1,3 +1,12 @@
+Sun Jun 6 15:47:23 1999 Douglas C. Schmidt <schmidt@danzon.cs.wustl.edu>
+
+ * src/Key_List.cpp (output_switch): Make sure to generate "const
+ char *resword;" rather than "char *resword" since otherwise C++
+ compilers correctly complain.
+
+ * tests: Fixed a bunch of warnings related to misuses of "const
+ char *".
+
Sun Jun 6 10:30:09 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
* tests/test-4.exp: Fixed another use of "index". Thanks to David
diff --git a/apps/gperf/src/Key_List.cpp b/apps/gperf/src/Key_List.cpp
index 9bbf0607d16..a2d8e06a256 100644
--- a/apps/gperf/src/Key_List.cpp
+++ b/apps/gperf/src/Key_List.cpp
@@ -31,10 +31,10 @@ ACE_RCSID(src, Key_List, "$Id$")
#include "Hash_Table.h"
// Default type for generated code.
-char *const Key_List::default_array_type = "char *";
+const char *const Key_List::default_array_type = "char *";
// in_word_set return type, by default.
-char *const Key_List::default_return_type = "char *";
+const char *const Key_List::default_return_type = "char *";
// How wide the printed field width must be to contain the maximum
// hash value.
@@ -105,7 +105,10 @@ Key_List::special_input (char delimiter)
continue;
if (i == 0)
- return "";
+ {
+ buf[0] = '\0';
+ return buf;
+ }
else
{
buf[delimiter == '%' && buf[i - 2] == ';'
@@ -154,7 +157,7 @@ Key_List::save_include_src (void)
0);
else
return special_input ('}');
- return "";
+ return (char *) "";
}
// Determines from the input file whether the user wants to build a
@@ -211,7 +214,7 @@ Key_List::output_types (void)
}
}
else if (option[POINTER]) // Return a char *.
- return_type = Key_List::default_array_type;
+ return_type = (char *) Key_List::default_array_type;
return 0;
}
@@ -560,12 +563,12 @@ Key_List::output_switch (int use_keyword_table)
{
if (option[COMP])
comp_buffer = option[STRCASECMP]
- ? "charmap[*str] == *resword && !strncasecmp (str + 1, resword + 1, len - 1)"
- : "*str == *resword && !strncmp (str + 1, resword + 1, len - 1)";
+ ? (char *) "charmap[*str] == *resword && !strncasecmp (str + 1, resword + 1, len - 1)"
+ : (char *) "*str == *resword && !strncmp (str + 1, resword + 1, len - 1)";
else
comp_buffer = option[STRCASECMP]
- ? "charmap[*str] == *resword && !strncasecmp (str + 1, resword + 1, len - 1)"
- : "*str == *resword && !strcmp (str + 1, resword + 1)";
+ ? (char *) "charmap[*str] == *resword && !strncasecmp (str + 1, resword + 1, len - 1)"
+ : (char *) "*str == *resword && !strcmp (str + 1, resword + 1)";
}
if (!option[OPTIMIZE])
ACE_OS::printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n {\n");
@@ -603,7 +606,7 @@ Key_List::output_switch (int use_keyword_table)
int i = 0;
ACE_OS::printf (" %s%s *resword; %s\n\n",
- option[CONSTANT] ? "const " : "",
+ option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "",
pointer_and_type_enabled ? struct_tag : "char",
option[LENTABLE] && !option[DUP] ? "unsigned int key_len;" : "");
if (total_switches == 1)
@@ -746,15 +749,17 @@ Key_List::output_keylength_table (void)
const int max_column = 15;
int slot = 0;
int column = 0;
- char *indent = option[GLOBAL] ? "" : " ";
+ const char *indent = option[GLOBAL] ? "" : " ";
List_Node *temp;
if (!option[DUP] && !option[SWITCH])
{
ACE_OS::printf ("\n%sstatic %sunsigned %s lengthtable[] =\n%s%s{\n ",
- indent, option[CONSTANT] ? "const " : "",
- max_key_len <= UCHAR_MAX ? "char" : (max_key_len <= USHRT_MAX ? "short" : "long"),
- indent, indent);
+ indent,
+ option[CONSTANT] ? "const " : "",
+ max_key_len <= UCHAR_MAX ? "char" : (max_key_len <= USHRT_MAX ? "short" : "long"),
+ indent,
+ indent);
for (temp = head; temp; temp = temp->next, slot++)
{
@@ -766,7 +771,9 @@ Key_List::output_keylength_table (void)
ACE_OS::printf ("%3d,%s", temp->length, ++column % (max_column - 1 ) ? "" : "\n ");
}
- ACE_OS::printf ("\n%s%s};\n", indent, indent);
+ ACE_OS::printf ("\n%s%s};\n",
+ indent,
+ indent);
}
}
@@ -776,15 +783,16 @@ Key_List::output_keylength_table (void)
void
Key_List::output_keyword_table (void)
{
- char *l_brace = *head->rest ? "{" : "";
- char *r_brace = *head->rest ? "}," : "";
- char *indent = option[GLOBAL] ? "" : " ";
+ const char *l_brace = *head->rest ? "{" : "";
+ const char *r_brace = *head->rest ? "}," : "";
+ const char *indent = option[GLOBAL] ? "" : " ";
int slot = 0;
List_Node *temp;
+ int pointer_and_type_enabled = option[POINTER] && option[TYPE];
ACE_OS::printf ("%sstatic %s%swordlist[] =\n%s%s{\n",
indent,
- option[CONSTANT] ? "const " : "",
+ option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "",
struct_tag,
indent,
indent);
@@ -1350,7 +1358,7 @@ Key_List::output_lookup_array (void)
max = val;
}
- char *indent = option[GLOBAL] ? "" : " ";
+ const char *indent = option[GLOBAL] ? "" : " ";
ACE_OS::printf ("%sstatic %ssigned %s lookup[] =\n%s%s{\n ", indent, option[CONSTANT] ? "const " : "",
max <= SCHAR_MAX ? "char" : (max <= SHRT_MAX ? "short" : "int"),
@@ -1397,6 +1405,8 @@ Key_List::output_lookup_function (void)
if (option[DUP] && total_duplicates > 0)
{
+ int pointer_and_type_enabled = option[POINTER] && option[TYPE];
+
ACE_OS::printf (" int slot = lookup[key];\n\n"
" if (slot >= 0 && slot < MAX_HASH_VALUE)\n");
if (option[OPTIMIZE])
@@ -1404,7 +1414,7 @@ Key_List::output_lookup_function (void)
else
{
ACE_OS::printf (" {\n"
- " %schar *s = wordlist[slot]", option[CONSTANT] ? "const " : "");
+ " %schar *s = wordlist[slot]", option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "");
if (array_type_ != Key_List::default_array_type)
ACE_OS::printf (".%s", option.key_name ());
@@ -1422,8 +1432,8 @@ Key_List::output_lookup_function (void)
" %s%s*base = &wordlist[-lookup[offset]];\n"
" %s%s*ptr = base + -lookup[offset + 1];\n\n"
" while (--ptr >= base)\n ",
- option[CONSTANT] ? "const " : "", struct_tag,
- option[CONSTANT] ? "const " : "", struct_tag);
+ option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "", struct_tag,
+ option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "", struct_tag);
if (array_type_ != Key_List::default_array_type)
{
if (option[COMP])
@@ -1450,7 +1460,9 @@ Key_List::output_lookup_function (void)
ACE_OS::printf (" return %swordlist[key]", option[TYPE] && option[POINTER] ? "&" : "");
else
{
- ACE_OS::printf (" %schar *s = wordlist[key]", option[CONSTANT] ? "const " : "");
+ int pointer_and_type_enabled = option[POINTER] && option[TYPE];
+
+ ACE_OS::printf (" %schar *s = wordlist[key]", option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "");
if (array_type_ != Key_List::default_array_type)
ACE_OS::printf (".%s", option.key_name ());
@@ -1597,7 +1609,11 @@ Key_List::output (void)
if (option[INLINE])
ACE_OS::printf ("inline\n");
- ACE_OS::printf ("%s%s\n", option[CONSTANT] ? "const " : "", return_type);
+ int pointer_and_type_enabled = option[POINTER] && option[TYPE];
+
+ ACE_OS::printf ("%s%s\n",
+ option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "",
+ return_type);
if (option[CPLUSPLUS])
ACE_OS::printf ("%s::", option.class_name ());
@@ -1795,9 +1811,9 @@ Key_List::dump (void)
Key_List::Key_List (void)
: head (0),
total_duplicates (0),
- array_type_ (Key_List::default_array_type),
- return_type (Key_List::default_return_type),
- struct_tag (Key_List::default_array_type),
+ array_type_ ((char *) Key_List::default_array_type),
+ return_type ((char *) Key_List::default_return_type),
+ struct_tag ((char *) Key_List::default_array_type),
max_key_len (INT_MIN),
min_key_len (INT_MAX),
key_sort (0),
diff --git a/apps/gperf/src/Key_List.h b/apps/gperf/src/Key_List.h
index 0992f8136ec..29e559934be 100644
--- a/apps/gperf/src/Key_List.h
+++ b/apps/gperf/src/Key_List.h
@@ -154,10 +154,10 @@ private:
int total_keys;
// Total number of keys, counting duplicates.
- static char *const default_array_type;
+ static const char *const default_array_type;
// Default type for generated code.
- static char *const default_return_type;
+ static const char *const default_return_type;
// in_word_set return type, by default.
static int field_width;
diff --git a/apps/gperf/tests/c-parse.gperf b/apps/gperf/tests/c-parse.gperf
index d1b8ba6c0ea..24aa09b2ecd 100644
--- a/apps/gperf/tests/c-parse.gperf
+++ b/apps/gperf/tests/c-parse.gperf
@@ -1,7 +1,7 @@
%{
/* Command-line: gperf -p -j1 -i 1 -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
%}
-struct resword { char *name; short token; enum rid rid; };
+struct resword { const char *name; short token; enum rid rid; };
%%
__alignof, ALIGNOF, NORID
__alignof__, ALIGNOF, NORID
diff --git a/apps/gperf/tests/gpc.gperf b/apps/gperf/tests/gpc.gperf
index 8fb469e46bc..6752d028546 100644
--- a/apps/gperf/tests/gpc.gperf
+++ b/apps/gperf/tests/gpc.gperf
@@ -9,7 +9,7 @@
*
*/
%}
-struct resword { char *name; short token; short iclass;};
+struct resword { const char *name; short token; short iclass;};
%%
And, AND, PASCAL_ISO
Array, ARRAY, PASCAL_ISO
diff --git a/apps/gperf/tests/gplus.gperf b/apps/gperf/tests/gplus.gperf
index 2a2e37f9b26..91815fcc549 100644
--- a/apps/gperf/tests/gplus.gperf
+++ b/apps/gperf/tests/gplus.gperf
@@ -1,7 +1,7 @@
%{
/* Command-line: gperf -p -j1 -o -t -N is_reserved_word -k1,4,$ gplus.gperf */
%}
-struct resword { char *name; short token; enum rid rid;};
+struct resword { const char *name; short token; enum rid rid;};
%%
__alignof, ALIGNOF, NORID
__alignof__, ALIGNOF, NORID
diff --git a/apps/gperf/tests/irc.gperf b/apps/gperf/tests/irc.gperf
index afe53c59e7d..dbe40095849 100644
--- a/apps/gperf/tests/irc.gperf
+++ b/apps/gperf/tests/irc.gperf
@@ -10,7 +10,7 @@ extern int m_linreply(), m_notice(), m_lusers(), m_voice(), m_grph();
extern int m_xtra(), m_motd();
%}
struct Message {
- char *cmd;
+ const char *cmd;
int (* func)();
int count;
int parameters;
diff --git a/apps/gperf/tests/test-1.exp b/apps/gperf/tests/test-1.exp
index b2c4e4e81ce..7417f4a92f9 100644
--- a/apps/gperf/tests/test-1.exp
+++ b/apps/gperf/tests/test-1.exp
@@ -2,7 +2,7 @@
/* Command-line: ../src/gperf -p -j1 -o -t -N is_reserved_word -k1,3,$ */
/* Command-line: gperf -p -j1 -i 1 -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
#include <string.h>
-struct resword { char *name; short token; enum rid rid; };
+struct resword { const char *name; short token; enum rid rid; };
#define TOTAL_KEYWORDS 51
#define MIN_WORD_LENGTH 2
diff --git a/apps/gperf/tests/test-2.exp b/apps/gperf/tests/test-2.exp
index 8e1dbe46b7d..ee39d99f558 100644
--- a/apps/gperf/tests/test-2.exp
+++ b/apps/gperf/tests/test-2.exp
@@ -56,7 +56,7 @@ hash (str, len)
return hval;
}
-char *
+const char *
in_word_set (str, len)
char *str;
unsigned int len;
@@ -173,7 +173,7 @@ in_word_set (str, len)
if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
{
- char *s = wordlist[key];
+ const char *s = wordlist[key];
if (len == lengthtable[key]
&& *str == *s && !strcmp (str + 1, s + 1))
diff --git a/apps/gperf/tests/test-3.exp b/apps/gperf/tests/test-3.exp
index 5c99e9ed406..03f379ebc84 100644
--- a/apps/gperf/tests/test-3.exp
+++ b/apps/gperf/tests/test-3.exp
@@ -2,7 +2,7 @@
/* Command-line: ../src/gperf -p -j 1 -o -a -C -g -t -k1,4,$ */
/* Command-line: gperf -p -j1 -o -t -N is_reserved_word -k1,4,$ gplus.gperf */
#include <string.h>
-struct resword { char *name; short token; enum rid rid;};
+struct resword { const char *name; short token; enum rid rid;};
#define TOTAL_KEYWORDS 71
#define MIN_WORD_LENGTH 2
diff --git a/apps/gperf/tests/test-4.exp b/apps/gperf/tests/test-4.exp
index d554d1c6729..124abb90585 100644
--- a/apps/gperf/tests/test-4.exp
+++ b/apps/gperf/tests/test-4.exp
@@ -2,7 +2,7 @@
/* Command-line: ../src/gperf -D -p -t */
/* Command-line: gperf -p -j1 -i 1 -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
#include <string.h>
-struct resword { char *name; short token; enum rid rid; };
+struct resword { const char *name; short token; enum rid rid; };
#define TOTAL_KEYWORDS 51
#define MIN_WORD_LENGTH 2
diff --git a/apps/gperf/tests/test-5.exp b/apps/gperf/tests/test-5.exp
index 679889f90c7..21b86d7bb96 100644
--- a/apps/gperf/tests/test-5.exp
+++ b/apps/gperf/tests/test-5.exp
@@ -10,7 +10,7 @@
*
*/
#include <string.h>
-struct resword { char *name; short token; short iclass;};
+struct resword { const char *name; short token; short iclass;};
#define TOTAL_KEYWORDS 35
#define MIN_WORD_LENGTH 2
diff --git a/apps/gperf/tests/test.cpp b/apps/gperf/tests/test.cpp
index de57616492c..156b9bf922d 100644
--- a/apps/gperf/tests/test.cpp
+++ b/apps/gperf/tests/test.cpp
@@ -11,7 +11,8 @@ ACE_RCSID(tests, test, "$Id$")
static const int MAX_LEN = 80;
-char *in_word_set (const char *str, unsigned int len);
+// Lookup function.
+const char *in_word_set (const char *str, unsigned int len);
int
main (int argc, char *argv[])