@@ -115,24 +115,24 @@ void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
115
115
break ;
116
116
}
117
117
}
118
-
118
+
119
119
} /* }}} */
120
120
121
121
static inline phpdbg_input_t * * phpdbg_read_argv (char * buffer , int * argc TSRMLS_DC ) /* {{{ */
122
122
{
123
- char * p , * s ;
123
+ char * p ;
124
124
char b [PHPDBG_MAX_CMD ];
125
125
int l = 0 ;
126
126
enum states {
127
127
IN_BETWEEN ,
128
- IN_WORD ,
129
- IN_STRING
128
+ IN_WORD ,
129
+ IN_STRING
130
130
} state = IN_BETWEEN ;
131
131
phpdbg_input_t * * argv = NULL ;
132
-
132
+
133
133
argv = (phpdbg_input_t * * ) emalloc (sizeof (phpdbg_input_t * * ));
134
134
(* argc ) = 0 ;
135
-
135
+
136
136
#define RESET_STATE () do {\
137
137
phpdbg_input_t *arg = emalloc(sizeof(phpdbg_input_t));\
138
138
if (arg) {\
@@ -157,11 +157,9 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_D
157
157
}
158
158
if (c == '"' ) {
159
159
state = IN_STRING ;
160
- s = p + 1 ;
161
160
continue ;
162
161
}
163
162
state = IN_WORD ;
164
- s = p ;
165
163
b [l ++ ]= c ;
166
164
continue ;
167
165
@@ -186,39 +184,39 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_D
186
184
continue ;
187
185
}
188
186
}
189
-
187
+
190
188
switch (state ) {
191
189
case IN_WORD : {
192
190
RESET_STATE ();
193
191
} break ;
194
-
192
+
195
193
case IN_STRING :
196
194
phpdbg_error (
197
- "Malformed command line (unclosed quote) @ %d: %s!" ,
195
+ "Malformed command line (unclosed quote) @ %d: %s!" ,
198
196
(p - buffer )- 1 , & buffer [(p - buffer )- 1 ]);
199
197
break ;
200
198
}
201
-
199
+
202
200
if ((* argc ) == 0 ) {
203
201
/* not needed */
204
202
efree (argv );
205
-
203
+
206
204
/* to be sure */
207
205
return NULL ;
208
206
}
209
-
207
+
210
208
return argv ;
211
209
} /* }}} */
212
210
213
- phpdbg_input_t * phpdbg_read_input (TSRMLS_D ) /* {{{ */
211
+ phpdbg_input_t * phpdbg_read_input (TSRMLS_D ) /* {{{ */
214
212
{
215
213
if (!(PHPDBG_G (flags ) & PHPDBG_IS_QUITTING )) {
216
214
phpdbg_input_t * buffer = NULL ;
217
215
size_t cmd_len = 0L ;
218
216
219
217
#ifndef HAVE_LIBREADLINE
220
218
char * cmd = NULL ;
221
- char buf [PHPDBG_MAX_CMD ];
219
+ char buf [PHPDBG_MAX_CMD ];
222
220
if (!phpdbg_write (PROMPT ) ||
223
221
!fgets (buf , PHPDBG_MAX_CMD , stdin )) {
224
222
/* the user has gone away */
@@ -227,7 +225,7 @@ phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */
227
225
zend_bailout ();
228
226
return NULL ;
229
227
}
230
-
228
+
231
229
cmd = buf ;
232
230
#else
233
231
char * cmd = readline (PROMPT );
@@ -249,7 +247,7 @@ phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */
249
247
while (* cmd && isspace (cmd [cmd_len - 1 ]))
250
248
cmd_len -- ;
251
249
cmd [cmd_len ] = '\0' ;
252
-
250
+
253
251
/* allocate and sanitize buffer */
254
252
buffer = (phpdbg_input_t * ) emalloc (sizeof (phpdbg_input_t ));
255
253
if (buffer ) {
@@ -261,24 +259,24 @@ phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */
261
259
buffer -> string [buffer -> length ] = '\0' ;
262
260
/* store constant pointer to start of buffer */
263
261
buffer -> start = (char * const * ) buffer -> string ;
264
- {
265
- /* temporary, when we switch to argv/argc handling
262
+ {
263
+ /* temporary, when we switch to argv/argc handling
266
264
will be unnecessary */
267
265
char * store = (char * ) estrdup (buffer -> string );
268
-
266
+
269
267
buffer -> argv = phpdbg_read_argv (
270
268
store , & buffer -> argc TSRMLS_CC );
271
-
269
+
272
270
if (buffer -> argc ) {
273
271
int arg = 0 ;
274
-
272
+
275
273
while (arg < buffer -> argc ) {
276
274
phpdbg_debug (
277
275
"argv %d=%s" , arg , buffer -> argv [arg ]-> string );
278
276
arg ++ ;
279
277
}
280
278
}
281
-
279
+
282
280
efree (store );
283
281
}
284
282
}
@@ -292,18 +290,18 @@ phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */
292
290
293
291
return buffer ;
294
292
}
295
-
293
+
296
294
return NULL ;
297
295
} /* }}} */
298
296
299
297
void phpdbg_destroy_input (phpdbg_input_t * * input TSRMLS_DC ) /*{{{ */
300
298
{
301
299
if (* input ) {
302
-
300
+
303
301
if ((* input )-> string ) {
304
302
efree ((* input )-> string );
305
303
}
306
-
304
+
307
305
if ((* input )-> argc > 0 ) {
308
306
int arg ;
309
307
for (arg = 0 ; arg < (* input )-> argc ; arg ++ ) {
@@ -315,7 +313,7 @@ void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
315
313
if ((* input )-> argv ) {
316
314
efree ((* input )-> argv );
317
315
}
318
-
316
+
319
317
efree (* input );
320
318
}
321
319
} /* }}} */
@@ -326,29 +324,29 @@ int phpdbg_do_cmd_ex(const phpdbg_command_t *command, phpdbg_input_t *input TSRM
326
324
327
325
if (input -> argc > 0 ) {
328
326
while (command && command -> name && command -> handler ) {
329
- if (((command -> name_len == input -> argv [0 ]-> length ) &&
327
+ if (((command -> name_len == input -> argv [0 ]-> length ) &&
330
328
(memcmp (command -> name , input -> argv [0 ]-> string , command -> name_len ) == SUCCESS )) ||
331
329
(command -> alias &&
332
- (input -> argv [0 ]-> length == 1 ) &&
330
+ (input -> argv [0 ]-> length == 1 ) &&
333
331
(command -> alias == * input -> argv [0 ]-> string ))) {
334
332
if (command -> subs && input -> argc > 1 ) {
335
333
phpdbg_input_t sub ;
336
-
334
+
337
335
sub .argc = input -> argc - 1 ;
338
336
sub .argv = & input -> argv [1 ];
339
-
337
+
340
338
return phpdbg_do_cmd_ex (command -> subs , & sub TSRMLS_CC );
341
339
}
342
-
340
+
343
341
phpdbg_debug (
344
- "found command %s for %s with %d arguments" ,
342
+ "found command %s for %s with %d arguments" ,
345
343
command -> name , input -> argv [0 ]-> string , input -> argc - 1 );
346
344
{
347
345
int arg ;
348
346
for (arg = 1 ; arg < input -> argc ; arg ++ ) {
349
347
phpdbg_debug (
350
- "\t#%d: [%s=%d]" ,
351
- arg ,
348
+ "\t#%d: [%s=%d]" ,
349
+ arg ,
352
350
input -> argv [arg ]-> string ,
353
351
input -> argv [arg ]-> length );
354
352
}
@@ -362,7 +360,7 @@ int phpdbg_do_cmd_ex(const phpdbg_command_t *command, phpdbg_input_t *input TSRM
362
360
phpdbg_error (
363
361
"No function executed !!" );
364
362
}
365
-
363
+
366
364
return rc ;
367
365
} /* }}} */
368
366
@@ -385,7 +383,7 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_le
385
383
expr ,
386
384
(cmd_len - expr_len ) ? (((cmd_len - expr_len ) - sizeof (" " ))+ 1 ) : 0 ,
387
385
& param TSRMLS_CC );
388
-
386
+
389
387
if (command -> subs && param .type == STR_PARAM ) {
390
388
if (phpdbg_do_cmd (command -> subs , param .str , param .len TSRMLS_CC ) == SUCCESS ) {
391
389
rc = SUCCESS ;
0 commit comments