Commit 96bcbb1e authored by Nick Mathewson's avatar Nick Mathewson 🥔
Browse files

Remove code to special-case "-cvs" ending, since it has not actually mattered...

Remove code to special-case "-cvs" ending, since it has not actually mattered since 0.0.9. Perhaps we can special-case even more...

svn:r6898
parent 8d2a71a4
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -2464,9 +2464,6 @@ typedef struct tor_version_t {
   * VER_RELEASE. */
  enum { VER_PRE=0, VER_RC=1, VER_RELEASE=2, } status;
  int patchlevel;
  /** CVS status.  For version in the post-0.1 format, this is always
   * IS_NOT_CVS */
  enum { IS_CVS=0, IS_NOT_CVS=1} cvs;
  char status_tag[MAX_STATUS_TAG_LEN];
} tor_version_t;

+2 −12
Original line number Diff line number Diff line
@@ -1803,7 +1803,7 @@ tor_version_parse(const char *s, tor_version_t *out)
{
  char *eos=NULL, *cp=NULL;
  /* Format is:
   *   "Tor " ? NUM dot NUM dot NUM [ ( pre | rc | dot ) NUM [ -cvs ] ]
   *   "Tor " ? NUM dot NUM dot NUM [ ( pre | rc | dot ) NUM [ - tag ] ]
   */
  tor_assert(s);
  tor_assert(out);
@@ -1829,7 +1829,6 @@ tor_version_parse(const char *s, tor_version_t *out)
  if (!*eos) {
    out->status = VER_RELEASE;
    out->patchlevel = 0;
    out->cvs = IS_NOT_CVS;
    return 0;
  }
  cp = eos;
@@ -1857,11 +1856,6 @@ tor_version_parse(const char *s, tor_version_t *out)
  if (*cp == '-' || *cp == '.')
    ++cp;
  strlcpy(out->status_tag, cp, sizeof(out->status_tag));
  if (0==strcmp(cp, "cvs")) {
    out->cvs = IS_CVS;
  } else {
    out->cvs = IS_NOT_CVS;
  }

  return 0;
}
@@ -1885,11 +1879,7 @@ tor_version_compare(tor_version_t *a, tor_version_t *b)
  else if ((i = a->patchlevel - b->patchlevel))
    return i;

  if (a->major > 0 || a->minor > 0) {
  return strcmp(a->status_tag, b->status_tag);
  } else {
    return (a->cvs - b->cvs);
  }
}

/** Return true iff versions <b>a</b> and <b>b</b> belong to the same series.
+0 −6
Original line number Diff line number Diff line
@@ -1387,35 +1387,30 @@ test_dir_format(void)
  test_eq(4, ver1.micro);
  test_eq(VER_PRE, ver1.status);
  test_eq(2, ver1.patchlevel);
  test_eq(IS_CVS, ver1.cvs);
  test_eq(0, tor_version_parse("0.3.4rc1", &ver1));
  test_eq(0, ver1.major);
  test_eq(3, ver1.minor);
  test_eq(4, ver1.micro);
  test_eq(VER_RC, ver1.status);
  test_eq(1, ver1.patchlevel);
  test_eq(IS_NOT_CVS, ver1.cvs);
  test_eq(0, tor_version_parse("1.3.4", &ver1));
  test_eq(1, ver1.major);
  test_eq(3, ver1.minor);
  test_eq(4, ver1.micro);
  test_eq(VER_RELEASE, ver1.status);
  test_eq(0, ver1.patchlevel);
  test_eq(IS_NOT_CVS, ver1.cvs);
  test_eq(0, tor_version_parse("1.3.4.999", &ver1));
  test_eq(1, ver1.major);
  test_eq(3, ver1.minor);
  test_eq(4, ver1.micro);
  test_eq(VER_RELEASE, ver1.status);
  test_eq(999, ver1.patchlevel);
  test_eq(IS_NOT_CVS, ver1.cvs);
  test_eq(0, tor_version_parse("0.1.2.4-alpha", &ver1));
  test_eq(0, ver1.major);
  test_eq(1, ver1.minor);
  test_eq(2, ver1.micro);
  test_eq(4, ver1.patchlevel);
  test_eq(VER_RELEASE, ver1.status);
  test_eq(IS_NOT_CVS, ver1.cvs);
  test_streq("alpha", ver1.status_tag);
  test_eq(0, tor_version_parse("0.1.2.4", &ver1));
  test_eq(0, ver1.major);
@@ -1423,7 +1418,6 @@ test_dir_format(void)
  test_eq(2, ver1.micro);
  test_eq(4, ver1.patchlevel);
  test_eq(VER_RELEASE, ver1.status);
  test_eq(IS_NOT_CVS, ver1.cvs);
  test_streq("", ver1.status_tag);

#define test_eq_vs(vs1, vs2) test_eq_type(version_status_t, "%d", (vs1), (vs2))