Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
semver.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "semver.h"
+ Include dependency graph for semver.c:

Go to the source code of this file.

Macros

#define SLICE_SIZE   50
 
#define DELIMITER   "."
 
#define PR_DELIMITER   "-"
 
#define MT_DELIMITER   "+"
 
#define NUMBERS   "0123456789"
 
#define ALPHA   "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
#define DELIMITERS   DELIMITER PR_DELIMITER MT_DELIMITER
 
#define VALID_CHARS   NUMBERS ALPHA DELIMITERS
 

Enumerations

enum  operators {
  SYMBOL_GT = 0x3e , SYMBOL_LT = 0x3c , SYMBOL_EQ = 0x3d , SYMBOL_TF = 0x7e ,
  SYMBOL_CF = 0x5e
}
 

Functions

static int strcut (char *str, int begin, int len)
 
static int contains (const char c, const char *matrix, size_t len)
 
static int has_valid_chars (const char *str, const char *matrix)
 
static int binary_comparison (int x, int y)
 
static int parse_int (const char *s)
 
static char * parse_slice (char *buf, char sep)
 
int semver_parse (const char *str, semver_t *ver)
 
int semver_parse_version (const char *str, semver_t *ver)
 
static int compare_prerelease (char *x, char *y)
 
int semver_compare_prerelease (semver_t x, semver_t y)
 
int semver_compare_version (semver_t x, semver_t y)
 
int semver_compare (semver_t x, semver_t y)
 
int semver_gt (semver_t x, semver_t y)
 
int semver_lt (semver_t x, semver_t y)
 
int semver_eq (semver_t x, semver_t y)
 
int semver_neq (semver_t x, semver_t y)
 
int semver_gte (semver_t x, semver_t y)
 
int semver_lte (semver_t x, semver_t y)
 
int semver_satisfies_caret (semver_t x, semver_t y)
 
int semver_satisfies_patch (semver_t x, semver_t y)
 
int semver_satisfies (semver_t x, semver_t y, const char *op)
 
void semver_free (semver_t *x)
 
static void concat_num (char *str, int x, char *sep)
 
static void concat_char (char *str, char *x, char *sep)
 
void semver_render (semver_t *x, char *dest)
 
void semver_bump (semver_t *x)
 
void semver_bump_minor (semver_t *x)
 
void semver_bump_patch (semver_t *x)
 
static int has_valid_length (const char *s)
 
int semver_is_valid (const char *s)
 
int semver_clean (char *s)
 
static int char_to_int (const char *str)
 
int semver_numeric (semver_t *x)
 
char * semver_strdup (const char *src)
 
semver_t semver_copy (const semver_t *ver)
 

Variables

static const size_t MAX_SIZE = sizeof(char) * 255
 
static const int MAX_SAFE_INT = (unsigned int) -1 >> 1
 

Macro Definition Documentation

◆ ALPHA

#define ALPHA   "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

◆ DELIMITER

#define DELIMITER   "."

◆ DELIMITERS

#define DELIMITERS   DELIMITER PR_DELIMITER MT_DELIMITER

◆ MT_DELIMITER

#define MT_DELIMITER   "+"

◆ NUMBERS

#define NUMBERS   "0123456789"

◆ PR_DELIMITER

#define PR_DELIMITER   "-"

◆ SLICE_SIZE

#define SLICE_SIZE   50

◆ VALID_CHARS

#define VALID_CHARS   NUMBERS ALPHA DELIMITERS

Enumeration Type Documentation

◆ operators

enum operators

Define comparison operators, storing the ASCII code per each symbol in hexadecimal notation.

Enumerator
SYMBOL_GT 
SYMBOL_LT 
SYMBOL_EQ 
SYMBOL_TF 
SYMBOL_CF 
34 {
35 SYMBOL_GT = 0x3e,
36 SYMBOL_LT = 0x3c,
37 SYMBOL_EQ = 0x3d,
38 SYMBOL_TF = 0x7e,
39 SYMBOL_CF = 0x5e
40};
@ SYMBOL_TF
Definition semver.c:38
@ SYMBOL_CF
Definition semver.c:39
@ SYMBOL_GT
Definition semver.c:35
@ SYMBOL_EQ
Definition semver.c:37
@ SYMBOL_LT
Definition semver.c:36

Function Documentation

◆ binary_comparison()

static int binary_comparison ( int  x,
int  y 
)
static
86 {
87 if (x == y) return 0;
88 if (x > y) return 1;
89 return -1;
90}

Referenced by semver_compare_version().

+ Here is the caller graph for this function:

◆ char_to_int()

static int char_to_int ( const char *  str)
static
590 {
591 int buf;
592 size_t i,len, mlen;
593 buf = 0;
594 len = strlen(str);
595 mlen = strlen(VALID_CHARS);
596
597 for (i = 0; i < len; i++)
598 if (contains(str[i], VALID_CHARS, mlen))
599 buf += (int) str[i];
600
601 return buf;
602}
#define VALID_CHARS
Definition semver.c:20
static int contains(const char c, const char *matrix, size_t len)
Definition semver.c:65

References contains(), and VALID_CHARS.

Referenced by semver_numeric().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_prerelease()

static int compare_prerelease ( char *  x,
char *  y 
)
static
215 {
216 char *lastx, *lasty, *xptr, *yptr, *endptr;
217 size_t xlen, ylen, xn, yn, min;
218 int xisnum, yisnum, xnum, ynum;
219 int res;
220 if (x == NULL && y == NULL) return 0;
221 if (y == NULL && x) return -1;
222 if (x == NULL && y) return 1;
223
224 lastx = x;
225 lasty = y;
226 xlen = strlen(x);
227 ylen = strlen(y);
228
229 while (1) {
230 if ((xptr = strchr(lastx, DELIMITER[0])) == NULL)
231 xptr = x + xlen;
232 if ((yptr = strchr(lasty, DELIMITER[0])) == NULL)
233 yptr = y + ylen;
234
235 xnum = strtol(lastx, &endptr, 10);
236 xisnum = endptr == xptr ? 1 : 0;
237 ynum = strtol(lasty, &endptr, 10);
238 yisnum = endptr == yptr ? 1 : 0;
239
240 if (xisnum && !yisnum) return -1;
241 if (!xisnum && yisnum) return 1;
242
243 if (xisnum && yisnum) {
244 /* Numerical comparison */
245 if (xnum != ynum) return xnum < ynum ? -1 : 1;
246 } else {
247 /* String comparison */
248 xn = xptr - lastx;
249 yn = yptr - lasty;
250 min = xn < yn ? xn : yn;
251 if ((res = strncmp(lastx, lasty, min))) return res < 0 ? -1 : 1;
252 if (xn != yn) return xn < yn ? -1 : 1;
253 }
254
255 lastx = xptr + 1;
256 lasty = yptr + 1;
257 if (lastx == x + xlen + 1 && lasty == y + ylen + 1) break;
258 if (lastx == x + xlen + 1) return -1;
259 if (lasty == y + ylen + 1) return 1;
260 }
261
262 return 0;
263}
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() min(const half &a, const half &b)
Definition Half.h:507
const Scalar & y
Definition MathFunctions.h:552
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297
#define DELIMITER
Definition semver.c:14

References DELIMITER.

Referenced by semver_compare_prerelease().

+ Here is the caller graph for this function:

◆ concat_char()

static void concat_char ( char *  str,
char *  x,
char *  sep 
)
static
498 {
499 char buf[SLICE_SIZE] = {0};
500 sprintf(buf, "%s%s", sep, x);
501 strcat(str, buf);
502}
#define SLICE_SIZE
Definition semver.c:13

References SLICE_SIZE.

Referenced by semver_render().

+ Here is the caller graph for this function:

◆ concat_num()

static void concat_num ( char *  str,
int  x,
char *  sep 
)
static

Renders

490 {
491 char buf[SLICE_SIZE] = {0};
492 if (sep == NULL) sprintf(buf, "%d", x);
493 else sprintf(buf, "%s%d", sep, x);
494 strcat(str, buf);
495}

References SLICE_SIZE.

Referenced by semver_numeric(), and semver_render().

+ Here is the caller graph for this function:

◆ contains()

static int contains ( const char  c,
const char *  matrix,
size_t  len 
)
static
65 {
66 size_t x;
67 for (x = 0; x < len; x++)
68 if ((char) matrix[x] == c) return 1;
69 return 0;
70}

Referenced by char_to_int(), Slic3r::FFFTreeSupport::draw_areas(), Slic3r::find_nearby_points(), has_valid_chars(), Slic3r::FFFTreeSupport::move_inside_if_outside(), semver_clean(), and Slic3r::FFFTreeSupport::smooth_branch_areas().

+ Here is the caller graph for this function:

◆ has_valid_chars()

