Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 238976 | Differences between
and this patch

Collapse All | Expand All

(-)cups-1.3.8/filter/hpgl-attr.c (-12 / +39 lines)
Lines 197-204 NP_number_pens(int num_params, /* I Link Here
197
197
198
  if (num_params == 0)
198
  if (num_params == 0)
199
    PenCount = 8;
199
    PenCount = 8;
200
  else if (num_params == 1 && params[0].value.number <= 1024)
200
  else if (num_params == 1)
201
    PenCount = (int)params[0].value.number;
201
  {
202
    if (params[0].value.number < 1 || params[0].value.number > MAX_PENS)
203
    {
204
      fprintf(stderr,
205
	      "DEBUG: HP-GL/2 \'NP\' command with invalid number of "
206
	      "pens (%d)!\n", (int)params[0].value.number);
207
      PenCount = 8;
208
    }
209
    else
210
      PenCount = (int)params[0].value.number;
211
  }
202
  else
212
  else
203
    fprintf(stderr,
213
    fprintf(stderr,
204
            "DEBUG: HP-GL/2 \'NP\' command with invalid number of "
214
            "DEBUG: HP-GL/2 \'NP\' command with invalid number of "
Lines 235-241 PC_pen_color(int num_params, /* I - Link Here
235
245
236
  if (num_params == 0)
246
  if (num_params == 0)
237
  {
247
  {
238
    for (i = 0; i <= PenCount; i ++)
248
    for (i = 0; i < PenCount; i ++)
239
      if (i < 8)
249
      if (i < 8)
240
      {
250
      {
241
        Pens[i].rgb[0] = standard_colors[i][0];
251
        Pens[i].rgb[0] = standard_colors[i][0];
Lines 256-262 PC_pen_color(int num_params, /* I - Link Here
256
  }
266
  }
257
  else if (num_params == 1 || num_params == 4)
267
  else if (num_params == 1 || num_params == 4)
258
  {
268
  {
259
    i = (int)params[0].value.number;
269
    i = (int)params[0].value.number - 1;
270
271
    if (i < 0 || i >= PenCount)
272
    {
273
      fprintf(stderr,
274
              "DEBUG: HP-GL/2 \'PC\' command with invalid pen (%d)!\n", i + 1);
275
      return;
276
    }
260
277
261
    if (num_params == 1)
278
    if (num_params == 1)
262
    {
279
    {
Lines 330-336 PW_pen_width(int num_params, /* I - Link Here
330
347
331
  if (num_params == 2)
348
  if (num_params == 2)
332
  {
349
  {
333
    pen = (int)params[1].value.number;
350
    pen = (int)params[1].value.number - 1;
351
352
    if (pen < 0 || pen >= PenCount)
353
    {
354
      fprintf(stderr,
355
              "DEBUG: HP-GL/2 \'PW\' command with invalid pen (%d)!\n",
356
	      pen + 1);
357
      return;
358
    }
334
359
335
    Pens[pen].width = w;
360
    Pens[pen].width = w;
336
361
Lines 345-351 PW_pen_width(int num_params, /* I - Link Here
345
    * Set width for all pens...
370
    * Set width for all pens...
346
    */
371
    */
347
372
348
    for (pen = 0; pen <= PenCount; pen ++)
373
    for (pen = 0; pen < PenCount; pen ++)
349
      Pens[pen].width = w;
374
      Pens[pen].width = w;
350
375
351
    if (PageDirty)
376
    if (PageDirty)
Lines 399-412 SP_select_pen(int num_params, /* I - Link Here
399
              param_t *params)		/* I - Parameters */
424
              param_t *params)		/* I - Parameters */
400
{
425
{
401
  if (num_params == 0)
426
  if (num_params == 0)
402
    PenNumber = 1;
427
    PenNumber = 0;
403
  else if (params[0].value.number <= PenCount)
428
  else if (num_params > 1)
404
    PenNumber = (int)params[0].value.number;
405
  else
406
    fprintf(stderr,
429
    fprintf(stderr,
407
            "DEBUG: HP-GL/2 \'SP\' command with invalid number or value "
430
            "DEBUG: HP-GL/2 \'SP\' command with invalid number of parameters "
408
	    "of parameters (%d, %d)!\n", num_params,
431
	    "(%d)!\n", num_params);
432
  else if (params[0].value.number <= 0 || params[0].value.number >= PenCount)
433
    fprintf(stderr, "DEBUG: HP-GL/2 \'SP\' command with invalid pen (%d)!\n",
409
	    (int)params[0].value.number);
434
	    (int)params[0].value.number);
435
  else
436
    PenNumber = (int)params[0].value.number - 1;
410
437
411
  if (PageDirty)
438
  if (PageDirty)
412
    printf("%.3f %.3f %.3f %.2f SP\n", Pens[PenNumber].rgb[0],
439
    printf("%.3f %.3f %.3f %.2f SP\n", Pens[PenNumber].rgb[0],
(-)cups-1.3.8/filter/hpgltops.h (-2 / +10 lines)
Lines 26-31 Link Here
26
#  define M_PI	3.14159265358979323846
26
#  define M_PI	3.14159265358979323846
27
#endif /* M_PI */
27
#endif /* M_PI */
28
28
29
30
/*
31
 * Maximum number of pens we emulate...
32
 */
33
34
#define MAX_PENS	1024
35
36
29
/*
37
/*
30
 * Parameter value structure...
38
 * Parameter value structure...
31
 */
39
 */
Lines 108-117 VAR float PenPosition[2] VALUE2(0.0f, 0. Link Here
108
						/* Current pen position */
116
						/* Current pen position */
109
		PenScaling	VALUE(1.0f),	/* Pen width scaling factor */
117
		PenScaling	VALUE(1.0f),	/* Pen width scaling factor */
110
		PenWidth	VALUE(1.0f);	/* Default pen width */
118
		PenWidth	VALUE(1.0f);	/* Default pen width */
111
VAR pen_t	Pens[1024];			/* State of each pen */
119
VAR pen_t	Pens[MAX_PENS];			/* State of each pen */
112
VAR int		PenMotion	VALUE(0), 	/* 0 = absolute, 1 = relative */
120
VAR int		PenMotion	VALUE(0), 	/* 0 = absolute, 1 = relative */
113
		PenValid	VALUE(0),	/* 1 = valid position, 0 = undefined */
121
		PenValid	VALUE(0),	/* 1 = valid position, 0 = undefined */
114
		PenNumber	VALUE(1),	/* Current pen number */
122
		PenNumber	VALUE(0),	/* Current pen number */
115
		PenCount	VALUE(8),	/* Number of pens */
123
		PenCount	VALUE(8),	/* Number of pens */
116
		PenDown		VALUE(0),	/* 0 = pen up, 1 = pen down */
124
		PenDown		VALUE(0),	/* 0 = pen up, 1 = pen down */
117
		PolygonMode	VALUE(0),	/* Drawing polygons? */
125
		PolygonMode	VALUE(0),	/* Drawing polygons? */

Return to bug 238976