@@ -76,10 +76,50 @@ typedef struct {
76
76
*/
77
77
pm_options_version_t version ;
78
78
79
+ /** A bitset of the various options that were set on the command line. */
80
+ uint8_t command_line ;
81
+
79
82
/** Whether or not the frozen string literal option has been set. */
80
83
bool frozen_string_literal ;
81
84
} pm_options_t ;
82
85
86
+ /**
87
+ * A bit representing whether or not the command line -a option was set. -a
88
+ * splits the input line $_ into $F.
89
+ */
90
+ static const uint8_t PM_OPTIONS_COMMAND_LINE_A = 0x1 ;
91
+
92
+ /**
93
+ * A bit representing whether or not the command line -e option was set. -e
94
+ * allow the user to specify a script to be executed. This is necessary for
95
+ * prism to know because certain warnings are not generated when -e is used.
96
+ */
97
+ static const uint8_t PM_OPTIONS_COMMAND_LINE_E = 0x2 ;
98
+
99
+ /**
100
+ * A bit representing whether or not the command line -l option was set. -l
101
+ * chomps the input line by default.
102
+ */
103
+ static const uint8_t PM_OPTIONS_COMMAND_LINE_L = 0x4 ;
104
+
105
+ /**
106
+ * A bit representing whether or not the command line -n option was set. -n
107
+ * wraps the script in a while gets loop.
108
+ */
109
+ static const uint8_t PM_OPTIONS_COMMAND_LINE_N = 0x8 ;
110
+
111
+ /**
112
+ * A bit representing whether or not the command line -p option was set. -p
113
+ * prints the value of $_ at the end of each loop.
114
+ */
115
+ static const uint8_t PM_OPTIONS_COMMAND_LINE_P = 0x10 ;
116
+
117
+ /**
118
+ * A bit representing whether or not the command line -x option was set. -x
119
+ * searches the input file for a shebang that matches the current Ruby engine.
120
+ */
121
+ static const uint8_t PM_OPTIONS_COMMAND_LINE_X = 0x20 ;
122
+
83
123
/**
84
124
* Set the filepath option on the given options struct.
85
125
*
@@ -112,6 +152,14 @@ PRISM_EXPORTED_FUNCTION void pm_options_encoding_set(pm_options_t *options, cons
112
152
*/
113
153
PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set (pm_options_t * options , bool frozen_string_literal );
114
154
155
+ /**
156
+ * Sets the command line option on the given options struct.
157
+ *
158
+ * @param options The options struct to set the command line option on.
159
+ * @param command_line The command_line value to set.
160
+ */
161
+ PRISM_EXPORTED_FUNCTION void pm_options_command_line_set (pm_options_t * options , uint8_t command_line );
162
+
115
163
/**
116
164
* Set the version option on the given options struct by parsing the given
117
165
* string. If the string contains an invalid option, this returns false.
@@ -186,7 +234,10 @@ PRISM_EXPORTED_FUNCTION void pm_options_free(pm_options_t *options);
186
234
* | `4` | the length the encoding |
187
235
* | ... | the encoding bytes |
188
236
* | `1` | frozen string literal |
189
- * | `1` | suppress warnings |
237
+ * | `1` | -p command line option |
238
+ * | `1` | -n command line option |
239
+ * | `1` | -l command line option |
240
+ * | `1` | -a command line option |
190
241
* | `1` | the version |
191
242
* | `4` | the number of scopes |
192
243
* | ... | the scopes |
0 commit comments