dfa.c (228072) | dfa.c (250125) |
---|---|
1/* dfa - DFA construction routines */ 2 3/* Copyright (c) 1990 The Regents of the University of California. */ 4/* All rights reserved. */ 5 6/* This code is derived from software contributed to Berkeley by */ 7/* Vern Paxson. */ 8 --- 147 unchanged lines hidden (view full) --- 156 157 if (j > num_associated_rules) { /* new rule */ 158 if (num_associated_rules < MAX_ASSOC_RULES) 159 rule_set[++num_associated_rules] = 160 rule_num; 161 } 162 } 163 | 1/* dfa - DFA construction routines */ 2 3/* Copyright (c) 1990 The Regents of the University of California. */ 4/* All rights reserved. */ 5 6/* This code is derived from software contributed to Berkeley by */ 7/* Vern Paxson. */ 8 --- 147 unchanged lines hidden (view full) --- 156 157 if (j > num_associated_rules) { /* new rule */ 158 if (num_associated_rules < MAX_ASSOC_RULES) 159 rule_set[++num_associated_rules] = 160 rule_num; 161 } 162 } 163 |
164 bubble (rule_set, num_associated_rules); | 164 qsort (&rule_set [1], num_associated_rules, sizeof (rule_set [1]), intcmp); |
165 166 fprintf (file, _(" associated rule line numbers:")); 167 168 for (i = 1; i <= num_associated_rules; ++i) { 169 if (i % 8 == 1) 170 putc ('\n', file); 171 172 fprintf (file, "\t%d", rule_set[i]); --- 657 unchanged lines hidden (view full) --- 830 for (i = 1; i <= lastdfa; ++i) 831 if (hashval == dhash[i]) { 832 if (numstates == dfasiz[i]) { 833 oldsns = dss[i]; 834 835 if (!didsort) { 836 /* We sort the states in sns so we 837 * can compare it to oldsns quickly. | 165 166 fprintf (file, _(" associated rule line numbers:")); 167 168 for (i = 1; i <= num_associated_rules; ++i) { 169 if (i % 8 == 1) 170 putc ('\n', file); 171 172 fprintf (file, "\t%d", rule_set[i]); --- 657 unchanged lines hidden (view full) --- 830 for (i = 1; i <= lastdfa; ++i) 831 if (hashval == dhash[i]) { 832 if (numstates == dfasiz[i]) { 833 oldsns = dss[i]; 834 835 if (!didsort) { 836 /* We sort the states in sns so we 837 * can compare it to oldsns quickly. |
838 * We use bubble because there probably 839 * aren't very many states. | |
840 */ | 838 */ |
841 bubble (sns, numstates); | 839 qsort (&sns [1], numstates, sizeof (sns [1]), intcmp); |
842 didsort = 1; 843 } 844 845 for (j = 1; j <= numstates; ++j) 846 if (sns[j] != oldsns[j]) 847 break; 848 849 if (j > numstates) { --- 18 unchanged lines hidden (view full) --- 868 869 dss[newds] = allocate_integer_array (numstates + 1); 870 871 /* If we haven't already sorted the states in sns, we do so now, 872 * so that future comparisons with it can be made quickly. 873 */ 874 875 if (!didsort) | 840 didsort = 1; 841 } 842 843 for (j = 1; j <= numstates; ++j) 844 if (sns[j] != oldsns[j]) 845 break; 846 847 if (j > numstates) { --- 18 unchanged lines hidden (view full) --- 866 867 dss[newds] = allocate_integer_array (numstates + 1); 868 869 /* If we haven't already sorted the states in sns, we do so now, 870 * so that future comparisons with it can be made quickly. 871 */ 872 873 if (!didsort) |
876 bubble (sns, numstates); | 874 qsort (&sns [1], numstates, sizeof (sns [1]), intcmp); |
877 878 for (i = 1; i <= numstates; ++i) 879 dss[newds][i] = sns[i]; 880 881 dfasiz[newds] = numstates; 882 dhash[newds] = hashval; 883 884 if (nacc == 0) { 885 if (reject) 886 dfaacc[newds].dfaacc_set = (int *) 0; 887 else 888 dfaacc[newds].dfaacc_state = 0; 889 890 accsiz[newds] = 0; 891 } 892 893 else if (reject) { 894 /* We sort the accepting set in increasing order so the 895 * disambiguating rule that the first rule listed is considered | 875 876 for (i = 1; i <= numstates; ++i) 877 dss[newds][i] = sns[i]; 878 879 dfasiz[newds] = numstates; 880 dhash[newds] = hashval; 881 882 if (nacc == 0) { 883 if (reject) 884 dfaacc[newds].dfaacc_set = (int *) 0; 885 else 886 dfaacc[newds].dfaacc_state = 0; 887 888 accsiz[newds] = 0; 889 } 890 891 else if (reject) { 892 /* We sort the accepting set in increasing order so the 893 * disambiguating rule that the first rule listed is considered |
896 * match in the event of ties will work. We use a bubble 897 * sort since the list is probably quite small. | 894 * match in the event of ties will work. |
898 */ 899 | 895 */ 896 |
900 bubble (accset, nacc); | 897 qsort (&accset [1], nacc, sizeof (accset [1]), intcmp); |
901 902 dfaacc[newds].dfaacc_set = 903 allocate_integer_array (nacc + 1); 904 905 /* Save the accepting set for later */ 906 for (i = 1; i <= nacc; ++i) { 907 dfaacc[newds].dfaacc_set[i] = accset[i]; 908 --- 191 unchanged lines hidden --- | 898 899 dfaacc[newds].dfaacc_set = 900 allocate_integer_array (nacc + 1); 901 902 /* Save the accepting set for later */ 903 for (i = 1; i <= nacc; ++i) { 904 dfaacc[newds].dfaacc_set[i] = accset[i]; 905 --- 191 unchanged lines hidden --- |