Enlightenment CVS committal
Author : tsauerbeck
Project : misc
Module : embrace
Dir : misc/embrace/src
Modified Files:
embrace.c embrace.h
Log Message:
added embrace_strstrip()
===================================================================
RCS file: /cvsroot/enlightenment/misc/embrace/src/embrace.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- embrace.c 4 Apr 2004 20:24:07 -0000 1.5
+++ embrace.c 9 Apr 2004 09:35:16 -0000 1.6
@@ -1,5 +1,5 @@
/*
- * $Id: embrace.c,v 1.5 2004/04/04 20:24:07 tsauerbeck Exp $
+ * $Id: embrace.c,v 1.6 2004/04/09 09:35:16 tsauerbeck Exp $
*
* Copyright (C) 2004 Embrace project.
*
@@ -26,6 +26,8 @@
#include <Esmart/dragable.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -68,6 +70,45 @@
*dest++ = 0;
}
+/**
+ * Remove leading and trailing whitespace
+ *
+ * @param str
+ * @return Trimmed string.
+ */
+char *embrace_strstrip (char *str)
+{
+ char *start, *ptr = str;
+
+ assert (str);
+
+ if (!strlen (str))
+ return str;
+
+ /* step over leading whitespace */
+ for (start = str; isspace (*start); start++);
+
+ if (str != start) {
+ while ((*ptr++ = *start++));
+ *ptr = 0;
+ }
+
+ if (!strlen (str))
+ return str;
+
+ ptr = &str[strlen (str) - 1];
+
+ if (!isspace (*ptr))
+ return str;
+
+ while (isspace (*ptr) && ptr > str)
+ ptr--;
+
+ ptr[1] = 0;
+
+ return str;
+}
+
static EmbracePlugin *find_plugin (Embrace *e, const char *name)
{
EmbracePlugin *ep;
===================================================================
RCS file: /cvsroot/enlightenment/misc/embrace/src/embrace.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- embrace.h 1 Apr 2004 18:29:36 -0000 1.2
+++ embrace.h 9 Apr 2004 09:35:16 -0000 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: embrace.h,v 1.2 2004/04/01 18:29:36 tsauerbeck Exp $
+ * $Id: embrace.h,v 1.3 2004/04/09 09:35:16 tsauerbeck Exp $
*
* Copyright (C) 2004 Embrace project.
*
@@ -58,5 +58,6 @@
int embrace_signal_get ();
void embrace_expand_path (char *str, char *dest, int destlen);
+char *embrace_strstrip (char *str);
#endif
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs