annotate gui/skin/cut.c @ 24938:328a5d99203e

Fix previous incorrect commit, +/- has higher precedence than shifts.
author diego
date Sun, 04 Nov 2007 13:41:07 +0000
parents 17bf4f4b0715
children b0a7b35b78d2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
2 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
3 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
4
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
5 void cutItem( char * in,char * out,char sep,int num )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
6 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
7 int i,n,c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
8 for ( c=0,n=0,i=0;i<strlen( in );i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
9 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
10 if ( in[i] == sep ) n++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
11 if ( n >= num && in[i] != sep ) out[c++]=in[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
12 if ( n >= num && in[i+1] == sep ) { out[c]=0; return; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
13 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
14 out[c]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
15 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
16
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
17 int cutItemToInt( char * in,char sep,int num )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
18 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
19 char tmp[512];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
20 cutItem( in,tmp,sep,num );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
21 return atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 float cutItemToFloat( char * in,char sep,int num )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 char tmp[512];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 cutItem( in,tmp,sep,num );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28 return atof( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
30
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
31 void cutChunk( char * in,char * s1 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
32 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33 cutItem( in,s1,'=',0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34 memmove( in,strchr( in,'=' )+1,strlen( in ) - strlen( s1 ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
36