mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-5.4'
By Gustavo André dos Santos Lopes (4) and others via Felipe Pena (2) and Xinchen Hui (2) * PHP-5.4: Remove unused codes based on microsoft's description,the direct convert from FILETIME struct to __int64 is unsafe. merge 5.3 entries restore NEWS Fix ext/intl build on ICU < 4.8 Optimization in ext/intl/msgformat Fixed tests in ext/intl Changed XFAILed collator_get_sort_key.phpt
This commit is contained in:
commit
07d0eab204
11 changed files with 79 additions and 245 deletions
|
@ -64,9 +64,11 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
|
|||
locale = INTL_G(default_locale);
|
||||
}
|
||||
|
||||
#ifdef MSG_FORMAT_QUOTE_APOS
|
||||
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
|
||||
INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format");
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((mfo)->mf_data.orig_format) {
|
||||
msgformat_data_free(&mfo->mf_data TSRMLS_CC);
|
||||
|
|
|
@ -82,11 +82,13 @@ PHP_FUNCTION( msgfmt_set_pattern )
|
|||
intl_convert_utf8_to_utf16(&spattern, &spattern_len, value, value_len, &INTL_DATA_ERROR_CODE(mfo));
|
||||
INTL_METHOD_CHECK_STATUS(mfo, "Error converting pattern to UTF-16" );
|
||||
|
||||
#ifdef MSG_FORMAT_QUOTE_APOS
|
||||
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
|
||||
intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
|
||||
"msgfmt_set_pattern: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* TODO: add parse error information */
|
||||
umsg_applyPattern(MSG_FORMAT_OBJECT(mfo), spattern, spattern_len, NULL, &INTL_DATA_ERROR_CODE(mfo));
|
||||
|
|
|
@ -19,9 +19,11 @@
|
|||
|
||||
#include <php.h>
|
||||
|
||||
#include "intl_common.h"
|
||||
#include "intl_error.h"
|
||||
#include "intl_data.h"
|
||||
#include <unicode/uconfig.h>
|
||||
|
||||
#include "../intl_common.h"
|
||||
#include "../intl_error.h"
|
||||
#include "../intl_data.h"
|
||||
#include "msgformat_data.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -38,4 +40,8 @@ extern zend_class_entry *MessageFormatter_ce_ptr;
|
|||
#define MSG_FORMAT_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(MessageFormatter, mfo)
|
||||
#define MSG_FORMAT_OBJECT(mfo) (mfo)->mf_data.umsgf
|
||||
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM < 48
|
||||
# define MSG_FORMAT_QUOTE_APOS 1
|
||||
#endif
|
||||
|
||||
#endif // #ifndef MSG_FORMAT_CLASS_H
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <unicode/ustring.h>
|
||||
#include "msgformat_data.h"
|
||||
|
||||
#include "msgformat_class.h"
|
||||
|
||||
/* {{{ void msgformat_data_init( msgformat_data* mf_data )
|
||||
* Initialize internals of msgformat_data.
|
||||
*/
|
||||
|
@ -77,6 +79,7 @@ msgformat_data* msgformat_data_create( TSRMLS_D )
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
#ifdef MSG_FORMAT_QUOTE_APOS
|
||||
int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec)
|
||||
{
|
||||
if(*spattern && *spattern_len && u_strchr(*spattern, (UChar)'\'')) {
|
||||
|
@ -94,6 +97,7 @@ int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *e
|
|||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include <php.h>
|
||||
|
||||
#include <unicode/umsg.h>
|
||||
#include "../intl_error.h"
|
||||
|
||||
#include "intl_error.h"
|
||||
#include <unicode/umsg.h>
|
||||
|
||||
typedef struct {
|
||||
// error hangling
|
||||
|
@ -38,6 +38,9 @@ typedef struct {
|
|||
msgformat_data* msgformat_data_create( TSRMLS_D );
|
||||
void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC );
|
||||
void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC );
|
||||
|
||||
#ifdef MSG_FORMAT_QUOTE_APOS
|
||||
int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec);
|
||||
#endif
|
||||
|
||||
#endif // MSG_FORMAT_DATA_H
|
||||
|
|
|
@ -137,11 +137,13 @@ PHP_FUNCTION( msgfmt_format_message )
|
|||
slocale = INTL_G(default_locale);
|
||||
}
|
||||
|
||||
#ifdef MSG_FORMAT_QUOTE_APOS
|
||||
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
|
||||
intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
|
||||
"msgfmt_format_message: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Create an ICU message formatter. */
|
||||
MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo));
|
||||
|
|
|
@ -129,11 +129,13 @@ PHP_FUNCTION( msgfmt_parse_message )
|
|||
slocale = INTL_G(default_locale);
|
||||
}
|
||||
|
||||
#ifdef MSG_FORMAT_QUOTE_APOS
|
||||
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
|
||||
intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
|
||||
"msgfmt_parse_message: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Create an ICU message formatter. */
|
||||
MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo));
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
collator_get_sort_key()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
--XFAIL--
|
||||
Sort keys are not fixed, comparing them to fixed strings doesn't work.
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
@ -18,8 +17,8 @@ function sort_arrays( $locale, $data )
|
|||
|
||||
foreach($data as $value) {
|
||||
$res_val = ut_coll_get_sort_key( $coll, $value );
|
||||
$res_str .= "source: ".urlencode($value)."\n".
|
||||
"key: ".urlencode($res_val)."\n";
|
||||
$res_str .= "source: ".$value."\n".
|
||||
"key: ".bin2hex($res_val)."\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
@ -58,42 +57,42 @@ ut_run();
|
|||
?>
|
||||
--EXPECT--
|
||||
source: abc
|
||||
key: %29%2B-%01%07%01%07%00
|
||||
key: 27292b01070107
|
||||
source: abd
|
||||
key: %29%2B%2F%01%07%01%07%00
|
||||
key: 27292d01070107
|
||||
source: aaa
|
||||
key: %29%29%29%01%07%01%07%00
|
||||
source: %D0%B0%D0%B0
|
||||
key: _++%01%06%01%06%00
|
||||
source: %D0%B0
|
||||
key: _+%01%05%01%05%00
|
||||
key: 27272701070107
|
||||
source: аа
|
||||
key: 5c0a0a01060106
|
||||
source: а
|
||||
key: 5c0a01050105
|
||||
source: z
|
||||
key: %5B%01%05%01%05%00
|
||||
source:
|
||||
key: %01%01%00
|
||||
source:
|
||||
key: %01%01%00
|
||||
key: 5901050105
|
||||
source:
|
||||
key: 0101
|
||||
source:
|
||||
key: 0101
|
||||
source: 3
|
||||
key: %26%80%01%05%01%05%00
|
||||
key: 1801050105
|
||||
source: y
|
||||
key: Y%01%05%01%05%00
|
||||
key: 5701050105
|
||||
source: i
|
||||
key: 9%01%05%01%05%00
|
||||
key: 3701050105
|
||||
source: k
|
||||
key: %3D%01%05%01%05%00
|
||||
source: %D0%B0%D0%B1%D0%B3
|
||||
key: _+%2C0%01%07%01%07%00
|
||||
source: %D0%B0%D0%B1%D0%B2
|
||||
key: _+%2C.%01%07%01%07%00
|
||||
source: %D0%B6%D0%B6%D0%B6
|
||||
key: _LLL%01%07%01%07%00
|
||||
source: %D1%8D%D1%8E%D1%8F
|
||||
key: %60%05%09%0B%01%07%01%07%00
|
||||
source: %D0%B0%D0%B1%D0%B3
|
||||
key: _+%2C0%01%07%01%07%00
|
||||
source: %D0%B0%D0%B1%D0%B2
|
||||
key: _+%2C.%01%07%01%07%00
|
||||
source: %D0%B6%D0%B6%D0%B6
|
||||
key: _LLL%01%07%01%07%00
|
||||
source: %D1%8D%D1%8E%D1%8F
|
||||
key: %60%05%09%0B%01%07%01%07%00
|
||||
key: 3b01050105
|
||||
source: абг
|
||||
key: 5c0a161a01070107
|
||||
source: абв
|
||||
key: 5c0a161801070107
|
||||
source: жжж
|
||||
key: 5c3a3a3a01070107
|
||||
source: эюя
|
||||
key: 5d3b3f4501070107
|
||||
source: абг
|
||||
key: 5c0a161a01070107
|
||||
source: абв
|
||||
key: 5c0a161801070107
|
||||
source: жжж
|
||||
key: 5c3a3a3a01070107
|
||||
source: эюя
|
||||
key: 5d3b3f4501070107
|
|
@ -1,8 +1,8 @@
|
|||
--TEST--
|
||||
numfmt_get/set_attribute() icu < 4.2
|
||||
numfmt_get/set_attribute()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.2', '<') != 1) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.2', '<') != 1) print 'skip for ICU 4.4+'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
@ -29,7 +29,7 @@ function ut_main()
|
|||
'ROUNDING_MODE' => array( NumberFormatter::ROUNDING_MODE, 1, 12345.123456 ),
|
||||
'ROUNDING_INCREMENT' => array( NumberFormatter::ROUNDING_INCREMENT, (float)2, 12345.123456 ),
|
||||
'FORMAT_WIDTH' => array( NumberFormatter::FORMAT_WIDTH, 27, 12345.123456 ),
|
||||
'PADDING_POSITION' => array( NumberFormatter::PADDING_POSITION, 21, 12345.123456 ),
|
||||
'PADDING_POSITION' => array( NumberFormatter::PADDING_POSITION, 2, 12345.123456 ),
|
||||
'SECONDARY_GROUPING_SIZE' => array( NumberFormatter::SECONDARY_GROUPING_SIZE, 2, 12345.123456 ),
|
||||
'SIGNIFICANT_DIGITS_USED' => array( NumberFormatter::SIGNIFICANT_DIGITS_USED, 1, 12345.123456 ),
|
||||
'MIN_SIGNIFICANT_DIGITS' => array( NumberFormatter::MIN_SIGNIFICANT_DIGITS, 3, 1 ),
|
||||
|
@ -159,7 +159,7 @@ Setting attribute: ok
|
|||
New attribute value: 1 ; Format result: '0,012,345.12345' ; Parse result: 12345.12345
|
||||
|
||||
Attribute ROUNDING_INCREMENT
|
||||
Old attribute value: 1.0E-5 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
Old attribute value: 0 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 2 ; Format result: '0,012,346.00000' ; Parse result: 12346
|
||||
|
||||
|
@ -171,7 +171,7 @@ New attribute value: 27 ; Format result: '************0,012,345.12346' ; Parse
|
|||
Attribute PADDING_POSITION
|
||||
Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 21 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
New attribute value: 2 ; Format result: '0,012,345.12346************' ; Parse result: 12345.12346
|
||||
|
||||
Attribute SECONDARY_GROUPING_SIZE
|
||||
Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
|
||||
|
|
|
@ -1,194 +0,0 @@
|
|||
--TEST--
|
||||
numfmt_get/set_attribute() icu >= 4.8
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Get/set various number formatting attributes.
|
||||
*/
|
||||
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
// attr_name => array( attr, value )
|
||||
$attributes = array(
|
||||
'PARSE_INT_ONLY' => array( NumberFormatter::PARSE_INT_ONLY, 1, 12345.123456 ),
|
||||
'GROUPING_USED' => array( NumberFormatter::GROUPING_USED, 0, 12345.123456 ),
|
||||
'DECIMAL_ALWAYS_SHOWN' => array( NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1, 12345 ),
|
||||
'MAX_INTEGER_DIGITS' => array( NumberFormatter::MAX_INTEGER_DIGITS, 2, 12345.123456 ),
|
||||
'MIN_INTEGER_DIGITS' => array( NumberFormatter::MIN_INTEGER_DIGITS, 20, 12345.123456 ),
|
||||
'INTEGER_DIGITS' => array( NumberFormatter::INTEGER_DIGITS, 7, 12345.123456 ),
|
||||
'MAX_FRACTION_DIGITS' => array( NumberFormatter::MAX_FRACTION_DIGITS, 2, 12345.123456 ),
|
||||
'MIN_FRACTION_DIGITS' => array( NumberFormatter::MIN_FRACTION_DIGITS, 20, 12345.123456 ),
|
||||
'FRACTION_DIGITS' => array( NumberFormatter::FRACTION_DIGITS, 5, 12345.123456 ),
|
||||
'MULTIPLIER' => array( NumberFormatter::MULTIPLIER, 2, 12345.123456 ),
|
||||
'GROUPING_SIZE' => array( NumberFormatter::GROUPING_SIZE, 2, 12345.123456 ),
|
||||
'ROUNDING_MODE' => array( NumberFormatter::ROUNDING_MODE, 1, 12345.123456 ),
|
||||
'ROUNDING_INCREMENT' => array( NumberFormatter::ROUNDING_INCREMENT, (float)2, 12345.123456 ),
|
||||
'FORMAT_WIDTH' => array( NumberFormatter::FORMAT_WIDTH, 27, 12345.123456 ),
|
||||
'PADDING_POSITION' => array( NumberFormatter::PADDING_POSITION, 21, 12345.123456 ),
|
||||
'SECONDARY_GROUPING_SIZE' => array( NumberFormatter::SECONDARY_GROUPING_SIZE, 2, 12345.123456 ),
|
||||
'SIGNIFICANT_DIGITS_USED' => array( NumberFormatter::SIGNIFICANT_DIGITS_USED, 1, 12345.123456 ),
|
||||
'MIN_SIGNIFICANT_DIGITS' => array( NumberFormatter::MIN_SIGNIFICANT_DIGITS, 3, 1 ),
|
||||
'MAX_SIGNIFICANT_DIGITS' => array( NumberFormatter::MAX_SIGNIFICANT_DIGITS, 4, 12345.123456 ),
|
||||
// 'LENIENT_PARSE' => array( NumberFormatter::LENIENT_PARSE, 2, 12345.123456 )
|
||||
);
|
||||
|
||||
$res_str = '';
|
||||
|
||||
$fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL );
|
||||
|
||||
foreach( $attributes as $attr_name => $args )
|
||||
{
|
||||
list( $attr, $new_val, $number ) = $args;
|
||||
$res_str .= "\nAttribute $attr_name\n";
|
||||
|
||||
// Get original value of the attribute.
|
||||
$orig_val = ut_nfmt_get_attribute( $fmt, $attr );
|
||||
|
||||
// Format the number using the original attribute value.
|
||||
$rc = ut_nfmt_format( $fmt, $number );
|
||||
|
||||
$ps = ut_nfmt_parse( $fmt, $rc );
|
||||
|
||||
$res_str .= sprintf( "Old attribute value: %s ; Format result: %s ; Parse result: %s\n",
|
||||
dump( $orig_val ),
|
||||
dump( $rc ),
|
||||
dump( $ps ) );
|
||||
|
||||
// Set new attribute value.
|
||||
$rc = ut_nfmt_set_attribute( $fmt, $attr, $new_val );
|
||||
if( $rc )
|
||||
$res_str .= "Setting attribute: ok\n";
|
||||
else
|
||||
$res_str .= sprintf( "Setting attribute failed: %s\n", ut_nfmt_get_error_message( $fmt ) );
|
||||
|
||||
// Format the number using the new value.
|
||||
$rc = ut_nfmt_format( $fmt, $number );
|
||||
|
||||
// Get current value of the attribute and check if it equals $new_val.
|
||||
$attr_val_check = ut_nfmt_get_attribute( $fmt, $attr );
|
||||
if( $attr_val_check !== $new_val )
|
||||
$res_str .= "ERROR: New $attr_name attribute value has not been set correctly.\n";
|
||||
|
||||
$ps = ut_nfmt_parse( $fmt, $rc );
|
||||
|
||||
$res_str .= sprintf( "New attribute value: %s ; Format result: %s ; Parse result: %s\n",
|
||||
dump( $new_val ),
|
||||
dump( $rc ),
|
||||
dump( $ps ) );
|
||||
|
||||
|
||||
// Restore original attribute of the value
|
||||
if( $attr != NumberFormatter::INTEGER_DIGITS && $attr != NumberFormatter::FRACTION_DIGITS
|
||||
&& $attr != NumberFormatter::FORMAT_WIDTH && $attr != NumberFormatter::SIGNIFICANT_DIGITS_USED )
|
||||
ut_nfmt_set_attribute( $fmt, $attr, $orig_val );
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Attribute PARSE_INT_ONLY
|
||||
Old attribute value: 0 ; Format result: '12,345.123' ; Parse result: 12345.123
|
||||
Setting attribute: ok
|
||||
New attribute value: 1 ; Format result: '12,345.123' ; Parse result: 12345
|
||||
|
||||
Attribute GROUPING_USED
|
||||
Old attribute value: 1 ; Format result: '12,345.123' ; Parse result: 12345.123
|
||||
Setting attribute: ok
|
||||
New attribute value: 0 ; Format result: '12345.123' ; Parse result: 12345.123
|
||||
|
||||
Attribute DECIMAL_ALWAYS_SHOWN
|
||||
Old attribute value: 0 ; Format result: '12,345' ; Parse result: 12345
|
||||
Setting attribute: ok
|
||||
New attribute value: 1 ; Format result: '12,345.' ; Parse result: 12345
|
||||
|
||||
Attribute MAX_INTEGER_DIGITS
|
||||
Old attribute value: 309 ; Format result: '12,345.123' ; Parse result: 12345.123
|
||||
Setting attribute: ok
|
||||
New attribute value: 2 ; Format result: '45.123' ; Parse result: 45.123
|
||||
|
||||
Attribute MIN_INTEGER_DIGITS
|
||||
Old attribute value: 1 ; Format result: '12,345.123' ; Parse result: 12345.123
|
||||
Setting attribute: ok
|
||||
New attribute value: 20 ; Format result: '00,000,000,000,000,012,345.123' ; Parse result: 12345.123
|
||||
|
||||
Attribute INTEGER_DIGITS
|
||||
Old attribute value: 1 ; Format result: '12,345.123' ; Parse result: 12345.123
|
||||
Setting attribute: ok
|
||||
New attribute value: 7 ; Format result: '0,012,345.123' ; Parse result: 12345.123
|
||||
|
||||
Attribute MAX_FRACTION_DIGITS
|
||||
Old attribute value: 3 ; Format result: '0,012,345.123' ; Parse result: 12345.123
|
||||
Setting attribute: ok
|
||||
New attribute value: 2 ; Format result: '0,012,345.12' ; Parse result: 12345.12
|
||||
|
||||
Attribute MIN_FRACTION_DIGITS
|
||||
Old attribute value: 0 ; Format result: '0,012,345.123' ; Parse result: 12345.123
|
||||
Setting attribute: ok
|
||||
New attribute value: 20 ; Format result: '0,012,345.12345600000000000000' ; Parse result: 12345.123456
|
||||
|
||||
Attribute FRACTION_DIGITS
|
||||
Old attribute value: 0 ; Format result: '0,012,345.123456' ; Parse result: 12345.123456
|
||||
Setting attribute: ok
|
||||
New attribute value: 5 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
|
||||
Attribute MULTIPLIER
|
||||
Old attribute value: 1 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 2 ; Format result: '0,024,690.24691' ; Parse result: 12345.123455
|
||||
|
||||
Attribute GROUPING_SIZE
|
||||
Old attribute value: 3 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 2 ; Format result: '0,01,23,45.12346' ; Parse result: 12345.12346
|
||||
|
||||
Attribute ROUNDING_MODE
|
||||
Old attribute value: 4 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 1 ; Format result: '0,012,345.12345' ; Parse result: 12345.12345
|
||||
|
||||
Attribute ROUNDING_INCREMENT
|
||||
Old attribute value: 0 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 2 ; Format result: '0,012,346.00000' ; Parse result: 12346
|
||||
|
||||
Attribute FORMAT_WIDTH
|
||||
Old attribute value: 0 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 27 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
|
||||
|
||||
Attribute PADDING_POSITION
|
||||
Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 21 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346
|
||||
|
||||
Attribute SECONDARY_GROUPING_SIZE
|
||||
Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 2 ; Format result: '************00,12,345.12346' ; Parse result: 12345.12346
|
||||
|
||||
Attribute SIGNIFICANT_DIGITS_USED
|
||||
Old attribute value: 0 ; Format result: '************0,012,345.12346' ; Parse result: 12345.12346
|
||||
Setting attribute: ok
|
||||
New attribute value: 1 ; Format result: '*******************12,345.1' ; Parse result: 12345.1
|
||||
|
||||
Attribute MIN_SIGNIFICANT_DIGITS
|
||||
Old attribute value: 1 ; Format result: '**************************1' ; Parse result: 1
|
||||
Setting attribute: ok
|
||||
New attribute value: 3 ; Format result: '***********************1.00' ; Parse result: 1
|
||||
|
||||
Attribute MAX_SIGNIFICANT_DIGITS
|
||||
Old attribute value: 6 ; Format result: '*******************12,345.1' ; Parse result: 12345.1
|
||||
Setting attribute: ok
|
||||
New attribute value: 4 ; Format result: '*********************12,350' ; Parse result: 12350
|
18
win32/time.c
18
win32/time.c
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* DH_TIME.C *
|
||||
|
@ -35,12 +34,21 @@
|
|||
|
||||
int getfilesystemtime(struct timeval *time_Info)
|
||||
{
|
||||
FILETIME ft;
|
||||
__int64 ff;
|
||||
FILETIME ft;
|
||||
__int64 ff;
|
||||
ULARGE_INTEGER convFromft;
|
||||
|
||||
GetSystemTimeAsFileTime(&ft); /* 100 ns blocks since 01-Jan-1641 */
|
||||
/* resolution seems to be 0.01 sec */
|
||||
ff = *(__int64*)(&ft);
|
||||
/* resolution seems to be 0.01 sec */
|
||||
/*
|
||||
* Do not cast a pointer to a FILETIME structure to either a
|
||||
* ULARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows.
|
||||
* via http://technet.microsoft.com/en-us/library/ms724284(v=vs.85).aspx
|
||||
*/
|
||||
convFromft.HighPart = ft.dwHighDateTime;
|
||||
convFromft.LowPart = ft.dwLowDateTime;
|
||||
ff = convFromft.QuadPart;
|
||||
|
||||
time_Info->tv_sec = (int)(ff/(__int64)10000000-(__int64)11644473600);
|
||||
time_Info->tv_usec = (int)(ff % 10000000)/10;
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue