| 1865 | if unsuccessful. 0 means no limit on line length. */ |
| 1866 | |
| 1867 | static ptrdiff_t |
| 1868 | decode_line_length (char const *spec) |
| 1869 | { |
| 1870 | uintmax_t val; |
| 1871 | |
| 1872 | /* Treat too-large values as if they were 0, which is |
| 1873 | effectively infinity. */ |
| 1874 | switch (xstrtoumax (spec, NULL, 0, &val, "")) |
| 1875 | { |
| 1876 | case LONGINT_OK: |
| 1877 | return val <= MIN (PTRDIFF_MAX, SIZE_MAX) ? val : 0; |
| 1878 | |
| 1879 | case LONGINT_OVERFLOW: |
| 1880 | return 0; |
| 1881 | |
| 1882 | case LONGINT_INVALID: |
| 1883 | case LONGINT_INVALID_SUFFIX_CHAR: |
| 1884 | case LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW: |
| 1885 | return -1; |
| 1886 | |
| 1887 | default: |
| 1888 | unreachable (); |
| 1889 | } |
| 1890 | } |
| 1891 | |
| 1892 | /* Return true if standard output is a tty, caching the result. */ |
| 1893 | |