Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More C cleanups #92

Merged
merged 14 commits into from
Jun 12, 2017
Merged

Conversation

ronnychevalier
Copy link
Contributor

They focus mainly on dpx-dvipdfmx.

In C, a cast from void * to any other pointer type is made implicitly.
Only in C++ such cast is needed.
Such special would parse the string provided as a command line argument
and would allow to change some parameters of dvipdfmx.

Such feature is not really useful since if a user wants to modify some
parameters we should provide command line parameters to tectonic to do
so directly.

This feature also impedes our ability to simplify the code and remove
global variables.

Removing this feature is equivalent to the parsing of the
dvipdfmx config file which was removed.
dvipdfmx_main has a new `pagespec` parameter previously provided via
the -s command line option. Currently, it is set to NULL, but it could
become a Tectonic command line argument if needed in the future.
Tectonic does not support input from stdin or output to stdout, thus we
remove the handling of such case in dvipdfmx_main.

Also add asserts to ensure Rust code provides values for dvi_filename
and pdfname.
dvipdfmx_main now has opt_flags as a parameter. It is set to 0 by
default. It allows to add the ability to modify such flags in the
future in Tectonic via a command line option if needed.
Also rename the variable to `enable_object_stream` to avoid to put a
comment above.
Change the global variable to a simple macro definition
We include stdbool.h if we need true or false.
@pkgw
Copy link
Collaborator

pkgw commented Jun 12, 2017

Can't say that I understand all of the changes here but I trust that more-than-syntax ones make sense. Thanks!

@pkgw pkgw merged commit 8e8eec4 into tectonic-typesetting:master Jun 12, 2017
Mrmaxmeier pushed a commit to Mrmaxmeier/tectonic that referenced this pull request Oct 1, 2019
vlasakm added a commit to vlasakm/tectonic that referenced this pull request Oct 15, 2022
In upstream dvipdfmx the `dvidpfmx:config` DVI special can be used to
pass arguments to dvipdfmx. This has seen some use in XeTeX packages.

For example, the ubiqitous package "hyperref" uses:

    \special{dvipdfmx:config C 0x0010}

This is normally parsed by dvipdfmx as command line arguments, i.e. as
if xdvipdfmx was ran as:

    xdvipdfmx -C 0x0010

The `'C'` option is a bitset of compatibility flags. In this case hyperref
needs the option `OPT_PDFDOC_NO_DEST_REMOVE`, which makes dvipdfmx
handle PDF destinations differently (I didn't check thoroughly how).

The `opt_flags` global variable used to hold these bitflags and the
`dvipdfmx:config` special could be used to set them. tectonic-typesetting#92 removed that
option.

While passing arbitrary command line arguments to dvidpfmx is probably
not what we want, I definitely know, that we at least need the
compatibility flags to work, and there is probably no other way packages
can set them.

The code that does the option parsing is mostly port from the 'C' option
parsing from dvipdfmx's `read_config_special` and `do_args_second_pass`.
IMHO the way `opt_flags` gets modified is undefined behaviour and does
other weird things with negative values, but the purpose of this commit
is to increase compatibility with upstream, not to fix things (which
should preferably be done upstream IMO).

Like with other options, instead of having a global variable, the
pointer to the value in `dvipdfmx_main` is passed around instead.
vlasakm added a commit to vlasakm/tectonic that referenced this pull request Oct 15, 2022
In upstream dvipdfmx the `dvidpfmx:config` DVI special can be used to
pass arguments to dvipdfmx. This has seen some use in XeTeX packages.

For example, the ubiqitous package "hyperref" uses:

    \special{dvipdfmx:config C 0x0010}

This is normally parsed by dvipdfmx as command line arguments, i.e. as
if xdvipdfmx was ran as:

    xdvipdfmx -C 0x0010

The `C` option is a bitset of compatibility flags. In this case hyperref
needs the option `OPT_PDFDOC_NO_DEST_REMOVE`, which makes dvipdfmx
handle PDF destinations differently (I didn't check thoroughly how).

The `opt_flags` global variable used to hold these bitflags and the
`dvipdfmx:config` special could be used to set them. tectonic-typesetting#92 removed that
option.

While passing arbitrary command line arguments to dvidpfmx is probably
not what we want, I definitely know, that we at least need the
compatibility flags to work, and there is probably no other way packages
can set them.

The code that does the option parsing is mostly port from the 'C' option
parsing from dvipdfmx's `read_config_special` and `do_args_second_pass`.
IMHO the way `opt_flags` gets modified is undefined behaviour and does
other weird things with negative values, but the purpose of this commit
is to increase compatibility with upstream, not to fix things (which
should preferably be done upstream IMO).

Like with other options, instead of having a global variable, the
pointer to the value in `dvipdfmx_main` is passed around instead.

While at it, I also added `z` and `g` options which also seem to be used
by LaTeX, so this should be enough for a while.

Hopefully fixes tectonic-typesetting#904.
vlasakm added a commit to vlasakm/tectonic that referenced this pull request Oct 15, 2022
In upstream dvipdfmx the `dvidpfmx:config` DVI special can be used to
pass arguments to dvipdfmx. This has seen some use in XeTeX packages.

For example, the ubiqitous package "hyperref" uses:

    \special{dvipdfmx:config C 0x0010}

This is normally parsed by dvipdfmx as command line arguments, i.e. as
if xdvipdfmx was ran as:

    xdvipdfmx -C 0x0010

The `C` option is a bitset of compatibility flags. In this case hyperref
needs the option `OPT_PDFDOC_NO_DEST_REMOVE`, which makes dvipdfmx
handle PDF destinations differently (I didn't check thoroughly how).

The `opt_flags` global variable used to hold these bitflags and the
`dvipdfmx:config` special could be used to set them. tectonic-typesetting#92 removed that
option.

While passing arbitrary command line arguments to dvidpfmx is probably
not what we want, I definitely know, that we at least need the
compatibility flags to work, and there is probably no other way packages
can set them.

The code that does the option parsing is mostly port from the 'C' option
parsing from dvipdfmx's `read_config_special` and `do_args_second_pass`.
IMHO the way `opt_flags` gets modified is undefined behaviour and does
other weird things with negative values, but the purpose of this commit
is to increase compatibility with upstream, not to fix things (which
should preferably be done upstream IMO).

Like with other options, instead of having a global variable, the
pointer to the value in `dvipdfmx_main` is passed around instead.

While at it, I also added `z` and `g` options which also seem to be used
by LaTeX, so this should be enough for a while.

Hopefully fixes tectonic-typesetting#904.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants