Sheri wrote:
> Philip Hazel wrote:
>
>> On Sun, 30 Dec 2007, Sheri wrote:
>>
>>
>>
>>> "Add a call to |_set_printf_count_output(1)| at the beginning of |main|
>>> in pcregrep.c; by default VC CRT does not support the format "%n" and
>>> the program pcregrep.exe using such format would crash."
>>>
>>>
>> %n is utterly Standard C - standardised around 1990. I try very hard to
>> write only Standard C, 1990 version, only deviating when I have to
>> interact with the operating system, in the interests of portability.
>> Consequently, I'm afraid I have no interest in messing about for the
>> benefit of environments that cannot support Standard 1990 C. I know this
>> sounds harsh, but one has to draw a line somewhere. (I *have* deviated
>> from this in the matter of providing for the absence of certain Standard
>> library functions, notably memmove(), but that's as far as I'm prepared
>> to go, and I muttered an awful lot when I did it. :-)
>>
>> Philip
>>
>>
The function is available, but is disabled by default for "security
reasons":
From:
http://msdn2.microsoft.com/en-us/library/ms175782.aspx
"Because of security reasons, support for the %n format specifier is
disabled by default in printf and all its variants. If %n is encountered
in a printf format specification, the default behavior is to invoke the
invalid parameter handler as described in Parameter Validation
<
http://msdn2.microsoft.com/en-us/library/ksazx244.aspx>. Calling
_set_printf_count_output with a non-zero argument will cause
printf-family functions to interpret %n as described in printf Type
Field Characters <
http://msdn2.microsoft.com/en-us/library/hf4y5e3w.aspx>."
Regards,
Sheri