Date: 05/31/98
- Next message: rasmus: "[PHP-DEV] CVS update: php31/ext/standard"
- Previous message: rasmus: "[PHP-DEV] CVS update: php3/doc/functions"
- Next in thread: rasmus: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sunday May 31, 1998 @ 9:15
Author: rasmus
Update of /repository/php3/functions
In directory asf:/tmp/cvs-serv23057/functions
Modified Files:
basic_functions.c php3_string.h string.c
Log Message:
Add trim() function - strips whitespace at the start of a string
Index: php3/functions/basic_functions.c
diff -c php3/functions/basic_functions.c:1.177 php3/functions/basic_functions.c:1.178
*** php3/functions/basic_functions.c:1.177 Sat May 30 09:05:26 1998
--- php3/functions/basic_functions.c Sun May 31 09:15:38 1998
***************
*** 127,132 ****
--- 127,133 ----
{"addslashes", php3_addslashes, NULL},
{"chop", php3_chop, NULL},
+ {"trim", php3_trim, NULL},
{"pos", array_current, first_arg_force_ref},
{"fsockopen", php3_fsockopen, NULL},
Index: php3/functions/php3_string.h
diff -c php3/functions/php3_string.h:1.15 php3/functions/php3_string.h:1.16
*** php3/functions/php3_string.h:1.15 Mon May 18 02:46:38 1998
--- php3/functions/php3_string.h Sun May 31 09:15:39 1998
***************
*** 29,35 ****
*/
! /* $Id: php3_string.h,v 1.15 1998/05/18 06:46:38 rasmus Exp $ */
#ifndef _PHPSTRING_H
#define _PHPSTRING_H
--- 29,35 ----
*/
! /* $Id: php3_string.h,v 1.16 1998/05/31 13:15:39 rasmus Exp $ */
#ifndef _PHPSTRING_H
#define _PHPSTRING_H
***************
*** 41,46 ****
--- 41,47 ----
extern void php3_strlen(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_strcmp(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_chop(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_trim(INTERNAL_FUNCTION_PARAMETERS);
extern void soundex(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_explode(INTERNAL_FUNCTION_PARAMETERS);
Index: php3/functions/string.c
diff -c php3/functions/string.c:1.119 php3/functions/string.c:1.120
*** php3/functions/string.c:1.119 Mon May 25 11:42:54 1998
--- php3/functions/string.c Sun May 31 09:15:40 1998
***************
*** 30,36 ****
*/
! /* $Id: string.c,v 1.119 1998/05/25 15:42:54 zeev Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 30,36 ----
*/
! /* $Id: string.c,v 1.120 1998/05/31 13:15:40 rasmus Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 98,103 ****
--- 98,131 ----
RETURN_FALSE;
}
+ void php3_trim(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval *str;
+ register int i;
+ TLS_VARS;
+
+ if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string(str);
+
+ if (str->type == IS_STRING) {
+ int len = str->value.str.len;
+ int trimmed = 0;
+ char *c = str->value.str.val;
+ for (i = 0; i <= len; i++) {
+ if (c[i] == ' ' || c[i] == '\n' || c[i] == '\r' ||
+ c[i] == '\t' || c[i] == '\v') {
+ trimmed++;
+ } else {
+ break;
+ }
+ }
+ RETVAL_STRINGL(c+trimmed, len-trimmed, 1);
+ return;
+ }
+ RETURN_FALSE;
+ }
void php3_explode(INTERNAL_FUNCTION_PARAMETERS)
{
- Next message: rasmus: "[PHP-DEV] CVS update: php31/ext/standard"
- Previous message: rasmus: "[PHP-DEV] CVS update: php3/doc/functions"
- Next in thread: rasmus: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

