Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'utils/nullstrcmp.c')
-rw-r--r--utils/nullstrcmp.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/nullstrcmp.c b/utils/nullstrcmp.c
new file mode 100644
index 00000000..a9e50f40
--- /dev/null
+++ b/utils/nullstrcmp.c
@@ -0,0 +1,21 @@
+/*
+ * Compare two strings, just like strcmp, except that we tolerate null
+ * pointers as a legal input, and define them to compare before any
+ * non-null string (even the empty string).
+ */
+
+#include <string.h>
+
+#include "defs.h"
+#include "misc.h"
+
+int nullstrcmp(const char *a, const char *b)
+{
+ if (a == NULL && b == NULL)
+ return 0;
+ if (a == NULL)
+ return -1;
+ if (b == NULL)
+ return +1;
+ return strcmp(a, b);
+}