static int has_valid_chars ( const char *  str,
const char *  matrix 
)
static
73 {
74 size_t i, len, mlen;
75 len = strlen(str);
76 mlen = strlen(matrix);
77
78 for (i = 0; i < len; i++)
79 if (contains(str[i], matrix, mlen) == 0)
80 return 0;
81
82 return 1;
83}

References contains().

Referenced by parse_int(), and semver_is_valid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has_valid_length()

static int has_valid_length ( const char *  s)
static

Helpers

541 {
542 return strlen(s) <= MAX_SIZE;
543}
static const size_t MAX_SIZE
Definition semver.c:22

References MAX_SIZE.

Referenced by semver_clean(), and semver_is_valid().

+ Here is the caller graph for this function:

◆ parse_int()

static int parse_int ( const char *  s)
static
93 {
94 int valid, num;
95 valid = has_valid_chars(s, NUMBERS);
96 if (valid == 0) return -1;
97
98 num = strtol(s, NULL, 10);
99 if (num > MAX_SAFE_INT) return -1;
100
101 return num;
102}
static int has_valid_chars(const char *str, const char *matrix)
Definition semver.c:73
#define NUMBERS
Definition semver.c:17
static const int MAX_SAFE_INT
Definition semver.c:23

References has_valid_chars(), MAX_SAFE_INT, and NUMBERS.

Referenced by semver_numeric().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_slice()

static char * parse_slice ( char *  buf,
char  sep 
)
static
109 {
110 char *pr, *part;
111 size_t plen;
112
113 /* Find separator in buf */
114 pr = strchr(buf, sep);
115 if (pr == NULL) return NULL;
116 /* Length from separator to end of buf */
117 plen = strlen(pr);
118
119 /* Copy from buf into new string */
120 part = calloc(plen + 1, sizeof(*part));
121 if (part == NULL) return NULL;
122 memcpy(part, pr + 1, plen);
123 /* Null terminate new string */
124 part[plen] = '\0';
125
126 /* Terminate buf where separator was */
127 *pr = '\0';
128
129 return part;
130}

Referenced by semver_parse().

+ Here is the caller graph for this function:

◆ semver_bump()

void semver_bump ( semver_t x)

Version bump helpers

522 {
523 x->major++;
524}

◆ semver_bump_minor()

void semver_bump_minor ( semver_t x)
527 {
528 x->minor++;
529}

◆ semver_bump_patch()

void semver_bump_patch ( semver_t x)
532 {
533 x->patch++;
534}

◆ semver_clean()

int semver_clean ( char *  s)

Removes non-valid characters in the given string.

Returns:

0 - Valid -1 - Invalid input

570 {
571 size_t i, len, mlen;
572 int res;
573 if (has_valid_length(s) == 0) return -1;
574
575 len = strlen(s);
576 mlen = strlen(VALID_CHARS);
577
578 for (i = 0; i < len; i++) {
579 if (contains(s[i], VALID_CHARS, mlen) == 0) {
580 res = strcut(s, (int)i, 1);
581 if(res == -1) return -1;
582 --len; --i;
583 }
584 }
585
586 return 0;
587}
static int strcut(char *str, int begin, int len)
Definition semver.c:51
static int has_valid_length(const char *s)
Definition semver.c:541

References contains(), has_valid_length(), strcut(), and VALID_CHARS.

+ Here is the call graph for this function:

◆ semver_compare()

int semver_compare ( semver_t  x,
semver_t  y 
)

Compare two semantic versions (x, y).

Returns:

  • 1 if x is higher than y
  • 0 if x is equal to y
  • -1 if x is lower than y
304 {
305 int res;
306
307 if ((res = semver_compare_version(x, y)) == 0) {
308 return semver_compare_prerelease(x, y);
309 }
310
311 return res;
312}
int semver_compare_prerelease(semver_t x, semver_t y)
Definition semver.c:266
int semver_compare_version(semver_t x, semver_t y)
Definition semver.c:282

References semver_compare_prerelease(), and semver_compare_version().

Referenced by semver_eq(), semver_gt(), semver_gte(), semver_lt(), semver_lte(), and semver_neq().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_compare_prerelease()

int semver_compare_prerelease ( semver_t  x,
semver_t  y 
)
266 {
267 return compare_prerelease(x.prerelease, y.prerelease);
268}
static int compare_prerelease(char *x, char *y)
Definition semver.c:215

References compare_prerelease().

Referenced by semver_compare().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_compare_version()

