Diff for /libelwix/src/json.c between versions 1.12.2.1 and 1.12.2.2

version 1.12.2.1, 2025/08/25 10:05:52 version 1.12.2.2, 2025/08/25 12:44:59
Line 1421  json_validate(const char *jstr, int *started) Line 1421  json_validate(const char *jstr, int *started)
 {  {
         register int o = 0, a = 0, q = 0, pos = 0;          register int o = 0, a = 0, q = 0, pos = 0;
   
           if (!jstr)
                   return -1;
   
         if (started)          if (started)
                 *started = 0;                  *started = 0;
   
Line 1458  json_validate(const char *jstr, int *started) Line 1461  json_validate(const char *jstr, int *started)
         } while (q || a || o);          } while (q || a || o);
   
         return pos;          return pos;
   }
   
   /*
    * json_marshaling() - Prepare JSON to one continues line
    *
    * @jstr = JSON string
    * @space = if it is 0 then spaces will be removed
    * return NULL error or !=NULL ready JSON for proceeding
    */
   char *
   json_marshaling(char * __restrict jstr, int space)
   {
           int started, ended, len;
           char *str, *pos, *js;
           register int q = 0;
   
           if (!jstr)
                   return NULL;
           else
                   js = jstr;
   
           ended = json_validate(jstr, &started);
           if (!ended)
                   return NULL;
           len = ended - started + 1;
           str = e_malloc(len);
           if (!str)
                   return NULL;
           else {
                   memset(str, 0, len);
                   pos = str;
           }
   
           js += started;
           while (*js && js < jstr + ended && --len) {
                   if (*js < 0x20) {
                           js++;
                           continue;
                   }
                   if (space && !q && *js == 0x20) {
                           js++;
                           continue;
                   }
                   if (*js == '"')
                           q = ~q;
                   *pos++ = *js++;
           }
           *pos = 0;
   
           len = strlen(jstr) + 1;
           strlcpy(jstr, str, len);
           e_free(str);
           return jstr;
 }  }

Removed from v.1.12.2.1  
changed lines
  Added in v.1.12.2.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>