File tree 1 file changed +17
-5
lines changed
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 45
45
#include "reb-c.h"
46
46
#include "reb-args.h"
47
47
48
- #define ARG_BUF_SIZE 1024
49
-
50
48
extern int OS_Get_Current_Dir (REBCHR * * lp );
51
49
52
50
// REBOL Option --Words:
@@ -201,14 +199,16 @@ const struct arg_chr arg_chars2[] = {
201
199
**
202
200
***********************************************************************/
203
201
{
202
+ int arg_buf_size = 128 ;
203
+
204
204
REBCHR * arg ;
205
205
REBCHR * args = 0 ; // holds trailing args
206
206
int flag ;
207
207
int i ;
208
208
209
209
CLEARS (rargs );
210
210
211
- // First arg is path to execuable (on most systems):
211
+ // First arg is path to executable (on most systems):
212
212
if (argc > 0 ) rargs -> exe_path = * argv ;
213
213
214
214
OS_Get_Current_Dir (& rargs -> home_dir );
@@ -262,11 +262,23 @@ const struct arg_chr arg_chars2[] = {
262
262
rargs -> script = arg ;
263
263
else {
264
264
int len ;
265
+ int size ;
266
+ REBCHR * tmp ;
265
267
if (!args ) {
266
- args = MAKE_STR (ARG_BUF_SIZE );
268
+ args = MAKE_STR (arg_buf_size );
267
269
args [0 ] = 0 ;
268
270
}
269
- len = ARG_BUF_SIZE - LEN_STR (args ) - 2 ; // space remaining
271
+ len = LEN_STR (arg ) + LEN_STR (args ) + 2 ;
272
+ size = arg_buf_size ;
273
+ while (size < len ) size *= 2 ;
274
+ if (size > arg_buf_size ) {
275
+ tmp = args ;
276
+ args = MAKE_STR (size );
277
+ memcpy (args , tmp , arg_buf_size );
278
+ arg_buf_size = size ;
279
+ free (tmp );
280
+ }
281
+ len = arg_buf_size - LEN_STR (args ) - 2 ; // space remaining
270
282
JOIN_STR (args , arg , len );
271
283
JOIN_STR (args , TXT (" " ), 1 );
272
284
}
You can’t perform that action at this time.
0 commit comments