Fossil SCM
fossil_fclose() is now a no-op if passed stdin (as was initially intended).
Commit
7723a92f069102ae153e01912939ab7e60771c61ba032eed6c3f32c31916a439
Parent
83d02c01b4f2b51…
1 file changed
+6
-4
+6
-4
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1810,19 +1810,21 @@ | ||
| 1810 | 1810 | #endif |
| 1811 | 1811 | return f; |
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | 1814 | /* |
| 1815 | -** Works like fclose() except that is a no-op if f is 0 and it | |
| 1816 | -** flushes, but does not close, f if it is one of (stdout, stderr). | |
| 1815 | +** Works like fclose() except that: | |
| 1816 | +** | |
| 1817 | +** 1) is a no-op if f is 0 or if it is stdin. | |
| 1818 | +** | |
| 1819 | +** 2) If f is one of (stdout, stderr), it is flushed but not closed. | |
| 1817 | 1820 | */ |
| 1818 | 1821 | void fossil_fclose(FILE *f){ |
| 1819 | - | |
| 1820 | 1822 | if(f!=0){ |
| 1821 | 1823 | if(stdout==f || stderr==f){ |
| 1822 | 1824 | fflush(f); |
| 1823 | - }else{ | |
| 1825 | + }else if(stdin!=f){ | |
| 1824 | 1826 | fclose(f); |
| 1825 | 1827 | } |
| 1826 | 1828 | } |
| 1827 | 1829 | } |
| 1828 | 1830 | |
| 1829 | 1831 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1810,19 +1810,21 @@ | |
| 1810 | #endif |
| 1811 | return f; |
| 1812 | } |
| 1813 | |
| 1814 | /* |
| 1815 | ** Works like fclose() except that is a no-op if f is 0 and it |
| 1816 | ** flushes, but does not close, f if it is one of (stdout, stderr). |
| 1817 | */ |
| 1818 | void fossil_fclose(FILE *f){ |
| 1819 | |
| 1820 | if(f!=0){ |
| 1821 | if(stdout==f || stderr==f){ |
| 1822 | fflush(f); |
| 1823 | }else{ |
| 1824 | fclose(f); |
| 1825 | } |
| 1826 | } |
| 1827 | } |
| 1828 | |
| 1829 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1810,19 +1810,21 @@ | |
| 1810 | #endif |
| 1811 | return f; |
| 1812 | } |
| 1813 | |
| 1814 | /* |
| 1815 | ** Works like fclose() except that: |
| 1816 | ** |
| 1817 | ** 1) is a no-op if f is 0 or if it is stdin. |
| 1818 | ** |
| 1819 | ** 2) If f is one of (stdout, stderr), it is flushed but not closed. |
| 1820 | */ |
| 1821 | void fossil_fclose(FILE *f){ |
| 1822 | if(f!=0){ |
| 1823 | if(stdout==f || stderr==f){ |
| 1824 | fflush(f); |
| 1825 | }else if(stdin!=f){ |
| 1826 | fclose(f); |
| 1827 | } |
| 1828 | } |
| 1829 | } |
| 1830 | |
| 1831 |