| 1 | --- src/wxterminal/gp_cairo.c.orig |
| 2 | +++ src/wxterminal/gp_cairo.c |
| 3 | @@ -1144,7 +1144,7 @@ void gp_cairo_add_shape( PangoRectangle rect,int position) |
| 4 | |
| 5 | FPRINTF((stderr, "adding blank custom shape\n")); |
| 6 | |
| 7 | - strncat(gp_cairo_utf8, " ", sizeof(gp_cairo_utf8)-strlen(gp_cairo_utf8)); |
| 8 | + strncat(gp_cairo_utf8, " ", sizeof(gp_cairo_utf8)-strlen(gp_cairo_utf8)-1); |
| 9 | p_attr_shape = pango_attr_shape_new (&rect,&rect); |
| 10 | p_attr_shape->start_index = position; |
| 11 | p_attr_shape->end_index = position+1; |
| 12 | @@ -1295,7 +1295,7 @@ void gp_cairo_enhanced_flush(plot_struct *plot) |
| 13 | } |
| 14 | |
| 15 | if (gp_cairo_enhanced_showflag) { |
| 16 | - strncat(gp_cairo_utf8, enhanced_text_utf8, sizeof(gp_cairo_utf8)-strlen(gp_cairo_utf8)); |
| 17 | + strncat(gp_cairo_utf8, enhanced_text_utf8, sizeof(gp_cairo_utf8)-strlen(gp_cairo_utf8)-1); |
| 18 | end = strlen(gp_cairo_utf8); |
| 19 | |
| 20 | /* add text attributes to the main list */ |
| 21 | @@ -1376,7 +1376,7 @@ void gp_cairo_enhanced_flush(plot_struct *plot) |
| 22 | |
| 23 | if (gp_cairo_enhanced_save) /* we aim at restoring position later */ { |
| 24 | save_start = strlen( gp_cairo_save_utf8); |
| 25 | - strncat(gp_cairo_save_utf8, enhanced_text_utf8, sizeof(gp_cairo_utf8)-strlen(gp_cairo_utf8)); |
| 26 | + strncat(gp_cairo_save_utf8, enhanced_text_utf8, sizeof(gp_cairo_utf8)-strlen(gp_cairo_utf8)-1); |
| 27 | save_end = strlen( gp_cairo_save_utf8); |
| 28 | |
| 29 | /* add text attributes to the save list */ |
| 30 | @@ -1387,7 +1387,7 @@ void gp_cairo_enhanced_flush(plot_struct *plot) |
| 31 | underprinted_start = strlen(gp_cairo_underprinted_utf8); |
| 32 | strncat(gp_cairo_underprinted_utf8, |
| 33 | enhanced_text_utf8, |
| 34 | - sizeof(gp_cairo_underprinted_utf8)-strlen(gp_cairo_underprinted_utf8)); |
| 35 | + sizeof(gp_cairo_underprinted_utf8)-strlen(gp_cairo_underprinted_utf8)-1); |
| 36 | underprinted_end = strlen(gp_cairo_underprinted_utf8); |
| 37 | |
| 38 | if (gp_cairo_enhanced_underprinted_AttrList) |
| 39 | --- term/cairo.trm.orig |
| 40 | +++ term/cairo.trm |
| 41 | @@ -523,7 +523,7 @@ TERM_PUBLIC void cairotrm_options() |
| 42 | /* Save options back into options string in normalized format */ |
| 43 | if (cairo_params->transparent) |
| 44 | strncat(term_options, ISCAIROLATEX ? " nobackground" : " transparent", |
| 45 | - sizeof(term_options) - strlen(term_options)); |
| 46 | + sizeof(term_options) - strlen(term_options) - 1); |
| 47 | else { |
| 48 | sprintf(tmp_term_options, " background \"#%02x%02x%02x\"", |
| 49 | (int)(255 * cairo_params->background.r), |
| 50 | @@ -533,28 +533,28 @@ TERM_PUBLIC void cairotrm_options() |
| 51 | } |
| 52 | |
| 53 | if (cairo_params->crop) |
| 54 | - strncat(term_options, " crop", sizeof(term_options)-strlen(term_options)); |
| 55 | + strncat(term_options, " crop", sizeof(term_options)-strlen(term_options)-1); |
| 56 | |
| 57 | if (set_enhanced) |
| 58 | - strncat(term_options, " enhanced", sizeof(term_options)-strlen(term_options)); |
| 59 | + strncat(term_options, " enhanced", sizeof(term_options)-strlen(term_options)-1); |
| 60 | |
| 61 | if (set_font) { |
| 62 | snprintf(tmp_term_options, sizeof(tmp_term_options), " font \"%s\"", font_setting); |
| 63 | free(font_setting); |
| 64 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 65 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 66 | } |
| 67 | |
| 68 | /* if (set_fontscale) */ |
| 69 | { |
| 70 | snprintf(tmp_term_options, sizeof(tmp_term_options), " fontscale %.1f", cairo_params->fontscale); |
| 71 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 72 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 73 | } |
| 74 | |
| 75 | if (cairo_params->mono) |
| 76 | - strncat(term_options, " monochrome", sizeof(term_options)-strlen(term_options)); |
| 77 | + strncat(term_options, " monochrome", sizeof(term_options)-strlen(term_options)-1); |
| 78 | |
| 79 | if (cairo_params->dashed) |
| 80 | - strncat(term_options, " dashed", sizeof(term_options)-strlen(term_options)); |
| 81 | + strncat(term_options, " dashed", sizeof(term_options)-strlen(term_options)-1); |
| 82 | |
| 83 | if (1 || set_size) { |
| 84 | if (cairo_params->explicit_units == CM) |
| 85 | @@ -572,22 +572,22 @@ TERM_PUBLIC void cairotrm_options() |
| 86 | sizeof(tmp_term_options), |
| 87 | " size %.2fin, %.2fin ", |
| 88 | cairo_params->width/72., cairo_params->height/72.); |
| 89 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 90 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 91 | } |
| 92 | |
| 93 | if (set_capjoin) { |
| 94 | strncat(term_options, cairo_params->rounded ? " rounded" : " butt", |
| 95 | - sizeof(term_options)-strlen(term_options)); |
| 96 | + sizeof(term_options)-strlen(term_options)-1); |
| 97 | } |
| 98 | |
| 99 | if (cairo_params->lw != cairo_params_default->lw) { |
| 100 | snprintf(tmp_term_options,sizeof(tmp_term_options), " linewidth %g", cairo_params->lw); |
| 101 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 102 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 103 | } |
| 104 | |
| 105 | if (cairo_params->dash_length != cairo_params_default->dash_length) { |
| 106 | snprintf(tmp_term_options,sizeof(tmp_term_options), " dashlength %g", cairo_params->dash_length); |
| 107 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 108 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 109 | } |
| 110 | |
| 111 | /* sync settings with ps_params for latex terminal */ |
| 112 | --- term/context.trm.orig |
| 113 | +++ term/context.trm |
| 114 | @@ -630,36 +630,42 @@ CONTEXT_options() |
| 115 | CONTEXT_params.header == NULL ? "noheader \\\n " : "\\\n header "); |
| 116 | |
| 117 | if (CONTEXT_params.header != NULL) { |
| 118 | - strncat(term_options,"\"", sizeof(term_options)-strlen(term_options)); |
| 119 | - strncat(term_options,CONTEXT_params.header, sizeof(term_options)-strlen(term_options)); |
| 120 | - strncat(term_options,"\" \\\n ", sizeof(term_options)-strlen(term_options)); |
| 121 | + strncat(term_options,"\"", sizeof(term_options)-strlen(term_options)-1); |
| 122 | + strncat(term_options,CONTEXT_params.header, sizeof(term_options)-strlen(term_options)-1); |
| 123 | + strncat(term_options,"\" \\\n ", sizeof(term_options)-strlen(term_options)-1); |
| 124 | } |
| 125 | |
| 126 | strncat(term_options, |
| 127 | CONTEXT_params.color ? "color " : "monochrome ", |
| 128 | - sizeof(term_options)-strlen(term_options)); |
| 129 | + sizeof(term_options)-strlen(term_options)-1); |
| 130 | |
| 131 | switch (CONTEXT_params.linejoin) { |
| 132 | case LINEJOIN_MITER: |
| 133 | strncat(term_options, "mitered ", |
| 134 | - sizeof(term_options)-strlen(term_options)); break; |
| 135 | + sizeof(term_options)-strlen(term_options)-1); |
| 136 | + break; |
| 137 | case LINEJOIN_ROUND: |
| 138 | strncat(term_options, "rounded ", |
| 139 | - sizeof(term_options)-strlen(term_options)); break; |
| 140 | + sizeof(term_options)-strlen(term_options)-1); |
| 141 | + break; |
| 142 | case LINEJOIN_BEVEL: |
| 143 | strncat(term_options, "beveled ", |
| 144 | - sizeof(term_options)-strlen(term_options)); break; |
| 145 | + sizeof(term_options)-strlen(term_options)-1); |
| 146 | + break; |
| 147 | } |
| 148 | switch (CONTEXT_params.linecap) { |
| 149 | case LINECAP_BUTT : |
| 150 | strncat(term_options, "butt", |
| 151 | - sizeof(term_options)-strlen(term_options)); break; |
| 152 | + sizeof(term_options)-strlen(term_options)-1); |
| 153 | + break; |
| 154 | case LINECAP_ROUND : |
| 155 | strncat(term_options, "round", |
| 156 | - sizeof(term_options)-strlen(term_options)); break; |
| 157 | + sizeof(term_options)-strlen(term_options)-1); |
| 158 | + break; |
| 159 | case LINECAP_SQUARE: |
| 160 | strncat(term_options, "squared", |
| 161 | - sizeof(term_options)-strlen(term_options)); break; |
| 162 | + sizeof(term_options)-strlen(term_options)-1); |
| 163 | + break; |
| 164 | } |
| 165 | |
| 166 | snprintf(tmp_term_options, sizeof(tmp_term_options), |
| 167 | @@ -669,29 +675,33 @@ CONTEXT_options() |
| 168 | CONTEXT_params.scale_linewidth, |
| 169 | CONTEXT_params.scale_text |
| 170 | ); |
| 171 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 172 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 173 | |
| 174 | switch (CONTEXT_params.points) { |
| 175 | case CONTEXT_POINTS_WITH_TEX : |
| 176 | strncat(term_options, "texpoints ", |
| 177 | - sizeof(term_options)-strlen(term_options)); break; |
| 178 | + sizeof(term_options)-strlen(term_options)-1); |
| 179 | + break; |
| 180 | case CONTEXT_POINTS_WITH_METAPOST : |
| 181 | strncat(term_options, "mppoints ", |
| 182 | - sizeof(term_options)-strlen(term_options)); break; |
| 183 | + sizeof(term_options)-strlen(term_options)-1); |
| 184 | + break; |
| 185 | } |
| 186 | #ifdef WRITE_PNG_IMAGE |
| 187 | switch (CONTEXT_params.images) { |
| 188 | case CONTEXT_IMAGES_INLINE : |
| 189 | strncat(term_options, "inlineimages ", |
| 190 | - sizeof(term_options)-strlen(term_options)); break; |
| 191 | + sizeof(term_options)-strlen(term_options)-1); |
| 192 | + break; |
| 193 | case CONTEXT_IMAGES_EXTERNAL : |
| 194 | strncat(term_options, "externalimages ", |
| 195 | - sizeof(term_options)-strlen(term_options)); break; |
| 196 | + sizeof(term_options)-strlen(term_options)-1); |
| 197 | + break; |
| 198 | } |
| 199 | #endif |
| 200 | snprintf(tmp_term_options, sizeof(tmp_term_options), "font \"%s,%g\"", |
| 201 | CONTEXT_params.font, CONTEXT_params.fontsize); |
| 202 | - strncat(term_options, tmp_term_options, sizeof(term_options) - strlen(term_options)); |
| 203 | + strncat(term_options, tmp_term_options, sizeof(term_options) - strlen(term_options)-1); |
| 204 | } |
| 205 | |
| 206 | /* ************** |
| 207 | @@ -1374,7 +1384,8 @@ CONTEXT_set_font(const char *font) |
| 208 | CONTEXT_fontsize = CONTEXT_fontsize_explicit; |
| 209 | |
| 210 | snprintf(tmp_fontstring, sizeof(tmp_fontstring), ",%gpt", CONTEXT_fontsize_explicit); |
| 211 | - strncat(CONTEXT_font_explicit, tmp_fontstring, sizeof(CONTEXT_font_explicit) - strlen(CONTEXT_font_explicit)); |
| 212 | + strncat(CONTEXT_font_explicit, tmp_fontstring, |
| 213 | + sizeof(CONTEXT_font_explicit) - strlen(CONTEXT_font_explicit)-1); |
| 214 | tmp_fontstring[MAX_ID_LEN] = NUL; |
| 215 | |
| 216 | /* no fontsize has been provided: switch back to default terminal fontsize */ |
| 217 | @@ -1591,7 +1602,6 @@ CONTEXT_write_palette(t_sm_palette *palette) |
| 218 | /* grayscale only */ |
| 219 | case SMPAL_COLOR_MODE_GRAY: |
| 220 | fprintf(gpoutfile, "color_mode(gray)"); |
| 221 | - // XXX: I'm not sure if something has to be done here or not |
| 222 | break; |
| 223 | /* one of several fixed transformations */ |
| 224 | case SMPAL_COLOR_MODE_RGB: |
| 225 | --- term/wxt.trm.orig |
| 226 | +++ term/wxt.trm |
| 227 | @@ -315,71 +315,71 @@ TERM_PUBLIC void wxt_options() |
| 228 | "%d", wxt_window_number); |
| 229 | |
| 230 | if (set_title) { |
| 231 | - strncat(term_options, " title \"", sizeof(term_options)-strlen(term_options)); |
| 232 | - strncat(term_options, wxt_title, sizeof(term_options)-strlen(term_options)); |
| 233 | - strncat(term_options, "\"", sizeof(term_options)-strlen(term_options)); |
| 234 | + strncat(term_options, " title \"", sizeof(term_options)-strlen(term_options)-1); |
| 235 | + strncat(term_options, wxt_title, sizeof(term_options)-strlen(term_options)-1); |
| 236 | + strncat(term_options, "\"", sizeof(term_options)-strlen(term_options)-1); |
| 237 | wxt_update_title(wxt_window_number); |
| 238 | } |
| 239 | |
| 240 | if (wxt_dashed) |
| 241 | - strncat(term_options, " dashed", sizeof(term_options)-strlen(term_options)); |
| 242 | + strncat(term_options, " dashed", sizeof(term_options)-strlen(term_options)-1); |
| 243 | |
| 244 | if (wxt_dashlength != 1.0) { |
| 245 | char tmp_term_options[MAX_LINE_LEN+1] = ""; |
| 246 | snprintf(tmp_term_options,sizeof(tmp_term_options), " dashlength %g", wxt_dashlength); |
| 247 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 248 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 249 | } |
| 250 | |
| 251 | if (wxt_background != 0xffffff) { |
| 252 | char tmp_term_options[MAX_LINE_LEN+1] = ""; |
| 253 | snprintf(tmp_term_options,sizeof(tmp_term_options), " background '#%06x'", wxt_background); |
| 254 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 255 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 256 | } |
| 257 | |
| 258 | if (set_size) { |
| 259 | char tmp_term_options[MAX_LINE_LEN+1] = ""; |
| 260 | snprintf(tmp_term_options, sizeof(tmp_term_options), |
| 261 | " size %d, %d", wxt_width, wxt_height); |
| 262 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 263 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 264 | wxt_update_size(wxt_window_number); |
| 265 | } |
| 266 | |
| 267 | if (set_enhanced) |
| 268 | strncat(term_options, |
| 269 | wxt_enhanced_enabled ? " enhanced" : " noenhanced", |
| 270 | - sizeof(term_options)-strlen(term_options)); |
| 271 | + sizeof(term_options)-strlen(term_options)-1); |
| 272 | |
| 273 | if (set_font) { |
| 274 | - strncat(term_options, " font \"", sizeof(term_options)-strlen(term_options)); |
| 275 | - strncat(term_options, font_setting, sizeof(term_options)-strlen(term_options)); |
| 276 | - strncat(term_options, "\"", sizeof(term_options)-strlen(term_options)); |
| 277 | + strncat(term_options, " font \"", sizeof(term_options)-strlen(term_options)-1); |
| 278 | + strncat(term_options, font_setting, sizeof(term_options)-strlen(term_options)-1); |
| 279 | + strncat(term_options, "\"", sizeof(term_options)-strlen(term_options)-1); |
| 280 | free(font_setting); |
| 281 | } |
| 282 | |
| 283 | if (wxt_set_fontscale != 1.0) { |
| 284 | char tmp_term_options[MAX_LINE_LEN+1] = ""; |
| 285 | snprintf(tmp_term_options,sizeof(tmp_term_options), " fontscale %.1f", wxt_set_fontscale); |
| 286 | - strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)); |
| 287 | + strncat(term_options, tmp_term_options, sizeof(term_options)-strlen(term_options)-1); |
| 288 | } |
| 289 | |
| 290 | if (set_capjoin) |
| 291 | strncat(term_options, wxt_rounded ? " rounded" : " butt", |
| 292 | - sizeof(term_options)-strlen(term_options)); |
| 293 | + sizeof(term_options)-strlen(term_options)-1); |
| 294 | |
| 295 | if (set_persist) |
| 296 | strncat(term_options, |
| 297 | (wxt_persist==yes) ? " persist" : " nopersist", |
| 298 | - sizeof(term_options)-strlen(term_options)); |
| 299 | + sizeof(term_options)-strlen(term_options)-1); |
| 300 | |
| 301 | if (set_raise) |
| 302 | strncat(term_options, |
| 303 | (wxt_raise==yes) ? " raise" : " noraise", |
| 304 | - sizeof(term_options)-strlen(term_options)); |
| 305 | + sizeof(term_options)-strlen(term_options)-1); |
| 306 | |
| 307 | if (set_ctrl) |
| 308 | strncat(term_options, |
| 309 | (wxt_ctrl==yes) ? " ctrl" : " noctrl", |
| 310 | - sizeof(term_options)-strlen(term_options)); |
| 311 | + sizeof(term_options)-strlen(term_options)-1); |
| 312 | |
| 313 | if (set_close) |
| 314 | wxt_close_terminal_window(wxt_window_number); |