int semver_compare_version ( semver_t  x,
semver_t  y 
)

Performs a major, minor and patch binary comparison (x, y). This function is mostly used internally

Returns:

0 - If versiona are equal 1 - If x is higher than y -1 - If x is lower than y

282 {
283 int res;
284
285 if ((res = binary_comparison(x.major, y.major)) == 0) {
286 if ((res = binary_comparison(x.minor, y.minor)) == 0) {
287 return binary_comparison(x.patch, y.patch);
288 }
289 }
290
291 return res;
292}
static int binary_comparison(int x, int y)
Definition semver.c:86

References binary_comparison().

Referenced by semver_compare().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_copy()

semver_t semver_copy ( const semver_t ver)
636 {
637 semver_t res = *ver;
638 if (ver->metadata != NULL) {
639 res.metadata = strdup(ver->metadata);
640 }
641 if (ver->prerelease != NULL) {
642 res.prerelease = strdup(ver->prerelease);
643 }
644 return res;
645}
char * metadata
Definition semver.h:27
char * prerelease
Definition semver.h:28
Definition semver.h:23

References semver_version_s::metadata, and semver_version_s::prerelease.

Referenced by Slic3r::Semver::operator=().

+ Here is the caller graph for this function:

◆ semver_eq()

int semver_eq ( semver_t  x,
semver_t  y 
)

Performs a equality comparison

337 {
338 return semver_compare(x, y) == 0;
339}
int semver_compare(semver_t x, semver_t y)
Definition semver.c:304

References semver_compare().

Referenced by semver_satisfies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_free()

void semver_free ( semver_t x)

Free heep allocated memory of a given semver. This is just a convenient function that you should call when you're done.

474 {
475 if (x->metadata) {
476 free(x->metadata);
477 x->metadata = NULL;
478 }
479 if (x->prerelease) {
480 free(x->prerelease);
481 x->prerelease = NULL;
482 }
483}
void free(void *)

References free().

Referenced by Slic3r::Semver::~Semver(), Slic3r::Semver::operator=(), and Slic3r::Semver::operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_gt()

int semver_gt ( semver_t  x,
semver_t  y 
)

Performs a greater than comparison

319 {
320 return semver_compare(x, y) == 1;
321}

References semver_compare().

Referenced by semver_satisfies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_gte()

int semver_gte ( semver_t  x,
semver_t  y 
)

Performs a greater than or equal comparison

355 {
356 return semver_compare(x, y) >= 0;
357}

References semver_compare().

Referenced by semver_satisfies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_is_valid()

int semver_is_valid ( const char *  s)

Checks if a given semver string is valid

Returns:

1 - Valid expression 0 - Invalid

555 {
556 return has_valid_length(s)
558}

References has_valid_chars(), has_valid_length(), and VALID_CHARS.

Referenced by semver_parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_lt()

int semver_lt ( semver_t  x,
semver_t  y 
)

Performs a lower than comparison

328 {
329 return semver_compare(x, y) == -1;
330}

References semver_compare().

Referenced by semver_satisfies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_lte()

int semver_lte ( semver_t  x,
semver_t  y 
)

Performs a lower than or equal comparison

364 {
365 return semver_compare(x, y) <= 0;
366}

References semver_compare().

Referenced by semver_satisfies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_neq()

int semver_neq ( semver_t  x,
semver_t  y 
)

Performs a non equal to comparison

346 {
347 return semver_compare(x, y) != 0;
348}

References semver_compare().

+ Here is the call graph for this function:

◆ semver_numeric()

int semver_numeric ( semver_t x)

Render a given semver as numeric value. Useful for ordering and filtering.

610 {
611 int num;
612 char buf[SLICE_SIZE * 3];
613 memset(&buf, 0, SLICE_SIZE * 3);
614
615 if (x->major) concat_num(buf, x->major, NULL);
616 if (x->minor) concat_num(buf, x->minor, NULL);
617 if (x->patch) concat_num(buf, x->patch, NULL);
618
619 num = parse_int(buf);
620 if(num == -1) return -1;
621
622 if (x->prerelease) num += char_to_int(x->prerelease);
623 if (x->metadata) num += char_to_int(x->metadata);
624
625 return num;
626}
static int parse_int(const char *s)
Definition semver.c:93
static void concat_num(char *str, int x, char *sep)
Definition semver.c:490
static int char_to_int(const char *str)
Definition semver.c:590

