fix xr_put
This commit is contained in:
		
							parent
							
								
									4501b9bd93
								
							
						
					
					
						commit
						3ee807a347
					
				
							
								
								
									
										13
									
								
								src/string.c
								
								
								
								
							
							
						
						
									
										13
									
								
								src/string.c
								
								
								
								
							|  | @ -74,28 +74,29 @@ pic_str_ref(pic_state *pic, pic_str *str, size_t i) | |||
| static xrope * | ||||
| xr_put(xrope *rope, size_t i, char c) | ||||
| { | ||||
|   xrope *x, *y; | ||||
|   char buf[1]; | ||||
|   xrope *x, *y, *z; | ||||
|   char buf[2]; | ||||
| 
 | ||||
|   if (xr_len(rope) <= i) { | ||||
|     return NULL; | ||||
|   } | ||||
| 
 | ||||
|   buf[0] = c; | ||||
|   buf[1] = '\0'; | ||||
| 
 | ||||
|   x = xr_sub(rope, 0, i); | ||||
|   y = xr_new_copy(buf, 1); | ||||
|   rope = xr_cat(x, y); | ||||
|   z = xr_cat(x, y); | ||||
|   XROPE_DECREF(x); | ||||
|   XROPE_DECREF(y); | ||||
| 
 | ||||
|   x = rope; | ||||
|   x = z; | ||||
|   y = xr_sub(rope, i + 1, xr_len(rope)); | ||||
|   rope = xr_cat(x, y); | ||||
|   z = xr_cat(z, y); | ||||
|   XROPE_DECREF(x); | ||||
|   XROPE_DECREF(y); | ||||
| 
 | ||||
|   return rope; | ||||
|   return z; | ||||
| } | ||||
| 
 | ||||
| void | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Yuichi Nishiwaki
						Yuichi Nishiwaki