Zend/zend_operators.c
/* this should be a function, not an operator... move me */
this should be a function, not an operator... move me
this should be a function not an operator ... move me
static void increment_string(zval *str)
{
    int carry=0;
    int pos=str->value.str.len-1;
    char *s=str->value.str.val;
    char *t;
    int last=0; 
    int ch;
	if (str->value.str.len == 0) {
		STR_FREE(str->value.str.val);
		str->value.str.val = estrndup("1", sizeof("1")-1);
		str->value.str.len = 1;
		return;
	}
	while (pos >= 0) {
        ch = s[pos];
        if (ch >= 'a' && ch <= 'z') {
            if (ch == 'z') {
                s[pos] = 'a';
                carry=1;
            } else {
                s[pos]++;
                carry=0;
            }
            last=LOWER_CASE;
        } else if (ch >= 'A' && ch <= 'Z') {
            if (ch == 'Z') {
                s[pos] = 'A';
                carry=1;
            } else {
                s[pos]++;
                carry=0;
            }
            last=UPPER_CASE;
        } else if (ch >= '0' && ch <= '9') {
            if (ch == '9') {
                s[pos] = '0';
                carry=1;
            } else {
                s[pos]++;
                carry=0;
            }
            last = NUMERIC;
        } else {
            carry=0;
            break;
        }
        if (carry == 0) {
            break;
        }
        pos--;
    }
    if (carry) {
        t = (char *) emalloc(str->value.str.len+1+1);
        memcpy(t+1, str->value.str.val, str->value.str.len);
        str->value.str.len++;
        t[str->value.str.len] = '\0';
        switch (last) {
            case NUMERIC:
            	t[0] = '1';
            	break;
            case UPPER_CASE:
            	t[0] = 'A';
            	break;
            case LOWER_CASE:
            	t[0] = 'a';
            	break;
        }
        STR_FREE(str->value.str.val);
        str->value.str.val = t;
    }
}
static void increment_string ( zval * str ) { int carry = 0 ; int pos = str -> value . str . len - 1 ; char * s = str -> value . str . val ; char * t ; int last = 0 ; int ch ; if ( str -> value . str . len == 0 ) { STR_FREE ( str -> value . str . val ) ; str -> value . str . val = estrndup ( " " , sizeof ( " " ) - 1 ) ; str -> value . str . len = 1 ; return ; } while ( pos >= 0 ) { ch = s [ pos ] ; if ( ch >= ' ' && ch <= ' ' ) { if ( ch == ' ' ) { s [ pos ] = ' ' ; carry = 1 ; } else { s [ pos ] ++ ; carry = 0 ; } last = LOWER_CASE ; } else if ( ch >= ' ' && ch <= ' ' ) { if ( ch == ' ' ) { s [ pos ] = ' ' ; carry = 1 ; } else { s [ pos ] ++ ; carry = 0 ; } last = UPPER_CASE ; } else if ( ch >= ' ' && ch <= ' ' ) { if ( ch == ' ' ) { s [ pos ] = ' ' ; carry = 1 ; } else { s [ pos ] ++ ; carry = 0 ; } last = NUMERIC ; } else { carry = 0 ; break ; } if ( carry == 0 ) { break ; } pos -- ; } if ( carry ) { t = ( char * ) emalloc ( str -> value . str . len + 1 + 1 ) ; memcpy ( t + 1 , str -> value . str . val , str -> value . str . len ) ; str -> value . str . len ++ ; t [ str -> value . str . len ] = ' \0 ' ; switch ( last ) { case NUMERIC : t [ 0 ] = ' ' ; break ; case UPPER_CASE : t [ 0 ] = ' ' ; break ; case LOWER_CASE : t [ 0 ] = ' ' ; break ; } STR_FREE ( str -> value . str . val ) ; str -> value . str . val = t ; } }
this should be a function, not an operator... move me
this should be a function not an operator ... move me
/* Shut up the compiler warning */