References char_to_int(), concat_num(), parse_int(), and SLICE_SIZE.

+ Here is the call graph for this function:

◆ semver_parse()

int semver_parse ( const char *  str,
semver_t ver 
)

Parses a string as semver expression.

Returns:

0 - Parsed successfully -1 - In case of error

142 {
143 int valid, res;
144 size_t len;
145 char *buf;
146 valid = semver_is_valid(str);
147 if (!valid) return -1;
148
149 len = strlen(str);
150 buf = calloc(len + 1, sizeof(*buf));
151 if (buf == NULL) return -1;
152 strcpy(buf, str);
153
154 ver->metadata = parse_slice(buf, MT_DELIMITER[0]);
155 ver->prerelease = parse_slice(buf, PR_DELIMITER[0]);
156
157 res = semver_parse_version(buf, ver);
158 free(buf);
159#if DEBUG > 0
160 printf("[debug] semver.c %s = %d.%d.%d, %s %s\n", str, ver->major, ver->minor, ver->patch, ver->prerelease, ver->metadata);
161#endif
162 return res;
163}
static char * parse_slice(char *buf, char sep)
Definition semver.c:109
#define PR_DELIMITER
Definition semver.c:15
int semver_parse_version(const char *str, semver_t *ver)
Definition semver.c:175
#define MT_DELIMITER
Definition semver.c:16
int semver_is_valid(const char *s)
Definition semver.c:555
int minor
Definition semver.h:25
int patch
Definition semver.h:26
int major
Definition semver.h:24

References free(), semver_version_s::major, semver_version_s::metadata, semver_version_s::minor, MT_DELIMITER, parse_slice(), semver_version_s::patch, PR_DELIMITER, semver_version_s::prerelease, semver_is_valid(), and semver_parse_version().

Referenced by Slic3r::Semver::parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ semver_parse_version()

int semver_parse_version ( const char *  str,
semver_t ver 
)

Parses a given string as semver expression.

Returns:

0 - Parsed successfully -1 - Parse error or invalid

175 {
176 size_t len;
177 int index, value;
178 char *slice, *next, *endptr;
179 slice = (char *) str;
180 index = 0;
181
182 // non mandatory
183 ver->patch = 0;
184
185 while (slice != NULL && index++ < 4) {
186 next = strchr(slice, DELIMITER[0]);
187 if (next == NULL)
188 len = strlen(slice);
189 else
190 len = next - slice;
191 if (len > SLICE_SIZE) return -1;
192
193 /* Cast to integer and store */
194 value = strtol(slice, &endptr, 10);
195 if (endptr != next && *endptr != '\0') return -1;
196
197 switch (index) {
198 case 1: ver->major = value; break;
199 case 2: ver->minor = value; break;
200 case 3: ver->patch = value; break;
201 }
202
203 /* Continue with the next slice */
204 if (next == NULL)
205 slice = NULL;
206 else
207 slice = next + 1;
208 }
209
210 // Major and minor versions are mandatory, patch version is not mandatory.
211 return (index == 2 || index == 3) ? 0 : -1;
212}
IGL_INLINE void slice(const Eigen::SparseMatrix< TX > &X, const Eigen::Matrix< int, Eigen::Dynamic, 1 > &R, const Eigen::Matrix< int, Eigen::Dynamic, 1 > &C, Eigen::SparseMatrix< TY > &Y)
Definition slice.cpp:15

References DELIMITER, semver_version_s::major, semver_version_s::minor, semver_version_s::patch, and SLICE_SIZE.

Referenced by semver_parse().

+ Here is the caller graph for this function:

◆ semver_render()

void semver_render ( semver_t x,
char *  dest 
)

Render a given semver as string

509 {
510 if (x->major) concat_num(dest, x->major, NULL);
511 if (x->minor) concat_num(dest, x->minor, DELIMITER);
512 if (x->patch) concat_num(dest, x->patch, DELIMITER);
513 if (x->prerelease) concat_char(dest, x->prerelease, PR_DELIMITER);
514 if (x->metadata) concat_char(dest, x->metadata, MT_DELIMITER);
515}
static void concat_char(char *str, char *x, char *sep)
Definition semver.c:498

References concat_char(), concat_num(), DELIMITER, MT_DELIMITER, and PR_DELIMITER.

+ Here is the call graph for this function:

◆ semver_satisfies()

int semver_satisfies ( semver_t  x,
semver_t  y,
const char *  op 
)

Checks if both versions can be satisfied based on the given comparison operator.

