/[bison]/bison/src/uniqstr.c
ViewVC logotype

Diff of /bison/src/uniqstr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by eggert, Fri Dec 13 08:47:15 2002 UTC revision 1.3 by eggert, Mon Feb 3 15:35:57 2003 UTC
# Line 1  Line 1 
1  /* Keep a unique copy of strings.  /* Keep a unique copy of strings.
2    
3     Copyright (C) 2002 Free Software Foundation, Inc.     Copyright (C) 2002, 2003 Free Software Foundation, Inc.
4    
5     This file is part of Bison, the GNU Compiler Compiler.     This file is part of Bison, the GNU Compiler Compiler.
6    
# Line 41  static struct hash_table *uniqstrs_table Line 41  static struct hash_table *uniqstrs_table
41  `-------------------------------------*/  `-------------------------------------*/
42    
43  uniqstr  uniqstr
44  uniqstr_new (char const *s)  uniqstr_new (char const *str)
45  {  {
46    uniqstr res = hash_lookup (uniqstrs_table, s);    uniqstr res = hash_lookup (uniqstrs_table, str);
47    if (!res)    if (!res)
48      {      {
49        /* First insertion in the hash. */        /* First insertion in the hash. */
50        res = xstrdup (s);        res = xstrdup (str);
51        hash_insert (uniqstrs_table, res);        hash_insert (uniqstrs_table, res);
52      }      }
53    return res;    return res;
# Line 59  uniqstr_new (char const *s) Line 59  uniqstr_new (char const *s)
59  `------------------------------*/  `------------------------------*/
60    
61  void  void
62  uniqstr_assert (char const *s)  uniqstr_assert (char const *str)
63  {  {
64    if (!hash_lookup (uniqstrs_table, s))    if (!hash_lookup (uniqstrs_table, str))
65      {      {
66        error (0, 0, "not a uniqstr: %s", quotearg (s));        error (0, 0, "not a uniqstr: %s", quotearg (str));
67        abort ();        abort ();
68      }      }
69  }  }
# Line 74  uniqstr_assert (char const *s) Line 74  uniqstr_assert (char const *s)
74  `--------------------*/  `--------------------*/
75    
76  static inline bool  static inline bool
77  uniqstr_print (uniqstr s)  uniqstr_print (uniqstr ustr)
78  {  {
79    fprintf (stderr, "%s\n", s);    fprintf (stderr, "%s\n", ustr);
80    return true;    return true;
81  }  }
82    
83  static bool  static bool
84  uniqstr_print_processor (void *s, void *null ATTRIBUTE_UNUSED)  uniqstr_print_processor (void *ustr, void *null ATTRIBUTE_UNUSED)
85  {  {
86    return uniqstr_print (s);    return uniqstr_print (ustr);
87  }  }
88    
89    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26