LCOV - code coverage report
Current view: top level - src - utils.c (source / functions) Hit Total Coverage
Test: report.info Lines: 16 18 88.9 %
Date: 2024-01-02 12:43:31 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include "utils.h"
       2             : 
       3           8 : char *trim(char *str)
       4             : {
       5             :     char *end;
       6             : 
       7             :     // Trim leading whitespace
       8           8 :     while (isspace((unsigned char)*str))
       9           0 :         str++;
      10             : 
      11           8 :     if (*str == 0) // Only whitespace
      12           0 :         return str;
      13             : 
      14             :     // Trim trailing whitespace
      15           8 :     end = str + strlen(str) - 1;
      16          12 :     while (end > str && isspace((unsigned char)*end))
      17           4 :         end--;
      18             : 
      19             :     // Write new null terminator
      20           8 :     *(end + 1) = 0;
      21             : 
      22           8 :     return str;
      23             : }
      24             : 
      25          33 : void handle_quotes(char *token)
      26             : {
      27          33 :     char quote_type = token[0];
      28          33 :     if (quote_type == '"' || quote_type == '\'')
      29             :     {
      30          10 :         char *end_quote = strchr(&token[1], quote_type);
      31             : 
      32          10 :         if (end_quote != NULL)
      33             :         {
      34           5 :             *end_quote = '\0';                        // Remove the end quotation mark
      35           5 :             memmove(token, token + 1, strlen(token)); // Remove the start quotation mark
      36             :         }
      37             :     }
      38          33 : }

Generated by: LCOV version 1.14