| 880 | /* The actual loop */ |
| 881 | |
| 882 | static uint replace_strings(REPLACE *rep, char **start, uint *max_length, |
| 883 | char *from) |
| 884 | { |
| 885 | reg1 REPLACE *rep_pos; |
| 886 | reg2 REPLACE_STRING *rep_str; |
| 887 | char *to, *end, *pos, *new; |
| 888 | |
| 889 | end=(to= *start) + *max_length-1; |
| 890 | rep_pos=rep+1; |
| 891 | for(;;) |
| 892 | { |
| 893 | while (!rep_pos->found) |
| 894 | { |
| 895 | rep_pos= rep_pos->next[(uchar) *from]; |
| 896 | if (to == end) |
| 897 | { |
| 898 | (*max_length)+=8192; |
| 899 | if (!(new=my_realloc(*start,*max_length,MYF(MY_WME)))) |
| 900 | return (uint) -1; |
| 901 | to=new+(to - *start); |
| 902 | end=(*start=new)+ *max_length-1; |
| 903 | } |
| 904 | *to++= *from++; |
| 905 | } |
| 906 | if (!(rep_str = ((REPLACE_STRING*) rep_pos))->replace_string) |
| 907 | return (uint) (to - *start)-1; |
| 908 | updated=1; /* Some char * is replaced */ |
| 909 | to-=rep_str->to_offset; |
| 910 | for (pos=rep_str->replace_string; *pos ; pos++) |
| 911 | { |
| 912 | if (to == end) |
| 913 | { |
| 914 | (*max_length)*=2; |
| 915 | if (!(new=my_realloc(*start,*max_length,MYF(MY_WME)))) |
| 916 | return (uint) -1; |
| 917 | to=new+(to - *start); |
| 918 | end=(*start=new)+ *max_length-1; |
| 919 | } |
| 920 | *to++= *pos; |
| 921 | } |
| 922 | if (!*(from-=rep_str->from_offset) && rep_pos->found != 2) |
| 923 | return (uint) (to - *start); |
| 924 | rep_pos=rep; |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | static char *buffer; /* The buffer itself, grown as needed. */ |
| 929 | static int bufbytes; /* Number of bytes in the buffer. */ |
no test coverage detected