]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-bz645773-case-insensitive-2of5.patch
- up to 7.3.1
[packages/gdb.git] / gdb-bz645773-case-insensitive-2of5.patch
1 http://sourceware.org/ml/gdb-patches/2011-04/msg00124.html
2 Subject: [patch 1/3] case insensitive: Reformat code
3
4 Hi,
5
6 just some reformatting to make the later patch more clear.  There should be no
7 functionality difference by this patch.  c1+c2 are a bit ugly but I found any
8 other solution a bit ugly.
9
10
11 Thanks,
12 Jan
13
14
15 gdb/
16 2011-04-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
17
18         Format the code for the next patch.
19         * dwarf2read.c (struct mapped_index): Include delimiting newlines.
20         * utils.c (strcmp_iw_ordered): Reformat the code for the next patch.
21         New variables c1 and c2.
22
23 --- a/gdb/dwarf2read.c
24 +++ b/gdb/dwarf2read.c
25 @@ -150,14 +150,19 @@ struct mapped_index
26  {
27    /* The total length of the buffer.  */
28    off_t total_size;
29 +
30    /* A pointer to the address table data.  */
31    const gdb_byte *address_table;
32 +
33    /* Size of the address table data in bytes.  */
34    offset_type address_table_size;
35 +
36    /* The symbol table, implemented as a hash table.  */
37    const offset_type *symbol_table;
38 +
39    /* Size in slots, each slot is 2 offset_types.  */
40    offset_type symbol_table_slots;
41 +
42    /* A pointer to the constant pool.  */
43    const char *constant_pool;
44  };
45 --- a/gdb/utils.c
46 +++ b/gdb/utils.c
47 @@ -3023,48 +3023,55 @@ strcmp_iw (const char *string1, const char *string2)
48  int
49  strcmp_iw_ordered (const char *string1, const char *string2)
50  {
51 -  while ((*string1 != '\0') && (*string2 != '\0'))
52 +  /* Formatting stub.  */
53 +  if (1)
54      {
55 -      while (isspace (*string1))
56 -       {
57 -         string1++;
58 -       }
59 -      while (isspace (*string2))
60 -       {
61 -         string2++;
62 -       }
63 -      if (*string1 != *string2)
64 +      /* C1 and C2 are valid only if *string1 != '\0' && *string2 != '\0'.
65 +        Provide stub characters if we are already at the end of one of the
66 +        strings.  */
67 +      char c1 = 'X', c2 = 'X';
68 +
69 +      while (*string1 != '\0' && *string2 != '\0')
70         {
71 -         break;
72 +         while (isspace (*string1))
73 +           string1++;
74 +         while (isspace (*string2))
75 +           string2++;
76 +
77 +             c1 = *string1;
78 +             c2 = *string2;
79 +         if (c1 != c2)
80 +           break;
81 +
82 +         if (*string1 != '\0')
83 +           {
84 +             string1++;
85 +             string2++;
86 +           }
87         }
88 -      if (*string1 != '\0')
89 +
90 +      switch (*string1)
91         {
92 -         string1++;
93 -         string2++;
94 +         /* Characters are non-equal unless they're both '\0'; we want to
95 +            make sure we get the comparison right according to our
96 +            comparison in the cases where one of them is '\0' or '('.  */
97 +       case '\0':
98 +         if (*string2 == '\0')
99 +           return 0;
100 +         else
101 +           return -1;
102 +       case '(':
103 +         if (*string2 == '\0')
104 +           return 1;
105 +         else
106 +           return -1;
107 +       default:
108 +         if (*string2 == '\0' || *string2 == '(')
109 +           return 1;
110 +         else
111 +           return c1 - c2;
112         }
113      }
114 -
115 -  switch (*string1)
116 -    {
117 -      /* Characters are non-equal unless they're both '\0'; we want to
118 -        make sure we get the comparison right according to our
119 -        comparison in the cases where one of them is '\0' or '('.  */
120 -    case '\0':
121 -      if (*string2 == '\0')
122 -       return 0;
123 -      else
124 -       return -1;
125 -    case '(':
126 -      if (*string2 == '\0')
127 -       return 1;
128 -      else
129 -       return -1;
130 -    default:
131 -      if (*string2 == '(')
132 -       return 1;
133 -      else
134 -       return *string1 - *string2;
135 -    }
136  }
137  
138  /* A simple comparison function with opposite semantics to strcmp.  */
139
This page took 0.063642 seconds and 3 git commands to generate.