LCOV - code coverage report
Current view: top level - src - ulong.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 16 16 100.0 %
Date: 2026-07-14 21:28:07 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 6 100.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright 2019-2026 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #include <exess/exess.h>
       5                 :            : 
       6                 :            : #include "number_utils.h"
       7                 :            : #include "read_utils.h"
       8                 :            : #include "result.h"
       9                 :            : #include "write_utils.h"
      10                 :            : 
      11                 :            : #include <stdint.h>
      12                 :            : #include <stdlib.h>
      13                 :            : 
      14                 :            : EXESS_NONBLOCKING EXESS_NONBLOCKING ExessResult
      15                 :      82827 : exess_read_ulong(const char* const str, uint64_t* const out)
      16                 :            : {
      17                 :      82827 :   *out = 0;
      18                 :            : 
      19                 :            :   // Skip leading whitespace and read sign if present
      20                 :      82827 :   size_t i    = skip_whitespace(str);
      21                 :      82827 :   int    sign = 1;
      22                 :      82827 :   i += read_sign(&sign, &str[i]);
      23                 :            : 
      24         [ +  + ]:      82827 :   if (sign == -1) {
      25                 :         10 :     size_t j = i;
      26         [ +  + ]:         13 :     while (str[j] == '0') {
      27                 :          3 :       ++j;
      28                 :            :     }
      29                 :            : 
      30         [ +  + ]:         10 :     return RESULT((j == i) ? EXESS_EXPECTED_ZERO : EXESS_SUCCESS, j);
      31                 :            :   }
      32                 :            : 
      33                 :      82817 :   ExessResult r = read_digits(out, str + i);
      34                 :            : 
      35                 :      82817 :   r.count += i;
      36                 :      82817 :   return r;
      37                 :            : }
      38                 :            : 
      39                 :            : EXESS_NONBLOCKING EXESS_NONBLOCKING ExessResult
      40                 :      82869 : exess_write_ulong(const uint64_t value, const size_t buf_size, char* const buf)
      41                 :            : {
      42                 :      82869 :   const ExessResult r = write_digits(value, buf_size, buf, 0);
      43                 :      82869 :   return end_write(r.status, buf_size, buf, r.count);
      44                 :            : }

Generated by: LCOV version 1.16