Date: 05/31/98
- Next message: rasmus: "[PHP-DEV] CVS update: php3/doc/functions"
- Previous message: rasmus: "[PHP-DEV] CVS update: php3/functions"
- Next in thread: rasmus: "[PHP-DEV] CVS update: php31/ext/standard"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sunday May 31, 1998 @ 9:19
Author: rasmus
Update of /repository/php31/ext/standard
In directory asf:/tmp/cvs-serv23174/ext/standard
Modified Files:
basic_functions.c php3_string.h string.c
Log Message:
Add trim() function to 3.1 tree
Index: php31/ext/standard/basic_functions.c
diff -c php31/ext/standard/basic_functions.c:1.6 php31/ext/standard/basic_functions.c:1.7
*** php31/ext/standard/basic_functions.c:1.6 Sat May 30 17:46:54 1998
--- php31/ext/standard/basic_functions.c Sun May 31 09:19:03 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: php31/ext/standard/php3_string.h
diff -c php31/ext/standard/php3_string.h:1.1.1.1 php31/ext/standard/php3_string.h:1.2
*** php31/ext/standard/php3_string.h:1.1.1.1 Tue May 26 22:26:59 1998
--- php31/ext/standard/php3_string.h Sun May 31 09:19:04 1998
***************
*** 29,35 ****
*/
! /* $Id: php3_string.h,v 1.1.1.1 1998/05/27 02:26:59 rasmus Exp $ */
#ifndef _PHPSTRING_H
#define _PHPSTRING_H
--- 29,35 ----
*/
! /* $Id: php3_string.h,v 1.2 1998/05/31 13:19:04 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: php31/ext/standard/string.c
diff -c php31/ext/standard/string.c:1.2 php31/ext/standard/string.c:1.3
*** php31/ext/standard/string.c:1.2 Wed May 27 23:25:28 1998
--- php31/ext/standard/string.c Sun May 31 09:19:04 1998
***************
*** 30,36 ****
*/
! /* $Id: string.c,v 1.2 1998/05/28 03:25:28 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 30,36 ----
*/
! /* $Id: string.c,v 1.3 1998/05/31 13:19:04 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: php3/doc/functions"
- Previous message: rasmus: "[PHP-DEV] CVS update: php3/functions"
- Next in thread: rasmus: "[PHP-DEV] CVS update: php31/ext/standard"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

