Commit 664c9f19 authored by Simon Latapie's avatar Simon Latapie

* http.c: little fix in RPN evaluator (now it is real RPN).

parent b03111a7
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* http.c : http mini-server ;) * http.c : http mini-server ;)
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: http.c,v 1.32 2003/11/12 02:43:33 garf Exp $ * $Id: http.c,v 1.33 2003/11/12 02:56:13 garf Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -2599,8 +2599,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2599,8 +2599,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
} }
else if( !strcmp( s, "-" ) ) else if( !strcmp( s, "-" ) )
{ {
int i = SSPopN( st, vars );
int j = SSPopN( st, vars ); int j = SSPopN( st, vars );
int i = SSPopN( st, vars );
SSPushN( st, i - j ); SSPushN( st, i - j );
} }
else if( !strcmp( s, "*" ) ) else if( !strcmp( s, "*" ) )
...@@ -2611,8 +2611,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2611,8 +2611,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
{ {
int i, j; int i, j;
i = SSPopN( st, vars );
j = SSPopN( st, vars ); j = SSPopN( st, vars );
i = SSPopN( st, vars );
SSPushN( st, j != 0 ? i / j : 0 ); SSPushN( st, j != 0 ? i / j : 0 );
} }
...@@ -2620,8 +2620,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2620,8 +2620,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
{ {
int i, j; int i, j;
i = SSPopN( st, vars );
j = SSPopN( st, vars ); j = SSPopN( st, vars );
i = SSPopN( st, vars );
SSPushN( st, j != 0 ? i % j : 0 ); SSPushN( st, j != 0 ? i % j : 0 );
} }
...@@ -2632,37 +2632,37 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2632,37 +2632,37 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
} }
else if( !strcmp( s, "<" ) ) else if( !strcmp( s, "<" ) )
{ {
int i = SSPopN( st, vars );
int j = SSPopN( st, vars ); int j = SSPopN( st, vars );
int i = SSPopN( st, vars );
SSPushN( st, i < j ? -1 : 0 ); SSPushN( st, i < j ? -1 : 0 );
} }
else if( !strcmp( s, ">" ) ) else if( !strcmp( s, ">" ) )
{ {
int i = SSPopN( st, vars );
int j = SSPopN( st, vars ); int j = SSPopN( st, vars );
int i = SSPopN( st, vars );
SSPushN( st, i > j ? -1 : 0 ); SSPushN( st, i > j ? -1 : 0 );
} }
else if( !strcmp( s, "<=" ) ) else if( !strcmp( s, "<=" ) )
{ {
int i = SSPopN( st, vars );
int j = SSPopN( st, vars ); int j = SSPopN( st, vars );
int i = SSPopN( st, vars );
SSPushN( st, i <= j ? -1 : 0 ); SSPushN( st, i <= j ? -1 : 0 );
} }
else if( !strcmp( s, ">=" ) ) else if( !strcmp( s, ">=" ) )
{ {
int i = SSPopN( st, vars );
int j = SSPopN( st, vars ); int j = SSPopN( st, vars );
int i = SSPopN( st, vars );
SSPushN( st, i >= j ? -1 : 0 ); SSPushN( st, i >= j ? -1 : 0 );
} }
/* 3. string functions */ /* 3. string functions */
else if( !strcmp( s, "strcat" ) ) else if( !strcmp( s, "strcat" ) )
{ {
char *s1 = SSPop( st );
char *s2 = SSPop( st ); char *s2 = SSPop( st );
char *s1 = SSPop( st );
char *str = malloc( strlen( s1 ) + strlen( s2 ) + 1 ); char *str = malloc( strlen( s1 ) + strlen( s2 ) + 1 );
strcpy( str, s1 ); strcpy( str, s1 );
...@@ -2675,8 +2675,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2675,8 +2675,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
} }
else if( !strcmp( s, "strcmp" ) ) else if( !strcmp( s, "strcmp" ) )
{ {
char *s1 = SSPop( st );
char *s2 = SSPop( st ); char *s2 = SSPop( st );
char *s1 = SSPop( st );
SSPushN( st, strcmp( s1, s2 ) ); SSPushN( st, strcmp( s1, s2 ) );
free( s1 ); free( s1 );
...@@ -2684,9 +2684,9 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2684,9 +2684,9 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
} }
else if( !strcmp( s, "strncmp" ) ) else if( !strcmp( s, "strncmp" ) )
{ {
char *s1 = SSPop( st );
char *s2 = SSPop( st );
int n = SSPopN( st, vars ); int n = SSPopN( st, vars );
char *s2 = SSPop( st );
char *s1 = SSPop( st );
SSPushN( st, strncmp( s1, s2 , n ) ); SSPushN( st, strncmp( s1, s2 , n ) );
free( s1 ); free( s1 );
...@@ -2729,8 +2729,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2729,8 +2729,8 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
} }
else if( !strcmp( s, "store" ) ) else if( !strcmp( s, "store" ) )
{ {
char *name = SSPop( st );
char *value = SSPop( st ); char *value = SSPop( st );
char *name = SSPop( st );
mvar_PushNewVar( vars, name, value ); mvar_PushNewVar( vars, name, value );
free( name ); free( name );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment