History

switch: fix label sorting

Pavlas, Zdenek committed 10 years ago

Commit da636951 parent c2ad11a2 files · +9 −2Browse files

Unified · Split

2 files
  1. tccgen.c +6 −2
  2. tests/tcctest.c +3 −0
tccgen.c+6−2
@@ -4881,8 +4881,12 @@ static void label_or_decl(int l) · 4880 unmodified lines
48814881 decl(l);
48824882 }
48834883
4884−static int case_cmp(const void *a, const void *b)
4885−{ return (*(struct case_t**) a)->v1 - (*(struct case_t**) b)->v1; }
4884+static int case_cmp(const void *pa, const void *pb)
4885+{
4886+ int a = (*(struct case_t**) pa)->v1;
4887+ int b = (*(struct case_t**) pb)->v1;
4888+ return a < b ? -1 : a > b;
4889+}
48864890
48874891 static void block(int *bsym, int *csym, int is_expr)
48884892 {
tests/tcctest.c+3−0
@@ -1554,6 +1554,9 @@ void switch_test() · 1553 unmodified lines
15541554 case 3:
15551555 printf("b");
15561556 break;
1557+ case 0xc33c6b9fU:
1558+ case 0x7c9eeeb9U:
1559+ break;
15571560 }
15581561 }
15591562 printf("\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t