man2hlp: limited support of \(lq, \(rq and \(dq commands.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2021-04-18 14:14:29 +03:00
parent 5fc84f2cfe
commit 0718ef89f7

View File

@ -205,6 +205,7 @@ sub print_string($)
my $len; # The length of current word
my $backslash_flag = 0;
my $font_change_flag = 0;
my $quotes_flag = 0;
# Skipping lines?
return if $skip_flag;
@ -247,6 +248,28 @@ sub print_string($)
# Attempt to handle backslash quoting
foreach (split //, $buffer)
{
# handle quotes: \(lq, \(rq, \(dq
if ($quotes_flag != 0)
{
if (($_ eq 'l' || $_ eq 'r' || $_ eq 'd') && $quotes_flag == 1)
{
# continue quotes handling
$quotes_flag = 2;
next;
}
elsif ($_ eq 'q' && $quotes_flag == 2)
{
# finish quotes handling
$quotes_flag = 0;
print $f_out '"';
next;
}
else
{
print $f_out '(' . $_;
print_error "Syntax error: unsupported \\(" . $_ . " command";
}
}
# handle \fR, \fB, \fI and \fP commands
if ($font_change_flag)
{
@ -271,6 +294,12 @@ sub print_string($)
$font_change_flag = 0;
next;
}
if ($_ eq '(' && $backslash_flag)
{
$quotes_flag = 1;
$backslash_flag = 0;
next;
}
if ($_ eq 'f' && $backslash_flag)
{
$font_change_flag = 1;
@ -284,6 +313,7 @@ sub print_string($)
}
$backslash_flag = 0;
$font_change_flag = 0;
$quotes_flag = 0;
print $f_out $_;
}
# Increase column