Eventual backslash output conversion outside quotes for more terminal-safety

This commit is contained in:
Thomas Schmitt 2008-11-10 12:38:01 +00:00
parent 31ccbfb4ad
commit 6ca36d3806
3 changed files with 36 additions and 21 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Nov 07, 2008"
.TH XORRISO 1 "Nov 11, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -2292,11 +2292,11 @@ Enable or disable the interpretation of symbolic representations of special
characters with quoted input, or with program arguments, or with program
text output. If enabled the following translations apply:
.br
\\a=bell(007) \\b=backspace(008) \\e=Escape(033) \\f=formfeed(014)
\\a=bell(007) \\b=backspace(010) \\e=Escape(033) \\f=formfeed(014)
.br
\\n=linefeed(012) \\r=carriage_return(015) \\t=tab(011)
.br
\\v=vtab(013) \\\\=backslash(134) \\[0-9][0-9][0-9]=octal_code
\\v=vtab(013) \\\\=backslash(134) \\[0-7][0-7][0-7]=octal_code
.br
\\\\x[0-9a-f][0-9a-f]=hex_code \\cC=control-C
.br
@ -2313,9 +2313,12 @@ With the start program arguments there is mode:
"with_program_arguments" translates all program arguments.
.br
.br
Mode "encode_output" encodes output characters inside single or double
quotation marks. It combines "encode_results" with "encode_infos". Encoding
applies to ASCII characters 1 to 31 and 127 to 255.
Mode "encode_output" encodes output characters. It combines "encode_results"
with "encode_infos". Inside single or double quotation marks encoding applies
to ASCII characters octal 001 to 037 , 177 to 377 and to backslash(134).
Outside quotation marks some harmless control characters stay unencoded:
bell(007), backspace(010), tab(011), linefeed(012), formfeed(014),
carriage_return(015).
.br
Mode "off" is default and disables any translation.
Mode "on" is
@ -2595,12 +2598,13 @@ This example assumes that the existing ISO image was written with character
set ISO-8859-1 but that the readers expected UTF-8. Now a new session with
the same files gets added with converted file names.
In order to avoid any weaknesses of the local character set this command
pretends that it is already the final target set UTF-8.
Therefore strange file names may appear in eventual error messages.
pretends that it uses already the final target set UTF-8.
Therefore strange file names may appear in eventual error messages which
will be made terminal-safe by option -backslash_codes.
.br
\fB$\fR xorriso -in_charset ISO-8859-1 -local_charset UTF-8 \\
.br
-out_charset UTF-8 -dev /dev/sr0 \\
-out_charset UTF-8 -backslash_codes on -dev /dev/sr0 \\
.br
-alter_date m +0 / -- -commit -eject all
.SS

View File

@ -513,7 +513,7 @@ int Sfile_off_t_text(char text[80], off_t num, int flag)
*/
int Sfile_bsl_interpreter(char *text, int upto, int *eaten, int flag)
{
char *rpt, *wpt, num_text[4], wdummy[8];
char *rpt, *wpt, num_text[8], wdummy[8];
unsigned int num= 0;
*eaten= 0;
@ -542,13 +542,14 @@ int Sfile_bsl_interpreter(char *text, int upto, int *eaten, int flag)
*(wpt++)= 11;
} else if(*rpt == '\\') {
*(wpt++)= '\\';
} else if(rpt[0] >= '0' && rpt[0] <= '9' &&
rpt[1] >= '0' && rpt[1] <= '9' &&
rpt[2] >= '0' && rpt[2] <= '9') {
num_text[0]= *(rpt + 0);
num_text[1]= *(rpt + 1);
num_text[2]= *(rpt + 2);
num_text[3]= 0;
} else if(rpt[0] >= '0' && rpt[0] <= '7' &&
rpt[1] >= '0' && rpt[1] <= '7' &&
rpt[2] >= '0' && rpt[2] <= '7') {
num_text[0]= '0';
num_text[1]= *(rpt + 0);
num_text[2]= *(rpt + 1);
num_text[3]= *(rpt + 2);
num_text[4]= 0;
sscanf(num_text, "%o", &num);
if(num > 0 && num <= 255) {
rpt+= 2;
@ -626,6 +627,8 @@ ex:;
/* @param flag bit0= only encode inside quotes
bit1= encode < 32 outside quotes except 7, 8, 9, 10, 12, 13
bit2= encode in any case above 126
*/
int Sfile_bsl_encoder(char **result, char *text, int flag)
{
@ -650,8 +653,16 @@ int Sfile_bsl_encoder(char **result, char *text, int flag)
sq_open= !(sq_open || dq_open);
if(*rpt == '"')
dq_open= !(sq_open || dq_open);
if((*rpt >= 32 && *rpt <= 126 && *rpt != '\\') ||
((flag & 1) && !(sq_open || dq_open))) {
if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\') {
*(wpt++)= *rpt;
continue;
}
if( ((flag & 1) && !(sq_open || dq_open)) &&
!((flag & 2) && (*rpt >= 1 && * rpt <= 31 &&
!(*rpt == 7 || *rpt == 8 || *rpt == 9 || *rpt == 10 ||
*rpt == 12 || *rpt == 13))) &&
!((flag & 4) && (*rpt > 126 || *rpt < 0)) &&
!((flag & 6) && *rpt == '\\')) {
*(wpt++)= *rpt;
continue;
}
@ -4360,7 +4371,7 @@ bit15= with bit1 or bit2: close depicted log file
/* Eventually perform backslash encoding of non-printable characters */
if(((xorriso->bsl_interpretation & 32) && channel_no == 1) ||
((xorriso->bsl_interpretation & 64) && channel_no == 2)) {
ret= Sfile_bsl_encoder(&text, text, 1);
ret= Sfile_bsl_encoder(&text, text, 1 | 2 | 4);
if(ret <= 0)
{ret= -1; goto ex;}
}

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.11.10.123332"
#define Xorriso_timestamP "2008.11.10.123713"