To: vim-dev@vim.org Subject: Patch 6.0ax.017 Fcc: outbox From: Bram Moolenaar ------------ Patch 6.0ax.017 Problem: (1) The printing code was using "UL" and "f" after constants, these don't work with a non-ANSI compiler. (2) When 'printheader' includes items that can be long, could cause a crash. (3) PostScript printing: When the last line of a page is bold, the header of the next page would not be bold. Solution: (1) Use type casts instead. (2) Allocate more space for the resulting header. (3) Reset the attributes when starting a new page. Files: src/ex_cmds2.c *** ../vim60ax.16/src/ex_cmds2.c Tue Sep 18 11:14:13 2001 --- src/ex_cmds2.c Mon Sep 24 22:44:52 2001 *************** *** 2451,2473 **** #ifdef FEAT_SYN_HL static const long_u cterm_color_8[8] = { ! 0x000000UL, 0xff0000UL, 0x00ff00UL, 0xffff00UL, ! 0x0000ffUL, 0xff00ffUL, 0x00ffffUL, 0xffffffUL }; static const long_u cterm_color_16[16] = { ! 0x000000UL, 0x0000c0UL, 0x008000UL, 0x004080UL, ! 0xc00000UL, 0xc000c0UL, 0x808000UL, 0xc0c0c0UL, ! 0x808080UL, 0x6060ffUL, 0x00ff00UL, 0x00ffffUL, ! 0xff8080UL, 0xff40ffUL, 0xffff00UL, 0xffffffUL }; static int current_syn_id; #endif ! #define COLOR_BLACK 0UL ! #define COLOR_WHITE 0xFFFFFFUL static int curr_italic; static int curr_bold; --- 2451,2473 ---- #ifdef FEAT_SYN_HL static const long_u cterm_color_8[8] = { ! (long_u)0x000000, (long_u)0xff0000, (long_u)0x00ff00, (long_u)0xffff00, ! (long_u)0x0000ff, (long_u)0xff00ff, (long_u)0x00ffff, (long_u)0xffffff }; static const long_u cterm_color_16[16] = { ! (long_u)0x000000, (long_u)0x0000c0, (long_u)0x008000, (long_u)0x004080, ! (long_u)0xc00000, (long_u)0xc000c0, (long_u)0x808000, (long_u)0xc0c0c0, ! (long_u)0x808080, (long_u)0x6060ff, (long_u)0x00ff00, (long_u)0x00ffff, ! (long_u)0xff8080, (long_u)0xff40ff, (long_u)0xffff00, (long_u)0xffffff }; static int current_syn_id; #endif ! #define COLOR_BLACK (long_u)0 ! #define COLOR_WHITE (long_u)0xFFFFFF static int curr_italic; static int curr_bold; *************** *** 2573,2579 **** char_u tbuf[20]; if (psettings->has_color) ! prt_set_fg(0x808080UL); else prt_set_fg(COLOR_BLACK); prt_set_bg(COLOR_WHITE); --- 2573,2579 ---- char_u tbuf[20]; if (psettings->has_color) ! prt_set_fg((long_u)0x808080); else prt_set_fg(COLOR_BLACK); prt_set_bg(COLOR_WHITE); *************** *** 2673,2679 **** if (prt_use_number()) width += PRINT_NUMBER_WIDTH; ! tbuf = alloc(width + 1); if (tbuf == NULL) return; --- 2673,2679 ---- if (prt_use_number()) width += PRINT_NUMBER_WIDTH; ! tbuf = alloc(width + IOSIZE); if (tbuf == NULL) return; *************** *** 2822,2829 **** } /* Set colors and font to normal. */ ! curr_bg = 0xffffffffUL; ! curr_fg = 0xffffffffUL; curr_italic = MAYBE; curr_bold = MAYBE; curr_underline = MAYBE; --- 2822,2829 ---- } /* Set colors and font to normal. */ ! curr_bg = (long_u)0xffffffff; ! curr_fg = (long_u)0xffffffff; curr_italic = MAYBE; curr_bold = MAYBE; curr_underline = MAYBE; *************** *** 3178,3197 **** static struct prt_mediasize_S prt_mediasize[] = { ! {"A4", 595.0f, 842.0f}, ! {"letter", 612.0f, 792.0f}, ! {"10x14", 720.0f, 1008.0f}, ! {"A3", 842.0f, 1191.0f}, ! {"A5", 420.0f, 595.0f}, ! {"B4", 729.0f, 1032.0f}, ! {"B5", 516.0f, 729.0f}, ! {"executive", 522.0f, 756.0f}, ! {"folio", 595.0f, 935.0f}, ! {"ledger", 1224.0f, 792.0f}, /* Yes, it is wider than taller! */ ! {"legal", 612.0f, 1008.0f}, ! {"quarto", 610.0f, 780.0f}, ! {"statement", 396.0f, 612.0f}, ! {"tabloid", 792.0f, 1224.0f} }; /* PS font names, must be in Roman, Bold, Italic, Bold-Italic order */ --- 3178,3197 ---- static struct prt_mediasize_S prt_mediasize[] = { ! {"A4", 595.0, 842.0}, ! {"letter", 612.0, 792.0}, ! {"10x14", 720.0, 1008.0}, ! {"A3", 842.0, 1191.0}, ! {"A5", 420.0, 595.0}, ! {"B4", 729.0, 1032.0}, ! {"B5", 516.0, 729.0}, ! {"executive", 522.0, 756.0}, ! {"folio", 595.0, 935.0}, ! {"ledger", 1224.0, 792.0}, /* Yes, it is wider than taller! */ ! {"legal", 612.0, 1008.0}, ! {"quarto", 610.0, 780.0}, ! {"statement", 396.0, 612.0}, ! {"tabloid", 792.0, 1224.0} }; /* PS font names, must be in Roman, Bold, Italic, Bold-Italic order */ *************** *** 3291,3298 **** static float prt_char_width; static float prt_number_width; static float prt_bgcol_offset; ! static float prt_pos_x_moveto = 0.0f; ! static float prt_pos_y_moveto = 0.0f; /* * Various control variables used to decide when and how to change the --- 3291,3298 ---- static float prt_char_width; static float prt_number_width; static float prt_bgcol_offset; ! static float prt_pos_x_moveto = 0.0; ! static float prt_pos_y_moveto = 0.0; /* * Various control variables used to decide when and how to change the *************** *** 3434,3443 **** if (real < (double)integer) fraction = -fraction; for (i = 0; i < precision; i++) ! fraction *= 10.0f; *pinteger = integer; ! *pfraction = (int)(fraction + 0.5f); } /* --- 3434,3443 ---- if (real < (double)integer) fraction = -fraction; for (i = 0; i < precision; i++) ! fraction *= 10.0; *pinteger = integer; ! *pfraction = (int)(fraction + 0.5); } /* *************** *** 3491,3497 **** } /* Convert size from font space to user space at current font scale */ ! #define PRT_PS_FONT_TO_USER(scale, size) ((size) * ((scale)/1000.0f)) static void prt_flush_buffer() --- 3491,3497 ---- } /* Convert size from font space to user space at current font scale */ ! #define PRT_PS_FONT_TO_USER(scale, size) ((size) * ((scale)/1000.0)) static void prt_flush_buffer() *************** *** 3749,3755 **** ret = (float)(nr * PRT_PS_DEFAULT_DPI); break; case PRT_UNIT_MM: ! ret = (float)(nr * PRT_PS_DEFAULT_DPI) / 25.4f; break; case PRT_UNIT_POINT: ret = (float)nr; --- 3749,3755 ---- ret = (float)(nr * PRT_PS_DEFAULT_DPI); break; case PRT_UNIT_MM: ! ret = (float)(nr * PRT_PS_DEFAULT_DPI) / 25.4; break; case PRT_UNIT_POINT: ret = (float)nr; *************** *** 3799,3805 **** prt_left_margin += prt_number_width; } else ! prt_number_width = 0.0f; return (int)((prt_right_margin - prt_left_margin) / prt_char_width); } --- 3799,3805 ---- prt_left_margin += prt_number_width; } else ! prt_number_width = 0.0; return (int)((prt_right_margin - prt_left_margin) / prt_char_width); } *************** *** 3819,3828 **** */ prt_bgcol_offset = PRT_PS_FONT_TO_USER(prt_line_height, prt_ps_font.bbox_min_y); ! if ((prt_ps_font.bbox_max_y - prt_ps_font.bbox_min_y) < 1000.0f) { prt_bgcol_offset -= PRT_PS_FONT_TO_USER(prt_line_height, ! (1000.0f - (prt_ps_font.bbox_max_y - prt_ps_font.bbox_min_y)) / 2); } --- 3819,3828 ---- */ prt_bgcol_offset = PRT_PS_FONT_TO_USER(prt_line_height, prt_ps_font.bbox_min_y); ! if ((prt_ps_font.bbox_max_y - prt_ps_font.bbox_min_y) < 1000.0) { prt_bgcol_offset -= PRT_PS_FONT_TO_USER(prt_line_height, ! (1000.0 - (prt_ps_font.bbox_max_y - prt_ps_font.bbox_min_y)) / 2); } *************** *** 4315,4320 **** --- 4315,4325 ---- prt_dsc_noarg("EndPageSetup"); + /* We have reset the font attributes, force setting them again. */ + curr_bg = (long_u)0xffffffff; + curr_fg = (long_u)0xffffffff; + curr_bold = MAYBE; + return !prt_file_error; } *************** *** 4461,4467 **** prt_pos_x += prt_char_width; /* The downside of fp - need a little tolerance in the right margin check */ ! need_break = (prt_pos_x + prt_char_width > (prt_right_margin + 0.01f)); if (need_break) prt_flush_buffer(); --- 4466,4472 ---- prt_pos_x += prt_char_width; /* The downside of fp - need a little tolerance in the right margin check */ ! need_break = (prt_pos_x + prt_char_width > (prt_right_margin + 0.01)); if (need_break) prt_flush_buffer(); *** ../vim60ax.16/src/version.c Mon Sep 24 22:03:42 2001 --- src/version.c Mon Sep 24 22:55:25 2001 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 17, /**/ -- Westheimer's Discovery: A couple of months in the laboratory can frequently save a couple of hours in the library. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///