[vlc-commits] [Git][videolan/vlc][master] 5 commits: charset: improve Doxygen
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Fri May 27 20:34:34 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
eb2e8a1a by Rémi Denis-Courmont at 2022-05-27T20:22:32+00:00
charset: improve Doxygen
- - - - -
9791d0cd by Rémi Denis-Courmont at 2022-05-27T20:22:32+00:00
charset: inline trivial us_atof()
- - - - -
91646be8 by Rémi Denis-Courmont at 2022-05-27T20:22:32+00:00
charset: rename us_* to vlc_*_c()
This matches the naming convention of vlc_strerror_c(), and avoids
clobbering the global namespace.
- - - - -
b71177af by Rémi Denis-Courmont at 2022-05-27T20:22:32+00:00
src: no longer allow the us_ prefix
- - - - -
a11e147d by Rémi Denis-Courmont at 2022-05-27T20:22:32+00:00
webvtt: fix parsing with comma as decimal separator
This fixes the CSS parser when the numeric locale has a comma instead
of a dot as decimal separator (notably the French locales).
- - - - -
28 changed files:
- include/vlc_charset.h
- modules/access/idummy.c
- modules/access_output/livehttp.c
- modules/audio_filter/equalizer.c
- modules/codec/jpeg.c
- modules/codec/ttml/substtml.c
- modules/codec/ttml/ttml.c
- modules/codec/vorbis.c
- modules/codec/webvtt/CSSLexer.l
- modules/codec/webvtt/encvtt.c
- modules/codec/webvtt/subsvtt.c
- modules/codec/x264.c
- modules/demux/adaptive/tools/Conversions.cpp
- modules/demux/mp4/mp4.c
- modules/demux/mpeg/es.c
- modules/demux/playlist/m3u.c
- modules/demux/subtitle.c
- modules/demux/xiph_metadata.c
- src/check_symbols
- src/config/chain.c
- src/config/cmdline.c
- src/input/meta.c
- src/input/vlmshell.c
- src/libvlccore.sym
- src/misc/variables.c
- src/network/httpd.c
- src/test/i18n_atof.c
- src/text/charset.c
Changes:
=====================================
include/vlc_charset.h
=====================================
@@ -349,11 +349,87 @@ static inline char *FromLatin1 (const char *latin)
* \defgroup c_locale C/POSIX locale functions
* @{
*/
-VLC_API double us_strtod( const char *, char ** ) VLC_USED;
-VLC_API float us_strtof( const char *, char ** ) VLC_USED;
-VLC_API double us_atof( const char * ) VLC_USED;
-VLC_API int us_vasprintf( char **, const char *, va_list );
-VLC_API int us_asprintf( char **, const char *, ... ) VLC_USED;
+
+/**
+ * Parses a double in C locale.
+ *
+ * This function parses a double-precision floating point number from a string
+ * just like the standard strtod() but it uses the C locale. In other words, it
+ * expects the POSIX/C/American decimal format regardless of the current
+ * numeric locale.
+ *
+ * \param str nul-terminated string to parse
+ * \param[out] end storage space for a pointer to the first unparsed byte
+ * (or NULL to discard it)
+ * \return the parsed double value (zero if no character could be parsed)
+ */
+VLC_API double vlc_strtod_c(const char *restrict str, char **restrict end)
+VLC_USED;
+
+/**
+ * Parses a float in C locale.
+ *
+ * This function parses a single-precision floating point number from a string
+ * just like the standard strtof() but it uses the C locale. In other words, it
+ * expects the POSIX/C/American decimal format regardless of the current
+ * numeric locale.
+ *
+ * \param str nul-terminated string to parse
+ * \param[out] end storage space for a pointer to the first unparsed byte
+ * (or NULL to discard it)
+ * \return the parsed double value (zero if no character could be parsed)
+ */
+VLC_API float vlc_strtof_c(const char *restrict str, char **restrict end)
+VLC_USED;
+
+/**
+ * Parses a double in C locale.
+ *
+ * This function parses a double-precision floating point number from a string
+ * just like the standard atof() but it uses the C locale. In other words, it
+ * expects the POSIX/C/American decimal format regardless of the current
+ * numeric locale.
+ *
+ * \param str nul-terminated string to parse
+ * \return the parsed double value (zero if no character could be parsed)
+ */
+VLC_USED static inline double vlc_atof_c(const char *str)
+{
+ return vlc_strtod_c(str, NULL);
+}
+
+/**
+ * Formats a string using the C locale.
+ *
+ * This function formats a string from a format string and a variable argument
+ * list, just like the standard vasprintf() but using the C locale for the
+ * formatting of numerals.
+ *
+ * \param[out] p storage space for a pointer to the heap-allocated formatted
+ * string (undefined on error)
+ * \param fmt format string
+ * \param ap variable argument list
+ * \return number of bytes formatted (excluding the nul terminator)
+ * or -1 on error
+ */
+VLC_API int vlc_vasprintf_c(char **restrict p, const char *restrict fmt,
+ va_list ap) VLC_USED;
+
+/**
+ * Formats a string using the C locale.
+ *
+ * This function formats a string from a format string and a variable argument
+ * list, just like the standard vasprintf() but using the C locale for the
+ * formatting of numerals.
+ *
+ * \param[out] p storage space for a pointer to the heap-allocated formatted
+ * string (undefined on error)
+ * \param fmt format string
+ * \return number of bytes formatted (excluding the nul terminator)
+ * or -1 on error
+ */
+VLC_API int vlc_asprintf_c( char **, const char *, ... ) VLC_USED;
+
/** @} */
/** @} */
=====================================
modules/access/idummy.c
=====================================
@@ -175,7 +175,7 @@ nop:
/* Check for a "vlc://pause:***" command */
if( !strncasecmp( psz_name, "pause:", 6 ) )
{
- double f = us_atof( psz_name + 6 );
+ double f = vlc_atof_c( psz_name + 6 );
vlc_tick_t length = vlc_tick_from_sec( f );
msg_Info( p_demux, "command `pause %f'", f );
=====================================
modules/access_output/livehttp.c
=====================================
@@ -729,7 +729,7 @@ static void closeCurrentSegment( sout_access_out_t *p_access, sout_access_out_sy
vlc_close( p_sys->i_handle );
p_sys->i_handle = -1;
- if( us_asprintf( &segment->psz_duration, "%.2f", secf_from_vlc_tick( p_sys->current_segment_length ) ) == -1 )
+ if( vlc_asprintf_c( &segment->psz_duration, "%.2f", secf_from_vlc_tick( p_sys->current_segment_length ) ) == -1 )
{
msg_Err( p_access, "Couldn't set duration on closed segment");
return;
=====================================
modules/audio_filter/equalizer.c
=====================================
@@ -547,7 +547,7 @@ static int BandsCallback( vlc_object_t *p_this, char const *psz_cmd,
{
char *next;
/* Read dB -20/20 */
- float f = us_strtof( p, &next );
+ float f = vlc_strtof_c( p, &next );
if( next == p || isnan( f ) )
break; /* no conversion */
=====================================
modules/codec/jpeg.c
=====================================
@@ -277,7 +277,7 @@ static bool getRDFFloat(const char *psz_rdf, float *out, const char *psz_var)
if (unlikely(p_end == NULL || p_end == p_start + 1))
return false;
- *out = us_strtof(p_start, NULL);
+ *out = vlc_strtof_c(p_start, NULL);
return true;
}
=====================================
modules/codec/ttml/substtml.c
=====================================
@@ -223,7 +223,7 @@ static ttml_length_t ttml_read_length( const char *psz )
ttml_length_t len = { 0.0, TTML_UNIT_UNKNOWN };
char* psz_end = NULL;
- float size = us_strtof( psz, &psz_end );
+ float size = vlc_strtof_c( psz, &psz_end );
len.i_value = size;
if( psz_end )
{
=====================================
modules/codec/ttml/ttml.c
=====================================
@@ -106,7 +106,7 @@ static tt_time_t tt_ParseTime( const char *s )
else /* Offset Time */
{
char *psz_end = (char *) s;
- double v = us_strtod( s, &psz_end );
+ double v = vlc_strtod_c( s, &psz_end );
if( psz_end != s && *psz_end )
{
if( *psz_end == 'm' )
=====================================
modules/codec/vorbis.c
=====================================
@@ -625,7 +625,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
r->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
- r->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
+ r->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = vlc_atof_c( psz_value );
}
else if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_PEAK" ) ||
!strcasecmp( psz_name, "RG_PEAK" ) )
@@ -633,7 +633,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
r->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
- r->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
+ r->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = vlc_atof_c( psz_value );
}
else if( !strcasecmp( psz_name, "REPLAYGAIN_ALBUM_GAIN" ) ||
!strcasecmp( psz_name, "RG_AUDIOPHILE" ) )
@@ -641,14 +641,14 @@ static void ParseVorbisComments( decoder_t *p_dec )
audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
r->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
- r->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
+ r->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = vlc_atof_c( psz_value );
}
else if( !strcasecmp( psz_name, "REPLAYGAIN_ALBUM_PEAK" ) )
{
audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
r->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
- r->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
+ r->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = vlc_atof_c( psz_value );
}
else if( !strcasecmp( psz_name, "METADATA_BLOCK_PICTURE" ) )
{ /* Do nothing, for now */ }
=====================================
modules/codec/webvtt/CSSLexer.l
=====================================
@@ -32,10 +32,10 @@
# include "config.h"
#endif
#include <vlc_common.h>
+#include <vlc_charset.h>
#include "css_parser.h"
#include "CSSGrammar.h"
#define VAL(a, b) { yylval->term.val = (a); yylval->term.type = TYPE_ ## b; }
-#define us_strtof strtof
char *d;
%}
@@ -79,24 +79,24 @@ range \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
"!{w}important" {return IMPORTANT_SYM;}
-{num}em { VAL( us_strtof(yytext, &d), EMS ); return LENGTH;}
+{num}em { VAL( vlc_strtof_c(yytext, &d), EMS ); return LENGTH;}
{num}ex { VAL( atoi(yytext), EXS ); return LENGTH;}
{num}px { VAL( atoi(yytext), PIXELS ); return LENGTH;}
-{num}cm { VAL( us_strtof(yytext, &d) * 10, MILLIMETERS ); return LENGTH;}
+{num}cm { VAL( vlc_strtof_c(yytext, &d) * 10, MILLIMETERS ); return LENGTH;}
{num}mm { VAL( atoi(yytext), MILLIMETERS ); return LENGTH;}
-{num}in { VAL( us_strtof(yytext, &d) * 25.4, MILLIMETERS ); return LENGTH;}
-{num}pt { VAL( us_strtof(yytext, &d), POINTS ); return LENGTH;}
-{num}pc { VAL( us_strtof(yytext, &d), POINTS ); return LENGTH;}
-{num}deg { VAL( us_strtof(yytext, &d), DEGREES ); return ANGLE;}
-{num}rad { VAL( us_strtof(yytext, &d) * 0.0174533, DEGREES ); return ANGLE;}
-{num}grad { VAL( us_strtof(yytext, &d) * 1.1111111, DEGREES ); return ANGLE;}
+{num}in { VAL( vlc_strtof_c(yytext, &d) * 25.4, MILLIMETERS ); return LENGTH;}
+{num}pt { VAL( vlc_strtof_c(yytext, &d), POINTS ); return LENGTH;}
+{num}pc { VAL( vlc_strtof_c(yytext, &d), POINTS ); return LENGTH;}
+{num}deg { VAL( vlc_strtof_c(yytext, &d), DEGREES ); return ANGLE;}
+{num}rad { VAL( vlc_strtof_c(yytext, &d) * 0.0174533, DEGREES ); return ANGLE;}
+{num}grad { VAL( vlc_strtof_c(yytext, &d) * 1.1111111, DEGREES ); return ANGLE;}
{num}ms { VAL( atoi(yytext), MILLISECONDS ); return TIME;}
{num}s { VAL( atoi(yytext) * 1000, MILLISECONDS ); return TIME;}
{num}Hz { VAL( atoi(yytext), HERTZ ); return FREQ;}
{num}kHz { VAL( atoi(yytext) * 1000, HERTZ ); return FREQ;}
{num}{ident} { VAL( 0, DIMENSION ); return DIMEN;}
{num}% { VAL( atoi(yytext), PERCENT ); return PERCENTAGE;}
-{num} { VAL( us_strtof(yytext, &d), NONE ); return NUMBER;}
+{num} { VAL( vlc_strtof_c(yytext, &d), NONE ); return NUMBER;}
"url("{w}{string}{w}")" { yylval->string = vlc_css_unquotedunescaped(yytext); return URI;}
"url("{w}{url}{w}")" { yylval->string = vlc_css_unquotedunescaped(yytext); return URI;}
=====================================
modules/codec/webvtt/encvtt.c
=====================================
@@ -183,7 +183,7 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_spu )
if( bo_size( &box ) != i_start + 8 )
bo_add_8( &box, ' ' );
char *psz;
- int i_printed = us_asprintf( &psz, "line:%2.2f%%", offset );
+ int i_printed = vlc_asprintf_c( &psz, "line:%2.2f%%", offset );
if( i_printed >= 0 )
{
if( i_printed > 0 )
=====================================
modules/codec/webvtt/subsvtt.c
=====================================
@@ -174,7 +174,7 @@ typedef struct
static bool parse_percent( const char *psz, float *value )
{
char *psz_end;
- float d = us_strtof( psz, &psz_end );
+ float d = vlc_strtof_c( psz, &psz_end );
if( d >= 0.0 && d <= 100.0 && *psz_end == '%' )
*value = d / 100.0;
return psz_end != psz;
@@ -183,14 +183,14 @@ static bool parse_percent( const char *psz, float *value )
static bool parse_percent_tuple( const char *psz, float *x, float *y )
{
char *psz_end;
- float a = us_strtof( psz, &psz_end );
+ float a = vlc_strtof_c( psz, &psz_end );
if( psz_end != psz &&
a >= 0.0 && a <= 100.0 && psz_end && *psz_end == '%' )
{
psz = strchr( psz_end, ',' );
if( psz )
{
- float b = us_strtof( ++psz, &psz_end );
+ float b = vlc_strtof_c( ++psz, &psz_end );
if( psz_end != psz &&
b >= 0.0 && b <= 100.0 && psz_end && *psz_end == '%' )
{
@@ -307,7 +307,7 @@ static void webvtt_cue_settings_ParseTuple( webvtt_cue_settings_t *p_settings,
p_settings->b_snap_to_lines = false;
}
else
- p_settings->line.value = us_strtof( psz_value, NULL );
+ p_settings->line.value = vlc_strtof_c( psz_value, NULL );
/* else auto */
const char *psz_align = strchr( psz_value, ',' );
=====================================
modules/codec/x264.c
=====================================
@@ -1008,11 +1008,11 @@ static int Open ( vlc_object_t *p_this )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "psy-rd" );
if( psz_val )
{
- if( us_atof( psz_val ) != 1.0 )
+ if( vlc_atof_c( psz_val ) != 1.0 )
{
char *p = strchr( psz_val, ':' );
- p_sys->param.analyse.f_psy_rd = us_atof( psz_val );
- p_sys->param.analyse.f_psy_trellis = p ? us_atof( p+1 ) : 0;
+ p_sys->param.analyse.f_psy_rd = vlc_atof_c( psz_val );
+ p_sys->param.analyse.f_psy_trellis = p ? vlc_atof_c( p+1 ) : 0;
}
free( psz_val );
}
@@ -1023,8 +1023,8 @@ static int Open ( vlc_object_t *p_this )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "level" );
if( psz_val )
{
- if( us_atof (psz_val) < 6 && us_atof (psz_val) > 0 )
- p_sys->param.i_level_idc = (int) (10 * us_atof (psz_val)
+ if( vlc_atof_c(psz_val) < 6 && vlc_atof_c(psz_val) > 0 )
+ p_sys->param.i_level_idc = (int) (10 * vlc_atof_c(psz_val)
+ .5);
else if( atoi(psz_val) >= 10 && atoi(psz_val) <= 51 )
p_sys->param.i_level_idc = atoi (psz_val);
=====================================
modules/demux/adaptive/tools/Conversions.cpp
=====================================
@@ -47,7 +47,7 @@ static vlc_tick_t str_duration( const char *psz_duration )
return -1;
do
{
- double number = us_strtod( psz_duration, &end_ptr );
+ double number = vlc_strtod_c( psz_duration, &end_ptr );
double mul = 0;
if ( psz_duration != end_ptr )
psz_duration = end_ptr;
=====================================
modules/demux/mp4/mp4.c
=====================================
@@ -3040,14 +3040,14 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
const char *psz_meta = vlc_meta_GetExtra( p_sys->p_meta, "replaygain_track_gain" );
if( psz_meta )
{
- double f_gain = us_atof( psz_meta );
+ double f_gain = vlc_atof_c( psz_meta );
p_arg->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = f_gain;
p_arg->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = f_gain != 0;
}
psz_meta = vlc_meta_GetExtra( p_sys->p_meta, "replaygain_track_peak" );
if( psz_meta )
{
- double f_gain = us_atof( psz_meta );
+ double f_gain = vlc_atof_c( psz_meta );
p_arg->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = f_gain;
p_arg->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = f_gain > 0;
}
=====================================
modules/demux/mpeg/es.c
=====================================
@@ -1095,7 +1095,7 @@ static int ID3TAG_Parse_Handler( uint32_t i_tag, const uint8_t *p_payload, size_
{
const char *psz_val = vlc_meta_GetExtra( p_meta, ppsz_keys[i] );
if( psz_val )
- *pf = us_atof( psz_val );
+ *pf = vlc_atof_c( psz_val );
}
free( ppsz_keys[i] );
}
=====================================
modules/demux/playlist/m3u.c
=====================================
@@ -532,7 +532,7 @@ static void parseEXTINF( char *psz_string,
/* Parse duration */
char *psz_end = NULL;
- float i_parsed_duration = us_strtof( psz_string, &psz_end );
+ float i_parsed_duration = vlc_strtof_c( psz_string, &psz_end );
if( i_parsed_duration > 0 )
meta->i_duration = vlc_tick_from_sec( (double)i_parsed_duration );
=====================================
modules/demux/subtitle.c
=====================================
@@ -1013,7 +1013,7 @@ static int ParseMicroDvd( vlc_object_t *p_obj, subs_properties_t *p_props,
/* We found a possible setting of the framerate "{1}{1}23.976" */
/* Check if it's usable, and if the sub-original-fps is not set */
- float f_fps = us_strtof( psz_text, NULL );
+ float f_fps = vlc_strtof_c( psz_text, NULL );
if( f_fps > 0.f && var_GetFloat( p_obj, "sub-original-fps" ) <= 0.f )
p_props->i_microsecperframe = llroundf((float)CLOCK_FREQ / f_fps);
}
@@ -1740,7 +1740,7 @@ static int ParseMPSub( vlc_object_t *p_obj, subs_properties_t *p_props,
if( sscanf( s, "FORMAT=%[^\r\n]", psz_temp ) )
{
- float f_fps = us_strtof( psz_temp, NULL );
+ float f_fps = vlc_strtof_c( psz_temp, NULL );
if( f_fps > 0.f && var_GetFloat( p_obj, "sub-original-fps" ) <= 0.f )
var_SetFloat( p_obj, "sub-original-fps", f_fps );
@@ -1753,10 +1753,10 @@ static int ParseMPSub( vlc_object_t *p_obj, subs_properties_t *p_props,
}
/* Data Lines */
- float f1 = us_strtof( s, &psz_temp );
+ float f1 = vlc_strtof_c( s, &psz_temp );
if( *psz_temp )
{
- float f2 = us_strtof( psz_temp, NULL );
+ float f2 = vlc_strtof_c( psz_temp, NULL );
p_props->mpsub.f_total += f1 * p_props->mpsub.i_factor;
p_subtitle->i_start = llroundf(10000.f * p_props->mpsub.f_total);
p_props->mpsub.f_total += f2 * p_props->mpsub.i_factor;
=====================================
modules/demux/xiph_metadata.c
=====================================
@@ -494,19 +494,19 @@ void vorbis_ParseComment( es_format_t *p_fmt, vlc_meta_t **pp_meta,
if (!p) goto next_comment;
if ( !strncasecmp(psz_comment, "REPLAYGAIN_TRACK_GAIN=", 22) )
{
- (*ppf_replay_gain)[AUDIO_REPLAY_GAIN_TRACK] = us_atof( ++p );
+ (*ppf_replay_gain)[AUDIO_REPLAY_GAIN_TRACK] = vlc_atof_c( ++p );
}
else if ( !strncasecmp(psz_comment, "REPLAYGAIN_ALBUM_GAIN=", 22) )
{
- (*ppf_replay_gain)[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( ++p );
+ (*ppf_replay_gain)[AUDIO_REPLAY_GAIN_ALBUM] = vlc_atof_c( ++p );
}
else if ( !strncasecmp(psz_comment, "REPLAYGAIN_ALBUM_PEAK=", 22) )
{
- (*ppf_replay_peak)[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( ++p );
+ (*ppf_replay_peak)[AUDIO_REPLAY_GAIN_ALBUM] = vlc_atof_c( ++p );
}
else if ( !strncasecmp(psz_comment, "REPLAYGAIN_TRACK_PEAK=", 22) )
{
- (*ppf_replay_peak)[AUDIO_REPLAY_GAIN_TRACK] = us_atof( ++p );
+ (*ppf_replay_peak)[AUDIO_REPLAY_GAIN_TRACK] = vlc_atof_c( ++p );
}
}
else if( !strncasecmp(psz_comment, "CHAPTER", 7) )
=====================================
src/check_symbols
=====================================
@@ -21,7 +21,7 @@ cat libvlccore.sym | grep -v \
-e '^net_' -e '^httpd_' \
-e '^config_' -e '^module_' -e '^var_' \
-e '^date_' -e '^plane_' \
- -e '^us_' -e '^utf8_' -e '^xml_' \
+ -e '^utf8_' -e '^xml_' \
-e '^[A-Z][a-z]*Charset$' \
-e '^NTPtime64$' \
&& exit 1
=====================================
src/config/chain.c
=====================================
@@ -396,7 +396,7 @@ void config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
NULL, 0 );
break;
case CONFIG_ITEM_FLOAT:
- val.f_float = us_atof( cfg->psz_value ? cfg->psz_value : "0" );
+ val.f_float = vlc_atof_c( cfg->psz_value ? cfg->psz_value : "0" );
break;
case CONFIG_ITEM_STRING:
val.psz_string = cfg->psz_value;
=====================================
src/config/cmdline.c
=====================================
@@ -311,7 +311,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
var_Change( p_this, psz_name, VLC_VAR_SETMINMAX,
(vlc_value_t){ .f_float = p_conf->min.f },
(vlc_value_t){ .f_float = p_conf->max.f } );
- var_SetFloat( p_this, psz_name, us_atof(state.arg) );
+ var_SetFloat( p_this, psz_name, vlc_atof_c(state.arg) );
break;
case CONFIG_ITEM_BOOL:
var_Create( p_this, psz_name, VLC_VAR_BOOL );
@@ -347,7 +347,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
break;
case CONFIG_ITEM_FLOAT:
var_Create( p_this, name, VLC_VAR_FLOAT );
- var_SetFloat( p_this, name, us_atof(state.arg) );
+ var_SetFloat( p_this, name, vlc_atof_c(state.arg) );
break;
case CONFIG_ITEM_BOOL:
var_Create( p_this, name, VLC_VAR_BOOL );
=====================================
src/input/meta.c
=====================================
@@ -290,26 +290,26 @@ void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
(psz_value = vlc_meta_GetExtra(p_meta, "RG_RADIO")) )
{
p_dst->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
- p_dst->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
+ p_dst->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = vlc_atof_c( psz_value );
}
if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_PEAK" )) ||
(psz_value = vlc_meta_GetExtra(p_meta, "RG_PEAK" )) )
{
p_dst->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
- p_dst->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
+ p_dst->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = vlc_atof_c( psz_value );
}
if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_GAIN" )) ||
(psz_value = vlc_meta_GetExtra(p_meta, "RG_AUDIOPHILE" )) )
{
p_dst->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
- p_dst->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
+ p_dst->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = vlc_atof_c( psz_value );
}
if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_PEAK" )) )
{
p_dst->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
- p_dst->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
+ p_dst->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = vlc_atof_c( psz_value );
}
}
=====================================
src/input/vlmshell.c
=====================================
@@ -436,7 +436,7 @@ static int ExecuteControl( vlm_t *p_vlm, const char *psz_name, const int i_arg,
else
{
/* Percent */
- double d_new_position = us_atof( psz_argument ) / 100.0;
+ double d_new_position = vlc_atof_c( psz_argument ) / 100.0;
if( b_relative )
{
=====================================
src/libvlccore.sym
=====================================
@@ -430,11 +430,10 @@ update_Download
update_GetRelease
update_NeedUpgrade
update_New
-us_asprintf
-us_atof
-us_strtod
-us_strtof
-us_vasprintf
+vlc_asprintf_c
+vlc_strtod_c
+vlc_strtof_c
+vlc_vasprintf_c
vlc_close
vlc_fopen
utf8_fprintf
=====================================
src/misc/variables.c
=====================================
@@ -990,7 +990,7 @@ void var_OptionParse( vlc_object_t *p_obj, const char *psz_option,
break;
case VLC_VAR_FLOAT:
- val.f_float = us_atof( psz_value );
+ val.f_float = vlc_atof_c( psz_value );
break;
case VLC_VAR_STRING:
=====================================
src/network/httpd.c
=====================================
@@ -1193,7 +1193,7 @@ void httpd_MsgAdd(httpd_message_t *msg, const char *name, const char *psz_value,
va_list args;
va_start(args, psz_value);
- int ret = us_vasprintf(&h->value, psz_value, args);
+ int ret = vlc_vasprintf_c(&h->value, psz_value, args);
va_end(args);
if (ret == -1) {
=====================================
src/test/i18n_atof.c
=====================================
@@ -1,5 +1,5 @@
/*****************************************************************************
- * i18n_atof.c: Test for us_atof
+ * i18n_atof.c: Test for vlc_atof_c()
*****************************************************************************
* Copyright (C) 2006 Rémi Denis-Courmont
*
@@ -35,22 +35,19 @@ int main (void)
const char sharp9[] = "999999#999999";
char *end;
- assert (us_atof("0") == 0.);
- assert (us_atof("1") == 1.);
- assert (us_atof("1.") == 1.);
- assert (us_atof("1,") == 1.);
- assert (us_atof("1#") == 1.);
- assert (us_atof(dot9) == 999999.999999);
- assert (us_atof(comma9) == 999999.);
- assert (us_atof(sharp9) == 999999.);
- assert (us_atof("invalid") == 0.);
+ assert(vlc_atof_c("0") == 0.);
+ assert(vlc_atof_c("1") == 1.);
+ assert(vlc_atof_c("1.") == 1.);
+ assert(vlc_atof_c("1,") == 1.);
+ assert(vlc_atof_c("1#") == 1.);
+ assert(vlc_atof_c(dot9) == 999999.999999);
+ assert(vlc_atof_c(comma9) == 999999.);
+ assert(vlc_atof_c(sharp9) == 999999.);
+ assert(vlc_atof_c("invalid") == 0.);
- assert ((us_strtod(dot9, &end ) == 999999.999999)
- && (*end == '\0'));
- assert ((us_strtod(comma9, &end ) == 999999.)
- && (*end == ','));
- assert ((us_strtod(sharp9, &end ) == 999999.)
- && (*end == '#'));
+ assert((vlc_strtod_c(dot9, &end ) == 999999.999999) && (*end == '\0'));
+ assert((vlc_strtod_c(comma9, &end ) == 999999.) && (*end == ','));
+ assert((vlc_strtod_c(sharp9, &end ) == 999999.) && (*end == '#'));
return 0;
}
=====================================
src/text/charset.c
=====================================
@@ -43,11 +43,7 @@
#include "libvlc.h"
#include <vlc_charset.h>
-/**
- * us_strtod() has the same prototype as ANSI C strtod() but it uses the
- * POSIX/C decimal format, regardless of the current numeric locale.
- */
-double us_strtod( const char *str, char **end )
+double vlc_strtod_c(const char *restrict str, char **restrict end)
{
locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
locale_t oldloc = uselocale (loc);
@@ -61,12 +57,7 @@ double us_strtod( const char *str, char **end )
return res;
}
-
-/**
- * us_strtof() has the same prototype as ANSI C strtof() but it uses the
- * POSIX/C decimal format, regardless of the current numeric locale.
- */
-float us_strtof( const char *str, char **end )
+float vlc_strtof_c(const char *restrict str, char **restrict end)
{
locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
locale_t oldloc = uselocale (loc);
@@ -80,22 +71,8 @@ float us_strtof( const char *str, char **end )
return res;
}
-
-/**
- * us_atof() has the same prototype as ANSI C atof() but it expects a dot
- * as decimal separator, regardless of the system locale.
- */
-double us_atof( const char *str )
-{
- return us_strtod( str, NULL );
-}
-
-
-/**
- * us_vasprintf() has the same prototype as vasprintf(), but doesn't use
- * the system locale.
- */
-int us_vasprintf( char **ret, const char *format, va_list ap )
+int vlc_vasprintf_c(char **restrict ret, const char *restrict format,
+ va_list ap)
{
locale_t loc = newlocale( LC_NUMERIC_MASK, "C", NULL );
locale_t oldloc = uselocale( loc );
@@ -111,18 +88,13 @@ int us_vasprintf( char **ret, const char *format, va_list ap )
return i_rc;
}
-
-/**
- * us_asprintf() has the same prototype as asprintf(), but doesn't use
- * the system locale.
- */
-int us_asprintf( char **ret, const char *format, ... )
+int vlc_asprintf_c(char **restrict ret, const char *restrict format, ...)
{
va_list ap;
int i_rc;
va_start( ap, format );
- i_rc = us_vasprintf( ret, format, ap );
+ i_rc = vlc_vasprintf_c(ret, format, ap);
va_end( ap );
return i_rc;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5494afa0e9df55cd92982e81e516c2e26e965be8...a11e147d2bcd6f77a1dad1c5c9b655948a7a005a
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5494afa0e9df55cd92982e81e516c2e26e965be8...a11e147d2bcd6f77a1dad1c5c9b655948a7a005a
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list