Allowed operators:

Returns:

1 - Can be satisfied 0 - Cannot be satisfied

430 {
431 int first, second;
432 /* Extract the comparison operator */
433 first = op[0];
434 second = op[1];
435
436 /* Caret operator */
437 if (first == SYMBOL_CF)
438 return semver_satisfies_caret(x, y);
439
440 /* Tilde operator */
441 if (first == SYMBOL_TF)
442 return semver_satisfies_patch(x, y);
443
444 /* Strict equality */
445 if (first == SYMBOL_EQ)
446 return semver_eq(x, y);
447
448 /* Greater than or equal comparison */
449 if (first == SYMBOL_GT) {
450 if (second == SYMBOL_EQ) {
451 return semver_gte(x, y);
452 }
453 return semver_gt(x, y);
454 }
455
456 /* Lower than or equal comparison */
457 if (first == SYMBOL_LT) {
458 if (second == SYMBOL_EQ) {
459 return semver_lte(x, y);
460 }
461 return semver_lt(x, y);
462 }
463
464 return 0;
465}
int semver_gte(semver_t x, semver_t y)
Definition semver.c:355
int semver_lt(semver_t x, semver_t y)
Definition semver.c:328
int semver_gt(semver_t x, semver_t y)
Definition semver.c:319
int semver_satisfies_caret(semver_t x, semver_t y)
Definition semver.c:381
int semver_satisfies_patch(semver_t x, semver_t y)
Definition semver.c:404
int semver_lte(semver_t x, semver_t y)
Definition semver.c:364
int semver_eq(semver_t x, semver_t y)
Definition semver.c:337

References semver_eq(), semver_gt(), semver_gte(), semver_lt(), semver_lte(), semver_satisfies_caret(), semver_satisfies_patch(), SYMBOL_CF, SYMBOL_EQ, SYMBOL_GT, SYMBOL_LT, and SYMBOL_TF.

+ Here is the call graph for this function:

◆ semver_satisfies_caret()

int semver_satisfies_caret ( semver_t  x,
semver_t  y 
)

Checks if version x can be satisfied by y performing a comparison with caret operator.

See: https://docs.npmjs.com/misc/semver#caret-ranges-1-2-3-0-2-5-0-0-4

Returns:

1 - Can be satisfied 0 - Cannot be satisfied

381 {
382 if (x.major == y.major) {
383 if (x.major == 0) {
384 return x.minor >= y.minor;
385 }
386 return 1;
387 }
388 return 0;
389}

Referenced by semver_satisfies().

+ Here is the caller graph for this function:

◆ semver_satisfies_patch()

int semver_satisfies_patch ( semver_t  x,
semver_t  y 
)

Checks if version x can be satisfied by y performing a comparison with tilde operator.

See: https://docs.npmjs.com/misc/semver#tilde-ranges-1-2-3-1-2-1

Returns:

1 - Can be satisfied 0 - Cannot be satisfied

404 {
405 return x.major == y.major
406 && x.minor == y.minor;
407}

Referenced by semver_satisfies().

+ Here is the caller graph for this function:

◆ semver_strdup()

char * semver_strdup ( const char *  src)
628 {
629 if (src == NULL) return NULL;
630 size_t len = strlen(src) + 1;
631 char *res = malloc(len);
632 return res != NULL ? (char *) memcpy(res, src, len) : NULL;
633}
void * malloc(YYSIZE_T)

References malloc().

+ Here is the call graph for this function:

◆ strcut()

static int strcut ( char *  str,
int  begin,
int  len 
)
static

Private helpers

51 {
52 size_t l;
53 l = strlen(str);
54
55 if((int)l < 0 || (int)l > MAX_SAFE_INT) return -1;
56
57 if (len < 0) len = (int)l - begin + 1;
58 if (begin + len > (int)l) len = (int)l - begin;
59 memmove(str + begin, str + begin + len, l - len + 1 - begin);
60
61 return len;
62}
S::iterator begin(S &sh, const PathTag &)
Definition geometry_traits.hpp:614

References MAX_SAFE_INT.

Referenced by semver_clean().

+ Here is the caller graph for this function:

Variable Documentation

◆ MAX_SAFE_INT

const int MAX_SAFE_INT = (unsigned int) -1 >> 1
static

Referenced by parse_int(), and strcut().

◆ MAX_SIZE

const size_t MAX_SIZE = sizeof(char) * 255
static

Referenced by has_valid_length().