From f7aadb3341de6bbbffc4f4bd78d0bc22fa58176f Mon Sep 17 00:00:00 2001
From: namark <nshan.nnnn@gmail.com>
Date: Mon, 8 Jan 2018 03:16:54 +0400
Subject: [PATCH] Using perror to report errno errors.

---
 crop.cpp     |  3 +--
 diff.cpp     |  4 +---
 glue.cpp     |  3 +--
 pop_test.cpp | 31 +++++++++++++++++++++++++++++++
 shred.cpp    |  3 +--
 swap.cpp     |  3 +--
 6 files changed, 36 insertions(+), 11 deletions(-)
 create mode 100644 pop_test.cpp

diff --git a/crop.cpp b/crop.cpp
index 00c23d0..7888e98 100644
--- a/crop.cpp
+++ b/crop.cpp
@@ -2,7 +2,6 @@
 #include <iostream>
 #include <iomanip>
 #include <string>
-#include <cstring>
 #include "simple/file.hpp"
 #include "simple/support/enum.hpp"
 
@@ -194,6 +193,6 @@ int main(int argc, char const* argv[]) try
 catch(...)
 {
 	if(errno)
-		std::cout << "Oh nooo! " << std::strerror(errno) << '\n';
+		std::perror("Oh nooo!");
 	throw;
 }
diff --git a/diff.cpp b/diff.cpp
index a686f38..001657d 100644
--- a/diff.cpp
+++ b/diff.cpp
@@ -1,7 +1,5 @@
 #include <iostream>
 #include <algorithm>
-#include <cmath>
-#include <cstring>
 #include "simple/file.hpp"
 #include "simple/geom/vector.hpp"
 #include "simple/support/arithmetic.hpp"
@@ -95,6 +93,6 @@ int main(int argc, char const* argv[]) try
 }
 catch(...)
 {
-	if(errno) std::cout << "Oh nooo! " << std::strerror(errno) << '\n';
+	if(errno) std::perror("Oh nooo!");
 	throw;
 }
diff --git a/glue.cpp b/glue.cpp
index a6bd8ca..236e77d 100644
--- a/glue.cpp
+++ b/glue.cpp
@@ -1,5 +1,4 @@
 #include <iostream>
-#include <cstring>
 #include "simple/file.hpp"
 
 using namespace std;
@@ -54,6 +53,6 @@ int main(int argc, char const * argv[]) try
 catch(...)
 {
 	if(errno)
-		std::cout << "Oh nooo! " << std::strerror(errno) << '\n';
+		std::perror("Oh nooo!");
 	throw;
 }
diff --git a/pop_test.cpp b/pop_test.cpp
new file mode 100644
index 0000000..9c70f5b
--- /dev/null
+++ b/pop_test.cpp
@@ -0,0 +1,31 @@
+#include "simple/file.hpp"
+#include <string>
+#include <iostream>
+
+using namespace std;
+using namespace simple;
+using file::string_stack::pop;
+using file::string_stack::push;
+
+int main()
+{
+	string one, two;
+	string command;
+	while(cin >> one)
+	{
+		cout << one << "\n\n";
+		while(cin >> command)
+		{
+			if("pop" == command)
+				push( two, pop(one) );
+			else if("push" == command)
+				push( one, pop(two) );
+			cout << "one: " << one << '\n';
+			cout << "two: " << two << "\n\n";
+		}
+		two.clear();
+		cin.ignore();
+		cin.clear();
+	}
+	return 0;
+}
diff --git a/shred.cpp b/shred.cpp
index b2e08b1..443479f 100644
--- a/shred.cpp
+++ b/shred.cpp
@@ -5,7 +5,6 @@
 #include <map>
 #include <functional>
 #include <algorithm>
-#include <cstring>
 
 #include "simple/file.hpp"
 #include "simple/support/enum.hpp"
@@ -147,6 +146,6 @@ int main(int argc, char const * argv[]) try
 catch(...)
 {
 	if(errno)
-		std::cout << "Oh nooo! " << std::strerror(errno) << '\n';
+		std::perror("Oh nooo!");
 	throw;
 }
diff --git a/swap.cpp b/swap.cpp
index 98c9b29..1023b31 100644
--- a/swap.cpp
+++ b/swap.cpp
@@ -1,5 +1,4 @@
 #include <iostream>
-#include <cstring>
 #include "simple/file.hpp"
 
 using namespace simple;
@@ -35,6 +34,6 @@ int main(int argc, char const* argv[]) try
 catch(...)
 {
 	if(errno)
-		std::cout << "Oh nooo! " << std::strerror(errno) << '\n';
+		std::perror("Oh nooo!");
 	throw;
 }
-- 
GitLab