diff --git a/xorriso/make_xorriso_1.c b/xorriso/make_xorriso_1.c index 907d325f..2653eed4 100644 --- a/xorriso/make_xorriso_1.c +++ b/xorriso/make_xorriso_1.c @@ -82,12 +82,82 @@ int Mx1__get_word(char *line, char word[256], char **remainder, int flag) } +int Mx1_is_wrap(struct Mx1 *m, char wraps[][20], char *start, char **found, + int flag) +{ + int i; + + for(i= 0; wraps[i][0] != 0; i++) + if(strncmp(start, wraps[i], strlen(wraps[i])) == 0) + break; + if(wraps[i][0] != 0) { + if(found != NULL) + *found= wraps[i]; + return(1); + } + return(0); +} + + +int Mx1_is_bold_wrap(struct Mx1 *m, char *start, char **found, int flag) +{ + int ret; + static char bold_wraps[][20]= { + "@b{", "@dfn{", "@emph{", "@strong{", "@command{", + "" }; + + ret= Mx1_is_wrap(m, bold_wraps, start, found, 0); + return(ret); +} + + +int Mx1_is_normal_wrap(struct Mx1 *m, char *start, char **found, int flag) +{ + int ret; + static char normal_wraps[][20]= { + "@var{", "@code{", "@i{", "@abbr{", "@file{", "@option{", "@samp{", "@r{", + "" }; + + ret= Mx1_is_wrap(m, normal_wraps, start, found, 0); + return(ret); +} + + +int Mx1_is_ignored_wrap(struct Mx1 *m, char *start, char **found, int flag) +{ + int ret; + static char ignored_wraps[][20]= { + "@ref{", "@xref{", + "" }; + + ret= Mx1_is_wrap(m, ignored_wraps, start, found, 0); + return(ret); +} + + +int Mx1_is_any_wrap(struct Mx1 *m, char *start, char **found, int flag) +{ + int ret; + + ret= Mx1_is_bold_wrap(m, start, found, 0); + if(ret > 0) + return(1); + ret= Mx1_is_normal_wrap(m, start, found, 0); + if(ret > 0) + return(2); + ret= Mx1_is_ignored_wrap(m, start, found, 0); + if(ret > 0) + return(3); + return(0); +} + + /* @param flag bit0= recursion + bit1= drop content of brackets */ int Mx1_rewrap(struct Mx1 *m, char **read_pt, char **write_pt, char *write_base, char *envelope, - char *front, char *back, - int flag) + char *front, char *back, int flag) { char *rpt, *wpt, *ept, content[256], msg[256]; int l, ret; @@ -103,17 +173,22 @@ int Mx1_rewrap(struct Mx1 *m, char **read_pt, char **write_pt, } /* Mapped {...} content is subject to the rules except {...} mapping. */ l= ept - rpt; - ret= Mx1_substitute(m, rpt, content, 0, l, 1); - if(ret <= 0) - return(ret); - l= strlen(content); + if(flag & 2) + l= 0; + if(l > 0) { + ret= Mx1_substitute(m, rpt, content, 0, l, 1); + if(ret <= 0) + return(ret); + l= strlen(content); + } if((wpt - write_base) + l + strlen(front) + strlen(back) > 255) { Mx1_report_error(m, "Line length overflow while text substitution", 0); return(-1); } strcpy(wpt, front); wpt+= strlen(front); - strncpy(wpt, content, l); + if(l > 0) + strncpy(wpt, content, l); wpt+= l; strcpy(wpt, back); wpt+= strlen(back); @@ -129,8 +204,8 @@ int Mx1_rewrap(struct Mx1 *m, char **read_pt, char **write_pt, int Mx1_substitute(struct Mx1 *m, char line_in[256], char line_out[256], int raw, int upto, int flag) { - char *rpt, *wpt; - int ret; + char *rpt, *wpt, *found; + int ret, typ= 0; wpt= line_out; for(rpt= line_in; rpt - line_in < upto && *rpt != 0; rpt++) { @@ -139,19 +214,34 @@ int Mx1_substitute(struct Mx1 *m, char line_in[256], char line_out[256], continue; } if(*rpt == '@') { - if(strncmp(rpt, "@strong{", 8) == 0 && !(flag & 1)) { - /* @strong{...} gets mapped to \fB...\fR . */ - rpt+= 8; + typ= 0; + if(!(flag & 1)) + typ= Mx1_is_any_wrap(m, rpt, &found, 0); + if(typ == 1) { + /* @b{...}, @command{...}, @dfn{...}, @emph{...}, @strong{...} + get mapped to \fB...\fR . + */ + rpt+= strlen(found); ret= Mx1_rewrap(m, &rpt, &wpt, line_out, - "@strong{" , "\\fB", "\\fR", 0); + found , "\\fB", "\\fR", flag & 1); if(ret <= 0) return(ret); - } else if(strncmp(rpt, "@command{", 9) == 0 && !(flag & 1)) { - /* @command{...} gets mapped to \fB...\fR . */ - rpt+= 9; - ret= Mx1_rewrap(m, &rpt, &wpt, line_out, - "@command{", "\\fB", "\\fR", 0); + } else if(typ == 2) { + /* @abbr{...}, @code{...}, @file{...}, @i{...}, @option{...}, @r{...}, + @ref{...}, @samp{...},@var{...}, get mapped to ... . + */ + rpt+= strlen(found); + ret= Mx1_rewrap(m, &rpt, &wpt, line_out, found, "", "", flag & 1); + if(ret <= 0) + return(ret); + + } else if(typ == 3) { + /* @ref{...}, @xref{...} get mapped to empty text. + */ + rpt+= strlen(found); + ret= Mx1_rewrap(m, &rpt, &wpt, line_out, found , "", "", + (flag & 1) | 2); if(ret <= 0) return(ret); @@ -173,9 +263,16 @@ int Mx1_substitute(struct Mx1 *m, char line_in[256], char line_out[256], strncmp(rpt, "@{", 2) == 0 || strncmp(rpt, "@}", 2) == 0) { /* @@ , @{, @} will get stripped of their first @. */ + if((wpt - line_out) + 1 > 255) + goto overflow; *(wpt++)= *(rpt + 1); rpt++; + } else { + if((wpt - line_out) + 1 > 255) + goto overflow; + *(wpt++)= *(rpt); + } } else if(*rpt == '\\') { @@ -314,10 +411,8 @@ int Mx1_convert(struct Mx1 *m, char line_in[256], char line_out[256], int flag) /* "\" becomes "\\" */ if(line_in[0] != '@' || - strncmp(line_in, "@strong{", 8) == 0 || - strncmp(line_in, "@command{", 9) == 0 || + Mx1_is_any_wrap(m, line_in, NULL, 0) > 0 || strncmp(line_in, "@minus{}", 8) == 0 || - strncmp(line_in, "@email{", 7) == 0 || strncmp(line_in, "@@", 2) == 0 || strncmp(line_in, "@{", 2) == 0 || strncmp(line_in, "@}", 2) == 0 ) { diff --git a/xorriso/xorriso.texi b/xorriso/xorriso.texi index f14ee109..bfd09eff 100644 --- a/xorriso/xorriso.texi +++ b/xorriso/xorriso.texi @@ -24,9 +24,11 @@ @c up to "@c man-ignore-lines end". @c Line blocks of "@menu" "@end menu" will be discarded. @c "@item word words" becomes "\fBword\fR words". -@c @strong{-...} gets mapped to \fB\-...\fR . -@c @strong{...} gets mapped to \fB...\fR . -@c @command{...} gets mapped to \fB...\fR . +@c @b{...}, @command{...}, @dfn{...}, @emph{...}, @strong{...} +@c get mapped to \fB...\fR . +@c @abbr{...}, @code{...}, @file{...}, @i{...}, @option{...}, @r{...}, +@c @ref{...}, @samp{...},@var{...}, get mapped to ... . +@c @ref{...}, @xref{...} get mapped to empty text. @c @email{...} gets mapped to <...> . @c Mapped {...} content is subject to the rules except {...} mapping. @c @minus{} will become "-". @@ -34,7 +36,7 @@ @c Other lines which begin by "@" will be discarded. @c In lines not stemming from "@c man", "\" becomes "\\" @c "-" which are not preceded by an uneven number of "\" will get -@c prepended one "\". +@c prepended one "\". @c @c @c man .\" Hey, EMACS: -*- nroff -*- diff --git a/xorriso/xorrisofs.texi b/xorriso/xorrisofs.texi index 22599b59..da1681ba 100644 --- a/xorriso/xorrisofs.texi +++ b/xorriso/xorrisofs.texi @@ -17,16 +17,18 @@ @c was originally derived in march 2010. @c One can produce the man page by applying the following rules: @c The first line gets discarded. -@c Line start "@c man " will become "", the remainder is put out unaltered. +@c Line start "@c man " will become "", the remainder is put out unaltered. @c Lines "@*" will be converted to ".br" @c "@c man-ignore-lines N" will discard N following lines. @c "@c man-ignore-lines begin" discards all following lines @c up to "@c man-ignore-lines end". @c Line blocks of "@menu" "@end menu" will be discarded. -@c "@item -word words" becomes "\fB\-word\fR words". @c "@item word words" becomes "\fBword\fR words". -@c @strong{...} gets mapped to \fB...\fR . -@c @command{...} gets mapped to \fB...\fR . +@c @b{...}, @command{...}, @dfn{...}, @emph{...}, @strong{...} +@c get mapped to \fB...\fR . +@c @abbr{...}, @code{...}, @file{...}, @i{...}, @option{...}, @r{...}, +@c @ref{...}, @samp{...},@var{...}, get mapped to ... . +@c @ref{...}, @xref{...} get mapped to empty text. @c @email{...} gets mapped to <...> . @c Mapped {...} content is subject to the rules except {...} mapping. @c @minus{} will become "-". @@ -34,7 +36,7 @@ @c Other lines which begin by "@" will be discarded. @c In lines not stemming from "@c man", "\" becomes "\\" @c "-" which are not preceded by an uneven number of "\" will get -@c prepended one "\". +@c prepended one "\". @c @c @c man .\" Hey, EMACS: -*- nroff -*-