Skip to content

Commit

Permalink
Merge pull request #237 from pkgw/c-tidying
Browse files Browse the repository at this point in the history
Tidying of the C/C++/ObjC code
  • Loading branch information
pkgw authored Oct 5, 2018
2 parents 2a99579 + 963bca3 commit 2210ff2
Show file tree
Hide file tree
Showing 191 changed files with 1,318 additions and 1,198 deletions.
55 changes: 24 additions & 31 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extern crate pkg_config;
extern crate regex;
extern crate sha2;

use std::env;
use std::path::PathBuf;


Expand All @@ -26,10 +25,6 @@ fn main() {

let deps = pkg_config::Config::new().cargo_metadata(false).probe(LIBS).unwrap();

// First, emit the string pool C code. Sigh.

let out_dir = env::var("OUT_DIR").unwrap();

// Actually I'm not 100% sure that I can't compile the C and C++ code
// into one library, but who cares?

Expand Down Expand Up @@ -83,7 +78,7 @@ fn main() {
ccfg
.file("tectonic/bibtex.c")
.file("tectonic/core-bridge.c")
.file("tectonic/core-kpathutil.c")
.file("tectonic/core-memory.c")
.file("tectonic/dpx-agl.c")
.file("tectonic/dpx-bmpimage.c")
.file("tectonic/dpx-cff.c")
Expand Down Expand Up @@ -155,26 +150,25 @@ fn main() {
.file("tectonic/dpx-type1c.c")
.file("tectonic/dpx-unicode.c")
.file("tectonic/dpx-vf.c")
.file("tectonic/engine-interface.c")
.file("tectonic/errors.c")
.file("tectonic/io.c")
.file("tectonic/mathutil.c")
.file("tectonic/output.c")
.file("tectonic/stringpool.c")
.file("tectonic/synctex.c")
.file("tectonic/texmfmp.c")
.file("tectonic/xetex0.c")
.file("tectonic/XeTeX_ext.c")
.file("tectonic/xetexini.c")
.file("tectonic/XeTeX_pic.c")
.file("tectonic/xetex-engine-interface.c")
.file("tectonic/xetex-errors.c")
.file("tectonic/xetex-ext.c")
.file("tectonic/xetex-ini.c")
.file("tectonic/xetex-io.c")
.file("tectonic/xetex-linebreak.c")
.file("tectonic/xetex-math.c")
.file("tectonic/xetex-output.c")
.file("tectonic/xetex-pic.c")
.file("tectonic/xetex-scaledmath.c")
.file("tectonic/xetex-shipout.c")
.file("tectonic/xetex-stringpool.c")
.file("tectonic/xetex-synctex.c")
.file("tectonic/xetex-texmfmp.c")
.file("tectonic/xetex-xetex0.c")
.define("HAVE_ZLIB", "1")
.define("HAVE_ZLIB_COMPRESS2", "1")
.define("ZLIB_CONST", "1")
.include(".")
.include(&out_dir);
.include(".");

let cppflags = [
"-std=c++14",
Expand Down Expand Up @@ -215,13 +209,12 @@ fn main() {
cppcfg
.cpp(true)
.flag("-Wall")
.file("tectonic/Engine.cpp")
.file("tectonic/XeTeXFontInst.cpp")
.file("tectonic/XeTeXFontMgr.cpp")
.file("tectonic/XeTeXLayoutInterface.cpp")
.file("tectonic/XeTeXOTMath.cpp")
.include(".")
.include(&out_dir);
.file("tectonic/teckit-Engine.cpp")
.file("tectonic/xetex-XeTeXFontInst.cpp")
.file("tectonic/xetex-XeTeXFontMgr.cpp")
.file("tectonic/xetex-XeTeXLayoutInterface.cpp")
.file("tectonic/xetex-XeTeXOTMath.cpp")
.include(".");

for p in deps.include_paths {
ccfg.include(&p);
Expand All @@ -232,11 +225,11 @@ fn main() {

if cfg!(target_os = "macos") {
ccfg.define("XETEX_MAC", Some("1"));
ccfg.file("tectonic/XeTeX_mac.c");
ccfg.file("tectonic/xetex-macos.c");

cppcfg.define("XETEX_MAC", Some("1"));
cppcfg.file("tectonic/XeTeXFontInst_Mac.cpp");
cppcfg.file("tectonic/XeTeXFontMgr_Mac.mm");
cppcfg.file("tectonic/xetex-XeTeXFontInst_Mac.cpp");
cppcfg.file("tectonic/xetex-XeTeXFontMgr_Mac.mm");

println!("cargo:rustc-link-lib=framework=Foundation");
println!("cargo:rustc-link-lib=framework=CoreFoundation");
Expand All @@ -247,7 +240,7 @@ fn main() {

if cfg!(not(target_os = "macos")) {
// At the moment we use Fontconfig on both Linux and Windows.
cppcfg.file("tectonic/XeTeXFontMgr_FC.cpp");
cppcfg.file("tectonic/xetex-XeTeXFontMgr_FC.cpp");
}

if cfg!(target_endian = "big") {
Expand Down
4 changes: 2 additions & 2 deletions src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ struct TectonicBridgeApi {

extern {
fn tt_get_error_message() -> *const libc::c_char;
fn tt_set_int_variable(var_name: *const libc::c_char, value: libc::c_int) -> libc::c_int;
//fn tt_set_string_variable(var_name: *const libc::c_char, value: *const libc::c_char) -> libc::c_int;
fn tt_xetex_set_int_variable(var_name: *const libc::c_char, value: libc::c_int) -> libc::c_int;
//fn tt_xetex_set_string_variable(var_name: *const libc::c_char, value: *const libc::c_char) -> libc::c_int;
fn tex_simple_main(api: *const TectonicBridgeApi, dump_name: *const libc::c_char, input_file_name: *const libc::c_char) -> libc::c_int;
fn dvipdfmx_simple_main(api: *const TectonicBridgeApi,
dviname: *const libc::c_char,
Expand Down
8 changes: 4 additions & 4 deletions src/engines/tex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ impl TexEngine {

// initialize globals
let v = if self.halt_on_error { 1 } else { 0 };
unsafe { super::tt_set_int_variable(b"halt_on_error_p\0".as_ptr() as _, v); }
unsafe { super::tt_xetex_set_int_variable(b"halt_on_error_p\0".as_ptr() as _, v); }
let v = if self.initex_mode { 1 } else { 0 };
unsafe { super::tt_set_int_variable(b"in_initex_mode\0".as_ptr() as _, v); }
unsafe { super::tt_xetex_set_int_variable(b"in_initex_mode\0".as_ptr() as _, v); }
let v = if self.synctex_enabled { 1 } else { 0 };
unsafe { super::tt_set_int_variable(b"synctex_enabled\0".as_ptr() as _, v); }
unsafe { super::tt_xetex_set_int_variable(b"synctex_enabled\0".as_ptr() as _, v); }
let v = if self.semantic_pagination_enabled { 1 } else { 0 };
unsafe { super::tt_set_int_variable(b"semantic_pagination_enabled\0".as_ptr() as _, v); }
unsafe { super::tt_xetex_set_int_variable(b"semantic_pagination_enabled\0".as_ptr() as _, v); }

unsafe {
match super::tex_simple_main(&bridge, cformat.as_ptr(), cinput.as_ptr()) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ pub use errors::{Error, ErrorKind, Result};

const APP_INFO: app_dirs::AppInfo = app_dirs::AppInfo {name: "Tectonic", author: "TectonicProject"};

const FORMAT_SERIAL: u32 = 28; // keep synchronized with tectonic/constants.h!!
const FORMAT_SERIAL: u32 = 28; // keep synchronized with tectonic/xetex-constants.h!!
227 changes: 0 additions & 227 deletions tectonic/XeTeX_pic.c

This file was deleted.

6 changes: 5 additions & 1 deletion tectonic/bibtex.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "bibtex.h"
#include "internals.h"

#include "core-bridge.h"
#include "core-memory.h"

#include <stdio.h> /* EOF, snprintf */

/* hack: the name eof conflicts with other function declarations under mingw. */
#define eof tectonic_eof
Expand Down
2 changes: 1 addition & 1 deletion tectonic/bibtex.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef BIBTEX_H
#define BIBTEX_H

#include "tectonic.h"
#include "core-bridge.h"

tt_history_t bibtex_main(const char *aux_file_name);

Expand Down
Loading

0 comments on commit 2210ff2

Please sign in to comment.