Fossil SCM

fossil_fclose() is now a no-op if passed stdin (as was initially intended).

stephan 2020-01-29 07:10 trunk
Commit 7723a92f069102ae153e01912939ab7e60771c61ba032eed6c3f32c31916a439
1 file changed +6 -4
+6 -4
--- src/file.c
+++ src/file.c
@@ -1810,19 +1810,21 @@
18101810
#endif
18111811
return f;
18121812
}
18131813
18141814
/*
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.
18171820
*/
18181821
void fossil_fclose(FILE *f){
1819
-
18201822
if(f!=0){
18211823
if(stdout==f || stderr==f){
18221824
fflush(f);
1823
- }else{
1825
+ }else if(stdin!=f){
18241826
fclose(f);
18251827
}
18261828
}
18271829
}
18281830
18291831
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button