Hi,

/* Not binary safe, but depending on your data that may be okay */
if (Z_STRLEN_PP(data) > 30) {
  php_stream_write(stream, Z_STRVAL_PP(data), 30);
} else {
  php_stream_printf(stream TSRMLS_CC, "%-30s", Z_STRVAL_PP(data));
}
Both solutions will pad the string with ' ', but I need to pad it with '\0'.

P.S. - As you might have noticed in the above code  Z_STRVAL_PP(data) is the
same as Z_STRVAL_P(*data).  The same is true of the Z_LVAL_P(*data) you used
in your previous question.   I don't recall if using the _PP is dictated by
the coding standards, but it's certainly in line with established
convention.  You'll probably find your code becomes more readable by others
who are accostomed to the PHP Core if you stick to the secondary indirection
macros.

OK, I'll adjust this in the extension.

Thanks,

Stephan

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to