php_eol instead of \n

This commit is contained in:
nadrad 2022-09-20 20:49:23 +02:00
parent fa07f5f819
commit e4ef78bbf9

22
h-m-m
View file

@ -40,7 +40,7 @@ for ( $i = 1 ; $i < $alen ; $i++ )
} }
elseif (isset($mm['arguments']['filename'])) elseif (isset($mm['arguments']['filename']))
{ {
echo "Invalid arguments: more than one filename!\n"; echo "Invalid arguments: more than one filename!".PHP_EOL;
exit(1); exit(1);
} }
else else
@ -191,8 +191,7 @@ function check_required_extensions()
{ {
if (!function_exists('mb_strlen')) if (!function_exists('mb_strlen'))
{ {
echo 'Required extension mbstring is not enabled; please check your php installation!'; echo 'Required extension mbstring is not enabled; please check your php installation!'.PHP_EOL;
echo PHP_EOL;
exit(1); exit(1);
} }
} }
@ -222,7 +221,7 @@ function check_the_available_clipboard_tool(&$mm)
if (trim($tool)==='') if (trim($tool)==='')
{ {
echo "Can't find your clipboard tool! I expected to find xclip, xsel, or wl-clipboard.\n"; echo "Can't find your clipboard tool! I expected to find xclip, xsel, or wl-clipboard.".PHP_EOL;
exit(1); exit(1);
} }
@ -244,7 +243,7 @@ function check_the_available_clipboard_tool(&$mm)
break; break;
default: default:
echo "I can't find your clipboard tool!\n"; echo "I can't find your clipboard tool!".PHP_EOL;
exit(1); exit(1);
} }
@ -401,7 +400,7 @@ function list_to_map($lines, $root_id, $start_id)
function map_to_list(&$mm, $id, $exclude_parent = false, $base = 0) function map_to_list(&$mm, $id, $exclude_parent = false, $base = 0)
{ {
if (!$exclude_parent) if (!$exclude_parent)
$output = str_repeat("\t",$base).$mm['nodes'][$id]['title']."\n"; $output = str_repeat("\t",$base).$mm['nodes'][$id]['title'].PHP_EOL;
else else
$output = ''; $output = '';
@ -504,7 +503,7 @@ function calculate_x_and_lh(&$mm, $id)
if ( mb_strlen($node['title']) > width_tolerance * $max_width ) if ( mb_strlen($node['title']) > width_tolerance * $max_width )
{ {
$lines = explode("\n" ,wordwrap($node['title'] ,$max_width)); $lines = explode(PHP_EOL ,wordwrap($node['title'] ,$max_width, PHP_EOL));
$mm['nodes'][$id]['w'] = 0; $mm['nodes'][$id]['w'] = 0;
foreach ($lines as $line) foreach ($lines as $line)
@ -854,11 +853,12 @@ function add_content_to_the_map(&$mm, $id)
$lines = $lines =
explode explode
( (
"\n", PHP_EOL,
wordwrap wordwrap
( (
$node['title'], $node['title']
$max_width ,$max_width
,PHP_EOL
) )
) )
; ;
@ -1999,6 +1999,8 @@ function paste_sub_tree(&$mm, $as_sibling )
$new_id = 1 + max(array_keys($mm['nodes'])); $new_id = 1 + max(array_keys($mm['nodes']));
// \n instead of PHP_EOL, just to be sure.
// existing \r's will be removed later.
$st = $st =
list_to_map list_to_map
( (