summaryrefslogtreecommitdiff
path: root/ext/pdf
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2001-05-27 00:01:55 +0000
committerRasmus Lerdorf <rasmus@php.net>2001-05-27 00:01:55 +0000
commit8ca880265e1931dece248eed1a17d0fc36f78995 (patch)
treee85f6d36ad966ce23a80f8712897d729ce9207e1 /ext/pdf
parentd342acc3a924240e069e785321f3c3b087206132 (diff)
downloadphp-git-8ca880265e1931dece248eed1a17d0fc36f78995.tar.gz
Make c2-4 optional since they aren't needed in all cases
Diffstat (limited to 'ext/pdf')
-rw-r--r--ext/pdf/pdf.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c
index a0d98f6506..6ca1b9b486 100644
--- a/ext/pdf/pdf.c
+++ b/ext/pdf/pdf.c
@@ -2907,25 +2907,48 @@ PHP_FUNCTION(pdf_end_template) {
RETURN_TRUE;
}
-/* {{{ proto void pdf_setcolor(int pdf, string type, string colorspace, double c1, double c2, double c3, double c4);
+/* {{{ proto void pdf_setcolor(int pdf, string type, string colorspace, double c1 [, double c2 [, double c3 [, double c4]]]);
* Set the current color space and color. */
PHP_FUNCTION(pdf_setcolor) {
zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7;
PDF *pdf;
double c1;
+ int argc = ZEND_NUM_ARGS();
- if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) {
+ if(argc < 4 || argc > 7) {
WRONG_PARAM_COUNT;
}
+ switch(argc) {
+ case 4:
+ if(zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ break;
+ case 5:
+ if(zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ break;
+ case 6:
+ if(zend_get_parameters_ex(6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ break;
+ case 7:
+ if(zend_get_parameters_ex(6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ break;
+ }
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
convert_to_string_ex(arg2);
convert_to_string_ex(arg3);
convert_to_double_ex(arg4);
- convert_to_double_ex(arg5);
- convert_to_double_ex(arg6);
- convert_to_double_ex(arg7);
+ if(argc > 4) convert_to_double_ex(arg5);
+ if(argc > 5) convert_to_double_ex(arg6);
+ if(argc > 6) convert_to_double_ex(arg7);
if (0 == (strcmp(Z_STRVAL_PP(arg3), "spot"))) {
c1 = Z_DVAL_PP(arg4)-PDFLIB_SPOT_OFFSET;
@@ -2939,9 +2962,9 @@ PHP_FUNCTION(pdf_setcolor) {
Z_STRVAL_PP(arg2),
Z_STRVAL_PP(arg3),
(float) c1,
- (float) Z_DVAL_PP(arg5),
- (float) Z_DVAL_PP(arg6),
- (float) Z_DVAL_PP(arg7));
+ (float) ((argc>4) ? Z_DVAL_PP(arg5):0),
+ (float) ((argc>5) ? Z_DVAL_PP(arg6):0),
+ (float) ((argc>6) ? Z_DVAL_PP(arg7):0));
RETURN_TRUE;
}