diff options
author | dscho <dscho> | 2004-03-22 08:40:51 +0000 |
---|---|---|
committer | dscho <dscho> | 2004-03-22 08:40:51 +0000 |
commit | 6a1a59f90e8aa12ee50aaad0244a9f1ad1d85900 (patch) | |
tree | 638fa4305c45ddad116a357cf3cfc1ce88f4d6a4 | |
parent | 5df82de5ce647592f6256b5c1b199cec775f9ce8 (diff) | |
download | libtdevnc-6a1a59f90e8aa12ee50aaad0244a9f1ad1d85900.tar.gz libtdevnc-6a1a59f90e8aa12ee50aaad0244a9f1ad1d85900.zip |
fix cargs.c: arguments were not correctly purged.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | cargs.c | 23 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/cargstest.c | 29 |
4 files changed, 45 insertions, 13 deletions
@@ -1,3 +1,7 @@ +2004-03-22 Johannes E. Schindelin <Johannes.Schindelin@gmx.de> + * fix cargs.c (hopefully for the last time): + arguments were not correctly purged + 2004-03-15 Johannes E. Schindelin <Johannes.Schindelin@gmx.de> * fix libvncserver-config to again return a linker when called with --link @@ -46,7 +46,6 @@ void rfbPurgeArguments(int* argc,int* position,int count,char *argv[]) if(amount) memmove(argv+(*position),argv+(*position)+count,sizeof(char*)*amount); (*argc)-=count; - (*position)--; } rfbBool @@ -127,11 +126,12 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]) } rfbScreen->progressiveSliceHeight = atoi(argv[++i]); } else { - /* we just remove the processed arguments from the list */ - if(i != i1) - rfbPurgeArguments(argc,&i1,i-i1,argv); - } - i1++; + i++; + i1=i; + continue; + } + /* we just remove the processed arguments from the list */ + rfbPurgeArguments(argc,&i1,i-i1+1,argv); i=i1; } return TRUE; @@ -157,12 +157,11 @@ rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[]) } else if (strcmp(argv[i], "-height") == 0) { *height = atoi(argv[++i]); } else { - /* we just remove the processed arguments from the list */ - if(i != i1) - if(i != i1) - rfbPurgeArguments(argc,&i1,i-i1,argv); - } - i1++; + i++; + i1=i; + continue; + } + rfbPurgeArguments(argc,&i1,i-i1,argv); i=i1; } return TRUE; diff --git a/test/Makefile.am b/test/Makefile.am index 8c04810..c250fe6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ CFLAGS=-I.. -g -Wall -noinst_PROGRAMS=tight-1 +noinst_PROGRAMS=tight-1 cargstest LDADD = ../libvncserver.a ../libvncclient/libvncclient.a diff --git a/test/cargstest.c b/test/cargstest.c new file mode 100644 index 0000000..2eadce7 --- /dev/null +++ b/test/cargstest.c @@ -0,0 +1,29 @@ +#include <rfb/rfb.h> + +int main(int argc,char** argv) +{ + int fake_argc=6; + char* fake_argv[6]={ + "dummy_program","-alwaysshared","-httpport","3002","-nothing","-dontdisconnect" + }; + rfbScreenInfoPtr screen; + rfbBool ret=0; + + screen = rfbGetScreen(&fake_argc,fake_argv,1024,768,8,3,1); +#define CHECK(a,b) if(screen->a!=b) { fprintf(stderr,#a " is %d (should be " #b ")\n",screen->a); ret=1; } + CHECK(width,1024); + CHECK(height,768); + CHECK(rfbAlwaysShared,TRUE); + CHECK(httpPort,3002); + CHECK(rfbDontDisconnect,TRUE); + if(fake_argc!=2) { + fprintf(stderr,"fake_argc is %d (should be 2)\n",fake_argc); + ret=1; + } + if(strcmp(fake_argv[1],"-nothing")) { + fprintf(stderr,"fake_argv[1] is %s (should be -nothing)\n",fake_argv[1]); + ret=1; + } + return ret; +} + |