[vlc-commits] [Git][videolan/vlc][master] 5 commits: charset: fix typo in documentation

Thomas Guillem (@tguillem) gitlab at videolan.org
Thu Oct 26 10:38:28 UTC 2023



Thomas Guillem pushed to branch master at VideoLAN / VLC


Commits:
6af3b461 by Thomas Guillem at 2023-10-26T10:05:58+00:00
charset: fix typo in documentation

- - - - -
5b759337 by Thomas Guillem at 2023-10-26T10:05:58+00:00
charset: add vlc_fprintf_c() and vlc_vfprintf_c()

- - - - -
a41647df by Thomas Guillem at 2023-10-26T10:05:58+00:00
tracer: add double type

- - - - -
a228304b by Thomas Guillem at 2023-10-26T10:05:58+00:00
logger: json: handle double types

- - - - -
6a8aeb53 by Thomas Guillem at 2023-10-26T10:05:58+00:00
clock: trace the clock coefficient

- - - - -


6 changed files:

- include/vlc_charset.h
- include/vlc_tracer.h
- modules/logger/json.c
- src/clock/clock.c
- src/libvlccore.sym
- src/text/charset.c


Changes:

=====================================
include/vlc_charset.h
=====================================
@@ -421,7 +421,7 @@ VLC_API int vlc_vasprintf_c(char **restrict p, const char *restrict fmt,
  * 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
+ * list, just like the standard asprintf() but using the C locale for the
  * formatting of numerals.
  *
  * \param[out] p storage space for a pointer to the heap-allocated formatted
@@ -432,6 +432,35 @@ VLC_API int vlc_vasprintf_c(char **restrict p, const char *restrict fmt,
  */
 VLC_API int vlc_asprintf_c( char **p, const char *fmt, ... ) VLC_USED;
 
+/**
+ * Write a string to the output using the C locale
+ *
+ * This function formats a string from a format string and a variable argument
+ * list, just like the standard vfprintf() but using the C locale for the
+ * formatting of numerals.
+ *
+ * \param f output stream to write the string to
+ * \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_vfprintf_c(FILE *f, const char *fmt, va_list ap);
+
+/**
+ * Write a string to the output using the C locale
+ *
+ * This function formats a string from a format string and a variable argument
+ * list, just like the standard fprintf() but using the C locale for the
+ * formatting of numerals.
+ *
+ * \param f output stream to write the string to
+ * \param fmt format string
+ * \return number of bytes formatted (excluding the nul terminator)
+ *        or -1 on error
+ */
+VLC_API int vlc_fprintf_c(FILE *f, const char *fmt, ...);
+
 int vlc_vsscanf_c(const char *, const char *, va_list) VLC_USED;
 int vlc_sscanf_c(const char*, const char*, ...) VLC_USED
 #ifdef __GNUC__


=====================================
include/vlc_tracer.h
=====================================
@@ -46,12 +46,14 @@
 enum vlc_tracer_value
 {
     VLC_TRACER_INT,
+    VLC_TRACER_DOUBLE,
     VLC_TRACER_STRING
 };
 
 typedef union
 {
     int64_t integer;
+    double double_;
     const char *string;
 } vlc_tracer_value_t;
 
@@ -112,6 +114,15 @@ static inline struct vlc_tracer_entry vlc_tracer_entry_FromInt(const char *key,
     return trace;
 }
 
+static inline struct vlc_tracer_entry vlc_tracer_entry_FromDouble(const char *key, double value)
+{
+    vlc_tracer_value_t tracer_value = {
+        .double_ = value,
+    };
+    struct vlc_tracer_entry trace = { key, tracer_value, VLC_TRACER_DOUBLE };
+    return trace;
+}
+
 static inline struct vlc_tracer_entry vlc_tracer_entry_FromString(const char *key, const char *value)
 {
     vlc_tracer_value_t tracer_value;
@@ -127,6 +138,7 @@ static inline struct vlc_tracer_entry vlc_tracer_entry_FromString(const char *ke
 #define VLC_TRACE(key, value) \
         _Generic((value), \
         int64_t: vlc_tracer_entry_FromInt, \
+        double: vlc_tracer_entry_FromDouble, \
         char *: vlc_tracer_entry_FromString, \
         const char *: vlc_tracer_entry_FromString) (key, value)
 #else


=====================================
modules/logger/json.c
=====================================
@@ -138,6 +138,12 @@ static void JsonPrintKeyValueNumber(FILE *stream, const char *key, int64_t value
     fprintf(stream, ": \"%"PRId64"\"", value);
 }
 
+static void JsonPrintKeyValueNumberFromDouble(FILE *stream, const char *key, double value)
+{
+    JsonPrintString(stream, key);
+    vlc_fprintf_c(stream, ": \"%le\"", value);
+}
+
 static void JsonPrintKeyValueLabel(FILE *stream, const char *key, const char *value)
 {
     JsonPrintString(stream, key);
@@ -178,6 +184,9 @@ static void TraceJson(void *opaque, vlc_tick_t ts, va_list entries)
             case VLC_TRACER_INT:
                 JsonPrintKeyValueNumber(stream, entry.key, entry.value.integer);
                 break;
+            case VLC_TRACER_DOUBLE:
+                JsonPrintKeyValueNumberFromDouble(stream, entry.key, entry.value.double_);
+                break;
             case VLC_TRACER_STRING:
                 JsonPrintKeyValueLabel(stream, entry.key, entry.value.string);
                 break;


=====================================
src/clock/clock.c
=====================================
@@ -201,6 +201,7 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
                              VLC_TRACE("type", "RENDER"),
                              VLC_TRACE("id", clock->track_str_id),
                              VLC_TRACE_TICK_NS("offset", main_clock->offset),
+                             VLC_TRACE("coeff", main_clock->coeff),
                              VLC_TRACE_END);
 
         main_clock->last = clock_point_Create(system_now, ts);


=====================================
src/libvlccore.sym
=====================================
@@ -442,6 +442,8 @@ update_Download
 update_GetRelease
 update_NeedUpgrade
 update_New
+vlc_vfprintf_c
+vlc_fprintf_c
 vlc_asprintf_c
 vlc_strtod_c
 vlc_strtof_c


=====================================
src/text/charset.c
=====================================
@@ -100,6 +100,33 @@ int vlc_asprintf_c(char **restrict ret, const char *restrict format, ...)
     return i_rc;
 }
 
+int vlc_vfprintf_c(FILE *f, const char *format, va_list ap)
+{
+    locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL);
+    locale_t oldloc = uselocale(loc);
+
+    int rc = vfprintf(f, format, ap);
+
+    if (loc != (locale_t)0)
+    {
+        uselocale(oldloc);
+        freelocale(loc);
+    }
+
+    return rc;
+}
+
+int vlc_fprintf_c(FILE *restrict f, const char *restrict format, ...)
+{
+    va_list ap;
+
+    va_start(ap, format);
+    int rc = vlc_vfprintf_c(f, format, ap);
+    va_end(ap);
+
+    return rc;
+}
+
 int vlc_vsscanf_c(const char *restrict buf, const char *restrict format,
                   va_list ap)
 {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5fed85a97f268116c2c8ddfdd11e34fa6c5c3d08...6a8aeb5397f4ce08b9842b1d3f3d5d3156f4b54f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5fed85a97f268116c2c8ddfdd11e34fa6c5c3d08...6a8aeb5397f4ce08b9842b1d3f3d5d3156f4b54f
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