All pastes #451471 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-21 15:30 UTC
rendered paste body
# Copy of $input_file to $output_file.
# $output_file is converted from dos to unix if needed
# Each input of msgstr (i.e. the part before any \n) is put on only 1 line
BEGIN=`grep -nm 1 "#: " $input_file | cut -d : -f 1`
END=`wc -l $input_file | $sed_soft 's/^[ \t]*//g' | cut -d " " -f 1`
$sed_soft $BEGIN','$END's/^\"\(.*\)\"$/\1/g;s/\r//g' $input_file |
$awk_soft 'BEGIN {FS=" ";test=0}
	$0 ~ /^[ \t]*$/ {if (test) {printf "\"\n";}; printf "\n"; test=0; next}
    $0 ~ /^#/ || $0 ~ /^\"/ || $0 ~ /^msgid/ || $0 ~ /^msgstr/ {
		if (test) {printf "\"\n"}
		printf "%s\n",$0
		test=0
		next}
	{	if (test==0) {printf "\""}
		printf "%s", $0
		test=1
		if (index($NF,"\\n") > 0)
			{printf "\"\n";test=0;}
		}
' > $output_file
echo "Converted $input_file to $output_file : done." >> $log_file