/* Initialize the fields */
N->Value = Value;
- N->Label = GetLocalLabel ();
+ N->Label = 0;
N->Nodes = 0;
/* Return the new node */
*/
{
CaseNode* N = 0;
+ unsigned CaseLabel = GetLocalLabel (); /* Code label */
while (Depth--) {
+ int Index;
+
/* Get the key */
unsigned char Key = (Val >> (Depth * CHAR_BIT)) & 0xFF;
/* Search for the node in the collection */
- int Index;
if (SearchCaseNode (Nodes, Key, &Index) == 0) {
/* Node not found - insert one */
CollInsert (Nodes, N, Index);
/* If this is not the last round, create the collection for
- * the subnodes.
+ * the subnodes, otherwise get a label for the code.
*/
if (Depth > 0) {
- N->Nodes = NewCollection ();
+ N->Nodes = NewCollection ();
+ } else {
+ N->Label = CaseLabel;
}
} else {
* duplicate case label in a switch.
*/
if (Depth == 0) {
- Error ("Duplicate case label");
+ Error ("Duplicate case label");
}
}
}
/* Return the label of the node we found/created */
- return N->Label;
+ return CaseLabel;
}