Skip to content

Commit ef9069b

Browse files
committed
fix const warnings in intl methods
1 parent 42cb9ac commit ef9069b

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

ext/intl/collator/collator_create.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/* {{{ */
2828
static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
2929
{
30-
char* locale;
30+
const char* locale;
3131
int locale_len = 0;
3232
zval* object;
3333
Collator_object* co;

ext/intl/formatter/formatter_main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/* {{{ */
2828
static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
2929
{
30-
char* locale;
30+
const char* locale;
3131
char* pattern = NULL;
3232
int locale_len = 0, pattern_len = 0;
3333
long style;

ext/intl/locale/locale_methods.c

+23-23
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int16_t findOffset(const char* const* list, const char* key)
121121
}
122122
/*}}}*/
123123

124-
static char* getPreferredTag(char* gf_tag)
124+
static char* getPreferredTag(const char* gf_tag)
125125
{
126126
char* result = NULL;
127127
int grOffset = 0;
@@ -175,7 +175,7 @@ static int getStrrtokenPos(char* str, int savedPos)
175175
* returns -1 if no singleton
176176
* strtok equivalent search for singleton
177177
*/
178-
static int getSingletonPos(char* str)
178+
static int getSingletonPos(const char* str)
179179
{
180180
int result =-1;
181181
int i=0;
@@ -251,7 +251,7 @@ PHP_NAMED_FUNCTION(zif_locale_set_default)
251251
* common code shared by get_primary_language,get_script or get_region or get_variant
252252
* result = 0 if error, 1 if successful , -1 if no value
253253
*/
254-
static char* get_icu_value_internal( char* loc_name , char* tag_name, int* result , int fromParseLocale)
254+
static char* get_icu_value_internal( const char* loc_name , char* tag_name, int* result , int fromParseLocale)
255255
{
256256
char* tag_value = NULL;
257257
int32_t tag_value_len = 512;
@@ -281,7 +281,7 @@ static char* get_icu_value_internal( char* loc_name , char* tag_name, int* resul
281281
/* Handle singletons */
282282
if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
283283
if( strlen(loc_name)>1 && (isIDPrefix(loc_name) ==1 ) ){
284-
return loc_name;
284+
return (char *)loc_name;
285285
}
286286
}
287287

@@ -370,7 +370,7 @@ static char* get_icu_value_internal( char* loc_name , char* tag_name, int* resul
370370
static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
371371
{
372372

373-
char* loc_name = NULL;
373+
const char* loc_name = NULL;
374374
int loc_name_len = 0;
375375

376376
char* tag_value = NULL;
@@ -465,10 +465,10 @@ PHP_FUNCTION(locale_get_primary_language )
465465
}}} */
466466
static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
467467
{
468-
char* loc_name = NULL;
468+
const char* loc_name = NULL;
469469
int loc_name_len = 0;
470470

471-
char* disp_loc_name = NULL;
471+
const char* disp_loc_name = NULL;
472472
int disp_loc_name_len = 0;
473473
int free_loc_name = 0;
474474

@@ -561,7 +561,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
561561
efree( mod_loc_name );
562562
}
563563
if (free_loc_name) {
564-
efree(disp_loc_name);
564+
efree((void *)disp_loc_name);
565565
disp_loc_name = NULL;
566566
}
567567
RETURN_FALSE;
@@ -572,7 +572,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
572572
efree( mod_loc_name );
573573
}
574574
if (free_loc_name) {
575-
efree(disp_loc_name);
575+
efree((void *)disp_loc_name);
576576
disp_loc_name = NULL;
577577
}
578578
/* Convert display locale name from UTF-16 to UTF-8. */
@@ -666,10 +666,10 @@ PHP_FUNCTION( locale_get_keywords )
666666
UEnumeration* e = NULL;
667667
UErrorCode status = U_ZERO_ERROR;
668668

669-
const char* kw_key = NULL;
669+
const char* kw_key = NULL;
670670
int32_t kw_key_len = 0;
671671

672-
char* loc_name = NULL;
672+
const char* loc_name = NULL;
673673
int loc_name_len = 0;
674674

675675
/*
@@ -716,7 +716,7 @@ PHP_FUNCTION( locale_get_keywords )
716716
kw_value = erealloc( kw_value , kw_value_len+1);
717717
}
718718
if (U_FAILURE(status)) {
719-
intl_error_set( NULL, FAILURE, "locale_get_keywords: Error encountered while getting the keyword value for the keyword", 0 TSRMLS_CC );
719+
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_get_keywords: Error encountered while getting the keyword value for the keyword", 0 TSRMLS_CC );
720720
if( kw_value){
721721
efree( kw_value );
722722
}
@@ -974,12 +974,12 @@ PHP_FUNCTION(locale_compose)
974974
* e.g. for locale='en_US-x-prv1-prv2-prv3'
975975
* returns a pointer to the string 'prv1-prv2-prv3'
976976
*/
977-
static char* get_private_subtags(char* loc_name)
977+
static char* get_private_subtags(const char* loc_name)
978978
{
979979
char* result =NULL;
980980
int singletonPos = 0;
981981
int len =0;
982-
char* mod_loc_name =NULL;
982+
const char* mod_loc_name =NULL;
983983

984984
if( loc_name && (len = strlen(loc_name)>0 ) ){
985985
mod_loc_name = loc_name ;
@@ -1019,7 +1019,7 @@ static char* get_private_subtags(char* loc_name)
10191019

10201020
/* {{{ code used by locale_parse
10211021
*/
1022-
static int add_array_entry(char* loc_name, zval* hash_arr, char* key_name TSRMLS_DC)
1022+
static int add_array_entry(const char* loc_name, zval* hash_arr, char* key_name TSRMLS_DC)
10231023
{
10241024
char* key_value = NULL;
10251025
char* cur_key_name = NULL;
@@ -1084,7 +1084,7 @@ static int add_array_entry(char* loc_name, zval* hash_arr, char* key_name TSRMLS
10841084
*/
10851085
PHP_FUNCTION(locale_parse)
10861086
{
1087-
char* loc_name = NULL;
1087+
const char* loc_name = NULL;
10881088
int loc_name_len = 0;
10891089
int grOffset = 0;
10901090

@@ -1128,8 +1128,8 @@ PHP_FUNCTION(locale_parse)
11281128
*/
11291129
PHP_FUNCTION(locale_get_all_variants)
11301130
{
1131-
char* loc_name = NULL;
1132-
int loc_name_len = 0;
1131+
const char* loc_name = NULL;
1132+
int loc_name_len = 0;
11331133

11341134
int result = 0;
11351135
char* token = NULL;
@@ -1182,10 +1182,10 @@ PHP_FUNCTION(locale_get_all_variants)
11821182
/*{{{
11831183
* Converts to lower case and also replaces all hyphens with the underscore
11841184
*/
1185-
static int strToMatch(char* str ,char *retstr)
1185+
static int strToMatch(const char* str ,char *retstr)
11861186
{
11871187
char* anchor = NULL;
1188-
char* anchor1 = NULL;
1188+
const char* anchor1 = NULL;
11891189
int result = 0;
11901190
int len = 0;
11911191

@@ -1225,7 +1225,7 @@ PHP_FUNCTION(locale_filter_matches)
12251225
{
12261226
char* lang_tag = NULL;
12271227
int lang_tag_len = 0;
1228-
char* loc_range = NULL;
1228+
const char* loc_range = NULL;
12291229
int loc_range_len = 0;
12301230

12311231
int result = 0;
@@ -1401,7 +1401,7 @@ static void array_cleanup( char* arr[] , int arr_size)
14011401
* returns the lookup result to lookup_loc_range_src_php
14021402
* internal function
14031403
*/
1404-
static char* lookup_loc_range(char* loc_range, HashTable* hash_arr, int canonicalize TSRMLS_DC)
1404+
static char* lookup_loc_range(const char* loc_range, HashTable* hash_arr, int canonicalize TSRMLS_DC)
14051405
{
14061406
int i = 0;
14071407
int cur_arr_len = 0;
@@ -1523,7 +1523,7 @@ PHP_FUNCTION(locale_lookup)
15231523
{
15241524
char* fallback_loc = NULL;
15251525
int fallback_loc_len = 0;
1526-
char* loc_range = NULL;
1526+
const char* loc_range = NULL;
15271527
int loc_range_len = 0;
15281528

15291529
zval* arr = NULL;

ext/intl/msgformat/msgformat.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/* {{{ */
2929
static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
3030
{
31-
char* locale;
31+
const char* locale;
3232
char* pattern;
3333
int locale_len = 0, pattern_len = 0;
3434
UChar* spattern = NULL;

ext/intl/msgformat/msgformat_format.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ PHP_FUNCTION( msgfmt_format_message )
103103
int spattern_len = 0;
104104
char *pattern = NULL;
105105
int pattern_len = 0;
106-
char *slocale = NULL;
106+
const char *slocale = NULL;
107107
int slocale_len = 0;
108108
MessageFormatter_object mf = {0};
109109
MessageFormatter_object *mfo = &mf;

ext/intl/msgformat/msgformat_parse.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ PHP_FUNCTION( msgfmt_parse_message )
9393
int spattern_len = 0;
9494
char *pattern = NULL;
9595
int pattern_len = 0;
96-
char *slocale = NULL;
96+
const char *slocale = NULL;
9797
int slocale_len = 0;
9898
char *source = NULL;
9999
int src_len = 0;

0 commit comments

Comments
 (0)