[Pkg-wmaker-commits] [wmbiff] 06/09: factor out comment stripping for testing, which seems to have passed
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:05:27 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to tag wmbiff_0_4_23
in repository wmbiff.
commit c5d384d828c96a787bd2c804f18af303c01330eb
Author: bluehal <bluehal>
Date: Tue Apr 20 04:55:46 2004 +0000
factor out comment stripping for testing, which seems to have passed
---
wmbiff/charutil.c | 17 ++++++++++++++++-
wmbiff/charutil.h | 4 +++-
wmbiff/test_wmbiff.c | 28 ++++++++++++++++++++++++++++
wmbiff/wmbiff.c | 14 ++++----------
4 files changed, 51 insertions(+), 12 deletions(-)
diff --git a/wmbiff/charutil.c b/wmbiff/charutil.c
index ba79a78..896c81e 100644
--- a/wmbiff/charutil.c
+++ b/wmbiff/charutil.c
@@ -1,4 +1,4 @@
-/* $Id: charutil.c,v 1.17 2004/03/28 00:28:58 bluehal Exp $ */
+/* $Id: charutil.c,v 1.18 2004/04/20 04:55:46 bluehal Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -244,6 +244,21 @@ char *strdup_ordie(const char *c)
return (ret);
}
+void StripComment(char *buf) {
+ char *p;
+
+ /* Strip comments at beginning of line, or after whitespace.
+ a kludgy way of avoiding problems with #'s in passwords. */
+ if (buf[0] == '#')
+ buf[0] = '\0';
+ for (p = (char *) buf + 1; *p && !(*p == '#' && isspace(*(p - 1)));
+ p++);
+ if (*p) {
+ *p = '\0';
+ }
+}
+
+
/* vim:set ts=4: */
/*
* Local Variables:
diff --git a/wmbiff/charutil.h b/wmbiff/charutil.h
index 85535e3..cbd687e 100644
--- a/wmbiff/charutil.h
+++ b/wmbiff/charutil.h
@@ -1,4 +1,4 @@
-/* $Id: charutil.h,v 1.11 2003/01/28 11:12:43 bluehal Exp $ */
+/* $Id: charutil.h,v 1.12 2004/04/20 04:55:55 bluehal Exp $ */
/* Author: Mark Hurley (debian4tux at telocity.com)
*
* Character / string manipulation utilities.
@@ -41,4 +41,6 @@ void chomp(char *s);
/* same as xstrdup, just better named ;) */
char *strdup_ordie(const char *c);
+
+void StripComment(char *buf);
#endif
diff --git a/wmbiff/test_wmbiff.c b/wmbiff/test_wmbiff.c
index 31f995d..5c2ef8b 100644
--- a/wmbiff/test_wmbiff.c
+++ b/wmbiff/test_wmbiff.c
@@ -21,6 +21,7 @@
#include "Client.h"
#include "passwordMgr.h"
#include "tlsComm.h"
+#include "charutil.h"
int debug_default = DEBUG_INFO;
int Relax = 1;
@@ -324,6 +325,28 @@ int test_getline_from_buffer(void)
return (0);
}
+int test_charutil(void) {
+
+ char *v = strdup("abc#def");
+
+ StripComment(v);
+ if(strcmp(v, "abc#def") != 0) {
+ printf("FAILURE: comment stripper stripped when it shouldn't\n");
+ return 1;
+ }
+
+ v = strdup("abc #def");
+
+ StripComment(v);
+ if(strcmp(v, "abc ") != 0) {
+ printf("FAILURE: comment stripper should've stripped\n");
+ return 1;
+ }
+
+
+ return 0;
+}
+
int print_info(UNUSED(void *state))
{
@@ -371,6 +394,11 @@ int main(UNUSED(int argc), UNUSED(char *argv[]))
exit(EXIT_FAILURE);
}
+ if (test_charutil()) {
+ printf("SOME TESTS FAILED!\n");
+ exit(EXIT_FAILURE);
+ }
+
printf("Success! on all tests.\n");
exit(EXIT_SUCCESS);
}
diff --git a/wmbiff/wmbiff.c b/wmbiff/wmbiff.c
index 1e80124..4e4e7ce 100644
--- a/wmbiff/wmbiff.c
+++ b/wmbiff/wmbiff.c
@@ -1,4 +1,4 @@
-/* $Id: wmbiff.c,v 1.61 2004/03/28 00:28:58 bluehal Exp $ */
+/* $Id: wmbiff.c,v 1.62 2004/04/20 04:55:55 bluehal Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -161,15 +161,9 @@ static int ReadLine(FILE * fp, /*@out@ */ char *setting,
if (buf[len - 1] == '\n') {
buf[len - 1] = '\0'; /* strip linefeed */
}
- /* Strip comments at beginning of line, or after whitespace.
- a kludgy way of avoiding problems with #'s in passwords. */
- if (buf[0] == '#')
- buf[0] = '\0';
- for (p = (char *) buf + 1; *p && !(*p == '#' && isspace(*(p - 1)));
- p++);
- if (*p) {
- *p = '\0';
- }
+
+ StripComment(buf);
+
if (!(p = strtok(buf, "=")))
return -1;
if (!(q = strtok(NULL, "\n")))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git
More information about the Pkg-wmaker-commits
mailing list