瀏覽代碼

tagfile: Hardcode error message for out of range integer values

This makes the test suite work on 32 bit-long platforms.

Gbp-Dch: ignore
Julian Andres Klode 10 年之前
父節點
當前提交
137e8ad4b6
共有 2 個文件被更改,包括 4 次插入5 次删除
  1. 3 4
      apt-pkg/tagfile.cc
  2. 1 1
      test/integration/test-policy-pinning

+ 3 - 4
apt-pkg/tagfile.cc

@@ -537,11 +537,10 @@ signed int pkgTagSection::FindI(const char *Tag,signed long Default) const
    errno = 0;
    char *End;
    signed long Result = strtol(S,&End,10);
-   if (errno == ERANGE)
-      _error->Errno("strtol", _("Cannot convert %s to integer"), S);
-   if (Result < std::numeric_limits<int>::min() || Result > std::numeric_limits<int>::max()) {
+   if (errno == ERANGE ||
+       Result < std::numeric_limits<int>::min() || Result > std::numeric_limits<int>::max()) {
       errno = ERANGE;
-      _error->Errno("", _("Cannot convert %s to integer"), S);
+      _error->Error(_("Cannot convert %s to integer: out of range"), S);
    }
    if (S == End)
       return Default;

+ 1 - 1
test/integration/test-policy-pinning

@@ -302,7 +302,7 @@ Pin-Priority: 2147483648
 " > rootdir/etc/apt/preferences
 
 testfailureequal "Reading package lists...
-E: Cannot convert 2147483648 to integer -  (34: Numerical result out of range)
+E: Cannot convert 2147483648 to integer: out of range
 E: ${tmppath}/rootdir/etc/apt/preferences: Value 2147483648 is outside the range of valid pin priorities (-32768 to 32767)" \
  aptget install -s coolstuff -o PinPriority=2147483648