From aa24676651f8bd3e8b434f72d5aac98e84c0867d Mon Sep 17 00:00:00 2001 From: Laurent Napias Date: Sat, 29 Jun 2019 10:43:23 +0200 Subject: Remove trailing whitespaces --- backend/comics/comics-document.c | 132 +++++----- backend/comics/comics-document.h | 2 +- backend/djvu/djvu-document-private.h | 8 +- backend/djvu/djvu-document.c | 110 ++++---- backend/djvu/djvu-document.h | 2 +- backend/djvu/djvu-links.c | 24 +- backend/djvu/djvu-links.h | 2 +- backend/djvu/djvu-text-page.c | 116 ++++---- backend/djvu/djvu-text-page.h | 6 +- backend/dvi/cairo-device.c | 12 +- backend/dvi/dvi-document.c | 108 ++++---- backend/dvi/dvi-document.h | 2 +- backend/dvi/fonts.c | 2 +- backend/dvi/mdvi-lib/afmparse.c | 494 +++++++++++++++++------------------ backend/dvi/mdvi-lib/afmparse.h | 122 ++++----- backend/dvi/mdvi-lib/bitmap.c | 126 ++++----- backend/dvi/mdvi-lib/bitmap.h | 10 +- backend/dvi/mdvi-lib/color.c | 10 +- backend/dvi/mdvi-lib/color.h | 2 +- backend/dvi/mdvi-lib/common.c | 20 +- backend/dvi/mdvi-lib/dviread.c | 264 +++++++++---------- backend/dvi/mdvi-lib/files.c | 12 +- backend/dvi/mdvi-lib/font.c | 56 ++-- backend/dvi/mdvi-lib/fontmap.c | 140 +++++----- backend/dvi/mdvi-lib/fontsrch.c | 22 +- backend/dvi/mdvi-lib/gf.c | 26 +- backend/dvi/mdvi-lib/hash.c | 30 +-- backend/dvi/mdvi-lib/mdvi.h | 32 +-- backend/dvi/mdvi-lib/pagesel.c | 64 ++--- backend/dvi/mdvi-lib/paper.c | 8 +- backend/dvi/mdvi-lib/pk.c | 52 ++-- backend/dvi/mdvi-lib/setup.c | 4 +- backend/dvi/mdvi-lib/sp-epsf.c | 34 +-- backend/dvi/mdvi-lib/special.c | 30 +-- backend/dvi/mdvi-lib/sysdeps.h | 4 +- backend/dvi/mdvi-lib/t1.c | 92 +++---- backend/dvi/mdvi-lib/tfm.c | 24 +- backend/dvi/mdvi-lib/tfmfile.c | 72 ++--- backend/dvi/mdvi-lib/tt.c | 66 ++--- backend/dvi/mdvi-lib/util.c | 52 ++-- backend/dvi/mdvi-lib/vf.c | 34 +-- backend/epub/epub-document.c | 212 +++++++-------- backend/epub/epub-document.h | 4 +- backend/epub/minizip/ioapi.h | 2 +- backend/pixbuf/pixbuf-document.c | 22 +- backend/pixbuf/pixbuf-document.h | 4 +- backend/ps/ev-spectre.c | 22 +- backend/ps/ev-spectre.h | 4 +- backend/tiff/tiff-document.c | 88 +++---- backend/tiff/tiff-document.h | 2 +- backend/tiff/tiff2ps.c | 20 +- backend/xps/xps-document.c | 10 +- 52 files changed, 1409 insertions(+), 1409 deletions(-) (limited to 'backend') diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c index 4d4d2939..ae37d23a 100644 --- a/backend/comics/comics-document.c +++ b/backend/comics/comics-document.c @@ -73,7 +73,7 @@ struct _ComicsDocument #define OFFSET_ZIP 2 #define NO_OFFSET 0 -/* For perfomance reasons of 7z* we've choosen to decompress on the temporary +/* For perfomance reasons of 7z* we've choosen to decompress on the temporary * directory instead of decompressing on the stdout */ /** @@ -138,7 +138,7 @@ EV_BACKEND_REGISTER_WITH_CODE (ComicsDocument, comics_document, * @unquoted_string: a literal string * * Quotes a string so unzip will not interpret the regex expressions of - * @unquoted_string. Basically, this functions uses [] to disable regex + * @unquoted_string. Basically, this functions uses [] to disable regex * expressions. The return value must be freed with * g_free() * * Return value: quoted and disabled-regex string @@ -188,22 +188,22 @@ comics_regex_quote (const gchar *unquoted_string) /* This function manages the command for decompressing a comic book */ -static gboolean +static gboolean comics_decompress_temp_dir (const gchar *command_decompress_tmp, - const gchar *command, + const gchar *command, GError **error) { gboolean success; gchar *std_out, *basename; GError *err = NULL; gint retval; - - success = g_spawn_command_line_sync (command_decompress_tmp, &std_out, + + success = g_spawn_command_line_sync (command_decompress_tmp, &std_out, NULL, &retval, &err); basename = g_path_get_basename (command); if (!success) { g_set_error (error, - EV_DOCUMENT_ERROR, + EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, _("Error launching the command “%s” in order to " "decompress the comic book: %s"), @@ -237,16 +237,16 @@ comics_decompress_temp_dir (const gchar *command_decompress_tmp, } /* This function shows how to use the choosen command for decompressing a - * comic book file. It modifies fields of the ComicsDocument struct with + * comic book file. It modifies fields of the ComicsDocument struct with * this information */ -static gboolean -comics_generate_command_lines (ComicsDocument *comics_document, +static gboolean +comics_generate_command_lines (ComicsDocument *comics_document, GError **error) { gchar *quoted_file, *quoted_file_aux; gchar *quoted_command; ComicBookDecompressType type; - + type = comics_document->command_usage; comics_document->regex_arg = command_usage_def[type].regex_arg; quoted_command = g_shell_quote (comics_document->selected_command); @@ -276,7 +276,7 @@ comics_generate_command_lines (ComicsDocument *comics_document, /* unrar-free can't create directories, but ev_mkdtemp already created the dir */ comics_document->decompress_tmp = - g_strdup_printf (command_usage_def[type].decompress_tmp, + g_strdup_printf (command_usage_def[type].decompress_tmp, quoted_command, quoted_file, comics_document->dir); g_free (quoted_file); @@ -295,10 +295,10 @@ comics_generate_command_lines (ComicsDocument *comics_document, } -/* This function chooses an external command for decompressing a comic +/* This function chooses an external command for decompressing a comic * book based on its mime tipe. */ -static gboolean -comics_check_decompress_command (gchar *mime_type, +static gboolean +comics_check_decompress_command (gchar *mime_type, ComicsDocument *comics_document, GError **error) { @@ -306,38 +306,38 @@ comics_check_decompress_command (gchar *mime_type, gchar *std_out, *std_err; gint retval; GError *err = NULL; - + /* FIXME, use proper cbr/cbz mime types once they're * included in shared-mime-info */ - + if (g_content_type_is_a (mime_type, "application/x-cbr") || g_content_type_is_a (mime_type, "application/x-rar")) { - /* The RARLAB provides a no-charge proprietary (freeware) - * decompress-only client for Linux called unrar. Another - * option is a GPLv2-licensed command-line tool developed by - * the Gna! project. Confusingly enough, the free software RAR - * decoder is also named unrar. For this reason we need to add - * some lines for disambiguation. Sorry for the added the + /* The RARLAB provides a no-charge proprietary (freeware) + * decompress-only client for Linux called unrar. Another + * option is a GPLv2-licensed command-line tool developed by + * the Gna! project. Confusingly enough, the free software RAR + * decoder is also named unrar. For this reason we need to add + * some lines for disambiguation. Sorry for the added the * complexity but it's life :) - * Finally, some distributions, like Debian, rename this free - * option as unrar-free. + * Finally, some distributions, like Debian, rename this free + * option as unrar-free. * */ - comics_document->selected_command = + comics_document->selected_command = g_find_program_in_path ("unrar"); if (comics_document->selected_command) { - /* We only use std_err to avoid printing useless error + /* We only use std_err to avoid printing useless error * messages on the terminal */ - success = + success = g_spawn_command_line_sync ( - comics_document->selected_command, + comics_document->selected_command, &std_out, &std_err, &retval, &err); if (!success) { g_propagate_error (error, err); g_error_free (err); return FALSE; - /* I don't check retval status because RARLAB unrar - * doesn't have a way to return 0 without involving an + /* I don't check retval status because RARLAB unrar + * doesn't have a way to return 0 without involving an * operation with a file*/ } else if (WIFEXITED (retval)) { if (g_strrstr (std_out,"freeware") != NULL) @@ -353,7 +353,7 @@ comics_check_decompress_command (gchar *mime_type, } } /* The Gna! free software client with Debian naming convention */ - comics_document->selected_command = + comics_document->selected_command = g_find_program_in_path ("unrar-free"); if (comics_document->selected_command) { comics_document->command_usage = GNAUNRAR; @@ -375,7 +375,7 @@ comics_check_decompress_command (gchar *mime_type, } else if (g_content_type_is_a (mime_type, "application/x-cbz") || g_content_type_is_a (mime_type, "application/zip")) { /* InfoZIP's unzip program */ - comics_document->selected_command = + comics_document->selected_command = g_find_program_in_path ("unzip"); comics_document->alternative_command = g_find_program_in_path ("zipnote"); @@ -399,8 +399,8 @@ comics_check_decompress_command (gchar *mime_type, } else if (g_content_type_is_a (mime_type, "application/x-cb7") || g_content_type_is_a (mime_type, "application/x-7z-compressed")) { - /* 7zr, 7za and 7z are the commands from the p7zip project able - * to decompress .7z files */ + /* 7zr, 7za and 7z are the commands from the p7zip project able + * to decompress .7z files */ comics_document->selected_command = g_find_program_in_path ("7zr"); if (comics_document->selected_command) { @@ -496,7 +496,7 @@ sort_page_names (gconstpointer a, else if (!sort_last_1 && sort_last_2) { compare = -1; - } + } else { key_1 = g_utf8_collate_key_for_filename (name_1, -1); @@ -542,9 +542,9 @@ comics_document_load (EvDocument *document, return FALSE; } - - if (!comics_check_decompress_command (mime_type, comics_document, - error)) { + + if (!comics_check_decompress_command (mime_type, comics_document, + error)) { g_free (mime_type); return FALSE; } else if (!comics_generate_command_lines (comics_document, error)) { @@ -586,10 +586,10 @@ comics_document_load (EvDocument *document, supported_extensions = get_supported_image_extensions (); for (i = 0; cb_files[i] != NULL; i++) { if (comics_document->offset != NO_OFFSET) { - if (g_utf8_strlen (cb_files[i],-1) > + if (g_utf8_strlen (cb_files[i],-1) > comics_document->offset) { - cb_file = - g_utf8_offset_to_pointer (cb_files[i], + cb_file = + g_utf8_offset_to_pointer (cb_files[i], comics_document->offset); } else { continue; @@ -665,11 +665,11 @@ comics_document_get_page_size (EvDocument *document, GdkPixbuf *pixbuf; gchar *filename; ComicsDocument *comics_document = COMICS_DOCUMENT (document); - + if (!comics_document->decompress_tmp) { argv = extract_argv (document, page->index); success = g_spawn_async_with_pipes (NULL, argv, NULL, - G_SPAWN_SEARCH_PATH | + G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &child_pid, @@ -684,7 +684,7 @@ comics_document_get_page_size (EvDocument *document, while (outpipe >= 0) { bytes = read (outpipe, buf, 1024); - + if (bytes > 0) gdk_pixbuf_loader_write (loader, buf, bytes, NULL); if (bytes <= 0 || got_size) { @@ -741,11 +741,11 @@ comics_document_render_pixbuf (EvDocument *document, gint width, height; gchar *filename; ComicsDocument *comics_document = COMICS_DOCUMENT (document); - + if (!comics_document->decompress_tmp) { argv = extract_argv (document, rc->page->index); success = g_spawn_async_with_pipes (NULL, argv, NULL, - G_SPAWN_SEARCH_PATH | + G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &child_pid, @@ -755,14 +755,14 @@ comics_document_render_pixbuf (EvDocument *document, loader = gdk_pixbuf_loader_new (); g_signal_connect (loader, "size-prepared", - G_CALLBACK (render_pixbuf_size_prepared_cb), + G_CALLBACK (render_pixbuf_size_prepared_cb), &rc->scale); while (outpipe >= 0) { bytes = read (outpipe, buf, 4096); if (bytes > 0) { - gdk_pixbuf_loader_write (loader, buf, bytes, + gdk_pixbuf_loader_write (loader, buf, bytes, NULL); } else if (bytes <= 0) { close (outpipe); @@ -777,13 +777,13 @@ comics_document_render_pixbuf (EvDocument *document, g_spawn_close_pid (child_pid); g_object_unref (loader); } else { - filename = + filename = g_build_filename (comics_document->dir, (char *) comics_document->page_names->pdata[rc->page->index], NULL); - + gdk_pixbuf_get_file_info (filename, &width, &height); - + tmp_pixbuf = gdk_pixbuf_new_from_file_at_size ( filename, width * (rc->scale) + 0.5, @@ -807,7 +807,7 @@ comics_document_render (EvDocument *document, pixbuf = comics_document_render_pixbuf (document, rc); surface = ev_document_misc_surface_from_pixbuf (pixbuf); g_object_unref (pixbuf); - + return surface; } @@ -825,24 +825,24 @@ render_pixbuf_size_prepared_cb (GdkPixbufLoader *loader, } /** - * comics_remove_dir: Removes a directory recursively. + * comics_remove_dir: Removes a directory recursively. * Returns: * 0 if it was successfully deleted, - * -1 if an error occurred + * -1 if an error occurred */ -static int -comics_remove_dir (gchar *path_name) +static int +comics_remove_dir (gchar *path_name) { GDir *content_dir; const gchar *filename; gchar *filename_with_path; - + if (g_file_test (path_name, G_FILE_TEST_IS_DIR)) { content_dir = g_dir_open (path_name, 0, NULL); filename = g_dir_read_name (content_dir); while (filename) { - filename_with_path = - g_build_filename (path_name, + filename_with_path = + g_build_filename (path_name, filename, NULL); comics_remove_dir (filename_with_path); g_free (filename_with_path); @@ -850,8 +850,8 @@ comics_remove_dir (gchar *path_name) } g_dir_close (content_dir); } - /* Note from g_remove() documentation: on Windows, it is in general not - * possible to remove a file that is open to some process, or mapped + /* Note from g_remove() documentation: on Windows, it is in general not + * possible to remove a file that is open to some process, or mapped * into memory.*/ return (g_remove (path_name)); } @@ -860,14 +860,14 @@ static void comics_document_finalize (GObject *object) { ComicsDocument *comics_document = COMICS_DOCUMENT (object); - + if (comics_document->decompress_tmp) { if (comics_remove_dir (comics_document->dir) == -1) g_warning (_("There was an error deleting “%s”."), comics_document->dir); g_free (comics_document->dir); } - + if (comics_document->page_names) { g_ptr_array_foreach (comics_document->page_names, (GFunc) g_free, NULL); g_ptr_array_free (comics_document->page_names, TRUE); @@ -940,7 +940,7 @@ comics_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, if (border) { GdkPixbuf *tmp_pixbuf = thumbnail; - + thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf); g_object_unref (tmp_pixbuf); } @@ -955,7 +955,7 @@ comics_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, gint *height) { gdouble page_width, page_height; - + comics_document_get_page_size (EV_DOCUMENT (document), rc->page, &page_width, &page_height); diff --git a/backend/comics/comics-document.h b/backend/comics/comics-document.h index 6cc55f00..f6a4b440 100644 --- a/backend/comics/comics-document.h +++ b/backend/comics/comics-document.h @@ -32,7 +32,7 @@ typedef struct _ComicsDocument ComicsDocument; GType comics_document_get_type (void) G_GNUC_CONST; G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module); - + G_END_DECLS #endif /* __COMICS_DOCUMENT_H__ */ diff --git a/backend/djvu/djvu-document-private.h b/backend/djvu/djvu-document-private.h index 2ec9b67a..92bc0f6d 100644 --- a/backend/djvu/djvu-document-private.h +++ b/backend/djvu/djvu-document-private.h @@ -1,6 +1,6 @@ -/* +/* * Declarations used throughout the djvu classes - * + * * Copyright (C) 2006, Michael Hofmann * * This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - + #ifndef __DJVU_DOCUMENT_INTERNAL_H__ #define __DJVU_DOCUMENT_INTERNAL_H__ @@ -41,7 +41,7 @@ struct _DjvuDocument { }; int djvu_document_get_n_pages (EvDocument *document); -void djvu_handle_events (DjvuDocument *djvu_document, +void djvu_handle_events (DjvuDocument *djvu_document, int wait, GError **error); diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c index 65f7f0f4..b3e41a8d 100644 --- a/backend/djvu/djvu-document.c +++ b/backend/djvu/djvu-document.c @@ -75,7 +75,7 @@ ev_djvu_error_quark (void) static GQuark q = 0; if (q == 0) q = g_quark_from_string ("ev-djvu-quark"); - + return q; } @@ -85,7 +85,7 @@ handle_message (const ddjvu_message_t *msg, GError **error) switch (msg->m_any.tag) { case DDJVU_ERROR: { gchar *error_str; - + if (msg->m_error.filename) { error_str = g_strdup_printf ("DjvuLibre error: %s:%d", msg->m_error.filename, @@ -94,16 +94,16 @@ handle_message (const ddjvu_message_t *msg, GError **error) error_str = g_strdup_printf ("DjvuLibre error: %s", msg->m_error.message); } - + if (error) { g_set_error_literal (error, EV_DJVU_ERROR, 0, error_str); } else { g_warning ("%s", error_str); } - + g_free (error_str); return; - } + } break; default: break; @@ -115,7 +115,7 @@ djvu_handle_events (DjvuDocument *djvu_document, int wait, GError **error) { ddjvu_context_t *ctx = djvu_document->d_context; const ddjvu_message_t *msg; - + if (!ctx) return; @@ -162,7 +162,7 @@ djvu_document_load (EvDocument *document, filename = g_filename_from_uri (uri, NULL, error); if (!filename) return FALSE; - + doc = ddjvu_document_create_by_filename (djvu_document->d_context, filename, TRUE); if (!doc) { @@ -205,10 +205,10 @@ djvu_document_load (EvDocument *document, g_free (filename); ddjvu_document_release (djvu_document->d_document); djvu_document->d_document = NULL; - + return FALSE; } - + g_free (djvu_document->uri); djvu_document->uri = g_strdup (uri); @@ -223,7 +223,7 @@ djvu_document_load (EvDocument *document, for (i = 0; i < n_files; i++) { struct ddjvu_fileinfo_s fileinfo; gchar *file; - + ddjvu_document_get_fileinfo (djvu_document->d_document, i, &fileinfo); @@ -234,7 +234,7 @@ djvu_document_load (EvDocument *document, if (!g_file_test (file, G_FILE_TEST_EXISTS)) { missing_files = TRUE; g_free (file); - + break; } g_free (file); @@ -271,9 +271,9 @@ int djvu_document_get_n_pages (EvDocument *document) { DjvuDocument *djvu_document = DJVU_DOCUMENT (document); - + g_return_val_if_fail (djvu_document->d_document, 0); - + return ddjvu_document_get_pagenum (djvu_document->d_document); } @@ -285,14 +285,14 @@ document_get_page_size (DjvuDocument *djvu_document, { ddjvu_pageinfo_t info; ddjvu_status_t r; - + while ((r = ddjvu_document_get_pageinfo(djvu_document->d_document, page, &info)) < DDJVU_JOB_OK) djvu_handle_events(djvu_document, TRUE, NULL); - + if (r >= DDJVU_JOB_FAILED) djvu_handle_events(djvu_document, TRUE, NULL); - *width = info.width * SCALE_FACTOR; + *width = info.width * SCALE_FACTOR; *height = info.height * SCALE_FACTOR; } @@ -311,7 +311,7 @@ djvu_document_get_page_size (EvDocument *document, } static cairo_surface_t * -djvu_document_render (EvDocument *document, +djvu_document_render (EvDocument *document, EvRenderContext *rc) { DjvuDocument *djvu_document = DJVU_DOCUMENT (document); @@ -325,31 +325,31 @@ djvu_document_render (EvDocument *document, double page_width, page_height, tmp; d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page->index); - + while (!ddjvu_page_decoding_done (d_page)) djvu_handle_events(djvu_document, TRUE, NULL); page_width = ddjvu_page_get_width (d_page) * rc->scale * SCALE_FACTOR + 0.5; page_height = ddjvu_page_get_height (d_page) * rc->scale * SCALE_FACTOR + 0.5; - + switch (rc->rotation) { case 90: rotation = DDJVU_ROTATE_90; tmp = page_height; page_height = page_width; page_width = tmp; - + break; case 180: rotation = DDJVU_ROTATE_180; - + break; case 270: rotation = DDJVU_ROTATE_270; tmp = page_height; page_height = page_width; page_width = tmp; - + break; default: rotation = DDJVU_ROTATE_0; @@ -367,7 +367,7 @@ djvu_document_render (EvDocument *document, rrect = prect; ddjvu_page_set_rotation (d_page, rotation); - + ddjvu_page_render (d_page, DDJVU_RENDER_COLOR, &prect, &rrect, @@ -387,18 +387,18 @@ djvu_document_finalize (GObject *object) if (djvu_document->d_document) ddjvu_document_release (djvu_document->d_document); - + if (djvu_document->opts) g_string_free (djvu_document->opts, TRUE); if (djvu_document->ps_filename) g_free (djvu_document->ps_filename); - + ddjvu_context_release (djvu_document->d_context); ddjvu_format_release (djvu_document->d_format); ddjvu_format_release (djvu_document->thumbs_format); g_free (djvu_document->uri); - + G_OBJECT_CLASS (djvu_document_parent_class)->finalize (object); } @@ -432,7 +432,7 @@ djvu_text_copy (DjvuDocument *djvu_document, if (page_text != miniexp_nil) { DjvuTextPage *page = djvu_text_page_new (page_text); - + text = djvu_text_page_copy (page, rectangle); djvu_text_page_free (page); ddjvu_miniexp_release (djvu_document->d_document, page_text); @@ -451,19 +451,19 @@ djvu_selection_get_selected_text (EvSelection *selection, double width, height; EvRectangle rectangle; gchar *text; - + djvu_document_get_page_size (EV_DOCUMENT (djvu_document), page, &width, &height); rectangle.x1 = points->x1 / SCALE_FACTOR; rectangle.y1 = (height - points->y2) / SCALE_FACTOR; rectangle.x2 = points->x2 / SCALE_FACTOR; rectangle.y2 = (height - points->y1) / SCALE_FACTOR; - + text = djvu_text_copy (djvu_document, page->index, &rectangle); - + if (text == NULL) text = g_strdup (""); - + return text; } @@ -475,13 +475,13 @@ djvu_selection_iface_init (EvSelectionInterface *iface) static void djvu_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, - EvRenderContext *rc, + EvRenderContext *rc, gint *width, gint *height) { - DjvuDocument *djvu_document = DJVU_DOCUMENT (document); + DjvuDocument *djvu_document = DJVU_DOCUMENT (document); gdouble page_width, page_height; - + djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page, &page_width, &page_height); @@ -504,12 +504,12 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, gdouble page_width, page_height; gint thumb_width, thumb_height; guchar *pixels; - + g_return_val_if_fail (djvu_document->d_document, NULL); djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page, &page_width, &page_height); - + thumb_width = (gint) (page_width * rc->scale); thumb_height = (gint) (page_height * rc->scale); @@ -517,14 +517,14 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, thumb_width, thumb_height); gdk_pixbuf_fill (pixbuf, 0xffffffff); pixels = gdk_pixbuf_get_pixels (pixbuf); - + while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page->index, 1) < DDJVU_JOB_OK) djvu_handle_events(djvu_document, TRUE, NULL); - - ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index, + + ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index, &thumb_width, &thumb_height, djvu_document->thumbs_format, - gdk_pixbuf_get_rowstride (pixbuf), + gdk_pixbuf_get_rowstride (pixbuf), (gchar *)pixels); rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation); @@ -532,11 +532,11 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, if (border) { GdkPixbuf *tmp_pixbuf = rotated_pixbuf; - + rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf); g_object_unref (tmp_pixbuf); } - + return rotated_pixbuf; } @@ -553,9 +553,9 @@ djvu_document_file_exporter_begin (EvFileExporter *exporter, EvFileExporterContext *fc) { DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter); - + if (djvu_document->ps_filename) - g_free (djvu_document->ps_filename); + g_free (djvu_document->ps_filename); djvu_document->ps_filename = g_strdup (fc->filename); g_string_assign (djvu_document->opts, "-page="); @@ -566,14 +566,14 @@ djvu_document_file_exporter_do_page (EvFileExporter *exporter, EvRenderContext *rc) { DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter); - - g_string_append_printf (djvu_document->opts, "%d,", (rc->page->index) + 1); + + g_string_append_printf (djvu_document->opts, "%d,", (rc->page->index) + 1); } static void djvu_document_file_exporter_end (EvFileExporter *exporter) { - int d_optc = 1; + int d_optc = 1; const char *d_optv[d_optc]; DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter); @@ -583,15 +583,15 @@ djvu_document_file_exporter_end (EvFileExporter *exporter) g_warning ("Cannot open file “%s”.", djvu_document->ps_filename); return; } - - d_optv[0] = djvu_document->opts->str; + + d_optv[0] = djvu_document->opts->str; ddjvu_job_t * job = ddjvu_document_print(djvu_document->d_document, fn, d_optc, d_optv); - while (!ddjvu_job_done(job)) { + while (!ddjvu_job_done(job)) { djvu_handle_events (djvu_document, TRUE, NULL); } - fclose(fn); + fclose(fn); } static EvFileExporterCapabilities @@ -617,7 +617,7 @@ static void djvu_document_init (DjvuDocument *djvu_document) { guint masks[4] = { 0xff0000, 0xff00, 0xff, 0xff000000 }; - + djvu_document->d_context = ddjvu_context_create ("Atril"); djvu_document->d_format = ddjvu_format_create (DDJVU_FORMAT_RGBMASK32, 4, masks); ddjvu_format_set_row_order (djvu_document->d_format, 1); @@ -627,7 +627,7 @@ djvu_document_init (DjvuDocument *djvu_document) djvu_document->ps_filename = NULL; djvu_document->opts = g_string_new (""); - + djvu_document->d_document = NULL; } @@ -651,7 +651,7 @@ djvu_document_find_find_text (EvDocumentFind *document, if (page_text != miniexp_nil) { DjvuTextPage *tpage = djvu_text_page_new (page_text); - + djvu_text_page_prepare_search (tpage, case_sensitive); if (tpage->links->len > 0) { djvu_text_page_search (tpage, text, case_sensitive); @@ -675,7 +675,7 @@ djvu_document_find_find_text (EvDocumentFind *document, r->y1 = height - r->y2 * SCALE_FACTOR; r->y2 = height - tmp * SCALE_FACTOR; } - + return matches; } diff --git a/backend/djvu/djvu-document.h b/backend/djvu/djvu-document.h index 76ec8765..72f01ba5 100644 --- a/backend/djvu/djvu-document.h +++ b/backend/djvu/djvu-document.h @@ -32,7 +32,7 @@ typedef struct _DjvuDocument DjvuDocument; GType djvu_document_get_type (void) G_GNUC_CONST; G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module); - + G_END_DECLS #endif /* __DJVU_DOCUMENT_H__ */ diff --git a/backend/djvu/djvu-links.c b/backend/djvu/djvu-links.c index 5999ebcd..da871dac 100644 --- a/backend/djvu/djvu-links.c +++ b/backend/djvu/djvu-links.c @@ -176,12 +176,12 @@ build_tree (const DjvuDocument *djvu_document, iter = miniexp_cdr (iter); } else if ( miniexp_length (iter) >= 2 ) { gchar *utf8_title = NULL; - + /* An entry */ if (!string_from_miniexp (miniexp_car (iter), &title)) goto unknown_entry; if (!string_from_miniexp (miniexp_cadr (iter), &link_dest)) goto unknown_entry; - + if (!g_utf8_validate (title, -1, NULL)) { utf8_title = str_to_utf8 (title); title_markup = g_markup_escape_text (utf8_title, -1); @@ -190,7 +190,7 @@ build_tree (const DjvuDocument *djvu_document, } ev_action = get_djvu_link_action (djvu_document, link_dest, -1); - + if (g_str_has_suffix (link_dest, ".djvu")) { /* FIXME: component file identifiers */ } else if (ev_action) { @@ -236,7 +236,7 @@ get_djvu_hyperlink_area (ddjvu_pageinfo_t *page_info, miniexp_t iter; iter = sexp; - + if ((miniexp_car (iter) == miniexp_symbol ("rect") || miniexp_car (iter) == miniexp_symbol ("oval")) && miniexp_length (iter) == 5) { /* FIXME: get bounding box for (oval) since Atril doesn't support shaped links */ @@ -257,7 +257,7 @@ get_djvu_hyperlink_area (ddjvu_pageinfo_t *page_info, ev_link_mapping->area.y2 = (page_info->height - miny); } else if (miniexp_car (iter) == miniexp_symbol ("poly") && miniexp_length (iter) >= 5 && miniexp_length (iter) % 2 == 1) { - + /* FIXME: get bounding box since Atril doesn't support shaped links */ int minx = G_MAXINT, miny = G_MAXINT; int maxx = G_MININT, maxy = G_MININT; @@ -287,7 +287,7 @@ get_djvu_hyperlink_area (ddjvu_pageinfo_t *page_info, } return TRUE; - + unknown_link: g_warning("DjvuLibre error: Unknown hyperlink area %s", miniexp_to_name(miniexp_car(sexp))); return FALSE; @@ -333,7 +333,7 @@ get_djvu_hyperlink_mapping (DjvuDocument *djvu_document, if (!ev_action) goto unknown_mapping; ev_link_mapping->data = ev_link_new (comment, ev_action); - + return ev_link_mapping; unknown_mapping: @@ -356,7 +356,7 @@ djvu_links_has_document_links (EvDocumentLinks *document_links) ddjvu_miniexp_release (djvu_document->d_document, outline); return TRUE; } - + return FALSE; } @@ -395,7 +395,7 @@ djvu_links_get_links (EvDocumentLinks *document_links, } ddjvu_miniexp_release (djvu_document->d_document, page_annotations); } - + return ev_mapping_list_new (page, retval, (GDestroyNotify)g_object_unref); } @@ -405,13 +405,13 @@ djvu_links_find_link_dest (EvDocumentLinks *document_links, { DjvuDocument *djvu_document = DJVU_DOCUMENT (document_links); EvLinkDest *ev_dest = NULL; - + ev_dest = get_djvu_link_dest (djvu_document, link_name, -1); if (!ev_dest) { g_warning ("DjvuLibre error: unknown link destination %s", link_name); } - + return ev_dest; } @@ -451,6 +451,6 @@ djvu_links_get_links_model (EvDocumentLinks *document_links) ddjvu_miniexp_release (djvu_document->d_document, outline); } - + return model; } diff --git a/backend/djvu/djvu-links.h b/backend/djvu/djvu-links.h index 6cacdd36..151db677 100644 --- a/backend/djvu/djvu-links.h +++ b/backend/djvu/djvu-links.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2006 Pauli Virtanen * * This program is free software; you can redistribute it and/or modify diff --git a/backend/djvu/djvu-text-page.c b/backend/djvu/djvu-text-page.c index d74a3983..90bce25e 100644 --- a/backend/djvu/djvu-text-page.c +++ b/backend/djvu/djvu-text-page.c @@ -29,13 +29,13 @@ * @page: #DjvuTextPage instance * @p: s-expression to append * @delimit: character/word/... delimiter - * + * * Appends the string in @p to the page text. - * + * * Returns: whether the end was not reached in this s-expression */ static gboolean -djvu_text_page_selection_process (DjvuTextPage *page, +djvu_text_page_selection_process (DjvuTextPage *page, miniexp_t p, int delimit) { @@ -43,7 +43,7 @@ djvu_text_page_selection_process (DjvuTextPage *page, char *token_text = (char *) miniexp_to_str (miniexp_nth (5, p)); if (page->text) { char *new_text = - g_strjoin (delimit & 2 ? "\n" : + g_strjoin (delimit & 2 ? "\n" : delimit & 1 ? " " : NULL, page->text, token_text, NULL); @@ -51,7 +51,7 @@ djvu_text_page_selection_process (DjvuTextPage *page, page->text = new_text; } else page->text = g_strdup (token_text); - if (p == page->end) + if (p == page->end) return FALSE; } return TRUE; @@ -62,24 +62,24 @@ djvu_text_page_selection_process (DjvuTextPage *page, * @page: #DjvuTextPage instance * @p: tree to append * @delimit: character/word/... delimiter - * + * * Walks the tree in @p and appends the text with - * djvu_text_page_selection_process() for all s-expressions + * djvu_text_page_selection_process() for all s-expressions * between the start and end fields. - * + * * Returns: whether the end was not reached in this subtree */ static gboolean -djvu_text_page_selection (DjvuTextPage *page, +djvu_text_page_selection (DjvuTextPage *page, miniexp_t p, int delimit) { g_return_val_if_fail (miniexp_consp (p) && miniexp_symbolp (miniexp_car (p)), FALSE); - if (miniexp_car (p) != page->char_symbol) + if (miniexp_car (p) != page->char_symbol) delimit |= miniexp_car (p) == page->word_symbol ? 1 : 2; - + miniexp_t deeper = miniexp_cddr (miniexp_cdddr (p)); while (deeper != miniexp_nil) { miniexp_t str = miniexp_car (deeper); @@ -100,11 +100,11 @@ djvu_text_page_selection (DjvuTextPage *page, static void djvu_text_page_limits_process (DjvuTextPage *page, - miniexp_t p, + miniexp_t p, EvRectangle *rect) { EvRectangle current; - + current.x1 = miniexp_to_int (miniexp_nth (1, p)); current.y1 = miniexp_to_int (miniexp_nth (2, p)); current.x2 = miniexp_to_int (miniexp_nth (3, p)); @@ -120,10 +120,10 @@ djvu_text_page_limits_process (DjvuTextPage *page, static void djvu_text_page_limits (DjvuTextPage *page, - miniexp_t p, + miniexp_t p, EvRectangle *rect) { - g_return_if_fail (miniexp_consp (p) && + g_return_if_fail (miniexp_consp (p) && miniexp_symbolp (miniexp_car (p))); miniexp_t deeper = miniexp_cddr (miniexp_cdddr (p)); @@ -139,20 +139,20 @@ djvu_text_page_limits (DjvuTextPage *page, } char * -djvu_text_page_copy (DjvuTextPage *page, +djvu_text_page_copy (DjvuTextPage *page, EvRectangle *rectangle) { char* text; - + page->start = miniexp_nil; page->end = miniexp_nil; djvu_text_page_limits (page, page->text_structure, rectangle); djvu_text_page_selection (page, page->text_structure, 0); - - /* Do not free the string */ + + /* Do not free the string */ text = page->text; page->text = NULL; - + return text; } @@ -160,14 +160,14 @@ djvu_text_page_copy (DjvuTextPage *page, * djvu_text_page_position: * @page: #DjvuTextPage instance * @position: index in the page text - * - * Returns the closest s-expression that contains the given position in + * + * Returns the closest s-expression that contains the given position in * the page text. - * + * * Returns: closest s-expression */ static miniexp_t -djvu_text_page_position (DjvuTextPage *page, +djvu_text_page_position (DjvuTextPage *page, int position) { GArray *links = page->links; @@ -197,12 +197,12 @@ djvu_text_page_position (DjvuTextPage *page, * djvu_text_page_union: * @target: first rectangle and result * @source: second rectangle - * - * Calculates the bounding box of two rectangles and stores the reuslt + * + * Calculates the bounding box of two rectangles and stores the reuslt * in the first. */ static void -djvu_text_page_union (EvRectangle *target, +djvu_text_page_union (EvRectangle *target, EvRectangle *source) { if (source->x1 < target->x1) @@ -221,15 +221,15 @@ djvu_text_page_union (EvRectangle *target, * @p: s-expression to append * @start: first s-expression in the selection * @end: last s-expression in the selection - * + * * Appends the rectangle defined by @p to the internal bounding box rectangle. - * + * * Returns: whether the end was not reached in this s-expression */ static gboolean -djvu_text_page_sexpr_process (DjvuTextPage *page, +djvu_text_page_sexpr_process (DjvuTextPage *page, miniexp_t p, - miniexp_t start, + miniexp_t start, miniexp_t end) { if (page->bounding_box || p == start) { @@ -256,16 +256,16 @@ djvu_text_page_sexpr_process (DjvuTextPage *page, * @p: tree to append * @start: first s-expression in the selection * @end: last s-expression in the selection - * - * Walks the tree in @p and extends the rectangle with + * + * Walks the tree in @p and extends the rectangle with * djvu_text_page_process() for all s-expressions between @start and @end. - * + * * Returns: whether the end was not reached in this subtree */ static gboolean -djvu_text_page_sexpr (DjvuTextPage *page, +djvu_text_page_sexpr (DjvuTextPage *page, miniexp_t p, - miniexp_t start, + miniexp_t start, miniexp_t end) { g_return_val_if_fail (miniexp_consp (p) && miniexp_symbolp @@ -293,12 +293,12 @@ djvu_text_page_sexpr (DjvuTextPage *page, * @page: #DjvuTextPage instance * @start: first s-expression in the selection * @end: last s-expression in the selection - * + * * Builds a rectangle that contains all s-expressions in the given range. */ static EvRectangle * djvu_text_page_box (DjvuTextPage *page, - miniexp_t start, + miniexp_t start, miniexp_t end) { page->bounding_box = NULL; @@ -312,22 +312,22 @@ djvu_text_page_box (DjvuTextPage *page, * @p: tree to append * @case_sensitive: do not ignore case * @delimit: insert spaces because of higher (sentence/paragraph/...) break - * - * Appends the tree in @p to the internal text string. + * + * Appends the tree in @p to the internal text string. */ static void djvu_text_page_append_text (DjvuTextPage *page, - miniexp_t p, - gboolean case_sensitive, + miniexp_t p, + gboolean case_sensitive, gboolean delimit) { char *token_text; - - g_return_if_fail (miniexp_consp (p) && + + g_return_if_fail (miniexp_consp (p) && miniexp_symbolp (miniexp_car (p))); delimit |= page->char_symbol != miniexp_car (p); - + miniexp_t deeper = miniexp_cddr (miniexp_cdddr (p)); while (deeper != miniexp_nil) { miniexp_t data = miniexp_car (deeper); @@ -354,7 +354,7 @@ djvu_text_page_append_text (DjvuTextPage *page, if (!case_sensitive) g_free (token_text); } else - djvu_text_page_append_text (page, data, + djvu_text_page_append_text (page, data, case_sensitive, delimit); delimit = FALSE; deeper = miniexp_cdr (deeper); @@ -366,12 +366,12 @@ djvu_text_page_append_text (DjvuTextPage *page, * @page: #DjvuTextPage instance * @text: text to search * @case_sensitive: do not ignore case - * - * Searches the page for the given text. The results list has to be + * + * Searches the page for the given text. The results list has to be * externally freed afterwards. */ -void -djvu_text_page_search (DjvuTextPage *page, +void +djvu_text_page_search (DjvuTextPage *page, const char *text, gboolean case_sensitive) { @@ -409,23 +409,23 @@ djvu_text_page_search (DjvuTextPage *page, * djvu_text_page_prepare_search: * @page: #DjvuTextPage instance * @case_sensitive: do not ignore case - * + * * Indexes the page text and prepares the page for subsequent searches. */ void djvu_text_page_prepare_search (DjvuTextPage *page, gboolean case_sensitive) { - djvu_text_page_append_text (page, page->text_structure, - case_sensitive, FALSE); + djvu_text_page_append_text (page, page->text_structure, + case_sensitive, FALSE); } /** * djvu_text_page_new: * @text: S-expression of the page text - * - * Creates a new page to search. - * + * + * Creates a new page to search. + * * Returns: new #DjvuTextPage instance */ DjvuTextPage * @@ -444,10 +444,10 @@ djvu_text_page_new (miniexp_t text) /** * djvu_text_page_free: * @page: #DjvuTextPage instance - * + * * Frees the given #DjvuTextPage instance. */ -void +void djvu_text_page_free (DjvuTextPage *page) { g_free (page->text); diff --git a/backend/djvu/djvu-text-page.h b/backend/djvu/djvu-text-page.h index 5ee85a3e..a25284f5 100644 --- a/backend/djvu/djvu-text-page.h +++ b/backend/djvu/djvu-text-page.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2006 Michael Hofmann * * This program is free software; you can redistribute it and/or modify @@ -46,11 +46,11 @@ struct _DjvuTextLink { miniexp_t pair; }; -char * djvu_text_page_copy (DjvuTextPage *page, +char * djvu_text_page_copy (DjvuTextPage *page, EvRectangle *rectangle); void djvu_text_page_prepare_search (DjvuTextPage *page, gboolean case_sensitive); -void djvu_text_page_search (DjvuTextPage *page, +void djvu_text_page_search (DjvuTextPage *page, const char *text, gboolean case_sensitive); DjvuTextPage* djvu_text_page_new (miniexp_t text); diff --git a/backend/dvi/cairo-device.c b/backend/dvi/cairo-device.c index 9f4badb2..7a639bde 100644 --- a/backend/dvi/cairo-device.c +++ b/backend/dvi/cairo-device.c @@ -33,7 +33,7 @@ typedef struct { gint ymargin; gdouble scale; - + Ulong fg; Ulong bg; @@ -102,7 +102,7 @@ dvi_cairo_draw_rule (DviContext *dvi, cairo_device = (DviCairoDevice *) dvi->device.device_data; color = cairo_device->fg; - + cairo_save (cairo_device->cr); cairo_set_line_width (cairo_device->cr, @@ -158,7 +158,7 @@ dvi_cairo_draw_ps (DviContext *dvi, spectre_render_context_set_scale (rc, (double)width / w, (double)height / h); - spectre_document_render_full (psdoc, rc, &data, &row_length); + spectre_document_render_full (psdoc, rc, &data, &row_length); status = spectre_document_status (psdoc); spectre_render_context_free (rc); @@ -168,7 +168,7 @@ dvi_cairo_draw_ps (DviContext *dvi, g_warning ("Error rendering PS document %s: %s\n", filename, spectre_status_to_string (status)); free (data); - + return; } @@ -182,7 +182,7 @@ dvi_cairo_draw_ps (DviContext *dvi, cairo_translate (cairo_device->cr, x + cairo_device->xmargin, y + cairo_device->ymargin); - cairo_set_source_surface (cairo_device->cr, image, 0, 0); + cairo_set_source_surface (cairo_device->cr, image, 0, 0); cairo_paint (cairo_device->cr); cairo_restore (cairo_device->cr); @@ -215,7 +215,7 @@ dvi_cairo_alloc_colors (void *device_data, frac = (gamma > 0) ? pow ((double)i / n, 1 / gamma) : 1 - pow ((double)(n - i) / n, -gamma); - + color.red = frac * color_fg.red; color.green = frac * color_fg.green; color.blue = frac * color_fg.blue; diff --git a/backend/dvi/dvi-document.c b/backend/dvi/dvi-document.c index 6051b7b1..1a84fe72 100644 --- a/backend/dvi/dvi-document.c +++ b/backend/dvi/dvi-document.c @@ -54,11 +54,11 @@ struct _DviDocument DviContext *context; DviPageSpec *spec; DviParams *params; - + /* To let document scale we should remember width and height */ double base_width; double base_height; - + gchar *uri; /* PDF exporter */ @@ -87,11 +87,11 @@ dvi_document_load (EvDocument *document, { gchar *filename; DviDocument *dvi_document = DVI_DOCUMENT(document); - + filename = g_filename_from_uri (uri, NULL, error); if (!filename) return FALSE; - + g_mutex_lock (&dvi_context_mutex); if (dvi_document->context) mdvi_destroy_context (dvi_document->context); @@ -99,7 +99,7 @@ dvi_document_load (EvDocument *document, dvi_document->context = mdvi_init_context(dvi_document->params, dvi_document->spec, filename); g_mutex_unlock (&dvi_context_mutex); g_free (filename); - + if (!dvi_document->context) { g_set_error_literal (error, EV_DOCUMENT_ERROR, @@ -107,19 +107,19 @@ dvi_document_load (EvDocument *document, _("DVI document has incorrect format")); return FALSE; } - + mdvi_cairo_device_init (&dvi_document->context->device); - - - dvi_document->base_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv + + + dvi_document->base_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv + 2 * unit2pix(dvi_document->params->dpi, MDVI_HMARGIN) / dvi_document->params->hshrink; - - dvi_document->base_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv + + dvi_document->base_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv + 2 * unit2pix(dvi_document->params->vdpi, MDVI_VMARGIN) / dvi_document->params->vshrink; - + g_free (dvi_document->uri); dvi_document->uri = g_strdup (uri); - + return TRUE; } @@ -138,7 +138,7 @@ static int dvi_document_get_n_pages (EvDocument *document) { DviDocument *dvi_document = DVI_DOCUMENT (document); - + return dvi_document->context->npages; } @@ -148,7 +148,7 @@ dvi_document_get_page_size (EvDocument *document, double *width, double *height) { - DviDocument *dvi_document = DVI_DOCUMENT (document); + DviDocument *dvi_document = DVI_DOCUMENT (document); *width = dvi_document->base_width; *height = dvi_document->base_height;; @@ -165,15 +165,15 @@ dvi_document_render (EvDocument *document, gint proposed_width, proposed_height; gint xmargin = 0, ymargin = 0; - /* We should protect our context since it's not - * thread safe. The work to the future - + /* We should protect our context since it's not + * thread safe. The work to the future - * let context render page independently */ g_mutex_lock (&dvi_context_mutex); - + mdvi_setpage (dvi_document->context, rc->page->index); - - mdvi_set_shrink (dvi_document->context, + + mdvi_set_shrink (dvi_document->context, (int)((dvi_document->params->hshrink - 1) / rc->scale) + 1, (int)((dvi_document->params->vshrink - 1) / rc->scale) + 1); @@ -181,12 +181,12 @@ dvi_document_render (EvDocument *document, required_height = dvi_document->base_height * rc->scale + 0.5; proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv; proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv; - + if (required_width >= proposed_width) xmargin = (required_width - proposed_width) / 2; if (required_height >= proposed_height) ymargin = (required_height - proposed_height) / 2; - + mdvi_cairo_device_set_margins (&dvi_document->context->device, xmargin, ymargin); mdvi_cairo_device_set_scale (&dvi_document->context->device, rc->scale); mdvi_cairo_device_render (dvi_document->context); @@ -196,18 +196,18 @@ dvi_document_render (EvDocument *document, rotated_surface = ev_document_misc_surface_rotate_and_scale (surface, required_width, - required_height, + required_height, rc->rotation); cairo_surface_destroy (surface); - + return rotated_surface; } static void dvi_document_finalize (GObject *object) -{ +{ DviDocument *dvi_document = DVI_DOCUMENT(object); - + g_mutex_lock (&dvi_context_mutex); if (dvi_document->context) { mdvi_cairo_device_free (&dvi_document->context->device); @@ -220,12 +220,12 @@ dvi_document_finalize (GObject *object) if (dvi_document->exporter_filename) g_free (dvi_document->exporter_filename); - + if (dvi_document->exporter_opts) g_string_free (dvi_document->exporter_opts, TRUE); g_free (dvi_document->uri); - + G_OBJECT_CLASS (dvi_document_parent_class)->finalize (object); } @@ -258,10 +258,10 @@ dvi_document_class_init (DviDocumentClass *klass) static void dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, - EvRenderContext *rc, + EvRenderContext *rc, gint *width, gint *height) -{ +{ DviDocument *dvi_document = DVI_DOCUMENT (document); gdouble page_width = dvi_document->base_width; gdouble page_height = dvi_document->base_height; @@ -277,7 +277,7 @@ dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, static GdkPixbuf * dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, - EvRenderContext *rc, + EvRenderContext *rc, gboolean border) { DviDocument *dvi_document = DVI_DOCUMENT (document); @@ -291,24 +291,24 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, thumb_height = (gint) (dvi_document->base_height * rc->scale); g_mutex_lock (&dvi_context_mutex); - + mdvi_setpage (dvi_document->context, rc->page->index); - mdvi_set_shrink (dvi_document->context, + mdvi_set_shrink (dvi_document->context, (int)dvi_document->base_width * dvi_document->params->hshrink / thumb_width, (int)dvi_document->base_height * dvi_document->params->vshrink / thumb_height); proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv; proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv; - + if (border) { - mdvi_cairo_device_set_margins (&dvi_document->context->device, + mdvi_cairo_device_set_margins (&dvi_document->context->device, MAX (thumb_width - proposed_width, 0) / 2, - MAX (thumb_height - proposed_height, 0) / 2); + MAX (thumb_height - proposed_height, 0) / 2); } else { - mdvi_cairo_device_set_margins (&dvi_document->context->device, + mdvi_cairo_device_set_margins (&dvi_document->context->device, MAX (thumb_width - proposed_width - 2, 0) / 2, - MAX (thumb_height - proposed_height - 2, 0) / 2); + MAX (thumb_height - proposed_height - 2, 0) / 2); } mdvi_cairo_device_set_scale (&dvi_document->context->device, rc->scale); @@ -345,11 +345,11 @@ dvi_document_file_exporter_begin (EvFileExporter *exporter, EvFileExporterContext *fc) { DviDocument *dvi_document = DVI_DOCUMENT(exporter); - + if (dvi_document->exporter_filename) - g_free (dvi_document->exporter_filename); + g_free (dvi_document->exporter_filename); dvi_document->exporter_filename = g_strdup (fc->filename); - + if (dvi_document->exporter_opts) { g_string_free (dvi_document->exporter_opts, TRUE); } @@ -372,16 +372,16 @@ dvi_document_file_exporter_end (EvFileExporter *exporter) gint exit_stat; GError *err = NULL; gboolean success; - + DviDocument *dvi_document = DVI_DOCUMENT(exporter); gchar* quoted_filename = g_shell_quote (dvi_document->context->filename); - + command_line = g_strdup_printf ("dvipdfm %s -o %s %s", /* dvipdfm -s 1,2,.., -o exporter_filename dvi_filename */ dvi_document->exporter_opts->str, dvi_document->exporter_filename, quoted_filename); g_free (quoted_filename); - + success = g_spawn_command_line_sync (command_line, NULL, NULL, @@ -469,7 +469,7 @@ hsb2rgb (float h, float s, float v, guchar *red, guchar *green, guchar *blue) *red = (guchar)floor(r * 255.0); *green = (guchar)floor(g * 255.0); *blue = (guchar)floor(b * 255.0); - + return TRUE; } @@ -498,7 +498,7 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char * } else if (strncmp (arg, "push", 4) == 0) { /* Find color source: Named, CMYK or RGB */ const char *tmp = arg + 4; - + while (isspace (*tmp)) tmp++; if (!strncmp ("rgb", tmp, 3)) { @@ -506,7 +506,7 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char * guchar red, green, blue; parse_color (tmp + 4, rgb, 3); - + red = 255 * rgb[0]; green = 255 * rgb[1]; blue = 255 * rgb[2]; @@ -517,14 +517,14 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char * guchar red, green, blue; parse_color (tmp + 4, hsb, 3); - + if (hsb2rgb (hsb[0], hsb[1], hsb[2], &red, &green, &blue)) mdvi_push_color (dvi, RGB2ULONG (red, green, blue), 0xFFFFFFFF); } else if (!strncmp ("cmyk", tmp, 4)) { gdouble cmyk[4]; double r, g, b; guchar red, green, blue; - + parse_color (tmp + 5, cmyk, 4); r = 1.0 - cmyk[0] - cmyk[3]; @@ -540,7 +540,7 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char * red = r * 255 + 0.5; green = g * 255 + 0.5; blue = b * 255 + 0.5; - + mdvi_push_color (dvi, RGB2ULONG (red, green, blue), 0xFFFFFFFF); } else if (!strncmp ("gray ", tmp, 5)) { gdouble gray; @@ -553,7 +553,7 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char * mdvi_push_color (dvi, RGB2ULONG (rgb, rgb, rgb), 0xFFFFFFFF); } else { GdkColor color; - + if (gdk_color_parse (tmp, &color)) { guchar red, green, blue; @@ -569,8 +569,8 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char * static void dvi_document_init_params (DviDocument *dvi_document) -{ - dvi_document->params = g_new0 (DviParams, 1); +{ + dvi_document->params = g_new0 (DviParams, 1); dvi_document->params->dpi = MDVI_DPI; dvi_document->params->vdpi = MDVI_VDPI; @@ -585,7 +585,7 @@ dvi_document_init_params (DviDocument *dvi_document) dvi_document->params->orientation = MDVI_ORIENT_TBLR; dvi_document->spec = NULL; - + dvi_document->params->bg = 0xffffffff; dvi_document->params->fg = 0xff000000; } diff --git a/backend/dvi/dvi-document.h b/backend/dvi/dvi-document.h index a84e892d..d39c39ea 100644 --- a/backend/dvi/dvi-document.h +++ b/backend/dvi/dvi-document.h @@ -32,7 +32,7 @@ typedef struct _DviDocument DviDocument; GType dvi_document_get_type (void) G_GNUC_CONST; G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module); - + G_END_DECLS #endif /* __DVI_DOCUMENT_H__ */ diff --git a/backend/dvi/fonts.c b/backend/dvi/fonts.c index 99be63ce..7c15f8d7 100644 --- a/backend/dvi/fonts.c +++ b/backend/dvi/fonts.c @@ -44,7 +44,7 @@ static struct fontinfo { void mdvi_register_fonts (void) { struct fontinfo *type; - + if (!registered) { for(type = known_fonts; type->info; type++) { mdvi_register_font_type(type->info, type->klass); diff --git a/backend/dvi/mdvi-lib/afmparse.c b/backend/dvi/mdvi-lib/afmparse.c index f90e5575..f8d840b7 100644 --- a/backend/dvi/mdvi-lib/afmparse.c +++ b/backend/dvi/mdvi-lib/afmparse.c @@ -2,25 +2,25 @@ * (C) 1988, 1989, 1990 by Adobe Systems Incorporated. All rights reserved. * * This file may be freely copied and redistributed as long as: - * 1) This entire notice continues to be included in the file, + * 1) This entire notice continues to be included in the file, * 2) If the file has been modified in any way, a notice of such * modification is conspicuously indicated. * * PostScript, Display PostScript, and Adobe are registered trademarks of * Adobe Systems Incorporated. - * + * * ************************************************************************ * THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO CHANGE WITHOUT * NOTICE, AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY ADOBE SYSTEMS - * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR - * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY - * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, - * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, + * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR + * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY + * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, + * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, * FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. * ************************************************************************ */ -/* +/* * modified for MDVI: * - some names changed to avoid conflicts with T1lib * - changed to ANSI C prototypes, as used by MDVI @@ -28,13 +28,13 @@ */ /* parseAFM.c - * + * * This file is used in conjuction with the parseAFM.h header file. * This file contains several procedures that are used to parse AFM * files. It is intended to work with an application program that needs * font metric information. The program can be used as is by making a * procedure call to "parseFile" (passing in the expected parameters) - * and having it fill in a data structure with the data from the + * and having it fill in a data structure with the data from the * AFM file, or an application developer may wish to customize this * code. * @@ -70,7 +70,7 @@ #include #include "afmparse.h" #undef VERSION - + #define lineterm EOL /* line terminating character */ #define normalEOF 1 /* return code from parsing routines used only */ /* in this module */ @@ -88,39 +88,39 @@ static char *ident = NULL; /* storage buffer for keywords */ -/* "shorts" for fast case statement +/* "shorts" for fast case statement * The values of each of these enumerated items correspond to an entry in the - * table of strings defined below. Therefore, if you add a new string as + * table of strings defined below. Therefore, if you add a new string as * new keyword into the keyStrings table, you must also add a corresponding * parseKey AND it MUST be in the same position! * * IMPORTANT: since the sorting algorithm is a binary search, the strings of - * keywords must be placed in lexicographical order, below. [Therefore, the - * enumerated items are not necessarily in lexicographical order, depending - * on the name chosen. BUT, they must be placed in the same position as the - * corresponding key string.] The NOPE shall remain in the last position, - * since it does not correspond to any key string, and it is used in the + * keywords must be placed in lexicographical order, below. [Therefore, the + * enumerated items are not necessarily in lexicographical order, depending + * on the name chosen. BUT, they must be placed in the same position as the + * corresponding key string.] The NOPE shall remain in the last position, + * since it does not correspond to any key string, and it is used in the * "recognize" procedure to calculate how many possible keys there are. */ enum parseKey { - ASCENDER, CHARBBOX, CODE, COMPCHAR, CAPHEIGHT, COMMENT, - DESCENDER, ENCODINGSCHEME, ENDCHARMETRICS, ENDCOMPOSITES, - ENDFONTMETRICS, ENDKERNDATA, ENDKERNPAIRS, ENDTRACKKERN, - FAMILYNAME, FONTBBOX, FONTNAME, FULLNAME, ISFIXEDPITCH, - ITALICANGLE, KERNPAIR, KERNPAIRXAMT, LIGATURE, CHARNAME, - NOTICE, COMPCHARPIECE, STARTCHARMETRICS, STARTCOMPOSITES, - STARTFONTMETRICS, STARTKERNDATA, STARTKERNPAIRS, - STARTTRACKKERN, TRACKKERN, UNDERLINEPOSITION, + ASCENDER, CHARBBOX, CODE, COMPCHAR, CAPHEIGHT, COMMENT, + DESCENDER, ENCODINGSCHEME, ENDCHARMETRICS, ENDCOMPOSITES, + ENDFONTMETRICS, ENDKERNDATA, ENDKERNPAIRS, ENDTRACKKERN, + FAMILYNAME, FONTBBOX, FONTNAME, FULLNAME, ISFIXEDPITCH, + ITALICANGLE, KERNPAIR, KERNPAIRXAMT, LIGATURE, CHARNAME, + NOTICE, COMPCHARPIECE, STARTCHARMETRICS, STARTCOMPOSITES, + STARTFONTMETRICS, STARTKERNDATA, STARTKERNPAIRS, + STARTTRACKKERN, TRACKKERN, UNDERLINEPOSITION, UNDERLINETHICKNESS, VERSION, XYWIDTH, XWIDTH, WEIGHT, XHEIGHT, NOPE } ; -/* keywords for the system: +/* keywords for the system: * This a table of all of the current strings that are vaild AFM keys. * Each entry can be referenced by the appropriate parseKey value (an - * enumerated data type defined above). If you add a new keyword here, + * enumerated data type defined above). If you add a new keyword here, * a corresponding parseKey MUST be added to the enumerated data type - * defined above, AND it MUST be added in the same position as the + * defined above, AND it MUST be added in the same position as the * string is in this table. * * IMPORTANT: since the sorting algorithm is a binary search, the keywords @@ -130,36 +130,36 @@ enum parseKey { static char *keyStrings[] = { "Ascender", "B", "C", "CC", "CapHeight", "Comment", - "Descender", "EncodingScheme", "EndCharMetrics", "EndComposites", - "EndFontMetrics", "EndKernData", "EndKernPairs", "EndTrackKern", - "FamilyName", "FontBBox", "FontName", "FullName", "IsFixedPitch", - "ItalicAngle", "KP", "KPX", "L", "N", - "Notice", "PCC", "StartCharMetrics", "StartComposites", - "StartFontMetrics", "StartKernData", "StartKernPairs", - "StartTrackKern", "TrackKern", "UnderlinePosition", + "Descender", "EncodingScheme", "EndCharMetrics", "EndComposites", + "EndFontMetrics", "EndKernData", "EndKernPairs", "EndTrackKern", + "FamilyName", "FontBBox", "FontName", "FullName", "IsFixedPitch", + "ItalicAngle", "KP", "KPX", "L", "N", + "Notice", "PCC", "StartCharMetrics", "StartComposites", + "StartFontMetrics", "StartKernData", "StartKernPairs", + "StartTrackKern", "TrackKern", "UnderlinePosition", "UnderlineThickness", "Version", "W", "WX", "Weight", "XHeight", NULL }; - -/*************************** PARSING ROUTINES **************/ - + +/*************************** PARSING ROUTINES **************/ + /*************************** token *************************/ /* A "AFM File Conventions" tokenizer. That means that it will * return the next token delimited by white space. See also - * the `linetoken' routine, which does a similar thing but + * the `linetoken' routine, which does a similar thing but * reads all tokens until the next end-of-line. */ - + static char *token(FILE *stream) { int ch, idx; /* skip over white space */ - while ((ch = fgetc(stream)) == ' ' || ch == lineterm || + while ((ch = fgetc(stream)) == ' ' || ch == lineterm || ch == ',' || ch == '\t' || ch == ';'); - + idx = 0; - while (ch != EOF && ch != ' ' && ch != lineterm + while (ch != EOF && ch != ' ' && ch != lineterm && ch != '\t' && ch != ':' && ch != ';' && idx < (MAX_NAME - 1)) { ident[idx++] = ch; @@ -170,7 +170,7 @@ static char *token(FILE *stream) if (idx >= 1 && ch != ':' ) ungetc(ch, stream); if (idx < 1 ) ident[idx++] = ch; /* single-character token */ ident[idx] = 0; - + return(ident); /* returns pointer to the token */ } /* token */ @@ -187,15 +187,15 @@ static char *linetoken(FILE *stream) { int ch, idx; - while ((ch = fgetc(stream)) == ' ' || ch == '\t' ); - + while ((ch = fgetc(stream)) == ' ' || ch == '\t' ); + idx = 0; while (ch != EOF && ch != lineterm && idx < (MAX_NAME - 1)) { ident[idx++] = ch; ch = fgetc(stream); } /* while */ - + ungetc(ch, stream); ident[idx] = 0; @@ -207,7 +207,7 @@ static char *linetoken(FILE *stream) /*************************** recognize *************************/ /* This function tries to match a string to a known list of - * valid AFM entries (check the keyStrings array above). + * valid AFM entries (check the keyStrings array above). * "ident" contains everything from white space through the * next space, tab, or ":" character. * @@ -231,7 +231,7 @@ static enum parseKey recognize(char *ident) if (found) return (enum parseKey) midpoint; else return NOPE; - + } /* recognize */ @@ -240,32 +240,32 @@ static enum parseKey recognize(char *ident) /* This function is called by "parseFile". It will parse the AFM File * up to the "StartCharMetrics" keyword, which essentially marks the * end of the Global Font Information and the beginning of the character - * metrics information. + * metrics information. * * If the caller of "parseFile" specified that it wanted the Global * Font Information (as defined by the "AFM File Specification" - * document), then that information will be stored in the returned + * document), then that information will be stored in the returned * data structure. * - * Any Global Font Information entries that are not found in a + * Any Global Font Information entries that are not found in a * given file, will have the usual default initialization value * for its type (i.e. entries of type int will be 0, etc). * - * This function returns an error code specifying whether there was - * a premature EOF or a parsing error. This return value is used by + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by * parseFile to determine if there is more file to parse. */ - + static BOOL parseGlobals(FILE *fp, GlobalFontInfo *gfi) -{ +{ BOOL cont = TRUE, save = (gfi != NULL); int error = ok; register char *keyword; - + while (cont) { keyword = token(fp); - + if (keyword == NULL) /* Have reached an early and unexpected EOF. */ /* Set flag and stop parsing */ @@ -273,15 +273,15 @@ static BOOL parseGlobals(FILE *fp, GlobalFontInfo *gfi) error = earlyEOF; break; /* get out of loop */ } - if (!save) + if (!save) /* get tokens until the end of the Global Font info section */ /* without saving any of the data */ - switch (recognize(keyword)) - { + switch (recognize(keyword)) + { case STARTCHARMETRICS: cont = FALSE; break; - case ENDFONTMETRICS: + case ENDFONTMETRICS: cont = FALSE; error = normalEOF; break; @@ -308,20 +308,20 @@ static BOOL parseGlobals(FILE *fp, GlobalFontInfo *gfi) break; case ENCODINGSCHEME: keyword = token(fp); - gfi->encodingScheme = (char *) + gfi->encodingScheme = (char *) malloc(strlen(keyword) + 1); strcpy(gfi->encodingScheme, keyword); - break; + break; case FULLNAME: keyword = linetoken(fp); gfi->fullName = (char *) malloc(strlen(keyword) + 1); strcpy(gfi->fullName, keyword); - break; - case FAMILYNAME: + break; + case FAMILYNAME: keyword = linetoken(fp); gfi->familyName = (char *) malloc(strlen(keyword) + 1); strcpy(gfi->familyName, keyword); - break; + break; case WEIGHT: keyword = token(fp); gfi->weight = (char *) malloc(strlen(keyword) + 1); @@ -336,13 +336,13 @@ static BOOL parseGlobals(FILE *fp, GlobalFontInfo *gfi) keyword = token(fp); if (MATCH(keyword, False)) gfi->isFixedPitch = 0; - else + else gfi->isFixedPitch = 1; - break; + break; case UNDERLINEPOSITION: keyword = token(fp); gfi->underlinePosition = atoi(keyword); - break; + break; case UNDERLINETHICKNESS: keyword = token(fp); gfi->underlineThickness = atoi(keyword); @@ -351,12 +351,12 @@ static BOOL parseGlobals(FILE *fp, GlobalFontInfo *gfi) keyword = token(fp); gfi->version = (char *) malloc(strlen(keyword) + 1); strcpy(gfi->version, keyword); - break; + break; case NOTICE: keyword = linetoken(fp); gfi->notice = (char *) malloc(strlen(keyword) + 1); strcpy(gfi->notice, keyword); - break; + break; case FONTBBOX: keyword = token(fp); gfi->fontBBox.llx = atoi(keyword); @@ -396,10 +396,10 @@ static BOOL parseGlobals(FILE *fp, GlobalFontInfo *gfi) break; } /* switch */ } /* while */ - + return(error); - -} /* parseGlobals */ + +} /* parseGlobals */ @@ -409,26 +409,26 @@ static BOOL parseGlobals(FILE *fp, GlobalFontInfo *gfi) /* Unmapped character codes are (at Adobe Systems) assigned the * width of the space character (if one exists) else they get the * value of 250 ems. This function initializes all entries in the - * char widths array to have this value. Then any mapped character - * codes will be replaced with the width of the appropriate character + * char widths array to have this value. Then any mapped character + * codes will be replaced with the width of the appropriate character * when parsing the character metric section. - + * This function parses the Character Metrics Section looking * for a space character (by comparing character names). If found, * the width of the space character will be used to initialize the - * values in the array of character widths. + * values in the array of character widths. * * Before returning, the position of the read/write pointer of the * file is reset to be where it was upon entering this function. */ - + static int initializeArray(FILE *fp, int *cwi) -{ +{ BOOL cont = TRUE, found = FALSE; long opos = ftell(fp); int code = 0, width = 0, i = 0, error = 0; register char *keyword; - + while (cont) { keyword = token(fp); @@ -448,67 +448,67 @@ static int initializeArray(FILE *fp, int *cwi) case XWIDTH: width = atoi(token(fp)); break; - case CHARNAME: + case CHARNAME: keyword = token(fp); if (MATCH(keyword, Space)) - { + { cont = FALSE; found = TRUE; - } - break; + } + break; case ENDCHARMETRICS: cont = FALSE; - break; + break; case ENDFONTMETRICS: cont = FALSE; error = normalEOF; break; case NOPE: - default: + default: error = parseError; break; } /* switch */ } /* while */ - + if (!found) width = 250; - + for (i = 0; i < 256; ++i) cwi[i] = width; - + fseek(fp, opos, 0); - + return(error); - -} /* initializeArray */ + +} /* initializeArray */ #endif /* unused */ /************************* parseCharWidths **************************/ /* This function is called by "parseFile". It will parse the AFM File - * up to the "EndCharMetrics" keyword. It will save the character + * up to the "EndCharMetrics" keyword. It will save the character * width info (as opposed to all of the character metric information) * if requested by the caller of parseFile. Otherwise, it will just * parse through the section without saving any information. * - * If data is to be saved, parseCharWidths is passed in a pointer + * If data is to be saved, parseCharWidths is passed in a pointer * to an array of widths that has already been initialized by the * standard value for unmapped character codes. This function parses * the Character Metrics section only storing the width information * for the encoded characters into the array using the character code * as the index into that array. * - * This function returns an error code specifying whether there was - * a premature EOF or a parsing error. This return value is used by + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by * parseFile to determine if there is more file to parse. */ - + static int parseCharWidths(FILE *fp, int *cwi) -{ +{ BOOL cont = TRUE, save = (cwi != NULL); int pos = 0, error = ok; register char *keyword; - + while (cont) { keyword = token(fp); @@ -519,19 +519,19 @@ static int parseCharWidths(FILE *fp, int *cwi) error = earlyEOF; break; /* get out of loop */ } - if (!save) + if (!save) /* get tokens until the end of the Char Metrics section without */ /* saving any of the data*/ - switch (recognize(keyword)) - { + switch (recognize(keyword)) + { case ENDCHARMETRICS: cont = FALSE; - break; + break; case ENDFONTMETRICS: cont = FALSE; error = normalEOF; break; - default: + default: break; } /* switch */ else @@ -558,15 +558,15 @@ static int parseCharWidths(FILE *fp, int *cwi) break; case ENDCHARMETRICS: cont = FALSE; - break; + break; case ENDFONTMETRICS: cont = FALSE; error = normalEOF; break; case CHARNAME: /* eat values (so doesn't cause parseError) */ - keyword = token(fp); + keyword = token(fp); break; - case CHARBBOX: + case CHARBBOX: keyword = token(fp); keyword = token(fp); keyword = token(fp); keyword = token(fp); break; @@ -574,15 +574,15 @@ static int parseCharWidths(FILE *fp, int *cwi) keyword = token(fp); keyword = token(fp); break; case NOPE: - default: + default: error = parseError; break; } /* switch */ } /* while */ - + return(error); - -} /* parseCharWidths */ + +} /* parseCharWidths */ /************************* parseCharMetrics ************************/ @@ -594,21 +594,21 @@ static int parseCharWidths(FILE *fp, int *cwi) * parseCharMetrics is passed in a pointer to an array of records * to hold information on a per character basis. This function * parses the Character Metrics section storing all character - * metric information for the ALL characters (mapped and unmapped) + * metric information for the ALL characters (mapped and unmapped) * into the array. * - * This function returns an error code specifying whether there was - * a premature EOF or a parsing error. This return value is used by + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by * parseFile to determine if there is more file to parse. */ - + static int parseCharMetrics(FILE *fp, FontInfo *fi) -{ +{ BOOL cont = TRUE, firstTime = TRUE; int error = ok, count = 0; register CharMetricInfo *temp = fi->cmi; register char *keyword; - + while (cont) { keyword = token(fp); @@ -621,10 +621,10 @@ static int parseCharMetrics(FILE *fp, FontInfo *fi) { case COMMENT: keyword = linetoken(fp); - break; + break; case CODE: if (count < fi->numOfChars) - { + { if (firstTime) firstTime = FALSE; else temp++; temp->code = atoi(token(fp)); @@ -639,16 +639,16 @@ static int parseCharMetrics(FILE *fp, FontInfo *fi) case XYWIDTH: temp->wx = atoi(token(fp)); temp->wy = atoi(token(fp)); - break; - case XWIDTH: + break; + case XWIDTH: temp->wx = atoi(token(fp)); break; - case CHARNAME: + case CHARNAME: keyword = token(fp); temp->name = (char *) malloc(strlen(keyword) + 1); strcpy(temp->name, keyword); - break; - case CHARBBOX: + break; + case CHARBBOX: temp->charBBox.llx = atoi(token(fp)); temp->charBBox.lly = atoi(token(fp)); temp->charBBox.urx = atoi(token(fp)); @@ -657,14 +657,14 @@ static int parseCharMetrics(FILE *fp, FontInfo *fi) case LIGATURE: { Ligature **tail = &(temp->ligs); Ligature *node = *tail; - + if (*tail != NULL) { while (node->next != NULL) node = node->next; - tail = &(node->next); + tail = &(node->next); } - + *tail = (Ligature *) calloc(1, sizeof(Ligature)); keyword = token(fp); (*tail)->succ = (char *) malloc(strlen(keyword) + 1); @@ -675,52 +675,52 @@ static int parseCharMetrics(FILE *fp, FontInfo *fi) break; } case ENDCHARMETRICS: cont = FALSE;; - break; - case ENDFONTMETRICS: + break; + case ENDFONTMETRICS: cont = FALSE; error = normalEOF; - break; + break; case NOPE: default: - error = parseError; - break; + error = parseError; + break; } /* switch */ } /* while */ - + if ((error == ok) && (count != fi->numOfChars)) error = parseError; - + return(error); - -} /* parseCharMetrics */ + +} /* parseCharMetrics */ /************************* parseTrackKernData ***********************/ -/* This function is called by "parseFile". It will parse the AFM File +/* This function is called by "parseFile". It will parse the AFM File * up to the "EndTrackKern" or "EndKernData" keywords. It will save the * track kerning data if requested by the caller of parseFile. * * parseTrackKernData is passed in a pointer to the FontInfo record. - * If data is to be saved, the FontInfo record will already contain + * If data is to be saved, the FontInfo record will already contain * a valid pointer to storage for the track kerning data. * - * This function returns an error code specifying whether there was - * a premature EOF or a parsing error. This return value is used by + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by * parseFile to determine if there is more file to parse. */ - + static int parseTrackKernData(FILE *fp, FontInfo *fi) -{ +{ BOOL cont = TRUE, save = (fi->tkd != NULL); int pos = 0, error = ok, tcount = 0; register char *keyword; - + while (cont) { keyword = token(fp); - + if (keyword == NULL) { error = earlyEOF; @@ -789,40 +789,40 @@ static int parseTrackKernData(FILE *fp, FontInfo *fi) break; } /* switch */ } /* while */ - + if (error == ok && tcount != fi->numOfTracks) error = parseError; - + return(error); - -} /* parseTrackKernData */ + +} /* parseTrackKernData */ /************************* parsePairKernData ************************/ -/* This function is called by "parseFile". It will parse the AFM File +/* This function is called by "parseFile". It will parse the AFM File * up to the "EndKernPairs" or "EndKernData" keywords. It will save * the pair kerning data if requested by the caller of parseFile. * * parsePairKernData is passed in a pointer to the FontInfo record. - * If data is to be saved, the FontInfo record will already contain + * If data is to be saved, the FontInfo record will already contain * a valid pointer to storage for the pair kerning data. * - * This function returns an error code specifying whether there was - * a premature EOF or a parsing error. This return value is used by + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by * parseFile to determine if there is more file to parse. */ - + static int parsePairKernData(FILE *fp, FontInfo *fi) -{ +{ BOOL cont = TRUE, save = (fi->pkd != NULL); int pos = 0, error = ok, pcount = 0; register char *keyword; - + while (cont) { keyword = token(fp); - + if (keyword == NULL) { error = earlyEOF; @@ -856,11 +856,11 @@ static int parsePairKernData(FILE *fp, FontInfo *fi) if (pcount < fi->numOfPairs) { keyword = token(fp); - fi->pkd[pos].name1 = (char *) + fi->pkd[pos].name1 = (char *) malloc(strlen(keyword) + 1); strcpy(fi->pkd[pos].name1, keyword); keyword = token(fp); - fi->pkd[pos].name2 = (char *) + fi->pkd[pos].name2 = (char *) malloc(strlen(keyword) + 1); strcpy(fi->pkd[pos].name2, keyword); keyword = token(fp); @@ -879,11 +879,11 @@ static int parsePairKernData(FILE *fp, FontInfo *fi) if (pcount < fi->numOfPairs) { keyword = token(fp); - fi->pkd[pos].name1 = (char *) + fi->pkd[pos].name1 = (char *) malloc(strlen(keyword) + 1); strcpy(fi->pkd[pos].name1, keyword); keyword = token(fp); - fi->pkd[pos].name2 = (char *) + fi->pkd[pos].name2 = (char *) malloc(strlen(keyword) + 1); strcpy(fi->pkd[pos].name2, keyword); keyword = token(fp); @@ -910,39 +910,39 @@ static int parsePairKernData(FILE *fp, FontInfo *fi) break; } /* switch */ } /* while */ - + if (error == ok && pcount != fi->numOfPairs) error = parseError; - + return(error); - -} /* parsePairKernData */ + +} /* parsePairKernData */ /************************* parseCompCharData **************************/ -/* This function is called by "parseFile". It will parse the AFM File - * up to the "EndComposites" keyword. It will save the composite +/* This function is called by "parseFile". It will parse the AFM File + * up to the "EndComposites" keyword. It will save the composite * character data if requested by the caller of parseFile. * - * parseCompCharData is passed in a pointer to the FontInfo record, and + * parseCompCharData is passed in a pointer to the FontInfo record, and * a boolean representing if the data should be saved. * * This function will create the appropriate amount of storage for * the composite character data and store a pointer to the storage * in the FontInfo record. * - * This function returns an error code specifying whether there was - * a premature EOF or a parsing error. This return value is used by + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by * parseFile to determine if there is more file to parse. */ - + static int parseCompCharData(FILE *fp, FontInfo *fi) -{ +{ BOOL cont = TRUE, firstTime = TRUE, save = (fi->ccd != NULL); int pos = 0, j = 0, error = ok, ccount = 0, pcount = 0; register char *keyword; - + while (cont) { keyword = token(fp); @@ -990,7 +990,7 @@ static int parseCompCharData(FILE *fp, FontInfo *fi) pcount = 0; if (firstTime) firstTime = FALSE; else pos++; - fi->ccd[pos].ccName = (char *) + fi->ccd[pos].ccName = (char *) malloc(strlen(keyword) + 1); strcpy(fi->ccd[pos].ccName, keyword); keyword = token(fp); @@ -1010,7 +1010,7 @@ static int parseCompCharData(FILE *fp, FontInfo *fi) if (pcount < fi->ccd[pos].numOfPieces) { keyword = token(fp); - fi->ccd[pos].pieces[j].pccName = (char *) + fi->ccd[pos].pieces[j].pccName = (char *) malloc(strlen(keyword) + 1); strcpy(fi->ccd[pos].pieces[j].pccName, keyword); keyword = token(fp); @@ -1035,23 +1035,23 @@ static int parseCompCharData(FILE *fp, FontInfo *fi) break; } /* switch */ } /* while */ - + if (error == ok && ccount != fi->numOfComps) error = parseError; - + return(error); - -} /* parseCompCharData */ + +} /* parseCompCharData */ -/*************************** 'PUBLIC' FUNCTION ********************/ +/*************************** 'PUBLIC' FUNCTION ********************/ /*************************** parseFile *****************************/ -/* parseFile is the only 'public' procedure available. It is called +/* parseFile is the only 'public' procedure available. It is called * from an application wishing to get information from an AFM file. * The caller of this function is responsible for locating and opening * an AFM file and handling all errors associated with that task. @@ -1061,43 +1061,43 @@ static int parseCompCharData(FILE *fp, FontInfo *fi) * the data requested filled in), and a mask specifying which * data from the AFM File should be saved in the FontInfo structure. * - * The file will be parsed and the requested data will be stored in + * The file will be parsed and the requested data will be stored in * a record of type FontInfo (refer to ParseAFM.h). * - * parseFile returns an error code as defined in parseAFM.h. + * parseFile returns an error code as defined in parseAFM.h. * - * The position of the read/write pointer associated with the file + * The position of the read/write pointer associated with the file * pointer upon return of this function is undefined. */ extern int afm_parse_file(FILE *fp, FontInfo **fi, FLAGS flags) { - + int code = ok; /* return code from each of the parsing routines */ int error = ok; /* used as the return code from this function */ - - register char *keyword; /* used to store a token */ - - - /* storage data for the global variable ident */ - ident = (char *) calloc(MAX_NAME, sizeof(char)); - if (ident == NULL) {error = storageProblem; return(error);} - + + register char *keyword; /* used to store a token */ + + + /* storage data for the global variable ident */ + ident = (char *) calloc(MAX_NAME, sizeof(char)); + if (ident == NULL) {error = storageProblem; return(error);} + (*fi) = (FontInfo *) calloc(1, sizeof(FontInfo)); - if ((*fi) == NULL) {error = storageProblem; return(error);} - - if (flags & P_G) + if ((*fi) == NULL) {error = storageProblem; return(error);} + + if (flags & P_G) { (*fi)->gfi = (GlobalFontInfo *) calloc(1, sizeof(GlobalFontInfo)); - if ((*fi)->gfi == NULL) {error = storageProblem; return(error);} + if ((*fi)->gfi == NULL) {error = storageProblem; return(error);} } - + /* The AFM File begins with Global Font Information. This section */ - /* will be parsed whether or not information should be saved. */ - code = parseGlobals(fp, (*fi)->gfi); - + /* will be parsed whether or not information should be saved. */ + code = parseGlobals(fp, (*fi)->gfi); + if (code < 0) error = code; - + /* The Global Font Information is followed by the Character Metrics */ /* section. Which procedure is used to parse this section depends on */ /* how much information should be saved. If all of the metrics info */ @@ -1105,25 +1105,25 @@ extern int afm_parse_file(FILE *fp, FontInfo **fi, FLAGS flags) /* is wanted, parseCharWidths is called. parseCharWidths will also */ /* be called in the case that no character data is to be saved, just */ /* to parse through the section. */ - + if ((code != normalEOF) && (code != earlyEOF)) { (*fi)->numOfChars = atoi(token(fp)); if (flags & (P_M ^ P_W)) { - (*fi)->cmi = (CharMetricInfo *) + (*fi)->cmi = (CharMetricInfo *) calloc((*fi)->numOfChars, sizeof(CharMetricInfo)); if ((*fi)->cmi == NULL) {error = storageProblem; return(error);} - code = parseCharMetrics(fp, *fi); + code = parseCharMetrics(fp, *fi); } else { if (flags & P_W) - { - (*fi)->cwi = (int *) calloc(256, sizeof(int)); - if ((*fi)->cwi == NULL) + { + (*fi)->cwi = (int *) calloc(256, sizeof(int)); + if ((*fi)->cwi == NULL) { - error = storageProblem; + error = storageProblem; return(error); } } @@ -1131,15 +1131,15 @@ extern int afm_parse_file(FILE *fp, FontInfo **fi, FLAGS flags) code = parseCharWidths(fp, (*fi)->cwi); } /* else */ } /* if */ - + if ((error != earlyEOF) && (code < 0)) error = code; - + /* The remaining sections of the AFM are optional. This code will */ /* look at the next keyword in the file to determine what section */ /* is next, and then allocate the appropriate amount of storage */ /* for the data (if the data is to be saved) and call the */ /* appropriate parsing routine to parse the section. */ - + while ((code != normalEOF) && (code != earlyEOF)) { keyword = token(fp); @@ -1161,11 +1161,11 @@ extern int afm_parse_file(FILE *fp, FontInfo **fi, FLAGS flags) if (flags & P_T) { (*fi)->numOfTracks = atoi(keyword); - (*fi)->tkd = (TrackKernData *) + (*fi)->tkd = (TrackKernData *) calloc((*fi)->numOfTracks, sizeof(TrackKernData)); - if ((*fi)->tkd == NULL) + if ((*fi)->tkd == NULL) { - error = storageProblem; + error = storageProblem; return(error); } } /* if */ @@ -1176,11 +1176,11 @@ extern int afm_parse_file(FILE *fp, FontInfo **fi, FLAGS flags) if (flags & P_P) { (*fi)->numOfPairs = atoi(keyword); - (*fi)->pkd = (PairKernData *) + (*fi)->pkd = (PairKernData *) calloc((*fi)->numOfPairs, sizeof(PairKernData)); - if ((*fi)->pkd == NULL) + if ((*fi)->pkd == NULL) { - error = storageProblem; + error = storageProblem; return(error); } } /* if */ @@ -1189,18 +1189,18 @@ extern int afm_parse_file(FILE *fp, FontInfo **fi, FLAGS flags) case STARTCOMPOSITES: keyword = token(fp); if (flags & P_C) - { + { (*fi)->numOfComps = atoi(keyword); - (*fi)->ccd = (CompCharData *) + (*fi)->ccd = (CompCharData *) calloc((*fi)->numOfComps, sizeof(CompCharData)); - if ((*fi)->ccd == NULL) + if ((*fi)->ccd == NULL) { - error = storageProblem; + error = storageProblem; return(error); } } /* if */ - code = parseCompCharData(fp, *fi); - break; + code = parseCompCharData(fp, *fi); + break; case ENDFONTMETRICS: code = normalEOF; break; @@ -1209,17 +1209,17 @@ extern int afm_parse_file(FILE *fp, FontInfo **fi, FLAGS flags) code = parseError; break; } /* switch */ - + if ((error != earlyEOF) && (code < 0)) error = code; - + } /* while */ - + if ((error != earlyEOF) && (code < 0)) error = code; - + if (ident != NULL) { free(ident); ident = NULL; } - + return(error); - + } /* parseFile */ /* added for MDVI: this function was copied from `parseAFMclient.c' */ @@ -1229,7 +1229,7 @@ void afm_free_fontinfo(FontInfo *fi) if (fi != NULL) { if (fi->gfi != NULL) - { + { free(fi->gfi->afmVersion); fi->gfi->afmVersion = NULL; free(fi->gfi->fontName); fi->gfi->fontName = NULL; free(fi->gfi->fullName); fi->gfi->fullName = NULL; @@ -1240,16 +1240,16 @@ void afm_free_fontinfo(FontInfo *fi) free(fi->gfi->encodingScheme); fi->gfi->encodingScheme = NULL; free(fi->gfi); fi->gfi = NULL; } - + if (fi->cwi != NULL) { free(fi->cwi); fi->cwi = NULL; } if (fi->cmi != NULL) - { + { int i = 0; CharMetricInfo *temp = fi->cmi; Ligature *node = temp->ligs; - + for (i = 0; i < fi->numOfChars; ++i) { for (node = temp->ligs; node != NULL; node = node->next) @@ -1257,47 +1257,47 @@ void afm_free_fontinfo(FontInfo *fi) free(node->succ); node->succ = NULL; free(node->lig); node->lig = NULL; } - + free(temp->name); temp->name = NULL; temp++; } - + free(fi->cmi); fi->cmi = NULL; } if (fi->tkd != NULL) { free(fi->tkd); fi->tkd = NULL; } - + if (fi->pkd != NULL) - { + { free(fi->pkd->name1); fi->pkd->name1 = NULL; free(fi->pkd->name2); fi->pkd->name2 = NULL; free(fi->pkd); fi->pkd = NULL; } if (fi->ccd != NULL) - { + { int i = 0, j = 0; CompCharData *ccd = fi->ccd; - + for (i = 0; i < fi->numOfComps; ++i) { for (j = 0; j < ccd[i].numOfPieces; ++j) { - free(ccd[i].pieces[j].pccName); + free(ccd[i].pieces[j].pccName); ccd[i].pieces[j].pccName = NULL; } - + free(ccd[i].ccName); ccd[i].ccName = NULL; } - + free(fi->ccd); fi->ccd = NULL; } - + free(fi); - } /* if */ - + } /* if */ + } /* afm_free_fontinfo */ #endif /* WITH_AFM_FILES */ diff --git a/backend/dvi/mdvi-lib/afmparse.h b/backend/dvi/mdvi-lib/afmparse.h index 6cce780c..164c3567 100644 --- a/backend/dvi/mdvi-lib/afmparse.h +++ b/backend/dvi/mdvi-lib/afmparse.h @@ -3,20 +3,20 @@ * (C) 1988, 1989 by Adobe Systems Incorporated. All rights reserved. * * This file may be freely copied and redistributed as long as: - * 1) This entire notice continues to be included in the file, + * 1) This entire notice continues to be included in the file, * 2) If the file has been modified in any way, a notice of such * modification is conspicuously indicated. * * PostScript, Display PostScript, and Adobe are registered trademarks of * Adobe Systems Incorporated. - * + * * ************************************************************************ * THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO CHANGE WITHOUT * NOTICE, AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY ADOBE SYSTEMS - * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR - * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY - * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, - * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, + * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR + * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY + * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, + * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, * FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. * ************************************************************************ */ @@ -27,23 +27,23 @@ * Together these files provide the functionality to parse Adobe Font * Metrics files and store the information in predefined data structures. * It is intended to work with an application program that needs font metric - * information. The program can be used as is by making a procedure call to + * information. The program can be used as is by making a procedure call to * parse an AFM file and have the data stored, or an application developer - * may wish to customize the code. + * may wish to customize the code. * - * This header file defines the data structures used as well as the key + * This header file defines the data structures used as well as the key * strings that are currently recognized by this version of the AFM parser. - * This program is based on the document "Adobe Font Metrics Files, + * This program is based on the document "Adobe Font Metrics Files, * Specification Version 2.0". * * AFM files are separated into distinct sections of different data. Because * of this, the parseAFM program can parse a specified file to only save - * certain sections of information based on the application's needs. A record + * certain sections of information based on the application's needs. A record * containing the requested information will be returned to the application. - * + * * AFM files are divided into five sections of data: * 1) The Global Font Information - * 2) The Character Metrics Information + * 2) The Character Metrics Information * 3) The Track Kerning Data * 4) The Pair-Wise Kerning Data * 5) The Composite Character Data @@ -52,22 +52,22 @@ * of what other sections are requested. In addition, in recognizing that * many applications will want ONLY the x-width of characters and not all * of the other character metrics information, there is a way to receive - * only the width information so as not to pay the storage cost for the - * unwanted data. An application should never request both the - * "quick and dirty" char metrics (widths only) and the Character Metrics - * Information since the Character Metrics Information will contain all + * only the width information so as not to pay the storage cost for the + * unwanted data. An application should never request both the + * "quick and dirty" char metrics (widths only) and the Character Metrics + * Information since the Character Metrics Information will contain all * of the character widths as well. - * - * There is a procedure in parseAFM.c, called parseFile, that can be + * + * There is a procedure in parseAFM.c, called parseFile, that can be * called from any application wishing to get information from the AFM File. * This procedure expects 3 parameters: a vaild file descriptor, a pointer - * to a (FontInfo *) variable (for which space will be allocated and then + * to a (FontInfo *) variable (for which space will be allocated and then * will be filled in with the data requested), and a mask specifying * which data from the AFM File should be saved in the FontInfo structure. - * + * * The flags that can be used to set the appropriate mask are defined below. - * In addition, several commonly used masks have already been defined. - * + * In addition, several commonly used masks have already been defined. + * * History: * original: DSM Thu Oct 20 17:39:59 PDT 1988 * modified: DSM Mon Jul 3 14:17:50 PDT 1989 @@ -99,25 +99,25 @@ #define P_C 0x20 /* 0010 0000 */ /* Composite Char Info */ /* Commonly used flags */ -#define P_GW (P_G | P_W) +#define P_GW (P_G | P_W) #define P_GM (P_G | P_M) #define P_GMP (P_G | P_M | P_P) -#define P_GMK (P_G | P_M | P_P | P_T) +#define P_GMK (P_G | P_M | P_P | P_T) #define P_ALL (P_G | P_M | P_P | P_T | P_C) /* Possible return codes from the parseFile procedure. - * + * * ok means there were no problems parsing the file. * * parseError means that there was some kind of parsing error, but the * parser went on. This could include problems like the count for any given * section does not add up to how many entries there actually were, or * there was a key that was not recognized. The return record may contain - * vaild data or it may not. + * vaild data or it may not. * * earlyEOF means that an End of File was encountered before expected. This * may mean that the AFM file had been truncated, or improperly formed. - * + * * storageProblem means that there were problems allocating storage for * the data structures that would have contained the AFM data. */ @@ -128,15 +128,15 @@ /************************* TYPES *********************************/ /* Below are all of the data structure definitions. These structures - * try to map as closely as possible to grouping and naming of data + * try to map as closely as possible to grouping and naming of data * in the AFM Files. */ -/* Bounding box definition. Used for the Font BBox as well as the +/* Bounding box definition. Used for the Font BBox as well as the * Character BBox. */ typedef struct -{ +{ int llx; /* lower left x-position */ int lly; /* lower left y-position */ int urx; /* upper right x-position */ @@ -144,12 +144,12 @@ typedef struct } BBox; /* Global Font information. - * The key that each field is associated with is in comments. For an + * The key that each field is associated with is in comments. For an * explanation about each key and its value please refer to the AFM - * documentation (full title & version given above). + * documentation (full title & version given above). */ typedef struct -{ +{ char *afmVersion; /* key: StartFontMetrics */ char *fontName; /* key: FontName */ char *fullName; /* key: FullName */ @@ -178,15 +178,15 @@ typedef struct _t_ligature struct _t_ligature *next; } Ligature; -/* Character Metric Information. This structure is used only if ALL +/* Character Metric Information. This structure is used only if ALL * character metric information is requested. If only the character * widths is requested, then only an array of the character x-widths * is returned. * - * The key that each field is associated with is in comments. For an - * explanation about each key and its value please refer to the + * The key that each field is associated with is in comments. For an + * explanation about each key and its value please refer to the * Character Metrics section of the AFM documentation (full title - * & version given above). + * & version given above). */ typedef struct { @@ -199,19 +199,19 @@ typedef struct } CharMetricInfo; /* Track kerning data structure. - * The fields of this record are the five values associated with every + * The fields of this record are the five values associated with every * TrackKern entry. - * - * For an explanation about each value please refer to the + * + * For an explanation about each value please refer to the * Track Kerning section of the AFM documentation (full title - * & version given above). + * & version given above). */ -typedef struct +typedef struct { - int degree; - float minPtSize, - minKernAmt, - maxPtSize, + int degree; + float minPtSize, + minKernAmt, + maxPtSize, maxKernAmt; } TrackKernData; @@ -219,11 +219,11 @@ typedef struct * The fields of this record are the four values associated with every * KP entry. For KPX entries, the yamt will be zero. * - * For an explanation about each value please refer to the + * For an explanation about each value please refer to the * Pair Kerning section of the AFM documentation (full title - * & version given above). + * & version given above). */ -typedef struct +typedef struct { char *name1; char *name2; @@ -234,10 +234,10 @@ typedef struct /* PCC is a piece of a composite character. This is a sub structure of a * compCharData described below. * These fields will be filled in with the values from the key PCC. - * - * For an explanation about each key and its value please refer to the + * + * For an explanation about each key and its value please refer to the * Composite Character section of the AFM documentation (full title - * & version given above). + * & version given above). */ typedef struct { @@ -246,15 +246,15 @@ typedef struct deltay; } Pcc; -/* Composite Character Information data structure. +/* Composite Character Information data structure. * The fields ccName and numOfPieces are filled with the values associated * with the key CC. The field pieces points to an array (size = numOfPieces) * of information about each of the parts of the composite character. That * array is filled in with the values from the key PCC. - * - * For an explanation about each key and its value please refer to the + * + * For an explanation about each key and its value please refer to the * Composite Character section of the AFM documentation (full title - * & version given above). + * & version given above). */ typedef struct { @@ -270,9 +270,9 @@ typedef struct * parseFile function. */ typedef struct -{ +{ GlobalFontInfo *gfi; /* ptr to a GlobalFontInfo record */ - int *cwi; /* ptr to 256 element array of just char widths */ + int *cwi; /* ptr to 256 element array of just char widths */ int numOfChars; /* number of entries in char metrics array */ CharMetricInfo *cmi; /* ptr to char metrics array */ int numOfTracks; /* number to entries in track kerning array */ @@ -289,7 +289,7 @@ typedef struct * * "fp" should be a valid file pointer to an AFM file. * - * "fi" is a pointer to a pointer to a FontInfo record sturcture + * "fi" is a pointer to a pointer to a FontInfo record sturcture * (defined above). Storage for the FontInfo structure will be * allocated in parseFile and the structure will be filled in * with the requested data from the AFM File. @@ -301,7 +301,7 @@ typedef struct * The possible return codes from parseFile are defined above. */ -extern int afm_parse_file __PROTO((FILE *, FontInfo **, FLAGS)); +extern int afm_parse_file __PROTO((FILE *, FontInfo **, FLAGS)); extern void afm_free_fontinfo __PROTO((FontInfo *)); #endif /* _MDVI_PARSEAFM_H */ diff --git a/backend/dvi/mdvi-lib/bitmap.c b/backend/dvi/mdvi-lib/bitmap.c index 4417a75b..de1de6a7 100644 --- a/backend/dvi/mdvi-lib/bitmap.c +++ b/backend/dvi/mdvi-lib/bitmap.c @@ -48,7 +48,7 @@ static BmUnit bit_masks[] = { #define SHOW_OP_DATA (DEBUGGING(BITMAP_OPS) && DEBUGGING(BITMAP_DATA)) #endif -/* +/* * Some useful macros to manipulate bitmap data * SEGMENT(m,n) = bit mask for a segment of `m' contiguous bits * starting at column `n'. These macros assume that @@ -118,7 +118,7 @@ static Uchar bit_swap[] = { }; -/* +/* * next we have three bitmap functions to convert bitmaps in LSB bit order * with 8, 16 and 32 bits per unit, to our internal format. The differences * are minimal, but writing a generic function to handle all unit sizes is @@ -132,8 +132,8 @@ BITMAP *bitmap_convert_lsb8(Uchar *bits, int w, int h, int stride) Uchar *unit; register Uchar *curr; int bytes; - - DEBUG((DBG_BITMAP_OPS, "convert LSB %dx%d@8 -> bitmap\n", w, h)); + + DEBUG((DBG_BITMAP_OPS, "convert LSB %dx%d@8 -> bitmap\n", w, h)); bm = bitmap_alloc_raw(w, h); @@ -141,14 +141,14 @@ BITMAP *bitmap_convert_lsb8(Uchar *bits, int w, int h, int stride) bytes = ROUND(w, 8); unit = (Uchar *)bm->data; curr = bits; - /* we try to do this as fast as we can */ + /* we try to do this as fast as we can */ for(i = 0; i < h; i++) { #ifdef WORD_LITTLE_ENDIAN memcpy(unit, curr, bytes); curr += stride; #else int j; - + for(j = 0; j < bytes; curr++, j++) unit[j] = bit_swap[*curr]; cur += stride - bytes; @@ -168,7 +168,7 @@ BITMAP *bitmap_convert_msb8(Uchar *data, int w, int h, int stride) Uchar *curr; int i; int bytes; - + bm = bitmap_alloc(w, h); bytes = ROUND(w, 8); unit = (Uchar *)bm->data; @@ -176,7 +176,7 @@ BITMAP *bitmap_convert_msb8(Uchar *data, int w, int h, int stride) for(i = 0; i < h; i++) { #ifdef WORD_LITTLE_ENDIAN int j; - + for(j = 0; j < bytes; curr++, j++) unit[j] = bit_swap[*curr]; curr += stride - bytes; @@ -197,7 +197,7 @@ BITMAP *bitmap_copy(BITMAP *bm) { BITMAP *nb = bitmap_alloc(bm->width, bm->height); - DEBUG((DBG_BITMAP_OPS, "copy %dx%d\n", bm->width, bm->height)); + DEBUG((DBG_BITMAP_OPS, "copy %dx%d\n", bm->width, bm->height)); memcpy(nb->data, bm->data, bm->height * bm->stride); return nb; } @@ -205,7 +205,7 @@ BITMAP *bitmap_copy(BITMAP *bm) BITMAP *bitmap_alloc(int w, int h) { BITMAP *bm; - + bm = xalloc(BITMAP); bm->width = w; bm->height = h; @@ -214,14 +214,14 @@ BITMAP *bitmap_alloc(int w, int h) bm->data = (BmUnit *)mdvi_calloc(h, bm->stride); else bm->data = NULL; - + return bm; } BITMAP *bitmap_alloc_raw(int w, int h) { BITMAP *bm; - + bm = xalloc(BITMAP); bm->width = w; bm->height = h; @@ -230,7 +230,7 @@ BITMAP *bitmap_alloc_raw(int w, int h) bm->data = (BmUnit *)mdvi_malloc(h * bm->stride); else bm->data = NULL; - + return bm; } @@ -250,7 +250,7 @@ void bitmap_print(FILE *out, BITMAP *bm) }; int sub; - a = bm->data; + a = bm->data; fprintf(out, " "); if(bm->width > 10) { putchar('0'); @@ -292,10 +292,10 @@ void bitmap_set_col(BITMAP *bm, int row, int col, int count, int state) { BmUnit *ptr; BmUnit mask; - + ptr = __bm_unit_ptr(bm, col, row); mask = FIRSTMASKAT(col); - + while(count-- > 0) { if(state) *ptr |= mask; @@ -306,7 +306,7 @@ void bitmap_set_col(BITMAP *bm, int row, int col, int count, int state) } } -/* +/* * to use this function you should first make sure that * there is room for `count' bits in the scanline * @@ -333,11 +333,11 @@ void bitmap_paint_bits(BmUnit *ptr, int n, int count) *ptr++ = bit_masks[BITMAP_BITS]; /* paint the tail */ - if(count > 0) + if(count > 0) *ptr |= SEGMENT(count, 0); } -/* +/* * same as paint_bits but clears pixels instead of painting them. Written * as a separate function for efficiency reasons. */ @@ -365,7 +365,7 @@ void bitmap_clear_bits(BmUnit *ptr, int n, int count) void bitmap_set_row(BITMAP *bm, int row, int col, int count, int state) { BmUnit *ptr; - + ptr = __bm_unit_ptr(bm, col, row); if(state) bitmap_paint_bits(ptr, col & (BITMAP_BITS-1), count); @@ -388,13 +388,13 @@ void bitmap_flip_horizontally(BITMAP *bm) nb.height = bm->height; nb.stride = bm->stride; nb.data = mdvi_calloc(bm->height, bm->stride); - + fptr = bm->data; tptr = __bm_unit_ptr(&nb, nb.width-1, 0); for(h = 0; h < bm->height; h++) { BmUnit *fline, *tline; - - fline = fptr; + + fline = fptr; tline = tptr; fmask = FIRSTMASK; tmask = FIRSTMASKAT(nb.width-1); @@ -434,13 +434,13 @@ void bitmap_flip_vertically(BITMAP *bm) nb.height = bm->height; nb.stride = bm->stride; nb.data = mdvi_calloc(bm->height, bm->stride); - + fptr = bm->data; tptr = __bm_unit_ptr(&nb, 0, nb.height-1); for(h = 0; h < bm->height; h++) { BmUnit *fline, *tline; - - fline = fptr; + + fline = fptr; tline = tptr; fmask = FIRSTMASK; for(w = 0; w < bm->width; w++) { @@ -470,18 +470,18 @@ void bitmap_flip_diagonally(BITMAP *bm) BmUnit *fptr, *tptr; BmUnit fmask, tmask; int w, h; - + nb.width = bm->width; nb.height = bm->height; nb.stride = bm->stride; nb.data = mdvi_calloc(bm->height, bm->stride); - + fptr = bm->data; tptr = __bm_unit_ptr(&nb, nb.width-1, nb.height-1); for(h = 0; h < bm->height; h++) { BmUnit *fline, *tline; - - fline = fptr; + + fline = fptr; tline = tptr; fmask = FIRSTMASK; tmask = FIRSTMASKAT(nb.width-1); @@ -516,19 +516,19 @@ void bitmap_rotate_clockwise(BITMAP *bm) BmUnit *fptr, *tptr; BmUnit fmask, tmask; int w, h; - + nb.width = bm->height; nb.height = bm->width; nb.stride = BM_BYTES_PER_LINE(&nb); nb.data = mdvi_calloc(nb.height, nb.stride); - + fptr = bm->data; tptr = __bm_unit_ptr(&nb, nb.width - 1, 0); - + tmask = FIRSTMASKAT(nb.width-1); for(h = 0; h < bm->height; h++) { BmUnit *fline, *tline; - + fmask = FIRSTMASK; fline = fptr; tline = tptr; @@ -556,7 +556,7 @@ void bitmap_rotate_clockwise(BITMAP *bm) mdvi_free(bm->data); bm->data = nb.data; bm->width = nb.width; - bm->height = nb.height; + bm->height = nb.height; bm->stride = nb.stride; if(SHOW_OP_DATA) bitmap_print(stderr, bm); @@ -568,19 +568,19 @@ void bitmap_rotate_counter_clockwise(BITMAP *bm) BmUnit *fptr, *tptr; BmUnit fmask, tmask; int w, h; - + nb.width = bm->height; nb.height = bm->width; nb.stride = BM_BYTES_PER_LINE(&nb); nb.data = mdvi_calloc(nb.height, nb.stride); - + fptr = bm->data; tptr = __bm_unit_ptr(&nb, 0, nb.height - 1); tmask = FIRSTMASK; for(h = 0; h < bm->height; h++) { BmUnit *fline, *tline; - + fmask = FIRSTMASK; fline = fptr; tline = tptr; @@ -608,7 +608,7 @@ void bitmap_rotate_counter_clockwise(BITMAP *bm) mdvi_free(bm->data); bm->data = nb.data; bm->width = nb.width; - bm->height = nb.height; + bm->height = nb.height; bm->stride = nb.stride; if(SHOW_OP_DATA) bitmap_print(stderr, bm); @@ -620,16 +620,16 @@ void bitmap_flip_rotate_clockwise(BITMAP *bm) BmUnit *fptr, *tptr; BmUnit fmask, tmask; int w, h; - + nb.width = bm->height; nb.height = bm->width; nb.stride = BM_BYTES_PER_LINE(&nb); nb.data = mdvi_calloc(nb.height, nb.stride); - + fptr = bm->data; tptr = __bm_unit_ptr(&nb, nb.width-1, nb.height-1); - tmask = FIRSTMASKAT(nb.width-1); + tmask = FIRSTMASKAT(nb.width-1); for(h = 0; h < bm->height; h++) { BmUnit *fline, *tline; @@ -659,7 +659,7 @@ void bitmap_flip_rotate_clockwise(BITMAP *bm) mdvi_free(bm->data); bm->data = nb.data; bm->width = nb.width; - bm->height = nb.height; + bm->height = nb.height; bm->stride = nb.stride; if(SHOW_OP_DATA) bitmap_print(stderr, bm); @@ -671,16 +671,16 @@ void bitmap_flip_rotate_counter_clockwise(BITMAP *bm) BmUnit *fptr, *tptr; BmUnit fmask, tmask; int w, h; - + nb.width = bm->height; nb.height = bm->width; nb.stride = BM_BYTES_PER_LINE(&nb); nb.data = mdvi_calloc(nb.height, nb.stride); - + fptr = bm->data; tptr = nb.data; tmask = FIRSTMASK; - + for(h = 0; h < bm->height; h++) { BmUnit *fline, *tline; @@ -711,7 +711,7 @@ void bitmap_flip_rotate_counter_clockwise(BITMAP *bm) mdvi_free(bm->data); bm->data = nb.data; bm->width = nb.width; - bm->height = nb.height; + bm->height = nb.height; bm->stride = nb.stride; if(SHOW_OP_DATA) bitmap_print(stderr, bm); @@ -751,7 +751,7 @@ void bitmap_transform(BITMAP *map, DviOrientation orient) /* * Count the number of non-zero bits in a box of dimensions w x h, starting * at column `step' in row `data'. - * + * * Shamelessly stolen from xdvi. */ static int do_sample(BmUnit *data, int stride, int step, int w, int h) @@ -760,7 +760,7 @@ static int do_sample(BmUnit *data, int stride, int step, int w, int h) int shift, n; int bits_left; int wid; - + ptr = data + step / BITMAP_BITS; end = bm_offset(data, h * stride); shift = FIRSTSHIFTAT(step); @@ -800,17 +800,17 @@ static int do_sample(BmUnit *data, int stride, int step, int w, int h) return n; } -void mdvi_shrink_box(DviContext *dvi, DviFont *font, +void mdvi_shrink_box(DviContext *dvi, DviFont *font, DviFontChar *pk, DviGlyph *dest) { int x, y, z; DviGlyph *glyph; int hs, vs; - + hs = dvi->params.hshrink; vs = dvi->params.vshrink; glyph = &pk->glyph; - + x = (int)glyph->x / hs; if((int)glyph->x - x * hs > 0) x++; @@ -844,15 +844,15 @@ void mdvi_shrink_glyph(DviContext *dvi, DviFont *font, int x, y; int w, h; int hs, vs; - + hs = dvi->params.hshrink; vs = dvi->params.vshrink; - + min_sample = vs * hs * dvi->params.density / 100; glyph = &pk->glyph; oldmap = (BITMAP *)glyph->data; - + x = (int)glyph->x / hs; init_cols = (int)glyph->x - x * hs; if(init_cols <= 0) @@ -910,7 +910,7 @@ void mdvi_shrink_glyph(DviContext *dvi, DviFont *font, old_ptr = bm_offset(old_ptr, rows * old_stride); rows_left -= rows; rows = vs; - } + } DEBUG((DBG_BITMAPS, "shrink_glyph: (%dw,%dh,%dx,%dy) -> (%dw,%dh,%dx,%dy)\n", glyph->w, glyph->h, glyph->x, glyph->y, dest->w, dest->h, dest->x, dest->y)); @@ -939,10 +939,10 @@ void mdvi_shrink_glyph_grey(DviContext *dvi, DviFont *font, hs = dvi->params.hshrink; vs = dvi->params.vshrink; dev = &dvi->device; - + glyph = &pk->glyph; map = (BITMAP *)glyph->data; - + x = (int)glyph->x / hs; init_cols = (int)glyph->x - x * hs; if(init_cols <= 0) @@ -960,18 +960,18 @@ void mdvi_shrink_glyph_grey(DviContext *dvi, DviFont *font, } h = y + ROUND((int)glyph->h - cols, vs) + 1; ASSERT(w && h); - + /* before touching anything, do this */ image = dev->create_image(dev->device_data, w, h, BITMAP_BITS); if(image == NULL) { mdvi_shrink_glyph(dvi, font, pk, dest); return; } - + /* save these colors */ pk->fg = MDVI_CURRFG(dvi); pk->bg = MDVI_CURRBG(dvi); - + samplemax = vs * hs; npixels = samplemax + 1; pixels = get_color_table(&dvi->device, npixels, pk->fg, pk->bg, @@ -982,7 +982,7 @@ void mdvi_shrink_glyph_grey(DviContext *dvi, DviFont *font, colortab[1] = pk->bg; pixels = &colortab[0]; } - + /* setup the new glyph */ dest->data = image; dest->x = x; @@ -1021,7 +1021,7 @@ void mdvi_shrink_glyph_grey(DviContext *dvi, DviFont *font, rows = vs; y++; } - + for(; y < h; y++) { for(x = 0; x < w; x++) dev->put_pixel(image, x, y, pixels[0]); diff --git a/backend/dvi/mdvi-lib/bitmap.h b/backend/dvi/mdvi-lib/bitmap.h index 4d98fecd..7b722bb4 100644 --- a/backend/dvi/mdvi-lib/bitmap.h +++ b/backend/dvi/mdvi-lib/bitmap.h @@ -54,7 +54,7 @@ typedef struct { #define __bm_unit_ptr(b,x,y) \ bm_offset((b)->data, (y) * (b)->stride + \ ((x) / BITMAP_BITS) * BITMAP_BYTES) - + #define __bm_unit(b,x,y) __bm_unit_ptr((b), (x), (y))[0] #define BM_GETPIXEL(b,x,y) __bm_unit((b), (x), (y)) @@ -91,7 +91,7 @@ typedef struct { } } /* end of sample code */ -#endif +#endif /* bitmaps are stored in native byte order */ #ifdef WORD_BIG_ENDIAN @@ -116,9 +116,9 @@ extern BITMAP *bitmap_alloc __PROTO((int, int)); extern BITMAP *bitmap_alloc_raw __PROTO((int, int)); extern void bitmap_destroy __PROTO((BITMAP *)); -/* - * set_row(bm, row, col, count, state): - * sets `count' pixels to state `onoff', starting from pixel +/* + * set_row(bm, row, col, count, state): + * sets `count' pixels to state `onoff', starting from pixel * at position (col, row). All pixels must lie in the same * row. */ diff --git a/backend/dvi/mdvi-lib/color.c b/backend/dvi/mdvi-lib/color.c index c28107fd..ef6036a9 100644 --- a/backend/dvi/mdvi-lib/color.c +++ b/backend/dvi/mdvi-lib/color.c @@ -47,7 +47,7 @@ void mdvi_push_color(DviContext *dvi, Ulong fg, Ulong bg) void mdvi_pop_color(DviContext *dvi) { Ulong fg, bg; - + if(dvi->color_top == 0) return; dvi->color_top--; @@ -81,7 +81,7 @@ static int cc_entries; /* create a color table */ -Ulong *get_color_table(DviDevice *dev, +Ulong *get_color_table(DviDevice *dev, int nlevels, Ulong fg, Ulong bg, double gamma, int density) { ColorCache *cc, *tofree; @@ -109,7 +109,7 @@ Ulong *get_color_table(DviDevice *dev, DEBUG((DBG_DEVICE, "Adding color table to cache (fg=%lu, bg=%lu, n=%d)\n", fg, bg, nlevels)); - + /* no entry was found in the cache, create a new one */ if(cc_entries < CCSIZE) { cc = &color_cache[cc_entries++]; @@ -119,7 +119,7 @@ Ulong *get_color_table(DviDevice *dev, mdvi_free(cc->pixels); } pixels = xnalloc(Ulong, nlevels); - status = dev->alloc_colors(dev->device_data, + status = dev->alloc_colors(dev->device_data, pixels, nlevels, fg, bg, gamma, density); if(status < 0) { mdvi_free(pixels); @@ -132,5 +132,5 @@ Ulong *get_color_table(DviDevice *dev, cc->nlevels = nlevels; cc->pixels = pixels; cc->hits = 1; - return pixels; + return pixels; } diff --git a/backend/dvi/mdvi-lib/color.h b/backend/dvi/mdvi-lib/color.h index 35b2f923..cbc3c0ef 100644 --- a/backend/dvi/mdvi-lib/color.h +++ b/backend/dvi/mdvi-lib/color.h @@ -22,7 +22,7 @@ #include "common.h" -extern Ulong *get_color_table(DviDevice *dev, +extern Ulong *get_color_table(DviDevice *dev, int nlevels, Ulong fg, Ulong bg, double gamma, int density); extern void mdvi_set_color __PROTO((DviContext *, Ulong, Ulong)); diff --git a/backend/dvi/mdvi-lib/common.c b/backend/dvi/mdvi-lib/common.c index 97b34b56..847a307d 100644 --- a/backend/dvi/mdvi-lib/common.c +++ b/backend/dvi/mdvi-lib/common.c @@ -25,8 +25,8 @@ long fsgetn(FILE *p, size_t n) { long v; - - v = fgetbyte(p); + + v = fgetbyte(p); if(v & 0x80) v -= 0x100; while(--n > 0) @@ -37,7 +37,7 @@ long fsgetn(FILE *p, size_t n) Ulong fugetn(FILE *p, size_t n) { Ulong v; - + v = fgetbyte(p); while(--n > 0) v = (v << 8) | fgetbyte(p); @@ -47,7 +47,7 @@ Ulong fugetn(FILE *p, size_t n) long msgetn(const Uchar *p, size_t n) { long v = (long)*p++; - + if(v & 0x80) v -= 0x100; while(--n > 0) @@ -68,7 +68,7 @@ char *read_string(FILE *in, int s, char *buffer, size_t len) { int n; char *str; - + n = fugetn(in, s ? s : 1); if((str = buffer) == NULL || n + 1 > len) str = mdvi_malloc(n + 1); @@ -83,7 +83,7 @@ char *read_string(FILE *in, int s, char *buffer, size_t len) size_t read_bcpl(FILE *in, char *buffer, size_t maxlen, size_t wanted) { size_t i; - + i = (int)fuget1(in); if(maxlen && i > maxlen) i = maxlen; @@ -99,7 +99,7 @@ char *read_alloc_bcpl(FILE *in, size_t maxlen, size_t *size) { size_t i; char *buffer; - + i = (size_t)fuget1(in); if(maxlen && i > maxlen) i = maxlen; @@ -121,7 +121,7 @@ void buff_free(Buffer *buf) { if(buf->data) mdvi_free(buf->data); - buff_init(buf); + buff_init(buf); } void buff_init(Buffer *buf) @@ -149,7 +149,7 @@ char *buff_gets(Buffer *buf, size_t *length) char *ptr; char *ret; size_t len; - + ptr = strchr(buf->data, '\n'); if(ptr == NULL) return NULL; @@ -163,6 +163,6 @@ char *buff_gets(Buffer *buf, size_t *length) } ret[len] = 0; if(length) *length = len; - return ret; + return ret; } diff --git a/backend/dvi/mdvi-lib/dviread.c b/backend/dvi/mdvi-lib/dviread.c index d0143205..c1cb21f6 100644 --- a/backend/dvi/mdvi-lib/dviread.c +++ b/backend/dvi/mdvi-lib/dviread.c @@ -53,37 +53,37 @@ DVICMDDEF(undefined); DVICMDDEF(unexpected); static const DviCommand dvi_commands[] = { - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, - set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, set_char, set_char, set_char, set_char, /* 0 - 127 */ set_char, set_char, set_char, set_char, /* 128 - 131 */ set_rule, /* 132 */ @@ -122,7 +122,7 @@ static const DviCommand dvi_commands[] = { unexpected, /* 247 (PRE) */ unexpected, /* 248 (POST) */ unexpected, /* 249 (POST_POST) */ - undefined, undefined, undefined, + undefined, undefined, undefined, undefined, undefined, undefined /* 250 - 255 */ }; @@ -172,7 +172,7 @@ static void dummy_dev_set_color(void *a, Ulong b, Ulong c) static void dvierr(DviContext *dvi, const char *format, ...) { va_list ap; - + va_start(ap, format); fprintf(stderr, "%s[%d]: Error: ", dvi->filename, dvi->currpage); @@ -183,7 +183,7 @@ static void dvierr(DviContext *dvi, const char *format, ...) static void dviwarn(DviContext *dvi, const char *format, ...) { va_list ap; - + fprintf(stderr, "%s[%d]: Warning: ", dvi->filename, dvi->currpage); va_start(ap, format); @@ -195,15 +195,15 @@ static void dviwarn(DviContext *dvi, const char *format, ...) ((d)->buffer.pos + (n) > (d)->buffer.length) static int get_bytes(DviContext *dvi, size_t n) -{ - /* +{ + /* * caller wants to read `n' bytes from dvi->buffer + dvi->pos. - * Make sure there is enough data to satisfy the request + * Make sure there is enough data to satisfy the request */ if(NEEDBYTES(dvi, n)) { size_t required; int newlen; - + if(dvi->buffer.frozen || dvi->in == NULL || feof(dvi->in)) { /* this is EOF */ dviwarn(dvi, _("unexpected EOF\n")); @@ -251,7 +251,7 @@ static int get_bytes(DviContext *dvi, size_t n) static int dskip(DviContext *dvi, long offset) { ASSERT(offset > 0); - + if(NEEDBYTES(dvi, offset) && get_bytes(dvi, offset) == -1) return -1; dvi->buffer.pos += offset; @@ -283,8 +283,8 @@ static long dugetn(DviContext *dvi, size_t n) { long val; - if(NEEDBYTES(dvi, n) && get_bytes(dvi, n) == -1) - return -1; + if(NEEDBYTES(dvi, n) && get_bytes(dvi, n) == -1) + return -1; val = mugetn(dvi->buffer.data + dvi->buffer.pos, n); dvi->buffer.pos += n; return val; @@ -292,8 +292,8 @@ static long dugetn(DviContext *dvi, size_t n) static long dtell(DviContext *dvi) { - return dvi->depth ? - dvi->buffer.pos : + return dvi->depth ? + dvi->buffer.pos : ftell(dvi->in) - dvi->buffer.length + dvi->buffer.pos; } @@ -321,7 +321,7 @@ static void dviprint(DviContext *dvi, const char *command, int sub, const char * { int i; va_list ap; - + printf("%s: ", dvi->filename); for(i = 0; i < dvi->depth; i++) printf(" "); @@ -341,7 +341,7 @@ static void dviprint(DviContext *dvi, const char *command, int sub, const char * int mdvi_find_tex_page(DviContext *dvi, int tex_page) { int i; - + for(i = 0; i < dvi->npages; i++) if(dvi->pagemap[i][1] == tex_page) return i; @@ -373,7 +373,7 @@ static int sort_dvi_down(const void *p1, const void *p2) void mdvi_sort_pages(DviContext *dvi, DviPageSort type) { int (*sortfunc) __PROTO((const void *, const void *)); - + switch(type) { case MDVI_PAGE_SORT_UP: sortfunc = sort_up; @@ -395,7 +395,7 @@ void mdvi_sort_pages(DviContext *dvi, DviPageSort type) sortfunc = NULL; break; } - + if(sortfunc) qsort(dvi->pagemap, dvi->npages, sizeof(PageNum), sortfunc); } @@ -411,7 +411,7 @@ static DviFontRef *define_font(DviContext *dvi, int op) int n; char *name; DviFontRef *ref; - + arg = dugetn(dvi, op - DVI_FNT_DEF1 + 1); checksum = duget4(dvi); scale = duget4(dvi); @@ -439,7 +439,7 @@ static char *opendvi(const char *name) { int len; char *file; - + len = strlen(name); /* if file ends with .dvi and it exists, that's it */ if(len >= 4 && STREQ(name+len-4, ".dvi")) { @@ -447,7 +447,7 @@ static char *opendvi(const char *name) if(access(name, R_OK) == 0) return mdvi_strdup(name); } - + /* try appending .dvi */ file = mdvi_malloc(len + 5); strcpy(file, name); @@ -468,7 +468,7 @@ int mdvi_reload(DviContext *dvi, DviParams *np) { DviContext *newdvi; DviParams *pars; - + /* close our file */ if(dvi->in) { fclose(dvi->in); @@ -476,8 +476,8 @@ int mdvi_reload(DviContext *dvi, DviParams *np) } pars = np ? np : &dvi->params; - DEBUG((DBG_DVI, "%s: reloading\n", dvi->filename)); - + DEBUG((DBG_DVI, "%s: reloading\n", dvi->filename)); + /* load it again */ newdvi = mdvi_init_context(pars, dvi->pagesel, dvi->filename); if(newdvi == NULL) { @@ -508,7 +508,7 @@ int mdvi_reload(DviContext *dvi, DviParams *np) if(dvi->fileid) mdvi_free(dvi->fileid); dvi->fileid = newdvi->fileid; - + dvi->dvi_page_w = newdvi->dvi_page_w; dvi->dvi_page_h = newdvi->dvi_page_h; @@ -517,25 +517,25 @@ int mdvi_reload(DviContext *dvi, DviParams *np) dvi->npages = newdvi->npages; if(dvi->currpage > dvi->npages-1) dvi->currpage = 0; - + mdvi_free(dvi->stack); dvi->stack = newdvi->stack; dvi->stacksize = newdvi->stacksize; /* remove fonts that are not being used anymore */ font_free_unused(&dvi->device); - - mdvi_free(newdvi->filename); + + mdvi_free(newdvi->filename); mdvi_free(newdvi); DEBUG((DBG_DVI, "%s: reload successful\n", dvi->filename)); if(dvi->device.refresh) dvi->device.refresh(dvi, dvi->device.device_data); - + return 0; } -/* function to change parameters ia DVI context +/* function to change parameters ia DVI context * The DVI context is modified ONLY if this function is successful */ int mdvi_configure(DviContext *dvi, DviParamCode option, ...) { @@ -543,12 +543,12 @@ int mdvi_configure(DviContext *dvi, DviParamCode option, ...) int reset_all; int reset_font; DviParams np; - + va_start(ap, option); reset_font = 0; reset_all = 0; - np = dvi->params; /* structure copy */ + np = dvi->params; /* structure copy */ while(option != MDVI_PARAM_LAST) { switch(option) { case MDVI_SET_DPI: @@ -613,7 +613,7 @@ int mdvi_configure(DviContext *dvi, DviParamCode option, ...) option = va_arg(ap, DviParamCode); } va_end(ap); - + /* check that all values make sense */ if(np.dpi <= 0 || np.vdpi <= 0) return -1; @@ -624,11 +624,11 @@ int mdvi_configure(DviContext *dvi, DviParamCode option, ...) if(np.hshrink < 1 || np.vshrink < 1) return -1; if(np.hdrift < 0 || np.vdrift < 0) - return -1; + return -1; if(np.fg == np.bg) return -1; - /* + /* * If the dpi or the magnification change, we basically have to reload * the DVI file again from scratch. */ @@ -650,7 +650,7 @@ int mdvi_configure(DviContext *dvi, DviParamCode option, ...) if(reset_font) { font_reset_chain_glyphs(&dvi->device, dvi->fonts, reset_font); } - dvi->params = np; + dvi->params = np; if((reset_font & MDVI_FONTSEL_GLYPH) && dvi->device.refresh) { dvi->device.refresh(dvi, dvi->device.device_data); return 0; @@ -659,8 +659,8 @@ int mdvi_configure(DviContext *dvi, DviParamCode option, ...) return 1; } /* - * Read the initial data from the DVI file. If something is wrong with the - * file, we just spit out an error message and refuse to load the file, + * Read the initial data from the DVI file. If something is wrong with the + * file, we just spit out an error message and refuse to load the file, * without giving any details. This makes sense because DVI files are ok * 99.99% of the time, and dvitype(1) can be used to check the other 0.01%. */ @@ -677,7 +677,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil /* * 1. Open the file and initialize the DVI context - */ + */ filename = opendvi(file); if(filename == NULL) { @@ -695,13 +695,13 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil dvi->pagemap = NULL; dvi->filename = filename; dvi->stack = NULL; - dvi->modtime = get_mtime(fileno(p)); + dvi->modtime = get_mtime(fileno(p)); dvi->buffer.data = NULL; dvi->pagesel = spec; dvi->in = p; /* now we can use the dget*() functions */ - /* - * 2. Read the preamble, extract scaling information, and + /* + * 2. Read the preamble, extract scaling information, and * setup the DVI parameters. */ @@ -710,7 +710,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil if((arg = fuget1(p)) != DVI_ID) { mdvi_error(_("%s: unsupported DVI format (version %u)\n"), file, arg); - goto error; /* jump to the end of this routine, + goto error; /* jump to the end of this routine, * where we handle errors */ } /* get dimensions */ @@ -721,8 +721,8 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil /* check that these numbers make sense */ if(!dvi->num || !dvi->den || !dvi->dvimag) goto bad_dvi; - - dvi->params.mag = + + dvi->params.mag = (par->mag > 0 ? par->mag : (double)dvi->dvimag / 1000.0); dvi->params.hdrift = par->hdrift; dvi->params.vdrift = par->vdrift; @@ -764,7 +764,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil fread(dvi->fileid, 1, n, p); dvi->fileid[n] = 0; DEBUG((DBG_DVI, "%s: %s\n", filename, dvi->fileid)); - + /* * 3. Read postamble, extract page information (number of * pages, dimensions) and stack depth. @@ -772,7 +772,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil /* jump to the end of the file */ if(fseek(p, (long)-1, SEEK_END) == -1) - goto error; + goto error; for(n = 0; (op = fuget1(p)) == DVI_TRAILER; n++) if(fseek(p, (long)-2, SEEK_CUR) < 0) break; @@ -795,7 +795,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil dvi->npages = fuget2(p); DEBUG((DBG_DVI, "%s: from postamble: stack depth %d, %d page%s\n", filename, dvi->stacksize, dvi->npages, dvi->npages > 1 ? "s" : "")); - + /* * 4. Process font definitions. */ @@ -803,7 +803,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil /* process font definitions */ dvi->nfonts = 0; dvi->fontmap = NULL; - /* + /* * CAREFUL: here we need to use the dvi->buffer, but it might leave the * the file cursor in the wrong position after reading fonts (because of * buffering). It's ok, though, because after the font definitions we read @@ -812,7 +812,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil */ while((op = duget1(dvi)) != DVI_POST_POST) { DviFontRef *ref; - + if(op == DVI_NOOP) continue; else if(op < DVI_FNT_DEF1 || op > DVI_FNT_DEF4) @@ -826,7 +826,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil } /* we don't need the buffer anymore */ dreset(dvi); - + if(op != DVI_POST_POST) goto bad_dvi; font_finish_definitions(dvi); @@ -840,14 +840,14 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil dvi->pagemap = xnalloc(PageNum, dvi->npages); memzero(dvi->pagemap, sizeof(PageNum) * dvi->npages); - + n = dvi->npages - 1; pagecount = n; while(offset != -1) { int i; PageNum page; - fseek(p, offset, SEEK_SET); + fseek(p, offset, SEEK_SET); op = fuget1(p); if(op != DVI_BOP || n < 0) goto bad_dvi; @@ -875,7 +875,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil DEBUG((DBG_DVI, "%d of %d pages selected\n", dvi->npages - pagecount, dvi->npages)); dvi->npages -= pagecount; - memmove(dvi->pagemap, &dvi->pagemap[pagecount], + memmove(dvi->pagemap, &dvi->pagemap[pagecount], dvi->npages * sizeof(PageNum)); } @@ -934,7 +934,7 @@ void mdvi_destroy_context(DviContext *dvi) mdvi_free(dvi->buffer.data); if(dvi->color_stack) mdvi_free(dvi->color_stack); - + mdvi_free(dvi); } @@ -955,13 +955,13 @@ static int mdvi_run_macro(DviContext *dvi, Uchar *macro, size_t len) int opcode; int oldtop; - dvi->depth++; + dvi->depth++; push(dvi, DVI_PUSH); dvi->pos.w = 0; dvi->pos.x = 0; dvi->pos.y = 0; dvi->pos.z = 0; - + /* save our state */ curr = dvi->currfont; fonts = dvi->fonts; @@ -982,7 +982,7 @@ static int mdvi_run_macro(DviContext *dvi, Uchar *macro, size_t len) break; } if(opcode != DVI_EOP) - dviwarn(dvi, _("%s: vf macro had errors\n"), + dviwarn(dvi, _("%s: vf macro had errors\n"), curr->ref->fontname); if(dvi->stacktop != oldtop) dviwarn(dvi, _("%s: stack not empty after vf macro\n"), @@ -1005,7 +1005,7 @@ int mdvi_dopage(DviContext *dvi, int pageno) int ppi; int reloaded = 0; -again: +again: if(dvi->in == NULL) { /* try reopening the file */ dvi->in = fopen(dvi->filename, "rb"); @@ -1017,7 +1017,7 @@ again: } DEBUG((DBG_FILES, "reopen(%s) -> Ok\n", dvi->filename)); } - + /* check if we need to reload the file */ if(!reloaded && get_mtime(fileno(dvi->in)) > dvi->modtime) { mdvi_reload(dvi, &dvi->params); @@ -1025,20 +1025,20 @@ again: reloaded = 1; goto again; } - + if(pageno < 0 || pageno > dvi->npages-1) { mdvi_error(_("%s: page %d out of range\n"), dvi->filename, pageno); return -1; } - + fseek(dvi->in, (long)dvi->pagemap[pageno][0], SEEK_SET); if((op = fuget1(dvi->in)) != DVI_BOP) { mdvi_error(_("%s: bad offset at page %d\n"), dvi->filename, pageno+1); return -1; } - + /* skip bop */ fseek(dvi->in, (long)44, SEEK_CUR); @@ -1048,7 +1048,7 @@ again: dvi->stacktop = 0; dvi->currpage = pageno; dvi->curr_layer = 0; - + if(dvi->buffer.data && !dvi->buffer.frozen) mdvi_free(dvi->buffer.data); @@ -1062,7 +1062,7 @@ again: /* reset color stack */ mdvi_reset_color(dvi); #endif - + /* set max horizontal and vertical drift (from dvips) */ if(dvi->params.hdrift < 0) { ppi = dvi->params.dpi / dvi->params.hshrink; /* shrunk pixels per inch */ @@ -1085,13 +1085,13 @@ again: dvi->params.thinsp = FROUND(0.025 * dvi->params.dpi / dvi->params.conv); dvi->params.vsmallsp = FROUND(0.025 * dvi->params.vdpi / dvi->params.vconv); - + /* execute all the commands in the page */ while((op = duget1(dvi)) != DVI_EOP) { if(dvi_commands[op](dvi, op) < 0) break; } - + fflush(stdout); fflush(stderr); if(op != DVI_EOP) @@ -1104,7 +1104,7 @@ again: static int inline move_vertical(DviContext *dvi, int amount) { int rvv; - + dvi->pos.v += amount; rvv = vpixel_round(dvi, dvi->pos.v); if(!dvi->params.vdrift) @@ -1113,7 +1113,7 @@ static int inline move_vertical(DviContext *dvi, int amount) return rvv; else { int newvv; - + newvv = dvi->pos.vv + vpixel_round(dvi, amount); if(rvv - newvv > dvi->params.vdrift) return rvv - dvi->params.vdrift; @@ -1121,13 +1121,13 @@ static int inline move_vertical(DviContext *dvi, int amount) return rvv + dvi->params.vdrift; else return newvv; - } + } } static int inline move_horizontal(DviContext *dvi, int amount) { int rhh; - + dvi->pos.h += amount; rhh = pixel_round(dvi, dvi->pos.h); if(!dvi->params.hdrift) @@ -1136,7 +1136,7 @@ static int inline move_horizontal(DviContext *dvi, int amount) return rhh; else { int newhh; - + newhh = dvi->pos.hh + pixel_round(dvi, amount); if(rhh - newhh > dvi->params.hdrift) return rhh - dvi->params.hdrift; @@ -1144,7 +1144,7 @@ static int inline move_horizontal(DviContext *dvi, int amount) return rhh + dvi->params.hdrift; else return newhh; - } + } } static void inline fix_after_horizontal(DviContext *dvi) @@ -1167,7 +1167,7 @@ static void inline fix_after_horizontal(DviContext *dvi) (b) > 0 ? (b) : -(b), (c) static void draw_shrink_rule (DviContext *dvi, int x, int y, Uint w, Uint h, int f) -{ +{ Ulong fg, bg; fg = dvi->curr_fg; @@ -1176,11 +1176,11 @@ static void draw_shrink_rule (DviContext *dvi, int x, int y, Uint w, Uint h, int mdvi_push_color (dvi, fg, bg); dvi->device.draw_rule(dvi, x, y, w, h, f); mdvi_pop_color (dvi); - + return; } -/* +/* * The only commands that actually draw something are: * set_char, set_rule */ @@ -1189,7 +1189,7 @@ static void draw_box(DviContext *dvi, DviFontChar *ch) { DviGlyph *glyph = NULL; int x, y, w, h; - + if(!MDVI_GLYPH_UNSET(ch->shrunk.data)) glyph = &ch->shrunk; else if(!MDVI_GLYPH_UNSET(ch->grey.data)) @@ -1237,7 +1237,7 @@ static void draw_box(DviContext *dvi, DviFontChar *ch) y = h - y; break; } - + draw_shrink_rule(dvi, dvi->pos.hh - x, dvi->pos.vv - y, w, h, 1); } @@ -1248,7 +1248,7 @@ int set_char(DviContext *dvi, int opcode) int hh; DviFontChar *ch; DviFont *font; - + if(opcode < 128) num = opcode; else @@ -1263,18 +1263,18 @@ int set_char(DviContext *dvi, int opcode) /* try to display something anyway */ ch = FONTCHAR(font, num); if(!glyph_present(ch)) { - dviwarn(dvi, - _("requested character %d does not exist in `%s'\n"), + dviwarn(dvi, + _("requested character %d does not exist in `%s'\n"), num, font->fontname); return 0; } draw_box(dvi, ch); } else if(dvi->curr_layer <= dvi->params.layer) { if(ISVIRTUAL(font)) - mdvi_run_macro(dvi, (Uchar *)font->private + + mdvi_run_macro(dvi, (Uchar *)font->private + ch->offset, ch->width); else if(ch->width && ch->height) - dvi->device.draw_glyph(dvi, ch, + dvi->device.draw_glyph(dvi, ch, dvi->pos.hh, dvi->pos.vv); } if(opcode >= DVI_PUT1 && opcode <= DVI_PUT4) { @@ -1292,7 +1292,7 @@ int set_char(DviContext *dvi, int opcode) dvi->pos.hh = hh; fix_after_horizontal(dvi); } - + return 0; } @@ -1300,11 +1300,11 @@ int set_rule(DviContext *dvi, int opcode) { Int32 a, b; int h, w; - + a = dsget4(dvi); b = dsget4(dvi); w = rule_round(dvi, b); if(a > 0 && b > 0) { - h = vrule_round(dvi, a); + h = vrule_round(dvi, a); SHOWCMD((dvi, opcode == DVI_SET_RULE ? "setrule" : "putrule", -1, "width %d, height %d (%dx%d pixels)\n", b, a, w, h)); @@ -1314,11 +1314,11 @@ int set_rule(DviContext *dvi, int opcode) draw_shrink_rule(dvi, dvi->pos.hh, dvi->pos.vv - h + 1, w, h, 1); } - } else { + } else { SHOWCMD((dvi, opcode == DVI_SET_RULE ? "setrule" : "putrule", -1, "(moving left only, by %d)\n", b)); } - + if(opcode == DVI_SET_RULE) { dvi->pos.h += b; dvi->pos.hh += w; @@ -1345,7 +1345,7 @@ int push(DviContext *dvi, int opcode) memcpy(&dvi->stack[dvi->stacktop], &dvi->pos, sizeof(DviState)); SHOWCMD((dvi, "push", -1, "level %d: (h=%d,v=%d,w=%d,x=%d,y=%d,z=%d,hh=%d,vv=%d)\n", - dvi->stacktop, + dvi->stacktop, dvi->pos.h, dvi->pos.v, dvi->pos.w, dvi->pos.x, dvi->pos.y, dvi->pos.z, dvi->pos.hh, dvi->pos.vv)); dvi->stacktop++; @@ -1361,7 +1361,7 @@ int pop(DviContext *dvi, int opcode) memcpy(&dvi->pos, &dvi->stack[dvi->stacktop-1], sizeof(DviState)); SHOWCMD((dvi, "pop", -1, "level %d: (h=%d,v=%d,w=%d,x=%d,y=%d,z=%d,hh=%d,vv=%d)\n", - dvi->stacktop, + dvi->stacktop, dvi->pos.h, dvi->pos.v, dvi->pos.w, dvi->pos.x, dvi->pos.y, dvi->pos.z, dvi->pos.hh, dvi->pos.vv)); dvi->stacktop--; @@ -1372,7 +1372,7 @@ int move_right(DviContext *dvi, int opcode) { Int32 arg; int h, hh; - + arg = dsgetn(dvi, opcode - DVI_RIGHT1 + 1); h = dvi->pos.h; hh = move_horizontal(dvi, arg); @@ -1387,7 +1387,7 @@ int move_down(DviContext *dvi, int opcode) { Int32 arg; int v, vv; - + arg = dsgetn(dvi, opcode - DVI_DOWN1 + 1); v = dvi->pos.v; vv = move_vertical(dvi, arg); @@ -1401,7 +1401,7 @@ int move_down(DviContext *dvi, int opcode) int move_w(DviContext *dvi, int opcode) { int h, hh; - + if(opcode != DVI_W0) dvi->pos.w = dsgetn(dvi, opcode - DVI_W0); h = dvi->pos.h; @@ -1416,13 +1416,13 @@ int move_w(DviContext *dvi, int opcode) int move_x(DviContext *dvi, int opcode) { int h, hh; - + if(opcode != DVI_X0) dvi->pos.x = dsgetn(dvi, opcode - DVI_X0); h = dvi->pos.h; hh = move_horizontal(dvi, dvi->pos.x); SHOWCMD((dvi, "x", opcode - DVI_X0, - "%d h:=%d%c%d=%d, hh:=%d\n", + "%d h:=%d%c%d=%d, hh:=%d\n", dvi->pos.x, DBGSUM(h, dvi->pos.x, dvi->pos.h), hh)); dvi->pos.hh = hh; return 0; @@ -1431,13 +1431,13 @@ int move_x(DviContext *dvi, int opcode) int move_y(DviContext *dvi, int opcode) { int v, vv; - + if(opcode != DVI_Y0) dvi->pos.y = dsgetn(dvi, opcode - DVI_Y0); v = dvi->pos.v; vv = move_vertical(dvi, dvi->pos.y); SHOWCMD((dvi, "y", opcode - DVI_Y0, - "%d h:=%d%c%d=%d, hh:=%d\n", + "%d h:=%d%c%d=%d, hh:=%d\n", dvi->pos.y, DBGSUM(v, dvi->pos.y, dvi->pos.v), vv)); dvi->pos.vv = vv; return 0; @@ -1452,7 +1452,7 @@ int move_z(DviContext *dvi, int opcode) v = dvi->pos.v; vv = move_vertical(dvi, dvi->pos.z); SHOWCMD((dvi, "z", opcode - DVI_Z0, - "%d h:=%d%c%d=%d, hh:=%d\n", + "%d h:=%d%c%d=%d, hh:=%d\n", dvi->pos.z, DBGSUM(v, dvi->pos.z, dvi->pos.v), vv)); dvi->pos.vv = vv; return 0; @@ -1462,7 +1462,7 @@ int sel_font(DviContext *dvi, int opcode) { DviFontRef *ref; int ndx; - + ndx = opcode - DVI_FNT_NUM0; if(dvi->depth) ref = font_find_flat(dvi, ndx); @@ -1484,7 +1484,7 @@ int sel_fontn(DviContext *dvi, int opcode) { Int32 arg; DviFontRef *ref; - + arg = dugetn(dvi, opcode - DVI_FNT1 + 1); if(dvi->depth) ref = font_find_flat(dvi, arg); @@ -1495,7 +1495,7 @@ int sel_fontn(DviContext *dvi, int opcode) return -1; } SHOWCMD((dvi, "fnt", opcode - DVI_FNT1 + 1, - "current font is %s (id %d)\n", + "current font is %s (id %d)\n", ref->ref->fontname, arg)); dvi->currfont = ref; return 0; @@ -1505,7 +1505,7 @@ int special(DviContext *dvi, int opcode) { char *s; Int32 arg; - + arg = dugetn(dvi, opcode - DVI_XXX1 + 1); if (arg <= 0) { dvierr(dvi, _("malformed special length\n")); @@ -1525,7 +1525,7 @@ int def_font(DviContext *dvi, int opcode) { DviFontRef *ref; Int32 arg; - + arg = dugetn(dvi, opcode - DVI_FNT_DEF1 + 1); if(dvi->depth) ref = font_find_flat(dvi, arg); diff --git a/backend/dvi/mdvi-lib/files.c b/backend/dvi/mdvi-lib/files.c index b7065068..fd88be69 100644 --- a/backend/dvi/mdvi-lib/files.c +++ b/backend/dvi/mdvi-lib/files.c @@ -26,13 +26,13 @@ char *dgets(Dstring *dstr, FILE *in) { char buffer[256]; - + dstr->length = 0; if(feof(in)) return NULL; while(fgets(buffer, 256, in) != NULL) { int len = strlen(buffer); - + if(buffer[len-1] == '\n') { dstring_append(dstr, buffer, len - 1); break; @@ -49,21 +49,21 @@ char *dgets(Dstring *dstr, FILE *in) const char *file_basename(const char *filename) { const char *ptr = strrchr(filename, '/'); - + return (ptr ? ptr + 1 : filename); } const char *file_extension(const char *filename) { const char *ptr = strchr(file_basename(filename), '.'); - + return (ptr ? ptr + 1 : NULL); } int file_readable(const char *filename) { int status = (access(filename, R_OK) == 0); - + DEBUG((DBG_FILES, "file_redable(%s) -> %s\n", filename, status ? "Yes" : "No")); return status; @@ -72,7 +72,7 @@ int file_readable(const char *filename) int file_exists(const char *filename) { int status = (access(filename, F_OK) == 0); - + DEBUG((DBG_FILES, "file_exists(%s) -> %s\n", filename, status ? "Yes" : "No")); return status; diff --git a/backend/dvi/mdvi-lib/font.c b/backend/dvi/mdvi-lib/font.c index 2f655df0..56e7bae4 100644 --- a/backend/dvi/mdvi-lib/font.c +++ b/backend/dvi/mdvi-lib/font.c @@ -48,7 +48,7 @@ int font_reopen(DviFont *font) static int load_font_file(DviParams *params, DviFont *font) { int status; - + if(SEARCH_DONE(font->search)) return -1; if(font->in == NULL && font_reopen(font) < 0) @@ -73,7 +73,7 @@ static int load_font_file(DviParams *params, DviFont *font) void font_drop_one(DviFontRef *ref) { DviFont *font; - + font = ref->ref; mdvi_free(ref); /* drop all children */ @@ -82,7 +82,7 @@ void font_drop_one(DviFontRef *ref) ref->ref->links--; } if(--font->links == 0) { - /* + /* * this font doesn't have any more references, but * we still keep it around in case a virtual font * requests it. @@ -104,7 +104,7 @@ void font_drop_one(DviFontRef *ref) void font_drop_chain(DviFontRef *head) { DviFontRef *ptr; - + for(; (ptr = head); ) { head = ptr->next; font_drop_one(ptr); @@ -116,15 +116,15 @@ int font_free_unused(DviDevice *dev) DviFont *font, *next; int count = 0; - DEBUG((DBG_FONTS, "destroying unused fonts\n")); + DEBUG((DBG_FONTS, "destroying unused fonts\n")); for(font = (DviFont *)fontlist.head; font; font = next) { DviFontRef *ref; - + next = font->next; if(font->links) continue; count++; - DEBUG((DBG_FONTS, "removing unused %s font `%s'\n", + DEBUG((DBG_FONTS, "removing unused %s font `%s'\n", TYPENAME(font), font->fontname)); listh_remove(&fontlist, LIST(font)); if(font->in) @@ -164,7 +164,7 @@ font_reference( DviFont *font; DviFontRef *ref; DviFontRef *subfont_ref; - + /* see if there is a font with the same characteristics */ for(font = (DviFont *)fontlist.head; font; font = font->next) { if(strcmp(name, font->fontname) == 0 @@ -210,7 +210,7 @@ void font_transform_glyph(DviOrientation orient, DviGlyph *g) { BITMAP *map; int x, y; - + map = (BITMAP *)g->data; if(MDVI_GLYPH_ISEMPTY(map)) map = NULL; @@ -240,7 +240,7 @@ void font_transform_glyph(DviOrientation orient, DviGlyph *g) g->y = x; SWAPINT(g->w, g->h); break; - case MDVI_ORIENT_RM90: + case MDVI_ORIENT_RM90: if(map) bitmap_rotate_clockwise(map); y = g->h - g->y; x = g->x; @@ -303,7 +303,7 @@ static int load_one_glyph(DviContext *dvi, DviFont *font, int code) /* check if we have to scale it */ if(!font->finfo->scalable && font->hdpi != font->vdpi) { int hs, vs, d; - + /* we scale it ourselves */ d = Max(font->hdpi, font->vdpi); hs = d / font->hdpi; @@ -311,8 +311,8 @@ static int load_one_glyph(DviContext *dvi, DviFont *font, int code) if(ch->width && ch->height && (hs > 1 || vs > 1)) { int h, v; DviGlyph glyph; - - DEBUG((DBG_FONTS, + + DEBUG((DBG_FONTS, "%s: scaling glyph %d to resolution %dx%d\n", font->fontname, code, font->hdpi, font->vdpi)); h = dvi->params.hshrink; @@ -336,10 +336,10 @@ static int load_one_glyph(DviContext *dvi, DviFont *font, int code) ch->glyph.w = glyph.w; ch->glyph.h = glyph.h; } - + } font_transform_glyph(dvi->params.orientation, &ch->glyph); - + return 0; } @@ -351,7 +351,7 @@ again: /* if we have not loaded the font yet, do so now */ if(!font->chars && load_font_file(&dvi->params, font) < 0) return NULL; - + /* get the unscaled glyph, maybe loading it from disk */ ch = FONTCHAR(font, code); if(!ch || !glyph_present(ch)) @@ -371,16 +371,16 @@ again: font->finfo->getglyph == NULL || (dvi->params.hshrink == 1 && dvi->params.vshrink == 1)) return ch; - + /* If the glyph is empty, we just need to shrink the box */ if(ch->missing || MDVI_GLYPH_ISEMPTY(ch->glyph.data)) { if(MDVI_GLYPH_UNSET(ch->shrunk.data)) mdvi_shrink_box(dvi, font, ch, &ch->shrunk); return ch; } else if(MDVI_ENABLED(dvi, MDVI_PARAM_ANTIALIASED)) { - if(ch->grey.data && + if(ch->grey.data && !MDVI_GLYPH_ISEMPTY(ch->grey.data) && - ch->fg == dvi->curr_fg && + ch->fg == dvi->curr_fg && ch->bg == dvi->curr_bg) return ch; if(ch->grey.data && @@ -424,12 +424,12 @@ void font_reset_font_glyphs(DviDevice *dev, DviFont *font, int what) { int i; DviFontChar *ch; - + if(what & MDVI_FONTSEL_GLYPH) - what |= MDVI_FONTSEL_BITMAP|MDVI_FONTSEL_GREY; + what |= MDVI_FONTSEL_BITMAP|MDVI_FONTSEL_GREY; if(font->subfonts) { DviFontRef *ref; - + for(ref = font->subfonts; ref; ref = ref->next) font_reset_font_glyphs(dev, ref->ref, what); } @@ -447,12 +447,12 @@ void font_reset_font_glyphs(DviDevice *dev, DviFont *font, int what) } if((what & MDVI_FONTSEL_GLYPH) && font->finfo->reset) font->finfo->reset(font); -} +} void font_reset_chain_glyphs(DviDevice *dev, DviFontRef *head, int what) { DviFontRef *ref; - + for(ref = head; ref; ref = ref->next) font_reset_font_glyphs(dev, ref->ref, what); } @@ -466,7 +466,7 @@ void font_finish_definitions(DviContext *dvi) { int count; DviFontRef **map, *ref; - + /* first get rid of unused fonts */ font_free_unused(&dvi->device); @@ -485,7 +485,7 @@ void font_finish_definitions(DviContext *dvi) DviFontRef *font_find_flat(DviContext *dvi, Int32 id) { DviFontRef *ref; - + for(ref = dvi->fonts; ref; ref = ref->next) if(ref->fontid == id) break; @@ -496,13 +496,13 @@ DviFontRef *font_find_mapped(DviContext *dvi, Int32 id) { int lo, hi, n; DviFontRef **map; - + /* do a binary search */ lo = 0; hi = dvi->nfonts; map = dvi->fontmap; while(lo < hi) { int sign; - + n = (hi + lo) >> 1; sign = (map[n]->fontid - id); if(sign == 0) diff --git a/backend/dvi/mdvi-lib/fontmap.c b/backend/dvi/mdvi-lib/fontmap.c index 20537c85..553b49da 100644 --- a/backend/dvi/mdvi-lib/fontmap.c +++ b/backend/dvi/mdvi-lib/fontmap.c @@ -61,7 +61,7 @@ static int fontmaps_loaded = 0; #define ENC_HASH_SIZE 31 #define PSMAP_HASH_SIZE 57 -/* this hash table should be big enough to +/* this hash table should be big enough to * hold (ideally) one glyph name per bucket */ #define ENCNAME_HASH_SIZE 131 /* most TeX fonts have 128 glyphs */ @@ -70,7 +70,7 @@ static DviEncoding *tex_text_encoding = NULL; static DviEncoding *default_encoding = NULL; /* we keep two hash tables for encodings: one for their base files (e.g. - * "8r.enc"), and another one for their names (e.g. "TeXBase1Encoding") */ + * "8r.enc"), and another one for their names (e.g. "TeXBase1Encoding") */ static DviHashTable enctable = MDVI_EMPTY_HASH_TABLE; static DviHashTable enctable_file = MDVI_EMPTY_HASH_TABLE; @@ -104,7 +104,7 @@ static void ps_init_default_paths __PROTO((void)); static int mdvi_set_default_encoding __PROTO((const char *name)); static int mdvi_init_fontmaps __PROTO((void)); -/* +/* * What we do here is allocate one block large enough to hold the entire * file (these files are small) minus the leading comments. This is much * better than allocating up to 256 tiny strings per encoding vector. */ @@ -116,7 +116,7 @@ static int read_encoding(DviEncoding *enc) char *name; char *next; struct stat st; - + ASSERT(enc->private == NULL); in = fopen(enc->filename, "rb"); @@ -153,7 +153,7 @@ static int read_encoding(DviEncoding *enc) curr = 0; next = name = NULL; - DEBUG((DBG_FMAP, "%s: reading encoding vector\n", enc->name)); + DEBUG((DBG_FMAP, "%s: reading encoding vector\n", enc->name)); for(line = enc->private; *line && curr < 256; line = next) { SKIPSP(line); if(*line == ']') { @@ -176,13 +176,13 @@ static int read_encoding(DviEncoding *enc) /* got a name */ if(*next) *next++ = 0; - + if(*name == '/') name++; enc->vector[curr] = name; /* add it to the hash table */ if(!STREQ(name, ".notdef")) { - mdvi_hash_add(&enc->nametab, MDVI_KEY(name), + mdvi_hash_add(&enc->nametab, MDVI_KEY(name), Int2Ptr(curr + 1), MDVI_HASH_REPLACE); } curr++; @@ -200,7 +200,7 @@ static int read_encoding(DviEncoding *enc) static DviEncoding *find_encoding(const char *name) { - return (DviEncoding *)(encodings.count ? + return (DviEncoding *)(encodings.count ? mdvi_hash_lookup(&enctable, MDVI_KEY(name)) : NULL); } @@ -249,15 +249,15 @@ static DviEncoding *register_encoding(const char *basefile, int replace) DEBUG((DBG_FMAP, "%s: already there\n", basefile)); return enc; /* no error */ } - } + } /* try our own files first */ - filename = kpse_find_file(basefile, + filename = kpse_find_file(basefile, kpse_program_text_format, 0); /* then try the system-wide ones */ if(filename == NULL) - filename = kpse_find_file(basefile, + filename = kpse_find_file(basefile, kpse_tex_ps_header_format, 0); if(filename == NULL) filename = kpse_find_file(basefile, @@ -272,7 +272,7 @@ static DviEncoding *register_encoding(const char *basefile, int replace) mdvi_free(filename); return NULL; } - + /* just lookup the name of the encoding */ name = NULL; dstring_init(&input); @@ -297,13 +297,13 @@ static DviEncoding *register_encoding(const char *basefile, int replace) offset = ftell(in); fclose(in); if(name == NULL || *name == 0) { - DEBUG((DBG_FMAP, + DEBUG((DBG_FMAP, "%s: could not determine name of encoding\n", basefile)); mdvi_free(filename); return NULL; } - + /* check if the encoding is already there */ enc = find_encoding(name); if(enc == tex_text_encoding) { @@ -347,9 +347,9 @@ static DviEncoding *register_encoding(const char *basefile, int replace) dstring_reset(&input); if(default_encoding == NULL) default_encoding = enc; - mdvi_hash_add(&enctable, MDVI_KEY(enc->name), + mdvi_hash_add(&enctable, MDVI_KEY(enc->name), enc, MDVI_HASH_UNCHECKED); - mdvi_hash_add(&enctable_file, MDVI_KEY(mdvi_strdup(basefile)), + mdvi_hash_add(&enctable_file, MDVI_KEY(mdvi_strdup(basefile)), enc, MDVI_HASH_REPLACE); listh_prepend(&encodings, LIST(enc)); DEBUG((DBG_FMAP, "%s: encoding `%s' registered\n", @@ -377,7 +377,7 @@ DviEncoding *mdvi_request_encoding(const char *name) if(enc->nametab.nkeys == 0) { int i; - DEBUG((DBG_FMAP, "%s: rehashing\n", enc->name)); + DEBUG((DBG_FMAP, "%s: rehashing\n", enc->name)); for(i = 0; i < 256; i++) { if(enc->vector[i] == NULL) continue; @@ -404,7 +404,7 @@ void mdvi_release_encoding(DviEncoding *enc, int should_free) int mdvi_encode_glyph(DviEncoding *enc, const char *name) { void *data; - + data = mdvi_hash_lookup(&enc->nametab, MDVI_KEY(name)); if(data == NULL) return -1; @@ -420,7 +420,7 @@ int mdvi_encode_glyph(DviEncoding *enc, const char *name) static void parse_spec(DviFontMapEnt *ent, char *spec) { char *arg, *command; - + /* this is a ridiculously simple parser, and recognizes only * things of the form . Of these, only * command=SlantFont, ExtendFont and ReEncodeFont are handled */ @@ -429,16 +429,16 @@ static void parse_spec(DviFontMapEnt *ent, char *spec) if(*spec) *spec++ = 0; command = getword(spec, " \t", &spec); if(*spec) *spec++ = 0; - if(!arg || !command) + if(!arg || !command) continue; if(STREQ(command, "SlantFont")) { double x = 10000 * strtod(arg, 0); - - /* SFROUND evaluates arguments twice */ + + /* SFROUND evaluates arguments twice */ ent->slant = SFROUND(x); } else if(STREQ(command, "ExtendFont")) { double x = 10000 * strtod(arg, 0); - + ent->extend = SFROUND(x); } else if(STREQ(command, "ReEncodeFont")) { if(ent->encoding) @@ -485,13 +485,13 @@ DviFontMapEnt *mdvi_load_fontmap(const char *file) } if(in == NULL) return NULL; - + ent = NULL; listh_init(&list); dstring_init(&input); last_encoding = NULL; last_encfile = NULL; - + while((ptr = dgets(&input, in)) != NULL) { char *font_file; char *tex_name; @@ -502,12 +502,12 @@ DviFontMapEnt *mdvi_load_fontmap(const char *file) lineno++; SKIPSP(ptr); - + /* we skip what dvips does */ - if(*ptr <= ' ' || *ptr == '*' || *ptr == '#' || + if(*ptr <= ' ' || *ptr == '*' || *ptr == '#' || *ptr == ';' || *ptr == '%') continue; - + font_file = NULL; tex_name = NULL; ps_name = NULL; @@ -522,14 +522,14 @@ DviFontMapEnt *mdvi_load_fontmap(const char *file) } while(*ptr) { char *hdr_name = NULL; - + while(*ptr && *ptr <= ' ') ptr++; if(*ptr == 0) break; if(*ptr == '"') { char *str; - + str = getstring(ptr, " \t", &ptr); if(*ptr) *ptr++ = 0; parse_spec(ent, str); @@ -557,7 +557,7 @@ DviFontMapEnt *mdvi_load_fontmap(const char *file) if(hdr_name) { const char *ext = file_extension(hdr_name); - + if(is_encoding || (ext && STRCEQ(ext, "enc"))) vec_name = hdr_name; else @@ -576,7 +576,7 @@ DviFontMapEnt *mdvi_load_fontmap(const char *file) /* if we have an encoding file, register it */ if(ent->encfile) { - /* register_encoding is smart enough not to load the + /* register_encoding is smart enough not to load the * same file twice */ if(!last_encfile || !STREQ(last_encfile, ent->encfile)) { last_encfile = ent->encfile; @@ -584,7 +584,7 @@ DviFontMapEnt *mdvi_load_fontmap(const char *file) } enc = last_encoding; } - if(ent->encfile && enc){ + if(ent->encfile && enc){ if(ent->encoding && !STREQ(ent->encoding, enc->name)) { mdvi_warning( _("%s: %d: [%s] requested encoding `%s' does not match vector `%s'\n"), @@ -593,15 +593,15 @@ DviFontMapEnt *mdvi_load_fontmap(const char *file) } else if(!ent->encoding) ent->encoding = mdvi_strdup(enc->name); } - + /* add it to the list */ /*print_ent(ent);*/ listh_append(&list, LIST(ent)); ent = NULL; } - dstring_reset(&input); + dstring_reset(&input); fclose(in); - + return (DviFontMapEnt *)list.head; } @@ -629,7 +629,7 @@ void mdvi_install_fontmap(DviFontMapEnt *head) for(ent = head; ent; ent = next) { /* add all the entries, overriding old ones */ DviFontMapEnt *old; - + old = (DviFontMapEnt *) mdvi_hash_remove(&maptable, MDVI_KEY(ent->fontname)); if(old != NULL) { @@ -639,7 +639,7 @@ void mdvi_install_fontmap(DviFontMapEnt *head) free_ent(old); } next = ent->next; - mdvi_hash_add(&maptable, MDVI_KEY(ent->fontname), + mdvi_hash_add(&maptable, MDVI_KEY(ent->fontname), ent, MDVI_HASH_UNCHECKED); listh_append(&fontmaps, LIST(ent)); } @@ -650,7 +650,7 @@ static void init_static_encoding() DviEncoding *encoding; int i; - DEBUG((DBG_FMAP, "installing static TeX text encoding\n")); + DEBUG((DBG_FMAP, "installing static TeX text encoding\n")); encoding = xalloc(DviEncoding); encoding->private = ""; encoding->filename = ""; @@ -671,7 +671,7 @@ static void init_static_encoding() mdvi_hash_create(&enctable, ENC_HASH_SIZE); mdvi_hash_create(&enctable_file, ENC_HASH_SIZE); enctable_file.hash_free = file_hash_free; - mdvi_hash_add(&enctable, MDVI_KEY(encoding->name), + mdvi_hash_add(&enctable, MDVI_KEY(encoding->name), encoding, MDVI_HASH_UNCHECKED); listh_prepend(&encodings, LIST(encoding)); tex_text_encoding = encoding; @@ -720,7 +720,7 @@ static int mdvi_init_fontmaps(void) /* create the fontmap hash table */ mdvi_hash_create(&maptable, MAP_HASH_SIZE); - + /* get the name of our configuration file */ config = kpse_cnf_get("mdvi-config"); if(config == NULL) @@ -738,13 +738,13 @@ static int mdvi_init_fontmaps(void) dstring_init(&input); while((line = dgets(&input, in)) != NULL) { char *arg, *map_file; - + SKIPSP(line); if(*line < ' ' || *line == '#' || *line == '%') continue; if(STRNEQ(line, "fontmap", 7)) { DviFontMapEnt *ent; - + arg = getstring(line + 7, " \t", &line); *line = 0; DEBUG((DBG_FMAP, "%s: loading fontmap\n", arg)); ent = mdvi_load_fontmap(arg); @@ -756,7 +756,7 @@ static int mdvi_init_fontmaps(void) if(ent == NULL) mdvi_warning(_("%s: could not load fontmap\n"), arg); else { - DEBUG((DBG_FMAP, + DEBUG((DBG_FMAP, "%s: installing fontmap\n", arg)); mdvi_install_fontmap(ent); count++; @@ -804,7 +804,7 @@ int mdvi_query_fontmap(DviFontMapInfo *info, const char *fontname) DviFontMapEnt *ent; if(!fontmaps_loaded && mdvi_init_fontmaps() < 0) - return -1; + return -1; ent = (DviFontMapEnt *)mdvi_hash_lookup(&maptable, MDVI_KEY(fontname)); if(ent == NULL) @@ -815,14 +815,14 @@ int mdvi_query_fontmap(DviFontMapInfo *info, const char *fontname) info->extend = ent->extend; info->slant = ent->slant; info->fullfile = ent->fullfile; - - return 0; + + return 0; } int mdvi_add_fontmap_file(const char *name, const char *fullpath) { DviFontMapEnt *ent; - + if(!fontmaps_loaded && mdvi_init_fontmaps() < 0) return -1; ent = (DviFontMapEnt *)mdvi_hash_lookup(&maptable, MDVI_KEY(name)); @@ -856,13 +856,13 @@ void mdvi_flush_encodings(void) if(tex_text_encoding->nametab.buckets) mdvi_hash_reset(&tex_text_encoding->nametab, 0); mdvi_hash_reset(&enctable, 0); - mdvi_hash_reset(&enctable_file, 0); + mdvi_hash_reset(&enctable_file, 0); } void mdvi_flush_fontmaps(void) { DviFontMapEnt *ent; - + if(!fontmaps_loaded) return; @@ -885,7 +885,7 @@ void ps_init_default_paths(void) ASSERT(psinitialized == 0); kppath = getenv("GS_LIB"); - kfpath = getenv("GS_FONTPATH"); + kfpath = getenv("GS_FONTPATH"); if(kppath != NULL) pslibdir = kpse_path_expand(kppath); @@ -904,7 +904,7 @@ int mdvi_ps_read_fontmap(const char *name) Dstring dstr; char *line; int count = 0; - + if(!psinitialized) ps_init_default_paths(); if(pslibdir) @@ -918,17 +918,17 @@ int mdvi_ps_read_fontmap(const char *name) return -1; } dstring_init(&dstr); - + while((line = dgets(&dstr, in)) != NULL) { char *name; char *mapname; const char *ext; PSFontMap *ps; - + SKIPSP(line); /* we're looking for lines of the form * /FONT-NAME (fontfile) - * /FONT-NAME /FONT-ALIAS + * /FONT-NAME /FONT-ALIAS */ if(*line != '/') continue; @@ -936,12 +936,12 @@ int mdvi_ps_read_fontmap(const char *name) if(*line) *line++ = 0; mapname = getword(line, " \t", &line); if(*line) *line++ = 0; - + if(!name || !mapname || !*name) continue; if(*mapname == '(') { char *end; - + mapname++; for(end = mapname; *end && *end != ')'; end++); *end = 0; @@ -960,7 +960,7 @@ int mdvi_ps_read_fontmap(const char *name) if(ps != NULL) { if(STREQ(ps->mapname, mapname)) continue; - DEBUG((DBG_FMAP, + DEBUG((DBG_FMAP, "(ps) replacing font `%s' (%s) by `%s'\n", name, ps->mapname, mapname)); mdvi_free(ps->mapname); @@ -984,7 +984,7 @@ int mdvi_ps_read_fontmap(const char *name) } fclose(in); dstring_reset(&dstr); - + DEBUG((DBG_FMAP, "(ps) %s: %d PostScript fonts registered\n", fullname, count)); return 0; @@ -993,7 +993,7 @@ int mdvi_ps_read_fontmap(const char *name) void mdvi_ps_flush_fonts(void) { PSFontMap *map; - + if(!psinitialized) return; DEBUG((DBG_FMAP, "(ps) flushing PS font map (%d) entries\n", @@ -1037,11 +1037,11 @@ char *mdvi_ps_find_font(const char *psname) /* is it an alias? */ smap = map; while(recursion_limit-- > 0 && smap && *smap->mapname == '/') - smap = (PSFontMap *)mdvi_hash_lookup(&pstable, + smap = (PSFontMap *)mdvi_hash_lookup(&pstable, MDVI_KEY(smap->mapname + 1)); if(smap == NULL) { if(recursion_limit == 0) - DEBUG((DBG_FMAP, + DEBUG((DBG_FMAP, "(ps) %s: possible loop in PS font map\n", psname)); return NULL; @@ -1055,7 +1055,7 @@ char *mdvi_ps_find_font(const char *psname) filename = NULL; if(filename) map->fullname = mdvi_strdup(filename); - + return filename; } @@ -1071,7 +1071,7 @@ char *mdvi_ps_find_font(const char *psname) * cache, so the next time it will be found at the first step (when we look * up NAME.afm). * - * The name `_ps_' in this function is not meant to imply that it can be + * The name `_ps_' in this function is not meant to imply that it can be * used for Type1 fonts only. It should be usable for TrueType fonts as well. * * The returned metric info is subjected to the same caching mechanism as @@ -1094,7 +1094,7 @@ TFMInfo *mdvi_ps_get_metrics(const char *fontname) double efactor; double sfactor; - DEBUG((DBG_FMAP, "(ps) %s: looking for metric data\n", fontname)); + DEBUG((DBG_FMAP, "(ps) %s: looking for metric data\n", fontname)); info = get_font_metrics(fontname, DviFontAny, NULL); if(info != NULL) return info; @@ -1102,7 +1102,7 @@ TFMInfo *mdvi_ps_get_metrics(const char *fontname) /* query the fontmap */ if(mdvi_query_fontmap(&map, fontname) < 0 || !map.psname) return NULL; - + /* get the PS font */ psfont = mdvi_ps_find_font(map.psname); if(psfont == NULL) @@ -1140,9 +1140,9 @@ TFMInfo *mdvi_ps_get_metrics(const char *fontname) if(info == NULL || (!map.extend && !map.slant)) return info; - /* - * transform the data as prescribed -- keep in mind that `info' - * points to CACHED data, so we're modifying the metric cache + /* + * transform the data as prescribed -- keep in mind that `info' + * points to CACHED data, so we're modifying the metric cache * in place. */ @@ -1174,6 +1174,6 @@ TFMInfo *mdvi_ps_get_metrics(const char *fontname) ch->right = TRANSFORM(ch->right, ch->height); } } - + return info; } diff --git a/backend/dvi/mdvi-lib/fontsrch.c b/backend/dvi/mdvi-lib/fontsrch.c index 8ebaa5ca..77cd8704 100644 --- a/backend/dvi/mdvi-lib/fontsrch.c +++ b/backend/dvi/mdvi-lib/fontsrch.c @@ -72,7 +72,7 @@ static int initialized = 0; static void init_font_classes(void) { int i; - + for(i = 0; i < MAX_CLASS; i++) listh_init(&font_classes[i]); initialized = 1; @@ -88,7 +88,7 @@ char **mdvi_list_font_class(int klass) char **list; int i, n; DviFontClass *fc; - + if(klass == -1) klass = MAX_CLASS-1; if(klass < 0 || klass >= MAX_CLASS) @@ -137,7 +137,7 @@ int mdvi_unregister_font_type(const char *name, int klass) if(klass == -1) klass = MAX_CLASS - 1; - + if(klass >= 0 && klass < MAX_CLASS) { k = klass; LIST_FOREACH(fc, DviFontClass, &font_classes[k]) { @@ -154,12 +154,12 @@ int mdvi_unregister_font_type(const char *name, int klass) } } else return -1; - + if(fc == NULL || fc->links) return -1; /* remove it */ listh_remove(&font_classes[k], LIST(fc)); - + /* and destroy it */ mdvi_free(fc->info.name); mdvi_free(fc); @@ -171,9 +171,9 @@ static char *lookup_font(DviFontClass *ptr, const char *name, Ushort *h, Ushort char *filename; /* - * If the font type registered a function to do the lookup, use that. + * If the font type registered a function to do the lookup, use that. * Otherwise we use kpathsea. - */ + */ if(ptr->info.lookup) filename = ptr->info.lookup(name, h, v); else if(ptr->info.kpse_type <= kpse_any_glyph_format) { @@ -208,7 +208,7 @@ char *mdvi_lookup_font(DviFontSearch *search) if(search->id < 0) return NULL; - + if(search->curr == NULL) { /* this is the initial search */ name = search->wanted_name; @@ -312,7 +312,7 @@ metrics: search->id = -1; search->actual_name = NULL; - + /* tough luck, nothing found */ return NULL; } @@ -322,7 +322,7 @@ DviFont *mdvi_add_font(const char *name, Int32 sum, int hdpi, int vdpi, Int32 scale) { DviFont *font; - + font = xalloc(DviFont); font->fontname = mdvi_strdup(name); SEARCH_INIT(font->search, font->fontname, hdpi, vdpi); @@ -354,7 +354,7 @@ int mdvi_font_retry(DviParams *params, DviFont *font) /* try the search again */ char *filename; - ASSERT(font->search.curr != NULL); + ASSERT(font->search.curr != NULL); /* we won't be using this class anymore */ font->search.curr->links--; diff --git a/backend/dvi/mdvi-lib/gf.c b/backend/dvi/mdvi-lib/gf.c index 00607ff6..d890e156 100644 --- a/backend/dvi/mdvi-lib/gf.c +++ b/backend/dvi/mdvi-lib/gf.c @@ -88,7 +88,7 @@ static int gf_read_bitmap(FILE *p, DviFontChar *ch) Int32 par; BmUnit *line; BITMAP *map; - + fseek(p, (long)ch->offset, SEEK_SET); op = fuget1(p); if(op == GF_BOC) { @@ -106,7 +106,7 @@ static int gf_read_bitmap(FILE *p, DviFontChar *ch) min_m = fuget1(p); /* this is max_m - min_m */ max_m = fuget1(p); min_n = fuget1(p); /* this is max_n - min_n */ - max_n = fuget1(p); + max_n = fuget1(p); min_m = max_m - min_m; min_n = max_n - min_n; } else { @@ -136,18 +136,18 @@ static int gf_read_bitmap(FILE *p, DviFontChar *ch) DEBUG((DBG_BITMAPS, "(gf) reading character %d\n", ch->code)); while((op = fuget1(p)) != GF_EOC) { Int32 n; - + if(feof(p)) break; if(op == GF_PAINT0) { DEBUG((DBG_BITMAPS, "(gf) Paint0 %s -> %s\n", - COLOR(paint_switch), COLOR(!paint_switch))); + COLOR(paint_switch), COLOR(!paint_switch))); paint_switch = !paint_switch; } else if(op <= GF_PAINT3) { if(op < GF_PAINT1) par = op; else - par = fugetn(p, op - GF_PAINT1 + 1); + par = fugetn(p, op - GF_PAINT1 + 1); if(y >= ch->height || x + par >= ch->width) goto toobig; /* paint everything between columns x and x + par - 1 */ @@ -159,14 +159,14 @@ static int gf_read_bitmap(FILE *p, DviFontChar *ch) paint_switch = !paint_switch; x += par; } else if(op >= GF_NEW_ROW_0 && op <= GF_NEW_ROW_MAX) { - y++; + y++; line = bm_offset(line, bpl); x = op - GF_NEW_ROW_0; paint_switch = BLACK; DEBUG((DBG_BITMAPS, "(gf) new_row_%d\n", x)); } else switch(op) { case GF_SKIP0: - y++; + y++; line = bm_offset(line, bpl); x = 0; paint_switch = WHITE; @@ -264,7 +264,7 @@ static int gf_load_font(DviParams *unused, DviFont *font) /* now read character locators in postamble */ if(fseek(p, (long)-1, SEEK_END) == -1) return -1; - + n = 0; while((op = fuget1(p)) == GF_TRAILER) { if(fseek(p, (long)-2, SEEK_CUR) < 0) @@ -306,7 +306,7 @@ static int gf_load_font(DviParams *unused, DviFont *font) DviFontChar *ch; int cc; - /* get the character code */ + /* get the character code */ cc = fuget1(p); if(cc < loc) loc = cc; @@ -342,11 +342,11 @@ static int gf_load_font(DviParams *unused, DviFont *font) ch->grey.data = NULL; ch->flags = 0; ch->loaded = 0; - } + } if(op != GF_POST_POST) goto badgf; - + if(loc > 0 || hic < 255) { /* shrink to optimal size */ memmove(font->chars, font->chars + loc, @@ -373,11 +373,11 @@ error: static int gf_font_get_glyph(DviParams *params, DviFont *font, int code) { DviFontChar *ch; - + if(code < font->loc || code > font->hic || !font->chars) return -1; ch = &font->chars[code - font->loc]; - + if(!ch->loaded) { if(ch->offset == 0) return -1; diff --git a/backend/dvi/mdvi-lib/hash.c b/backend/dvi/mdvi-lib/hash.c index d359e3c8..3327fa58 100644 --- a/backend/dvi/mdvi-lib/hash.c +++ b/backend/dvi/mdvi-lib/hash.c @@ -33,7 +33,7 @@ static Ulong hash_string(DviHashKey key) { Uchar *p; Ulong h, g; - + for(h = 0, p = (Uchar *)key; *p; p++) { h = (h << 4UL) + *p; if((g = h & 0xf0000000L) != 0) { @@ -41,7 +41,7 @@ static Ulong hash_string(DviHashKey key) h ^= g; } } - + return h; } @@ -63,7 +63,7 @@ void mdvi_hash_init(DviHashTable *hash) void mdvi_hash_create(DviHashTable *hash, int size) { int i; - + hash->nbucks = size; hash->buckets = xnalloc(DviHashBucket *, size); for(i = 0; i < size; i++) @@ -78,9 +78,9 @@ static DviHashBucket *hash_find(DviHashTable *hash, DviHashKey key) { Ulong hval; DviHashBucket *buck; - + hval = (hash->hash_func(key) % hash->nbucks); - + for(buck = hash->buckets[hval]; buck; buck = buck->next) if(hash->hash_comp(buck->key, key) == 0) break; @@ -92,7 +92,7 @@ int mdvi_hash_add(DviHashTable *hash, DviHashKey key, void *data, int rep) { DviHashBucket *buck = NULL; Ulong hval; - + if(rep != MDVI_HASH_UNCHECKED) { buck = hash_find(hash, key); if(buck != NULL) { @@ -112,11 +112,11 @@ int mdvi_hash_add(DviHashTable *hash, DviHashKey key, void *data, int rep) hash->buckets[hval] = buck; hash->nkeys++; } - + /* save key and data */ buck->key = key; buck->data = data; - + return 0; } @@ -131,10 +131,10 @@ static DviHashBucket *hash_remove(DviHashTable *hash, DviHashKey key) { DviHashBucket *buck, *last; Ulong hval; - + hval = hash->hash_func(key); hval %= hash->nbucks; - + for(last = NULL, buck = hash->buckets[hval]; buck; buck = buck->next) { if(hash->hash_comp(buck->key, key) == 0) break; @@ -167,10 +167,10 @@ void *mdvi_hash_remove_ptr(DviHashTable *hash, DviHashKey key) DviHashBucket *buck, *last; Ulong hval; void *ptr; - + hval = hash->hash_func(key); hval %= hash->nbucks; - + for(last = NULL, buck = hash->buckets[hval]; buck; buck = buck->next) { if(buck->key == key) break; @@ -192,20 +192,20 @@ void *mdvi_hash_remove_ptr(DviHashTable *hash, DviHashKey key) int mdvi_hash_destroy_key(DviHashTable *hash, DviHashKey key) { DviHashBucket *buck = hash_remove(hash, key); - + if(buck == NULL) return -1; if(hash->hash_free) hash->hash_free(buck->key, buck->data); mdvi_free(buck); - return 0; + return 0; } void mdvi_hash_reset(DviHashTable *hash, int reuse) { int i; DviHashBucket *buck; - + /* remove all keys in the hash table */ for(i = 0; i < hash->nbucks; i++) { for(; (buck = hash->buckets[i]); ) { diff --git a/backend/dvi/mdvi-lib/mdvi.h b/backend/dvi/mdvi-lib/mdvi.h index 37664a76..a05f9278 100644 --- a/backend/dvi/mdvi-lib/mdvi.h +++ b/backend/dvi/mdvi-lib/mdvi.h @@ -62,34 +62,34 @@ typedef Ulong DviColor; typedef enum { FALSE = 0, - TRUE = 1 + TRUE = 1 } DviBool; #include "hash.h" #include "paper.h" -/* +/* * information about a page: * pagenum[0] = offset to BOP * pagenum[1], ..., pagenum[10] = TeX \counters */ typedef long PageNum[11]; -/* this structure contains the platform-specific information +/* this structure contains the platform-specific information * required to interpret a DVI file */ -typedef void (*DviGlyphDraw) __PROTO((DviContext *context, +typedef void (*DviGlyphDraw) __PROTO((DviContext *context, DviFontChar *glyph, int x, int y)); typedef void (*DviRuleDraw) __PROTO((DviContext *context, - int x, int y, + int x, int y, Uint width, Uint height, int fill)); typedef int (*DviColorScale) __PROTO((void *device_data, - Ulong *pixels, + Ulong *pixels, int npixels, - Ulong foreground, + Ulong foreground, Ulong background, double gamma, int density)); @@ -104,7 +104,7 @@ typedef void (*DviDevDestroy) __PROTO((void *data)); typedef void (*DviRefresh) __PROTO((DviContext *dvi, void *device_data)); typedef void (*DviSetColor) __PROTO((void *device_data, Ulong, Ulong)); typedef void (*DviPSDraw) __PROTO((DviContext *context, - const char *filename, + const char *filename, int x, int y, Uint width, Uint height)); @@ -155,7 +155,7 @@ struct _DviGlyph { void *data; /* bitmap or XImage */ }; -typedef void (*DviFontShrinkFunc) +typedef void (*DviFontShrinkFunc) __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); typedef int (*DviFontLoadFunc) __PROTO((DviParams *, DviFont *)); typedef int (*DviFontGetGlyphFunc) __PROTO((DviParams *, DviFont *, int)); @@ -351,7 +351,7 @@ struct _DviState { int w; int x; int y; - int z; + int z; }; struct _DviColorPair { @@ -415,7 +415,7 @@ struct _DviRange { }; -typedef void (*DviSpecialHandler) +typedef void (*DviSpecialHandler) __PROTO((DviContext *dvi, const char *prefix, const char *arg)); #define RANGE_HAS_LOWER(x) \ @@ -433,7 +433,7 @@ typedef void (*DviSpecialHandler) #define MDVI_PARAM_SHOWUNDEF 8 #define MDVI_PARAM_DELAYFONTS 16 -/* +/* * The FALLBACK priority class is reserved for font formats that * contain no glyph information and are to be used as a last * resort (e.g. TFM, AFM) @@ -553,10 +553,10 @@ extern void mdvi_flush_specials __PROTO((void)); #define glyph_present(x) ((x) && (x)->offset) /* create a reference to a font */ -extern DviFontRef *font_reference __PROTO((DviParams *params, - Int32 dvi_id, - const char *font_name, - Int32 checksum, +extern DviFontRef *font_reference __PROTO((DviParams *params, + Int32 dvi_id, + const char *font_name, + Int32 checksum, int xdpi, int ydpi, Int32 scale_factor)); diff --git a/backend/dvi/mdvi-lib/pagesel.c b/backend/dvi/mdvi-lib/pagesel.c index 5a153955..82c59a37 100644 --- a/backend/dvi/mdvi-lib/pagesel.c +++ b/backend/dvi/mdvi-lib/pagesel.c @@ -47,7 +47,7 @@ DviRange *mdvi_parse_range(const char *format, DviRange *limit, int *nitems, cha char * text; DviRange one; DviRange *range; - + quoted = (*format == '{'); if(quoted) format++; @@ -59,7 +59,7 @@ DviRange *mdvi_parse_range(const char *format, DviRange *limit, int *nitems, cha lower = 0; upper = 0; type = MDVI_RANGE_UNBOUNDED; - + if(limit) { switch(limit->type) { case MDVI_RANGE_BOUNDED: @@ -96,7 +96,7 @@ DviRange *mdvi_parse_range(const char *format, DviRange *limit, int *nitems, cha int this_type; int lower_given = 0; int upper_given = 0; - + if(*cp == 0 || *cp == '.' || (*cp == '}' && quoted)) done = 1; else if(*cp != ',') @@ -109,7 +109,7 @@ DviRange *mdvi_parse_range(const char *format, DviRange *limit, int *nitems, cha f = lower; t = upper; s = 1; - + p = strchr(text, ':'); if(p) *p++ = 0; if(*text) { @@ -165,7 +165,7 @@ finish: one.to = t; one.from = f; one.step = s; - + if(curr == size) { size += 8; range = mdvi_realloc(range, size * sizeof(DviRange)); @@ -174,7 +174,7 @@ finish: *cp = ch; text = cp + 1; } - if(done) + if(done) cp--; if(quoted && *cp == '}') cp++; @@ -189,7 +189,7 @@ finish: DviPageSpec *mdvi_parse_page_spec(const char *format) { - /* + /* * a page specification looks like this: * '{'RANGE_SPEC'}' for a DVI spec * '{'RANGE_SPEC'}' '.' ... for a TeX spec @@ -199,7 +199,7 @@ DviPageSpec *mdvi_parse_page_spec(const char *format) int count; int i; char *ptr; - + spec = xnalloc(struct _DviPageSpec *, 11); for(i = 0; i < 11; i++) spec[i] = NULL; @@ -214,7 +214,7 @@ DviPageSpec *mdvi_parse_page_spec(const char *format) } } else range = NULL; - + if(*format == 'D' || *format == 'd' || *ptr != '.') i = 0; else @@ -226,13 +226,13 @@ DviPageSpec *mdvi_parse_page_spec(const char *format) spec[i]->nranges = count; } else spec[i] = NULL; - + if(*ptr != '.') { if(*ptr) mdvi_warning(_("garbage after DVI page specification ignored\n")); return spec; } - + for(i++; *ptr == '.' && i <= 10; i++) { ptr++; if(*ptr == '*') { @@ -240,7 +240,7 @@ DviPageSpec *mdvi_parse_page_spec(const char *format) range = NULL; } else { char *end; - + range = mdvi_parse_range(ptr, NULL, &count, &end); if(end == ptr) { if(range) mdvi_free(range); @@ -255,13 +255,13 @@ DviPageSpec *mdvi_parse_page_spec(const char *format) } else spec[i] = NULL; } - + if(i > 10) mdvi_warning(_("more than 10 counters in page specification\n")); else if(*ptr) mdvi_warning(_("garbage after TeX page specification ignored\n")); - - return spec; + + return spec; } /* returns non-zero if the given page is included by `spec' */ @@ -269,11 +269,11 @@ int mdvi_page_selected(DviPageSpec *spec, PageNum page, int dvipage) { int i; int not_found; - + if(spec == NULL) return 1; if(spec[0]) { - not_found = mdvi_in_range(spec[0]->ranges, + not_found = mdvi_in_range(spec[0]->ranges, spec[0]->nranges, dvipage); if(not_found < 0) return 0; @@ -281,7 +281,7 @@ int mdvi_page_selected(DviPageSpec *spec, PageNum page, int dvipage) for(i = 1; i <= 10; i++) { if(spec[i] == NULL) continue; - not_found = mdvi_in_range(spec[i]->ranges, + not_found = mdvi_in_range(spec[i]->ranges, spec[i]->nranges, (int)page[i]); if(not_found < 0) return 0; @@ -292,7 +292,7 @@ int mdvi_page_selected(DviPageSpec *spec, PageNum page, int dvipage) void mdvi_free_page_spec(DviPageSpec *spec) { int i; - + for(i = 0; i < 11; i++) if(spec[i]) { mdvi_free(spec[i]->ranges); @@ -304,7 +304,7 @@ void mdvi_free_page_spec(DviPageSpec *spec) int mdvi_in_range(DviRange *range, int nitems, int value) { DviRange *r; - + for(r = range; r < range + nitems; r++) { int cond; @@ -330,7 +330,7 @@ int mdvi_in_range(DviRange *range, int nitems, int value) return (r - range); break; case MDVI_RANGE_UPPER: - if(value == r->to) + if(value == r->to) return (r - range); if(r->step < 0) cond = (value > r->to); @@ -352,12 +352,12 @@ int mdvi_range_length(DviRange *range, int nitems) { int count = 0; DviRange *r; - + for(r = range; r < range + nitems; r++) { int n; if(r->type != MDVI_RANGE_BOUNDED) - return -2; + return -2; n = (r->to - r->from) / r->step; if(n < 0) n = 0; @@ -395,7 +395,7 @@ int main() #if 0 char buf[256]; DviRange limit; - + limit.from = 0; limit.to = 100; limit.step = 2; @@ -405,7 +405,7 @@ int main() char *end; int count; int i; - + printf("Range> "); fflush(stdout); if(fgets(buf, 256, stdin) == NULL) break; @@ -419,20 +419,20 @@ int main() printf("range is empty\n"); continue; } - + for(i = 0; i < count; i++) { - printf("Range %d (%d elements):\n", + printf("Range %d (%d elements):\n", i, mdvi_range_length(&range[i], 1)); print_range(&range[i]); } if(end && *end) printf("Tail: [%s]\n", end); - printf("range has %d elements\n", + printf("range has %d elements\n", mdvi_range_length(range, count)); #if 1 while(1) { int v; - + printf("Value: "); fflush(stdout); if(fgets(buf, 256, stdin) == NULL) break; @@ -455,7 +455,7 @@ int main() #else DviPageSpec *spec; char buf[256]; - + while(1) { printf("Spec> "); fflush(stdout); if(fgets(buf, 256, stdin) == NULL) @@ -469,13 +469,13 @@ int main() printf("no spec parsed\n"); else { int i; - + printf("spec = "); for(i = 0; i < 11; i++) { printf("Counter %d:\n", i); if(spec[i]) { int k; - + for(k = 0; k < spec[i]->nranges; k++) print_range(&spec[i]->ranges[k]); } else diff --git a/backend/dvi/mdvi-lib/paper.c b/backend/dvi/mdvi-lib/paper.c index 42cbcd3f..7ba454ab 100644 --- a/backend/dvi/mdvi-lib/paper.c +++ b/backend/dvi/mdvi-lib/paper.c @@ -75,7 +75,7 @@ static const DviPaperSpec papers[] = { {"ledger", "17in", "11in"}, {"note", "7.5in", "10in"}, {"tabloid", "11in", "17in"}, - {"statement", "5.5in", "8.5in"}, + {"statement", "5.5in", "8.5in"}, {0, 0, 0} }; @@ -111,7 +111,7 @@ int mdvi_get_paper_size(const char *name, DviPaper *paper) paper->name = _("custom"); return 0; } - + for(sp = &papers[0]; sp->name; sp++) { if(!sp->width || !sp->height) { paper->pclass = str2class(sp->name); @@ -132,10 +132,10 @@ DviPaperSpec *mdvi_get_paper_specs(DviPaperClass pclass) int i; int first, count; DviPaperSpec *spec, *ptr; - + first = -1; count = 0; - if(pclass == MDVI_PAPER_CLASS_ANY || + if(pclass == MDVI_PAPER_CLASS_ANY || pclass == MDVI_PAPER_CLASS_CUSTOM) { first = 0; count = (sizeof(papers) / sizeof(papers[0])) - 3; diff --git a/backend/dvi/mdvi-lib/pk.c b/backend/dvi/mdvi-lib/pk.c index 1b42a319..5e8da5bb 100644 --- a/backend/dvi/mdvi-lib/pk.c +++ b/backend/dvi/mdvi-lib/pk.c @@ -112,7 +112,7 @@ static char *pk_lookup(const char *name, Ushort *hdpi, Ushort *vdpi) } else if(filename) { *hdpi = *vdpi = type.dpi; } - return filename; + return filename; } static char *pk_lookupn(const char *name, Ushort *hdpi, Ushort *vdpi) @@ -132,7 +132,7 @@ static char *pk_lookupn(const char *name, Ushort *hdpi, Ushort *vdpi) } else if(filename) { *hdpi = *vdpi = type.dpi; } - return filename; + return filename; } static inline int pk_get_nyb(FILE *p, pkread *pk) @@ -140,10 +140,10 @@ static inline int pk_get_nyb(FILE *p, pkread *pk) unsigned t; int nb; char c; - + t = c = pk->currbyte; nb = pk->nybpos; - + switch(nb) { case 0: c = pk->currbyte = fuget1(p); @@ -157,7 +157,7 @@ static inline int pk_get_nyb(FILE *p, pkread *pk) return (t & 0xf); } -/* +/* * this is a bit cumbersome because we have to pass around * the `pkread' data... */ @@ -165,7 +165,7 @@ static int pk_packed_num(FILE *p, pkread *pkr, int *repeat) { int i, j; int dyn_f = pkr->dyn_f; - + i = pk_get_nyb(p, pkr); if(i == 0) { do { @@ -174,12 +174,12 @@ static int pk_packed_num(FILE *p, pkread *pkr, int *repeat) } while(j == 0); while(i-- > 0) j = (j << 4) + pk_get_nyb(p, pkr); - return (j - 15 + ((13 - dyn_f) << 4) + + return (j - 15 + ((13 - dyn_f) << 4) + dyn_f); } else if(i <= dyn_f) return i; else if(i < 14) - return ((i - dyn_f - 1) << 4) + + return ((i - dyn_f - 1) << 4) + pk_get_nyb(p, pkr) + dyn_f + 1; else { *repeat = 1; @@ -198,7 +198,7 @@ static BITMAP *get_bitmap(FILE *p, int w, int h, int flags) BITMAP *bm; int bitpos; int currch; - + flags = 0; /* shut up that compiler */ bitpos = -1; if((bm = bitmap_alloc(w, h)) == NULL) @@ -209,7 +209,7 @@ static BITMAP *get_bitmap(FILE *p, int w, int h, int flags) currch = 0; for(i = 0; i < h; i++) { BmUnit mask; - + mask = FIRSTMASK; for(j = 0; j < w; j++) { if(bitpos < 0) { @@ -238,7 +238,7 @@ static BITMAP *get_packed(FILE *p, int w, int h, int flags) int repeat_count; int paint; pkread pkr; - + pkr.nybpos = 0; pkr.currbyte = 0; pkr.dyn_f = PK_DYN_F(flags); @@ -253,7 +253,7 @@ static BITMAP *get_packed(FILE *p, int w, int h, int flags) w, h, flags)); while(row < h) { int i = 0; - + count = pk_packed_num(p, &pkr, &i); if(i > 0) { if(repeat_count) @@ -261,11 +261,11 @@ static BITMAP *get_packed(FILE *p, int w, int h, int flags) repeat_count, i); repeat_count = i; } - + if(count >= inrow) { Uchar *r, *t; BmUnit *a, mask; - + /* first finish current row */ if(paint) bitmap_set_row(bm, row, w - inrow, inrow, paint); @@ -369,11 +369,11 @@ static int pk_load_font(DviParams *unused, DviFont *font) fuget4(p); fuget4(p); if(feof(p)) - goto badpk; + goto badpk; /* now start reading the font */ loc = 256; hic = -1; maxch = 256; - + /* initialize alpha and beta for TFM width computation */ TFMPREPARE(font->scale, z, alpha, beta); @@ -389,7 +389,7 @@ static int pk_load_font(DviParams *unused, DviFont *font) #ifndef NODEBUG char *t; int n; - + i = fugetn(p, flag_byte - PK_X1 + 1); if(i < 256) t = &s[0]; @@ -428,7 +428,7 @@ static int pk_load_font(DviParams *unused, DviFont *font) int x, y; int offset; long tfm; - + switch(flag_byte & 0x7) { case 7: pl = fuget4(p); @@ -438,13 +438,13 @@ static int pk_load_font(DviParams *unused, DviFont *font) fsget4(p); /* skip dx */ fsget4(p); /* skip dy */ w = fuget4(p); - h = fuget4(p); + h = fuget4(p); x = fsget4(p); y = fsget4(p); break; case 4: case 5: - case 6: + case 6: pl = (flag_byte % 4) * 65536 + fuget2(p); cc = fuget1(p); offset = ftell(p) + pl; @@ -484,7 +484,7 @@ static int pk_load_font(DviParams *unused, DviFont *font) if(cc > hic) hic = cc; if(cc > maxch) { - font->chars = xresize(font->chars, + font->chars = xresize(font->chars, DviFontChar, cc + 16); for(i = maxch; i < cc + 16; i++) font->chars[i].offset = 0; @@ -523,13 +523,13 @@ static int pk_load_font(DviParams *unused, DviFont *font) /* resize font char data */ if(loc > 0 || hic < maxch-1) { - memmove(font->chars, font->chars + loc, + memmove(font->chars, font->chars + loc, (hic - loc + 1) * sizeof(DviFontChar)); font->chars = xresize(font->chars, DviFontChar, hic - loc + 1); } font->loc = loc; - font->hic = hic; + font->hic = hic; return 0; badpk: @@ -547,7 +547,7 @@ static int pk_font_get_glyph(DviParams *params, DviFont *font, int code) if((ch = FONTCHAR(font, code)) == NULL) return -1; - + if(ch->offset == 0) return -1; DEBUG((DBG_GLYPHS, "(pk) loading glyph for character %d (%dx%d) in font `%s'\n", @@ -561,11 +561,11 @@ static int pk_font_get_glyph(DviParams *params, DviFont *font, int code) ch->glyph.w = ch->width; ch->glyph.h = ch->height; ch->glyph.data = NULL; - return 0; + return 0; } if(fseek(font->in, ch->offset, SEEK_SET) == -1) return -1; - ch->glyph.data = get_char(font->in, + ch->glyph.data = get_char(font->in, ch->width, ch->height, ch->flags); if(ch->glyph.data) { /* restore original settings */ diff --git a/backend/dvi/mdvi-lib/setup.c b/backend/dvi/mdvi-lib/setup.c index ba0c545d..881bed50 100644 --- a/backend/dvi/mdvi-lib/setup.c +++ b/backend/dvi/mdvi-lib/setup.c @@ -25,7 +25,7 @@ #include "mdvi.h" #include "private.h" -void mdvi_init_kpathsea(const char *program, +void mdvi_init_kpathsea(const char *program, const char *mfmode, const char *font, int dpi, const char *texmfcnf) { @@ -33,7 +33,7 @@ void mdvi_init_kpathsea(const char *program, /* Stop meaningless output generation. */ kpse_make_tex_discard_errors = FALSE; - + p = strrchr(program, '/'); p = (p ? p + 1 : program); kpse_set_program_name(program, p); diff --git a/backend/dvi/mdvi-lib/sp-epsf.c b/backend/dvi/mdvi-lib/sp-epsf.c index 4f1b49cb..104c955b 100644 --- a/backend/dvi/mdvi-lib/sp-epsf.c +++ b/backend/dvi/mdvi-lib/sp-epsf.c @@ -53,7 +53,7 @@ typedef struct { void epsf_special __PROTO((DviContext *dvi, char *prefix, char *arg)); /* Note: the given strings are modified in place */ -static char *parse_epsf_special(EpsfBox *box, char **ret, +static char *parse_epsf_special(EpsfBox *box, char **ret, char *prefix, char *arg) { static struct { @@ -90,11 +90,11 @@ static char *parse_epsf_special(EpsfBox *box, char **ret, double vsize; double hscale; double vscale; - + /* this special has the form * ["]file.ps["] [key=valye]* */ - + /* scan the filename */ while(*arg == ' ' || *arg == '\t') arg++; @@ -116,7 +116,7 @@ static char *parse_epsf_special(EpsfBox *box, char **ret, value[i] = atof(keys[i].value); present[i] = 0; } - + buff_init(&buffer); buff_add(&buffer, "@beginspecial ", 0); @@ -128,13 +128,13 @@ static char *parse_epsf_special(EpsfBox *box, char **ret, while(*ptr == ' ' || *ptr == '\t') ptr++; keyname = ptr; - + /* get the whole key=value pair */ for(; *ptr && *ptr != ' ' && *ptr != '\t'; ptr++); - + if(*ptr) *ptr++ = 0; /* now we shouldn't touch `ptr' anymore */ - + /* now work on this pair */ p = strchr(keyname, '='); if(p == NULL) @@ -174,18 +174,18 @@ static char *parse_epsf_special(EpsfBox *box, char **ret, } if(val) value[i] = atof(val); - + /* put the argument */ buff_add(&buffer, val, 0); buff_add(&buffer, " @", 2); buff_add(&buffer, keyname, 0); buff_add(&buffer, " ", 1); - + /* remember that this option was given */ present[i] = 0xff; } buff_add(&buffer, " @setspecial", 0); - + /* now compute the bounding box (code comes from dvips) */ originx = 0; originy = 0; @@ -193,7 +193,7 @@ static char *parse_epsf_special(EpsfBox *box, char **ret, vscale = 1; hsize = 0; vsize = 0; - + if(present[HSIZE]) hsize = value[HSIZE]; if(present[VSIZE]) @@ -220,7 +220,7 @@ static char *parse_epsf_special(EpsfBox *box, char **ret, vscale = value[RHI] / (10.0 * vsize); } } - + box->ox = originx; box->oy = originy; box->bw = hsize * hscale; @@ -228,7 +228,7 @@ static char *parse_epsf_special(EpsfBox *box, char **ret, box->angle = value[ANGLE]; *ret = buffer.data; - + return filename; } @@ -243,7 +243,7 @@ void epsf_special(DviContext *dvi, char *prefix, char *arg) int w, h; double xf, vf; struct stat buf; - + file = parse_epsf_special(&box, &special, prefix, arg); if (file != NULL) mdvi_free (special); @@ -272,7 +272,7 @@ void epsf_special(DviContext *dvi, char *prefix, char *arg) if (tmp) { /* Document directory */ int path_len = strlen (dvi->filename) - strlen (tmp + 1); int file_len = strlen (file); - + psfile = mdvi_malloc (path_len + file_len + 1); psfile[0] = '\0'; strncat (psfile, dvi->filename, path_len); @@ -287,7 +287,7 @@ void epsf_special(DviContext *dvi, char *prefix, char *arg) mdvi_free (psfile); } - + psfile = mdvi_build_path_from_cwd (file); if (stat (psfile, &buf) == 0) { /* Current working dir */ dvi->device.draw_ps (dvi, psfile, x, y, w, h); @@ -297,7 +297,7 @@ void epsf_special(DviContext *dvi, char *prefix, char *arg) } mdvi_free (psfile); - + psfile = kpse_find_pict (file); if (psfile) { /* kpse */ dvi->device.draw_ps (dvi, psfile, x, y, w, h); diff --git a/backend/dvi/mdvi-lib/special.c b/backend/dvi/mdvi-lib/special.c index e4832544..e1f1a618 100644 --- a/backend/dvi/mdvi-lib/special.c +++ b/backend/dvi/mdvi-lib/special.c @@ -39,7 +39,7 @@ typedef struct _DviSpecial { #endif DviSpecialHandler handler; } DviSpecial; - + static ListHead specials = {NULL, NULL, 0}; #define SPECIAL(x) \ @@ -65,7 +65,7 @@ static void register_builtin_specials(void) { int i; - ASSERT(registered_builtins == 0); + ASSERT(registered_builtins == 0); registered_builtins = 1; for(i = 0; i < NSPECIALS; i++) mdvi_register_special( @@ -79,7 +79,7 @@ static void register_builtin_specials(void) static DviSpecial *find_special_prefix(const char *prefix) { DviSpecial *sp; - + /* should have a hash table here, but I'm so lazy */ for(sp = (DviSpecial *)specials.head; sp; sp = sp->next) { if(STRCEQ(sp->prefix, prefix)) @@ -88,7 +88,7 @@ static DviSpecial *find_special_prefix(const char *prefix) return sp; } -int mdvi_register_special(const char *label, const char *prefix, +int mdvi_register_special(const char *label, const char *prefix, const char *regex, DviSpecialHandler handler, int replace) { DviSpecial *sp; @@ -127,9 +127,9 @@ int mdvi_register_special(const char *label, const char *prefix, sp->label = mdvi_strdup(label); sp->plen = strlen(prefix); if(newsp) - listh_prepend(&specials, LIST(sp)); - DEBUG((DBG_SPECIAL, - "New \\special handler `%s' with prefix `%s'\n", + listh_prepend(&specials, LIST(sp)); + DEBUG((DBG_SPECIAL, + "New \\special handler `%s' with prefix `%s'\n", label, prefix)); return 0; } @@ -137,8 +137,8 @@ int mdvi_register_special(const char *label, const char *prefix, int mdvi_unregister_special(const char *prefix) { DviSpecial *sp; - - sp = find_special_prefix(prefix); + + sp = find_special_prefix(prefix); if(sp == NULL) return -1; mdvi_free(sp->prefix); @@ -156,7 +156,7 @@ int mdvi_unregister_special(const char *prefix) int mdvi_do_special(DviContext *dvi, char *string) { char *prefix; - char *ptr; + char *ptr; DviSpecial *sp; if(!registered_builtins) { @@ -170,7 +170,7 @@ int mdvi_do_special(DviContext *dvi, char *string) string++; DEBUG((DBG_SPECIAL, "Looking for a handler for `%s'\n", string)); - + /* now try to find a match */ ptr = string; for(sp = (DviSpecial *)specials.head; sp; sp = sp->next) { @@ -193,13 +193,13 @@ int mdvi_do_special(DviContext *dvi, char *string) /* extract the prefix */ if(ptr == string) { prefix = NULL; - DEBUG((DBG_SPECIAL, + DEBUG((DBG_SPECIAL, "REGEX match with `%s' (arg `%s')\n", sp->label, ptr)); } else { if(*ptr) *ptr++ = 0; prefix = string; - DEBUG((DBG_SPECIAL, + DEBUG((DBG_SPECIAL, "PREFIX match with `%s' (prefix `%s', arg `%s')\n", sp->label, prefix, ptr)); } @@ -213,8 +213,8 @@ int mdvi_do_special(DviContext *dvi, char *string) void mdvi_flush_specials(void) { DviSpecial *sp, *list; - - + + for(list = (DviSpecial *)specials.head; (sp = list); ) { list = sp->next; if(sp->prefix) mdvi_free(sp->prefix); diff --git a/backend/dvi/mdvi-lib/sysdeps.h b/backend/dvi/mdvi-lib/sysdeps.h index c77d7651..3955c0dd 100644 --- a/backend/dvi/mdvi-lib/sysdeps.h +++ b/backend/dvi/mdvi-lib/sysdeps.h @@ -18,7 +18,7 @@ #ifndef _SYSDEP_H #define _SYSDEP_H 1 -/* +/* * The purpose of this file is to define symbols that describe the * system-dependent features we use. Namely, byte order, native integer * types of various sizes, and safe pointer<->integer conversion. @@ -75,7 +75,7 @@ typedef short Int16; #endif /* SIZEOF_INT != 2 */ #endif /* SIZEOF_SHORT != 2 */ -/* +/* * An integer type to convert to and from pointers safely. All we do here is * look for an integer type with the same size as a pointer. */ diff --git a/backend/dvi/mdvi-lib/t1.c b/backend/dvi/mdvi-lib/t1.c index d63f055c..12bb01fa 100644 --- a/backend/dvi/mdvi-lib/t1.c +++ b/backend/dvi/mdvi-lib/t1.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* +/* * Type1 font support for MDVI * * We use T1lib only as a rasterizer, not to draw glyphs. @@ -37,7 +37,7 @@ typedef struct t1info { struct t1info *next; struct t1info *prev; char *fontname; /* (short) name of this font */ - int t1id; /* T1lib's id for this font */ + int t1id; /* T1lib's id for this font */ int hasmetrics; /* have we processed this font? */ TFMInfo *tfminfo; /* TFM data is shared */ DviFontMapInfo mapinfo; @@ -47,7 +47,7 @@ typedef struct t1info { static void t1_font_remove __PROTO((T1Info *)); static int t1_load_font __PROTO((DviParams *, DviFont *)); static int t1_font_get_glyph __PROTO((DviParams *, DviFont *, int)); -static void t1_font_shrink_glyph +static void t1_font_shrink_glyph __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); static void t1_free_data __PROTO((DviFont *)); static void t1_reset_font __PROTO((DviFont *)); @@ -79,10 +79,10 @@ static int t1lib_ydpi = -1; static ListHead t1fonts = {NULL, NULL, 0}; static DviHashTable t1hash; -/* Type1 fonts need their own `lookup' function. Here is how it works: +/* Type1 fonts need their own `lookup' function. Here is how it works: * First we try to find the font by its given name. If that fails, we * query the font maps. A typical font map entry may contain the line - * + * * ptmr8rn Times-Roman ".82 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc private; - + if(info == NULL) return; DEBUG((DBG_FONTS, "(t1) resetting font `%s'\n", font->fontname)); @@ -215,19 +215,19 @@ static void t1_transform_font(T1Info *info) mdvi_warning(_("%s: could not encode font\n"), info->fontname); } if(info->mapinfo.slant) { - DEBUG((DBG_TYPE1, "(t1) %s: slanting by %.3f\n", + DEBUG((DBG_TYPE1, "(t1) %s: slanting by %.3f\n", info->fontname, MDVI_FMAP_SLANT(&info->mapinfo))); - T1_SlantFont(info->t1id, + T1_SlantFont(info->t1id, MDVI_FMAP_SLANT(&info->mapinfo)); } if(info->mapinfo.extend) { DEBUG((DBG_TYPE1, "(t1) %s: extending by %.3f\n", info->fontname, MDVI_FMAP_EXTEND(&info->mapinfo))); - T1_ExtendFont(info->t1id, + T1_ExtendFont(info->t1id, MDVI_FMAP_EXTEND(&info->mapinfo)); - } + } } /* if this function is called, we really need this font */ @@ -257,7 +257,7 @@ static int t1_really_load_font(DviParams *params, DviFont *font, T1Info *info) * data for it */ info->tfminfo = mdvi_ps_get_metrics(info->fontname); if(info->tfminfo == NULL) { - DEBUG((DBG_FONTS, + DEBUG((DBG_FONTS, "(t1) %s: no metric data, font ignored\n", info->fontname)); goto t1_error; @@ -274,7 +274,7 @@ static int t1_really_load_font(DviParams *params, DviFont *font, T1Info *info) if(old && old->t1id != -1) { /* let's take advantage of T1lib's font sharing */ t1id = T1_CopyFont(old->t1id); - DEBUG((DBG_TYPE1, "(t1) %s -> %d (CopyFont)\n", + DEBUG((DBG_TYPE1, "(t1) %s -> %d (CopyFont)\n", info->fontname, t1id)); copied = 1; } else { @@ -287,7 +287,7 @@ static int t1_really_load_font(DviParams *params, DviFont *font, T1Info *info) goto t1_error; info->t1id = t1id; - /* + /* * a minor optimization: If the old font in the hash table has * not been loaded yet, replace it by this one, so we can use * CopyFont later. @@ -296,7 +296,7 @@ static int t1_really_load_font(DviParams *params, DviFont *font, T1Info *info) DEBUG((DBG_TYPE1, "(t1) font `%s' exchanged in hash table\n", info->fontname)); mdvi_hash_remove(&t1hash, (unsigned char *)old->fontname); - mdvi_hash_add(&t1hash, (unsigned char *)info->fontname, + mdvi_hash_add(&t1hash, (unsigned char *)info->fontname, info, MDVI_HASH_UNCHECKED); } @@ -323,7 +323,7 @@ static int t1_really_load_font(DviParams *params, DviFont *font, T1Info *info) /* get the scaled characters metrics */ get_tfm_chars(params, font, info->tfminfo, 0); info->hasmetrics = 1; - + DEBUG((DBG_TYPE1, "(t1) font `%s' really-loaded\n", info->fontname)); return 0; @@ -331,7 +331,7 @@ t1_error: /* some error does not allows us to use this font. We need to reset * the font structure, so the font system can try to read this * font in a different class */ - + /* first destroy the private data */ t1_font_remove(info); /* now reset all chars -- this is the important part */ @@ -365,7 +365,7 @@ static int init_t1lib(DviParams *params) mdvi_hash_init(&t1hash); DEBUG((DBG_TYPE1, "(t1) t1lib %s initialized -- resolution is (%d, %d), pad is %d bits\n", T1_GetLibIdent(), params->dpi, params->vdpi, T1_GetBitmapPad())); - t1lib_initialized = 1; + t1lib_initialized = 1; t1lib_xdpi = params->dpi; t1lib_ydpi = params->vdpi; return 0; @@ -375,7 +375,7 @@ static int t1_load_font(DviParams *params, DviFont *font) { T1Info *info; int i; - + if(t1lib_initialized < 0) return -1; else if(t1lib_initialized == 0 && init_t1lib(params) < 0) @@ -389,7 +389,7 @@ static int t1_load_font(DviParams *params, DviFont *font) info = xalloc(T1Info); - /* + /* * mark the font as `unregistered' with T1lib. It will * be added when we actually use it */ @@ -405,15 +405,15 @@ static int t1_load_font(DviParams *params, DviFont *font) info->mapinfo.extend = 0; info->mapinfo.slant = 0; info->encoding = NULL; - + /* create the hash table if we have not done so yet */ if(t1hash.nbucks == 0) mdvi_hash_create(&t1hash, T1_HASH_SIZE); - mdvi_hash_add(&t1hash, (unsigned char *) info->fontname, info, MDVI_HASH_UNIQUE); + mdvi_hash_add(&t1hash, (unsigned char *) info->fontname, info, MDVI_HASH_UNIQUE); listh_append(&t1fonts, LIST(info)); font->private = info; - + /* reset everything */ font->chars = xnalloc(DviFontChar, 256); font->loc = 0; @@ -426,7 +426,7 @@ static int t1_load_font(DviParams *params, DviFont *font) font->chars[i].shrunk.data = NULL; font->chars[i].grey.data = NULL; } - + return 0; } @@ -438,7 +438,7 @@ static int t1_load_font(DviParams *params, DviFont *font) static inline BITMAP *t1_glyph_bitmap(GLYPH *glyph) { int w, h, pad; - + w = GLYPH_WIDTH(glyph); h = GLYPH_HEIGHT(glyph); @@ -455,12 +455,12 @@ static void t1_font_shrink_glyph(DviContext *dvi, DviFont *font, DviFontChar *ch GLYPH *glyph; T1Info *info; T1_TMATRIX matrix; - + info = (T1Info *)font->private; ASSERT(info != NULL); DEBUG((DBG_TYPE1, "(t1) shrinking glyph for character %d in `%s' (%d,%d)\n", - ch->code, font->fontname, ch->width, ch->height)); + ch->code, font->fontname, ch->width, ch->height)); size = (double)font->scale / (dvi->params.tfm_conv * 0x100000); size = 72.0 * size / 72.27; matrix.cxx = 1.0/(double)dvi->params.hshrink; @@ -477,7 +477,7 @@ static void t1_font_shrink_glyph(DviContext *dvi, DviFont *font, DviFontChar *ch #ifndef NODEBUG if(DEBUGGING(BITMAP_DATA)) { - DEBUG((DBG_BITMAP_DATA, + DEBUG((DBG_BITMAP_DATA, "(t1) %s: t1_shrink_glyph(%d): (%dw,%dh,%dx,%dy) -> (%dw,%dh,%dx,%dy)\n", ch->glyph.w, ch->glyph.h, ch->glyph.x, ch->glyph.y, dest->w, dest->h, dest->x, dest->y)); @@ -497,11 +497,11 @@ static int t1_font_get_glyph(DviParams *params, DviFont *font, int code) double size; T1_TMATRIX matrix; int dpi; - + ASSERT(info != NULL); if(!info->hasmetrics && t1_really_load_font(params, font, info) < 0) return -1; - ch = FONTCHAR(font, code); + ch = FONTCHAR(font, code); if(!ch || !glyph_present(ch)) return -1; ch->loaded = 1; @@ -522,7 +522,7 @@ static int t1_font_get_glyph(DviParams *params, DviFont *font, int code) size = 72.0 * size / 72.27; dpi = Max(font->hdpi, font->vdpi); - /* we don't want the glyph to be cached twice (once by us, another by + /* we don't want the glyph to be cached twice (once by us, another by * T1lib), so we use an identity matrix to tell T1lib not to keep the * glyph around */ matrix.cxx = (double)font->hdpi / dpi; @@ -545,21 +545,21 @@ static int t1_font_get_glyph(DviParams *params, DviFont *font, int code) ch->glyph.w = GLYPH_WIDTH(glyph); ch->glyph.h = GLYPH_HEIGHT(glyph); - /* let's also fix the glyph's origin + /* let's also fix the glyph's origin * (which is not contained in the TFM) */ ch->x = ch->glyph.x; ch->y = ch->glyph.y; /* let's fix these too */ ch->width = ch->glyph.w; ch->height = ch->glyph.h; - + return 0; } static void t1_font_remove(T1Info *info) { T1Info *old; - + /* first remove it from our list */ listh_remove(&t1fonts, LIST(info)); @@ -567,13 +567,13 @@ static void t1_font_remove(T1Info *info) old = (T1Info *)mdvi_hash_lookup(&t1hash, (unsigned char *)info->fontname); if(old == info) { mdvi_hash_remove(&t1hash, (unsigned char *) info->fontname); - /* go through the list and see if there is another + /* go through the list and see if there is another * font with this name */ for(old = (T1Info *)t1fonts.head; old; old = old->next) if(STREQ(old->fontname, info->fontname)) break; if(old != NULL) - mdvi_hash_add(&t1hash, (unsigned char *) old->fontname, old, + mdvi_hash_add(&t1hash, (unsigned char *) old->fontname, old, MDVI_HASH_UNCHECKED); } /* release our encoding vector */ @@ -603,17 +603,17 @@ static void t1_free_data(DviFont *font) /* called after all the glyphs are destroyed */ if(font->private == NULL) { - /* this is perfectly normal, it just means the font has + /* this is perfectly normal, it just means the font has * not been requested by MDVI yet */ return; } - + /* destroy this data */ t1_font_remove((T1Info *)font->private); font->private = NULL; - /* + /* * if this is the last T1 font, reset the T1 library * It is important that we do this, because this is will be called * when the resolution or the magnification changes. diff --git a/backend/dvi/mdvi-lib/tfm.c b/backend/dvi/mdvi-lib/tfm.c index f37de0be..f87140d2 100644 --- a/backend/dvi/mdvi-lib/tfm.c +++ b/backend/dvi/mdvi-lib/tfm.c @@ -74,7 +74,7 @@ DviFontInfo afm_font_info = { #define TYPENAME(font) \ ((font)->search.info ? (font)->search.info : "none") -/* +/* * Although it does not seem that way, this conversion is independent of the * shrinking factors, within roundoff (that's because `conv' and `vconv' * have already been scaled by hshrink and vshrink, repsectively). We @@ -91,14 +91,14 @@ int get_tfm_chars(DviParams *params, DviFont *font, TFMInfo *info, int loaded) int n; DviFontChar *ch; TFMChar *ptr; - + n = info->hic - info->loc + 1; if(n != FONT_GLYPH_COUNT(font)) { font->chars = mdvi_realloc(font->chars, n * sizeof(DviFontChar)); } font->loc = info->loc; - font->hic = info->hic; + font->hic = info->hic; ch = font->chars; ptr = info->chars; @@ -120,14 +120,14 @@ int get_tfm_chars(DviParams *params, DviFont *font, TFMInfo *info, int loaded) c = TFMSCALE(z, ptr->height, alpha, beta); d = TFMSCALE(z, ptr->depth, alpha, beta); - /* now convert to unscaled pixels */ + /* now convert to unscaled pixels */ ch->width = XCONV(b - a); ch->height = YCONV(c - d); if(ch->height < 0) ch->height = -ch->height; ch->x = XCONV(a); ch->y = YCONV(c); /* - * the offset is not used, but we might as well set it to + * the offset is not used, but we might as well set it to * something meaningful (and it MUST be non-zero) */ ch->flags = 0; @@ -173,10 +173,10 @@ static int tfm_load_font(DviParams *params, DviFont *font) tfm = get_font_metrics(font->fontname, type, font->filename); if(tfm == NULL) return -1; - + if(tfm->checksum && font->checksum && tfm->checksum != font->checksum) { mdvi_warning(_("%s: Checksum mismatch (got %u, expected %u)\n"), - font->fontname, (unsigned)tfm->checksum, + font->fontname, (unsigned)tfm->checksum, (unsigned)font->checksum); } font->checksum = tfm->checksum; @@ -185,17 +185,17 @@ static int tfm_load_font(DviParams *params, DviFont *font) font->hic = 0; font->chars = NULL; get_tfm_chars(params, font, tfm, 1); - + /* free everything */ free_font_metrics(tfm); - + return 0; } static int tfm_font_get_glyph(DviParams *params, DviFont *font, int code) { DviFontChar *ch; - + ch = FONTCHAR(font, code); if(!glyph_present(ch)) return -1; @@ -203,9 +203,9 @@ static int tfm_font_get_glyph(DviParams *params, DviFont *font, int code) ch->glyph.y = ch->y; ch->glyph.w = ch->width; ch->glyph.h = ch->height; - /* + /* * This has two purposes: (1) avoid unnecessary calls to this function, - * and (2) detect when the glyph data for a TFM font is actually used + * and (2) detect when the glyph data for a TFM font is actually used * (we'll get a SEGV). Any occurrence of that is a bug. */ ch->glyph.data = MDVI_GLYPH_EMPTY; diff --git a/backend/dvi/mdvi-lib/tfmfile.c b/backend/dvi/mdvi-lib/tfmfile.c index c23d9fe0..f7ba251f 100644 --- a/backend/dvi/mdvi-lib/tfmfile.c +++ b/backend/dvi/mdvi-lib/tfmfile.c @@ -51,7 +51,7 @@ static DviHashTable tfmhash; static inline void swap_array(Uint32 *ptr, int n) { Uint32 i; - + while(n-- > 0) { i = *ptr; *ptr++ = ((i & 0xff000000) >> 24) @@ -80,7 +80,7 @@ int afm_load_file(const char *filename, TFMInfo *info) int status; CharMetricInfo *cm; FILE *in; - + in = fopen(filename, "rb"); if(in == NULL) return -1; @@ -91,7 +91,7 @@ int afm_load_file(const char *filename, TFMInfo *info) mdvi_error(_("%s: Error reading AFM data\n"), filename); return -1; } - + /* aim high */ info->chars = xnalloc(TFMChar, 256); info->loc = 256; @@ -106,7 +106,7 @@ int afm_load_file(const char *filename, TFMInfo *info) for(cm = fi->cmi; cm < fi->cmi + fi->numOfChars; cm++) { int code; TFMChar *ch; - + code = cm->code; if(code < 0 || code > 255) continue; /* ignore it */ @@ -179,7 +179,7 @@ int tfm_load_file(const char *filename, TFMInfo *info) /* allocate a word-aligned buffer to hold the file */ size = 4 * ROUND(st.st_size, 4); if(size != st.st_size) - mdvi_warning(_("Warning: TFM file `%s' has suspicious size\n"), + mdvi_warning(_("Warning: TFM file `%s' has suspicious size\n"), filename); tfm = (Uchar *)mdvi_malloc(size); if(fread(tfm, st.st_size, 1, in) != 1) @@ -190,12 +190,12 @@ int tfm_load_file(const char *filename, TFMInfo *info) /* not a checksum, but serves a similar purpose */ checksum = 0; - + ptr = tfm; /* get the counters */ lf = muget2(ptr); lh = muget2(ptr); checksum += 6 + lh; - bc = muget2(ptr); + bc = muget2(ptr); ec = muget2(ptr); checksum += ec - bc + 1; nw = muget2(ptr); checksum += nw; nh = muget2(ptr); checksum += nh; @@ -213,7 +213,7 @@ int tfm_load_file(const char *filename, TFMInfo *info) heights = cb; cb += nh; depths = cb; - if(widths[0] || heights[0] || depths[0] || + if(widths[0] || heights[0] || depths[0] || checksum != lf || bc - 1 > ec || ec > 255 || ne > 256) goto bad_tfm; @@ -250,7 +250,7 @@ int tfm_load_file(const char *filename, TFMInfo *info) ptr += n; } /* now we don't read from `ptr' anymore */ - + info->loc = bc; info->hic = ec; info->type = DviFontTFM; @@ -285,7 +285,7 @@ int tfm_load_file(const char *filename, TFMInfo *info) /* free everything */ mdvi_free(tfm); - + return 0; bad_tfm: @@ -293,7 +293,7 @@ bad_tfm: error: if(tfm) mdvi_free(tfm); if(in) fclose(in); - return -1; + return -1; } static int ofm1_load_file(FILE *in, TFMInfo *info) @@ -309,7 +309,7 @@ static int ofm1_load_file(FILE *in, TFMInfo *info) Int32 *depths; TFMChar *tch; TFMChar *end; - + lh = fuget4(in); bc = fuget4(in); ec = fuget4(in); @@ -355,16 +355,16 @@ static int ofm1_load_file(FILE *in, TFMInfo *info) /* jump to the beginning of the char-info table */ fseek(in, 4L*nco, SEEK_SET); - size = ec - bc + 1; + size = ec - bc + 1; info->loc = bc; info->hic = ec; info->chars = xnalloc(TFMChar, size); end = info->chars + size; - + for(tch = info->chars, i = 0; i < ncw; i++) { TFMChar ch; int nr; - + /* in the characters we store the actual indices */ ch.advance = fuget2(in); ch.height = fuget1(in); @@ -383,7 +383,7 @@ static int ofm1_load_file(FILE *in, TFMInfo *info) memcpy(tch++, &ch, sizeof(TFMChar)); if(tch == end) goto bad_tfm; - } + } /* I wish we were done, but we aren't */ @@ -406,7 +406,7 @@ static int ofm1_load_file(FILE *in, TFMInfo *info) if(widths[0] || heights[0] || depths[0]) goto bad_tfm; - + /* now fix the characters */ size = ec - bc + 1; for(tch = info->chars; tch < end; tch++) { @@ -451,7 +451,7 @@ static int ofm_load_file(const char *filename, TFMInfo *info) /* not a checksum, but serves a similar purpose */ checksum = 0; - + /* get the counters */ /* get file level */ olevel = fsget2(in); @@ -459,7 +459,7 @@ static int ofm_load_file(const char *filename, TFMInfo *info) goto bad_tfm; olevel = fsget2(in); if(olevel != 0) { - DEBUG((DBG_FONTS, "(mt) reading Level-1 OFM file `%s'\n", + DEBUG((DBG_FONTS, "(mt) reading Level-1 OFM file `%s'\n", filename)); /* we handle level-1 files separately */ if(ofm1_load_file(in, info) < 0) @@ -471,7 +471,7 @@ static int ofm_load_file(const char *filename, TFMInfo *info) nwords = 14; lf = fuget4(in); checksum = nwords; lh = fuget4(in); checksum += lh; - bc = fuget4(in); + bc = fuget4(in); ec = fuget4(in); checksum += 2 * (ec - bc + 1); nw = fuget4(in); checksum += nw; nh = fuget4(in); checksum += nh; @@ -482,7 +482,7 @@ static int ofm_load_file(const char *filename, TFMInfo *info) checksum += 2*fuget4(in); /* skip extensible recipe count */ checksum += fuget4(in); /* skip # of font parameters */ - /* I have found several .ofm files that seem to have the + /* I have found several .ofm files that seem to have the * font-direction word missing, so we try to detect that here */ if(checksum == lf + 1) { DEBUG((DBG_FONTS, "(mt) font direction missing in `%s'\n", @@ -553,12 +553,12 @@ static int ofm_load_file(const char *filename, TFMInfo *info) } /* from this point on, no error checking is done */ - + /* we don't need this anymore */ fclose(in); /* now we don't read from `ptr' anymore */ - + info->loc = bc; info->hic = ec; info->type = DviFontTFM; @@ -589,13 +589,13 @@ static int ofm_load_file(const char *filename, TFMInfo *info) bad_tfm: mdvi_error(_("%s: File corrupted, or not a TFM file\n"), filename); fclose(in); - return -1; + return -1; } char *lookup_font_metrics(const char *name, int *type) { char *file; - + switch(*type) { #ifndef WITH_AFM_FILES case DviFontAny: @@ -617,7 +617,7 @@ char *lookup_font_metrics(const char *name, int *type) #ifdef WITH_AFM_FILES case DviFontAFM: file = kpse_find_file(name, kpse_afm_format, 0); - break; + break; case DviFontAny: file = kpse_find_file(name, kpse_afm_format, 0); *type = DviFontAFM; @@ -634,8 +634,8 @@ char *lookup_font_metrics(const char *name, int *type) return file; } -/* - * The next two functions are just wrappers for the font metric loaders, +/* + * The next two functions are just wrappers for the font metric loaders, * and use the pool of TFM data */ @@ -652,9 +652,9 @@ TFMInfo *get_font_metrics(const char *short_name, int type, const char *filename TFMPool *tfm = NULL; int status; char *file; - + if(tfmpool.count) { - tfm = (TFMPool *)mdvi_hash_lookup(&tfmhash, + tfm = (TFMPool *)mdvi_hash_lookup(&tfmhash, MDVI_KEY(short_name)); if(tfm != NULL) { DEBUG((DBG_FONTS, "(mt) reusing metric file `%s' (%d links)\n", @@ -693,11 +693,11 @@ TFMInfo *get_font_metrics(const char *short_name, int type, const char *filename return NULL; } tfm->short_name = mdvi_strdup(short_name); - + /* add it to the pool */ if(tfmpool.count == 0) mdvi_hash_create(&tfmhash, TFM_HASH_SIZE); - mdvi_hash_add(&tfmhash, MDVI_KEY(tfm->short_name), + mdvi_hash_add(&tfmhash, MDVI_KEY(tfm->short_name), tfm, MDVI_HASH_UNCHECKED); listh_prepend(&tfmpool, LIST(tfm)); tfm->links = 1; @@ -719,7 +719,7 @@ void free_font_metrics(TFMInfo *info) if(tfm == NULL) return; if(--tfm->links > 0) { - DEBUG((DBG_FONTS, "(mt) %s not removed, still in use\n", + DEBUG((DBG_FONTS, "(mt) %s not removed, still in use\n", tfm->short_name)); return; } @@ -729,16 +729,16 @@ void free_font_metrics(TFMInfo *info) listh_remove(&tfmpool, LIST(tfm)); mdvi_free(tfm->short_name); mdvi_free(tfm->tfminfo.chars); - mdvi_free(tfm); + mdvi_free(tfm); } void flush_font_metrics(void) { TFMPool *ptr; - + for(; (ptr = (TFMPool *)tfmpool.head); ) { tfmpool.head = LIST(ptr->next); - + mdvi_free(ptr->short_name); mdvi_free(ptr->tfminfo.chars); mdvi_free(ptr); diff --git a/backend/dvi/mdvi-lib/tt.c b/backend/dvi/mdvi-lib/tt.c index e85d8e70..28ce3204 100644 --- a/backend/dvi/mdvi-lib/tt.c +++ b/backend/dvi/mdvi-lib/tt.c @@ -51,7 +51,7 @@ static int tt_load_font __PROTO((DviParams *, DviFont *)); static int tt_font_get_glyph __PROTO((DviParams *, DviFont *, int)); static void tt_free_data __PROTO((DviFont *)); static void tt_reset_font __PROTO((DviFont *)); -static void tt_shrink_glyph +static void tt_shrink_glyph __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); static void tt_font_remove __PROTO((FTInfo *)); @@ -97,14 +97,14 @@ static void tt_encode_font(DviFont *font, FTInfo *info) { TT_Face_Properties prop; int i; - + if(TT_Get_Face_Properties(info->face, &prop)) return; - + for(i = 0; i < prop.num_Glyphs; i++) { char *string; int ndx; - + if(TT_Get_PS_Name(info->face, i, &string)) continue; ndx = mdvi_encode_glyph(info->encoding, string); @@ -127,9 +127,9 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) TT_CharMap cmap; TT_Face_Properties props; int map_found; - + DEBUG((DBG_TT, "(tt) really_load_font(%s)\n", info->fontname)); - + /* get the point size */ point_size = (double)font->scale / (params->tfm_conv * 0x100000); point_size = 72.0 * point_size / 72.27; @@ -142,7 +142,7 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) info->hasmetrics = 1; return 0; } - + /* load the face */ DEBUG((DBG_TT, "(tt) loading new face `%s'\n", info->fontname)); @@ -152,11 +152,11 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) info->fontname, TT_ErrToString18(status)); return -1; } - + /* create a new instance of this face */ status = TT_New_Instance(info->face, &info->instance); if(status) { - mdvi_warning(_("(tt) %s: could not create face: %s\n"), + mdvi_warning(_("(tt) %s: could not create face: %s\n"), info->fontname, TT_ErrToString18(status)); TT_Close_Face(info->face); return -1; @@ -165,12 +165,12 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) /* create a glyph */ status = TT_New_Glyph(info->face, &info->glyph); if(status) { - mdvi_warning(_("(tt) %s: could not create glyph: %s\n"), + mdvi_warning(_("(tt) %s: could not create glyph: %s\n"), info->fontname, TT_ErrToString18(status)); goto tt_error; } - /* + /* * We'll try to find a Unicode charmap. It's not that important that we * actually find one, especially if the fontmap files are installed * properly, but it's good to have some predefined behaviour @@ -180,14 +180,14 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) map_found = -1; for(i = 0; map_found < 0 && i < props.num_CharMaps; i++) { TT_UShort pid, eid; - + TT_Get_CharMap_ID(info->face, i, &pid, &eid); switch(pid) { case TT_PLATFORM_APPLE_UNICODE: map_found = i; break; case TT_PLATFORM_ISO: - if(eid == TT_ISO_ID_7BIT_ASCII || + if(eid == TT_ISO_ID_7BIT_ASCII || eid == TT_ISO_ID_8859_1) map_found = 1; break; @@ -205,7 +205,7 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) DEBUG((DBG_TT, "(tt) %s: using charmap #%d\n", info->fontname, map_found)); TT_Get_CharMap(info->face, map_found, &cmap); - + DEBUG((DBG_TT, "(tt) %s: Set_Char_Size(%.2f, %d, %d)\n", font->fontname, point_size, font->hdpi, font->vdpi)); status = TT_Set_Instance_Resolutions(info->instance, @@ -215,7 +215,7 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) info->fontname, TT_ErrToString18(status)); goto tt_error; } - status = TT_Set_Instance_CharSize(info->instance, + status = TT_Set_Instance_CharSize(info->instance, FROUND(point_size * 64)); if(status) { error(_("(tt) %s: could not set point size: %s\n"), @@ -234,7 +234,7 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) if(info->encoding != NULL) { TT_Post post; - + status = TT_Load_PS_Names(info->face, &post); if(status) { mdvi_warning(_("(tt) %s: could not load PS name table\n"), @@ -245,7 +245,7 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) } /* get the metrics. If this fails, it's not fatal, but certainly bad */ - info->tfminfo = get_font_metrics(info->fontname, + info->tfminfo = get_font_metrics(info->fontname, info->fmftype, info->fmfname); if(info->tfminfo == NULL) { @@ -269,7 +269,7 @@ static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) font->chars[i - font->loc].code = TT_Char_Index(cmap, i); } - info->loaded = 1; + info->loaded = 1; info->hasmetrics = 1; return 0; @@ -285,10 +285,10 @@ static int tt_load_font(DviParams *params, DviFont *font) { int i; FTInfo *info; - + if(!initialized && init_freetype() < 0) return -1; - + if(font->in != NULL) { fclose(font->in); font->in = NULL; @@ -297,7 +297,7 @@ static int tt_load_font(DviParams *params, DviFont *font) info = xalloc(FTInfo); memzero(info, sizeof(FTInfo)); - info->fmftype = DviFontAny; /* any metrics type will do */ + info->fmftype = DviFontAny; /* any metrics type will do */ info->fmfname = lookup_font_metrics(font->fontname, &info->fmftype); info->fontname = font->fontname; info->hasmetrics = 0; @@ -320,17 +320,17 @@ static int tt_load_font(DviParams *params, DviFont *font) font->chars[i].shrunk.data = NULL; font->chars[i].grey.data = NULL; } - + if(info->fmfname == NULL) mdvi_warning(_("(tt) %s: no font metric data\n"), font->fontname); - + listh_append(&ttfonts, LIST(info)); font->private = info; return 0; } -static int tt_get_bitmap(DviParams *params, DviFont *font, +static int tt_get_bitmap(DviParams *params, DviFont *font, int code, double xscale, double yscale, DviGlyph *glyph) { TT_Outline outline; @@ -379,18 +379,18 @@ static int tt_get_bitmap(DviParams *params, DviFont *font, raster.size = h * raster.cols; raster.flow = TT_Flow_Down; raster.bitmap = mdvi_calloc(h, raster.cols); - + TT_Translate_Outline(&outline, -bbox.xMin, -bbox.yMin); TT_Get_Outline_Bitmap(tt_handle, &outline, &raster); glyph->data = bitmap_convert_msb8(raster.bitmap, w, h, ROUND(w, 8)); TT_Done_Outline(&outline); mdvi_free(raster.bitmap); - + return 0; tt_error: if(have_outline) TT_Done_Outline(&outline); - return -1; + return -1; } static int tt_font_get_glyph(DviParams *params, DviFont *font, int code) @@ -400,7 +400,7 @@ static int tt_font_get_glyph(DviParams *params, DviFont *font, int code) int error; double xs, ys; int dpi; - + ASSERT(info != NULL); if(!info->hasmetrics && tt_really_load_font(params, font, info) < 0) return -1; @@ -420,11 +420,11 @@ static int tt_font_get_glyph(DviParams *params, DviFont *font, int code) (double)font->hdpi / dpi, (double)font->vdpi / dpi, &ch->glyph); - if(error) + if(error) goto missing; ch->x = ch->glyph.x; ch->y = ch->glyph.y; - + return 0; missing: @@ -452,10 +452,10 @@ static void tt_shrink_glyph(DviContext *dvi, DviFont *font, DviFontChar *ch, Dvi static void tt_reset_font(DviFont *font) { FTInfo *info = (FTInfo *)font->private; - + if(info == NULL) return; - info->hasmetrics = 0; + info->hasmetrics = 0; } static void tt_font_remove(FTInfo *info) @@ -483,7 +483,7 @@ static void tt_free_data(DviFont *font) { if(font->private == NULL) return; - + tt_font_remove((FTInfo *)font->private); if(initialized && ttfonts.count == 0) { DEBUG((DBG_TT, "(tt) last font removed -- closing FreeType\n")); diff --git a/backend/dvi/mdvi-lib/util.c b/backend/dvi/mdvi-lib/util.c index 349d273a..15b53f13 100644 --- a/backend/dvi/mdvi-lib/util.c +++ b/backend/dvi/mdvi-lib/util.c @@ -85,7 +85,7 @@ int mdvi_set_logstream(FILE *file) int mdvi_set_loglevel(int level) { int old = _mdvi_log_level; - + _mdvi_log_level = level; return old; } @@ -96,7 +96,7 @@ Uint32 _mdvi_debug_mask = 0; void __debug(int mask, const char *format, ...) { va_list ap; - + va_start(ap, format); if(_mdvi_debug_mask & mask) { if(!DEBUGGING(SILENT)) { @@ -118,7 +118,7 @@ void __debug(int mask, const char *format, ...) void mdvi_message(const char *format, ...) { va_list ap; - + va_start(ap, format); if(_mdvi_log_level >= LOG_INFO) { fprintf(stderr, "%s: ", program_name); @@ -135,10 +135,10 @@ void mdvi_message(const char *format, ...) void mdvi_crash(const char *format, ...) { va_list ap; - + va_start(ap, format); - fprintf(stderr, "%s: %s: ", - program_name, + fprintf(stderr, "%s: %s: ", + program_name, gettext(messages[(int)time(NULL) % NMSGS])); vfprintf(stderr, format, ap); #ifndef __GNUC__ @@ -154,7 +154,7 @@ void mdvi_crash(const char *format, ...) void mdvi_error(const char *format, ...) { va_list ap; - + va_start(ap, format); fprintf(stderr, _("%s: Error: "), program_name); vfprintf(stderr, format, ap); @@ -170,7 +170,7 @@ void mdvi_error(const char *format, ...) void mdvi_warning(const char *format, ...) { va_list ap; - + va_start(ap, format); fprintf(stderr, _("%s: Warning: "), program_name); vfprintf(stderr, format, ap); @@ -186,7 +186,7 @@ void mdvi_warning(const char *format, ...) void mdvi_fatal(const char *format, ...) { va_list ap; - + va_start(ap, format); fprintf(stderr, _("%s: Fatal: "), program_name); vfprintf(stderr, format, ap); @@ -207,7 +207,7 @@ void mdvi_fatal(const char *format, ...) void *mdvi_malloc(size_t nelems) { void *ptr = malloc(nelems); - + if(ptr == NULL) mdvi_fatal(_("out of memory allocating %u bytes\n"), (unsigned)nelems); @@ -217,19 +217,19 @@ void *mdvi_malloc(size_t nelems) void *mdvi_realloc(void *data, size_t newsize) { void *ptr; - + if(newsize == 0) mdvi_crash(_("attempted to reallocate with zero size\n")); ptr = realloc(data, newsize); if(ptr == NULL) mdvi_fatal(_("failed to reallocate %u bytes\n"), (unsigned)newsize); - return ptr; + return ptr; } void *mdvi_calloc(size_t nmemb, size_t size) { void *ptr; - + if(nmemb == 0) mdvi_crash(_("attempted to callocate 0 members\n")); if(size == 0) @@ -253,7 +253,7 @@ char *mdvi_strdup(const char *string) { int length; char *ptr; - + length = strlen(string) + 1; ptr = (char *)mdvi_malloc(length); memcpy(ptr, string, length); @@ -272,7 +272,7 @@ char *mdvi_strndup(const char *string, size_t length) { int n; char *ptr; - + n = strlen(string); if(n > length) n = length; @@ -284,7 +284,7 @@ char *mdvi_strndup(const char *string, size_t length) void *mdvi_memdup(const void *data, size_t length) { void *ptr = mdvi_malloc(length); - + memcpy(ptr, data, length); return ptr; } @@ -339,7 +339,7 @@ char *mdvi_build_path_from_cwd (const char *path) buf = mdvi_realloc (buf, strlen (buf) + strlen (path) + 2); strcat (buf, "/"); strncat (buf, path, strlen (path)); - + return buf; } @@ -349,9 +349,9 @@ double unit2pix_factor(const char *spec) double factor; const char *p, *q; static const char *units = "incmmmmtptpcddccspbpftydcs"; - + val = 0.0; - + for(p = spec; *p >= '0' && *p <= '9'; p++) val = 10.0 * val + (double)(*p - '0'); if(*p == '.') { @@ -389,14 +389,14 @@ double unit2pix_factor(const char *spec) int unit2pix(int dpi, const char *spec) { double factor = unit2pix_factor(spec); - + return (int)(factor * dpi + 0.5); } Ulong get_mtime(int fd) { struct stat st; - + if(fstat(fd, &st) == 0) return (Ulong)st.st_mtime; return 0; @@ -419,7 +419,7 @@ char *getword(char *string, const char *delim, char **end) { char *ptr; char *word; - + /* skip leading delimiters */ for(ptr = string; *ptr && strchr(delim, *ptr); ptr++); @@ -438,10 +438,10 @@ char *getstring(char *string, const char *delim, char **end) char *ptr; char *word; int quoted = 0; - + /* skip leading delimiters */ for(ptr = string; *ptr && strchr(delim, *ptr); ptr++); - + if(ptr == NULL) return NULL; quoted = (*ptr == '"'); @@ -456,7 +456,7 @@ char *getstring(char *string, const char *delim, char **end) static long pow2(size_t n) { long x = 8; /* don't bother allocating less than this */ - + while(x < n) x <<= 1L; return x; @@ -487,7 +487,7 @@ int dstring_append(Dstring *dstr, const char *string, int len) dstr->data = mdvi_malloc(8); dstr->data[0] = 0; } - + return dstr->length; } diff --git a/backend/dvi/mdvi-lib/vf.c b/backend/dvi/mdvi-lib/vf.c index a5ae3bbe..5fa5e451 100644 --- a/backend/dvi/mdvi-lib/vf.c +++ b/backend/dvi/mdvi-lib/vf.c @@ -68,11 +68,11 @@ static int vf_load_font(DviParams *params, DviFont *font) int nchars; int loc, hic; DviFontRef *last; - + macros = NULL; msize = mlen = 0; p = font->in; - + if(fuget1(p) != 247 || fuget1(p) != 202) goto badvf; mlen = fuget1(p); @@ -84,14 +84,14 @@ static int vf_load_font(DviParams *params, DviFont *font) } else if(!font->checksum) font->checksum = checksum; font->design = fuget4(p); - + /* read all the fonts in the preamble */ last = NULL; /* initialize alpha, beta and z for TFM width computation */ TFMPREPARE(font->scale, z, alpha, beta); - op = fuget1(p); + op = fuget1(p); while(op >= DVI_FNT_DEF1 && op <= DVI_FNT_DEF4) { DviFontRef *ref; Int32 scale, design; @@ -101,9 +101,9 @@ static int vf_load_font(DviParams *params, DviFont *font) int hdpi; int vdpi; char *name; - + /* process fnt_def commands */ - + id = fugetn(p, op - DVI_FNT_DEF1 + 1); checksum = fuget4(p); scale = fuget4(p); @@ -121,13 +121,13 @@ static int vf_load_font(DviParams *params, DviFont *font) fread(name, 1, n, p); name[n] = 0; DEBUG((DBG_FONTS, "(vf) %s: defined font `%s' at %.1fpt (%dx%d dpi)\n", - font->fontname, name, + font->fontname, name, (double)scale / (params->tfm_conv * 0x100000), hdpi, vdpi)); /* get the font */ ref = font_reference(params, id, name, checksum, hdpi, vdpi, scale); if(ref == NULL) { - mdvi_error(_("(vf) %s: could not load font `%s'\n"), + mdvi_error(_("(vf) %s: could not load font `%s'\n"), font->fontname, name); goto error; } @@ -139,12 +139,12 @@ static int vf_load_font(DviParams *params, DviFont *font) ref->next = NULL; op = fuget1(p); } - + if(op >= DVI_FNT_DEF1 && op <= DVI_FNT_DEF4) goto error; /* This function correctly reads both .vf and .ovf files */ - + font->chars = xnalloc(DviFontChar, 256); for(i = 0; i < 256; i++) font->chars[i].offset = 0; @@ -155,7 +155,7 @@ static int vf_load_font(DviParams *params, DviFont *font) int pl; Int32 cc; Int32 tfm; - + if(op == 242) { pl = fuget4(p); cc = fuget4(p); @@ -176,7 +176,7 @@ static int vf_load_font(DviParams *params, DviFont *font) if(hic < 0 || cc > hic) hic = cc; if(cc >= nchars) { - font->chars = xresize(font->chars, + font->chars = xresize(font->chars, DviFontChar, cc + 16); for(i = nchars; i < cc + 16; i++) font->chars[i].offset = 0; @@ -187,7 +187,7 @@ static int vf_load_font(DviParams *params, DviFont *font) font->fontname, cc); goto error; } - + DEBUG((DBG_GLYPHS, "(vf) %s: defined character %d (macro length %d)\n", font->fontname, cc, pl)); font->chars[cc].width = pl + 1; @@ -215,8 +215,8 @@ static int vf_load_font(DviParams *params, DviFont *font) macros = xresize(macros, Uchar, mlen); msize = mlen; } - - DEBUG((DBG_FONTS|DBG_GLYPHS, + + DEBUG((DBG_FONTS|DBG_GLYPHS, "(vf) %s: macros use %d bytes\n", font->fontname, msize)); if(loc > 0 || hic < nchars-1) { @@ -230,7 +230,7 @@ static int vf_load_font(DviParams *params, DviFont *font) font->private = macros; return 0; - + badvf: mdvi_error(_("%s: File corrupted, or not a VF file.\n"), font->fontname); error: @@ -243,5 +243,5 @@ error: static void vf_free_macros(DviFont *font) { - mdvi_free(font->private); + mdvi_free(font->private); } diff --git a/backend/epub/epub-document.c b/backend/epub/epub-document.c index c0fa275b..a45fe935 100644 --- a/backend/epub/epub-document.c +++ b/backend/epub/epub-document.c @@ -41,13 +41,13 @@ /*For strcasestr(),strstr()*/ #include -typedef enum _xmlParseReturnType +typedef enum _xmlParseReturnType { XML_ATTRIBUTE, XML_KEYWORD }xmlParseReturnType; -typedef struct _contentListNode { +typedef struct _contentListNode { gchar* key ; gchar* value ; gint index ; @@ -87,7 +87,7 @@ struct _EpubDocument }; static void epub_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface); -static void epub_document_document_find_iface_init (EvDocumentFindInterface *iface); +static void epub_document_document_find_iface_init (EvDocumentFindInterface *iface); static void epub_document_document_links_iface_init (EvDocumentLinksInterface *iface); EV_BACKEND_REGISTER_WITH_CODE (EpubDocument, epub_document, @@ -108,10 +108,10 @@ epub_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, gint *height) { gdouble page_width, page_height; - + page_width = 800; page_height = 1080; - + *width = MAX ((gint)(page_width * rc->scale + 0.5), 1); *height = MAX ((gint)(page_height * rc->scale + 0.5), 1); } @@ -150,7 +150,7 @@ in_tag(const char* found) return TRUE; } -static int +static int get_substr_count(const char * haystack,const char *needle,gboolean case_sensitive) { const char* tmp = haystack ; @@ -180,7 +180,7 @@ epub_document_check_hits(EvDocumentFind *document_find, gboolean case_sensitive) { gchar *filepath = g_filename_from_uri((gchar*)page->backend_page,NULL,NULL); - htmlDocPtr htmldoc = xmlParseFile(filepath); + htmlDocPtr htmldoc = xmlParseFile(filepath); htmlNodePtr htmltag = xmlDocGetRootElement(htmldoc); int count=0; htmlNodePtr bodytag = htmltag->xmlChildrenNode; @@ -188,12 +188,12 @@ epub_document_check_hits(EvDocumentFind *document_find, while ( xmlStrcmp(bodytag->name,(xmlChar*)"body") ) { bodytag = bodytag->next; } - + xmlBufferPtr bodybuffer = xmlBufferCreate(); xmlNodeDump(bodybuffer,htmldoc,bodytag,0,1); count = get_substr_count((char*)bodybuffer->content,text,case_sensitive); - + xmlBufferFree(bodybuffer); xmlFreeDoc(htmldoc); g_free (filepath); @@ -234,7 +234,7 @@ epub_document_make_tree_entry(linknode* ListData,LinksCBStruct* UserData) else { expand=FALSE; } - + EvLinkDest *ev_dest = NULL; EvLinkAction *ev_action; @@ -249,14 +249,14 @@ epub_document_make_tree_entry(linknode* ListData,LinksCBStruct* UserData) else { ev_dest = ev_link_dest_new_hlink((gchar*)ListData->pagelink,ListData->page); } - + ev_action = ev_link_action_new_dest (ev_dest); link = ev_link_new((gchar*)ListData->linktext,ev_action); gtk_tree_store_append (GTK_TREE_STORE (UserData->model), &tree_iter,(UserData->parent)); title_markup = g_strdup((gchar*)ListData->linktext); - + gtk_tree_store_set (GTK_TREE_STORE (UserData->model), &tree_iter, EV_DOCUMENT_LINKS_COLUMN_MARKUP, title_markup, EV_DOCUMENT_LINKS_COLUMN_LINK, link, @@ -269,20 +269,20 @@ epub_document_make_tree_entry(linknode* ListData,LinksCBStruct* UserData) cbstruct.model = UserData->model; g_list_foreach (ListData->children,(GFunc)epub_document_make_tree_entry,&cbstruct); } - + g_free (title_markup); - g_object_unref (link); + g_object_unref (link); } static GtkTreeModel * -epub_document_links_get_links_model(EvDocumentLinks *document_links) +epub_document_links_get_links_model(EvDocumentLinks *document_links) { GtkTreeModel *model = NULL; g_return_val_if_fail (EPUB_IS_DOCUMENT (document_links), NULL); - + EpubDocument *epub_document = EPUB_DOCUMENT(document_links); - + model = (GtkTreeModel*) gtk_tree_store_new (EV_DOCUMENT_LINKS_COLUMN_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_OBJECT, @@ -296,9 +296,9 @@ epub_document_links_get_links_model(EvDocumentLinks *document_links) GtkTreeIter parent; linkStruct.parent = &parent; - + gtk_tree_store_append (GTK_TREE_STORE (model), &parent,NULL); - + gtk_tree_store_set (GTK_TREE_STORE (model), &parent, EV_DOCUMENT_LINKS_COLUMN_MARKUP, epub_document->docTitle, EV_DOCUMENT_LINKS_COLUMN_LINK, link, @@ -306,11 +306,11 @@ epub_document_links_get_links_model(EvDocumentLinks *document_links) -1); g_object_unref(link); - + if (epub_document->index) { g_list_foreach (epub_document->index,(GFunc)epub_document_make_tree_entry,&linkStruct); } - + return model; } @@ -332,7 +332,7 @@ epub_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *ifa } static void -epub_document_document_find_iface_init (EvDocumentFindInterface *iface) +epub_document_document_find_iface_init (EvDocumentFindInterface *iface) { iface->check_for_hits = epub_document_check_hits; } @@ -341,7 +341,7 @@ static void epub_document_document_links_iface_init(EvDocumentLinksInterface *iface) { iface->has_document_links = epub_document_links_has_document_links; - iface->get_links_model = epub_document_links_get_links_model; + iface->get_links_model = epub_document_links_get_links_model; iface->get_links = epub_document_links_get_links; } @@ -361,35 +361,35 @@ epub_document_save (EvDocument *document, static int epub_document_get_n_pages (EvDocument *document) -{ +{ EpubDocument *epub_document = EPUB_DOCUMENT (document); if (epub_document-> contentList == NULL) return 0; - + return g_list_length(epub_document->contentList); } /** - * epub_remove_temporary_dir : Removes a directory recursively. + * epub_remove_temporary_dir : Removes a directory recursively. * This function is same as comics_remove_temporary_dir * Returns: * 0 if it was successfully deleted, - * -1 if an error occurred + * -1 if an error occurred */ -static int -epub_remove_temporary_dir (gchar *path_name) +static int +epub_remove_temporary_dir (gchar *path_name) { GDir *content_dir; const gchar *filename; gchar *filename_with_path; - + if (g_file_test (path_name, G_FILE_TEST_IS_DIR)) { content_dir = g_dir_open (path_name, 0, NULL); filename = g_dir_read_name (content_dir); while (filename) { - filename_with_path = - g_build_filename (path_name, + filename_with_path = + g_build_filename (path_name, filename, NULL); epub_remove_temporary_dir (filename_with_path); g_free (filename_with_path); @@ -397,8 +397,8 @@ epub_remove_temporary_dir (gchar *path_name) } g_dir_close (content_dir); } - /* Note from g_remove() documentation: on Windows, it is in general not - * possible to remove a file that is open to some process, or mapped + /* Note from g_remove() documentation: on Windows, it is in general not + * possible to remove a file that is open to some process, or mapped * into memory.*/ return (g_remove (path_name)); } @@ -408,33 +408,33 @@ static gboolean check_mime_type (const gchar* uri, GError** error); -static gboolean +static gboolean open_xml_document (const gchar* filename); -static gboolean +static gboolean set_xml_root_node (xmlChar* rootname); static xmlNodePtr xml_get_pointer_to_node (xmlChar* parserfor, xmlChar* attributename, xmlChar* attributevalue); -static void -xml_parse_children_of_node (xmlNodePtr parent, +static void +xml_parse_children_of_node (xmlNodePtr parent, xmlChar* parserfor, xmlChar* attributename, xmlChar* attributevalue); -static gboolean +static gboolean xml_check_attribute_value (xmlNode* node, xmlChar * attributename, xmlChar* attributevalue); -static xmlChar* +static xmlChar* xml_get_data_from_node (xmlNodePtr node, xmlParseReturnType rettype, xmlChar* attributename); -static void +static void xml_free_doc(); static void @@ -447,9 +447,9 @@ static xmlNodePtr xmlretval ; /* **Functions to parse the xml files. -**Open a XML document for reading +**Open a XML document for reading */ -static gboolean +static gboolean open_xml_document ( const gchar* filename ) { xmldocument = xmlParseFile(filename); @@ -466,16 +466,16 @@ open_xml_document ( const gchar* filename ) /** *Check if the root value is same as rootname . - *if supplied rootvalue = NULL ,just set root to rootnode . + *if supplied rootvalue = NULL ,just set root to rootnode . **/ -static gboolean +static gboolean set_xml_root_node(xmlChar* rootname) { xmlroot = xmlDocGetRootElement(xmldocument); - + if (xmlroot == NULL) { - xmlFreeDoc(xmldocument); + xmlFreeDoc(xmldocument); return FALSE; } @@ -492,7 +492,7 @@ set_xml_root_node(xmlChar* rootname) { return FALSE; } -} +} static xmlNodePtr xml_get_pointer_to_node(xmlChar* parserfor, @@ -517,9 +517,9 @@ xml_get_pointer_to_node(xmlChar* parserfor, if ( xml_check_attribute_value(topchild,attributename,attributevalue) == TRUE ) { xmlretval = topchild; - return xmlretval; + return xmlretval; } - else + else { /*No need to parse children node*/ topchild = topchild->next ; @@ -535,14 +535,14 @@ xml_get_pointer_to_node(xmlChar* parserfor, return xmlretval ; } -static void -xml_parse_children_of_node(xmlNodePtr parent, +static void +xml_parse_children_of_node(xmlNodePtr parent, xmlChar* parserfor, xmlChar* attributename, xmlChar* attributevalue ) { xmlNodePtr child = parent->xmlChildrenNode ; - + while ( child != NULL ) { if ( !xmlStrcmp(child->name,parserfor)) @@ -552,7 +552,7 @@ xml_parse_children_of_node(xmlNodePtr parent, xmlretval = child; return ; } - else + else { /*No need to parse children node*/ child = child->next ; @@ -571,14 +571,14 @@ xml_parse_children_of_node(xmlNodePtr parent, } } -static void +static void xml_free_doc() { xmlFreeDoc(xmldocument); xmldocument = NULL; } -static gboolean +static gboolean xml_check_attribute_value(xmlNode* node, xmlChar * attributename, xmlChar* attributevalue) @@ -586,7 +586,7 @@ xml_check_attribute_value(xmlNode* node, xmlChar* attributefromfile ; if ( attributename == NULL || attributevalue == NULL ) { - return TRUE ; + return TRUE ; } else if ( !xmlStrcmp(( attributefromfile = xmlGetProp(node,attributename)), attributevalue) ) @@ -598,7 +598,7 @@ xml_check_attribute_value(xmlNode* node, return FALSE ; } -static xmlChar* +static xmlChar* xml_get_data_from_node(xmlNodePtr node, xmlParseReturnType rettype, xmlChar* attributename) @@ -617,14 +617,14 @@ check_mime_type(const gchar* uri,GError** error) { GError * err = NULL ; const gchar* mimeFromFile = ev_file_get_mime_type(uri,FALSE,&err); - + gchar* mimetypes[] = {"application/epub+zip","application/x-booki+zip"}; int typecount = 2; if ( !mimeFromFile ) { if (err) { g_propagate_error (error, err); - } + } else { g_set_error_literal (error, EV_DOCUMENT_ERROR, @@ -658,7 +658,7 @@ extract_one_file(EpubDocument* epub_document,GError ** error) GFile * outfile ; gsize writesize = 0; GString * gfilepath ; - unz_file_info64 info ; + unz_file_info64 info ; gchar* directory; GString* dir_create; GFileOutputStream * outstream ; @@ -675,7 +675,7 @@ extract_one_file(EpubDocument* epub_document,GError ** error) directory = g_strrstr(currentfilename,"/") ; if ( directory != NULL ) - directory++; + directory++; gfilepath = g_string_new(epub_document->tmp_archive_dir) ; g_string_append_printf(gfilepath,"/%s",(gchar*)currentfilename); @@ -730,8 +730,8 @@ out: return result; } -static gboolean -extract_epub_from_container (const gchar* uri, +static gboolean +extract_epub_from_container (const gchar* uri, EpubDocument *epub_document, GError ** error) { @@ -742,7 +742,7 @@ extract_epub_from_container (const gchar* uri, { if (err) { g_propagate_error (error, err); - } + } else { g_set_error_literal (error, EV_DOCUMENT_ERROR, @@ -770,7 +770,7 @@ extract_epub_from_container (const gchar* uri, { if (err) { g_propagate_error (error, err); - } + } else { g_set_error_literal (error, EV_DOCUMENT_ERROR, @@ -786,7 +786,7 @@ extract_epub_from_container (const gchar* uri, { if (err) { g_propagate_error (error, err); - } + } else { g_set_error_literal (error, EV_DOCUMENT_ERROR, @@ -802,7 +802,7 @@ extract_epub_from_container (const gchar* uri, { if (err) { g_propagate_error (error, err); - } + } else { g_set_error_literal (error, EV_DOCUMENT_ERROR, @@ -810,7 +810,7 @@ extract_epub_from_container (const gchar* uri, _("could not extract archive")); } goto out; - } + } if ( unzGoToNextFile(epub_document->epubDocument) == UNZ_END_OF_LIST_OF_FILE ) { result = TRUE; @@ -823,18 +823,18 @@ out: return result; } -static gchar* +static gchar* get_uri_to_content(const gchar* uri,GError ** error,EpubDocument *epub_document) { gchar* tmp_archive_dir = epub_document->tmp_archive_dir; GError *err = NULL ; - + gchar *containerpath = g_filename_from_uri(uri,NULL,&err); if ( !containerpath ) { if (err) { g_propagate_error (error,err); - } + } else { g_set_error_literal (error, EV_DOCUMENT_ERROR, @@ -842,7 +842,7 @@ get_uri_to_content(const gchar* uri,GError ** error,EpubDocument *epub_document) _("could not retrieve container file")); } return NULL ; - } + } gboolean result = open_xml_document(containerpath); g_free (containerpath); @@ -852,7 +852,7 @@ get_uri_to_content(const gchar* uri,GError ** error,EpubDocument *epub_document) EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, _("could not open container file")); - + return NULL ; } @@ -861,7 +861,7 @@ get_uri_to_content(const gchar* uri,GError ** error,EpubDocument *epub_document) g_set_error_literal(error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, - _("container file is corrupt")); + _("container file is corrupt")); return NULL ; } @@ -874,7 +874,7 @@ get_uri_to_content(const gchar* uri,GError ** error,EpubDocument *epub_document) _("epub file is invalid or corrupt")); return NULL ; } - + xmlChar *relativepath = xml_get_data_from_node(rootfileNode,XML_ATTRIBUTE,(xmlChar*)"full-path") ; if ( relativepath == NULL ) { @@ -916,7 +916,7 @@ get_uri_to_content(const gchar* uri,GError ** error,EpubDocument *epub_document) if ( !content_uri ) { if (err) { g_propagate_error (error,err); - } + } else { g_set_error_literal (error, @@ -927,7 +927,7 @@ get_uri_to_content(const gchar* uri,GError ** error,EpubDocument *epub_document) return NULL ; } xml_free_doc(); - return content_uri ; + return content_uri ; } static gboolean @@ -967,7 +967,7 @@ setup_document_content_list(const gchar* content_uri, GError** error,gchar *docu EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, _("could not parse content manifest")); - + return FALSE ; } if ( set_xml_root_node((xmlChar*)"package") == FALSE) { @@ -975,25 +975,25 @@ setup_document_content_list(const gchar* content_uri, GError** error,gchar *docu g_set_error_literal(error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, - _("content file is invalid")); + _("content file is invalid")); return FALSE ; } - if ( ( spine = xml_get_pointer_to_node((xmlChar*)"spine",NULL,NULL) )== NULL ) + if ( ( spine = xml_get_pointer_to_node((xmlChar*)"spine",NULL,NULL) )== NULL ) { g_set_error_literal(error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, - _("epub file has no spine")); + _("epub file has no spine")); return FALSE ; } - - if ( ( manifest = xml_get_pointer_to_node((xmlChar*)"manifest",NULL,NULL) )== NULL ) + + if ( ( manifest = xml_get_pointer_to_node((xmlChar*)"manifest",NULL,NULL) )== NULL ) { g_set_error_literal(error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, - _("epub file has no manifest")); + _("epub file has no manifest")); return FALSE ; } @@ -1001,7 +1001,7 @@ setup_document_content_list(const gchar* content_uri, GError** error,gchar *docu /*Get first instance of itemref from the spine*/ xml_parse_children_of_node(spine,(xmlChar*)"itemref",NULL,NULL); - + if ( xmlretval != NULL ) itemrefptr = xmlretval ; else @@ -1020,7 +1020,7 @@ setup_document_content_list(const gchar* content_uri, GError** error,gchar *docu break; } if ( xmlStrcmp(itemrefptr->name,(xmlChar*)"itemref") == 0) - { + { contentListNode *newnode = g_malloc0(sizeof(newnode)); newnode->key = (gchar*)xml_get_data_from_node(itemrefptr,XML_ATTRIBUTE,(xmlChar*)"idref"); if ( newnode->key == NULL ) @@ -1031,7 +1031,7 @@ setup_document_content_list(const gchar* content_uri, GError** error,gchar *docu } xmlretval=NULL ; xml_parse_children_of_node(manifest,(xmlChar*)"item",(xmlChar*)"id",(xmlChar*)newnode->key); - + if ( xmlretval != NULL ) { itemptr = xmlretval ; @@ -1059,7 +1059,7 @@ setup_document_content_list(const gchar* content_uri, GError** error,gchar *docu errorflag = TRUE; break; } - + newnode->index = indexcounter++ ; newlist = g_list_prepend(newlist, newnode); @@ -1075,7 +1075,7 @@ setup_document_content_list(const gchar* content_uri, GError** error,gchar *docu g_propagate_error(error,err); } else - { + { g_set_error_literal(error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_INVALID, @@ -1221,7 +1221,7 @@ setup_index_from_navfile(gchar *tocpath) } static GList* -setup_document_index(EpubDocument *epub_document,gchar *containeruri) +setup_document_index(EpubDocument *epub_document,gchar *containeruri) { GString *tocpath = g_string_new(epub_document->documentdir); gchar *tocfilename = get_toc_file_name(containeruri); @@ -1303,7 +1303,7 @@ setup_document_index(EpubDocument *epub_document,gchar *containeruri) } uri = g_string_new(g_filename_to_uri(pagelink->str,NULL,NULL)); g_string_free(pagelink,TRUE); - + if (fragment) { g_string_append(uri,fragment); } @@ -1312,13 +1312,13 @@ setup_document_index(EpubDocument *epub_document,gchar *containeruri) g_string_free(uri,TRUE); index = g_list_prepend(index,newnode); } - + navPoint = navPoint->next; } while(navPoint != NULL); xml_free_doc(); - + return g_list_reverse(index); } @@ -1378,7 +1378,7 @@ epub_document_get_info(EvDocument *document) epubinfo->title = NULL ; else epubinfo->title = (char*)xml_get_data_from_node(metanode,XML_KEYWORD,NULL); - + metanode = xml_get_pointer_to_node((xmlChar*)"creator",NULL,NULL); if ( metanode == NULL ) epubinfo->author = g_strdup("unknown"); @@ -1394,9 +1394,9 @@ epub_document_get_info(EvDocument *document) buffer = g_string_new((gchar*)xml_get_data_from_node (xmlroot,XML_ATTRIBUTE,(xmlChar*)"version")); g_string_prepend(buffer,"epub "); epubinfo->format = g_string_free(buffer,FALSE); - + /*FIXME: Add more of these as you write the corresponding modules*/ - + epubinfo->layout = EV_DOCUMENT_LAYOUT_SINGLE_PAGE; metanode = xml_get_pointer_to_node((xmlChar*)"publisher",NULL,NULL); @@ -1411,7 +1411,7 @@ epub_document_get_info(EvDocument *document) /*Copying*/ epubinfo->permissions = EV_DOCUMENT_PERMISSIONS_OK_TO_COPY; /*TODO : Add a function to get date*/ - + if (xmldocument) xml_free_doc(); return epubinfo ; @@ -1505,7 +1505,7 @@ add_night_sheet(contentListNode *listdata,gchar *sheet) set_xml_root_node(NULL); xmlNodePtr head = xml_get_pointer_to_node((xmlChar*)"head",NULL,NULL); - + xmlNodePtr link = xmlNewTextChild(head,NULL,(xmlChar*)"link",NULL); xmlAttrPtr href = xmlNewProp(link,(xmlChar*)"href",(xmlChar*)sheeturi); xmlAttrPtr rel = xmlNewProp(link,(xmlChar*)"rel",(xmlChar*)"alternate stylesheet"); @@ -1548,7 +1548,7 @@ epub_document_check_add_night_sheet(EvDocument *document) gchar *csspath = g_strdup_printf("%s/atrilnightstyle.css",epub_document->documentdir); - + GFile *styles = g_file_new_for_path (csspath); GOutputStream *outstream = (GOutputStream*)g_file_create(styles,G_FILE_CREATE_PRIVATE,NULL,NULL); if ( g_output_stream_write((GOutputStream*)outstream,style,strlen(style),NULL,NULL) == -1 ) @@ -1571,7 +1571,7 @@ epub_document_toggle_night_mode(EvDocument *document,gboolean night) EpubDocument *epub_document = EPUB_DOCUMENT(document); g_return_if_fail(EPUB_IS_DOCUMENT(epub_document)); - if (night) + if (night) g_list_foreach(epub_document->contentList,(GFunc)change_to_night_sheet,NULL); else g_list_foreach(epub_document->contentList,(GFunc)change_to_day_sheet,NULL); @@ -1742,7 +1742,7 @@ epub_document_load (EvDocument* document, epub_document->docTitle = epub_document_set_document_title(contentOpfUri); epub_document->index = setup_document_index(epub_document,contentOpfUri); - + epub_document->contentList = setup_document_content_list (contentOpfUri,&err,epub_document->documentdir); if (epub_document->index != NULL && epub_document->contentList != NULL) @@ -1776,13 +1776,13 @@ static void epub_document_finalize (GObject *object) { EpubDocument *epub_document = EPUB_DOCUMENT (object); - + if (epub_document->epubDocument != NULL) { if (epub_remove_temporary_dir (epub_document->tmp_archive_dir) == -1) g_warning (_("There was an error deleting “%s”."), epub_document->tmp_archive_dir); } - + if ( epub_document->contentList ) { g_list_free_full(epub_document->contentList,(GDestroyNotify)free_tree_nodes); epub_document->contentList = NULL; @@ -1819,12 +1819,12 @@ epub_document_class_init (EpubDocumentClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass); - + gobject_class->finalize = epub_document_finalize; ev_document_class->load = epub_document_load; ev_document_class->save = epub_document_save; ev_document_class->get_n_pages = epub_document_get_n_pages; - ev_document_class->get_info = epub_document_get_info; + ev_document_class->get_info = epub_document_get_info; ev_document_class->get_page = epub_document_get_page; ev_document_class->toggle_night_mode = epub_document_toggle_night_mode; ev_document_class->check_add_night_sheet = epub_document_check_add_night_sheet; diff --git a/backend/epub/epub-document.h b/backend/epub/epub-document.h index b1120ec7..962b829a 100644 --- a/backend/epub/epub-document.h +++ b/backend/epub/epub-document.h @@ -14,8 +14,8 @@ typedef struct _EpubDocument EpubDocument; GType epub_document_get_type (void) G_GNUC_CONST; -G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module); - +G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module); + G_END_DECLS #endif /* __EPUB_DOCUMENT_H__ */ diff --git a/backend/epub/minizip/ioapi.h b/backend/epub/minizip/ioapi.h index 137cd64e..7a0f44ad 100644 --- a/backend/epub/minizip/ioapi.h +++ b/backend/epub/minizip/ioapi.h @@ -19,7 +19,7 @@ */ #ifndef _ZLIBIOAPI64_H -#define _ZLIBIOAPI64_H +#define _ZLIBIOAPI64_H #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) diff --git a/backend/pixbuf/pixbuf-document.c b/backend/pixbuf/pixbuf-document.c index 065fe498..a4fe88ed 100644 --- a/backend/pixbuf/pixbuf-document.c +++ b/backend/pixbuf/pixbuf-document.c @@ -35,7 +35,7 @@ struct _PixbufDocument EvDocument parent_instance; GdkPixbuf *pixbuf; - + gchar *uri; }; @@ -46,7 +46,7 @@ static void pixbuf_document_document_thumbnails_iface_init (EvDocumentThumbnails EV_BACKEND_REGISTER_WITH_CODE (PixbufDocument, pixbuf_document, { EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS, - pixbuf_document_document_thumbnails_iface_init) + pixbuf_document_document_thumbnails_iface_init) }); static gboolean @@ -55,7 +55,7 @@ pixbuf_document_load (EvDocument *document, GError **error) { PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - + gchar *filename; GdkPixbuf *pixbuf; @@ -63,7 +63,7 @@ pixbuf_document_load (EvDocument *document, filename = g_filename_from_uri (uri, NULL, error); if (!filename) return FALSE; - + pixbuf = gdk_pixbuf_new_from_file (filename, error); if (!pixbuf) @@ -72,7 +72,7 @@ pixbuf_document_load (EvDocument *document, pixbuf_document->pixbuf = pixbuf; g_free (pixbuf_document->uri); pixbuf_document->uri = g_strdup (uri); - + return TRUE; } @@ -83,7 +83,7 @@ pixbuf_document_save (EvDocument *document, { PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - return ev_xfer_uri_simple (pixbuf_document->uri, uri, error); + return ev_xfer_uri_simple (pixbuf_document->uri, uri, error); } static int @@ -117,7 +117,7 @@ pixbuf_document_render (EvDocument *document, (gdk_pixbuf_get_width (pixbuf_document->pixbuf) * rc->scale) + 0.5, (gdk_pixbuf_get_height (pixbuf_document->pixbuf) * rc->scale) + 0.5, GDK_INTERP_BILINEAR); - + rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, 360 - rc->rotation); g_object_unref (scaled_pixbuf); @@ -134,7 +134,7 @@ pixbuf_document_finalize (GObject *object) g_object_unref (pixbuf_document->pixbuf); g_free (pixbuf_document->uri); - + G_OBJECT_CLASS (pixbuf_document_parent_class)->finalize (object); } @@ -161,10 +161,10 @@ pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); GdkPixbuf *pixbuf, *rotated_pixbuf; gint width, height; - + width = (gint) (gdk_pixbuf_get_width (pixbuf_document->pixbuf) * rc->scale); height = (gint) (gdk_pixbuf_get_height (pixbuf_document->pixbuf) * rc->scale); - + pixbuf = gdk_pixbuf_scale_simple (pixbuf_document->pixbuf, width, height, GDK_INTERP_BILINEAR); @@ -177,7 +177,7 @@ pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, static void pixbuf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, - EvRenderContext *rc, + EvRenderContext *rc, gint *width, gint *height) { diff --git a/backend/pixbuf/pixbuf-document.h b/backend/pixbuf/pixbuf-document.h index a4f677cd..8166facc 100644 --- a/backend/pixbuf/pixbuf-document.h +++ b/backend/pixbuf/pixbuf-document.h @@ -31,8 +31,8 @@ typedef struct _PixbufDocument PixbufDocument; GType pixbuf_document_get_type (void) G_GNUC_CONST; -G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module); - +G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module); + G_END_DECLS #endif /* __PIXBUF_DOCUMENT_H__ */ diff --git a/backend/ps/ev-spectre.c b/backend/ps/ev-spectre.c index b0489b78..f29f7b2c 100644 --- a/backend/ps/ev-spectre.c +++ b/backend/ps/ev-spectre.c @@ -88,13 +88,13 @@ ps_document_load (EvDocument *document, filename = g_filename_from_uri (uri, NULL, error); if (!filename) return FALSE; - + ps->doc = spectre_document_new (); spectre_document_load (ps->doc, filename); if (spectre_document_status (ps->doc)) { gchar *filename_dsp; - + filename_dsp = g_filename_display_name (filename); g_set_error (error, G_FILE_ERROR, @@ -262,7 +262,7 @@ ps_document_get_info (EvDocument *document) ps_page = spectre_document_get_page (ps->doc, 0); spectre_page_get_size (ps_page, &width, &height); spectre_page_free (ps_page); - + info->title = g_strdup (spectre_document_get_title (ps->doc)); info->format = g_strdup (spectre_document_get_format (ps->doc)); info->creator = g_strdup (creator ? creator : spectre_document_get_for (ps->doc)); @@ -300,7 +300,7 @@ ps_document_render (EvDocument *document, static const cairo_user_data_key_t key; ps_page = (SpectrePage *)rc->page->backend_page; - + spectre_page_get_size (ps_page, &width_points, &height_points); width = (gint) ((width_points * rc->scale) + 0.5); @@ -322,7 +322,7 @@ ps_document_render (EvDocument *document, if (spectre_page_status (ps_page)) { g_warning ("%s", spectre_status_to_string (spectre_page_status (ps_page))); g_free (data); - + return NULL; } @@ -333,7 +333,7 @@ ps_document_render (EvDocument *document, swidth = width; sheight = height; } - + surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_RGB24, swidth, sheight, @@ -365,7 +365,7 @@ ps_document_class_init (PSDocumentClass *klass) /* EvDocumentThumbnailsIface */ static GdkPixbuf * ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails, - EvRenderContext *rc, + EvRenderContext *rc, gboolean border) { PSDocument *ps = PS_DOCUMENT (document_thumbnails); @@ -377,13 +377,13 @@ ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails, g_warning ("Error rendering thumbnail"); return NULL; } - + pixbuf = ev_document_misc_pixbuf_from_surface (surface); cairo_surface_destroy (surface); if (border) { GdkPixbuf *border_pixbuf; - + border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf); g_object_unref (pixbuf); pixbuf = border_pixbuf; @@ -394,7 +394,7 @@ ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails, static void ps_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails, - EvRenderContext *rc, + EvRenderContext *rc, gint *width, gint *height) { @@ -420,7 +420,7 @@ ps_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface iface->get_thumbnail = ps_document_thumbnails_get_thumbnail; iface->get_dimensions = ps_document_thumbnails_get_dimensions; } - + /* EvFileExporterIface */ static void ps_document_file_exporter_begin (EvFileExporter *exporter, diff --git a/backend/ps/ev-spectre.h b/backend/ps/ev-spectre.h index de9b7725..cbe4e495 100644 --- a/backend/ps/ev-spectre.h +++ b/backend/ps/ev-spectre.h @@ -1,8 +1,8 @@ /* * Ghostscript widget for GTK/MATE - * + * * Copyright 1998 - 2005 The Free Software Foundation - * + * * Authors: Jaka Mocnik, Federico Mena (Quartic), Szekeres Istvan (Pista) * * This library is free software; you can redistribute it and/or diff --git a/backend/tiff/tiff-document.c b/backend/tiff/tiff-document.c index 0aa31cb6..3d273fee 100644 --- a/backend/tiff/tiff-document.c +++ b/backend/tiff/tiff-document.c @@ -47,7 +47,7 @@ struct _TiffDocument TIFF *tiff; gint n_pages; TIFF2PSContext *ps_export_ctx; - + gchar *uri; }; @@ -89,22 +89,22 @@ tiff_document_load (EvDocument *document, TiffDocument *tiff_document = TIFF_DOCUMENT (document); gchar *filename; TIFF *tiff; - + filename = g_filename_from_uri (uri, NULL, error); if (!filename) return FALSE; - + push_handlers (); tiff = TIFFOpen (filename, "r"); if (tiff) { guint32 w, h; - + /* FIXME: unused data? why bother here */ TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); } - + if (!tiff) { pop_handlers (); @@ -116,12 +116,12 @@ tiff_document_load (EvDocument *document, g_free (filename); return FALSE; } - + tiff_document->tiff = tiff; g_free (tiff_document->uri); g_free (filename); tiff_document->uri = g_strdup (uri); - + pop_handlers (); return TRUE; } @@ -130,24 +130,24 @@ static gboolean tiff_document_save (EvDocument *document, const char *uri, GError **error) -{ +{ TiffDocument *tiff_document = TIFF_DOCUMENT (document); - return ev_xfer_uri_simple (tiff_document->uri, uri, error); + return ev_xfer_uri_simple (tiff_document->uri, uri, error); } static int tiff_document_get_n_pages (EvDocument *document) { TiffDocument *tiff_document = TIFF_DOCUMENT (document); - + g_return_val_if_fail (TIFF_IS_DOCUMENT (document), 0); g_return_val_if_fail (tiff_document->tiff != NULL, 0); - + if (tiff_document->n_pages == -1) { push_handlers (); tiff_document->n_pages = 0; - + do { tiff_document->n_pages ++; } @@ -165,7 +165,7 @@ tiff_document_get_resolution (TiffDocument *tiff_document, { gfloat x = 72.0, y = 72.0; gushort unit; - + if (TIFFGetField (tiff_document->tiff, TIFFTAG_XRESOLUTION, &x) && TIFFGetField (tiff_document->tiff, TIFFTAG_YRESOLUTION, &y)) { if (TIFFGetFieldDefaulted (tiff_document->tiff, TIFFTAG_RESOLUTIONUNIT, &unit)) { @@ -189,24 +189,24 @@ tiff_document_get_page_size (EvDocument *document, guint32 w, h; gfloat x_res, y_res; TiffDocument *tiff_document = TIFF_DOCUMENT (document); - + g_return_if_fail (TIFF_IS_DOCUMENT (document)); g_return_if_fail (tiff_document->tiff != NULL); - + push_handlers (); if (TIFFSetDirectory (tiff_document->tiff, page->index) != 1) { pop_handlers (); return; } - + TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &h); tiff_document_get_resolution (tiff_document, &x_res, &y_res); h = h * (x_res / y_res); - + *width = w; *height = h; - + pop_handlers (); } @@ -224,10 +224,10 @@ tiff_document_render (EvDocument *document, cairo_surface_t *surface; cairo_surface_t *rotated_surface; static const cairo_user_data_key_t key; - + g_return_val_if_fail (TIFF_IS_DOCUMENT (document), NULL); g_return_val_if_fail (tiff_document->tiff != NULL, NULL); - + push_handlers (); if (TIFFSetDirectory (tiff_document->tiff, rc->page->index) != 1) { pop_handlers (); @@ -252,9 +252,9 @@ tiff_document_render (EvDocument *document, } tiff_document_get_resolution (tiff_document, &x_res, &y_res); - + pop_handlers (); - + /* Sanity check the doc */ if (width <= 0 || height <= 0) { g_warning("Invalid width or height."); @@ -265,22 +265,22 @@ tiff_document_render (EvDocument *document, if (rowstride / 4 != width) { g_warning("Overflow while rendering document."); /* overflow, or cairo was changed in an unsupported way */ - return NULL; + return NULL; } - + bytes = height * rowstride; if (bytes / rowstride != height) { g_warning("Overflow while rendering document."); /* overflow */ return NULL; } - + pixels = g_try_malloc (bytes); if (!pixels) { g_warning("Failed to allocate memory for rendering."); return NULL; } - + surface = cairo_image_surface_create_for_data (pixels, CAIRO_FORMAT_RGB24, width, height, @@ -315,7 +315,7 @@ tiff_document_render (EvDocument *document, (height * rc->scale * (x_res / y_res)) + 0.5, rc->rotation); cairo_surface_destroy (surface); - + return rotated_surface; } @@ -331,7 +331,7 @@ tiff_document_render_pixbuf (EvDocument *document, GdkPixbuf *pixbuf; GdkPixbuf *scaled_pixbuf; GdkPixbuf *rotated_pixbuf; - + push_handlers (); if (TIFFSetDirectory (tiff_document->tiff, rc->page->index) != 1) { pop_handlers (); @@ -349,28 +349,28 @@ tiff_document_render_pixbuf (EvDocument *document, } tiff_document_get_resolution (tiff_document, &x_res, &y_res); - + pop_handlers (); - + /* Sanity check the doc */ if (width <= 0 || height <= 0) - return NULL; + return NULL; rowstride = width * 4; if (rowstride / 4 != width) /* overflow */ - return NULL; - + return NULL; + bytes = height * rowstride; if (bytes / rowstride != height) /* overflow */ - return NULL; - + return NULL; + pixels = g_try_malloc (bytes); if (!pixels) return NULL; - - pixbuf = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, TRUE, 8, + + pixbuf = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, TRUE, 8, width, height, rowstride, (GdkPixbufDestroyNotify) g_free, NULL); TIFFReadRGBAImageOriented (tiff_document->tiff, @@ -384,10 +384,10 @@ tiff_document_render_pixbuf (EvDocument *document, height * rc->scale * (x_res / y_res), GDK_INTERP_BILINEAR); g_object_unref (pixbuf); - + rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, 360 - rc->rotation); g_object_unref (scaled_pixbuf); - + return rotated_pixbuf; } @@ -437,26 +437,26 @@ tiff_document_class_init (TiffDocumentClass *klass) static GdkPixbuf * tiff_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, - EvRenderContext *rc, + EvRenderContext *rc, gboolean border) { GdkPixbuf *pixbuf; pixbuf = tiff_document_render_pixbuf (EV_DOCUMENT (document), rc); - + if (border) { GdkPixbuf *tmp_pixbuf = pixbuf; - + pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf); g_object_unref (tmp_pixbuf); } - + return pixbuf; } static void tiff_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, - EvRenderContext *rc, + EvRenderContext *rc, gint *width, gint *height) { diff --git a/backend/tiff/tiff-document.h b/backend/tiff/tiff-document.h index 19db6158..b45f78c4 100644 --- a/backend/tiff/tiff-document.h +++ b/backend/tiff/tiff-document.h @@ -32,7 +32,7 @@ typedef struct _TiffDocument TiffDocument; GType tiff_document_get_type (void) G_GNUC_CONST; G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module); - + G_END_DECLS #endif /* __TIFF_DOCUMENT_H__ */ diff --git a/backend/tiff/tiff2ps.c b/backend/tiff/tiff2ps.c index f8933674..bcbbf885 100644 --- a/backend/tiff/tiff2ps.c +++ b/backend/tiff/tiff2ps.c @@ -5,23 +5,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -827,7 +827,7 @@ PS_Lvl2ImageDict(TIFF2PSContext* ctx, TIFF* tif, uint32 w, uint32 h) * Workaround for some software that may crash when last strip * of image contains fewer number of scanlines than specified * by the `/Height' variable. So for stripped images with multiple - * strips we will set `/Height' as `im_h', because one is + * strips we will set `/Height' as `im_h', because one is * recalculated for each strip - including the (smaller) final strip. * For tiled images and images with only one strip `/Height' will * contain number of scanlines in tile (or image height in case of @@ -1722,7 +1722,7 @@ Ascii85Flush(TIFF2PSContext* ctx) fputs("~>\n", ctx->fd); } #if defined( EXP_ASCII85ENCODER) - + #define A85BREAKCNTR ctx->ascii85breaklen #define A85BREAKLEN (2*MAXLINE) diff --git a/backend/xps/xps-document.c b/backend/xps/xps-document.c index 602220ac..8db7d56c 100644 --- a/backend/xps/xps-document.c +++ b/backend/xps/xps-document.c @@ -513,13 +513,13 @@ xps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, { GdkPixbuf *thumbnail; cairo_surface_t *surface; - + surface = xps_document_render (EV_DOCUMENT (document), rc); - + thumbnail = ev_document_misc_pixbuf_from_surface (surface); - + cairo_surface_destroy (surface); - + if (border) { GdkPixbuf *tmp_pixbuf = thumbnail; @@ -537,7 +537,7 @@ xps_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, gint *height) { gdouble page_width, page_height; - + xps_document_get_page_size (EV_DOCUMENT (document), rc->page, &page_width, &page_height); -- cgit v1.2.1