Mercurial > mplayer.hg
annotate gui/skin/cut.c @ 32826:9ce10a293f56
Simplify array initialization.
author | ib |
---|---|
date | Wed, 16 Feb 2011 17:19:28 +0000 |
parents | 180883b8a488 |
children | 904d9843ffb6 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <string.h> | |
20 #include <stdlib.h> | |
21 | |
30529 | 22 #include "cut.h" |
23 | |
32811 | 24 void cutItemString( char * in,char * out,char sep,int num,size_t maxout ) |
23077 | 25 { |
32816 | 26 int n; |
27 unsigned int i,c; | |
23077 | 28 for ( c=0,n=0,i=0;i<strlen( in );i++ ) |
29 { | |
30 if ( in[i] == sep ) n++; | |
32815 | 31 if ( n >= num && in[i] != sep && c + 1 < maxout ) out[c++] = in[i]; |
32811 | 32 if ( n >= num && in[i+1] == sep ) break; |
23077 | 33 } |
32811 | 34 if ( c < maxout ) out[c] = '\0'; |
23077 | 35 } |
36 | |
37 int cutItemToInt( char * in,char sep,int num ) | |
38 { | |
32813 | 39 char tmp[64]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
40 cutItem( in,tmp,sep,num ); |
23077 | 41 return atoi( tmp ); |
42 } |