- }
- if (!$fold_pos)
- {
- /* not succeed yet so we try at spaces and = */
- for ($j=($i+$length); $j>$i; $j--)
- {
- switch ($line{$j})
- {
- case (' '):
- case ('='):
- $fold_pos = $j;
- break;
- default:
- break;
- }
- if ($fold_pos)
- {
- $j=$i;
- }
- }
- }
- if (!$fold_pos)
- {
- /* clean folding didn't work */
- $fold_pos = $i+$length;
- }
- $line = substr_replace($line,$line{$fold_pos}.$fold_string,$fold_pos,1);
- $cnt += strlen($fold_string);
- $i = $j + strlen($fold_string);
- }
- }
- return $line;
+ if (!$fold_pos) { /* not succeed yet so we try at spaces & = */
+ for ($j=($i+$length); $j>$i; $j--) {
+ switch ($line{$j}) {
+ case (' '):
+ case ('='): $fold_pos = $i = $j; break;
+ default: break;
+ }
+ }
+ }
+ if (!$fold_pos) { /* clean folding didn't work */
+ $i = $j = $fold_pos = $i+$length;
+ }
+ $line = substr_replace($line,$line{$fold_pos}.$fold_string,
+ $fold_pos,1);
+ $cnt += strlen($fold_string);
+ $i = $j + strlen($fold_string);
+ }
+ }
+ return $line;