forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5e3c30f
Teach in-tree getopt_long() to move non-options to the end of argv.
Unlike the other implementations of getopt_long() I could find, thein-tree implementation does not reorder non-options to the end ofargv. Instead, it returns -1 as soon as the first non-option isfound, even if there are other options listed afterwards. Bymoving non-options to the end of argv, getopt_long() can parse allspecified options and return -1 when only non-options remain.This quirk is periodically missed by hackers (e.g.,869aa40,ffd3980, andd9ddc50). This commit introduces theaforementioned non-option reordering behavior to the in-treegetopt_long() implementation.Special thanks to Noah Misch for his help verifying behavior onAIX.Reviewed-by: Kyotaro Horiguchi, Michael PaquierDiscussion:https://postgr.es/m/20230609232257.GA121461%40nathanxps131 parent8dc2a54 commit5e3c30f
2 files changed
+44
-19
lines changedLines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
46 |
| - | |
47 |
| - | |
| 45 | + | |
| 46 | + | |
48 | 47 |
| |
49 | 48 |
| |
50 | 49 |
| |
| |||
73 | 72 |
| |
74 | 73 |
| |
75 | 74 |
| |
76 |
| - | |
| 75 | + | |
77 | 76 |
| |
78 | 77 |
| |
79 | 78 |
| |
80 | 79 |
| |
81 | 80 |
| |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 |
| |
83 | 85 |
|
Lines changed: 38 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
53 |
| - | |
54 |
| - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
55 | 58 |
| |
56 | 59 |
| |
57 | 60 |
| |
| |||
60 | 63 |
| |
61 | 64 |
| |
62 | 65 |
| |
| 66 | + | |
| 67 | + | |
63 | 68 |
| |
64 | 69 |
| |
65 | 70 |
| |
66 |
| - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
67 | 79 |
| |
68 | 80 |
| |
| 81 | + | |
| 82 | + | |
69 | 83 |
| |
70 | 84 |
| |
71 | 85 |
| |
72 | 86 |
| |
73 | 87 |
| |
74 |
| - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
75 | 97 |
| |
76 |
| - | |
77 |
| - | |
78 |
| - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
79 | 101 |
| |
80 |
| - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
81 | 106 |
| |
82 |
| - | |
83 |
| - | |
84 |
| - | |
85 |
| - | |
86 |
| - | |
| 107 | + | |
87 | 108 |
| |
88 | 109 |
| |
| 110 | + | |
| 111 | + | |
89 | 112 |
| |
90 | 113 |
| |
91 | 114 |
| |
92 | 115 |
| |
93 |
| - | |
94 |
| - | |
| 116 | + | |
| 117 | + | |
95 | 118 |
| |
96 | 119 |
| |
97 | 120 |
| |
|
0 commit comments
Comments
(0)