Merge branch 'issue-316'
This commit is contained in:
		
						commit
						03e1ef1753
					
				|  | @ -519,17 +519,22 @@ static pic_value | |||
| pic_str_string_copy(pic_state *pic) | ||||
| { | ||||
|   pic_str *str; | ||||
|   int n, start, end; | ||||
|   int n, start, end, len; | ||||
| 
 | ||||
|   n = pic_get_args(pic, "s|ii", &str, &start, &end); | ||||
| 
 | ||||
|   len = pic_str_len(str); | ||||
| 
 | ||||
|   switch (n) { | ||||
|   case 1: | ||||
|     start = 0; | ||||
|   case 2: | ||||
|     end = pic_str_len(str); | ||||
|     end = len; | ||||
|   } | ||||
| 
 | ||||
|   if (start < 0 || end > len || end < start) | ||||
|     pic_errorf(pic, "string-copy: invalid index"); | ||||
| 
 | ||||
|   return pic_obj_value(pic_str_sub(pic, str, start, end)); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Yuichi Nishiwaki
						Yuichi Nishiwaki