File tree 1 file changed +12
-8
lines changed
1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ const struct arg_chr arg_chars2[] = {
199
199
**
200
200
***********************************************************************/
201
201
{
202
- int arg_buf_size = 1024 ;
202
+ int arg_buf_size = 128 ;
203
203
204
204
REBCHR * arg ;
205
205
REBCHR * args = 0 ; // holds trailing args
@@ -208,7 +208,7 @@ const struct arg_chr arg_chars2[] = {
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 );
@@ -261,20 +261,24 @@ const struct arg_chr arg_chars2[] = {
261
261
if (!rargs -> script )
262
262
rargs -> script = arg ;
263
263
else {
264
- int len ; REBCHR * tmp ;
264
+ int len ;
265
+ int size ;
266
+ REBCHR * tmp ;
265
267
if (!args ) {
266
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
270
- while (len < 0 ) {
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 ) {
271
275
tmp = args ;
272
- args = MAKE_STR (2 * arg_buf_size );
276
+ args = MAKE_STR (size );
273
277
memcpy (args , tmp , arg_buf_size );
274
- arg_buf_size *= 2 ;
278
+ arg_buf_size = size ;
275
279
free (tmp );
276
- len = arg_buf_size - LEN_STR (args ) - 2 ;
277
280
}
281
+ len = arg_buf_size - LEN_STR (args ) - 2 ; // space remaining
278
282
JOIN_STR (args , arg , len );
279
283
JOIN_STR (args , TXT (" " ), 1 );
280
284
}
You can’t perform that action at this time.
0 commit comments